File indexing completed on 2024-05-12 17:24:09
0001 /* 0002 SPDX-License-Identifier: GPL-2.0-or-later 0003 SPDX-FileCopyrightText: 2023 Mathis <mbb@kaidan.im> 0004 */ 0005 0006 #include <QApplication> 0007 #include <QQmlApplicationEngine> 0008 #include <QUrl> 0009 #include <QtQml> 0010 0011 #include "app.h" 0012 #include "database.h" 0013 #include "planteditor.h" 0014 #include "plantimagemodel.h" 0015 #include "colorgradientinterpolator.h" 0016 #include "plantsmodel.h" 0017 #include "waterhistorymodel.h" 0018 #include "healthhistorymodel.h" 0019 #include "version-powerplant.h" 0020 #include <KAboutData> 0021 #include <KLocalizedContext> 0022 #include <KLocalizedString> 0023 0024 #include <QCoro/QCoroTask> 0025 #include <QCoro/QCoroFuture> 0026 0027 #include "powerplantconfig.h" 0028 0029 Q_DECL_EXPORT int main(int argc, char *argv[]) 0030 { 0031 QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 0032 QApplication app(argc, argv); 0033 KLocalizedString::setApplicationDomain("powerplant"); 0034 0035 QCoreApplication::setOrganizationName(QStringLiteral("KDE")); 0036 QCoreApplication::setApplicationName(QStringLiteral("powerplant")); 0037 0038 KAboutData aboutData( 0039 // The program name used internally. 0040 QStringLiteral("PowerPlant"), 0041 // A displayable program name string. 0042 i18nc("@title", "PowerPlant"), 0043 // The program version string. 0044 QStringLiteral(POWERPLANT_VERSION_STRING), 0045 // Short description of what the app does. 0046 i18n("A small app to track your plants"), 0047 // The license this code is released under. 0048 KAboutLicense::GPL, 0049 // Copyright Statement. 0050 i18n("(c) 2023")); 0051 aboutData.addAuthor(i18nc("@info:credit", "Mathis BrĂ¼chert"), 0052 i18nc("@info:credit", "Author"), 0053 QStringLiteral("mbb@kaidan.im")); 0054 KAboutData::setApplicationData(aboutData); 0055 0056 QQmlApplicationEngine engine; 0057 0058 auto config = powerplantConfig::self(); 0059 0060 qmlRegisterSingletonInstance("org.kde.powerplant", 1, 0, "Config", config); 0061 0062 qmlRegisterType<WaterHistoryModel>("org.kde.powerplant", 1, 0, "WaterHistoryModel"); 0063 qmlRegisterType<HealthHistoryModel>("org.kde.powerplant", 1, 0, "HealthHistoryModel"); 0064 qmlRegisterType<Plant>("org.kde.powerplant", 1, 0, "Plant"); 0065 qmlRegisterType<PlantEditor>("org.kde.powerplant", 1, 0, "PlantEditor"); 0066 qmlRegisterType<PlantsModel>("org.kde.powerplant", 1, 0, "PlantsModel"); 0067 qmlRegisterType<PlantImageModel>("org.kde.powerplant", 1, 0, "PlantImageModel"); 0068 qmlRegisterType<ColorGradientInterpolator>("org.kde.powerplant", 1, 0, "ColorInterpolator"); 0069 0070 qmlRegisterSingletonType("org.kde.powerplant", 1, 0, "About", [](QQmlEngine *engine, QJSEngine *) -> QJSValue { 0071 return engine->toScriptValue(KAboutData::applicationData()); 0072 }); 0073 0074 0075 engine.rootContext()->setContextObject(new KLocalizedContext(&engine)); 0076 engine.load(QUrl(QStringLiteral("qrc:///main.qml"))); 0077 0078 if (engine.rootObjects().isEmpty()) { 0079 return -1; 0080 } 0081 return app.exec(); 0082 }