summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2013-02-15 17:18:58 +0100
committerAndrea Diamantini <adjam7@gmail.com>2013-02-15 17:18:58 +0100
commit036bd6c5ac265da394472806039ea42823fc4b89 (patch)
tree57422f10d5dd092d5db1bed40639eb2770aa1ab6 /src
parentGet sure rules with not supported filter options are ignored (diff)
downloadrekonq-036bd6c5ac265da394472806039ea42823fc4b89.tar.xz
Restores Bookmarks menu (in 2.x fashion)
Cleans up 1.x code about and create a unique bk menu to be shown in rekonq tools menu, (eventually) in the toolbar and in (an ideal) menubar This work starts from Lindsay's review request about. Thanks :) REVIEW: 108729
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/bookmarks/bookmarkmanager.cpp20
-rw-r--r--src/bookmarks/bookmarkmanager.h4
-rw-r--r--src/bookmarks/bookmarksmenu.cpp159
-rw-r--r--src/bookmarks/bookmarksmenu.h70
-rw-r--r--src/bookmarks/bookmarkstoolbar.cpp107
-rw-r--r--src/bookmarks/bookmarkstoolbar.h43
-rw-r--r--src/webwindow/rekonqui.rc13
-rw-r--r--src/webwindow/webwindow.cpp10
9 files changed, 273 insertions, 154 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1a53c37a..d0984c93 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -27,6 +27,7 @@ set(rekonq_KDEINIT_SRCS
#----------------------------------------
bookmarks/bookmarkmanager.cpp
bookmarks/bookmarkscontextmenu.cpp
+ bookmarks/bookmarksmenu.cpp
bookmarks/bookmarkstoolbar.cpp
bookmarks/bookmarkowner.cpp
#----------------------------------------
diff --git a/src/bookmarks/bookmarkmanager.cpp b/src/bookmarks/bookmarkmanager.cpp
index 30a7772a..9c684a01 100644
--- a/src/bookmarks/bookmarkmanager.cpp
+++ b/src/bookmarks/bookmarkmanager.cpp
@@ -33,8 +33,11 @@
// Local Includes
#include "application.h"
+
+#include "bookmarksmenu.h"
#include "bookmarkstoolbar.h"
#include "bookmarkowner.h"
+
#include "iconmanager.h"
// KDE Includes
@@ -189,8 +192,8 @@ void BookmarkManager::fillBookmarkBar(BookmarkToolBar *toolBar)
{
KBookmarkActionMenu *menuAction = new KBookmarkActionMenu(bookmark.toGroup(), toolBar);
menuAction->setDelayed(false);
- BookmarkMenu *bMenu = new BookmarkMenu(m_manager, m_owner, menuAction->menu(), bookmark.address());
- bMenu->setParent(menuAction->menu());
+// BookmarkMenu *bMenu = new BookmarkMenu(m_manager, m_owner, menuAction->menu(), bookmark.address());
+// bMenu->setParent(menuAction->menu());
connect(menuAction->menu(), SIGNAL(aboutToShow()), toolBar, SLOT(menuDisplayed()));
connect(menuAction->menu(), SIGNAL(aboutToHide()), toolBar, SLOT(menuHidden()));
@@ -314,3 +317,16 @@ void BookmarkManager::emitChanged()
{
m_manager->emitChanged();
}
+
+KActionMenu* BookmarkManager::bookmarkActionMenu(QWidget *parent)
+{
+ KMenu *menu = new KMenu(parent);
+ KActionMenu *bookmarkActionMenu = new KActionMenu(menu);
+ bookmarkActionMenu->setMenu(menu);
+ bookmarkActionMenu->setText(i18n("&Bookmarks"));
+ BookmarkMenu *bMenu = new BookmarkMenu(m_manager, m_owner, menu, m_actionCollection);
+ bMenu->setParent(menu);
+
+ return bookmarkActionMenu;
+}
+
diff --git a/src/bookmarks/bookmarkmanager.h b/src/bookmarks/bookmarkmanager.h
index c970d390..1a76d0d0 100644
--- a/src/bookmarks/bookmarkmanager.h
+++ b/src/bookmarks/bookmarkmanager.h
@@ -36,6 +36,7 @@
// KDE Includes
#include <KBookmark>
+#include <KActionMenu>
// Qt Includes
#include <QObject>
@@ -44,7 +45,6 @@
// Forward Declarations
class BookmarkToolBar;
class BookmarkOwner;
-class BookmarkMenu;
class KAction;
class KActionCollection;
@@ -121,6 +121,8 @@ public:
{
return QL1S("application/x-rekonq-bookmark");
}
+
+ KActionMenu* bookmarkActionMenu(QWidget *parent);
private:
/**
diff --git a/src/bookmarks/bookmarksmenu.cpp b/src/bookmarks/bookmarksmenu.cpp
new file mode 100644
index 00000000..1f89df04
--- /dev/null
+++ b/src/bookmarks/bookmarksmenu.cpp
@@ -0,0 +1,159 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2008-2013 by Andrea Diamantini <adjam7 at gmail dot com>
+* Copyright (C) 2010 by Yoann Laissus <yoann dot laissus at gmail dot com>
+*
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License as
+* published by the Free Software Foundation; either version 2 of
+* the License or (at your option) version 3 or any later version
+* accepted by the membership of KDE e.V. (or its successor approved
+* by the membership of KDE e.V.), which shall act as a proxy
+* defined in Section 14 of version 3 of the license.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+* ============================================================ */
+
+
+// Self Includes
+#include "bookmarksmenu.h"
+#include "bookmarksmenu.moc"
+
+// Local Includes
+#include "bookmarkscontextmenu.h"
+#include "bookmarkmanager.h"
+#include "bookmarkowner.h"
+
+#include "iconmanager.h"
+#include "webwindow.h"
+
+// Qt Includes
+#include <QFrame>
+#include <QActionEvent>
+#include <QApplication>
+
+
+BookmarkMenu::BookmarkMenu(KBookmarkManager *manager,
+ KBookmarkOwner *owner,
+ KMenu *menu,
+ KActionCollection* actionCollection)
+ : KBookmarkMenu(manager, owner, menu, actionCollection)
+{
+}
+
+
+BookmarkMenu::BookmarkMenu(KBookmarkManager *manager,
+ KBookmarkOwner *owner,
+ KMenu *parentMenu,
+ const QString &parentAddress)
+ : KBookmarkMenu(manager, owner, parentMenu, parentAddress)
+{
+}
+
+
+BookmarkMenu::~BookmarkMenu()
+{
+ kDebug() << "Deleting BookmarkMenu.. See http://svn.reviewboard.kde.org/r/5606/ about.";
+}
+
+
+KMenu * BookmarkMenu::contextMenu(QAction *act)
+{
+ KBookmarkActionInterface* action = dynamic_cast<KBookmarkActionInterface *>(act);
+ if (!action)
+ return 0;
+ return new BookmarksContextMenu(action->bookmark(), manager(), static_cast<BookmarkOwner*>(owner()));
+}
+
+
+QAction * BookmarkMenu::actionForBookmark(const KBookmark &bookmark)
+{
+ if (bookmark.isGroup())
+ {
+ KBookmarkActionMenu *actionMenu = new KBookmarkActionMenu(bookmark, this);
+ BookmarkMenu *menu = new BookmarkMenu(manager(), owner(), actionMenu->menu(), bookmark.address());
+ // An hack to get rid of bug 219274
+ connect(actionMenu, SIGNAL(hovered()), menu, SLOT(slotAboutToShow()));
+ return actionMenu;
+ }
+ else if (bookmark.isSeparator())
+ {
+ return KBookmarkMenu::actionForBookmark(bookmark);
+ }
+ else
+ {
+ KBookmarkAction *action = new KBookmarkAction(bookmark, owner(), this);
+ action->setIcon(IconManager::self()->iconForUrl(KUrl(bookmark.url())));
+ return action;
+ }
+}
+
+
+void BookmarkMenu::refill()
+{
+ clear();
+
+ if (isRoot())
+ {
+ addAddBookmark();
+ addAddBookmarksList();
+
+ if (parentMenu()->actions().count() > 0)
+ parentMenu()->addSeparator();
+
+ WebWindow *w = qobject_cast<WebWindow *>(parentMenu()->parent());
+ QAction *a;
+ // bk page
+ a = w->actionByName(QL1S("open_bookmarks_page"));
+ parentMenu()->addAction(a);
+ a = w->actionByName(QL1S("show_bookmarks_toolbar"));
+ parentMenu()->addAction(a);
+
+ addEditBookmarks();
+
+ if (parentMenu()->actions().count() > 0)
+ parentMenu()->addSeparator();
+ }
+
+ fillBookmarks();
+
+ if (!isRoot())
+ {
+ if (parentMenu()->actions().count() > 0)
+ parentMenu()->addSeparator();
+
+ addOpenFolderInTabs();
+ addAddBookmarksList();
+ }
+}
+
+
+void BookmarkMenu::addOpenFolderInTabs()
+{
+ KBookmarkGroup group = manager()->findByAddress(parentAddress()).toGroup();
+
+ if (!group.first().isNull())
+ {
+ KBookmark bookmark = group.first();
+
+ while (bookmark.isGroup() || bookmark.isSeparator())
+ {
+ bookmark = group.next(bookmark);
+ }
+
+ if (!bookmark.isNull())
+ {
+ parentMenu()->addAction(BookmarkManager::self()->owner()->createAction(group, BookmarkOwner::OPEN_FOLDER));
+ }
+ }
+}
diff --git a/src/bookmarks/bookmarksmenu.h b/src/bookmarks/bookmarksmenu.h
new file mode 100644
index 00000000..36b3bca5
--- /dev/null
+++ b/src/bookmarks/bookmarksmenu.h
@@ -0,0 +1,70 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2008-2013 by Andrea Diamantini <adjam7 at gmail dot com>
+* Copyright (C) 2010 by Yoann Laissus <yoann dot laissus at gmail dot com>
+*
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License as
+* published by the Free Software Foundation; either version 2 of
+* the License or (at your option) version 3 or any later version
+* accepted by the membership of KDE e.V. (or its successor approved
+* by the membership of KDE e.V.), which shall act as a proxy
+* defined in Section 14 of version 3 of the license.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+* ============================================================ */
+
+
+#ifndef BOOKMARKS_MENU_H
+#define BOOKMARKS_MENU_H
+
+
+// Rekonq Includes
+#include "rekonq_defines.h"
+
+// KDE Includes
+#include <KBookmarkMenu>
+
+
+/**
+ * This class represent the rekonq bookmarks menu.
+ * It's just a simple class inherited from KBookmarkMenu
+ *
+ */
+class BookmarkMenu : public KBookmarkMenu
+{
+ Q_OBJECT
+
+public:
+ BookmarkMenu(KBookmarkManager* manager,
+ KBookmarkOwner* owner,
+ KMenu* menu,
+ KActionCollection* actionCollection);
+
+ BookmarkMenu(KBookmarkManager *manager,
+ KBookmarkOwner *owner,
+ KMenu *parentMenu,
+ const QString &parentAddress);
+
+ ~BookmarkMenu();
+
+protected:
+ virtual KMenu * contextMenu(QAction * act);
+ virtual void refill();
+ virtual QAction* actionForBookmark(const KBookmark &bookmark);
+
+private:
+ void addOpenFolderInTabs();
+};
+
+#endif // BOOKMARKS_MENU_H
diff --git a/src/bookmarks/bookmarkstoolbar.cpp b/src/bookmarks/bookmarkstoolbar.cpp
index c570622f..5c45daeb 100644
--- a/src/bookmarks/bookmarkstoolbar.cpp
+++ b/src/bookmarks/bookmarkstoolbar.cpp
@@ -2,7 +2,7 @@
*
* This file is a part of the rekonq project
*
-* Copyright (C) 2008-2012 by Andrea Diamantini <adjam7 at gmail dot com>
+* Copyright (C) 2008-2013 by Andrea Diamantini <adjam7 at gmail dot com>
* Copyright (C) 2010 by Yoann Laissus <yoann dot laissus at gmail dot com>
*
*
@@ -37,114 +37,15 @@
#include "iconmanager.h"
#include "webwindow.h"
+// KDE Includes
+#include <KMenu>
+
// Qt Includes
#include <QFrame>
#include <QActionEvent>
#include <QApplication>
-BookmarkMenu::BookmarkMenu(KBookmarkManager *manager,
- KBookmarkOwner *owner,
- KMenu *menu,
- KActionCollection* actionCollection)
- : KBookmarkMenu(manager, owner, menu, actionCollection)
-{
-}
-
-
-BookmarkMenu::BookmarkMenu(KBookmarkManager *manager,
- KBookmarkOwner *owner,
- KMenu *parentMenu,
- const QString &parentAddress)
- : KBookmarkMenu(manager, owner, parentMenu, parentAddress)
-{
-}
-
-
-BookmarkMenu::~BookmarkMenu()
-{
- kDebug() << "Deleting BookmarkMenu.. See http://svn.reviewboard.kde.org/r/5606/ about.";
-}
-
-
-KMenu * BookmarkMenu::contextMenu(QAction *act)
-{
- KBookmarkActionInterface* action = dynamic_cast<KBookmarkActionInterface *>(act);
- if (!action)
- return 0;
- return new BookmarksContextMenu(action->bookmark(), manager(), static_cast<BookmarkOwner*>(owner()));
-}
-
-
-QAction * BookmarkMenu::actionForBookmark(const KBookmark &bookmark)
-{
- if (bookmark.isGroup())
- {
- KBookmarkActionMenu *actionMenu = new KBookmarkActionMenu(bookmark, this);
- BookmarkMenu *menu = new BookmarkMenu(manager(), owner(), actionMenu->menu(), bookmark.address());
- // An hack to get rid of bug 219274
- connect(actionMenu, SIGNAL(hovered()), menu, SLOT(slotAboutToShow()));
- return actionMenu;
- }
- else if (bookmark.isSeparator())
- {
- return KBookmarkMenu::actionForBookmark(bookmark);
- }
- else
- {
- KBookmarkAction *action = new KBookmarkAction(bookmark, owner(), this);
- action->setIcon(IconManager::self()->iconForUrl(KUrl(bookmark.url())));
- connect(action, SIGNAL(hovered()), this, SLOT(actionHovered()));
- return action;
- }
-}
-
-
-void BookmarkMenu::refill()
-{
- clear();
- fillBookmarks();
-
- if (parentMenu()->actions().count() > 0)
- parentMenu()->addSeparator();
-
- if (isRoot())
- {
- addAddBookmarksList();
- addEditBookmarks();
- }
- else
- {
- addOpenFolderInTabs();
- addAddBookmarksList();
- }
-}
-
-
-void BookmarkMenu::addOpenFolderInTabs()
-{
- KBookmarkGroup group = manager()->findByAddress(parentAddress()).toGroup();
-
- if (!group.first().isNull())
- {
- KBookmark bookmark = group.first();
-
- while (bookmark.isGroup() || bookmark.isSeparator())
- {
- bookmark = group.next(bookmark);
- }
-
- if (!bookmark.isNull())
- {
- parentMenu()->addAction(BookmarkManager::self()->owner()->createAction(group, BookmarkOwner::OPEN_FOLDER));
- }
- }
-}
-
-
-// ------------------------------------------------------------------------------------------------------
-
-
BookmarkToolBar::BookmarkToolBar(QWidget *parent)
: KToolBar(parent, false, false)
, m_currentMenu(0)
diff --git a/src/bookmarks/bookmarkstoolbar.h b/src/bookmarks/bookmarkstoolbar.h
index bca7864f..104debce 100644
--- a/src/bookmarks/bookmarkstoolbar.h
+++ b/src/bookmarks/bookmarkstoolbar.h
@@ -2,7 +2,7 @@
*
* This file is a part of the rekonq project
*
-* Copyright (C) 2008-2012 by Andrea Diamantini <adjam7 at gmail dot com>
+* Copyright (C) 2008-2013 by Andrea Diamantini <adjam7 at gmail dot com>
* Copyright (C) 2010 by Yoann Laissus <yoann dot laissus at gmail dot com>
*
*
@@ -24,6 +24,7 @@
*
* ============================================================ */
+
#ifndef BOOKMARKSTOOLBAR_H
#define BOOKMARKSTOOLBAR_H
@@ -32,45 +33,11 @@
#include "rekonq_defines.h"
// KDE Includes
-#include <KBookmarkMenu>
-
-/**
- * This class represent the rekonq bookmarks menu.
- * It's just a simple class inherited from KBookmarkMenu
- *
- */
-class BookmarkMenu : public KBookmarkMenu
-{
- Q_OBJECT
-
-public:
- BookmarkMenu(KBookmarkManager* manager,
- KBookmarkOwner* owner,
- KMenu* menu,
- KActionCollection* actionCollection);
- BookmarkMenu(KBookmarkManager *manager,
- KBookmarkOwner *owner,
- KMenu *parentMenu,
- const QString &parentAddress);
- ~BookmarkMenu();
-
-protected:
- virtual KMenu * contextMenu(QAction * act);
- virtual void refill();
- virtual QAction* actionForBookmark(const KBookmark &bookmark);
-
-private:
- void addOpenFolderInTabs();
-
-};
-
-
-// ------------------------------------------------------------------------------
-
-
-// KDE Includes
#include <KToolBar>
+// Forward Declarations
+class KMenu;
+
/**
* This class manage the bookmark toolbar.
diff --git a/src/webwindow/rekonqui.rc b/src/webwindow/rekonqui.rc
index ea068e56..190111d9 100644
--- a/src/webwindow/rekonqui.rc
+++ b/src/webwindow/rekonqui.rc
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<!DOCTYPE gui SYSTEM "kpartgui.dtd">
-<gui name="rekonq" version="67">
+<gui name="rekonq" version="68">
<!--- =========== Rekonq Menu ============= -->
<Menu name="rekonqMenu" noMerge="1">
@@ -41,15 +41,8 @@
</Menu>
<Separator/>
- <Menu name="bookmarksMenu" icon="bookmarks" noMerge="1">
- <text>&amp;Bookmarks</text>
- <Action name="bookmark_add" />
- <Separator/>
- <Action name="open_bookmarks_page" />
- <Action name="show_bookmarks_toolbar" />
- <Action name="bookmark_edit" />
- <!-- TODO: would we list all bookmarks, after a separator, here?? -->
- </Menu>
+ <Action name="bookmarksActionMenu" />
+
<Action name="open_history_page" />
<Action name="open_downloads_page" />
<Separator/>
diff --git a/src/webwindow/webwindow.cpp b/src/webwindow/webwindow.cpp
index faf919a7..75636dbd 100644
--- a/src/webwindow/webwindow.cpp
+++ b/src/webwindow/webwindow.cpp
@@ -62,7 +62,9 @@
#include <KToolBar>
#include <KToggleFullScreenAction>
#include <KShortcutsDialog>
+#include <KRun>
+// Qt Includes
#include <QLabel>
#include <QStyle>
#include <QTextDocument>
@@ -303,6 +305,14 @@ void WebWindow::setupActions()
// Edit bookmarks
a = KStandardAction::editBookmarks(BookmarkManager::self(), SLOT(slotEditBookmarks()), actionCollection());
+
+ // Bookmark Menu
+ KActionMenu *bmMenu = BookmarkManager::self()->bookmarkActionMenu(this);
+ bmMenu->setIcon(KIcon("bookmarks"));
+ bmMenu->setDelayed(false);
+ bmMenu->setShortcutConfigurable(true);
+ bmMenu->setShortcut(KShortcut(Qt::ALT + Qt::Key_B));
+ actionCollection()->addAction(QL1S("bookmarksActionMenu"), bmMenu);
// User Agent
a = new KAction(KIcon("preferences-web-browser-identification"), i18n("Browser Identification"), this);