Replace the clean property with a function
This commit is contained in:
parent
57864caac2
commit
8370759608
1 changed files with 16 additions and 17 deletions
|
@ -26,17 +26,15 @@ Page {
|
||||||
property int finishX;
|
property int finishX;
|
||||||
property int finishY;
|
property int finishY;
|
||||||
|
|
||||||
property bool clear: false
|
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
id: menu
|
id: menu
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
spacing: 3
|
||||||
// Workaround: we don't want the Slider animation!
|
// Workaround: we don't want the Slider animation!
|
||||||
height: 95
|
height: 95
|
||||||
spacing: 3
|
|
||||||
|
|
||||||
IconButton {
|
IconButton {
|
||||||
icon.source: "image://theme/icon-camera-focus"
|
icon.source: "image://theme/icon-camera-focus"
|
||||||
|
@ -79,8 +77,7 @@ Page {
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
clear = true;
|
canvas.clear();
|
||||||
canvas.requestPaint();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,6 +96,13 @@ Page {
|
||||||
|
|
||||||
onLineWidthChanged: requestPaint()
|
onLineWidthChanged: requestPaint()
|
||||||
|
|
||||||
|
function clear()
|
||||||
|
{
|
||||||
|
var ctx = getContext("2d");
|
||||||
|
ctx.fillRect(0, 0, width, height);
|
||||||
|
requestPaint();
|
||||||
|
}
|
||||||
|
|
||||||
onPaint: {
|
onPaint: {
|
||||||
var ctx = getContext("2d");
|
var ctx = getContext("2d");
|
||||||
ctx.fillStyle = "#ffffff";
|
ctx.fillStyle = "#ffffff";
|
||||||
|
@ -108,19 +112,14 @@ Page {
|
||||||
ctx.miterLimit = 1;
|
ctx.miterLimit = 1;
|
||||||
ctx.strokeStyle = strokeStyle;
|
ctx.strokeStyle = strokeStyle;
|
||||||
|
|
||||||
if (clear === true) {
|
ctx.beginPath();
|
||||||
ctx.fillRect(0, 0, width, height);
|
ctx.moveTo(startX, startY);
|
||||||
clear = false;
|
ctx.lineTo(finishX, finishY);
|
||||||
} else {
|
ctx.closePath();
|
||||||
ctx.beginPath();
|
ctx.stroke();
|
||||||
ctx.moveTo(startX, startY);
|
|
||||||
ctx.lineTo(finishX, finishY);
|
|
||||||
ctx.closePath();
|
|
||||||
ctx.stroke();
|
|
||||||
|
|
||||||
startX = finishX;
|
startX = finishX;
|
||||||
startY = finishY;
|
startY = finishY;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
|
Loading…
Reference in a new issue