-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.cpp
52 lines (40 loc) · 1.73 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QIcon>
#include <QLocale>
#include <QThread>
#include <QTranslator>
#include "packagemanager.h"
#include "packagemodel.h"
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QTranslator translator;
const QStringList uiLanguages = QLocale::system().uiLanguages();
for (const QString &locale : uiLanguages) {
const QString baseName = "eosquickstart_" + QLocale(locale).name();
if (translator.load(":/i18n/" + baseName)) {
app.installTranslator(&translator);
break;
}
}
QSettings settings("/etc/eos-quickstart.conf", QSettings::NativeFormat);
const Terminal preferredTerminal = {settings.value("PreferredTerminalPath").toString(), settings.value("PreferredTerminalArgs").toString()};
PackageModel model;
PackageManager packageManager(settings.value("PackageManager", "/usr/bin/pacman").toString(), &model, preferredTerminal);
const QStringList packageList = packageManager.installedPackages();
model.loadModel(settings, packageList);
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty(QStringLiteral("packageModel"), &model);
engine.rootContext()->setContextProperty(QStringLiteral("packageManager"), &packageManager);
const QUrl url(u"qrc:/eosquickstart/main.qml"_qs);
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);
app.setWindowIcon(QIcon::fromTheme("system-software-install"));
return app.exec();
}