summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Troscher <fritz_van_tom@hotmail.com>2011-08-12 12:41:24 +0200
committerAndrea Diamantini <adjam7@gmail.com>2011-08-12 12:41:24 +0200
commitb5dcfc28a2c8a7922e0a56cafc62b4f89b692eb1 (patch)
tree22387215ff24c17a71b8c804c293b6d8f3d0fde5
parentnotify popup improvements (diff)
downloadrekonq-b5dcfc28a2c8a7922e0a56cafc62b4f89b692eb1.tar.xz
Use KXMLGui to create rekonq menu
Easier and (hopefully) safer (less code to manage) REVIEW: 102209 REVIEWED-BY: adjam
-rw-r--r--src/mainwindow.cpp116
-rw-r--r--src/mainwindow.h6
-rw-r--r--src/rekonqui.rc170
3 files changed, 152 insertions, 140 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 0bcaaed5..73109881 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -73,10 +73,11 @@
#include <KMessageBox>
#include <KProcess>
#include <KPushButton>
-#include <KStandardDirs>
-#include <KToggleFullScreenAction>
#include <KProtocolManager>
+#include <KStandardDirs>
#include <KTemporaryFile>
+#include <KToggleFullScreenAction>
+#include <KXMLGUIFactory>
#include <KParts/Part>
#include <KParts/BrowserExtension>
@@ -116,7 +117,6 @@ MainWindow::MainWindow()
, m_popup(new QLabel(this))
, m_hidePopupTimer(new QTimer(this))
, m_rekonqMenu(0)
- , m_toolsActionMenu(0)
{
// creating a centralWidget containing panel, m_view and the hidden findbar
QWidget *centralWidget = new QWidget;
@@ -148,9 +148,6 @@ MainWindow::MainWindow()
// setting up rekonq toolbar(s)
setupToolbars();
- // disable help menu, as we'll load it on our own...
- setHelpMenuEnabled(false);
-
// a call to KXmlGuiWindow::setupGUI() populates the GUI
// with actions, using KXMLGUI.
// It also applies the saved mainwindow settings, if any, and ask the
@@ -207,6 +204,16 @@ void MainWindow::initBookmarkBar()
}
m_bookmarksBar = new BookmarkToolBar(XMLGUIBkBar, this);
rApp->bookmarkProvider()->registerBookmarkBar(m_bookmarksBar);
+ QAction *a = actionByName(QL1S("show_bookmarks_toolbar"));
+ a->setChecked(XMLGUIBkBar->isVisible());
+ connect(a, SIGNAL(toggled(bool)), this, SLOT(toggleBookmarkBarVisible(bool)));
+}
+
+
+void MainWindow::toggleBookmarkBarVisible(bool visible)
+{
+ if (m_bookmarksBar)
+ m_bookmarksBar->toolBar()->setVisible(visible);
}
@@ -222,62 +229,6 @@ void MainWindow::configureToolbars()
}
-void MainWindow::updateToolsMenu()
-{
- if (m_rekonqMenu->isEmpty())
- {
- m_rekonqMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Open)));
- m_rekonqMenu->addAction(actionByName(KStandardAction::name(KStandardAction::SaveAs)));
- m_rekonqMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Print)));
- m_rekonqMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Find)));
-
- QAction *action = actionByName(KStandardAction::name(KStandardAction::Zoom));
- action->setCheckable(true);
- connect(m_zoomBar, SIGNAL(visibilityChanged(bool)), action, SLOT(setChecked(bool)));
- m_rekonqMenu->addAction(action);
-
- m_rekonqMenu->addSeparator();
-
- m_rekonqMenu->addAction(actionByName(QL1S("private_browsing")));
- m_rekonqMenu->addAction(actionByName(QL1S("clear_private_data")));
-
- m_rekonqMenu->addSeparator();
-
- // tools Action Menu
- m_toolsActionMenu = new KActionMenu(KIcon("preferences-other"), i18n("Tools"), this);
- m_toolsActionMenu->addAction(actionByName(QL1S("web_inspector")));
- m_toolsActionMenu->addAction(actionByName(QL1S("page_source")));
- m_toolsActionMenu->addAction(actionByName(QL1S("net_analyzer")));
- m_toolsActionMenu->addAction(actionByName(QL1S("set_editable")));
-
- m_toolsActionMenu->addSeparator();
-
- m_toolsActionMenu->addAction(actionByName(QL1S("useragent")));
- m_toolsActionMenu->addAction(actionByName(QL1S("adblock")));
-
- m_rekonqMenu->addAction(m_toolsActionMenu);
- // -----------------------------------------------------------------------------------------
-
- m_rekonqMenu->addSeparator();
-
- action = m_bookmarksBar->toolBar()->toggleViewAction();
- action->setText(i18n("Bookmarks Toolbar"));
- action->setIcon(KIcon("bookmarks-bar"));
- m_rekonqMenu->addAction(action);
-
- m_rekonqMenu->addAction(actionByName(QL1S("show_history_panel")));
- m_rekonqMenu->addAction(actionByName(QL1S("show_bookmarks_panel")));
- m_rekonqMenu->addAction(actionByName(KStandardAction::name(KStandardAction::FullScreen)));
-
- m_rekonqMenu->addSeparator();
-
- helpMenu()->setIcon(KIcon("help-browser"));
- m_rekonqMenu->addAction(helpMenu()->menuAction());
- m_rekonqMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Preferences)));
- }
-}
-
-
void MainWindow::postLaunch()
{
setupBookmarksAndToolsShortcuts();
@@ -293,7 +244,7 @@ void MainWindow::postLaunch()
connect(m_view, SIGNAL(showStatusBarMessage(const QString&, Rekonq::Notify)), this, SLOT(notifyMessage(const QString&, Rekonq::Notify)));
connect(m_view, SIGNAL(linkHovered(const QString&)), this, SLOT(notifyMessage(const QString&)));
- // --------- connect signals and slots
+ // connect signals and slots
connect(m_view, SIGNAL(currentTitle(const QString &)), this, SLOT(updateWindowTitle(const QString &)));
connect(m_view, SIGNAL(printRequested(QWebFrame *)), this, SLOT(printRequested(QWebFrame *)));
@@ -308,7 +259,7 @@ void MainWindow::postLaunch()
// update toolbar actions signals
connect(m_view, SIGNAL(currentChanged(int)), this, SLOT(updateActions()));
- //Change window icon according to tab icon
+ // Change window icon according to tab icon
connect(m_view, SIGNAL(currentChanged(int)), this, SLOT(changeWindowIcon(int)));
// launch it manually. Just the first time...
@@ -319,6 +270,7 @@ void MainWindow::postLaunch()
// Zoom Bar signal
connect(m_view, SIGNAL(currentChanged(int)), m_zoomBar, SLOT(updateSlider(int)));
+
// Ctrl + wheel handling
connect(this->currentTab()->view(), SIGNAL(zoomChanged(int)), m_zoomBar, SLOT(setValue(int)));
@@ -445,7 +397,8 @@ void MainWindow::setupActions()
// ========================= History related actions ==============================
a = actionCollection()->addAction(KStandardAction::Back);
- connect(a, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(openPrevious(Qt::MouseButtons, Qt::KeyboardModifiers)));
+ connect(a, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)),
+ this, SLOT(openPrevious(Qt::MouseButtons, Qt::KeyboardModifiers)));
m_historyBackMenu = new KMenu(this);
a->setMenu(m_historyBackMenu);
@@ -453,7 +406,8 @@ void MainWindow::setupActions()
connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(openActionUrl(QAction *)));
a = actionCollection()->addAction(KStandardAction::Forward);
- connect(a, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(openNext(Qt::MouseButtons, Qt::KeyboardModifiers)));
+ connect(a, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)),
+ this, SLOT(openNext(Qt::MouseButtons, Qt::KeyboardModifiers)));
m_historyForwardMenu = new KMenu(this);
a->setMenu(m_historyForwardMenu);
@@ -544,7 +498,12 @@ void MainWindow::setupActions()
bmMenu->setShortcut(KShortcut(Qt::ALT + Qt::Key_B));
actionCollection()->addAction(QL1S("bookmarksActionMenu"), bmMenu);
- // --- User Agent
+ // Bookmark Toolbar
+ a = new KAction(KIcon("bookmarks-bar"), i18n("Bookmarks Toolbar"), this);
+ a->setCheckable(true);
+ actionCollection()->addAction(QL1S("show_bookmarks_toolbar"), a);
+
+ // User Agent
a = new KAction(KIcon("preferences-web-browser-identification"), i18n("Browser Identification"), this);
actionCollection()->addAction(QL1S("useragent"), a);
a->setMenu(m_userAgentMenu);
@@ -575,12 +534,9 @@ void MainWindow::setupTools()
toolsAction->setShortcut(KShortcut(Qt::ALT + Qt::Key_T));
m_rekonqMenu = new KMenu(this);
toolsAction->setMenu(m_rekonqMenu); // dummy menu to have the dropdown arrow
- connect(m_rekonqMenu, SIGNAL(aboutToShow()), this, SLOT(updateToolsMenu()));
// adding rekonq_tools to rekonq actionCollection
actionCollection()->addAction(QL1S("rekonq_tools"), toolsAction);
-
- // Actions are added after the call to setupGUI() to ensure the help menu works
}
@@ -591,7 +547,8 @@ void MainWindow::setupPanels()
// STEP 1
// Setup history panel
m_historyPanel = new HistoryPanel(i18n("History Panel"), this);
- connect(m_historyPanel, SIGNAL(openUrl(const KUrl&, const Rekonq::OpenType &)), rApp, SLOT(loadUrl(const KUrl&, const Rekonq::OpenType &)));
+ connect(m_historyPanel, SIGNAL(openUrl(const KUrl&, const Rekonq::OpenType &)),
+ rApp, SLOT(loadUrl(const KUrl&, const Rekonq::OpenType &)));
connect(m_historyPanel, SIGNAL(itemHovered(QString)), this, SLOT(notifyMessage(QString)));
connect(m_historyPanel, SIGNAL(destroyed()), rApp, SLOT(saveConfiguration()));
@@ -606,7 +563,8 @@ void MainWindow::setupPanels()
// STEP 2
// Setup bookmarks panel
m_bookmarksPanel = new BookmarksPanel(i18n("Bookmarks Panel"), this);
- connect(m_bookmarksPanel, SIGNAL(openUrl(const KUrl&, const Rekonq::OpenType &)), rApp, SLOT(loadUrl(const KUrl&, const Rekonq::OpenType &)));
+ connect(m_bookmarksPanel, SIGNAL(openUrl(const KUrl&, const Rekonq::OpenType &)),
+ rApp, SLOT(loadUrl(const KUrl&, const Rekonq::OpenType &)));
connect(m_bookmarksPanel, SIGNAL(itemHovered(QString)), this, SLOT(notifyMessage(QString)));
connect(m_bookmarksPanel, SIGNAL(destroyed()), rApp, SLOT(saveConfiguration()));
@@ -647,6 +605,16 @@ void MainWindow::setupPanels()
m_analyzerPanel->hide();
}
+
+void MainWindow::finalizeGUI(KXMLGUIClient* client)
+{
+ KXmlGuiWindow::finalizeGUI(client);
+ //update rekonqMenu when GUI has changed
+ KMenu *m = qobject_cast<KMenu*>(factory()->container("rekonqMenu", this));
+ m_rekonqMenu->addActions(m->actions());
+}
+
+
void MainWindow::openLocation()
{
if (isFullScreen())
@@ -1236,8 +1204,8 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status)
const QPoint mousePos = mapFromGlobal(QCursor::pos());
int y = height() - m_popup->height() - hScrollbarSize;
int x = QRect(QPoint(0, y), labelSize).contains(mousePos)
- ? width() - labelSize.width() - vScrollbarSize
- : 0;
+ ? width() - labelSize.width() - vScrollbarSize
+ : 0;
m_popup->move(x, y);
m_popup->show();
diff --git a/src/mainwindow.h b/src/mainwindow.h
index a5a54f9d..c2654a93 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -49,8 +49,6 @@ class WebInspectorPanel;
class WebTab;
class ZoomBar;
-class KActionMenu;
-
class QWebFrame;
class QLabel;
@@ -141,6 +139,7 @@ protected:
void resizeEvent(QResizeEvent *event);
bool event(QEvent *event);
bool queryClose();
+ void finalizeGUI(KXMLGUIClient *client);
private Q_SLOTS:
void postLaunch();
@@ -185,7 +184,7 @@ private Q_SLOTS:
void setEditable(bool);
void initBookmarkBar();
- void updateToolsMenu();
+ void toggleBookmarkBarVisible(bool);
private:
MainView *m_view;
@@ -214,7 +213,6 @@ private:
QTimer *m_hidePopupTimer;
KMenu *m_rekonqMenu;
- KActionMenu *m_toolsActionMenu;
};
#endif // MAINWINDOW_H
diff --git a/src/rekonqui.rc b/src/rekonqui.rc
index 5a99fe90..9d8ded63 100644
--- a/src/rekonqui.rc
+++ b/src/rekonqui.rc
@@ -1,83 +1,129 @@
<?xml version="1.0"?>
<!DOCTYPE gui SYSTEM "kpartgui.dtd">
-<gui name="rekonq" version="53">
+<gui name="rekonq" version="54">
-<MenuBar>
-
-<!-- ============ FILE menu =========== -->
-<Menu name="file" noMerge="1"><text>&amp;File</text>
+<!--- =========== Rekonq Menu ============= -->
+<Menu name="rekonqMenu" noMerge="1">
<Action name="file_open" />
- <Action name="open_location" />
- <Separator/>
- <Action name="new_tab" />
- <Action name="close_tab" />
- <Separator/>
<Action name="file_save_as" />
- <Separator/>
- <Action name="file_print_preview" />
<Action name="file_print" />
+ <Action name="edit_find" />
+ <Action name="view_zoom" />
<Separator/>
- <Action name="file_quit" />
-</Menu>
-
-<!-- ============ EDIT menu =========== -->
-<Menu name="edit" noMerge="1"><text>&amp;Edit</text>
- <Action name="edit_undo" />
- <Action name="edit_redo" />
- <Separator/>
- <Action name="edit_cut" />
- <Action name="edit_copy" />
- <Action name="edit_paste" />
+ <Action name="private_browsing" />
+ <Action name="clear_private_data" />
<Separator/>
- <Action name="edit_find" />
- <Action name="edit_find_next" />
- <Action name="edit_find_prev" />
-</Menu>
-<!-- ============ VIEW menu =========== -->
-<Menu name="view" noMerge="1"><text>&amp;View</text>
- <Action name="view_redisplay" />
- <Action name="go_home" />
+ <Menu name="toolsMenu" icon="preferences-other" noMerge="1">
+ <text>&amp;Tools</text>
+ <Action name="web_inspector" />
+ <Action name="page_source" />
+ <Action name="net_analyter" />
+ <Action name="set_editable" />
+ <Separator/>
+ <Action name="useragent" />
+ <Action name="adblock" />
+ </Menu>
+
<Separator/>
- <Action name="bigger_font" />
- <Action name="normal_font" />
- <Action name="smaller_font" />
+ <Action name="show_history_panel" />
+ <Action name="show_bookmarks_toolbar" />
+ <Action name="show_bookmarks_panel" />
+ <Action name="fullscreen" />
<Separator/>
- <Action name="page_source" />
-</Menu>
-<!-- ============ GO menu =========== -->
-<Menu name="go" deleted="true">
+ <Menu name="help" icon="help-browser">
+ <text>&amp;Help</text>
+ <Action name="help_contents"/>
+ <Action name="help_whats_this"/>
+ <Separator weakSeparator="1"/>
+ <Action name="help_report_bug"/>
+ <Separator weakSeparator="1"/>
+ <Action name="switch_application_language"/>
+ <Separator weakSeparator="1"/>
+ <Action name="help_about_app"/>
+ <Action name="help_about_kde"/>
+ </Menu>
+
+ <Action name="options_configure" />
</Menu>
+<!--- --------------------------------------- -->
-<!-- ============ HISTORY menu =========== -->
-<Action name="history" ><text>Hi&amp;story</text>
-</Action>
-<!-- ============ BOOKMARKS menu =========== -->
-<Action name="bookmarksActionMenu" ><text>&amp;Bookmarks</text>
-</Action>
+<MenuBar>
+ <!-- ============ FILE menu =========== -->
+ <Menu name="file" noMerge="1"><text>&amp;File</text>
+ <Action name="file_open" />
+ <Action name="open_location" />
+ <Separator/>
+ <Action name="new_tab" />
+ <Action name="close_tab" />
+ <Separator/>
+ <Action name="file_save_as" />
+ <Separator/>
+ <Action name="file_print_preview" />
+ <Action name="file_print" />
+ <Separator/>
+ <Action name="file_quit" />
+ </Menu>
-<!-- ============ TOOLS menu =========== -->
-<Menu name="tools" noMerge="1"><text>&amp;Tools</text>
- <Action name="web_inspector" />
- <Action name="private_browsing" />
- <Action name="clear_private_data" />
-</Menu>
+ <!-- ============ EDIT menu =========== -->
+ <Menu name="edit" noMerge="1"><text>&amp;Edit</text>
+ <Action name="edit_undo" />
+ <Action name="edit_redo" />
+ <Separator/>
+ <Action name="edit_cut" />
+ <Action name="edit_copy" />
+ <Action name="edit_paste" />
+ <Separator/>
+ <Action name="edit_find" />
+ <Action name="edit_find_next" />
+ <Action name="edit_find_prev" />
+ </Menu>
-<!-- ============ SETTINGS menu =========== -->
-<Menu name="settings" noMerge="1"><text>&amp;Settings</text>
- <Action name="options_show_menubar" />
- <Merge name="StandardToolBarMenuHandler" />
- <Merge/>
- <Separator/>
- <Action name="fullscreen" />
- <Separator/>
- <Action name="options_configure_keybinding" />
- <Action name="options_configure_toolbars" />
- <Action name="options_configure" />
-</Menu>
+ <!-- ============ VIEW menu =========== -->
+ <Menu name="view" noMerge="1"><text>&amp;View</text>
+ <Action name="view_redisplay" />
+ <Action name="go_home" />
+ <Separator/>
+ <Action name="bigger_font" />
+ <Action name="normal_font" />
+ <Action name="smaller_font" />
+ <Separator/>
+ <Action name="page_source" />
+ </Menu>
+
+ <!-- ============ GO menu =========== -->
+ <Menu name="go" deleted="true">
+ </Menu>
+
+ <!-- ============ HISTORY menu =========== -->
+ <Action name="history" ><text>Hi&amp;story</text>
+ </Action>
+
+ <!-- ============ BOOKMARKS menu =========== -->
+ <Action name="bookmarksActionMenu" ><text>&amp;Bookmarks</text>
+ </Action>
+
+ <!-- ============ TOOLS menu =========== -->
+ <Menu name="tools" noMerge="1"><text>&amp;Tools</text>
+ <Action name="web_inspector" />
+ <Action name="private_browsing" />
+ <Action name="clear_private_data" />
+ </Menu>
+ <!-- ============ SETTINGS menu =========== -->
+ <Menu name="settings" noMerge="1"><text>&amp;Settings</text>
+ <Action name="options_show_menubar" />
+ <Merge name="StandardToolBarMenuHandler" />
+ <Merge/>
+ <Separator/>
+ <Action name="fullscreen" />
+ <Separator/>
+ <Action name="options_configure_keybinding" />
+ <Action name="options_configure_toolbars" />
+ <Action name="options_configure" />
+ </Menu>
</MenuBar>
<!-- ============ Main ToolBar =========== -->