]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinviewactionhandler.cpp
Merge remote-tracking branch 'origin/KDE/4.12'
[dolphin.git] / src / views / dolphinviewactionhandler.cpp
index c7832d725e33839229e32045882f61eca2e6af20..051174f6dbb25d787ca24151e73199f57021adc2 100644 (file)
@@ -84,6 +84,8 @@ void DolphinViewActionHandler::setCurrentView(DolphinView* view)
             this, SLOT(slotSortRoleChanged(QByteArray)));
     connect(view, SIGNAL(zoomLevelChanged(int,int)),
             this, SLOT(slotZoomLevelChanged(int,int)));
+    connect(view, SIGNAL(writeStateChanged(bool)),
+            this, SLOT(slotWriteStateChanged(bool)));
 }
 
 DolphinView* DolphinViewActionHandler::currentView()
@@ -99,6 +101,7 @@ void DolphinViewActionHandler::createActions()
     newDirAction->setText(i18nc("@action", "Create Folder..."));
     newDirAction->setShortcut(Qt::Key_F10);
     newDirAction->setIcon(KIcon("folder-new"));
+    newDirAction->setEnabled(false);    // Will be enabled in slotWriteStateChanged(bool) if the current URL is writable
     connect(newDirAction, SIGNAL(triggered()), this, SIGNAL(createDirectory()));
 
     // File menu
@@ -314,14 +317,7 @@ void DolphinViewActionHandler::slotRename()
 void DolphinViewActionHandler::slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers modifiers)
 {
     emit actionBeingHandled();
-    // Note: kde3's konq_mainwindow.cpp used to check
-    // reason == KAction::PopupMenuActivation && ...
-    // but this isn't supported anymore
-    if (modifiers & Qt::ShiftModifier) {
-        m_currentView->deleteSelectedItems();
-    } else {
-        m_currentView->trashSelectedItems();
-    }
+    m_currentView->trashSelectedItems();
 }
 
 void DolphinViewActionHandler::slotDeleteItems()
@@ -489,6 +485,11 @@ void DolphinViewActionHandler::slotHiddenFilesShownChanged(bool shown)
     showHiddenFilesAction->setChecked(shown);
 }
 
+void DolphinViewActionHandler::slotWriteStateChanged(bool isFolderWritable)
+{
+    m_actionCollection->action("create_dir")->setEnabled(isFolderWritable);
+}
+
 KToggleAction* DolphinViewActionHandler::iconsModeAction()
 {
     KToggleAction* iconsView = m_actionCollection->add<KToggleAction>("icons");
@@ -528,8 +529,10 @@ void DolphinViewActionHandler::slotSortRoleChanged(const QByteArray& role)
     if (action) {
         action->setChecked(true);
 
-        QAction* sortByMenu =  m_actionCollection->action("sort");
-        sortByMenu->setIcon(KIcon(action->icon()));
+        if (!action->icon().isNull()) {
+            QAction* sortByMenu = m_actionCollection->action("sort");
+            sortByMenu->setIcon(KIcon(action->icon()));
+        }
     }
 }