[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kcm-grub2/frameworks] /: Initial port to KF5
From:       Alexander Volkov <null () kde ! org>
Date:       2018-05-11 16:44:08
Message-ID: E1fHB9M-00065t-AX () code ! kde ! org
[Download RAW message or body]

Git commit 7d3c3f70cfebc96d8447a9d21c3a0ff72f3d5379 by Alexander Volkov.
Committed on 11/05/2018 at 17:41.
Pushed by volkov into branch 'frameworks'.

Initial port to KF5

Without QApt and QPackageKit backends.

M  +61   -16   CMakeLists.txt
M  +1    -1    other/CMakeLists.txt
M  +1    -1    other/kcm_grub2.desktop
M  +5    -7    src/CMakeLists.txt
M  +7    -6    src/convertDlg.cpp
M  +5    -7    src/helper/CMakeLists.txt
M  +40   -23   src/helper/helper.cpp
M  +2    -0    src/helper/helper.h
M  +30   -16   src/installDlg.cpp
M  +66   -89   src/kcm_grub2.cpp
M  +0    -1    src/kcm_grub2.h

https://commits.kde.org/kcm-grub2/7d3c3f70cfebc96d8447a9d21c3a0ff72f3d5379

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8fbf4c4..9291ed7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,16 @@
 project(kcm-grub2)
+
+cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
+set(PROJECT_VERSION "5.12.80")
+set(QT_MIN_VERSION "5.9.0")
+find_package(ECM 1.0.0 REQUIRED NO_MODULE)
+set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} \
${CMAKE_CURRENT_SOURCE_DIR}/cmake) +include(ECMInstallIcons)
+include(KDEInstallDirs)
+include(KDECMakeSettings)
+include(KDECompilerSettings)
+include(FeatureSummary)
+
 set(KCM_GRUB2_VERSION_MAJOR "0")
 set(KCM_GRUB2_VERSION_MINOR "6")
 set(KCM_GRUB2_VERSION_PATCH "4")
@@ -6,34 +18,67 @@ set(KCM_GRUB2_VERSION \
"${KCM_GRUB2_VERSION_MAJOR}.${KCM_GRUB2_VERSION_MINOR}.${K  
 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
 
-find_package(Qt4 4.6.0 REQUIRED)
-find_package(KDE4 4.4.0 REQUIRED)
-include(KDE4Defaults)
 include(GRUBPaths)
 
+find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core Gui Widgets)
+
+find_package(KF5 REQUIRED COMPONENTS
+    Auth
+    KDELibs4Support
+)
+
 # Qt
 add_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII \
-DQT_NO_CAST_FROM_BYTEARRAY -DQT_NO_KEYWORDS -DQT_STRICT_ITERATORS \
-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)  # ImageMagick
 add_definitions(-DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16)
 
-macro_optional_find_package(ImageMagick COMPONENTS Magick++ MagickCore)
-macro_log_feature(ImageMagick_FOUND "ImageMagick" "Create splash images compatible \
                with GRUB2" "http://www.imagemagick.org/" FALSE "" "")
-macro_bool_to_01(ImageMagick_FOUND HAVE_IMAGEMAGICK)
+find_package(ImageMagick COMPONENTS Magick++ MagickCore)
+set_package_properties(ImageMagick PROPERTIES
+                       DESCRIPTION "Create splash images compatible with GRUB2"
+                       URL "http://www.imagemagick.org/"
+                       TYPE OPTIONAL)
+if(ImageMagick_FOUND)
+    set(HAVE_IMAGEMAGICK 1)
+else()
+    set(HAVE_IMAGEMAGICK 0)
+endif()
 
-macro_optional_find_package(HD)
-macro_log_feature(HD_FOUND "hwinfo" "Retrieve list of resolutions valid in GRUB2" \
                "http://www.opensuse.org/" FALSE "" "")
-macro_bool_to_01(HD_FOUND HAVE_HD)
+find_package(HD)
+set_package_properties(hwinfo PROPERTIES
+                       DESCRIPTION "Retrieve list of resolutions valid in GRUB2"
+                       URL "http://www.opensuse.org/"
+                       TYPE OPTIONAL)
+if(HD_FOUND)
+    set(HAVE_HD 1)
+else()
+    set(HAVE_HD 0)
+endif()
 
-macro_optional_find_package(QApt)
-macro_log_feature(QAPT_FOUND "LibQApt" "Remove unneeded old entries (qapt backend)" \
                "https://projects.kde.org/projects/extragear/sysadmin/libqapt/" FALSE \
                "" "")
-macro_bool_to_01(QAPT_FOUND HAVE_QAPT)
+find_package(QApt)
+set_package_properties(QApt PROPERTIES
+                       DESCRIPTION "Remove unneeded old entries (qapt backend)"
+                       URL \
"https://projects.kde.org/projects/extragear/sysadmin/libqapt/" +                     \
TYPE OPTIONAL) +if(QAPT_FOUND)
+    set(HAVE_QAPT 1)
+else()
+    set(HAVE_QAPT 0)
+endif()
 
-macro_optional_find_package(QPackageKit)
-macro_log_feature(QPACKAGEKIT_FOUND "QPackageKit" "Remove unneeded old entries \
                (qpackagekit backend)" "http://www.packagekit.org/" FALSE "" "")
-macro_bool_to_01(QPACKAGEKIT_FOUND HAVE_QPACKAGEKIT)
+find_package(QPackageKit)
+set_package_properties(QPackageKit PROPERTIES
+                       DESCRIPTION "Remove unneeded old entries (qpackagekit \
backend)" +                       URL "http://www.packagekit.org/"
+                       TYPE OPTIONAL)
+if(QPACKAGEKIT_FOUND)
+    set(HAVE_QPACKAGEKIT 1)
+else()
+    set(HAVE_QPACKAGEKIT 0)
+endif()
 
-macro_display_feature_log()
 configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/src/config.h)
 
+feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
+
 add_subdirectory(other)
 add_subdirectory(src)
diff --git a/other/CMakeLists.txt b/other/CMakeLists.txt
index 3564d80..59db95f 100644
--- a/other/CMakeLists.txt
+++ b/other/CMakeLists.txt
@@ -1,2 +1,2 @@
 # Install
-install(FILES kcm_grub2.desktop DESTINATION ${SERVICES_INSTALL_DIR})
+install(FILES kcm_grub2.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
diff --git a/other/kcm_grub2.desktop b/other/kcm_grub2.desktop
index 90b3ee2..7fbb0bf 100644
--- a/other/kcm_grub2.desktop
+++ b/other/kcm_grub2.desktop
@@ -2,7 +2,7 @@
 Icon=system-reboot
 Type=Service
 X-KDE-ServiceTypes=KCModule
-Exec=kcmshell4 kcm_grub2
+Exec=kcmshell5 kcm_grub2
 
 X-KDE-Library=kcm_grub2
 X-KDE-ParentApp=kcontrol
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2e46392..0daa4fa 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,7 +1,6 @@
 add_subdirectory(helper)
 
 # Set Include Directories
-set(kcm_grub2_INCLUDE_DIRS ${KDE4_INCLUDES})
 if(HAVE_IMAGEMAGICK)
     set(kcm_grub2_INCLUDE_DIRS ${kcm_grub2_INCLUDE_DIRS} \
${ImageMagick_INCLUDE_DIRS})  endif(HAVE_IMAGEMAGICK)
@@ -13,14 +12,14 @@ endif(HAVE_QAPT)
 
 # Set Sources
 set(kcm_grub2_SRCS common.cpp entry.cpp installDlg.cpp kcm_grub2.cpp)
-kde4_add_ui_files(kcm_grub2_SRCS ../ui/installDlg.ui ../ui/kcm_grub2.ui)
+qt5_wrap_ui(kcm_grub2_SRCS ../ui/installDlg.ui ../ui/kcm_grub2.ui)
 if(HAVE_IMAGEMAGICK)
     set(kcm_grub2_SRCS ${kcm_grub2_SRCS} convertDlg.cpp)
-    kde4_add_ui_files(kcm_grub2_SRCS ../ui/convertDlg.ui)
+    qt5_wrap_ui(kcm_grub2_SRCS ../ui/convertDlg.ui)
 endif(HAVE_IMAGEMAGICK)
 if(HAVE_QAPT OR HAVE_QPACKAGEKIT)
     set(kcm_grub2_SRCS ${kcm_grub2_SRCS} removeDlg.cpp)
-    kde4_add_ui_files(kcm_grub2_SRCS ../ui/removeDlg.ui)
+    qt5_wrap_ui(kcm_grub2_SRCS ../ui/removeDlg.ui)
 endif(HAVE_QAPT OR HAVE_QPACKAGEKIT)
 if(HAVE_QAPT)
     if(QAPT_VERSION_MAJOR EQUAL 1)
@@ -33,7 +32,6 @@ elseif(HAVE_QPACKAGEKIT)
 endif(HAVE_QAPT)
 
 # Set Link Libraries
-set(kcm_grub2_LINK_LIBS ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${KDE4_SOLID_LIBS})
 if(HAVE_IMAGEMAGICK)
     set(kcm_grub2_LINK_LIBS ${kcm_grub2_LINK_LIBS} ${ImageMagick_LIBRARIES})
 endif(HAVE_IMAGEMAGICK)
@@ -50,8 +48,8 @@ endif(HAVE_IMAGEMAGICK)
 
 # Build & Link
 include_directories(${kcm_grub2_INCLUDE_DIRS})
-kde4_add_plugin(kcm_grub2 ${kcm_grub2_SRCS})
-target_link_libraries(kcm_grub2 ${kcm_grub2_LINK_LIBS})
+add_library(kcm_grub2 MODULE ${kcm_grub2_SRCS})
+target_link_libraries(kcm_grub2 ${kcm_grub2_LINK_LIBS} Qt5::Core Qt5::Widgets \
KF5::Auth KF5::KIOCore KF5::Solid KF5::KDELibs4Support)  
 # Install
 install(TARGETS kcm_grub2 DESTINATION ${PLUGIN_INSTALL_DIR})
diff --git a/src/convertDlg.cpp b/src/convertDlg.cpp
index 6e1cca9..4cc14fa 100644
--- a/src/convertDlg.cpp
+++ b/src/convertDlg.cpp
@@ -19,9 +19,10 @@
 #include "convertDlg.h"
 
 //KDE
-#include <KFileDialog>
 #include <KMessageBox>
 #include <KMimeType>
+#include <KLocalizedString>
+#include <KUrl>
 
 //ImageMagick
 #include <Magick++.h>
@@ -48,11 +49,11 @@ ConvertDialog::ConvertDialog(QWidget *parent, Qt::WFlags flags) : \
KDialog(parent  QString writeFilter = QString(QLatin1String("*%1|%5 (%1)\n*%2|%6 \
(%2)\n*%3 *%4|%7 (%3 %4)")).arg(QLatin1String(".png"), QLatin1String(".tga"), \
QLatin1String(".jpg"), QLatin1String(".jpeg"), \
KMimeType::mimeType(QLatin1String("image/png"))->comment(), \
KMimeType::mimeType(QLatin1String("image/x-tga"))->comment(), \
KMimeType::mimeType(QLatin1String("image/jpeg"))->comment());  
     ui->kurlrequester_image->setMode(KFile::File | KFile::ExistingOnly | \
                KFile::LocalOnly);
-    ui->kurlrequester_image->fileDialog()->setOperationMode(KFileDialog::Opening);
-    ui->kurlrequester_image->fileDialog()->setFilter(readFilter);
+    ui->kurlrequester_image->setAcceptMode(QFileDialog::AcceptOpen);
+    ui->kurlrequester_image->setFilter(readFilter);
     ui->kurlrequester_converted->setMode(KFile::File | KFile::LocalOnly);
-    ui->kurlrequester_converted->fileDialog()->setOperationMode(KFileDialog::Saving);
                
-    ui->kurlrequester_converted->fileDialog()->setFilter(writeFilter);
+    ui->kurlrequester_converted->setAcceptMode(QFileDialog::AcceptSave);
+    ui->kurlrequester_converted->setFilter(writeFilter);
 }
 ConvertDialog::~ConvertDialog()
 {
@@ -76,7 +77,7 @@ void ConvertDialog::slotButtonClicked(int button)
         } else if (ui->spinBox_width->value() == 0 || ui->spinBox_height->value() == \
                0) {
             KMessageBox::information(this, i18nc("@info", "Please fill in both \
<interface>Width</interface> and <interface>Height</interface> fields."));  return;
-        } else if (!QFileInfo(ui->kurlrequester_converted->url().directory()).isWritable()) \
{ +        } else if \
                (!QFileInfo(KUrl(ui->kurlrequester_converted->url()).directory()).isWritable()) \
                {
             KMessageBox::information(this, i18nc("@info", "You do not have write \
permissions in this directory, please select another destination."));  return;
         }
diff --git a/src/helper/CMakeLists.txt b/src/helper/CMakeLists.txt
index 6a8792b..03f90f7 100644
--- a/src/helper/CMakeLists.txt
+++ b/src/helper/CMakeLists.txt
@@ -1,5 +1,4 @@
 # Set Include Directories
-set(kcmgrub2helper_INCLUDE_DIRS ${KDE4_INCLUDES})
 if(HAVE_HD)
     set(kcmgrub2helper_INCLUDE_DIRS ${kcmgrub2helper_INCLUDE_DIRS} \
${HD_INCLUDE_DIR})  endif(HAVE_HD)
@@ -8,17 +7,16 @@ endif(HAVE_HD)
 set(kcmgrub2helper_SRCS helper.cpp)
 
 # Set Link Libraries
-set(kcmgrub2helper_LINK_LIBS ${KDE4_KDECORE_LIBS})
 if(HAVE_HD)
     set(kcmgrub2helper_LINK_LIBS ${kcmgrub2helper_LINK_LIBS} ${HD_LIBRARY})
 endif(HAVE_HD)
 
 # Build & Link
 include_directories(${kcmgrub2helper_INCLUDE_DIRS})
-kde4_add_executable(kcmgrub2helper ${kcmgrub2helper_SRCS})
-target_link_libraries(kcmgrub2helper ${kcmgrub2helper_LINK_LIBS})
+add_executable(kcmgrub2helper ${kcmgrub2helper_SRCS})
+target_link_libraries(kcmgrub2helper ${kcmgrub2helper_LINK_LIBS} \
KF5::KDELibs4Support)  
 # Install
-install(TARGETS kcmgrub2helper DESTINATION ${LIBEXEC_INSTALL_DIR})
-kde4_install_auth_helper_files(kcmgrub2helper org.kde.kcontrol.kcmgrub2 root)
-kde4_install_auth_actions(org.kde.kcontrol.kcmgrub2 kcmgrub2.actions)
+install(TARGETS kcmgrub2helper DESTINATION ${KAUTH_HELPER_INSTALL_DIR})
+kauth_install_helper_files(kcmgrub2helper org.kde.kcontrol.kcmgrub2 root)
+kauth_install_actions(org.kde.kcontrol.kcmgrub2 kcmgrub2.actions)
diff --git a/src/helper/helper.cpp b/src/helper/helper.cpp
index 2581dff..b799d09 100644
--- a/src/helper/helper.cpp
+++ b/src/helper/helper.cpp
@@ -26,7 +26,6 @@
 
 //KDE
 #include <KDebug>
-#include <KGlobal>
 #include <KLocale>
 #include <KProcess>
 #include <KAuth/HelperSupport>
@@ -45,7 +44,6 @@ static const QLatin1String path("/usr/sbin:/usr/bin:/sbin:/bin");
 
 Helper::Helper()
 {
-    KGlobal::locale()->insertCatalog(QLatin1String("kcm-grub2"));
     qputenv("PATH", path.latin1());
 }
 
@@ -57,15 +55,29 @@ ActionReply Helper::executeCommand(const QStringList &command)
 
     kDebug() << "Executing" << command.join(QLatin1String(" "));
     int exitCode = process.execute();
+    const QByteArray output = process.readAll();
 
     ActionReply reply;
     if (exitCode != 0) {
-        reply = ActionReply::HelperErrorReply;
-        reply.setErrorCode(exitCode);
+        reply = ActionReply::HelperErrorReply(exitCode);
+        QString errorMessage;
+        switch (exitCode) {
+        case -2:
+            errorMessage = i18nc("@info", "The process could not be started.");
+            break;
+        case -1:
+            errorMessage = i18nc("@info", "The process crashed.");
+            break;
+        default:
+            errorMessage = QString::fromUtf8(output);
+            break;
+        }
+        reply.setErrorDescription(i18nc("@info", "Command: \
<command>%1</command><nl/>", command.join(QLatin1String(" "))) + +                    \
errorDescription(exitCode, errorMessage)); +    } else {
+        reply.addData(QLatin1String("command"), command);
+        reply.addData(QLatin1String("output"), output);
     }
-    reply.addData(QLatin1String("isProcessReply"), true);
-    reply.addData(QLatin1String("command"), command);
-    reply.addData(QLatin1String("output"), process.readAll());
     return reply;
 }
 bool Helper::setLang(const QString &lang)
@@ -104,21 +116,21 @@ ActionReply Helper::defaults(QVariantMap args)
     QString originalConfigFileName = configFileName + QLatin1String(".original");
 
     if (!QFile::exists(originalConfigFileName)) {
-        reply = ActionReply::HelperErrorReply;
-        reply.setErrorCode(1);
-        reply.addData(QLatin1String("errorDescription"), i18n("Original \
configuration file <filename>%1</filename> does not exist.", \
originalConfigFileName)); +        reply = ActionReply::HelperErrorReply();
+        reply.setError(1);
+        reply.setErrorDescription(errorDescription(reply.errorCode(), i18n("Original \
configuration file <filename>%1</filename> does not exist.", \
originalConfigFileName)));  return reply;
     }
     if (!QFile::remove(configFileName)) {
-        reply = ActionReply::HelperErrorReply;
-        reply.setErrorCode(2);
-        reply.addData(QLatin1String("errorDescription"), i18n("Cannot remove current \
configuration file <filename>%1</filename>.", configFileName)); +        reply = \
ActionReply::HelperErrorReply(); +        reply.setError(2);
+        reply.setErrorDescription(errorDescription(reply.errorCode(), i18n("Cannot \
remove current configuration file <filename>%1</filename>.", configFileName)));  \
return reply;  }
     if (!QFile::copy(originalConfigFileName, configFileName)) {
-        reply = ActionReply::HelperErrorReply;
-        reply.setErrorCode(3);
-        reply.addData(QLatin1String("errorDescription"), i18n("Cannot copy original \
configuration file <filename>%1</filename> to <filename>%2</filename>.", \
originalConfigFileName, configFileName)); +        reply = \
ActionReply::HelperErrorReply(); +        reply.setError(3);
+        reply.setErrorDescription(errorDescription(reply.errorCode(), i18n("Cannot \
copy original configuration file <filename>%1</filename> to \
<filename>%2</filename>.", originalConfigFileName, configFileName)));  return reply;
     }
     return reply;
@@ -133,9 +145,9 @@ ActionReply Helper::install(QVariantMap args)
     if (mountPoint.isEmpty()) {
         for (int i = 0; QDir(mountPoint = \
QString(QLatin1String("%1/kcm-grub2-%2")).arg(QDir::tempPath(), \
QString::number(i))).exists(); i++);  if (!QDir().mkpath(mountPoint)) {
-            reply = ActionReply::HelperErrorReply;
-            reply.setErrorCode(4);
-            reply.addData(QLatin1String("errorDescription"), i18n("Failed to create \
temporary mount point.")); +            reply = ActionReply::HelperErrorReply();
+            reply.setError(4);
+            reply.setErrorDescription(errorDescription(reply.errorCode(), \
i18n("Failed to create temporary mount point.")));  return reply;
         }
         ActionReply mountReply = executeCommand(QStringList() << \
QLatin1String("mount") << partition << mountPoint); @@ -231,9 +243,9 @@ ActionReply \
Helper::save(QVariantMap args)  
     QFile file(configFileName);
     if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
-        reply = ActionReply::HelperErrorReply;
-        reply.setErrorCode(5);
-        reply.addData(QLatin1String("errorDescription"), file.errorString());
+        reply = ActionReply::HelperErrorReply();
+        reply.setError(5);
+        reply.setErrorDescription(errorDescription(reply.errorCode(), \
file.errorString()));  return reply;
     }
     file.write(rawConfigFileContents);
@@ -271,4 +283,9 @@ ActionReply Helper::save(QVariantMap args)
     return grub_mkconfigReply;
 }
 
-KDE4_AUTH_HELPER_MAIN("org.kde.kcontrol.kcmgrub2", Helper)
+QString Helper::errorDescription(int errorCode, const QString &errorMessage) const
+{
+    return i18nc("@info", "Error code: <numid>%1</numid><nl/>Error message: \
<message>%2</message>", errorCode, errorMessage); +}
+
+KAUTH_HELPER_MAIN("org.kde.kcontrol.kcmgrub2", Helper)
diff --git a/src/helper/helper.h b/src/helper/helper.h
index e63b41f..9a8f37f 100644
--- a/src/helper/helper.h
+++ b/src/helper/helper.h
@@ -35,6 +35,8 @@ public Q_SLOTS:
     ActionReply install(QVariantMap args);
     ActionReply load(QVariantMap args);
     ActionReply save(QVariantMap args);
+private:
+    QString errorDescription(int errorCode, const QString &errorMessage) const;
 };
 
 #endif
diff --git a/src/installDlg.cpp b/src/installDlg.cpp
index 34a2847..8f2d4ec 100644
--- a/src/installDlg.cpp
+++ b/src/installDlg.cpp
@@ -21,12 +21,16 @@
 //Qt
 #include <QFile>
 #include <QRadioButton>
+#include <QPushButton>
 
 //KDE
-#include <kdeversion.h>
+#include <KGlobal>
+#include <KLocalizedString>
+#include <KIcon>
 #include <KMessageBox>
 #include <KProgressDialog>
-#include <KAuth/ActionWatcher>
+#include <KAuthAction>
+#include <KAuthExecuteJob>
 using namespace KAuth;
 #include <Solid/Device>
 #include <Solid/StorageAccess>
@@ -84,7 +88,7 @@ void InstallDialog::slotButtonClicked(int button)
 {
     if (button == KDialog::Ok) {
         Action installAction(QLatin1String("org.kde.kcontrol.kcmgrub2.install"));
-        installAction.setHelperID(QLatin1String("org.kde.kcontrol.kcmgrub2"));
+        installAction.setHelperId(QLatin1String("org.kde.kcontrol.kcmgrub2"));
         for (int i = 0; i < ui->treeWidget_recover->topLevelItemCount(); i++) {
             QRadioButton *radio = qobject_cast<QRadioButton \
*>(ui->treeWidget_recover->itemWidget(ui->treeWidget_recover->topLevelItem(i), 0));  \
if (radio && radio->isChecked()) { @@ -98,11 +102,10 @@ void \
                InstallDialog::slotButtonClicked(int button)
             KMessageBox::sorry(this, i18nc("@info", "Sorry, you have to select a \
partition with a proper name!"));  return;
         }
-#if KDE_IS_VERSION(4,6,0)
         installAction.setParentWidget(this);
-#endif
 
-        if (installAction.authorize() != Action::Authorized) {
+        KAuth::ExecuteJob *installJob = \
installAction.execute(KAuth::Action::AuthorizeOnlyMode); +        if \
(!installJob->exec()) {  return;
         }
 
@@ -112,19 +115,30 @@ void InstallDialog::slotButtonClicked(int button)
         progressDlg.progressBar()->setMinimum(0);
         progressDlg.progressBar()->setMaximum(0);
         progressDlg.show();
-        connect(installAction.watcher(), SIGNAL(actionPerformed(ActionReply)), \
&progressDlg, SLOT(hide())); +        installJob = installAction.execute();
+        connect(installJob, SIGNAL(finished(KJob*)), &progressDlg, SLOT(hide()));
 
-        ActionReply reply = installAction.execute();
-        if (reply.succeeded()) {
-            KDialog *dialog = new KDialog(this, Qt::Dialog);
-            dialog->setCaption(i18nc("@title:window", "Information"));
-            dialog->setButtons(KDialog::Ok | KDialog::Details);
+        if (installJob->exec()) {
+            QDialog *dialog = new QDialog(this);
+            dialog->setWindowTitle(i18nc("@title:window", "Information"));
             dialog->setModal(true);
-            dialog->setDefaultButton(KDialog::Ok);
-            dialog->setEscapeButton(KDialog::Ok);
-            KMessageBox::createKMessageBox(dialog, QMessageBox::Information, \
i18nc("@info", "Successfully installed GRUB."), QStringList(), QString(), 0, \
KMessageBox::Notify, reply.data().value(QLatin1String("output")).toString()); // \
krazy:exclude=qclasses +            dialog->setAttribute(Qt::WA_DeleteOnClose);
+
+            QPushButton *detailsButton = new QPushButton;
+            detailsButton->setObjectName(QStringLiteral("detailsButton"));
+            detailsButton->setText(QApplication::translate("KMessageBox", \
"&Details") + QStringLiteral(" >>")); +            \
detailsButton->setIcon(QIcon::fromTheme(QStringLiteral("help-about"))); +
+            QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
+            buttonBox->addButton(detailsButton, QDialogButtonBox::HelpRole);
+            buttonBox->addButton(QDialogButtonBox::Ok);
+            buttonBox->button(QDialogButtonBox::Ok)->setFocus();
+
+            KMessageBox::createKMessageBox(dialog, buttonBox, \
QMessageBox::Information, i18nc("@info", "Successfully installed GRUB."), +           \
QStringList(), QString(), nullptr, KMessageBox::Notify, +                             \
QString::fromUtf8(installJob->data().value(QLatin1String("output")).toByteArray())); \
// krazy:exclude=qclasses  } else {
-            KMessageBox::detailedError(this, i18nc("@info", "Failed to install \
GRUB."), KDE_IS_VERSION(4,7,0) ? reply.errorDescription() : \
reply.data().value(QLatin1String("errorDescription")).toString()); +            \
KMessageBox::detailedError(this, i18nc("@info", "Failed to install GRUB."), \
installJob->errorText());  }
     }
     KDialog::slotButtonClicked(button);
diff --git a/src/kcm_grub2.cpp b/src/kcm_grub2.cpp
index 0f44efb..fd7db2a 100644
--- a/src/kcm_grub2.cpp
+++ b/src/kcm_grub2.cpp
@@ -25,8 +25,12 @@
 #include <QDesktopWidget>
 #include <QStandardItemModel>
 #include <QTreeView>
+#include <QPushButton>
 
 //KDE
+#include <KGlobal>
+#include <KLocalizedString>
+#include <KIcon>
 #include <KAboutData>
 #include <KDebug>
 #include <KInputDialog>
@@ -34,7 +38,8 @@
 #include <KMessageBox>
 #include <KPluginFactory>
 #include <KProgressDialog>
-#include <KAuth/ActionWatcher>
+#include <KAuthAction>
+#include <KAuthExecuteJob>
 
 //Project
 #include "common.h"
@@ -54,13 +59,14 @@
 K_PLUGIN_FACTORY(GRUB2Factory, registerPlugin<KCMGRUB2>();)
 K_EXPORT_PLUGIN(GRUB2Factory("kcmgrub2"))
 
-KCMGRUB2::KCMGRUB2(QWidget *parent, const QVariantList &list) : \
KCModule(GRUB2Factory::componentData(), parent, list) +KCMGRUB2::KCMGRUB2(QWidget \
*parent, const QVariantList &list) : KCModule(parent, list)  {
-    //Isn't KAboutData's second argument supposed to do this?
-    KGlobal::locale()->insertCatalog(QLatin1String("kcm-grub2"));
-
-    KAboutData *about = new KAboutData("kcmgrub2", "kcm-grub2", ki18nc("@title", \
"KDE GRUB2 Bootloader Control Module"), KCM_GRUB2_VERSION, ki18nc("@title", "A KDE \
Control Module for configuring the GRUB2 bootloader."), KAboutData::License_GPL_V3, \
ki18nc("@info:credit", "Copyright (C) 2008-2013 Konstantinos Smanis"), \
                KLocalizedString(), \
                "http://ksmanis.wordpress.com/projects/grub2-editor/");
-    about->addAuthor(ki18nc("@info:credit", "Κonstantinos Smanis"), \
ki18nc("@info:credit", "Main Developer"), "konstantinos.smanis@gmail.com", \
"http://ksmanis.wordpress.com/"); +    KAboutData *about = new \
KAboutData(QStringLiteral("kcmgrub2"), i18nc("@title", "KDE GRUB2 Bootloader Control \
Module"), +                                       QStringLiteral(KCM_GRUB2_VERSION), \
i18nc("@title", "A KDE Control Module for configuring the GRUB2 bootloader."), +      \
KAboutLicense::GPL_V3, i18nc("@info:credit", "Copyright (C) 2008-2013 Konstantinos \
Smanis"), QString(), +                                       \
QStringLiteral("http://ksmanis.wordpress.com/projects/grub2-editor/")); +    \
about->addAuthor(i18nc("@info:credit", "Κonstantinos Smanis"), i18nc("@info:credit", \
"Main Developer"), +                     \
QStringLiteral("konstantinos.smanis@gmail.com"), \
QStringLiteral("http://ksmanis.wordpress.com/"));  setAboutData(about);
 
     ui = new Ui::KCMGRUB2;
@@ -76,19 +82,16 @@ KCMGRUB2::~KCMGRUB2()
 void KCMGRUB2::defaults()
 {
     Action defaultsAction(QLatin1String("org.kde.kcontrol.kcmgrub2.defaults"));
-    defaultsAction.setHelperID(QLatin1String("org.kde.kcontrol.kcmgrub2"));
-#if KDE_IS_VERSION(4,6,0)
+    defaultsAction.setHelperId(QLatin1String("org.kde.kcontrol.kcmgrub2"));
     defaultsAction.setParentWidget(this);
-#endif
 
-    ActionReply reply = defaultsAction.execute();
-    processReply(reply);
-    if (reply.succeeded()) {
+    KAuth::ExecuteJob *defaultsJob = defaultsAction.execute();
+    if (defaultsJob->exec()) {
         load();
         save();
         KMessageBox::information(this, i18nc("@info", "Successfully restored the \
default values."));  } else {
-        KMessageBox::detailedError(this, i18nc("@info", "Failed to restore the \
default values."), reply.errorDescription()); +        \
KMessageBox::detailedError(this, i18nc("@info", "Failed to restore the default \
values."), defaultsJob->errorText());  }
 }
 void KCMGRUB2::load()
@@ -472,7 +475,7 @@ void KCMGRUB2::save()
     }
 
     Action saveAction(QLatin1String("org.kde.kcontrol.kcmgrub2.save"));
-    saveAction.setHelperID(QLatin1String("org.kde.kcontrol.kcmgrub2"));
+    saveAction.setHelperId(QLatin1String("org.kde.kcontrol.kcmgrub2"));
     saveAction.addArgument(QLatin1String("rawConfigFileContents"), \
configFileContents.toUtf8());  \
saveAction.addArgument(QLatin1String("rawDefaultEntry"), !m_entries.isEmpty() ? \
grubDefault.toUtf8() : m_settings.value(QLatin1String("GRUB_DEFAULT")).toUtf8());  if \
(ui->kcombobox_language->currentIndex() > 0) { @@ -482,13 +485,14 @@ void \
KCMGRUB2::save()  if (m_dirtyBits.testBit(memtestDirty)) {
         saveAction.addArgument(QLatin1String("memtest"), \
ui->checkBox_memtest->isChecked());  }
-#if KDE_IS_VERSION(4,6,0)
     saveAction.setParentWidget(this);
-#endif
+    saveAction.setTimeout(60000);
 
-    if (saveAction.authorize() != Action::Authorized) {
+    KAuth::ExecuteJob *saveJob = \
saveAction.execute(KAuth::Action::AuthorizeOnlyMode); +    if (!saveJob->exec()) {
         return;
     }
+    saveJob = saveAction.execute();
 
     KProgressDialog progressDlg(this, i18nc("@title:window Verb (gerund). Refers to \
current status.", "Saving"), i18nc("@info:progress", "Saving GRUB settings..."));  \
progressDlg.setAllowCancel(false); @@ -496,21 +500,30 @@ void KCMGRUB2::save()
     progressDlg.progressBar()->setMinimum(0);
     progressDlg.progressBar()->setMaximum(0);
     progressDlg.show();
-    connect(saveAction.watcher(), SIGNAL(actionPerformed(ActionReply)), \
                &progressDlg, SLOT(hide()));
-
-    ActionReply reply = saveAction.execute();
-    processReply(reply);
-    if (reply.succeeded()) {
-        KDialog *dialog = new KDialog(this, Qt::Dialog);
-        dialog->setCaption(i18nc("@title:window", "Information"));
-        dialog->setButtons(KDialog::Ok | KDialog::Details);
+    connect(saveJob, SIGNAL(finished(KJob*)), &progressDlg, SLOT(hide()));
+
+    if (saveJob->exec()) {
+        QDialog *dialog = new QDialog(this);
+        dialog->setWindowTitle(i18nc("@title:window", "Information"));
         dialog->setModal(true);
-        dialog->setDefaultButton(KDialog::Ok);
-        dialog->setEscapeButton(KDialog::Ok);
-        KMessageBox::createKMessageBox(dialog, QMessageBox::Information, \
i18nc("@info", "Successfully saved GRUB settings."), QStringList(), QString(), 0, \
KMessageBox::Notify, \
QString::fromUtf8(reply.data().value(QLatin1String("output")).toByteArray().constData())); \
// krazy:exclude=qclasses +        dialog->setAttribute(Qt::WA_DeleteOnClose);
+
+        QPushButton *detailsButton = new QPushButton;
+        detailsButton->setObjectName(QStringLiteral("detailsButton"));
+        detailsButton->setText(QApplication::translate("KMessageBox", "&Details") + \
QStringLiteral(" >>")); +        \
detailsButton->setIcon(QIcon::fromTheme(QStringLiteral("help-about"))); +
+        QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
+        buttonBox->addButton(detailsButton, QDialogButtonBox::HelpRole);
+        buttonBox->addButton(QDialogButtonBox::Ok);
+        buttonBox->button(QDialogButtonBox::Ok)->setFocus();
+
+        KMessageBox::createKMessageBox(dialog, buttonBox, QMessageBox::Information, \
i18nc("@info", "Successfully saved GRUB settings."), +                                \
QStringList(), QString(), nullptr, KMessageBox::Notify, +                             \
QString::fromUtf8(saveJob->data().value(QLatin1String("output")).toByteArray().constData())); \
// krazy:exclude=qclasses  load();
     } else {
-        KMessageBox::detailedError(this, i18nc("@info", "Failed to save GRUB \
settings."), reply.errorDescription()); +        KMessageBox::detailedError(this, \
i18nc("@info", "Failed to save GRUB settings."), saveJob->errorText());  }
 }
 
@@ -1020,61 +1033,58 @@ void KCMGRUB2::readAll()
     //Do not prompt for password if only the VBE operation is required, unless \
                forced.
     if (operations && ((operations & (~Vbe)) || m_resolutionsForceRead)) {
         Action loadAction(QLatin1String("org.kde.kcontrol.kcmgrub2.load"));
-        loadAction.setHelperID(QLatin1String("org.kde.kcontrol.kcmgrub2"));
+        loadAction.setHelperId(QLatin1String("org.kde.kcontrol.kcmgrub2"));
         loadAction.addArgument(QLatin1String("operations"), (int)(operations));
-#if KDE_IS_VERSION(4,6,0)
         loadAction.setParentWidget(this);
-#endif
 
-        ActionReply reply = loadAction.execute();
-        processReply(reply);
-        if (reply.failed()) {
+        KAuth::ExecuteJob *loadJob = loadAction.execute();
+        if (!loadJob->exec()) {
             kError() << "KAuth error!";
-            kError() << "Error code:" << reply.errorCode();
-            kError() << "Error description:" << reply.errorDescription();
+            kError() << "Error code:" << loadJob->error();
+            kError() << "Error description:" << loadJob->errorText();
             return;
         }
 
         if (operations.testFlag(MenuFile)) {
-            if (reply.data().value(QLatin1String("menuSuccess")).toBool()) {
-                parseEntries(QString::fromUtf8(reply.data().value(QLatin1String("menuContents")).toByteArray().constData()));
 +            if (loadJob->data().value(QLatin1String("menuSuccess")).toBool()) {
+                parseEntries(QString::fromUtf8(loadJob->data().value(QLatin1String("menuContents")).toByteArray().constData()));
  } else {
                 kError() << "Helper failed to read file:" << grubMenuPath();
-                kError() << "Error code:" << \
                reply.data().value(QLatin1String("menuError")).toInt();
-                kError() << "Error description:" << \
reply.data().value(QLatin1String("menuErrorString")).toString(); +                \
kError() << "Error code:" << \
loadJob->data().value(QLatin1String("menuError")).toInt(); +                kError() \
<< "Error description:" << \
loadJob->data().value(QLatin1String("menuErrorString")).toString();  }
         }
         if (operations.testFlag(ConfigurationFile)) {
-            if (reply.data().value(QLatin1String("configSuccess")).toBool()) {
-                parseSettings(QString::fromUtf8(reply.data().value(QLatin1String("configContents")).toByteArray().constData()));
 +            if (loadJob->data().value(QLatin1String("configSuccess")).toBool()) {
+                parseSettings(QString::fromUtf8(loadJob->data().value(QLatin1String("configContents")).toByteArray().constData()));
  } else {
                 kError() << "Helper failed to read file:" << grubConfigPath();
-                kError() << "Error code:" << \
                reply.data().value(QLatin1String("configError")).toInt();
-                kError() << "Error description:" << \
reply.data().value(QLatin1String("configErrorString")).toString(); +                \
kError() << "Error code:" << \
loadJob->data().value(QLatin1String("configError")).toInt(); +                \
kError() << "Error description:" << \
loadJob->data().value(QLatin1String("configErrorString")).toString();  }
         }
         if (operations.testFlag(EnvironmentFile)) {
-            if (reply.data().value(QLatin1String("envSuccess")).toBool()) {
-                parseEnv(QString::fromUtf8(reply.data().value(QLatin1String("envContents")).toByteArray().constData()));
 +            if (loadJob->data().value(QLatin1String("envSuccess")).toBool()) {
+                parseEnv(QString::fromUtf8(loadJob->data().value(QLatin1String("envContents")).toByteArray().constData()));
  } else {
                 kError() << "Helper failed to read file:" << grubEnvPath();
-                kError() << "Error code:" << \
                reply.data().value(QLatin1String("envError")).toInt();
-                kError() << "Error description:" << \
reply.data().value(QLatin1String("envErrorString")).toString(); +                \
kError() << "Error code:" << \
loadJob->data().value(QLatin1String("envError")).toInt(); +                kError() \
<< "Error description:" << \
loadJob->data().value(QLatin1String("envErrorString")).toString();  }
         }
         if (operations.testFlag(MemtestFile)) {
-            m_memtest = reply.data().value(QLatin1String("memtest")).toBool();
+            m_memtest = loadJob->data().value(QLatin1String("memtest")).toBool();
             if (m_memtest) {
-                m_memtestOn = \
reply.data().value(QLatin1String("memtestOn")).toBool(); +                m_memtestOn \
= loadJob->data().value(QLatin1String("memtestOn")).toBool();  }
         }
         if (operations.testFlag(Vbe)) {
-            m_resolutions = \
reply.data().value(QLatin1String("gfxmodes")).toStringList(); +            \
m_resolutions = loadJob->data().value(QLatin1String("gfxmodes")).toStringList();  \
m_resolutionsEmpty = false;  m_resolutionsForceRead = false;
         }
         if (operations.testFlag(Locales)) {
-            m_locales = reply.data().value(QLatin1String("locales")).toStringList();
+            m_locales = \
loadJob->data().value(QLatin1String("locales")).toStringList();  }
     }
 }
@@ -1137,41 +1147,6 @@ void KCMGRUB2::showResolutions()
     }
 }
 
-void KCMGRUB2::processReply(ActionReply &reply)
-{
-    if (reply.type() == ActionReply::Success || reply.type() == \
                ActionReply::KAuthError) {
-        return;
-    }
-
-    //Process error (contains command, output, errorCode, errorMessage, \
                errorDescription)
-    QLatin1String processKey("isProcessReply");
-    if (reply.data().contains(processKey) && \
                reply.data().value(processKey).toBool()) {
-        QString errorMessage;
-        switch (reply.errorCode()) {
-        case -2:
-            errorMessage = i18nc("@info", "The process could not be started.");
-            break;
-        case -1:
-            errorMessage = i18nc("@info", "The process crashed.");
-            break;
-        default:
-            errorMessage = \
QString::fromUtf8(reply.data().value(QLatin1String("output")).toByteArray().constData());
                
-            break;
-        }
-        reply.addData(QLatin1String("errorMessage"), errorMessage);
-        reply.setErrorDescription(i18nc("@info", "Command: \
<command>%1</command><nl/>Error code: <numid>%2</numid><nl/>Error \
message:<nl/><message>%3</message>", \
reply.data().value(QLatin1String("command")).toStringList().join(QLatin1String(" ")), \
                reply.errorCode(), errorMessage));
-        return;
-    }
-
-    //Simple error (contains errorCode, errorMessage, errorDescription)
-    QLatin1String errorKey("errorDescription");
-    if (reply.data().contains(errorKey)) {
-        QString errorMessage = reply.data().value(errorKey).toString();
-        reply.addData(QLatin1String("errorMessage"), errorMessage);
-        reply.setErrorDescription(i18nc("@info", "Error code: \
<numid>%1</numid><nl/>Error message: <message>%2</message>", reply.errorCode(), \
                errorMessage));
-        reply.data().remove(errorKey);
-    }
-}
 QString KCMGRUB2::parseTitle(const QString &line)
 {
     QChar ch;
@@ -1312,3 +1287,5 @@ void KCMGRUB2::parseEnv(const QString &config)
         m_env[line.section(QLatin1Char('='), 0, 0)] = line.section(QLatin1Char('='), \
1);  }
 }
+
+#include "kcm_grub2.moc"
diff --git a/src/kcm_grub2.h b/src/kcm_grub2.h
index bc57d30..c36657b 100644
--- a/src/kcm_grub2.h
+++ b/src/kcm_grub2.h
@@ -93,7 +93,6 @@ private:
     void sortResolutions();
     void showResolutions();
 
-    void processReply(ActionReply &reply);
     QString parseTitle(const QString &line);
     void parseEntries(const QString &config);
     void parseSettings(const QString &config);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic