#include "./initiatequick.h" #include "./controller.h" #include "resources/config.h" #include #include #include #include #include #include #include #ifdef PASSWORD_MANAGER_GUI_QTWIDGETS #include #endif using namespace ApplicationUtilities; namespace QtGui { int runQuickGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs, const QString &file) { // init application #ifdef __ANDROID__ qputenv("QT_QUICK_CONTROLS_STYLE", "material"); #endif 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(); // load translations and enforce UTF-8 locale QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); 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 //qmlRegisterType("martchus.passwordmanager", 2, 0, "EntryFilterModel"); //qmlRegisterType("martchus.passwordmanager", 2, 0, "EntryModel"); //qmlRegisterType("martchus.passwordmanager", 2, 0, "FieldModel"); //qmlRegisterType("martchus.passwordmanager", 2, 1, "AccountEntry"); QQmlApplicationEngine engine; Controller controller(file); QQmlContext *const context(engine.rootContext()); context->setContextProperty(QStringLiteral("userPaths"), userPaths); context->setContextProperty(QStringLiteral("nativeInterface"), &controller); engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml"))); // run event loop return a.exec(); } } // namespace QtGui