blob: dd01e4f0254702ca2d381d8545dbf76c71791ce0 (
plain)
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick.Effects
import QtQuick.Controls.Basic
Item {
id: rootItem
property bool show: true
property real showAnimation: show ? 1 : 0
width: settings.settingsViewWidth
x: -(width + 30) * (1 - showAnimation) + 20
function resetPosition() {
let lw = lightMouseArea.width
let lh = lightMouseArea.height
let sizeValue = sizeSlider.value - sizeSlider.from;
let sizeRange = sizeSlider.to - sizeSlider.from;
let lightX = lw * 0.4 - lw * 0.2 * (sizeValue) / (sizeRange)
let lightY = lh * 0.4 - lh * 0.2 * (sizeValue) / (sizeRange)
updatePosition(lightX, lightY)
}
function updatePosition(posX, posY) {
let margin = 20;
let halfW = (lightMouseArea.width - margin * 2) * 0.5;
let halfH = (lightMouseArea.height - margin * 2) * 0.5;
posX = Math.max(margin, posX);
posY = Math.max(margin, posY);
posX = Math.min(lightMouseArea.width - margin, posX);
posY = Math.min(lightMouseArea.height - margin, posY);
let dX = (posX - margin - halfW) / (halfW);
let dY = (posY - margin - halfH) / (halfH);
settings.offsetX = dX * 30;
settings.offsetY = dY * 30;
lightItem.x = posX;
lightItem.y = posY;
}
Behavior on showAnimation {
NumberAnimation {
duration: 400
easing.type: Easing.InOutQuad
}
}
// Open/close button
Item {
width: 30 * dp
height: 30 * dp
anchors.left: parent.right
anchors.leftMargin: 20
anchors.top: parent.top
anchors.topMargin: -10
Rectangle {
anchors.fill: parent
color: Qt.lighter(mainWindow.mainColor, 0.8)
radius: 4
}
Image {
anchors.centerIn: parent
source: "images/arrow.png"
rotation: rootItem.showAnimation * 180
}
MouseArea {
anchors.fill: parent
anchors.margins: -30 * dp
onClicked: {
rootItem.show = !rootItem.show;
}
}
}
// Background
Rectangle {
anchors.fill: scrollView
opacity: showAnimation ? 1 : 0
visible: opacity
anchors.margins: -10
color: Qt.lighter(mainWindow.mainColor, 0.15)
radius: 4
}
ScrollView {
id: scrollView
anchors.fill: parent
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
ScrollBar.vertical.interactive: false
clip: true
Column {
id: settingsArea
anchors.fill: parent
opacity: showAnimation
visible: opacity
spacing: 10 * dp
SettingsComponentSlider {
id: sizeSlider
text: qsTr("Size") + ": " + value.toFixed()
value: settings.itemSize
from: 100
to: 300
onMoved: {
settings.itemSize = value
settings.radius = Math.min(settings.radius, radiusSlider.to)
settings.spread = Math.min(settings.spread, spreadSlider.to)
settings.spread = Math.max(settings.spread, spreadSlider.from)
settings.blur = value * 0.2
resetPosition();
}
}
SettingsComponentSlider {
id: radiusSlider
text: qsTr("Radius") + ": " + value.toFixed()
value: settings.radius
from: 0
to: settings.itemSize * 0.5
onMoved: {
settings.radius = value
}
}
SettingsComponentCheckBox {
id: individualRadiusCheckBox
text: qsTr("Individual corner radius")
checked: settings.individualRadius
onCheckedChanged: {
settings.individualRadius = checked;
}
}
SettingsComponentSlider {
id: radiusTRSlider
text: qsTr("Radius Top-Right") + ": " + value.toFixed()
enabled: individualRadiusCheckBox.checked
value: settings.radiustr
from: 0
to: settings.itemSize * 0.5
onMoved: {
settings.radiustr = value
}
}
SettingsComponentSlider {
id: radiusBRSlider
text: qsTr("Radius Bottom-Right") + ": " + value.toFixed()
enabled: individualRadiusCheckBox.checked
value: settings.radiusbr
from: 0
to: settings.itemSize * 0.5
onMoved: {
settings.radiusbr = value
}
}
SettingsComponentSlider {
id: radiusBLSlider
text: qsTr("Radius Bottom-Left") + ": " + value.toFixed()
enabled: individualRadiusCheckBox.checked
value: settings.radiusbl
from: 0
to: settings.itemSize * 0.5
onMoved: {
settings.radiusbl = value
}
}
SettingsComponentSlider {
id: radiusTLSlider
text: qsTr("Radius Top-Left") + ": " + value.toFixed()
enabled: individualRadiusCheckBox.checked
value: settings.radiustl
from: 0
to: settings.itemSize * 0.5
onMoved: {
settings.radiustl = value
}
}
SettingsComponentSlider {
text: qsTr("Blur") + ": " + value.toFixed()
value: settings.blur
from: 0
to: 100
onMoved: {
settings.blur = value;
}
}
SettingsComponentSlider {
text: qsTr("Opacity") + ": " + value.toFixed(2)
value: settings.opacity
from: 0.0
to: 1.0
onMoved: {
settings.opacity = value;
}
}
SettingsComponentSlider {
id: spreadSlider
text: qsTr("Spread") + ": " + value.toFixed(2)
value: settings.spread
from: -settings.itemSize * 0.1
to: settings.itemSize * 0.1
onMoved: {
settings.spread = value;
}
}
}
}
Row {
anchors.horizontalCenter: scrollView.horizontalCenter
anchors.bottom: resetButton.top
anchors.bottomMargin: 20 * dp
spacing: 20 * dp
SettingsComponentButton {
text: "DEBUG"
checkable: true
checked: settings.showDebug
onCheckedChanged: settings.showDebug = checked
}
SettingsComponentButton {
text: "CUSTOM"
checkable: true
checked: settings.showCustomMaterial
onCheckedChanged: settings.showCustomMaterial = checked
}
}
SettingsComponentButton {
id: resetButton
anchors.horizontalCenter: scrollView.horizontalCenter
anchors.bottom: scrollView.bottom
anchors.bottomMargin: 20 * dp
text: "RESET"
onClicked: settings.resetSettings()
}
}
|