Commit ebd4082c authored by Laurent Montel's avatar Laurent Montel
Browse files

Port away from deprecated KIO code

parent 3e574109
Pipeline #220500 passed with stage
in 11 minutes and 20 seconds
......@@ -25,7 +25,12 @@
#include <MessageCore/StringUtil>
#include <Akonadi/ItemFetchJob>
#include <kio_version.h>
#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0)
#include <KIO/JobUiDelegateFactory>
#else
#include <KIO/JobUiDelegate>
#endif
#include <QIcon>
#include <QMenu>
......@@ -683,7 +688,11 @@ void AttachmentControllerBase::openWith(const KService::Ptr &offer)
// If offer is null, this will show the "open with" dialog
auto job = new KIO::ApplicationLauncherJob(offer);
job->setUrls({url});
#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0)
job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, d->wParent));
#else
job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, d->wParent));
#endif
job->start();
connect(job, &KJob::result, this, [tempFile, job]() {
if (job->error()) {
......@@ -704,7 +713,11 @@ void AttachmentControllerBase::openAttachment(const AttachmentPart::Ptr &part)
}
tempFile->setPermissions(QFile::ReadUser);
auto job = new KIO::OpenUrlJob(QUrl::fromLocalFile(tempFile->fileName()), QString::fromLatin1(part->mimeType()));
#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0)
job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, d->wParent));
#else
job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, d->wParent));
#endif
job->setDeleteTemporaryFile(true);
connect(job, &KIO::OpenUrlJob::result, this, [this, tempFile](KJob *job) {
if (job->error() == KIO::ERR_USER_CANCELED) {
......
......@@ -49,7 +49,12 @@
#include <KEmailAddress>
#include <KFileItemActions>
#include <KIO/ApplicationLauncherJob>
#include <kio_version.h>
#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0)
#include <KIO/JobUiDelegateFactory>
#else
#include <KIO/JobUiDelegate>
#endif
#include <KIO/OpenUrlJob>
#include <KLocalizedString>
#include <KMessageBox>
......@@ -279,7 +284,11 @@ void ViewerPrivate::openAttachment(KMime::Content *node, const QUrl &url)
if (ct->mimeType() == "message/external-body") {
if (ct->hasParameter(QStringLiteral("url"))) {
auto job = new KIO::OpenUrlJob(url, QStringLiteral("text/html"));
#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0)
job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, q));
#else
job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, q));
#endif
job->start();
return;
}
......@@ -680,7 +689,11 @@ void ViewerPrivate::attachmentOpenWith(KMime::Content *node, const KService::Ptr
auto job = new KIO::ApplicationLauncherJob(offer);
job->setUrls({url});
#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0)
job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, mMainWindow));
#else
job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, mMainWindow));
#endif
job->start();
connect(job, &KJob::result, this, [url, job]() {
if (job->error()) {
......@@ -1932,7 +1945,11 @@ void ViewerPrivate::executeRunner(const QUrl &url)
{
if (!MessageViewer::Util::handleUrlWithQDesktopServices(url)) {
auto job = new KIO::OpenUrlJob(url);
#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0)
job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, viewer()));
#else
job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, viewer()));
#endif
job->setRunExecutables(false);
job->start();
}
......@@ -2259,7 +2276,11 @@ void ViewerPrivate::slotExportHtmlPageSuccess(const QString &filename)
{
const QUrl url(QUrl::fromLocalFile(filename));
auto job = new KIO::OpenUrlJob(url, QStringLiteral("text/html"), q);
#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0)
job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, q));
#else
job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, q));
#endif
job->setDeleteTemporaryFile(true);
job->start();
......
......@@ -6,7 +6,12 @@
#include "opensavedfilefolderwidget.h"
#include <kio_version.h>
#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0)
#include <KIO/JobUiDelegateFactory>
#else
#include <KIO/JobUiDelegate>
#endif
#include <KIO/OpenFileManagerWindowJob>
#include <KIO/OpenUrlJob>
#include <KLocalizedString>
......@@ -70,7 +75,11 @@ void OpenSavedFileFolderWidget::slotOpenFile()
{
for (const auto &url : std::as_const(mUrls)) {
auto job = new KIO::OpenUrlJob(url);
#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0)
job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
#else
job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
#endif
job->setDeleteTemporaryFile(true);
connect(job, &KIO::OpenUrlJob::result, this, [this](KJob *job) {
if (job->error() == KIO::ERR_USER_CANCELED) {
......
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