diff options
-rw-r--r-- | src/mainwindow.cpp | 105 | ||||
-rw-r--r-- | src/mainwindow.h | 3 |
2 files changed, 66 insertions, 42 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f0cb5e61..d7eb4efd 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -74,6 +74,7 @@ #include <KStandardDirs> #include <KActionCategory> #include <KProcess> +#include <KActionMenu> // Qt Includes #include <QtCore/QTimer> @@ -110,6 +111,7 @@ MainWindow::MainWindow() , m_bookmarksBar(0) , m_popup(new KPassivePopup(this)) , m_hidePopup(new QTimer(this)) + , m_toolsMenu(0) { // creating a centralWidget containing panel, m_view and the hidden findbar QWidget *centralWidget = new QWidget; @@ -216,6 +218,8 @@ void MainWindow::initBookmarkBar() } m_bookmarksBar = new BookmarkToolBar(XMLGUIBkBar, this); Application::bookmarkProvider()->registerBookmarkBar(m_bookmarksBar); + + initToolsMenu(); } @@ -231,6 +235,58 @@ void MainWindow::configureToolbars() } +void MainWindow::initToolsMenu() +{ + if (!m_toolsMenu) + return; + + m_toolsMenu->menu()->clear(); + + 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))); + + 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(QL1S("encodings"))); + + m_toolsMenu->addSeparator(); + + m_toolsMenu->addAction(actionByName(QL1S("private_browsing"))); + m_toolsMenu->addAction(actionByName(QL1S("clear_private_data"))); + + m_toolsMenu->addSeparator(); + + 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(); + + action = m_bookmarksBar->toolBar()->toggleViewAction(); + action->setText("Bookmark 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->addSeparator(); + + this->setHelpMenuEnabled(true); + helpMenu()->setIcon(KIcon("help-browser")); + m_toolsMenu->addAction(helpMenu()->menuAction()); + m_toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Preferences))); +} + + void MainWindow::postLaunch() { setupBookmarksAndToolsShortcuts(); @@ -464,50 +520,15 @@ void MainWindow::setupActions() void MainWindow::setupTools() { kDebug() << "setup tools..."; - KActionMenu *toolsMenu = new KActionMenu(KIcon("configure"), i18n("&Tools"), this); - toolsMenu->setDelayed(false); - toolsMenu->setShortcutConfigurable(true); - toolsMenu->setShortcut( KShortcut(Qt::ALT + Qt::Key_T) ); - - toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Open))); - toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::SaveAs))); - toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Print))); - toolsMenu->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))); - toolsMenu->addAction(action); - - toolsMenu->addAction(actionByName(QL1S("encodings"))); - - toolsMenu->addSeparator(); - - toolsMenu->addAction(actionByName(QL1S("private_browsing"))); - toolsMenu->addAction(actionByName(QL1S("clear_private_data"))); - - toolsMenu->addSeparator(); - - 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"))); - toolsMenu->addAction(webMenu); - - toolsMenu->addSeparator(); - - toolsMenu->addAction(actionByName(QL1S("show_history_panel"))); - toolsMenu->addAction(actionByName(QL1S("show_bookmarks_panel"))); - toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::FullScreen))); - - toolsMenu->addSeparator(); - - helpMenu()->setIcon(KIcon("help-browser")); - toolsMenu->addAction(helpMenu()->menuAction()); - toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Preferences))); + 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) ); // adding rekonq_tools to rekonq actionCollection - actionCollection()->addAction(QL1S("rekonq_tools"), toolsMenu); + actionCollection()->addAction(QL1S("rekonq_tools"), m_toolsMenu); + + // 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 6ae99b5e..e135adca 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -167,6 +167,7 @@ private slots: void enableNetworkAnalysis(bool); void initBookmarkBar(); + void initToolsMenu(); private: MainView *m_view; @@ -188,6 +189,8 @@ private: KPassivePopup *m_popup; QTimer *m_hidePopup; + + KActionMenu *m_toolsMenu; }; #endif // MAINWINDOW_H |