diff options
Diffstat (limited to 'src/views')
| -rw-r--r-- | src/views/dolphinviewactionhandler.cpp | 10 | ||||
| -rw-r--r-- | src/views/dolphinviewactionhandler.h | 7 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/views/dolphinviewactionhandler.cpp b/src/views/dolphinviewactionhandler.cpp index 88d5c015b..4d5dba070 100644 --- a/src/views/dolphinviewactionhandler.cpp +++ b/src/views/dolphinviewactionhandler.cpp @@ -84,6 +84,12 @@ void DolphinViewActionHandler::createActions(SelectionMode::ActionTextHelper *ac newDirAction->setEnabled(false); // Will be enabled in slotWriteStateChanged(bool) if the current URL is writable connect(newDirAction, &QAction::triggered, this, &DolphinViewActionHandler::createDirectoryTriggered); + QAction *newFileAction = m_actionCollection->addAction(QStringLiteral("create_file")); + newFileAction->setText(i18nc("@action", "Create File…")); + newFileAction->setIcon(QIcon::fromTheme(QStringLiteral("document-new"))); + newFileAction->setEnabled(false); // Will be enabled in slotWriteStateChanged(bool) if the current URL is writable + connect(newFileAction, &QAction::triggered, this, &DolphinViewActionHandler::createFileTriggered); + // File menu auto renameAction = KStandardAction::renameFile(this, &DolphinViewActionHandler::slotRename, m_actionCollection); @@ -639,7 +645,9 @@ void DolphinViewActionHandler::slotHiddenFilesShownChanged(bool shown) void DolphinViewActionHandler::slotWriteStateChanged(bool isFolderWritable) { - m_actionCollection->action(QStringLiteral("create_dir"))->setEnabled(isFolderWritable && KProtocolManager::supportsMakeDir(currentView()->url())); + const bool supportsMakeDir = KProtocolManager::supportsMakeDir(currentView()->url()); + m_actionCollection->action(QStringLiteral("create_dir"))->setEnabled(isFolderWritable && supportsMakeDir); + m_actionCollection->action(QStringLiteral("create_file"))->setEnabled(isFolderWritable); } KToggleAction *DolphinViewActionHandler::iconsModeAction() diff --git a/src/views/dolphinviewactionhandler.h b/src/views/dolphinviewactionhandler.h index f36b3d1d0..20d62cf64 100644 --- a/src/views/dolphinviewactionhandler.h +++ b/src/views/dolphinviewactionhandler.h @@ -87,6 +87,13 @@ Q_SIGNALS: */ void createDirectoryTriggered(); + /** + * Emitted if the user requested creating a new file. + * The receiver of the signal (DolphinMainWindow or DolphinPart) invokes + * the method createFile of their KNewFileMenu instance. + */ + void createFileTriggered(); + /** Used to request either entering or leaving of selection mode */ void selectionModeChangeTriggered(bool enabled, SelectionMode::BottomBar::Contents bottomBarContents = SelectionMode::BottomBar::Contents::GeneralContents); |
