]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphincontextmenu.cpp
If 'remember view-properties' is selected, store the .directory files only if the...
[dolphin.git] / src / dolphincontextmenu.cpp
index 116edf4f0b9f942f16bf7f147decb9ca7e59aa68..a36d1aeb06a174227942a67cd668db9c68940636 100644 (file)
@@ -37,6 +37,7 @@
 #include <kmenubar.h>
 #include <kmessagebox.h>
 #include <kmimetypetrader.h>
+#include <kmodifierkeyinfo.h>
 #include <knewfilemenu.h>
 #include <konqmimedata.h>
 #include <konq_operations.h>
@@ -53,7 +54,7 @@
 #include "views/dolphinview.h"
 #include "views/viewmodecontroller.h"
 
-KModifierKeyInfo* DolphinContextMenu::m_keyInfo = 0;
+K_GLOBAL_STATIC(KModifierKeyInfo, m_keyInfo)
 
 DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent,
                                        const KFileItem& fileInfo,
@@ -101,7 +102,7 @@ void DolphinContextMenu::setCustomActions(const QList<QAction*>& actions)
 void DolphinContextMenu::open()
 {
     // get the context information
-    if (m_baseUrl.protocol() == "trash") {
+    if (m_baseUrl.protocol() == QLatin1String("trash")) {
         m_context |= TrashContext;
     }
 
@@ -127,9 +128,10 @@ void DolphinContextMenu::open()
 
 void DolphinContextMenu::initializeModifierKeyInfo()
 {
-    if (m_keyInfo == 0) {
-        m_keyInfo = new KModifierKeyInfo();
-    }
+    // Access m_keyInfo, so that it gets instantiated by
+    // K_GLOBAL_STATIC
+    KModifierKeyInfo* keyInfo = m_keyInfo;
+    Q_UNUSED(keyInfo);
 }
 
 void DolphinContextMenu::slotKeyModifierPressed(Qt::Key key, bool pressed)
@@ -217,6 +219,7 @@ void DolphinContextMenu::openItemContextMenu()
 {
     Q_ASSERT(!m_fileInfo.isNull());
 
+    QAction* addToPlacesAction = 0;
     if (m_fileInfo.isDir() && (m_selectedUrls.count() == 1)) {
         // setup 'Create New' menu
         DolphinNewFileMenu* newFileMenu = new DolphinNewFileMenu(m_popup.data(), m_mainWindow);
@@ -235,6 +238,14 @@ void DolphinContextMenu::openItemContextMenu()
         // insert 'Open in new window' and 'Open in new tab' entries
         m_popup->addAction(m_mainWindow->actionCollection()->action("open_in_new_window"));
         m_popup->addAction(m_mainWindow->actionCollection()->action("open_in_new_tab"));
+
+        // insert 'Add to Places' entry
+        if (!placeExists(m_fileInfo.url())) {
+            addToPlacesAction = m_popup->addAction(KIcon("bookmark-new"),
+                                                   i18nc("@action:inmenu Add selected folder to places",
+                                                         "Add to Places"));
+        }
+
         m_popup->addSeparator();
     }
     addShowMenubarAction();
@@ -253,14 +264,6 @@ void DolphinContextMenu::openItemContextMenu()
         m_copyToMenu.setItems(m_selectedItems);
         m_copyToMenu.setReadOnly(!capabilities().supportsWriting());
         m_copyToMenu.addActionsTo(m_popup.data());
-        m_popup->addSeparator();
-    }
-
-    // insert 'Add to Places' entry if exactly one item is selected
-    QAction* addToPlacesAction = 0;
-    if (m_fileInfo.isDir() && (m_selectedUrls.count() == 1) && !placeExists(m_fileInfo.url())) {
-        addToPlacesAction = m_popup->addAction(KIcon("bookmark-new"),
-                                             i18nc("@action:inmenu Add selected folder to places", "Add to Places"));
     }
 
     // insert 'Properties...' entry
@@ -426,9 +429,7 @@ void DolphinContextMenu::addServiceActions(KFileItemActions& fileItemActions)
     fileItemActions.addOpenWithActionsTo(m_popup.data(), "DesktopEntryName != 'dolphin'");
 
     // insert 'Actions' sub menu
-    if (fileItemActions.addServiceActionsTo(m_popup.data())) {
-        m_popup->addSeparator();
-    }
+    fileItemActions.addServiceActionsTo(m_popup.data());
 }
 
 void DolphinContextMenu::addVersionControlActions()