]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphincontextmenu.cpp
The apply button in the settings dialog now disables itself when settings are applied...
[dolphin.git] / src / dolphincontextmenu.cpp
index 1af74b2e31715f0034ba6e8f8c01da5d9c9c137a..1d99f96373e7dcce4817954c7946dfc9b1eea1cc 100644 (file)
@@ -21,7 +21,8 @@
 #include "dolphincontextmenu.h"
 
 #include "dolphinmainwindow.h"
-#include "dolphinsettings.h"
+#include "dolphinnewmenu.h"
+#include "settings/dolphinsettings.h"
 #include "dolphinview.h"
 #include "dolphinviewcontainer.h"
 #include "dolphin_generalsettings.h"
@@ -59,7 +60,8 @@ DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent,
     m_capabilities(0),
     m_fileInfo(fileInfo),
     m_baseUrl(baseUrl),
-    m_context(NoContext)
+    m_context(NoContext),
+    m_copyToMenu(parent)
 {
     // The context menu either accesses the URLs of the selected items
     // or the items itself. To increase the performance both lists are cached.
@@ -172,6 +174,24 @@ void DolphinContextMenu::openItemContextMenu()
     Q_ASSERT(!m_fileInfo.isNull());
 
     KMenu* popup = new KMenu(m_mainWindow);
+    if (m_fileInfo.isDir() && (m_selectedUrls.count() == 1)) {
+        // setup 'Create New' menu
+        DolphinNewMenu* newMenu = new DolphinNewMenu(popup, m_mainWindow);
+        newMenu->slotCheckUpToDate();
+        newMenu->setPopupFiles(m_fileInfo.url());
+        newMenu->setEnabled(capabilities().supportsWriting());
+
+        KMenu* menu = newMenu->menu();
+        menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
+        menu->setIcon(KIcon("document-new"));
+        popup->addMenu(newMenu->menu());
+        popup->addSeparator();
+
+        // insert 'Open in new window' and 'Open in new tab' entries
+        popup->addAction(m_mainWindow->actionCollection()->action("open_in_new_window"));
+        popup->addAction(m_mainWindow->actionCollection()->action("open_in_new_tab"));
+        popup->addSeparator();
+    }
     addShowMenubarAction(popup);
     insertDefaultItemActions(popup);
 
@@ -264,8 +284,10 @@ void DolphinContextMenu::openViewportContextMenu()
     QAction* action = popup->exec(QCursor::pos());
     if (action == propertiesAction) {
         const KUrl& url = m_mainWindow->activeViewContainer()->url();
-        KPropertiesDialog dialog(url, m_mainWindow);
-        dialog.exec();
+
+        KPropertiesDialog* dialog = new KPropertiesDialog(url, m_mainWindow);
+        dialog->setAttribute(Qt::WA_DeleteOnClose);
+        dialog->show();
     } else if (action == addToPlacesAction) {
         const KUrl& url = m_mainWindow->activeViewContainer()->url();
         if (url.isValid()) {
@@ -296,8 +318,10 @@ void DolphinContextMenu::insertDefaultItemActions(KMenu* popup)
     popup->addAction(renameAction);
 
     // insert 'Move to Trash' and (optionally) 'Delete'
-    KConfigGroup kdeConfig(KGlobal::config(), "KDE");
-    bool showDeleteCommand = kdeConfig.readEntry("ShowDeleteCommand", false);
+    KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig("kdeglobals", KConfig::IncludeGlobals);
+    KConfigGroup configGroup(globalConfig, "KDE");
+    bool showDeleteCommand = configGroup.readEntry("ShowDeleteCommand", false);
+
     const KUrl& url = m_mainWindow->activeViewContainer()->url();
     if (url.isLocalFile()) {
         QAction* moveToTrashAction = collection->action("move_to_trash");
@@ -316,10 +340,6 @@ void DolphinContextMenu::addShowMenubarAction(KMenu* menu)
 {
     KAction* showMenuBar = m_mainWindow->showMenuBarAction();
     if (!m_mainWindow->menuBar()->isVisible()) {
-        // TODO: it should not be necessary to uncheck the menu
-        // bar action, but currently the action states don't get
-        // updated if the menu is disabled
-        showMenuBar->setChecked(false);
         menu->addAction(showMenuBar);
         menu->addSeparator();
     }