Initial commit
This commit is contained in:
44
main.cpp
Normal file
44
main.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
|
||||
#include <QLocale>
|
||||
#include <QTranslator>
|
||||
#include <QQmlContext>
|
||||
|
||||
#include "models/summarymodel.h"
|
||||
#include "models/usersmodel.h"
|
||||
#include "services/beerservice.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
#endif
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
QTranslator translator;
|
||||
const QStringList uiLanguages = QLocale::system().uiLanguages();
|
||||
for (const QString &locale : uiLanguages) {
|
||||
const QString baseName = "beerlog_" + QLocale(locale).name();
|
||||
if (translator.load(":/i18n/" + baseName)) {
|
||||
app.installTranslator(&translator);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
const QUrl url(QStringLiteral("qrc:/main.qml"));
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
||||
&app, [url](QObject *obj, const QUrl &objUrl) {
|
||||
if (!obj && url == objUrl)
|
||||
QCoreApplication::exit(-1);
|
||||
}, Qt::QueuedConnection);
|
||||
|
||||
engine.rootContext()->setContextProperty("beerService", new BeerService(&engine));
|
||||
qmlRegisterType<SummaryModel>("ru.ded.beerlog", 1, 0, "SummaryModel");
|
||||
qmlRegisterType<UsersModel>("ru.ded.beerlog", 1, 0, "UsersModel");
|
||||
|
||||
engine.load(url);
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user