Files
glassMxrph/quickshell/components/GlassColorPicker.qml
T
mxandClaude Opus 5.5 99e64a7713 Add glassMxrph shell sources
Initial commit of the Quickshell desktop suite: bar, dock, launcher,
settings, Control Center, dashboard, OSD, lock screen, desktop widgets,
plugin host with the vendored Noctalia/Omarchy compatibility layer,
helpers, packaging, tests and phase documentation.

Includes the optimization work so far: usage widgets and dashboard
gauges no longer animate continuously, desktop widgets pause while
covered, system controls stop flickering on background polls, dock app
matching uses an indexed catalog, and workspace ghosts are created only
for occupied slots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 22:36:17 +02:00

134 lines
3.9 KiB
QML

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import "../theme"
ColumnLayout {
id: root
property color selectedColor: Theme.accent
property real hue: 0
property real saturation: 1
property real brightness: 1
signal chosen(color color)
function sync() {
if (selectedColor.hsvHue >= 0)
hue = selectedColor.hsvHue;
saturation = selectedColor.hsvSaturation;
brightness = selectedColor.hsvValue;
}
function commit() {
chosen(Qt.hsva(hue, saturation, brightness, 1));
}
onSelectedColorChanged: sync()
Component.onCompleted: sync()
Rectangle {
id: field
objectName: "colorSaturationValue"
Layout.fillWidth: true
Layout.preferredHeight: 150
color: Qt.hsva(root.hue, 1, 1, 1)
radius: 8
clip: true
Rectangle {
anchors.fill: parent
gradient: Gradient {
orientation: Gradient.Horizontal
GradientStop {
position: 0
color: Qt.rgba(1, 1, 1, 1)
}
GradientStop {
position: 1
color: Qt.rgba(1, 1, 1, 0)
}
}
}
Rectangle {
anchors.fill: parent
gradient: Gradient {
GradientStop {
position: 0
color: Qt.rgba(0, 0, 0, 0)
}
GradientStop {
position: 1
color: Qt.rgba(0, 0, 0, 1)
}
}
}
Rectangle {
x: root.saturation * (parent.width - 12)
y: (1 - root.brightness) * (parent.height - 12)
width: 12
height: 12
radius: 6
color: Theme.transparent
border.width: 2
border.color: Theme.text
}
MouseArea {
anchors.fill: parent
function pick(x, y) {
root.saturation = Math.max(0, Math.min(1, x / width));
root.brightness = 1 - Math.max(0, Math.min(1, y / height));
root.commit();
}
onPressed: event => pick(event.x, event.y)
onPositionChanged: event => {
if (pressed)
pick(event.x, event.y);
}
}
}
Slider {
id: hueSlider
objectName: "colorHue"
Layout.fillWidth: true
from: 0
to: 1
value: root.hue
onMoved: {
root.hue = value;
root.commit();
}
background: Rectangle {
x: hueSlider.leftPadding
y: hueSlider.topPadding + hueSlider.availableHeight / 2 - height / 2
width: hueSlider.availableWidth
height: 10
radius: 5
gradient: Gradient {
orientation: Gradient.Horizontal
GradientStop {
position: 0
color: Qt.hsva(0, 1, 1, 1)
}
GradientStop {
position: 0.1667
color: Qt.hsva(0.1667, 1, 1, 1)
}
GradientStop {
position: 0.3333
color: Qt.hsva(0.3333, 1, 1, 1)
}
GradientStop {
position: 0.5
color: Qt.hsva(0.5, 1, 1, 1)
}
GradientStop {
position: 0.6667
color: Qt.hsva(0.6667, 1, 1, 1)
}
GradientStop {
position: 0.8333
color: Qt.hsva(0.8333, 1, 1, 1)
}
GradientStop {
position: 1
color: Qt.hsva(1, 1, 1, 1)
}
}
}
}
}