X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/9706fbe6fedfa01f38a01b7dbe8d111e6745928d..619300e36035794cd885c6248af2c9d906453eea:/src/dolphinviewcontainer.cpp?ds=sidebyside diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index ee4bb6e4c..862654a6b 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -76,6 +77,7 @@ DolphinViewContainer::DolphinViewContainer(const QUrl &url, QWidget *parent) , m_searchModeEnabled(false) , m_adminBar{nullptr} , m_authorizeToEnterFolderAction{nullptr} + , m_createFolderAction(nullptr) , m_messageWidget(nullptr) , m_selectionModeTopBar{nullptr} , m_view(nullptr) @@ -973,6 +975,27 @@ 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()) { + if (!m_createFolderAction) { + m_createFolderAction = new QAction(this); + m_createFolderAction->setText(i18nc("@action", "Create")); + m_createFolderAction->setIcon(QIcon::fromTheme(QStringLiteral("folder-new"))); + m_createFolderAction->setToolTip(i18nc("@info:tooltip", "Create this folder 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); + connect(job, &KJob::result, this, [this](KJob *job) { + if (job->error()) { + showErrorMessage(job->errorString()); + } else { + m_view->reload(); + m_messageWidget->animatedHide(); + } + }); + }); + } + showMessage(message, KMessageWidget::Error, {m_createFolderAction}); + return; } Q_EMIT showErrorMessage(message); }