File indexing completed on 2024-05-19 04:35:50

0001 // SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>
0002 // SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0003 
0004 #include <KAboutData>
0005 #include <KLocalizedContext>
0006 #include <KLocalizedString>
0007 #include <QApplication>
0008 #include <QCoroQml>
0009 #include <QIcon>
0010 #include <QQmlApplicationEngine>
0011 #include <QQuickStyle>
0012 #include <QUrl>
0013 #include <QtQml>
0014 
0015 #include "config.h"
0016 
0017 #include "optiimage-version.h"
0018 
0019 using namespace Qt::Literals::StringLiterals;
0020 
0021 int main(int argc, char *argv[])
0022 {
0023     QApplication app(argc, argv);
0024     KLocalizedString::setApplicationDomain("optiimage");
0025 
0026     // Default to org.kde.desktop style unless the user forces another style
0027     if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) {
0028         QQuickStyle::setStyle(QStringLiteral("org.kde.desktop"));
0029     }
0030 
0031     KAboutData about(QStringLiteral("optiimage"),
0032                      i18n("OptiImage"),
0033                      QStringLiteral(OPTIIMAGE_VERSION_STRING),
0034                      i18n("Images Optimiser"),
0035                      KAboutLicense::GPL_V3,
0036                      i18n("© 2021 - 2023 Carl Schwan"));
0037 
0038     about.addAuthor(i18n("Carl Schwan"), i18n("Maintainer"), QStringLiteral("carl@carlschwan.eu"));
0039     about.setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"), i18nc("EMAIL OF TRANSLATORS", "Your emails"));
0040     about.setOrganizationDomain("kde.org");
0041     about.setBugAddress("https://bugs.kde.org/describecomponents.cgi?product=optiimage");
0042 
0043     KAboutData::setApplicationData(about);
0044     QGuiApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("org.kde.optiimage")));
0045 
0046     auto config = Config::self();
0047     qmlRegisterSingletonInstance("org.kde.optiimage.private", 1, 0, "Config", config);
0048 
0049     QQmlApplicationEngine engine;
0050     QCoro::Qml::registerTypes();
0051 
0052     engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
0053     engine.loadFromModule(u"org.kde.optiimage"_s, u"Main"_s);
0054 
0055     if (engine.rootObjects().isEmpty()) {
0056         return -1;
0057     }
0058 
0059     return app.exec();
0060 }