Selaa lähdekoodia

Merge branch 'master' of https://github.com/Maldela/fancontrol-gui

Maldela 9 vuotta sitten
vanhempi
commit
a973398886
6 muutettua tiedostoa jossa 48 lisäystä ja 54 poistoa
  1. 4 2
      CMakeLists.txt
  2. 17 5
      fancontrol-gui/src/main.cpp
  3. 4 7
      helper/CMakeLists.txt
  4. 0 35
      helper/MoveSystemFiles.cmake
  5. 1 1
      kcm/CMakeLists.txt
  6. 22 4
      lib/src/loader.cpp

+ 4 - 2
CMakeLists.txt

@@ -16,6 +16,8 @@ set(STANDARD_CONFIG_FILE "/etc/fancontrol" CACHE STRING "The location of the sta
 add_definitions(-DSTANDARD_SERVICE_NAME="${STANDARD_SERVICE_NAME}")
 add_definitions(-DSTANDARD_CONFIG_FILE="${STANDARD_CONFIG_FILE}")
 
+set(KDE_INSTALL_USE_QT_SYS_PATHS ON)
+
 
 #KCM can't be build without systemd support
 if(BUILD_KCM AND NO_SYSTEMD)
@@ -92,12 +94,12 @@ endif(BUILD_GUI)
 
 
 #Build the KCM
-if(BUILD_KCM AND ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr")
+if(BUILD_KCM)
 
     message(STATUS "Build the KCM")
     add_subdirectory(kcm)
 
-endif(BUILD_KCM AND ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr")
+endif(BUILD_KCM)
 
 
 #install the shared parts

+ 17 - 5
fancontrol-gui/src/main.cpp

@@ -25,7 +25,6 @@
 #include <QtCore/QFileInfo>
 #include <QtGui/QIcon>
 
-
 #include <KDeclarative/KDeclarative>
 #include <KI18n/KLocalizedString>
 #include <KPackage/PackageLoader>
@@ -83,10 +82,23 @@ int main(int argc, char *argv[])
 
     if (!package.isValid())
     {
-        package.setDefaultPackageRoot(QStringLiteral("/usr/local/share/kpackage/kcms"));
-        package.setPath(QStringLiteral("kcm_fancontrol"));
-        package.addFileDefinition("appqmlroot", QStringLiteral("ui/Application.qml"), i18n("The Application's root QML file"));
-        package.setRequired("appqmlroot", true);
+        QStringList possiblePackageLocations = QStringList() << QStringLiteral("/usr/local/share/kpackage/kcms")
+                                                             << QStringLiteral("kpackage/kcms")
+                                                             << QStringLiteral("/opt/share/kpackage/kcms");
+
+        for (int i=0; i<possiblePackageLocations.size(); i++)
+        {
+            package.setDefaultPackageRoot(possiblePackageLocations.at(i));
+            package.setPath(QStringLiteral("kcm_fancontrol"));
+            package.addFileDefinition("appqmlroot", QStringLiteral("ui/Application.qml"), i18n("The Application's root QML file"));
+            package.setRequired("appqmlroot", true);
+
+            if (package.isValid())
+            {
+                engine.load(QUrl::fromLocalFile(package.filePath("appqmlroot")));
+                break;
+            }
+        }
     }
 
     if (package.isValid())

+ 4 - 7
helper/CMakeLists.txt

@@ -12,13 +12,10 @@ find_package(KF5Auth REQUIRED)
 
 add_executable(fancontrol-gui-helper src/helper.cpp)
 target_link_libraries(fancontrol-gui-helper ${LIBRARIES})
-install(TARGETS fancontrol-gui-helper DESTINATION ${KAUTH_HELPER_INSTALL_DIR})
+install(TARGETS fancontrol-gui-helper DESTINATION ${KAUTH_HELPER_INSTALL_ABSOLUTE_DIR})
+
+set(SYSCONF_INSTALL_DIR "/etc")
+set(DBUS_SYSTEM_SERVICES_INSTALL_DIR "/usr/share/dbus-1/system-services")
 
 kauth_install_helper_files(fancontrol-gui-helper fancontrol.gui.helper root)
 kauth_install_actions(fancontrol.gui.helper fancontrol_gui.actions)
-
-message(STATUS "${CMAKE_INSTALL_PREFIX}")
-
-if(NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr") 
-    install(SCRIPT MoveSystemFiles.cmake)
-endif(NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr")

+ 0 - 35
helper/MoveSystemFiles.cmake

@@ -1,35 +0,0 @@
-# file(RENAME "${CMAKE_INSTALL_PREFIX} "/etc/dbus-1/system.d/fancontrol.gui.helper.conf")
-# file(RENAME "${CMAKE_INSTALL_PREFIX}/lib/kauth/fancontrol-gui-helper" "/usr/lib/kauth/fancontrol-gui-helper")
-# file(RENAME "${CMAKE_INSTALL_PREFIX}/share/dbus-1/system-services/fancontrol.gui.helper.service" "/usr/share/dbus-1/system-services/fancontrol.gui.helper.service")
-
-set(helper_conf_file "etc/dbus-1/system.d/fancontrol.gui.helper.conf")
-set(helper_bin_file "lib/kauth/fancontrol-gui-helper")
-set(helper_service_file "share/dbus-1/system-services/fancontrol.gui.helper.service")
-set(helper_conf_file_destination "/${helper_conf_file}")
-set(helper_bin_file_destination "/usr/${helper_bin_file}")
-set(helper_service_file_destination "/usr/${helper_service_file}")
-set(install_manifest_path "${CMAKE_SOURCE_DIR}/install_manifest.txt")
-
-execute_process(COMMAND ln -sf ${CMAKE_INSTALL_PREFIX}/${helper_conf_file} ${helper_conf_file_destination} RESULT_VARIABLE result OUTPUT_VARIABLE output)
-message(STATUS "Creating symlink: ${helper_conf_file_destination} -> ${CMAKE_INSTALL_PREFIX}/${helper_conf_file}")
-
-if(${result})
-    message(WARNING "Creation of symlink ${helper_conf_file_destination} -> ${CMAKE_INSTALL_PREFIX}/${helper_conf_file} ${result} ${output} failed:")
-    message(WARNING "${output}")
-endif(${result})
-
-execute_process(COMMAND ln -sf ${CMAKE_INSTALL_PREFIX}/${helper_bin_file} ${helper_bin_file_destination} RESULT_VARIABLE result OUTPUT_VARIABLE output)
-message(STATUS "Creating symlink: ${helper_bin_file_destination} -> ${CMAKE_INSTALL_PREFIX}/${helper_bin_file}")
-
-if(${result})
-    message(WARNING "Creation of symlink ${helper_bin_file_destination} -> ${CMAKE_INSTALL_PREFIX}/${helper_bin_file} ${result} ${output} failed:")
-    message(WARNING "${output}")
-endif(${result})
-
-execute_process(COMMAND ln -sf ${CMAKE_INSTALL_PREFIX}/${helper_service_file} ${helper_service_file_destination} RESULT_VARIABLE result OUTPUT_VARIABLE output)
-message(STATUS "Creating symlink: ${helper_service_file_destination} -> ${CMAKE_INSTALL_PREFIX}/${helper_service_file}")
-
-if(${result})
-    message(WARNING "Creation of symlink ${helper_service_file_destination} -> ${CMAKE_INSTALL_PREFIX}/${helper_service_file} ${result} ${output} failed:")
-    message(WARNING "${output}")
-endif(${result})

+ 1 - 1
kcm/CMakeLists.txt

@@ -9,7 +9,7 @@ add_library(kcm_fancontrol MODULE src/fancontrolkcm.cpp)
 
 target_link_libraries(kcm_fancontrol ${LIBRARIES})
 
-install(TARGETS kcm_fancontrol DESTINATION "${LIB_INSTALL_DIR}/qt/plugins/kcms")
+install(TARGETS kcm_fancontrol DESTINATION "${CMAKE_INSTALL_PLUGINDIR}/kcms")
 install(FILES kcm_fancontrol.desktop DESTINATION ${SERVICES_INSTALL_DIR})
 
 kcoreaddons_desktop_to_json(kcm_fancontrol "kcm_fancontrol.desktop")

+ 22 - 4
lib/src/loader.cpp

@@ -227,7 +227,7 @@ bool Loader::load(const QUrl &url)
     QString fileName;
     if (url.isEmpty())
     {
-        qDebug() << "Given empty url. Fallback to " << m_configUrl;
+        qDebug() << "Given empty url. Fallback to" << m_configUrl;
         fileName = m_configUrl.toLocalFile();
     }
     else if (url.isValid())
@@ -272,7 +272,13 @@ bool Loader::load(const QUrl &url)
         KAuth::ExecuteJob *reply = action.execute();
         if (!reply->exec())
         {
-            qDebug() << reply->error();
+            if (reply->error() == 4)
+            {
+                qDebug() << "Aborted by user";
+                return false;
+            }
+            
+            qDebug() << "Error while loading:" << reply->error();
             setError(reply->errorString() + reply->errorText(), true);
             return false;
         }
@@ -495,7 +501,13 @@ bool Loader::save(const QUrl &url)
 
         if (!reply->exec())
         {
-            qDebug() << reply->error();
+            if (reply->error() == 4)
+            {
+                qDebug() << "Aborted by user";
+                return false;
+            }
+            
+            qDebug() << "Error while saving:" << reply->error();
             setError(reply->errorString() + reply->errorText(), true);
             return false;
         }
@@ -678,7 +690,13 @@ void Loader::handleDetectSensorsResult(KJob *job)
 {
     if (job->error())
     {
-        qDebug() << job->error();
+        if (job->error() == 4)
+        {
+            qDebug() << "Aborted by user";
+            return;
+        }
+            
+        qDebug() << "Error while detecting sensors:" << job->error();
         setError(job->errorString() + job->errorText(), true);
     }
     else