Clean initialization of of Qt Quick GUI

This commit is contained in:
Martchus 2018-12-15 23:10:53 +01:00
parent 36b8324f6b
commit e59662acc9
1 changed files with 3 additions and 18 deletions

View File

@ -6,7 +6,9 @@
#include "resources/config.h"
// enable inline helper functions for Qt Quick provided by qtutilities
#define QT_UTILITIES_GUI_QTQUICK
#include <qtutilities/resources/qtconfigarguments.h>
#include <qtutilities/resources/resources.h>
@ -22,10 +24,6 @@
#include <QApplication>
#endif
#ifdef Q_OS_ANDROID
#include <QtAndroid>
#endif
using namespace ApplicationUtilities;
namespace QtGui {
@ -50,12 +48,10 @@ int runQuickGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs, c
qtConfigArgs.applySettings();
qtConfigArgs.applySettingsForQuickGui();
#ifdef Q_OS_ANDROID
// assume we're bundling breeze icons under Android
// assume we're bundling breeze icons
if (QIcon::themeName().isEmpty()) {
QIcon::setThemeName(QStringLiteral("breeze"));
}
#endif
// load settings from configuration file
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QStringLiteral(PROJECT_NAME));
@ -63,16 +59,6 @@ int runQuickGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs, c
// load translations
LOAD_QT_TRANSLATIONS;
// determine user paths
const QVariantMap userPaths{
{ QStringLiteral("desktop"), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) },
{ QStringLiteral("documents"), QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) },
{ QStringLiteral("music"), QStandardPaths::writableLocation(QStandardPaths::MusicLocation) },
{ QStringLiteral("movies"), QStandardPaths::writableLocation(QStandardPaths::MoviesLocation) },
{ QStringLiteral("pictures"), QStandardPaths::writableLocation(QStandardPaths::PicturesLocation) },
{ QStringLiteral("home"), QStandardPaths::writableLocation(QStandardPaths::HomeLocation) },
};
// init Quick GUI
QQmlApplicationEngine engine;
Controller controller(settings, file);
@ -80,7 +66,6 @@ int runQuickGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs, c
registerControllerForAndroid(&controller);
#endif
auto *const context(engine.rootContext());
context->setContextProperty(QStringLiteral("userPaths"), userPaths);
context->setContextProperty(QStringLiteral("nativeInterface"), &controller);
context->setContextProperty(QStringLiteral("app"), &a);
context->setContextProperty(QStringLiteral("description"), QStringLiteral(APP_DESCRIPTION));