From e1dc349d6bc117b5db8b8229804c3600ae57da0a Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 14 Jul 2012 12:03:31 +0200 Subject: Review boomarks management Maybe this is a bit risky before release, but this lets us adding a bookmarks shortcut (CTRL+D) as used in the major browsers. With this commit, rekonq doubles this behavior. BUG: 303445 --- src/bookmarks/bookmarkmanager.cpp | 3 --- src/mainwindow.cpp | 11 +++++++++++ src/mainwindow.h | 3 +++ src/urlbar/urlbar.cpp | 21 ++++++++++++++------- src/urlbar/urlbar.h | 7 ++++++- src/webview.cpp | 2 +- 6 files changed, 35 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/bookmarks/bookmarkmanager.cpp b/src/bookmarks/bookmarkmanager.cpp index 3ccb09a5..33f3c662 100644 --- a/src/bookmarks/bookmarkmanager.cpp +++ b/src/bookmarks/bookmarkmanager.cpp @@ -78,9 +78,6 @@ BookmarkManager::BookmarkManager(QObject *parent) // bookmarks loading connect(this, SIGNAL(openUrl(KUrl, Rekonq::OpenType)), rApp, SLOT(loadUrl(KUrl, Rekonq::OpenType))); - - KAction *a = KStandardAction::addBookmark(m_owner, SLOT(bookmarkCurrentPage()), this); - m_actionCollection->addAction(QL1S("rekonq_add_bookmark"), a); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index a3b222b3..ad11e1af 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -401,6 +401,11 @@ void MainWindow::setupActions() tabAction->setDelayed(false); actionCollection()->addAction(QL1S("tab_list"), tabAction); + // ============================== Bookmark ======================================= + a = KStandardAction::addBookmark(this, SLOT(bookmarkCurrentPage()), actionCollection()); + KShortcut bkShortcut(Qt::CTRL + Qt::Key_D); + a->setShortcut(bkShortcut); + //================================Download======================================== a = new KAction(KIcon("download"), i18n("Downloads"), this); a->setShortcut(KShortcut(Qt::CTRL + Qt::Key_J)); @@ -1669,3 +1674,9 @@ void MainWindow::loadCheckedUrl(const KUrl& url, const Rekonq::OpenType& type, Q } } } + + +void MainWindow::bookmarkCurrentPage() +{ + currentTab()->urlBar()->manageBookmarks(); +} diff --git a/src/mainwindow.h b/src/mainwindow.h index e7e03053..1382046b 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -196,6 +196,9 @@ private Q_SLOTS: void toggleBookmarkBarVisible(bool); + // add bookmark + void bookmarkCurrentPage(); + /** * This is for the things to do ABSOLUTELY AFTER ctor launch: * the less, the better. diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp index f3d759f7..21debceb 100644 --- a/src/urlbar/urlbar.cpp +++ b/src/urlbar/urlbar.cpp @@ -372,7 +372,7 @@ void UrlBar::loadFinished() // show bookmark info IconButton *bt = addRightIcon(UrlBar::BK); - connect(bt, SIGNAL(clicked(QPoint)), this, SLOT(manageBookmarks(QPoint))); + connect(bt, SIGNAL(clicked(QPoint)), this, SLOT(manageBookmarks())); // show favorite icon IconButton *fbt = addRightIcon(UrlBar::Favorite); @@ -697,12 +697,8 @@ void UrlBar::delSlot() } -void UrlBar::manageBookmarks(QPoint pos) +void UrlBar::manageBookmarks() { - IconButton *bt = qobject_cast(this->sender()); - if (!bt) - return; - if (_tab->url().scheme() == QL1S("about")) return; @@ -713,8 +709,19 @@ void UrlBar::manageBookmarks(QPoint pos) bookmark = rApp->bookmarkManager()->owner()->bookmarkCurrentPage(); } + // calculate position + int iconSize = IconSize(KIconLoader::Small) + c_iconMargin; + + // Add a generic 10 to move it a bit below and right. + // No need to be precise... + int iconWidth = 10 + width() - ((iconSize + c_iconMargin)); + int iconHeight = 10 + (height() - iconSize) / 2; + + QPoint p = mapToGlobal(QPoint(iconWidth, iconHeight)); + + // show bookmark widget BookmarkWidget *widget = new BookmarkWidget(bookmark, window()); - widget->showAt(pos); + widget->showAt(p); } diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h index fadd2f95..b2cf44ac 100644 --- a/src/urlbar/urlbar.h +++ b/src/urlbar/urlbar.h @@ -95,6 +95,12 @@ public: public Q_SLOTS: void setQUrl(const QUrl &url); + /** + * Let us add bookmarks as the major browsers do + * + */ + void manageBookmarks(); + private Q_SLOTS: void loadRequestedUrl(const KUrl& url, Rekonq::OpenType = Rekonq::CurrentTab); @@ -106,7 +112,6 @@ private Q_SLOTS: void detectTypedString(const QString &); void suggest(); - void manageBookmarks(QPoint); void manageFavorites(QPoint); void refreshFavicon(); diff --git a/src/webview.cpp b/src/webview.cpp index 4ebd5a9b..00112d61 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -405,7 +405,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) } else { - a = rApp->bookmarkManager()->actionByName("rekonq_add_bookmark"); + a = mainwindow->actionByName(KStandardAction::name(KStandardAction::AddBookmark)); menu.addAction(a); } menu.addAction(sendByMailAction); -- cgit v1.2.1