X Max & Y Min settings, redo stack reset option.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Adsooi 2021-08-21 19:46:20 +02:00
parent 21f7ce3133
commit 6b70e6df9e
Signed by: Ad5001
GPG key ID: EF45F9C6AFE20160
10 changed files with 239 additions and 7 deletions

View file

@ -22,6 +22,7 @@ from json import load, dumps
DEFAULT_SETTINGS = { DEFAULT_SETTINGS = {
"check_for_updates": True, "check_for_updates": True,
"reset_redo_stack": True,
"last_install_greet": "0", "last_install_greet": "0",
"lang": "en" "lang": "en"
} }

View file

@ -113,6 +113,15 @@ MenuBar {
onTriggered: Helper.setSettingBool("check_for_updates", checked) onTriggered: Helper.setSettingBool("check_for_updates", checked)
icon.name: 'update' icon.name: 'update'
} }
Action {
id: resetRedoStackMenuSetting
text: qsTr("Reset redo stack automaticly")
checkable: true
checked: Helper.getSettingBool("reset_redo_stack")
onTriggered: Helper.setSettingBool("reset_redo_stack", checked)
icon.name: 'history'
}
} }
Menu { Menu {

View file

@ -97,6 +97,18 @@ Popup {
} }
} }
CheckBox {
id: resetRedoStackSetting
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: checkForUpdatesSetting.bottom
checked: Helper.getSettingBool("reset_redo_stack")
text: 'Reset redo stack when a new action is added to history'
onClicked: {
Helper.setSettingBool("reset_redo_stack", checked)
resetRedoStackMenuSetting.checked = checked
}
}
Button { Button {
text: "Done" text: "Done"
font.pixelSize: 20 font.pixelSize: 20
@ -107,7 +119,7 @@ Popup {
} }
Timer { Timer {
running: Helper.getSetting("last_install_greet") != Helper.getVersion() running: Helper.getSetting("last_install_greet") != Helper.getVersion()+"a"
repeat: false repeat: false
interval: 50 interval: 50
onTriggered: greetingPopup.open() onTriggered: greetingPopup.open()

View file

@ -67,10 +67,12 @@ Item {
console.log("Added new entry to history: " + action.getReadableString()) console.log("Added new entry to history: " + action.getReadableString())
undoStack.push(action) undoStack.push(action)
undoCount++; undoCount++;
if(Helper.getSettingBool("reset_redo_stack")) {
redoStack = [] redoStack = []
redoCount = 0 redoCount = 0
} }
} }
}
function undo() { function undo() {
if(undoStack.length > 0) { if(undoStack.length > 0) {

View file

@ -112,6 +112,7 @@ ApplicationWindow {
Settings { Settings {
id: settings id: settings
canvas: drawCanvas
onChanged: drawCanvas.requestPaint() onChanged: drawCanvas.requestPaint()
} }

View file

@ -26,6 +26,7 @@ ScrollView {
signal changed() signal changed()
property int settingWidth: settings.width - ScrollBar.vertical.width property int settingWidth: settings.width - ScrollBar.vertical.width
property Canvas canvas
property double xzoom: 100 property double xzoom: 100
property double yzoom: 10 property double yzoom: 10
@ -73,7 +74,7 @@ ScrollView {
min: 1 min: 1
icon: "icons/settings/xzoom.svg" icon: "icons/settings/xzoom.svg"
width: settings.settingWidth width: settings.settingWidth
defValue: settings.xzoom value: settings.xzoom.toFixed(2)
onChanged: function(newValue) { onChanged: function(newValue) {
settings.xzoom = newValue settings.xzoom = newValue
settings.changed() settings.changed()
@ -87,7 +88,7 @@ ScrollView {
label: "Y Zoom" label: "Y Zoom"
icon: "icons/settings/yzoom.svg" icon: "icons/settings/yzoom.svg"
width: settings.settingWidth width: settings.settingWidth
defValue: settings.yzoom value: settings.yzoom.toFixed(2)
onChanged: function(newValue) { onChanged: function(newValue) {
settings.yzoom = newValue settings.yzoom = newValue
settings.changed() settings.changed()
@ -105,8 +106,12 @@ ScrollView {
width: settings.settingWidth width: settings.settingWidth
defValue: settings.xmin defValue: settings.xmin
onChanged: function(newValue) { onChanged: function(newValue) {
if(parseFloat(maxX.value) > newValue) {
settings.xmin = newValue settings.xmin = newValue
settings.changed() settings.changed()
} else {
alert.show("Minimum x value must be inferior to maximum.")
}
} }
} }
@ -114,6 +119,7 @@ ScrollView {
id: maxY id: maxY
height: 30 height: 30
isDouble: true isDouble: true
min: -Infinity
label: "Max Y" label: "Max Y"
icon: "icons/settings/ymax.svg" icon: "icons/settings/ymax.svg"
width: settings.settingWidth width: settings.settingWidth
@ -124,6 +130,44 @@ ScrollView {
} }
} }
TextSetting {
id: maxX
height: 30
isDouble: true
min: -Infinity
label: "Max X"
icon: "icons/settings/xmax.svg"
width: settings.settingWidth
value: canvas.px2x(canvas.canvasSize.width).toFixed(2)
onChanged: function(xvaluemax) {
if(xvaluemax > settings.xmin) {
settings.xzoom = settings.xzoom * canvas.canvasSize.width/(canvas.x2px(xvaluemax)) // Adjusting zoom to fit. = (end)/(px of current point)
settings.changed()
} else {
alert.show("Maximum x value must be superior to minimum.")
}
}
}
TextSetting {
id: minY
height: 30
isDouble: true
min: -Infinity
label: "Min Y"
icon: "icons/settings/ymin.svg"
width: settings.settingWidth
defValue: canvas.px2y(canvas.canvasSize.height).toFixed(2)
onChanged: function(yvaluemin) {
if(yvaluemin < settings.ymax) {
settings.yzoom = settings.yzoom * canvas.canvasSize.height/(canvas.y2px(yvaluemin)) // Adjusting zoom to fit. = (end)/(px of current point)
settings.changed()
} else {
alert.show("Minimum y value must be inferior to maximum.")
}
}
}
TextSetting { TextSetting {
id: xAxisStep id: xAxisStep
height: 30 height: 30

View file

@ -30,6 +30,7 @@ Item {
property double min: -1 property double min: -1
property string label property string label
property string defValue property string defValue
property alias value: input.text
property string icon: "" property string icon: ""
Icon { Icon {

View file

@ -0,0 +1 @@
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd"><path d="M5.829 21c-.412 1.165-1.524 2-2.829 2-1.656 0-3-1.344-3-3s1.344-3 3-3c1.305 0 2.417.835 2.829 2h3.342c.412-1.165 1.524-2 2.829-2 1.305 0 2.417.835 2.829 2h3.342c.412-1.165 1.524-2 2.829-2 1.656 0 3 1.344 3 3s-1.344 3-3 3c-1.305 0-2.417-.835-2.829-2h-3.342c-.412 1.165-1.524 2-2.829 2-1.305 0-2.417-.835-2.829-2h-3.342zm6.171-2c.552 0 1 .448 1 1s-.448 1-1 1-1-.448-1-1 .448-1 1-1zm0-18c-2.624 0-5 2.127-5 4.751 0 2.624 2.168 5.756 5 10.249 2.832-4.493 5-7.625 5-10.249 0-2.624-2.376-4.751-5-4.751zm0 7c-1.105 0-2-.895-2-2s.895-2 2-2 2 .895 2 2-.895 2-2 2z"/></svg>

After

Width:  |  Height:  |  Size: 675 B

View file

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="24.0px"
height="24.0px"
viewBox="0 0 24.0 24.0"
version="1.1"
id="SVGRoot"
sodipodi:docname="xmax.svg"
inkscape:version="1.0.2 (e86c870879, 2021-01-15)">
<defs
id="defs836" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.4"
inkscape:cx="7.9418411"
inkscape:cy="14.202968"
inkscape:document-units="px"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="true"
inkscape:window-width="1920"
inkscape:window-height="1011"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1">
<inkscape:grid
type="xygrid"
id="grid1406" />
</sodipodi:namedview>
<metadata
id="metadata839">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="fill:#000000;fill-rule:evenodd;stroke-width:4.24264"
id="rect1418"
width="2"
height="18"
x="7"
y="3" />
<rect
style="fill:#000000;fill-rule:evenodd;stroke-width:3.65149"
id="rect1420"
width="20"
height="2"
x="2"
y="15" />
<rect
style="fill:#ff0000;fill-rule:evenodd;stroke-width:1.78884"
id="rect1413"
width="1"
height="8"
x="19"
y="12" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="24.0px"
height="24.0px"
viewBox="0 0 24.0 24.0"
version="1.1"
id="SVGRoot"
sodipodi:docname="ymin.svg"
inkscape:version="1.0.2 (e86c870879, 2021-01-15)">
<defs
id="defs836" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.4"
inkscape:cx="7.9418411"
inkscape:cy="14.202968"
inkscape:document-units="px"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="true"
inkscape:window-width="1920"
inkscape:window-height="1011"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1">
<inkscape:grid
type="xygrid"
id="grid1406" />
</sodipodi:namedview>
<metadata
id="metadata839">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="fill:#000000;fill-rule:evenodd;stroke-width:4.24264"
id="rect1418"
width="2"
height="18"
x="7"
y="3" />
<rect
style="fill:#000000;fill-rule:evenodd;stroke-width:3.65149"
id="rect1420"
width="20"
height="2"
x="2"
y="15" />
<rect
style="fill:#ff0000;fill-rule:evenodd;stroke-width:1.78884"
id="rect1413"
width="1"
height="8"
x="19"
y="-12"
transform="rotate(90)" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB