Răsfoiți Sursa

fixed loading of right config at startup

Malte Veerman 9 ani în urmă
părinte
comite
665863ae9f
2 a modificat fișierele cu 17 adăugiri și 19 ștergeri
  1. 8 8
      fancontrol-gui/src/main.cpp
  2. 9 11
      lib/src/systemdcommunicator.cpp

+ 8 - 8
fancontrol-gui/src/main.cpp

@@ -32,9 +32,9 @@
 int main(int argc, char *argv[])
 {
     QApplication app(argc, argv);
-    
+
     KLocalizedString::setApplicationDomain("kcm_fancontrol");
-    
+
     KAboutData about("fancontrol_gui",
                     i18n("Fancontrol-GUI"),
                     "0.1",
@@ -44,20 +44,20 @@ int main(int argc, char *argv[])
                     QString(),
                     "http://github.com/maldela/fancontrol-gui",
                     "http://github.com/maldela/fancontrol-gui/issues");
-    about.addAuthor(i18n("Malte Veerman"), i18n("Main Developer"), "maldela@halloarsch.de"); 
+    about.addAuthor(i18n("Malte Veerman"), i18n("Main Developer"), "maldela@halloarsch.de");
     KAboutData::setApplicationData(about);
 
     QQmlApplicationEngine engine;
-    
+
     KDeclarative::KDeclarative decl;
     decl.setDeclarativeEngine(&engine);
     decl.setupBindings();
-        
+
     Fancontrol::GUIBase base;
-    base.loader()->load();
+    base.load();
     QObject::connect(&app, &QApplication::aboutToQuit, [&] () { base.save(false); });
     engine.rootContext()->setContextProperty("base", &base);
-    
+
     KPackage::Package package = KPackage::PackageLoader::self()->loadPackage("KPackage/GenericQML");
     package.setDefaultPackageRoot("kpackage/kcms");
     package.setPath("kcm_fancontrol");
@@ -65,4 +65,4 @@ int main(int argc, char *argv[])
     engine.load(QUrl::fromLocalFile(package.path() + "/contents/ui/Application.qml"));
 
     return app.exec();
-}
+}

+ 9 - 11
lib/src/systemdcommunicator.cpp

@@ -29,6 +29,7 @@
 #include <QtDBus/QDBusInterface>
 
 #include <KAuth/KAuthExecuteJob>
+#include <KI18n/KLocalizedString>
 
 
 #ifndef STANDARD_SERVICE_NAME
@@ -79,6 +80,10 @@ SystemdCommunicator::SystemdCommunicator(QObject *parent, const QString &service
         setServiceName(STANDARD_SERVICE_NAME);
     else
         setServiceName(serviceName);
+
+    emit serviceNameChanged();
+    emit serviceEnabledChanged();
+    emit serviceActiveChanged();
 }
 
 void SystemdCommunicator::setServiceName(const QString &name)
@@ -157,14 +162,10 @@ bool SystemdCommunicator::serviceExists()
     foreach (const SystemdUnitFile &unitFile, list)
     {
         if (unitFile.path.contains(m_serviceName + ".service"))
-        {
-            setError("Success");
             return true;
-        }
     }
 
-    setError("Service " + m_serviceName + " doesn't exist");
-    qDebug() << "Service does not exist!";
+    setError(i18n("Service %1 doesn't exist", m_serviceName));
     return false;
 }
 
@@ -312,7 +313,7 @@ bool SystemdCommunicator::restartService()
         return dbusAction("ReloadOrRestartUnit", args);
     }
 
-    setError("Service doesn't exist");
+    setError(i18n("Service does not exist"));
     return false;
 }
 
@@ -329,11 +330,8 @@ void SystemdCommunicator::setError(const QString &error)
 {
     qCritical() << error;
 
-    if (error != m_error)
-    {
-        m_error = error;
-        emit errorChanged();
-    }
+    m_error = error;
+    emit errorChanged();
 }
 
 }