┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGleb Kasachou <[email protected]>2025-07-29 11:45:35 +0300
committerMéven Car <[email protected]>2025-07-30 07:57:20 +0000
commit134b45aedc420e18352cce82ebe2b0db68d3c42e (patch)
tree8207b08b32b619a4f522a706b1c09b0429774cb3 /src
parent98c5db504685f125ef5140331c36fafc91bf2945 (diff)
Disable "Create folder" action if the location is not writable
Instead of hiding the action when the user lacks permission to create the folder, it is now shown in a disabled state. The tooltip is also updated to reflect the disabled state.
Diffstat (limited to 'src')
-rw-r--r--src/dolphinviewcontainer.cpp10
-rw-r--r--src/dolphinviewcontainer.h2
2 files changed, 9 insertions, 3 deletions
diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp
index 726e0d129..1b8791167 100644
--- a/src/dolphinviewcontainer.cpp
+++ b/src/dolphinviewcontainer.cpp
@@ -991,12 +991,11 @@ void DolphinViewContainer::slotErrorMessageFromView(const QString &message, cons
}
showMessage(i18nc("@info", "Authorization required to enter this folder."), KMessageWidget::Error, {m_authorizeToEnterFolderAction});
return;
- } else if (kioErrorCode == KIO::ERR_DOES_NOT_EXIST && m_view->url().isLocalFile() && isFolderCreatable(m_view->url())) {
+ } else if (kioErrorCode == KIO::ERR_DOES_NOT_EXIST && m_view->url().isLocalFile()) {
if (!m_createFolderAction) {
m_createFolderAction = new QAction(this);
m_createFolderAction->setText(i18nc("@action", "Create missing folder"));
m_createFolderAction->setIcon(QIcon::fromTheme(QStringLiteral("folder-new")));
- m_createFolderAction->setToolTip(i18nc("@info:tooltip", "Create the folder at this path and open it"));
connect(m_createFolderAction, &QAction::triggered, this, [this](bool) {
KIO::MkpathJob *job = KIO::mkpath(m_view->url());
KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Mkpath, {}, m_view->url(), job);
@@ -1010,6 +1009,13 @@ void DolphinViewContainer::slotErrorMessageFromView(const QString &message, cons
});
});
}
+ if (isTopMostParentFolderWritable(m_view->url())) {
+ m_createFolderAction->setEnabled(true);
+ m_createFolderAction->setToolTip(i18nc("@info:tooltip", "Create the folder at this path and open it"));
+ } else {
+ m_createFolderAction->setEnabled(false);
+ m_createFolderAction->setToolTip(i18nc("@info:tooltip", "You do not have permission to create the folder"));
+ }
showMessage(message, KMessageWidget::Error, {m_createFolderAction});
return;
}
diff --git a/src/dolphinviewcontainer.h b/src/dolphinviewcontainer.h
index 4acccdd81..d2d322b08 100644
--- a/src/dolphinviewcontainer.h
+++ b/src/dolphinviewcontainer.h
@@ -464,7 +464,7 @@ private:
* Check if a folder can be created at url.
* This method supports only local URLs.
*/
- bool isFolderCreatable(QUrl url);
+ bool isTopMostParentFolderWritable(QUrl url);
protected:
bool eventFilter(QObject *object, QEvent *event) override;