File indexing completed on 2024-09-08 13:03:43
0001 /* 0002 SPDX-License-Identifier: GPL-2.0-or-later 0003 SPDX-FileCopyrightText: 2022 Louis Schul <schul9louis@gmail.com> 0004 */ 0005 0006 #include <QApplication> 0007 #include <QQmlApplicationEngine> 0008 0009 // Do not remove this, breaks Qt6 build 0010 #include <QtQml> 0011 0012 #include <QtWebEngineQuick> 0013 0014 #include "app.h" 0015 #include "kleverconfig.h" 0016 #include <KAboutData> 0017 #include <KLocalizedContext> 0018 #include <KLocalizedString> 0019 0020 #include "logic/colorschemer.h" 0021 #include "logic/documentHandler.h" 0022 #include "logic/kleverUtility.h" 0023 #include "logic/mdHandler.h" 0024 0025 #include "logic/treeview/noteTreeModel.h" 0026 0027 #include "logic/painting/pressureequation.h" 0028 #include "logic/painting/sketchmodel.h" 0029 #include "logic/painting/sketchserializer.h" 0030 #include "logic/painting/sketchview.h" 0031 #include "logic/painting/strokeitem.h" 0032 #include "logic/painting/strokelistitem.h" 0033 0034 #include "logic/parser/parser.h" 0035 0036 #include "logic/printing/printingHelper.h" 0037 0038 // Plugins 0039 #include "logic/plugins/emoji/emojiModel.h" 0040 #include "logic/plugins/emoji/emoticonFilterModel.h" 0041 #include "logic/plugins/noteMapper/noteMapper.h" 0042 #include "logic/plugins/syntaxHighlight/highlightHelper.h" 0043 0044 Q_DECL_EXPORT int main(int argc, char *argv[]) 0045 { 0046 QtWebEngineQuick::initialize(); 0047 QApplication app(argc, argv); 0048 QCoreApplication::setOrganizationName(QStringLiteral("KDE")); 0049 0050 KLocalizedString::setApplicationDomain("klevernotes"); 0051 0052 KAboutData aboutData( 0053 // The program name used internally. 0054 QStringLiteral("klevernotes"), 0055 // A displayable program name string. 0056 i18nc("@title", "KleverNotes"), 0057 // The program version string. 0058 QStringLiteral("1.0"), 0059 // Short description of what the app does. 0060 i18n("Application Description"), 0061 // The license this code is released under. 0062 KAboutLicense::GPL, 0063 // Copyright Statement. 0064 i18n("(c) 2022-2023")); 0065 aboutData.addAuthor(i18nc("@info:credit", "Louis Schul"), 0066 // i18nc("@info:credit", "Author Role"), 0067 QStringLiteral("schul9louis@outlook.fr") 0068 // QStringLiteral("https://yourwebsite.com") 0069 ); 0070 aboutData.setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"), i18nc("EMAIL OF TRANSLATORS", "Your emails")); 0071 KAboutData::setApplicationData(aboutData); 0072 QGuiApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("org.kde.klevernotes"))); 0073 0074 QQmlApplicationEngine engine; 0075 0076 auto config = KleverConfig::self(); 0077 // General 0078 QObject::connect(config, &KleverConfig::storagePathChanged, config, &KleverConfig::save); 0079 QObject::connect(config, &KleverConfig::defaultCategoryNameChanged, config, &KleverConfig::save); 0080 QObject::connect(config, &KleverConfig::defaultGroupNameChanged, config, &KleverConfig::save); 0081 QObject::connect(config, &KleverConfig::defaultNoteNameChanged, config, &KleverConfig::save); 0082 QObject::connect(config, &KleverConfig::pdfWarningHiddenChanged, config, &KleverConfig::save); 0083 // Appearence 0084 QObject::connect(config, &KleverConfig::editorFontChanged, config, &KleverConfig::save); 0085 QObject::connect(config, &KleverConfig::categoryDisplayNameChanged, config, &KleverConfig::save); 0086 QObject::connect(config, &KleverConfig::viewBodyColorChanged, config, &KleverConfig::save); 0087 QObject::connect(config, &KleverConfig::viewTextColorChanged, config, &KleverConfig::save); 0088 QObject::connect(config, &KleverConfig::viewTitleColorChanged, config, &KleverConfig::save); 0089 QObject::connect(config, &KleverConfig::viewLinkColorChanged, config, &KleverConfig::save); 0090 QObject::connect(config, &KleverConfig::viewVisitedLinkColorChanged, config, &KleverConfig::save); 0091 QObject::connect(config, &KleverConfig::viewCodeColorChanged, config, &KleverConfig::save); 0092 QObject::connect(config, &KleverConfig::viewHighlightColorChanged, config, &KleverConfig::save); 0093 QObject::connect(config, &KleverConfig::viewFontChanged, config, &KleverConfig::save); 0094 QObject::connect(config, &KleverConfig::codeFontChanged, config, &KleverConfig::save); 0095 QObject::connect(config, &KleverConfig::stylePathChanged, config, &KleverConfig::save); 0096 // Plugins 0097 QObject::connect(config, &KleverConfig::codeSynthaxHighlightEnabledChanged, config, &KleverConfig::save); 0098 QObject::connect(config, &KleverConfig::codeSynthaxHighlighterChanged, config, &KleverConfig::save); 0099 QObject::connect(config, &KleverConfig::codeSynthaxHighlighterStyleChanged, config, &KleverConfig::save); 0100 QObject::connect(config, &KleverConfig::noteMapEnabledChanged, config, &KleverConfig::save); 0101 QObject::connect(config, &KleverConfig::quickEmojiEnabledChanged, config, &KleverConfig::save); 0102 QObject::connect(config, &KleverConfig::emojiToneChanged, config, &KleverConfig::save); 0103 QObject::connect(config, &KleverConfig::quickEmojiDialogEnabledChanged, config, &KleverConfig::save); 0104 QObject::connect(config, &KleverConfig::pumlEnabledChanged, config, &KleverConfig::save); 0105 0106 qmlRegisterSingletonInstance("org.kde.Klever", 1, 0, "Config", config); 0107 0108 qmlRegisterSingletonType("org.kde.Klever", 1, 0, "About", [](QQmlEngine *engine, QJSEngine *) -> QJSValue { 0109 return engine->toScriptValue(KAboutData::applicationData()); 0110 }); 0111 0112 App application; 0113 qmlRegisterSingletonInstance("org.kde.Klever", 1, 0, "App", &application); 0114 0115 KleverUtility kleverUtility; 0116 qmlRegisterSingletonInstance<KleverUtility>("org.kde.Klever", 1, 0, "KleverUtility", &kleverUtility); 0117 0118 DocumentHandler documentHandler; 0119 qmlRegisterSingletonInstance<DocumentHandler>("org.kde.Klever", 1, 0, "DocumentHandler", &documentHandler); 0120 0121 MDHandler mdHandler; 0122 qmlRegisterSingletonInstance<MDHandler>("org.kde.Klever", 1, 0, "MDHandler", &mdHandler); 0123 0124 ColorSchemer colorScheme; 0125 qmlRegisterSingletonInstance<ColorSchemer>("org.kde.Klever", 1, 0, "ColorSchemer", &colorScheme); 0126 0127 qmlRegisterType<PrintingUtility>("org.kde.Klever", 1, 0, "PrintingUtility"); 0128 0129 qmlRegisterType<Parser>("org.kde.Klever", 1, 0, "Parser"); 0130 qmlRegisterType<NoteTreeModel>("org.kde.Klever", 1, 0, "NoteTreeModel"); 0131 0132 // === PLUGINS === 0133 qmlRegisterType<EmoticonFilterModel>("org.kde.neochat", 1, 0, "EmoticonFilterModel"); 0134 qmlRegisterSingletonInstance("org.kde.neochat", 1, 0, "EmojiModel", &EmojiModel::instance()); 0135 0136 qmlRegisterType<NoteMapper>("org.kde.Klever", 1, 0, "NoteMapper"); 0137 0138 HighlightHelper highlightHelper; 0139 qmlRegisterSingletonInstance<HighlightHelper>("org.kde.Klever", 1, 0, "HighlightHelper", &highlightHelper); 0140 // === === === === 0141 0142 qRegisterMetaType<StrokeSample>(); 0143 qRegisterMetaType<Stroke>(); 0144 qRegisterMetaType<Stroke::Type>(); 0145 qRegisterMetaType<Event>(); 0146 0147 qmlRegisterUncreatableType<StrokeSample>("WashiPad", 1, 0, "strokeSample", QStringLiteral("Use the createSample function on SketchViewHandler instead")); 0148 qmlRegisterUncreatableType<Stroke>("WashiPad", 1, 0, "stroke", QStringLiteral("Use the createStroke function on SketchViewHandler instead")); 0149 qmlRegisterUncreatableType<Event>("WashiPad", 1, 0, "event", QStringLiteral("They are provided by the SketchViewHandler")); 0150 0151 qmlRegisterType<PressureEquation>("WashiPad", 1, 0, "PressureEquation"); 0152 0153 qmlRegisterType<SketchViewHandler>("WashiPad", 1, 0, "SketchViewHandler"); 0154 0155 qmlRegisterType<SketchModel>("WashiPad", 1, 0, "SketchModel"); 0156 qmlRegisterType<SketchSerializer>("WashiPad", 1, 0, "SketchSerializer"); 0157 qmlRegisterType<StrokeItem>("WashiPad", 1, 0, "StrokeItem"); 0158 qmlRegisterType<StrokeListItem>("WashiPad", 1, 0, "StrokeListItem"); 0159 0160 engine.rootContext()->setContextObject(new KLocalizedContext(&engine)); 0161 engine.load(QUrl(QStringLiteral("qrc:/contents/ui/main.qml"))); 0162 0163 if (engine.rootObjects().isEmpty()) { 0164 return -1; 0165 } 0166 0167 return app.exec(); 0168 }