aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikko Syrjä <mikko@3d-system.fi>2019-02-19 22:17:28 +0200
committerMikko Syrjä <mikko@3d-system.fi>2019-02-19 22:17:28 +0200
commit73b8e028b54c2a616c508df555b114789d1f2d06 (patch)
treed605c768fa4241eed78a24a8039d74e83472d0ce
parentaec3abf4dcad514448072c6c80c8ada4b6a254b8 (diff)
downloadsymedit-73b8e028b54c2a616c508df555b114789d1f2d06.tar.gz
symedit-73b8e028b54c2a616c508df555b114789d1f2d06.zip
Tool improvements.
-rw-r--r--BarSeparator.qml (renamed from Separator.qml)0
-rw-r--r--BarTool.qml (renamed from Tool.qml)5
-rw-r--r--Editor.qml35
-rw-r--r--MenuTool.qml15
-rw-r--r--image/circle_horizontal.pngbin865 -> 0 bytes
-rw-r--r--image/circle_radius.pngbin0 -> 1044 bytes
-rw-r--r--image/circle_vertical.pngbin1020 -> 0 bytes
-rw-r--r--image/cursor_arrow_icon&48.pngbin0 -> 3875 bytes
-rw-r--r--main.qml438
-rw-r--r--qml.qrc11
10 files changed, 146 insertions, 358 deletions
diff --git a/Separator.qml b/BarSeparator.qml
index 2ac4832..2ac4832 100644
--- a/Separator.qml
+++ b/BarSeparator.qml
diff --git a/Tool.qml b/BarTool.qml
index 138766a..99e5938 100644
--- a/Tool.qml
+++ b/BarTool.qml
@@ -3,8 +3,8 @@ import QtQuick.Controls 1.4
ToolButton
{
- property int tool
property string image
+ property int tool: 0
implicitHeight: 32
implicitWidth: 32
@@ -15,6 +15,7 @@ ToolButton
}
onClicked:
{
- window.tool = tool
+ if ( tool )
+ window.tool = tool
}
}
diff --git a/Editor.qml b/Editor.qml
index bb3b53c..0b396d2 100644
--- a/Editor.qml
+++ b/Editor.qml
@@ -9,10 +9,9 @@ Rectangle
LinePoly = 12,
RectangleCenter = 21,
RectangleCorner = 22,
- CircleCenter = 31,
- CircleHorizontal = 32,
- CircleVertical = 33,
- CircleCorner = 34,
+ CircleCorner = 31,
+ CircleRadius = 32,
+ CircleCenter = 33,
ArcSemicircle = 41,
ArcQuarter = 42,
Text = 51
@@ -227,29 +226,23 @@ Rectangle
else if ( tool > 30 && tool < 40 ) // circle
{
var centerx, centery, radius
- if ( tool === Editor.Tool.CircleCenter )
+ if ( tool === Editor.Tool.CircleCorner )
{
- radius = Math.sqrt(deltax * deltax + deltay * deltay)
- centerx = startx
- centery = starty
+ radius = (deltax < deltay ? deltax : deltay) / 2
+ centerx = cornerx + radius
+ centery = cornery - radius
}
- else if ( tool === Editor.Tool.CircleHorizontal )
+ else if ( tool === Editor.Tool.CircleRadius )
{
- radius = deltax / 2
- centerx = startx + (mousex < startx ? -radius : radius)
- centery = starty
+ radius = Math.sqrt(deltax * deltax + deltay * deltay) / 2
+ centerx = (startx + mousex) / 2
+ centery = (starty + mousey) / 2
}
- else if ( tool === Editor.Tool.CircleVertical )
+ else if ( tool === Editor.Tool.CircleCenter )
{
- radius = deltay / 2
+ radius = Math.sqrt(deltax * deltax + deltay * deltay)
centerx = startx
- centery = starty + (mousey < starty ? -radius : radius)
- }
- else if ( tool === Editor.Tool.CircleCorner )
- {
- radius = (deltax < deltay ? deltax : deltay) / 2
- centerx = cornerx + radius
- centery = cornery - radius
+ centery = starty
}
if ( radius )
{
diff --git a/MenuTool.qml b/MenuTool.qml
new file mode 100644
index 0000000..9f418a8
--- /dev/null
+++ b/MenuTool.qml
@@ -0,0 +1,15 @@
+import QtQuick 2.9
+import QtQuick.Controls 1.4
+
+MenuItem
+{
+ property int tool: 0
+
+ checkable : true
+ checked: (window.tool === tool)
+ onTriggered:
+ {
+ if ( tool )
+ window.tool = tool
+ }
+}
diff --git a/image/circle_horizontal.png b/image/circle_horizontal.png
deleted file mode 100644
index 9ff2c15..0000000
--- a/image/circle_horizontal.png
+++ /dev/null
Binary files differ
diff --git a/image/circle_radius.png b/image/circle_radius.png
new file mode 100644
index 0000000..73169c7
--- /dev/null
+++ b/image/circle_radius.png
Binary files differ
diff --git a/image/circle_vertical.png b/image/circle_vertical.png
deleted file mode 100644
index 38b6be8..0000000
--- a/image/circle_vertical.png
+++ /dev/null
Binary files differ
diff --git a/image/cursor_arrow_icon&48.png b/image/cursor_arrow_icon&48.png
new file mode 100644
index 0000000..83fcad8
--- /dev/null
+++ b/image/cursor_arrow_icon&48.png
Binary files differ
diff --git a/main.qml b/main.qml
index 8b0a5fe..0e1c715 100644
--- a/main.qml
+++ b/main.qml
@@ -9,7 +9,7 @@ ApplicationWindow
property bool fillitem: false
property int alignment: 1
- property real linewidth: 1.2
+ property real linewidth: 1
property int snapgrid: 1
property int tool: 0
@@ -22,24 +22,8 @@ ApplicationWindow
Menu
{
title: qsTr("File") //%%
- MenuItem
- {
- text: qsTr("Open") //%%
- shortcut: "Ctrl+O"
- onTriggered:
- {
- //##
- }
- }
- MenuItem
- {
- text: qsTr("Save") //%%
- shortcut: "Ctrl+S"
- onTriggered:
- {
- //##
- }
- }
+ MenuItem { text: qsTr("Open"); shortcut: "Ctrl+O"; onTriggered: open() } //%%
+ MenuItem { text: qsTr("Save"); shortcut: "Ctrl+S"; onTriggered: save() } //%%
MenuSeparator { }
MenuItem
{
@@ -54,165 +38,39 @@ ApplicationWindow
onTriggered: { manager.writeClipboard() }
}
MenuSeparator { }
- MenuItem
- {
- text: qsTr("Exit") //%%
- shortcut: "F4"
- onTriggered: { Qt.quit() }
- }
+ MenuItem { text: qsTr("Exit"); shortcut: "F4"; onTriggered: Qt.quit() } //%%
}
Menu
{
title: qsTr("Edit") //%%
- MenuItem
- {
- text: qsTr("Cut") //%%
- shortcut: "Ctrl+X"
- onTriggered:
- {
- //##
- }
- }
- MenuItem
- {
- text: qsTr("Copy") //%%
- shortcut: "Ctrl+C"
- onTriggered:
- {
- //##
- }
- }
- MenuItem
- {
- text: qsTr("Paste") //%%
- shortcut: "Ctrl+V"
- onTriggered:
- {
- //##
- }
- }
+ MenuItem { text: qsTr("Cut"); shortcut: "Ctrl+X"; onTriggered: cut() } //%%
+ MenuItem { text: qsTr("Copy"); shortcut: "Ctrl+C"; onTriggered: copy() } //%%
+ MenuItem { text: qsTr("Paste"); shortcut: "Ctrl+V"; onTriggered: paste() } //%%
MenuSeparator { }
- MenuItem
- {
- text: qsTr("Up") //%%
- shortcut: "Alt+Up"
- onTriggered:
- {
- //##
- }
- }
- MenuItem
- {
- text: qsTr("Down") //%%
- shortcut: "Alt+Down"
- onTriggered:
- {
- //##
- }
- }
+ MenuItem { text: qsTr("Raise"); shortcut: "Alt+Up"; onTriggered: raise() } //%%
+ MenuItem { text: qsTr("Lower"); shortcut: "Alt+Down"; onTriggered: lower() } //%%
MenuSeparator { }
- MenuItem
- {
- text: qsTr("Delete") //%%
- shortcut: "Delete"
- onTriggered:
- {
- //##
- }
- }
+ MenuItem { text: qsTr("Delete"); shortcut: "Delete"; onTriggered: remove() } //%%
}
Menu
{
title: qsTr("Tool") //%%
- MenuItem
- {
- text: qsTr("Select") //%%
- checkable : true
- checked: (tool === Editor.Tool.Select)
- onTriggered: { tool = Editor.Tool.Select }
- }
+ MenuTool { text: qsTr("Select"); tool: Editor.Tool.Select } //%%
MenuSeparator { }
- MenuItem
- {
- text: qsTr("Line") //%%
- checkable : true
- checked: (tool === Editor.Tool.LineSingle)
- onTriggered: { tool = Editor.Tool.LineSingle }
- }
- MenuItem
- {
- text: qsTr("Polyline") //%%
- checkable : true
- checked: (tool === Editor.Tool.LinePoly)
- onTriggered: { tool = Editor.Tool.LinePoly }
- }
+ MenuTool { text: qsTr("Line"); tool: Editor.Tool.LineSingle } //%%
+ MenuTool { text: qsTr("Polyline"); tool: Editor.Tool.LinePoly } //%%
MenuSeparator { }
- MenuItem
- {
- text: qsTr("Rectangle Corner") //%%
- checkable : true
- checked: (tool === Editor.Tool.RectangleCorner)
- onTriggered: { tool = Editor.Tool.RectangleCorner }
- }
- MenuItem
- {
- text: qsTr("Rectangle Center") //%%
- checkable : true
- checked: (tool === Editor.Tool.RectangleCenter)
- onTriggered: { tool = Editor.Tool.RectangleCenter }
- }
+ MenuTool { text: qsTr("Rectangle Corner"); tool: Editor.Tool.RectangleCorner } //%%
+ MenuTool { text: qsTr("Rectangle Center"); tool: Editor.Tool.RectangleCenter } //%%
MenuSeparator { }
- MenuItem
- {
- text: qsTr("Circle Corner") //%%
- checkable : true
- checked: (tool === Editor.Tool.CircleCorner)
- onTriggered: { tool = Editor.Tool.CircleCorner }
- }
- MenuItem
- {
- text: qsTr("Circle Center") //%%
- checkable : true
- checked: (tool === Editor.Tool.CircleCenter)
- onTriggered: { tool = Editor.Tool.CircleCenter }
- }
- MenuItem
- {
- text: qsTr("Circle Horizontal") //%%
- checkable : true
- checked: (tool === Editor.Tool.CircleHorizontal)
- onTriggered: { tool = Editor.Tool.CircleHorizontal }
- }
- MenuItem
- {
- text: qsTr("Circle Vertical") //%%
- checkable : true
- checked: (tool === Editor.Tool.CircleVertical)
- onTriggered: { tool = Editor.Tool.CircleVertical }
- }
+ MenuTool { text: qsTr("Circle Corner"); tool: Editor.Tool.CircleCorner } //%%
+ MenuTool { text: qsTr("Circle Radius"); tool: Editor.Tool.CircleRadius } //%%
+ MenuTool { text: qsTr("Circle Center"); tool: Editor.Tool.CircleCenter } //%%
MenuSeparator { }
- MenuItem
- {
- text: qsTr("Semicircle") //%%
- checkable : true
- checked: (tool === Editor.Tool.ArcSemicircle)
- onTriggered: { tool = Editor.Tool.ArcSemicircle }
- }
- MenuItem
- {
- text: qsTr("Quarter circle") //%%
- checkable : true
- checked: (tool === Editor.Tool.ArcQuarter)
- onTriggered: { tool = Editor.Tool.ArcQuarter }
- }
+ MenuTool { text: qsTr("Semicircle"); tool: Editor.Tool.ArcSemicircle } //%%
+ MenuTool { text: qsTr("Quarter circle"); tool: Editor.Tool.ArcQuarter } //%%
MenuSeparator { }
- MenuItem
- {
- text: qsTr("Text") //%%
- checkable : true
- checked: (tool === Editor.Tool.Text)
- onTriggered: { tool = Editor.Tool.Text }
- }
+ MenuTool { text: qsTr("Text"); tool: Editor.Tool.Text } //%%
}
Menu
{
@@ -221,19 +79,13 @@ ApplicationWindow
{
text: qsTr("Help") //%%
shortcut: "F1"
- onTriggered:
- {
- //##
- }
+ onTriggered: { help() }
}
MenuSeparator { }
MenuItem
{
text: qsTr("About") //%%
- onTriggered:
- {
- //##
- }
+ onTriggered: { about() }
}
}
}
@@ -245,124 +97,29 @@ ApplicationWindow
RowLayout
{
height: 32
- ToolButton
- {
- implicitHeight: 32; implicitWidth: 32
- Image
- {
- source: "image/folder_open_icon&48.png"
- anchors { fill: parent; margins: 4 }
- }
- onClicked:
- {
-
- }
- }
- ToolButton
- {
- implicitHeight: 32; implicitWidth: 32
- Image
- {
- source: "image/save_icon&48.png"
- anchors { fill: parent; margins: 4 }
- }
- onClicked:
- {
-
- }
- }
- ToolButton { implicitWidth: 8 }
- ToolButton
- {
- implicitHeight: 32; implicitWidth: 32
- Image
- {
- source: "image/clipboard_cut_icon&48.png"
- anchors { fill: parent; margins: 4 }
- }
- onClicked:
- {
-
- }
- }
- ToolButton
- {
- implicitHeight: 32; implicitWidth: 32
- Image
- {
- source: "image/clipboard_copy_icon&48.png"
- anchors { fill: parent; margins: 4 }
- }
- onClicked:
- {
-
- }
- }
- ToolButton
- {
- implicitHeight: 32; implicitWidth: 32
- Image
- {
- source: "image/clipboard_past_icon&48.png"
- anchors { fill: parent; margins: 4 }
- }
- onClicked:
- {
-
- }
- }
- ToolButton
- {
- implicitHeight: 32; implicitWidth: 32
- Image
- {
- source: "image/br_up_icon&48.png"
- anchors { fill: parent; margins: 4 }
- }
- onClicked:
- {
-
- }
- }
- ToolButton
- {
- implicitHeight: 32; implicitWidth: 32
- Image
- {
- source: "image/br_down_icon&48.png"
- anchors { fill: parent; margins: 4 }
- }
- onClicked:
- {
-
- }
- }
- ToolButton
- {
- implicitHeight: 32; implicitWidth: 32
- Image
- {
- source: "image/delete.png"
- anchors { fill: parent; margins: 4 }
- }
- onClicked:
- {
-
- }
- }
- Separator { }
- Tool { tool: Editor.Tool.LineSingle; image: "image/line_single.png" }
- Tool { tool: Editor.Tool.LinePoly; image: "image/line_poly.png" }
- Separator { }
- Tool { tool: Editor.Tool.RectangleCorner; image: "image/rectangle_corner.png" }
- Tool { tool: Editor.Tool.RectangleCenter; image: "image/rectangle_center.png" }
- Separator { }
- Tool { tool: Editor.Tool.CircleCorner; image: "image/circle_corner.png" }
- Tool { tool: Editor.Tool.CircleCenter; image: "image/circle_center.png" }
- Tool { tool: Editor.Tool.CircleHorizontal; image: "image/circle_horizontal.png" }
- Tool { tool: Editor.Tool.CircleVertical; image: "image/circle_vertical.png" }
- Separator { }
- Tool { tool: Editor.Tool.Text; image: "image/text.png" }
+ BarTool { image: "image/folder_open_icon&48.png"; onClicked: open() }
+ BarTool { image: "image/save_icon&48.png"; onClicked: save() }
+ BarSeparator { }
+ BarTool { image: "image/clipboard_cut_icon&48.png"; onClicked: cut() }
+ BarTool { image: "image/clipboard_copy_icon&48.png"; onClicked: copy() }
+ BarTool { image: "image/clipboard_past_icon&48.png"; onClicked: paste() }
+ BarTool { image: "image/br_up_icon&48.png"; onClicked: raise() }
+ BarTool { image: "image/br_down_icon&48.png"; onClicked: lower() }
+ BarTool { image: "image/delete.png"; onClicked: remove() }
+ BarSeparator { }
+ BarTool { image: "image/cursor_arrow_icon&48.png"; tool: Editor.Tool.Select }
+ BarSeparator { }
+ BarTool { image: "image/line_single.png"; tool: Editor.Tool.LineSingle }
+ BarTool { image: "image/line_poly.png"; tool: Editor.Tool.LinePoly }
+ BarSeparator { }
+ BarTool { image: "image/rectangle_corner.png"; tool: Editor.Tool.RectangleCorner }
+ BarTool { image: "image/rectangle_center.png"; tool: Editor.Tool.RectangleCenter }
+ BarSeparator { }
+ BarTool { image: "image/circle_corner.png"; tool: Editor.Tool.CircleCorner }
+ BarTool { image: "image/circle_radius.png"; tool: Editor.Tool.CircleRadius }
+ BarTool { image: "image/circle_center.png"; tool: Editor.Tool.CircleCenter }
+ BarSeparator { }
+ BarTool { image: "image/text.png"; tool: Editor.Tool.Text }
}
RowLayout
{
@@ -375,7 +132,7 @@ ApplicationWindow
text: qsTr("Fill") //%%
onClicked: { fillitem = !fillitem }
}
- Separator { }
+ BarSeparator { }
Label { text: qsTr("Snap") } //%%
ComboBox
{
@@ -396,53 +153,23 @@ ApplicationWindow
else { currentIndex = 2 } // default 5
}
}
- Separator { }
+ BarSeparator { }
Label { text: qsTr("Line width") } //%%
ComboBox
{
id: widthlist
- model: [ 1, 2 ]
-/*
- onCurrentIndexChanged:
- {
- if ( currentIndex == 0 ) { snap = 1 }
- else if ( currentIndex == 1 ) { snap = 2 }
- else if ( currentIndex == 2 ) { snap = 5 }
- else if ( currentIndex == 3 ) { snap = 10 }
- }
- function setSnap()
- {
- if ( snap == 1 ) { currentIndex = 0 }
- else if ( snap == 2 ) { currentIndex = 1 }
- else if ( snap == 10 ) { currentIndex = 3 }
- else { currentIndex = 2 } // default 5
- }
-*/
+ model: [ 1, 2, 3, 4, 5 ]
+ onCurrentIndexChanged: { linewidth = currentIndex + 1 }
+ function setWidth() { currentIndex = linewidth - 1 }
}
- Separator { }
+ BarSeparator { }
Label { text: qsTr("Alignment") } //%%
ComboBox
{
id: alignlist
model: [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
- onCurrentIndexChanged:
- {
-/*
- if ( currentIndex == 0 ) { snap = 1 }
- else if ( currentIndex == 1 ) { snap = 2 }
- else if ( currentIndex == 2 ) { snap = 5 }
- else if ( currentIndex == 3 ) { snap = 10 }
-*/
- }
- function setAlign()
- {
-/*
- if ( snap == 1 ) { currentIndex = 0 }
- else if ( snap == 2 ) { currentIndex = 1 }
- else if ( snap == 10 ) { currentIndex = 3 }
- else { currentIndex = 2 } // default 5
-*/
- }
+ onCurrentIndexChanged: { alignment = currentIndex + 1 }
+ function setAlign() { currentIndex = alignment - 1 }
}
}
}
@@ -469,7 +196,7 @@ ApplicationWindow
onFillitemChanged: { manager.setFillItem(fillitem); }
onAlignmentChanged: { manager.setAlignment(alignment); }
- onLinewidthChanged: { manager.setLineWidth(linewidth * 10); }
+ onLinewidthChanged: { manager.setLineWidth(linewidth); }
onSnapgridChanged: { manager.setSnapGrid(snapgrid); }
onToolChanged: { manager.setTool(tool); }
@@ -482,14 +209,65 @@ ApplicationWindow
fillitem = manager.getFillItem()
alignment = manager.getAlignment()
- linewidth = manager.getLineWidth() / 10
+ linewidth = manager.getLineWidth()
snapgrid = manager.getSnapGrid()
tool = manager.getTool()
- alignlist.setAlign()
snaplist.setSnap()
+ widthlist.setWidth()
+ alignlist.setAlign()
visible = true
manager.setInitialized()
}
+
+ function open()
+ {
+
+ }
+
+ function save()
+ {
+
+ }
+
+ function cut()
+ {
+
+ }
+
+ function copy()
+ {
+
+ }
+
+ function paste()
+ {
+
+ }
+
+ function raise()
+ {
+
+ }
+
+ function lower()
+ {
+
+ }
+
+ function remove()
+ {
+
+ }
+
+ function help()
+ {
+
+ }
+
+ function about()
+ {
+
+ }
}
diff --git a/qml.qrc b/qml.qrc
index 657071b..7ec1847 100644
--- a/qml.qrc
+++ b/qml.qrc
@@ -1,14 +1,15 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
- <file>Tool.qml</file>
+ <file>MenuTool.qml</file>
+ <file>BarSeparator.qml</file>
+ <file>BarTool.qml</file>
<file>Editor.qml</file>
<file>image/rectangle_center.png</file>
<file>image/rectangle_corner.png</file>
<file>image/circle_corner.png</file>
- <file>image/circle_center.png</file>
- <file>image/circle_horizontal.png</file>
- <file>image/circle_vertical.png</file>
+ <file>image/circle_radius.png</file>
+ <file>image/circle_center.png</file>
<file>image/line_single.png</file>
<file>image/line_poly.png</file>
<file>image/clipboard_copy_icon&amp;48.png</file>
@@ -20,6 +21,6 @@
<file>image/br_up_icon&amp;48.png</file>
<file>image/text.png</file>
<file>image/delete.png</file>
- <file>Separator.qml</file>
+ <file>image/cursor_arrow_icon&amp;48.png</file>
</qresource>
</RCC>