-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.qml
88 lines (76 loc) · 2.07 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
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import CropTool
ApplicationWindow {
id: root
title: qsTr("Crop Tool")
width: 1920
height: 1080
visible: true
Material.theme: Material.Dark
Material.accent: Material.Orange
ColumnLayout {
anchors.fill: parent
RowLayout {
Layout.fillWidth: true
ToolButton {
text: "Crop"
checkable: true
onCheckedChanged: {
if (image1.selection) {
image1.selection.destroy()
}
image1.selection = cropComponent.createObject(image1, {
"anchors.fill": image1,
"focus": true
})
}
}
ComboBox {
id: combo
Layout.preferredWidth: 150
textRole: "text"
valueRole: "value"
model: ListModel {
id: model
ListElement {
text: "Rule of Third"
value: 0
}
ListElement {
text: "Diagonal"
value: 1
}
ListElement {
text: "Golden Ratio"
value: 2
}
}
}
}
Item {
Layout.fillWidth: true
Layout.fillHeight: true
Image {
id: image1
property var selection: undefined
property real windowAspect: parent.width / parent.height
property real aspect: sourceSize.width / sourceSize.height
property bool horizontal: windowAspect >= aspect
anchors.centerIn: parent
mipmap: true
width: horizontal ? parent.height * aspect : parent.width
height: horizontal ? parent.height : parent.width / aspect
source: "https://images.unsplash.com/photo-1457301353672-324d6d14f471?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2070&q=80"
}
}
}
Component {
id: cropComponent
CropTool {
focus: true
compositeGuideType: combo.currentValue
}
}
}