Warning, file /office/marknote/src/main.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-or-later
0003     SPDX-FileCopyrightText: 2021 Mathis Brüchert <mbb-mail@gmx.de>
0004 */
0005 
0006 #include <KAboutData>
0007 #include <KLocalizedContext>
0008 #include <KLocalizedString>
0009 #include <QApplication>
0010 #include <QIcon>
0011 #include <QQmlApplicationEngine>
0012 #include <QQuickStyle>
0013 #include <QUrl>
0014 #include <QtQml>
0015 
0016 #include "../marknote-version.h"
0017 #include "documenthandler.h"
0018 #include "notebooksmodel.h"
0019 #include "notesmodel.h"
0020 
0021 #ifdef Q_OS_WINDOWS
0022 #include <Windows.h>
0023 #endif
0024 
0025 int main(int argc, char *argv[])
0026 {
0027 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0028     QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
0029 #endif
0030 
0031     QApplication app(argc, argv);
0032     // Default to org.kde.desktop style unless the user forces another style
0033     if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) {
0034         QQuickStyle::setStyle(QStringLiteral("org.kde.desktop"));
0035     }
0036 
0037 #ifdef Q_OS_WINDOWS
0038     if (AttachConsole(ATTACH_PARENT_PROCESS)) {
0039         freopen("CONOUT$", "w", stdout);
0040         freopen("CONOUT$", "w", stderr);
0041     }
0042 
0043     QApplication::setStyle(QStringLiteral("breeze"));
0044     auto font = app.font();
0045     font.setPointSize(10);
0046     app.setFont(font);
0047 #endif
0048     KLocalizedString::setApplicationDomain("marknote");
0049 
0050     QGuiApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("org.kde.marknote")));
0051 
0052     KAboutData about(QStringLiteral("marknote"),
0053                      i18n("Marknote"),
0054                      QStringLiteral(MARKNOTE_VERSION_STRING),
0055                      i18n("Note taking application"),
0056                      KAboutLicense::GPL_V2,
0057                      i18n("© 2023 Mathis Brüchert"));
0058     about.addAuthor(i18n("Mathis Brüchert"), i18n("Maintainer"), QStringLiteral("mbb-mail@gmx.de"));
0059     about.setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"), i18nc("EMAIL OF TRANSLATORS", "Your emails"));
0060 
0061     KAboutData::setApplicationData(about);
0062 
0063     QQmlApplicationEngine engine;
0064 
0065     qmlRegisterType<DocumentHandler>("org.kde.marknote", 1, 0, "DocumentHandler");
0066     qmlRegisterType<NotesModel>("org.kde.marknote", 1, 0, "NotesModel");
0067     qmlRegisterType<NoteBooksModel>("org.kde.marknote", 1, 0, "NoteBooksModel");
0068 
0069     qmlRegisterAnonymousType<QAbstractItemModel>("org.kde.marknote", 1);
0070     qmlRegisterType<QSortFilterProxyModel>("org.kde.marknote", 1, 0, "SortFilterModel");
0071 
0072     qmlRegisterSingletonType("org.kde.marknote", 1, 0, "About", [](QQmlEngine *engine, QJSEngine *) -> QJSValue {
0073         return engine->toScriptValue(KAboutData::applicationData());
0074     });
0075 
0076     engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
0077     engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
0078 
0079     if (engine.rootObjects().isEmpty()) {
0080         return -1;
0081     }
0082 
0083     return app.exec();
0084 }