From 280fa647f15faf8fdd415328d7ff1fd15c621fc9 Mon Sep 17 00:00:00 2001 From: Frank Reininghaus Date: Sun, 29 Dec 2013 09:23:17 +0100 Subject: [PATCH] Disable the "Create folder" action in read-only directories The action can be triggered, e.g., by pressing F10. BUG: 294054 FIXED-IN: 4.12.1 REVIEW: 114560 --- src/views/dolphinviewactionhandler.cpp | 8 ++++++++ src/views/dolphinviewactionhandler.h | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/src/views/dolphinviewactionhandler.cpp b/src/views/dolphinviewactionhandler.cpp index 9a9718c333..051174f6db 100644 --- a/src/views/dolphinviewactionhandler.cpp +++ b/src/views/dolphinviewactionhandler.cpp @@ -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 @@ -482,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("icons"); diff --git a/src/views/dolphinviewactionhandler.h b/src/views/dolphinviewactionhandler.h index edbe41b900..e80ffc0dff 100644 --- a/src/views/dolphinviewactionhandler.h +++ b/src/views/dolphinviewactionhandler.h @@ -196,6 +196,11 @@ private Q_SLOTS: */ void slotHiddenFilesShownChanged(bool shown); + /** + * Updates the state of the 'Create Folder...' action. + */ + void slotWriteStateChanged(bool isFolderWritable); + /** * Opens the view properties dialog, which allows to modify the properties * of the currently active view.