File indexing completed on 2024-05-05 04:47:08
0001 #include <QApplication> 0002 #include <QCommandLineParser> 0003 #include <QQmlApplicationEngine> 0004 #include <QQmlContext> 0005 #include <QIcon> 0006 0007 #include <KI18n/KLocalizedString> 0008 0009 #include <MauiKit3/Core/mauiapp.h> 0010 #include <MauiKit3/Terminal/moduleinfo.h> 0011 #include <MauiKit3/TextEditor/moduleinfo.h> 0012 #include <MauiKit3/FileBrowsing/moduleinfo.h> 0013 0014 #include "controllers/processmanager.h" 0015 #include "controllers/projectmanager.h" 0016 #include "controllers/cmakeproject.h" 0017 #include "controllers/cmakeprojecttarget.h" 0018 0019 #include "controllers/cmakeprojectmanager.h" 0020 #include "controllers/projectpreferences.h" 0021 #include "models/fonts.h" 0022 #include "models/cmakeprojectsmodel.h" 0023 #include "models/cmaketargetsmodel.h" 0024 #include "models/sourcesmodel.h" 0025 0026 #include "../strike_version.h" 0027 #include "strike.h" 0028 0029 #define STRIKE_URI "org.slike.strike" 0030 0031 Q_DECL_EXPORT int main(int argc, char *argv[]) 0032 { 0033 QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 0034 QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true); 0035 QApplication app(argc, argv); 0036 0037 app.setOrganizationName(QStringLiteral("Maui")); 0038 app.setWindowIcon(QIcon(":/img/strike.svg")); 0039 0040 KLocalizedString::setApplicationDomain("strike"); 0041 0042 KAboutData about(QStringLiteral("strike"), 0043 QStringLiteral("Strike"), 0044 STRIKE_VERSION_STRING, 0045 i18n("Build and run code."), 0046 KAboutLicense::LGPL_V3, 0047 APP_COPYRIGHT_NOTICE, 0048 QString(GIT_BRANCH) + "/" + QString(GIT_COMMIT_HASH)); 0049 0050 about.addAuthor(QStringLiteral("Camilo Higuita"), i18n("Developer"), QStringLiteral("milo.h@aol.com")); 0051 about.setHomepage("https://slike.org"); 0052 about.setProductName("slike/strike"); 0053 about.setBugAddress("https://invent.kde.org/maui/strike/-/issues"); 0054 about.setOrganizationDomain(STRIKE_URI); 0055 about.setProgramLogo(app.windowIcon()); 0056 0057 const auto TData = MauiKitTerminal::aboutData(); 0058 about.addComponent(TData.name(), MauiKitTerminal::buildVersion(), TData.version(), TData.webAddress()); 0059 0060 const auto FBData = MauiKitFileBrowsing::aboutData(); 0061 about.addComponent(FBData.name(), MauiKitFileBrowsing::buildVersion(), FBData.version(), FBData.webAddress()); 0062 0063 const auto TEData = MauiKitTextEditor::aboutData(); 0064 about.addComponent(TEData.name(), MauiKitTextEditor::buildVersion(), TEData.version(), TEData.webAddress()); 0065 0066 KAboutData::setApplicationData(about); 0067 MauiApp::instance()->setIconName("qrc:/img/strike.svg"); 0068 0069 QCommandLineParser parser; 0070 0071 about.setupCommandLine(&parser); 0072 parser.process(app); 0073 0074 about.processCommandLine(&parser); 0075 const QStringList args = parser.positionalArguments(); 0076 0077 QQmlApplicationEngine engine; 0078 const QUrl url(QStringLiteral("qrc:/main.qml")); 0079 QObject::connect( 0080 &engine, 0081 &QQmlApplicationEngine::objectCreated, 0082 &app, 0083 [url, args](QObject *obj, const QUrl &objUrl) { 0084 if (!obj && url == objUrl) 0085 QCoreApplication::exit(-1); 0086 0087 if (!args.isEmpty()) 0088 Strike::instance()->requestFiles(args); 0089 }, 0090 Qt::QueuedConnection); 0091 0092 engine.rootContext()->setContextObject(new KLocalizedContext(&engine)); 0093 0094 qmlRegisterSingletonInstance<Strike>(STRIKE_URI, 1, 0, "Strike", Strike::instance()); 0095 qmlRegisterType<ProjectManager>(STRIKE_URI, 1, 0, "Project"); //entry point for the project 0096 0097 qmlRegisterAnonymousType<ProjectPreferences>(STRIKE_URI, 1); 0098 qmlRegisterAnonymousType<CMakeProjectsModel>(STRIKE_URI, 1); 0099 qmlRegisterAnonymousType<CMakeProjectTarget>(STRIKE_URI, 1); 0100 qmlRegisterAnonymousType<CMakeTargetsModel>(STRIKE_URI, 1); 0101 qmlRegisterAnonymousType<SourcesModel>(STRIKE_URI, 1); 0102 qmlRegisterUncreatableType<ProcessManager>(STRIKE_URI, 1, 0, "Process", "For the enums. To use it get it from the manager"); 0103 0104 qmlRegisterUncreatableType<CMakeProject>(STRIKE_URI, 1, 0, "CMakeProject", "Get the pointer from CMakeProjectManager"); 0105 0106 qmlRegisterUncreatableType<CMakeProjectManager>(STRIKE_URI, 1, 0, "Manager", "The Project Manager get obtained form StrikeProjec."); 0107 0108 qmlRegisterSingletonType<Fonts>(STRIKE_URI, 1, 0, "Fonts", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * { 0109 Q_UNUSED(engine) 0110 Q_UNUSED(scriptEngine) 0111 return new Fonts; 0112 }); 0113 0114 engine.load(url); 0115 0116 return app.exec(); 0117 }