File indexing completed on 2025-02-23 04:26:04
0001 #include <QApplication> 0002 #include <QQmlApplicationEngine> 0003 #include <QCommandLineParser> 0004 #include <QDate> 0005 #include <QIcon> 0006 #include <QQmlContext> 0007 0008 #include <MauiKit3/Core/mauiapp.h> 0009 0010 #include <KAboutData> 0011 #include <KI18n/KLocalizedString> 0012 0013 #include "../project_version.h" 0014 0015 //Useful for setting quickly an app template 0016 #define ORG_NAME "Maui" 0017 #define PROJECT_NAME "Era" 0018 #define COMPONENT_NAME "era" 0019 #define PROJECT_DESCRIPTION "Clock and timer." 0020 #define PROJECT_YEAR "2022" 0021 #define PRODUCT_NAME "maui/era" 0022 #define PROJECT_PAGE "https://mauikit.org" 0023 #define REPORT_PAGE "https://github.com/Nitrux/era/issues/new" 0024 0025 int main(int argc, char *argv[]) 0026 { 0027 QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 0028 0029 QApplication app(argc, argv); 0030 0031 app.setOrganizationName(QStringLiteral(ORG_NAME)); 0032 app.setWindowIcon(QIcon(":/logo.png")); 0033 0034 0035 KLocalizedString::setApplicationDomain(COMPONENT_NAME); 0036 0037 KAboutData about(QStringLiteral(COMPONENT_NAME), i18n(PROJECT_NAME), PROJECT_VERSION_STRING, i18n(PROJECT_DESCRIPTION), 0038 KAboutLicense::LGPL_V3, QString("© %1-%2 %3 Development Team").arg(PROJECT_YEAR, QString::number(QDate::currentDate().year()), ORG_NAME), QString(GIT_BRANCH) + "/" + QString(GIT_COMMIT_HASH)); 0039 0040 about.addAuthor(i18n("Camilo Higuita"), i18n("Developer"), QStringLiteral("milo.h@aol.com")); 0041 0042 about.setHomepage(PROJECT_PAGE); 0043 about.setProductName(PRODUCT_NAME); 0044 about.setBugAddress(REPORT_PAGE); 0045 about.setOrganizationDomain(PROJECT_URI); 0046 about.setProgramLogo(app.windowIcon()); 0047 0048 KAboutData::setApplicationData(about); 0049 MauiApp::instance()->setIconName("qrc:/logo.svg"); 0050 0051 QCommandLineParser parser; 0052 parser.setApplicationDescription(about.shortDescription()); 0053 parser.process(app); 0054 about.processCommandLine(&parser); 0055 0056 QQmlApplicationEngine engine; 0057 engine.rootContext()->setContextObject(new KLocalizedContext(&engine)); 0058 0059 const QUrl url(QStringLiteral("qrc:/main.qml")); 0060 QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, 0061 &app, [url](QObject *obj, const QUrl &objUrl) { 0062 if (!obj && url == objUrl) 0063 QCoreApplication::exit(-1); 0064 }, Qt::QueuedConnection); 0065 0066 0067 engine.rootContext()->setContextObject(new KLocalizedContext(&engine)); 0068 0069 engine.load(url); 0070 0071 return app.exec(); 0072 }