swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 1 | #include "IdeMain.h" |
| 2 | |
| 3 | #include <QQmlApplicationEngine> |
| 4 | #include <QQuickStyle> |
swissChili | d2af6ad | 2022-04-16 14:42:17 -0700 | [diff] [blame] | 5 | #include <QTranslator> |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 6 | |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame] | 7 | #include "CellModel.h" |
swissChili | a44bf72 | 2022-04-16 18:41:54 -0700 | [diff] [blame] | 8 | #include "RecentModel.h" |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame] | 9 | |
swissChili | 505de41 | 2022-03-24 12:35:08 -0700 | [diff] [blame] | 10 | int ideMain(Application *app) |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 11 | { |
| 12 | QQmlApplicationEngine engine; |
| 13 | |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 14 | QQuickStyle::setStyle("Material"); |
| 15 | |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame] | 16 | qRegisterMetaType<CellModel>(); |
| 17 | qRegisterMetaType<CellModel *>(); |
swissChili | a44bf72 | 2022-04-16 18:41:54 -0700 | [diff] [blame] | 18 | qRegisterMetaType<RecentModel>(); |
| 19 | qRegisterMetaType<RecentModel *>(); |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame] | 20 | |
swissChili | d2af6ad | 2022-04-16 14:42:17 -0700 | [diff] [blame] | 21 | QTranslator translator; |
| 22 | qInfo() << "loading translations" << translator.load(QLocale(), "refal", "_", ":/ts/", ".qm"); |
| 23 | app->installTranslator(&translator); |
| 24 | |
swissChili | a44bf72 | 2022-04-16 18:41:54 -0700 | [diff] [blame] | 25 | app->setOrganizationName("swissChili"); |
| 26 | app->setOrganizationDomain("swisschili.sh"); |
| 27 | app->setApplicationName("REFAL Studio"); |
| 28 | |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 29 | const QUrl url(QStringLiteral("qrc:/qml/main.qml")); |
| 30 | QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, |
| 31 | app, [url](QObject *obj, const QUrl &objUrl) |
| 32 | { |
| 33 | if (!obj && url == objUrl) |
| 34 | QCoreApplication::exit(-1); |
| 35 | }, Qt::QueuedConnection); |
| 36 | engine.load(url); |
| 37 | |
| 38 | return app->exec(); |
| 39 | } |