51 lines
1.2 KiB
C++
Raw Normal View History

#include "clientapp.h"
2019-07-29 15:29:07 +03:00
#include "imageprovider.h"
#include "ProfileViewItems/userview.h"
#include <QQmlApplicationEngine>
#include <QQmlContext>
2019-07-29 11:45:04 +03:00
#include <back-end/ProfileViewItems/mainmenumodel.h>
2019-08-17 23:42:22 +03:00
#include <back-end/ProfileViewItems/notificationservice.h>
2019-08-09 20:48:31 +03:00
QByteArray ClientApp::initTheme() {
int themeIndex = Settings::get()->getValue(THEME, THEME_DEFAULT).toInt();
switch (themeIndex) {
case 1: return "Dark";
default: return "Light";
}
}
ClientApp::ClientApp() {
2019-07-29 15:29:07 +03:00
}
2019-07-29 15:29:07 +03:00
ClientApp::~ClientApp() {
}
2019-07-29 11:45:04 +03:00
bool ClientApp::init(QQmlApplicationEngine *engine) {
2019-08-09 20:48:31 +03:00
qputenv("QT_QUICK_CONTROLS_MATERIAL_THEME", initTheme());
qmlRegisterType <GuiObject> ();
qmlRegisterType <Diff> ();
2019-07-29 11:45:04 +03:00
qmlRegisterType <MainMenuModel> ();
qmlRegisterType <UserView> ();
auto root = engine->rootContext();
if (!root)
return false;
2019-07-29 15:29:07 +03:00
engine->addImageProvider(QLatin1String("userItems"), new ImageProvider());
root->setContextProperty("contr", &contr);
2019-08-17 23:42:22 +03:00
root->setContextProperty("notificationService", NotificationService::getService());
engine->load(QUrl(QStringLiteral("qrc:/front-end/main.qml")));
if (engine->rootObjects().isEmpty())
return false;
return true;
}