File indexing completed on 2024-05-19 04:48:21

0001 #include <QApplication>
0002 #include <QQmlApplicationEngine>
0003 #include <QCommandLineParser>
0004 #include <QQmlContext>
0005 
0006 #include <QDate>
0007 #include <QIcon>
0008 
0009 #include <MauiKit/Core/mauiapp.h>
0010 
0011 #include <KAboutData>
0012 #include <KI18n/KLocalizedString>
0013 
0014 #include "../project_version.h"
0015 
0016 #include "colorutils.h"
0017 
0018 //Useful for setting quickly an app template
0019 #define ORG_NAME "Maui"
0020 #define PROJECT_NAME "Paleta"
0021 #define COMPONENT_NAME "paleta"
0022 #define PROJECT_DESCRIPTION "Color utilities."
0023 #define PROJECT_YEAR "2022"
0024 #define PRODUCT_NAME "maui/paleta"
0025 #define PROJECT_PAGE "https://mauikit.org"
0026 #define REPORT_PAGE "https://github.com/Nitrux/maui-colors/issues/new"
0027 
0028 int main(int argc, char *argv[])
0029 {
0030     QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
0031 
0032     QApplication app(argc, argv);
0033 
0034     app.setOrganizationName(QStringLiteral(ORG_NAME));
0035     app.setWindowIcon(QIcon(":/logo.png"));
0036 
0037     MauiApp::instance()->setIconName("qrc:/logo.svg");
0038 
0039     KLocalizedString::setApplicationDomain(COMPONENT_NAME);
0040 
0041     KAboutData about(QStringLiteral(COMPONENT_NAME), i18n(PROJECT_NAME), PROJECT_VERSION_STRING, i18n(PROJECT_DESCRIPTION),
0042                      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));
0043 
0044     about.addAuthor(i18n("Camilo Higuita"), i18n("Developer"), QStringLiteral("milo.h@aol.com"));
0045 
0046     about.setHomepage(PROJECT_PAGE);
0047     about.setProductName(PRODUCT_NAME);
0048     about.setBugAddress(REPORT_PAGE);
0049     about.setOrganizationDomain(PROJECT_URI);
0050     about.setProgramLogo(app.windowIcon());
0051 
0052     KAboutData::setApplicationData(about);
0053 
0054     QCommandLineParser parser;
0055     parser.setApplicationDescription(about.shortDescription());
0056     parser.process(app);
0057     about.processCommandLine(&parser);
0058 
0059     QQmlApplicationEngine engine;
0060     const QUrl url(QStringLiteral("qrc:/main.qml"));
0061     QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
0062                      &app, [url](QObject *obj, const QUrl &objUrl) {
0063         if (!obj && url == objUrl)
0064             QCoreApplication::exit(-1);
0065     }, Qt::QueuedConnection);
0066 
0067     engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
0068     qmlRegisterSingletonType<ColorUtils>(PROJECT_URI, 1, 0, "ColorUtils", [](QQmlEngine *, QJSEngine *) -> QObject*
0069       {
0070           return new ColorUtils;
0071       });
0072 
0073     engine.load(url);
0074 
0075     return app.exec();
0076 }