Commit 0b278a3a authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Port away from deprecated KIO::JobUiDelegate constructor

parent 2c303a07
Pipeline #227144 passed with stage
in 7 minutes and 12 seconds
......@@ -11,6 +11,7 @@
#include <KFileItem>
#include <KIO/JobUiDelegate>
#include <KIO/JobUiDelegateFactory>
#include <KIO/OpenUrlJob>
#include <KIO/StatJob>
......@@ -108,7 +109,7 @@ bool FileEntry::run(const QString &actionId, const QVariant &argument)
if (actionId.isEmpty()) {
auto job = new KIO::OpenUrlJob(m_fileItem->url());
job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, QApplication::activeWindow()));
job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, QApplication::activeWindow()));
job->setShowOpenOrExecuteDialog(true);
job->start();
......
......@@ -8,6 +8,7 @@
#include <KIO/ApplicationLauncherJob>
#include <KNotificationJobUiDelegate>
#include <QDebug>
ProcessRunner::ProcessRunner(QObject *parent)
: QObject(parent)
......
......@@ -32,6 +32,7 @@
#include <KFileItem>
#include <KIO/ApplicationLauncherJob>
#include <KIO/JobUiDelegate>
#include <KIO/JobUiDelegateFactory>
#include <KIO/OpenFileManagerWindowJob>
#include <KIO/OpenUrlJob>
#include <KLocalizedString>
......@@ -367,7 +368,7 @@ bool RecentUsageModel::trigger(int row, const QString &actionId, const QVariant
const QUrl resourceUrl = docData(resource, Kicker::UrlRole, mimeType).toUrl();
auto job = new KIO::OpenUrlJob(resourceUrl);
job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, QApplication::activeWindow()));
job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, QApplication::activeWindow()));
job->setShowOpenOrExecuteDialog(true);
job->start();
......
......@@ -12,11 +12,11 @@
#include <KApplicationTrader>
#include <KAuthorized>
#include <KLocalizedString>
#include <KIO/ApplicationLauncherJob>
#include <KIO/JobUiDelegate>
#include <KIO/JobUiDelegateFactory>
#include <KIO/MimeTypeFinderJob>
#include <KIO/OpenUrlJob>
#include <KLocalizedString>
#include <KNotificationJobUiDelegate>
FileInfo::FileInfo(QObject *parent)
......@@ -145,7 +145,7 @@ void FileInfo::mimeTypeFound(const QString &mimeType)
job->setUiDelegate(new KNotificationJobUiDelegate(KJobUiDelegate::AutoErrorHandlingEnabled));
} else {
// needs KIO::JobUiDelegate for open with handler
job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoErrorHandlingEnabled, nullptr /*widget*/));
job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoErrorHandlingEnabled, nullptr /*widget*/));
}
job->setUrls({m_url});
job->start();
......
......@@ -29,6 +29,7 @@
#include <KIO/FileUndoManager>
#include <KIO/JobUiDelegate>
#include <KIO/OpenFileManagerWindowJob>
#include <KIO/WidgetsAskUserActionHandler>
FileMenu::FileMenu(QObject *parent)
: QObject(parent)
......@@ -147,14 +148,16 @@ void FileMenu::open(int x, int y)
const bool canTrash = itemProperties.isLocal() && itemProperties.supportsMoving();
if (canTrash) {
auto moveToTrashLambda = [this] {
const QList<QUrl> urls{m_url};
KIO::JobUiDelegate uiDelegate;
if (uiDelegate.askDeleteConfirmation(urls, KIO::JobUiDelegate::Trash, KIO::JobUiDelegate::DefaultConfirmation)) {
auto *job = KIO::trash(urls);
job->uiDelegate()->setAutoErrorHandlingEnabled(true);
KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Trash, urls, QUrl(QStringLiteral("trash:/")), job);
}
auto handler = new KIO::WidgetsAskUserActionHandler(this);
connect(handler, &KIO::WidgetsAskUserActionHandler::askUserDeleteResult, [handler](bool allow, const QList<QUrl> &urls) {
if (allow) {
auto job = KIO::trash(urls);
job->uiDelegate()->setAutoErrorHandlingEnabled(true);
KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Trash, urls, QUrl(QStringLiteral("trash:/")), job);
}
handler->deleteLater();
});
handler->askUserDelete({m_url}, KIO::AskUserActionInterface::Trash, KIO::AskUserActionInterface::DefaultConfirmation);
};
QAction *moveToTrashAction = KStandardAction::moveToTrash(this, moveToTrashLambda, menu);
moveToTrashAction->setShortcut({}); // Can't focus notification to press Delete
......@@ -166,13 +169,15 @@ void FileMenu::open(int x, int y)
if (itemProperties.supportsDeleting() && (!canTrash || showDeleteCommand)) {
auto deleteLambda = [this] {
const QList<QUrl> urls{m_url};
KIO::JobUiDelegate uiDelegate;
if (uiDelegate.askDeleteConfirmation(urls, KIO::JobUiDelegate::Delete, KIO::JobUiDelegate::DefaultConfirmation)) {
auto *job = KIO::del(urls);
job->uiDelegate()->setAutoErrorHandlingEnabled(true);
}
auto handler = new KIO::WidgetsAskUserActionHandler(this);
connect(handler, &KIO::WidgetsAskUserActionHandler::askUserDeleteResult, [handler](bool allow, const QList<QUrl> &urls) {
if (allow) {
auto job = KIO::del(urls);
job->uiDelegate()->setAutoErrorHandlingEnabled(true);
}
handler->deleteLater();
});
handler->askUserDelete({m_url}, KIO::AskUserActionInterface::Delete, KIO::AskUserActionInterface::DefaultConfirmation);
};
QAction *deleteAction = KStandardAction::deleteFile(this, deleteLambda, menu);
deleteAction->setShortcut({});
......
......@@ -21,6 +21,7 @@
#include <Baloo/Query>
#include <KIO/JobUiDelegate>
#include <KIO/JobUiDelegateFactory>
#include <KIO/OpenFileManagerWindowJob>
#include <KIO/OpenUrlJob>
#include <KNotificationJobUiDelegate>
......@@ -159,7 +160,7 @@ void SearchRunner::Run(const QString &id, const QString &actionId)
}
auto *job = new KIO::OpenUrlJob(url);
job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, QApplication::activeWindow()));
job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, QApplication::activeWindow()));
job->setShowOpenOrExecuteDialog(true);
job->start();
}
......@@ -12,6 +12,7 @@
#include <KIO/Job>
#include <KIO/JobUiDelegate>
#include <KIO/JobUiDelegateFactory>
#include <KIO/OpenFileManagerWindowJob>
#include <KIO/OpenUrlJob>
#include <KLocalizedString>
......@@ -110,7 +111,7 @@ void RecentDocuments::run(const Plasma::RunnerContext &context, const Plasma::Qu
}
auto *job = new KIO::OpenUrlJob(url);
job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, QApplication::activeWindow()));
job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, QApplication::activeWindow()));
job->setShowOpenOrExecuteDialog(true);
job->start();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment