Port away from KRun to KIO::OpenUrlJob

Also bump minimum KF5 version to 5.71
This commit is contained in:
Andrius Štikonas 2020-09-12 23:21:18 +01:00
parent c3c5fd8837
commit 0b77294e3d
2 changed files with 5 additions and 8 deletions

View File

@ -20,7 +20,7 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
# Dependencies
set(QT_MIN_VERSION "5.10.0")
set(KF5_MIN_VERSION "5.56")
set(KF5_MIN_VERSION "5.71")
set(KPMCORE_MIN_VERSION "4.1.0")
set(CMAKE_USE_RELATIVE_PATHS OFF)

View File

@ -43,8 +43,8 @@
#include <KAboutData>
#include <KConfigGroup>
#include <KRun>
#include <KIO/CopyJob>
#include <KIO/OpenUrlJob>
#include <KJobUiDelegate>
#include <KLocalizedString>
#include <KIconLoader>
@ -440,8 +440,6 @@ void ApplyProgressDialog::browserReport()
{
QTemporaryFile file;
// Make sure the temp file is created somewhere another user can read it: KRun::runUrl() will open
// the file as the logged in user, not as the user running our application.
file.setFileTemplate(QStringLiteral("/tmp/") + QCoreApplication::applicationName() + QStringLiteral("-XXXXXX.html"));
file.setAutoRemove(false);
@ -454,11 +452,10 @@ void ApplyProgressDialog::browserReport()
<< report().toHtml()
<< html.footer();
// set the temp file's permission for everyone to read it.
file.setPermissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ReadGroup | QFile::ReadOther);
file.setPermissions(QFile::ReadOwner | QFile::WriteOwner);
if (!KRun::runUrl(QUrl::fromLocalFile(file.fileName()), QStringLiteral("text/html"), this, KRun::RunFlags()))
KMessageBox::sorry(this, xi18nc("@info", "The configured external browser could not be run. Please check your settings."), xi18nc("@title:window", "Could Not Launch Browser."));
auto *job = new KIO::OpenUrlJob(QUrl::fromLocalFile(file.fileName()), QStringLiteral("text/html"), this);
job->start();
} else
KMessageBox::sorry(this, xi18nc("@info", "Could not create temporary file <filename>%1</filename> for writing.", file.fileName()), i18nc("@title:window", "Could Not Launch Browser."));
}