Skip to content

Commit

Permalink
C/C++/QML formatted code (#57)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] authored Jun 16, 2024
1 parent f7cbff3 commit db77454
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 95 deletions.
122 changes: 61 additions & 61 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
]
}
16 changes: 7 additions & 9 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,24 @@

#include <QQuickStyle>
#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();
}
12 changes: 4 additions & 8 deletions main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,21 @@ Window {
Connections {
target: QmlTextCode
function onCodeChanged() {
box.create(QmlTextCode.code)
box.create(QmlTextCode.code);
}

}
Item {
id: box
anchors.fill: parent
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)
}


}
12 changes: 7 additions & 5 deletions qmltextcode.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
#include "qmltextcode.h"

std::vector<QmlTextCode*> QmlTextCode::editors=std::vector<QmlTextCode*>();
std::vector<QmlTextCode *> QmlTextCode::editors = std::vector<QmlTextCode *>();
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>("qmlTextCode")
.function("setCode", &QmlTextCode::setCode)
.class_function("get_editor", &QmlTextCode::get_editor, emscripten::allow_raw_pointers());
Expand Down
25 changes: 13 additions & 12 deletions qmltextcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<QmlTextCode*> editors;
static std::vector<QmlTextCode *> editors;
};


0 comments on commit db77454

Please sign in to comment.