]> cloud.milkyroute.net Git - dolphin.git/commitdiff
DolphinContextMenu: Show "Show menubar" entry if necessary
authorPeter Penz <peter.penz19@gmail.com>
Sun, 27 Mar 2011 17:27:27 +0000 (19:27 +0200)
committerPeter Penz <peter.penz19@gmail.com>
Sun, 27 Mar 2011 17:29:23 +0000 (19:29 +0200)
If the user has hidden the menubar and the toolbar there is no way to
get back the menu (at least not without knowing the Ctrl+M shortcut).
Show an entry in the context-menu to bring back the menubar.

src/dolphincontextmenu.cpp
src/dolphincontextmenu.h

index 07c934e33b7eb4ae92e5b0487d9855f002af3df8..0aa82b2060664de2a62ad619d147c451dfb2c090 100644 (file)
@@ -49,6 +49,7 @@
 #include <KPropertiesDialog>
 #include <KStandardAction>
 #include <KStandardDirs>
+#include <KToolBar>
 
 #include <QApplication>
 #include <QClipboard>
@@ -184,6 +185,8 @@ void DolphinContextMenu::openTrashContextMenu()
     QAction* propertiesAction = m_mainWindow->actionCollection()->action("properties");
     m_popup->addAction(propertiesAction);
 
+    addShowMenuBarAction();
+
     QAction *action = m_popup->exec(QCursor::pos());
     if (action == emptyTrashAction) {
         const QString text(i18nc("@info", "Do you really want to empty the Trash? All items will be deleted."));
@@ -365,6 +368,8 @@ void DolphinContextMenu::openViewportContextMenu()
     QAction* propertiesAction = m_popup->addAction(i18nc("@action:inmenu", "Properties"));
     propertiesAction->setIcon(KIcon("document-properties"));
 
+    addShowMenuBarAction();
+
     QAction* action = m_popup->exec(QCursor::pos());
     if (action == propertiesAction) {
         const KUrl& url = m_mainWindow->activeViewContainer()->url();
@@ -405,6 +410,16 @@ void DolphinContextMenu::insertDefaultItemActions()
     }
 }
 
+void DolphinContextMenu::addShowMenuBarAction()
+{
+    const KActionCollection* ac = m_mainWindow->actionCollection();
+    QAction* showMenuBar = ac->action(KStandardAction::name(KStandardAction::ShowMenubar));
+    if (!m_mainWindow->menuBar()->isVisible() && !m_mainWindow->toolBar()->isVisible()) {
+        m_popup->addSeparator();
+        m_popup->addAction(showMenuBar);
+    }
+}
+
 QString DolphinContextMenu::placesName(const KUrl& url) const
 {
     QString name = url.fileName();
index 1c1cabb82697e7fbae4a375e06aaf5301deb3a0b..50fce443903c32396249c5dfcc6dce7724c347fe 100644 (file)
@@ -122,6 +122,12 @@ private:
 
     void insertDefaultItemActions();
 
+    /**
+     * Adds the "Show menubar" action to the menu if the
+     * menubar is hidden.
+     */
+    void addShowMenuBarAction();
+
     /**
      * Returns a name for adding the URL \a url to the Places panel.
      */