diff --git a/CMakePresets.json b/CMakePresets.json index ac80482..ec5a060 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,63 +1,63 @@ { - "version": 6, - "configurePresets": [ - { - "name": "default-release", - "displayName": "Default Config", - "description": "Release build type using Ninja generator", - "generator": "Ninja", - "binaryDir": "${sourceDir}/build/release", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release" - } - }, - { - "name": "default-develop", - "displayName": "Default Config for development", - "description": "Debug build type using Ninja generator", - "generator": "Ninja", - "binaryDir": "${sourceDir}/build/debug", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug" - } - } - ], - "buildPresets": [ - { - "name": "default-release", - "configurePreset": "default-release" - }, - { - "name": "default-develop", - "configurePreset": "default-develop" - } - ], - "workflowPresets": [ - { - "name": "release", - "steps": [ - { - "type": "configure", - "name": "default-release" - }, - { - "type": "build", - "name": "default-release" - } - ] - }, - { - "name": "develop", - "steps": [ - { - "type": "configure", - "name": "default-develop" - }, - { - "type": "build", - "name": "default-develop" - } - ] - } - ] + "version": 6, + "configurePresets": [ + { + "name": "default-release", + "displayName": "Default Config", + "description": "Release build type using Ninja generator", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/release", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "default-develop", + "displayName": "Default Config for development", + "description": "Debug build type using Ninja generator", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/debug", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + } + ], + "buildPresets": [ + { + "name": "default-release", + "configurePreset": "default-release" + }, + { + "name": "default-develop", + "configurePreset": "default-develop" + } + ], + "workflowPresets": [ + { + "name": "release", + "steps": [ + { + "type": "configure", + "name": "default-release" + }, + { + "type": "build", + "name": "default-release" + } + ] + }, + { + "name": "develop", + "steps": [ + { + "type": "configure", + "name": "default-develop" + }, + { + "type": "build", + "name": "default-develop" + } + ] + } + ] } diff --git a/main.cpp b/main.cpp index 4de98f1..da3a06f 100644 --- a/main.cpp +++ b/main.cpp @@ -3,26 +3,24 @@ #include #ifdef USE_QtQr -#include "Qrimageprovider.hpp" #include "Qrimagedecoder.hpp" +#include "Qrimageprovider.hpp" #endif - - int main(int argc, char *argv[]) { - QGuiApplication app(argc, argv); + QGuiApplication app(argc, argv); QQuickStyle::setStyle("Esterv.Controls.Flat"); - QQmlApplicationEngine engine; - engine.addImportPath("qrc:/esterVtech.com/imports"); + QQmlApplicationEngine engine; + engine.addImportPath("qrc:/esterVtech.com/imports"); #ifdef USE_QtQr engine.addImageProvider(QLatin1String("qrcode"), new QRImageProvider(1)); - engine.addImageProvider(QLatin1String("wasm"), new WasmImageProvider()); + engine.addImageProvider(QLatin1String("wasm"), new WasmImageProvider()); #endif const QUrl url("qrc:/esterVtech.com/imports/qmlonline/main.qml"); - engine.load(url); + engine.load(url); - return app.exec(); + return app.exec(); } diff --git a/main.qml b/main.qml index 8d9aa90..00ceb8e 100644 --- a/main.qml +++ b/main.qml @@ -16,9 +16,8 @@ Window { Connections { target: QmlTextCode function onCodeChanged() { - box.create(QmlTextCode.code) + box.create(QmlTextCode.code); } - } Item { id: box @@ -26,15 +25,12 @@ Window { property var userItem: null function create(textComponent) { - - if(userItem) { - userItem.destroy() + if (userItem) { + userItem.destroy(); } - userItem = Qt.createQmlObject(textComponent, box, "userItem") + userItem = Qt.createQmlObject(textComponent, box, "userItem"); } Component.onCompleted: box.create(QmlTextCode.code) } - - } diff --git a/qmltextcode.cpp b/qmltextcode.cpp index 8886ea4..34390ab 100644 --- a/qmltextcode.cpp +++ b/qmltextcode.cpp @@ -1,20 +1,22 @@ #include "qmltextcode.h" -std::vector QmlTextCode::editors=std::vector(); +std::vector QmlTextCode::editors = std::vector(); void QmlTextCode::setCode(const std::string &code) { - const auto var=QString::fromStdString(code); - if (_code != var) { + const auto var = QString::fromStdString(code); + if (_code != var) + { _code = var; emit codeChanged(); } } -QmlTextCode* QmlTextCode::get_editor(const size_t& index) +QmlTextCode *QmlTextCode::get_editor(const size_t &index) { return editors[index]; } #ifdef USE_EMSCRIPTEN -EMSCRIPTEN_BINDINGS(qmltextcode) { +EMSCRIPTEN_BINDINGS(qmltextcode) +{ emscripten::class_("qmlTextCode") .function("setCode", &QmlTextCode::setCode) .class_function("get_editor", &QmlTextCode::get_editor, emscripten::allow_raw_pointers()); diff --git a/qmltextcode.h b/qmltextcode.h index 8762f9d..84303f4 100644 --- a/qmltextcode.h +++ b/qmltextcode.h @@ -14,21 +14,22 @@ class QmlTextCode : public QObject QML_ELEMENT QML_SINGLETON -public: - QmlTextCode(){ + public: + QmlTextCode() + { editors.push_back(this); }; - QString read() const{return _code;}; - void setCode(const std::string& code); - static QmlTextCode* get_editor(const size_t& index); - - + QString read() const + { + return _code; + }; + void setCode(const std::string &code); + static QmlTextCode *get_editor(const size_t &index); -signals: + signals: void codeChanged(); -private: + + private: QString _code; - static std::vector editors; + static std::vector editors; }; - -