Clean code for initializing Qt Quick GUI
This commit is contained in:
parent
9ebffe6b16
commit
ba9a6e26de
|
@ -18,18 +18,17 @@
|
||||||
#include <passwordfile/util/openssl.h>
|
#include <passwordfile/util/openssl.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QGuiApplication>
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QtQml>
|
|
||||||
#ifdef Q_OS_ANDROID
|
|
||||||
#include <QDirIterator>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
using App = QApplication;
|
||||||
|
#else
|
||||||
|
#include <QGuiApplication>
|
||||||
|
using App = QGuiApplication;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
@ -46,21 +45,13 @@ int runQuickGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs, c
|
||||||
setupAndroidSpecifics();
|
setupAndroidSpecifics();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// work around kirigami plugin trying to be clever
|
|
||||||
if (!qEnvironmentVariableIsSet("XDG_CURRENT_DESKTOP")) {
|
|
||||||
qputenv("XDG_CURRENT_DESKTOP", QByteArray("please don't override my settings"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// init OpenSSL
|
// init OpenSSL
|
||||||
OpenSsl::init();
|
OpenSsl::init();
|
||||||
|
|
||||||
// init application
|
// init application
|
||||||
SET_QT_APPLICATION_INFO;
|
SET_QT_APPLICATION_INFO;
|
||||||
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
auto application = App(argc, argv);
|
||||||
auto application = QApplication(argc, argv);
|
QObject::connect(&application, &QCoreApplication::aboutToQuit, &OpenSsl::clean);
|
||||||
#else
|
|
||||||
auto application = QGuiApplication(argc, argv);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// restore Qt settings
|
// restore Qt settings
|
||||||
auto qtSettings = QtUtilities::QtSettings();
|
auto qtSettings = QtUtilities::QtSettings();
|
||||||
|
@ -79,7 +70,7 @@ int runQuickGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs, c
|
||||||
qtConfigArgs.applySettingsForQuickGui();
|
qtConfigArgs.applySettingsForQuickGui();
|
||||||
LOAD_QT_TRANSLATIONS;
|
LOAD_QT_TRANSLATIONS;
|
||||||
|
|
||||||
// init Quick GUI
|
// init QML engine
|
||||||
auto controller = Controller(*settings, file);
|
auto controller = Controller(*settings, file);
|
||||||
auto engine = QQmlApplicationEngine();
|
auto engine = QQmlApplicationEngine();
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
|
@ -97,7 +88,6 @@ int runQuickGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs, c
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QObject::connect(&application, &QCoreApplication::aboutToQuit, &OpenSsl::clean);
|
|
||||||
// load main QML file; run event loop or exit if it cannot be loaded
|
// load main QML file; run event loop or exit if it cannot be loaded
|
||||||
const auto mainUrl = QUrl(QStringLiteral("qrc:/qml/main.qml"));
|
const auto mainUrl = QUrl(QStringLiteral("qrc:/qml/main.qml"));
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
|
|
Loading…
Reference in New Issue