Port away from deprecated KIO::JobUiDelegate constructor

wilder-5.26
Alexander Lohnau 4 years ago
parent 2c303a07f8
commit 0b278a3a98
  1. 3
      applets/kicker/plugin/fileentry.cpp
  2. 1
      applets/kicker/plugin/processrunner.cpp
  3. 3
      applets/kicker/plugin/recentusagemodel.cpp
  4. 6
      applets/notifications/fileinfo.cpp
  5. 35
      applets/notifications/filemenu.cpp
  6. 3
      runners/baloo/baloosearchrunner.cpp
  7. 3
      runners/recentdocuments/recentdocuments.cpp

@ -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();
}

Loading…
Cancel
Save