diff options
author | Felix Rohrbach <fxrh@gmx.de> | 2011-01-18 15:05:04 +0100 |
---|---|---|
committer | Felix Rohrbach <fxrh@gmx.de> | 2011-01-22 17:50:39 +0100 |
commit | 327b0383dfc43651ebb7b401929942f3715b6602 (patch) | |
tree | 8486971ead4ced49a9714a518e4fe711a0901f52 /src | |
parent | Keep downloaded suggestions in memory. (diff) | |
download | rekonq-327b0383dfc43651ebb7b401929942f3715b6602.tar.xz |
If showDeveloperTools is disabled, hide the development entries in the rekonq menu, too.
With this patch, the menu will be created the first time the user opens the menu.
RB: 100374
Diffstat (limited to 'src')
-rw-r--r-- | src/mainwindow.cpp | 90 | ||||
-rw-r--r-- | src/mainwindow.h | 5 |
2 files changed, 50 insertions, 45 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 59fff832..ece11cc3 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -106,6 +106,7 @@ MainWindow::MainWindow() , m_popup(new KPassivePopup(this)) , m_hidePopup(new QTimer(this)) , m_toolsMenu(0) + , m_developerMenu(0) { // creating a centralWidget containing panel, m_view and the hidden findbar QWidget *centralWidget = new QWidget; @@ -212,9 +213,6 @@ void MainWindow::initBookmarkBar() } m_bookmarksBar = new BookmarkToolBar(XMLGUIBkBar, this); Application::bookmarkProvider()->registerBookmarkBar(m_bookmarksBar); - - // To update the bookmark toolbar action - initToolsMenu(); } @@ -230,55 +228,58 @@ void MainWindow::configureToolbars() } -void MainWindow::initToolsMenu() +void MainWindow::updateToolsMenu() { - if (!m_toolsMenu) - return; + if( m_toolsMenu->isEmpty() ) + { + m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Open))); + m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::SaveAs))); + m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Print))); + m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Find))); - m_toolsMenu->menu()->clear(); + QAction *action = actionByName(KStandardAction::name(KStandardAction::Zoom)); + action->setCheckable(true); + connect (m_zoomBar, SIGNAL(visibilityChanged(bool)), action, SLOT(setChecked(bool))); + m_toolsMenu->addAction(action); - m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Open))); - m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::SaveAs))); - m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Print))); - m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Find))); + m_toolsMenu->addAction(actionByName(QL1S("encodings"))); - QAction *action = actionByName(KStandardAction::name(KStandardAction::Zoom)); - action->setCheckable(true); - connect (m_zoomBar, SIGNAL(visibilityChanged(bool)), action, SLOT(setChecked(bool))); - m_toolsMenu->addAction(action); + m_toolsMenu->addSeparator(); - m_toolsMenu->addAction(actionByName(QL1S("encodings"))); + m_toolsMenu->addAction(actionByName(QL1S("private_browsing"))); + m_toolsMenu->addAction(actionByName(QL1S("clear_private_data"))); - m_toolsMenu->addSeparator(); + m_toolsMenu->addSeparator(); - m_toolsMenu->addAction(actionByName(QL1S("private_browsing"))); - m_toolsMenu->addAction(actionByName(QL1S("clear_private_data"))); + m_developerMenu = new KActionMenu(KIcon("applications-development-web"), i18n("Development"), this); + m_developerMenu->addAction(actionByName(QL1S("web_inspector"))); + m_developerMenu->addAction(actionByName(QL1S("page_source"))); + m_developerMenu->addAction(actionByName(QL1S("net_analyzer"))); - m_toolsMenu->addSeparator(); + m_toolsMenu->addAction(m_developerMenu); + if(!ReKonfig::showDeveloperTools()) + m_developerMenu->setVisible(false); - KActionMenu *webMenu = new KActionMenu(KIcon("applications-development-web"), i18n("Development"), this); - webMenu->addAction(actionByName(QL1S("web_inspector"))); - webMenu->addAction(actionByName(QL1S("page_source"))); - webMenu->addAction(actionByName(QL1S("net_analyzer"))); - m_toolsMenu->addAction(webMenu); + m_toolsMenu->addSeparator(); - m_toolsMenu->addSeparator(); + action = m_bookmarksBar->toolBar()->toggleViewAction(); + action->setText(i18n("Bookmarks Toolbar")); + action->setIcon(KIcon("bookmarks-bar")); + m_toolsMenu->addAction(action); - action = m_bookmarksBar->toolBar()->toggleViewAction(); - action->setText(i18n("Bookmarks Toolbar")); - action->setIcon(KIcon("bookmarks-bar")); - m_toolsMenu->addAction(action); + m_toolsMenu->addAction(actionByName(QL1S("show_history_panel"))); + m_toolsMenu->addAction(actionByName(QL1S("show_bookmarks_panel"))); + m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::FullScreen))); - m_toolsMenu->addAction(actionByName(QL1S("show_history_panel"))); - m_toolsMenu->addAction(actionByName(QL1S("show_bookmarks_panel"))); - m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::FullScreen))); + m_toolsMenu->addSeparator(); - m_toolsMenu->addSeparator(); + this->setHelpMenuEnabled(true); + helpMenu()->setIcon(KIcon("help-browser")); + m_toolsMenu->addAction(helpMenu()->menuAction()); + m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Preferences))); + } - this->setHelpMenuEnabled(true); - helpMenu()->setIcon(KIcon("help-browser")); - m_toolsMenu->addAction(helpMenu()->menuAction()); - m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Preferences))); + m_developerMenu->setVisible(ReKonfig::showDeveloperTools()); } @@ -529,13 +530,16 @@ void MainWindow::setupActions() void MainWindow::setupTools() { kDebug() << "setup tools..."; - m_toolsMenu = new KActionMenu(KIcon("configure"), i18n("&Tools"), this); - m_toolsMenu->setDelayed(false); - m_toolsMenu->setShortcutConfigurable(true); - m_toolsMenu->setShortcut( KShortcut(Qt::ALT + Qt::Key_T) ); + KActionMenu *toolsAction = new KActionMenu(KIcon("configure"), i18n("&Tools"), this); + toolsAction->setDelayed(false); + toolsAction->setShortcutConfigurable(true); + toolsAction->setShortcut( KShortcut(Qt::ALT + Qt::Key_T) ); + m_toolsMenu = new KMenu(this); + toolsAction->setMenu(m_toolsMenu); // dummy menu to have the dropdown arrow + connect( m_toolsMenu, SIGNAL(aboutToShow()), this, SLOT(updateToolsMenu()) ); // adding rekonq_tools to rekonq actionCollection - actionCollection()->addAction(QL1S("rekonq_tools"), m_toolsMenu); + actionCollection()->addAction(QL1S("rekonq_tools"), toolsAction); // Actions are added after the call to setupGUI() to ensure the help menu works } diff --git a/src/mainwindow.h b/src/mainwindow.h index 02cd7237..c915934b 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -169,7 +169,7 @@ private Q_SLOTS: void enableNetworkAnalysis(bool); void initBookmarkBar(); - void initToolsMenu(); + void updateToolsMenu(); private: MainView *m_view; @@ -193,7 +193,8 @@ private: KPassivePopup *m_popup; QTimer *m_hidePopup; - KActionMenu *m_toolsMenu; + KMenu *m_toolsMenu; + KActionMenu *m_developerMenu; }; #endif // MAINWINDOW_H |