94 lines
3.0 KiB
C++
94 lines
3.0 KiB
C++
#include "./initiatequick.h"
|
|
#include "./controller.h"
|
|
#ifdef Q_OS_ANDROID
|
|
#include "./android.h"
|
|
#endif
|
|
|
|
#include "resources/config.h"
|
|
|
|
#define QT_UTILITIES_GUI_QTQUICK
|
|
#include <qtutilities/resources/qtconfigarguments.h>
|
|
#include <qtutilities/resources/resources.h>
|
|
|
|
#include <QGuiApplication>
|
|
#include <QIcon>
|
|
#include <QQmlApplicationEngine>
|
|
#include <QQmlContext>
|
|
#include <QSettings>
|
|
#include <QTextCodec>
|
|
#include <QtQml>
|
|
|
|
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
|
#include <QApplication>
|
|
#endif
|
|
|
|
#ifdef Q_OS_ANDROID
|
|
#include <QtAndroid>
|
|
#endif
|
|
|
|
using namespace ApplicationUtilities;
|
|
|
|
namespace QtGui {
|
|
|
|
int runQuickGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs, const QString &file)
|
|
{
|
|
// setup Android-specifics (logging, theming)
|
|
#ifdef Q_OS_ANDROID
|
|
setupAndroidSpecifics();
|
|
#endif
|
|
|
|
// init application
|
|
SET_QT_APPLICATION_INFO;
|
|
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
|
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
|
|
QApplication a(argc, argv);
|
|
#else
|
|
QGuiApplication a(argc, argv);
|
|
#endif
|
|
|
|
// apply settings specified via command line args
|
|
qtConfigArgs.applySettings();
|
|
qtConfigArgs.applySettingsForQuickGui();
|
|
|
|
#ifdef Q_OS_ANDROID
|
|
// assume we're bundling breeze icons under Android
|
|
if (QIcon::themeName().isEmpty()) {
|
|
QIcon::setThemeName(QStringLiteral("breeze"));
|
|
}
|
|
#endif
|
|
|
|
// load settings from configuration file
|
|
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QStringLiteral(PROJECT_NAME));
|
|
|
|
// 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);
|
|
#ifdef Q_OS_ANDROID
|
|
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));
|
|
context->setContextProperty(QStringLiteral("dependencyVersions"), QStringList(DEPENCENCY_VERSIONS));
|
|
engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
|
|
|
|
// run event loop
|
|
return a.exec();
|
|
}
|
|
} // namespace QtGui
|