1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 13:32:50 -05:00

Default to Zenity Color picker

- QT 6.9.3 removed the previous color picker we used
- Zenity is default in gnome based distros
- Kcolorchooser can be installed separately and will be preferred over Zenity
This commit is contained in:
purian23
2025-10-04 22:59:02 -04:00
parent ad44f09421
commit 804bf879ed

View File

@@ -1,37 +1,79 @@
import QtQuick
import Qt.labs.platform
import Quickshell
import Quickshell.Io
import qs.Common
import qs.Services
Item {
id: colorPickerModal
property string availablePicker: "zenity"
signal colorSelected(color selectedColor)
function show() {
colorDialog.open()
if (availablePicker === "kcolorchooser") {
kcolorchooserProcess.running = true
} else {
zenityProcess.running = true
}
}
function hide() {
colorDialog.close()
kcolorchooserProcess.running = false
zenityProcess.running = false
}
function copyColorToClipboard(colorValue) {
Quickshell.execDetached(["sh", "-c", `echo "${colorValue}" | wl-copy`])
ToastService.showInfo(`Color ${colorValue} copied to clipboard`)
console.log("Copied color to clipboard:", colorValue)
ToastService.showInfo(`Color ${colorValue} copied`)
}
ColorDialog {
id: colorDialog
title: "Color Picker - Select and copy color"
color: Theme.primary
Process {
id: kcolorDetector
running: false
command: ["which", "kcolorchooser"]
onAccepted: {
const colorString = color.toString()
copyColorToClipboard(colorString)
colorSelected(color)
onExited: (code, status) => {
if (code === 0) {
availablePicker = "kcolorchooser"
}
}
}
Process {
id: kcolorchooserProcess
running: false
command: ["kcolorchooser", "--print"]
stdout: SplitParser {
onRead: data => {
const colorValue = data.trim()
if (colorValue.length > 0) {
copyColorToClipboard(colorValue)
colorSelected(colorValue)
}
}
}
}
Process {
id: zenityProcess
running: false
command: ["zenity", "--color-selection", "--show-palette"]
stdout: SplitParser {
onRead: data => {
const colorValue = data.trim()
if (colorValue.length > 0) {
copyColorToClipboard(colorValue)
colorSelected(colorValue)
}
}
}
}
Component.onCompleted: {
kcolorDetector.running = true
}
}