-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.qml
89 lines (79 loc) · 2.3 KB
/
main.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import QtQuick 2.15
import QtQuick.Window 2.15
import Qt.labs.platform 1.1
Window {
property int curImageWidth: 885
property int curImageHeight: 505
height: curImageHeight
width: curImageWidth
visible: true
title: qsTr("ImageViewer")
id: mainwin
property string rgb_str: "null"
Component.onCompleted: {
subwin.show()
}
Image {
id: img
source: "qrc:/startup-image.webp"
fillMode: Image.PreserveAspectFit
anchors.fill: parent
onSourceSizeChanged: {
curImageWidth = sourceSize.width
curImageHeight = sourceSize.height
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: {
if (mouse.button === Qt.LeftButton) {
fileDialog.open()
} else {
if(!image_util.isReady())
return
var pixels_str = image_util.getImagePixelsOfArea(maskwin.x, maskwin.y, maskwin.width, maskwin.height)
rgb_str = pixels_str
// console.log(pixels_str[1])
}
}
HoverHandler {
onHoveredChanged: {
if(hovered) {
cursor.setHoveredCursor(parent)
} else {
cursorShape = Qt.ArrowCursor
}
}
}
onPositionChanged: {
maskwin.x = mouse.x - maskwin.width / 2 - 8
maskwin.y = mouse.y - maskwin.height / 2 + 10
}
}
}
SubWin {
id: subwin
visible: true
x: mainwin.x + mainwin.width
y: mainwin.y
}
FileDialog {
id: fileDialog
folder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
fileMode: FileDialog.OpenFile
nameFilters: ["image files (*.png *.jpg *.tif *.jpeg *.webp)"]
onAccepted: {
// console.log(file)
img.source = file
image_util.setImage(file)
}
}
Rectangle {
id: maskwin
// anchors.centerIn: parent
width: 20
height: 20
color: "#1abc9c";
opacity: 0.3
}
}