|
@@ -20,8 +20,11 @@
|
|
#include <QtWidgets/QApplication>
|
|
#include <QtWidgets/QApplication>
|
|
#include <QtQml/QQmlApplicationEngine>
|
|
#include <QtQml/QQmlApplicationEngine>
|
|
#include <QtQml/QQmlContext>
|
|
#include <QtQml/QQmlContext>
|
|
|
|
+#include <QtCore/QCommandLineParser>
|
|
|
|
+#include <QtCore/QLoggingCategory>
|
|
#include <QtCore/QFileInfo>
|
|
#include <QtCore/QFileInfo>
|
|
-#include <QDebug>
|
|
|
|
|
|
+#include <QtGui/QIcon>
|
|
|
|
+
|
|
|
|
|
|
#include <KDeclarative/KDeclarative>
|
|
#include <KDeclarative/KDeclarative>
|
|
#include <KI18n/KLocalizedString>
|
|
#include <KI18n/KLocalizedString>
|
|
@@ -32,15 +35,19 @@
|
|
#include "windowconfig.h"
|
|
#include "windowconfig.h"
|
|
|
|
|
|
|
|
|
|
|
|
+Q_DECLARE_LOGGING_CATEGORY(FANCONTROL)
|
|
|
|
+Q_LOGGING_CATEGORY(FANCONTROL, "fancontrol-gui")
|
|
|
|
+
|
|
int main(int argc, char *argv[])
|
|
int main(int argc, char *argv[])
|
|
{
|
|
{
|
|
QApplication app(argc, argv);
|
|
QApplication app(argc, argv);
|
|
|
|
+ app.setWindowIcon(QIcon::fromTheme(QStringLiteral("fancontrol_gui")));
|
|
|
|
|
|
KLocalizedString::setApplicationDomain("kcm_fancontrol");
|
|
KLocalizedString::setApplicationDomain("kcm_fancontrol");
|
|
|
|
|
|
KAboutData about(QStringLiteral("fancontrol_gui"),
|
|
KAboutData about(QStringLiteral("fancontrol_gui"),
|
|
i18n("Fancontrol-GUI"),
|
|
i18n("Fancontrol-GUI"),
|
|
- QStringLiteral("0.1"),
|
|
|
|
|
|
+ QStringLiteral("0.3"),
|
|
i18n("Graphical user interface for fancontrol"),
|
|
i18n("Graphical user interface for fancontrol"),
|
|
KAboutLicense::KAboutLicense::GPL_V2,
|
|
KAboutLicense::KAboutLicense::GPL_V2,
|
|
QStringLiteral("Copyright (C) 2015 Malte Veerman"),
|
|
QStringLiteral("Copyright (C) 2015 Malte Veerman"),
|
|
@@ -49,37 +56,41 @@ int main(int argc, char *argv[])
|
|
QStringLiteral("http://github.com/maldela/fancontrol-gui/issues"));
|
|
QStringLiteral("http://github.com/maldela/fancontrol-gui/issues"));
|
|
about.addAuthor(i18n("Malte Veerman"), i18n("Main Developer"), QStringLiteral("maldela@halloarsch.de"));
|
|
about.addAuthor(i18n("Malte Veerman"), i18n("Main Developer"), QStringLiteral("maldela@halloarsch.de"));
|
|
KAboutData::setApplicationData(about);
|
|
KAboutData::setApplicationData(about);
|
|
|
|
+ QCommandLineParser parser;
|
|
|
|
+ about.setupCommandLine(&parser);
|
|
|
|
+ parser.process(app);
|
|
|
|
+ about.processCommandLine(&parser);
|
|
|
|
+
|
|
|
|
+ QQmlApplicationEngine engine;
|
|
|
|
+ QQmlContext *context = engine.rootContext();
|
|
|
|
|
|
- QScopedPointer<QQmlApplicationEngine> engine(new QQmlApplicationEngine);
|
|
|
|
- QQmlContext *context = engine->rootContext();
|
|
|
|
-
|
|
|
|
KDeclarative::KDeclarative decl;
|
|
KDeclarative::KDeclarative decl;
|
|
- decl.setDeclarativeEngine(engine.data());
|
|
|
|
|
|
+ decl.setDeclarativeEngine(&engine);
|
|
decl.setupBindings();
|
|
decl.setupBindings();
|
|
|
|
|
|
Fancontrol::GUIBase base;
|
|
Fancontrol::GUIBase base;
|
|
base.load();
|
|
base.load();
|
|
context->setContextProperty(QStringLiteral("base"), &base);
|
|
context->setContextProperty(QStringLiteral("base"), &base);
|
|
-
|
|
|
|
|
|
+
|
|
WindowConfig *windowConfig = WindowConfig::instance();
|
|
WindowConfig *windowConfig = WindowConfig::instance();
|
|
context->setContextProperty(QStringLiteral("windowConfig"), windowConfig);
|
|
context->setContextProperty(QStringLiteral("windowConfig"), windowConfig);
|
|
|
|
|
|
KPackage::Package package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("KPackage/GenericQML"));
|
|
KPackage::Package package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("KPackage/GenericQML"));
|
|
- package.setDefaultPackageRoot(QStringLiteral("/usr/local/share/kpackage/kcms"));
|
|
|
|
|
|
+ package.setDefaultPackageRoot(QStringLiteral("/usr/share/kpackage/kcms"));
|
|
package.setPath(QStringLiteral("kcm_fancontrol"));
|
|
package.setPath(QStringLiteral("kcm_fancontrol"));
|
|
package.addFileDefinition("appqmlroot", QStringLiteral("ui/Application.qml"), i18n("The Application's root QML file"));
|
|
package.addFileDefinition("appqmlroot", QStringLiteral("ui/Application.qml"), i18n("The Application's root QML file"));
|
|
package.setRequired("appqmlroot", true);
|
|
package.setRequired("appqmlroot", true);
|
|
-
|
|
|
|
|
|
+
|
|
if (!package.isValid())
|
|
if (!package.isValid())
|
|
{
|
|
{
|
|
- package.setDefaultPackageRoot(QStringLiteral("/usr/share/kpackage/kcms"));
|
|
|
|
|
|
+ package.setDefaultPackageRoot(QStringLiteral("/usr/local/share/kpackage/kcms"));
|
|
package.setPath(QStringLiteral("kcm_fancontrol"));
|
|
package.setPath(QStringLiteral("kcm_fancontrol"));
|
|
package.addFileDefinition("appqmlroot", QStringLiteral("ui/Application.qml"), i18n("The Application's root QML file"));
|
|
package.addFileDefinition("appqmlroot", QStringLiteral("ui/Application.qml"), i18n("The Application's root QML file"));
|
|
package.setRequired("appqmlroot", true);
|
|
package.setRequired("appqmlroot", true);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if (package.isValid())
|
|
if (package.isValid())
|
|
- engine->load(QUrl::fromLocalFile(package.filePath("appqmlroot")));
|
|
|
|
|
|
+ engine.load(QUrl::fromLocalFile(package.filePath("appqmlroot")));
|
|
|
|
|
|
return app.exec();
|
|
return app.exec();
|
|
}
|
|
}
|