File indexing completed on 2024-04-28 17:05:12

0001 // SPDX-FileCopyrightText: 2022 Felipe Kinoshita <kinofhek@gmail.com>
0002 // SPDX-License-Identifier: LGPL-2.1-or-later
0003 
0004 #include <QApplication>
0005 #include <QIcon>
0006 #include <QQmlApplicationEngine>
0007 #include <QQuickWindow>
0008 #include <QtQml>
0009 #include <QUrl>
0010 
0011 #include <KAboutData>
0012 #include <KLocalizedContext>
0013 #include <KDBusService>
0014 #include <KLocalizedString>
0015 
0016 #include "version-fielding.h"
0017 #include "fieldingconfig.h"
0018 #include "controller.h"
0019 #include <QQuickStyle>
0020 
0021 Q_DECL_EXPORT int main(int argc, char *argv[])
0022 {
0023 #ifdef Q_OS_ANDROID
0024     QGuiApplication app(argc, argv);
0025     QQuickStyle::setStyle(QStringLiteral("org.kde.breeze"));
0026 #else
0027     QApplication app(argc, argv);
0028     // Default to org.kde.desktop style unless the user forces another style
0029     if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) {
0030         QQuickStyle::setStyle(QStringLiteral("org.kde.desktop"));
0031     }
0032 #endif
0033 
0034     KLocalizedString::setApplicationDomain("fielding");
0035     QCoreApplication::setOrganizationName(QStringLiteral("KDE"));
0036     QCoreApplication::setApplicationName(QStringLiteral("fielding"));
0037 
0038     KAboutData aboutData(
0039                          // The program name used internally.
0040                          QStringLiteral("fielding"),
0041                          // A displayable program name string.
0042                          i18nc("@title", "Fielding"),
0043                          // The program version string.
0044                          QStringLiteral(FIELDING_VERSION_STRING),
0045                          // Short description of what the app does.
0046                          i18n("REST API testing tool"),
0047                          // The license this code is released under.
0048                          KAboutLicense::GPL,
0049                          // Copyright Statement.
0050                          i18n("© 2022 - 2023 KDE Community"));
0051     aboutData.addAuthor(i18nc("@info:credit", "Felipe Kinoshita"), i18nc("@info:credit", "Author"), QStringLiteral("kinofhek@gmail.com"), QStringLiteral("https://fhek.gitlab.io"));
0052     aboutData.setBugAddress("https://invent.kde.org/utilities/fielding/-/issues/new");
0053     KAboutData::setApplicationData(aboutData);
0054     QGuiApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("org.kde.fielding")));
0055 
0056     QQmlApplicationEngine engine;
0057 
0058     auto config = fieldingConfig::self();
0059 
0060     qmlRegisterSingletonInstance("org.kde.fielding.config", 1, 0, "Config", config);
0061 
0062     engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
0063     engine.loadFromModule(QStringLiteral("org.kde.fielding"), QStringLiteral("Main"));
0064 
0065     if (engine.rootObjects().isEmpty()) {
0066         return -1;
0067     }
0068 
0069     KDBusService service(KDBusService::Unique);
0070 
0071     return app.exec();
0072 }