aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikko Syrjä <mikko@3d-system.fi>2019-02-07 00:49:47 +0200
committerMikko Syrjä <mikko@3d-system.fi>2019-02-07 00:49:47 +0200
commit4ba65342d3ce4d8945340a90b33d57a8932bf15d (patch)
tree5cd05392f65ccaead8464ea93abe50d6a2227aaf
parent66b2fdf05599e2c9b59230c2772fe140e8c24f5b (diff)
downloadsymedit-4ba65342d3ce4d8945340a90b33d57a8932bf15d.tar.gz
symedit-4ba65342d3ce4d8945340a90b33d57a8932bf15d.zip
Added C++ connection manager class.
-rw-r--r--Editor.qml13
-rw-r--r--main.cpp9
-rw-r--r--main.qml8
-rw-r--r--symedit.cpp48
-rw-r--r--symedit.h27
-rw-r--r--symedit.pro6
6 files changed, 100 insertions, 11 deletions
diff --git a/Editor.qml b/Editor.qml
index 0c14ef6..4abd5fa 100644
--- a/Editor.qml
+++ b/Editor.qml
@@ -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
diff --git a/main.cpp b/main.cpp
index 5298d03..9eb9e40 100644
--- a/main.cpp
+++ b/main.cpp
@@ -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();
diff --git a/main.qml b/main.qml
index 36f0d5f..203234d 100644
--- a/main.qml
+++ b/main.qml
@@ -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