ViewSolutions
Loading...
Searching...
No Matches
viewsolutions.cpp
Go to the documentation of this file.
1//#
2//# Copyright (C) 2020-2025 QuasarApp.
3//# Distributed under the GPLv3 software license, see the accompanying
4//# Everyone is permitted to copy and distribute verbatim copies
5//# of this license document, but changing it is not allowed.
6//#
7
8#include "variantlistmodel.h"
9#include "viewsolutions.h"
10#include <QQmlContext>
11#include <qmlcolorpicker.h>
12#include <QQmlApplicationEngine>
13#include <QFile>
14#include <QDir>
15#include <modelstorage.h>
16
17namespace ViewSolutions {
18QSharedPointer<ModelStorage> init(QQmlApplicationEngine *engine) {
19
20 if (!engine)
21 return nullptr;
22
23 auto root = engine->rootContext();
24 if (!root)
25 return nullptr;
26
28
29 engine->addImportPath(":/");
30
31
32
33 auto&& storage = QSharedPointer<ModelStorage>::create(engine);
34 QQmlEngine::setObjectOwnership(storage.get(), QQmlEngine::CppOwnership);
35
36 root->setContextProperty("modelsStorage", storage.get());
37
38 auto&& picker = QSharedPointer<QMLColorPicker>::create();
39 storage->addModel(picker);
40
41 // to-do - remove
42 root->setContextProperty("colorPicker", picker.get());
43
44 qRegisterMetaType<VariantListModel>("VariantListModel");
45
46
47
48 return storage;
49}
50}
the ViewSolutions namespace
QSharedPointer< ModelStorage > init(QQmlApplicationEngine *engine)
init this method import all qml resources to your project.
void initResources()