Clean initialization of of Qt Quick GUI
This commit is contained in:
parent
36b8324f6b
commit
e59662acc9
|
@ -6,7 +6,9 @@
|
||||||
|
|
||||||
#include "resources/config.h"
|
#include "resources/config.h"
|
||||||
|
|
||||||
|
// enable inline helper functions for Qt Quick provided by qtutilities
|
||||||
#define QT_UTILITIES_GUI_QTQUICK
|
#define QT_UTILITIES_GUI_QTQUICK
|
||||||
|
|
||||||
#include <qtutilities/resources/qtconfigarguments.h>
|
#include <qtutilities/resources/qtconfigarguments.h>
|
||||||
#include <qtutilities/resources/resources.h>
|
#include <qtutilities/resources/resources.h>
|
||||||
|
|
||||||
|
@ -22,10 +24,6 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_ANDROID
|
|
||||||
#include <QtAndroid>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace ApplicationUtilities;
|
using namespace ApplicationUtilities;
|
||||||
|
|
||||||
namespace QtGui {
|
namespace QtGui {
|
||||||
|
@ -50,12 +48,10 @@ int runQuickGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs, c
|
||||||
qtConfigArgs.applySettings();
|
qtConfigArgs.applySettings();
|
||||||
qtConfigArgs.applySettingsForQuickGui();
|
qtConfigArgs.applySettingsForQuickGui();
|
||||||
|
|
||||||
#ifdef Q_OS_ANDROID
|
// assume we're bundling breeze icons
|
||||||
// assume we're bundling breeze icons under Android
|
|
||||||
if (QIcon::themeName().isEmpty()) {
|
if (QIcon::themeName().isEmpty()) {
|
||||||
QIcon::setThemeName(QStringLiteral("breeze"));
|
QIcon::setThemeName(QStringLiteral("breeze"));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// load settings from configuration file
|
// load settings from configuration file
|
||||||
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QStringLiteral(PROJECT_NAME));
|
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 translations
|
||||||
LOAD_QT_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
|
// init Quick GUI
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
Controller controller(settings, file);
|
Controller controller(settings, file);
|
||||||
|
@ -80,7 +66,6 @@ int runQuickGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs, c
|
||||||
registerControllerForAndroid(&controller);
|
registerControllerForAndroid(&controller);
|
||||||
#endif
|
#endif
|
||||||
auto *const context(engine.rootContext());
|
auto *const context(engine.rootContext());
|
||||||
context->setContextProperty(QStringLiteral("userPaths"), userPaths);
|
|
||||||
context->setContextProperty(QStringLiteral("nativeInterface"), &controller);
|
context->setContextProperty(QStringLiteral("nativeInterface"), &controller);
|
||||||
context->setContextProperty(QStringLiteral("app"), &a);
|
context->setContextProperty(QStringLiteral("app"), &a);
|
||||||
context->setContextProperty(QStringLiteral("description"), QStringLiteral(APP_DESCRIPTION));
|
context->setContextProperty(QStringLiteral("description"), QStringLiteral(APP_DESCRIPTION));
|
||||||
|
|
Loading…
Reference in New Issue