diff options
| author | Mikko Syrjä <mikko@3d-system.fi> | 2019-02-07 00:49:47 +0200 |
|---|---|---|
| committer | Mikko Syrjä <mikko@3d-system.fi> | 2019-02-07 00:49:47 +0200 |
| commit | 4ba65342d3ce4d8945340a90b33d57a8932bf15d (patch) | |
| tree | 5cd05392f65ccaead8464ea93abe50d6a2227aaf | |
| parent | 66b2fdf05599e2c9b59230c2772fe140e8c24f5b (diff) | |
| download | symedit-4ba65342d3ce4d8945340a90b33d57a8932bf15d.tar.gz symedit-4ba65342d3ce4d8945340a90b33d57a8932bf15d.zip | |
Added C++ connection manager class.
| -rw-r--r-- | Editor.qml | 13 | ||||
| -rw-r--r-- | main.cpp | 9 | ||||
| -rw-r--r-- | main.qml | 8 | ||||
| -rw-r--r-- | symedit.cpp | 48 | ||||
| -rw-r--r-- | symedit.h | 27 | ||||
| -rw-r--r-- | symedit.pro | 6 |
6 files changed, 100 insertions, 11 deletions
@@ -162,13 +162,14 @@ Rectangle { if ( tool === Editor.Tool.RectangleCenter ) { - //## - } - else if ( tool === Editor.Tool.RectangleCorner ) - { - context.rect((cornerx + max) * scalexy, (max - cornery) * scalexy, - deltax * scalexy, deltay * scalexy) + cornerx = startx + (mousex < startx ? -deltax : -deltax) + cornery = starty + (mousey < starty ? deltay : deltay) + deltax *= 2 + deltay *= 2 } + else if ( tool === Editor.Tool.RectangleCorner ) { } + context.rect((cornerx + max) * scalexy, (max - cornery) * scalexy, + deltax * scalexy, deltay * scalexy) if ( fill ) context.fill() else @@ -1,15 +1,22 @@ +#include <QQmlContext> #include <QGuiApplication> #include <QQmlApplicationEngine> +#include "symedit.h" + int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); + SymEdit manager; + QQmlApplicationEngine engine; + engine.rootContext()->setContextProperty("manager", &manager); + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); - if (engine.rootObjects().isEmpty()) + if ( engine.rootObjects().isEmpty() ) return -1; return app.exec(); @@ -6,7 +6,8 @@ ApplicationWindow { property alias mousex: editor.mousex property alias mousey: editor.mousey - property real snap: 5.0 + property int align: 1 + property int snap: 1 property int tool: 0 property bool fill: false @@ -243,8 +244,9 @@ ApplicationWindow Component.onCompleted: { + tool = Editor.Tool.Line + fill = manager.getFill() + snap = manager.getSnap(); snaplist.setsnap() - fill = true - tool = Editor.Tool.Select } } diff --git a/symedit.cpp b/symedit.cpp new file mode 100644 index 0000000..f077370 --- /dev/null +++ b/symedit.cpp @@ -0,0 +1,48 @@ +#include <QGuiApplication> + +#include "symedit.h" + +//! Constructor. +/*! + \param parent //!< Optional parent. +*/ +SymEdit::SymEdit(QObject* parent) : QObject(parent) +{ + clipboard = QGuiApplication::clipboard(); +} + +// +void SymEdit::setFill(bool fill) +{ + //## +} + +// +bool SymEdit::getFill() const +{ + return true; //## +} + +// +void SymEdit::setSnap(int snap) +{ + //## +} + +// +int SymEdit::getSnap() const +{ + return 5; //## +} + +// +void SymEdit::setAlign(int align) +{ + //## +} + +// +int SymEdit::getAlign() const +{ + return 9; //## +} diff --git a/symedit.h b/symedit.h new file mode 100644 index 0000000..1a71c55 --- /dev/null +++ b/symedit.h @@ -0,0 +1,27 @@ +#ifndef SYMEDIT_H +#define SYMEDIT_H + +#include <QObject> +#include <QString> +#include <QClipboard> + +//! Manager class. +class SymEdit : public QObject +{ + Q_OBJECT + +public: + explicit SymEdit(QObject* parent = nullptr); + + Q_INVOKABLE void setFill(bool fill); + Q_INVOKABLE bool getFill() const; + Q_INVOKABLE void setSnap(int snap); + Q_INVOKABLE int getSnap() const; + Q_INVOKABLE void setAlign(int align); + Q_INVOKABLE int getAlign() const; + +private: + QClipboard* clipboard; //!< System clipboard. +}; + +#endif diff --git a/symedit.pro b/symedit.pro index b5bab04..da52c07 100644 --- a/symedit.pro +++ b/symedit.pro @@ -12,7 +12,8 @@ DEFINES += QT_DEPRECATED_WARNINGS # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 -SOURCES += main.cpp +SOURCES += main.cpp \ + symedit.cpp RESOURCES += qml.qrc @@ -26,3 +27,6 @@ QML_DESIGNER_IMPORT_PATH = qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target + +HEADERS += \ + symedit.h |
