From c18a4bf0e5561ec97ef299a0992f267905021c66 Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Sun, 22 Aug 2010 14:09:41 +0200 Subject: - Move the BK bar context menu slot and connection to BookmarkContextMenu - The context menu now works without selected bookmark in the BK bar --- src/bookmarks/bookmarkprovider.cpp | 20 -------------------- src/bookmarks/bookmarkprovider.h | 6 ------ src/bookmarks/bookmarkstoolbar.cpp | 16 ++++++++++++++++ src/bookmarks/bookmarkstoolbar.h | 1 + 4 files changed, 17 insertions(+), 26 deletions(-) (limited to 'src/bookmarks') diff --git a/src/bookmarks/bookmarkprovider.cpp b/src/bookmarks/bookmarkprovider.cpp index 41704f58..7bfb608b 100644 --- a/src/bookmarks/bookmarkprovider.cpp +++ b/src/bookmarks/bookmarkprovider.cpp @@ -109,8 +109,6 @@ void BookmarkProvider::registerBookmarkBar(BookmarkToolBar *toolbar) kDebug() << "new bookmark bar..."; m_bookmarkToolBars.append(toolbar); - toolbar->toolBar()->setContextMenuPolicy(Qt::CustomContextMenu); - connect(toolbar->toolBar(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(contextMenu(const QPoint&))); kDebug() << "new bookmark bar... DONE!"; } @@ -183,24 +181,6 @@ KBookmark BookmarkProvider::bookmarkForUrl(const KUrl &url) } -void BookmarkProvider::contextMenu(const QPoint &point) -{ - if (m_bookmarkToolBars.isEmpty()) - return; - - KToolBar *bookmarkToolBar = m_bookmarkToolBars.at(0)->toolBar(); - if (!bookmarkToolBar) - return; - - KBookmarkActionInterface *action = dynamic_cast(bookmarkToolBar->actionAt(point)); - if (!action) - return; - - BookmarksContextMenu menu(action->bookmark(), bookmarkManager(), bookmarkOwner()); - menu.exec(bookmarkToolBar->mapToGlobal(point)); -} - - void BookmarkProvider::slotBookmarksChanged(const QString& /*groupAddress*/, const QString& /*caller*/) { foreach(BookmarkToolBar *bookmarkToolBar, m_bookmarkToolBars) diff --git a/src/bookmarks/bookmarkprovider.h b/src/bookmarks/bookmarkprovider.h index e21bd227..36724d75 100644 --- a/src/bookmarks/bookmarkprovider.h +++ b/src/bookmarks/bookmarkprovider.h @@ -122,12 +122,6 @@ signals: public slots: - /** - * @short Opens the context menu on given position - * @param point Point on which you want to open this menu - */ - void contextMenu(const QPoint &point); - /** * @short Waits for signal that the group with the address has been modified by the caller. * Waits for signal that the group (or any of its children) with the address diff --git a/src/bookmarks/bookmarkstoolbar.cpp b/src/bookmarks/bookmarkstoolbar.cpp index 64e9c3b9..bc307965 100644 --- a/src/bookmarks/bookmarkstoolbar.cpp +++ b/src/bookmarks/bookmarkstoolbar.cpp @@ -166,6 +166,8 @@ BookmarkToolBar::BookmarkToolBar(KToolBar *toolBar, QObject *parent) , m_dropAction(0) , m_filled(false) { + toolBar->setContextMenuPolicy(Qt::CustomContextMenu); + connect(toolBar, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenu(const QPoint &))); connect(Application::bookmarkProvider()->bookmarkManager(), SIGNAL(changed(QString, QString)), this, SLOT(hideMenu())); toolBar->setAcceptDrops(true); toolBar->installEventFilter(this); @@ -189,6 +191,20 @@ KToolBar* BookmarkToolBar::toolBar() } +void BookmarkToolBar::contextMenu(const QPoint &point) +{ + KBookmarkActionInterface *action = dynamic_cast(toolBar()->actionAt(point)); + KBookmark bookmark; + if (action) + bookmark = action->bookmark(); + + BookmarksContextMenu menu(bookmark, + Application::bookmarkProvider()->bookmarkManager(), + Application::bookmarkProvider()->bookmarkOwner()); + menu.exec(toolBar()->mapToGlobal(point)); +} + + void BookmarkToolBar::menuDisplayed() { qApp->installEventFilter(this); diff --git a/src/bookmarks/bookmarkstoolbar.h b/src/bookmarks/bookmarkstoolbar.h index 54a430e3..b1e2a555 100644 --- a/src/bookmarks/bookmarkstoolbar.h +++ b/src/bookmarks/bookmarkstoolbar.h @@ -91,6 +91,7 @@ protected: bool eventFilter(QObject *watched, QEvent *event); private slots: + void contextMenu(const QPoint &); void actionHovered(); void menuDisplayed(); void menuHidden(); -- cgit v1.2.1