Skip to content

Commit 9e430c2

Browse files
committed
Update Setting menu position and color picker. appVersion fixed in main
1 parent 524477d commit 9e430c2

File tree

3 files changed

+203
-175
lines changed

3 files changed

+203
-175
lines changed

qml/Settings.qml

Lines changed: 120 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import QtQuick 2.15
22
import QtQuick.Controls 2.15
33
import QtQuick.Layouts 1.15
44
import QtQuick.Window 2.15
5+
import QtQuick.Dialogs
56
import QtCore
67

78
ApplicationWindow {
89
id: settingsWindow
910

1011
// Set width and height based on content's implicit size plus margins
11-
width: settingsLayout.implicitWidth + 2 * settingsLayoutLeftRightMargin
12+
width: settingsLayout.implicitWidth + 10 * settingsLayoutLeftRightMargin
1213
height: settingsLayout.implicitHeight + 2 * settingsLayoutTopBottomMargin
1314

1415
title: "Settings"
@@ -21,7 +22,7 @@ ApplicationWindow {
2122

2223
property var mainWindow: null
2324

24-
// --- Signals and Properties ---
25+
// Signals and Properties
2526
property int initialFontSize: 11
2627
property bool showIcon: true
2728
property bool screenontop: true
@@ -33,7 +34,6 @@ ApplicationWindow {
3334
signal screenontopset(bool ontop)
3435

3536
// The 'platformName' property is now provided by C++ via setContextProperty
36-
// property string platformName: "default" // Removed this line, as it's a context property
3737

3838
// Hidden TextEdit for clipboard operations
3939
TextEdit {
@@ -42,12 +42,11 @@ ApplicationWindow {
4242
text: ""
4343
}
4444

45-
// --- Main Layout ---
45+
// Main Layout
4646
ColumnLayout {
4747
id: settingsLayout
4848
anchors.fill: parent
4949
anchors.margins: settingsLayoutLeftRightMargin
50-
spacing: 10
5150

5251
Label {
5352
text: "Font Size"
@@ -71,78 +70,131 @@ ApplicationWindow {
7170
Layout.alignment: Qt.AlignHCenter
7271
}
7372

74-
GridLayout {
73+
// Color picker
74+
Item {
75+
id: customColorPicker
76+
width: 250
77+
height: 150
7578
Layout.alignment: Qt.AlignHCenter
76-
columns: 4
77-
columnSpacing: 15
78-
rowSpacing: 15
79-
80-
Repeater {
81-
model: [
82-
{ name: "Green", colorValue: "lightgreen" },
83-
{ name: "Cyan", colorValue: "cyan" },
84-
{ name: "Yellow", colorValue: "yellow" },
85-
{ name: "White", colorValue: "white" },
86-
{ name: "Orange", colorValue: "orange" },
87-
{ name: "Magenta", colorValue: "magenta" },
88-
{ name: "Red", colorValue: "red" },
89-
{ name: "Gray", colorValue: "gray" },
90-
{ name: "Teal", colorValue: "teal" },
91-
{ name: "Black", colorValue: "black" },
92-
{ name: "Blue", colorValue: "blue" },
93-
{ name: "Light Blue", colorValue: "lightblue" }
94-
]
95-
delegate: Rectangle {
96-
id: colorBox
97-
width: 40
98-
height: 40
99-
color: modelData.colorValue
100-
radius: 4
101-
border.color: "#444"
102-
border.width: 1
103-
104-
// Custom Popup for tooltip
105-
Popup {
106-
id: customToolTip
107-
// Position the popup relative to the mouse area's center
108-
x: mouseArea.mouseX + 10 // Offset from mouse cursor
109-
y: mouseArea.mouseY + 10 // Offset from mouse cursor
110-
//parent: settingsWindow // Or a more appropriate common parent
111-
visible: mouseArea.containsMouse
112-
modal: false // Don't block interaction with other elements
113-
closePolicy: Popup.NoAutoClose // We control visibility with mouseArea.containsMouse
114-
opacity: 0.9 // Make it slightly transparent
115-
padding: 5
116-
background: Rectangle {
117-
color: "#222"
118-
radius: 3
119-
border.color: "#888"
120-
border.width: 1
79+
80+
property color selectedColor: appSettings.value("fontColor", "white")
81+
property real currentHue: selectedColor.hsvHue >= 0 ? selectedColor.hsvHue : 0
82+
property real currentSaturation: selectedColor.hsvSaturation
83+
property real currentValue: selectedColor.hsvValue
84+
property bool isInitialized: false
85+
86+
Component.onCompleted: {
87+
isInitialized = true;
88+
}
89+
90+
onCurrentHueChanged: updateColor()
91+
onCurrentSaturationChanged: updateColor()
92+
onCurrentValueChanged: updateColor()
93+
94+
onSelectedColorChanged: {
95+
currentHue = selectedColor.hsvHue >= 0 ? selectedColor.hsvHue : 0;
96+
currentSaturation = selectedColor.hsvSaturation;
97+
currentValue = selectedColor.hsvValue;
98+
99+
if (isInitialized) {
100+
fontColorChanged(selectedColor);
101+
}
102+
}
103+
104+
function updateColor() {
105+
var newColor = Qt.hsva(currentHue, currentSaturation, currentValue, 1.0);
106+
if (newColor.toString() !== selectedColor.toString()) {
107+
selectedColor = newColor;
108+
}
109+
}
110+
111+
RowLayout {
112+
anchors.fill: parent
113+
spacing: 10
114+
width: 250
115+
height: 180
116+
117+
Rectangle {
118+
id: svArea
119+
Layout.fillWidth: true
120+
Layout.fillHeight: true
121+
color: Qt.hsva(customColorPicker.currentHue, 1.0, 1.0, 1.0)
122+
123+
Rectangle {
124+
anchors.fill: parent
125+
gradient: Gradient {
126+
GradientStop { position: 0.0; color: "white" }
127+
GradientStop { position: 1.0; color: "transparent" }
121128
}
122-
contentItem: Label {
123-
text: modelData.name
124-
color: "white"
125-
font.pointSize: 10
126-
horizontalAlignment: Text.AlignHCenter
127-
verticalAlignment: Text.AlignVCenter
129+
}
130+
Rectangle {
131+
anchors.fill: parent
132+
gradient: Gradient {
133+
orientation: Gradient.Vertical
134+
GradientStop { position: 0.0; color: "transparent" }
135+
GradientStop { position: 1.0; color: "black" }
128136
}
129-
130-
// Ensure the popup's implicit size is respected
131-
implicitWidth: contentItem.implicitWidth + 2 * padding
132-
implicitHeight: contentItem.implicitHeight + 2 * padding
133137
}
138+
Rectangle {
139+
id: svIndicator
140+
x: svArea.width * customColorPicker.currentSaturation - (width / 2)
141+
y: svArea.height * (1.0 - customColorPicker.currentValue) - (height / 2)
142+
width: 12
143+
height: 12
144+
radius: 6
145+
color: "transparent"
146+
border.color: customColorPicker.currentValue > 0.5 ? "black" : "white"
147+
border.width: 2
148+
}
149+
MouseArea {
150+
anchors.fill: parent
151+
onPressed: (mouse) => updateSV(mouse.x, mouse.y)
152+
onPositionChanged: (mouse) => { if (pressed) updateSV(mouse.x, mouse.y) }
134153

154+
function updateSV(mx, my) {
155+
customColorPicker.currentSaturation = Math.max(0, Math.min(1, mx / svArea.width));
156+
customColorPicker.currentValue = 1.0 - Math.max(0, Math.min(1, my / svArea.height));
157+
}
158+
}
159+
}
135160

161+
Rectangle {
162+
id: hueSlider
163+
Layout.preferredWidth: 25
164+
Layout.fillHeight: true
165+
radius: 4
166+
gradient: Gradient {
167+
orientation: Gradient.Vertical
168+
GradientStop { position: 0.0; color: "#ff0000" }
169+
GradientStop { position: 0.166; color: "#ffff00" }
170+
GradientStop { position: 0.333; color: "#00ff00" }
171+
GradientStop { position: 0.5; color: "#00ffff" }
172+
GradientStop { position: 0.666; color: "#0000ff" }
173+
GradientStop { position: 0.833; color: "#ff00ff" }
174+
GradientStop { position: 1.0; color: "#ff0000" }
175+
}
176+
Rectangle {
177+
width: parent.width + 4
178+
height: 4
179+
x: -2
180+
y: hueSlider.height * customColorPicker.currentHue - (height / 2)
181+
color: "white"
182+
border.color: "black"
183+
}
136184
MouseArea {
137-
id: mouseArea
138185
anchors.fill: parent
139-
hoverEnabled: true
140-
onClicked: fontColorChanged(modelData.colorValue)
186+
onPressed: (mouse) => updateHue(mouse.y)
187+
onPositionChanged: (mouse) => { if (pressed) updateHue(mouse.y) }
188+
189+
function updateHue(my) {
190+
customColorPicker.currentHue = Math.max(0, Math.min(1, my / hueSlider.height));
191+
}
141192
}
142193
}
143194
}
144195
}
145196

197+
146198
Item { Layout.fillHeight: true }
147199

148200
Label {
@@ -203,7 +255,7 @@ ApplicationWindow {
203255
}
204256
}
205257

206-
// --- Autostart Button ---
258+
// Autostart Button
207259
Button {
208260
id: autostartButton
209261
Layout.fillWidth: true
@@ -222,7 +274,7 @@ ApplicationWindow {
222274
}
223275
}
224276

225-
// --- New Calendar Button (visible only on Wayland) ---
277+
// New Calendar Button (visible only on Wayland)
226278
Button {
227279
id: calendarButton
228280
Layout.fillWidth: true
@@ -267,7 +319,7 @@ ApplicationWindow {
267319
}
268320
}
269321

270-
// --- Declarative Timer for Copy Message ---
322+
// Declarative Timer for Copy Message
271323
Timer {
272324
id: resetTimer
273325
interval: 1500
@@ -324,7 +376,7 @@ ApplicationWindow {
324376
}
325377

326378

327-
// --- Window Closing Handler ---
379+
// Window Closing Handler
328380
onClosing: {
329381
resetTimer.stop();
330382
destroy();

qml/main.qml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ ApplicationWindow {
4141
property bool isDarkMode: false
4242
property bool debugVisible: false
4343
property string currentDebugInfo: ""
44-
property string appVersion: "1.0.0"
4544
property bool isPrintMode: false
4645

4746
QtObject {

0 commit comments

Comments
 (0)