FOSSredder 0.5.0
Loading...
Searching...
No Matches
QmlRuntime.cpp
Go to the documentation of this file.
1
5
7
8#include <QCoreApplication>
9#include <QDir>
10#include <QLibraryInfo>
11#include <QQmlEngine>
12#include <qqml.h>
13
16#include "ui/shell/AppActions.h"
17#include "ui/shell/Defaults.h"
18#include "ui/shell/Navigation.h"
20#include "ui/shell/Status.h"
30
31namespace ui::bootstrap {
32
33namespace {
34
35template<typename T>
36void registerContextObjectType(const char* name) {
37 qmlRegisterUncreatableType<T>(ui::qml::contracts::module::kName,
40 "This type is provided by AppContext");
41}
42
43} // namespace
44
46 // Idempotent registration of QML-exposed types and metaobjects.
47 static bool registered = false;
48 if (registered)
49 return;
50
51 qmlRegisterUncreatableType<ui::Navigation>(
57 registerContextObjectType<ui::Actions>("Actions");
58 registerContextObjectType<ui::FileSystemBrowser>("FileSystemBrowser");
59 registerContextObjectType<ui::LanguageService>("LanguageService");
60 registerContextObjectType<ui::Status>("Status");
61 registerContextObjectType<ui::ActorViewModel>("ActorViewModel");
62 registerContextObjectType<ui::BookingViewModel>("BookingViewModel");
63 registerContextObjectType<ui::ContractViewModel>("ContractViewModel");
64 registerContextObjectType<ui::PropertyViewModel>("PropertyViewModel");
65 registerContextObjectType<ui::AnalysisViewModel>("AnalysisViewModel");
66 registerContextObjectType<ui::AnnualViewModel>("AnnualViewModel");
67 registerContextObjectType<ui::ExportViewModel>("ExportViewModel");
68 registerContextObjectType<ui::ImportViewModel>("ImportViewModel");
69 registerContextObjectType<ui::SettingsViewModel>("SettingsViewModel");
70 qmlRegisterUncreatableMetaObject(
71 ui::qml::contracts::staticMetaObject, ui::qml::contracts::module::kName,
76 registered = true;
77}
78
79void configureRuntime(QQmlEngine* engine) {
80 if (!engine)
81 return;
82
83 const QString qtImports = QLibraryInfo::path(QLibraryInfo::Qml2ImportsPath);
84 if (!qtImports.isEmpty() && QDir(qtImports).exists()) {
85 engine->addImportPath(qtImports);
86 }
87
88 const QString appQmlDir = QCoreApplication::applicationDirPath() +
89 QLatin1Char('/') + ui::config::kAppQmlDirName;
90 if (QDir(appQmlDir).exists()) {
91 engine->addImportPath(appQmlDir);
92 }
93
94 const QString appDir = QCoreApplication::applicationDirPath();
95 if (QDir(appDir).exists()) {
96 engine->addImportPath(appDir);
97 }
98
99 const QString imageFormatsDir = QCoreApplication::applicationDirPath() +
100 QLatin1Char('/') +
102 if (QDir(imageFormatsDir).exists()) {
103 QCoreApplication::addLibraryPath(imageFormatsDir);
104 }
105}
106
107} // namespace ui::bootstrap
Declares the QML API for the Actor view.
Declares the QML API for the Analysis view.
Declares the QML API for the Annual view.
Declares QAction wrappers exposed to the UI layer and QML.
Declares the QML API for the Booking view.
Declares the QML API for the Contract view.
Defines UI-specific runtime constants that are not shared with core.
Declares the QML API for the Export view.
Declares the UI helper that exposes a minimal filesystem view to QML.
Declares the QML API for import overview and draft review.
Declares the UI service responsible for runtime language switching.
Declarations for the UI Navigation component.
Declares the QML API for the Property view.
QML registration and context property name constants used by the UI.
QML runtime setup helpers for registering types and configuring the engine.
Declares the Settings page view model.
Declarations for the UI Status component.
void configureRuntime(QQmlEngine *engine)
Configure QQmlEngine import paths and plugin library paths.
void registerTypes()
Register QML types and meta objects used by the application.
const auto kAppQmlDirName
Deployment directory containing filesystem QML modules next to the executable.
Definition Defaults.h:27
const auto kImageFormatsDirName
Deployment directory containing Qt image format plugins next to the executable.
Definition Defaults.h:30
constexpr auto kQmlContractsTypeDescription
constexpr auto kQmlContractsTypeName
constexpr auto kNavigationTypeName
constexpr auto kNavigationTypeDescription