quickshell/modules/applets/ThemeSwitcher.qml
2026-09-10 22:43:20 +02:00

93 lines
2.7 KiB
QML

import Quickshell
import Quickshell.Io
import QtQuick
import QtQuick.Layouts
import qs
import qs.settings
import qs.widgets
import qs.modules.Services
Rectangle {
id: child
implicitWidth: 800
implicitHeight: 600
color: Colors.base01
radius: Config.cfg.appearance.rounding
MouseArea {
acceptedButtons: Qt.AllButtons
anchors.fill: parent
}
Process {
id: getSchemes
property list<string> schemes
running: true
command: ["tinty", "list"]
stdout: SplitParser {
onRead: text => {
getSchemes.schemes.push(text);
}
}
}
Rectangle {
anchors.fill: parent
anchors.centerIn: parent
anchors.margins: 10
radius: Config.cfg.appearance.rounding
color: Colors.base01
clip: true
RowLayout {
id: contentLayout
anchors.fill: parent
anchors.margins: 30
ListView {
id: schemeList
spacing: 5
Layout.fillHeight: true
model: getSchemes.schemes
implicitWidth: 300
delegate: Rectangle {
id: container
required property string modelData
color: Colors.base02
height: 30
radius: Config.cfg.appearance.rounding
implicitWidth: 300
StyledText {
id: schemeName
anchors.centerIn: parent
text: container.modelData
}
MouseArea {
id: schemeSetter
anchors.fill: container
acceptedButtons: Qt.LeftButton
cursorShape: Qt.PointingHandCursor
onClicked: {
setTheme.themeName = modelData;
setTheme.running = true;
}
Process {
id: setTheme
property string themeName
command: ["tinty", "apply", themeName]
}
}
}
}
StyledText {
id: currentScheme
text: ""
Process {
id: getCurrentScheme
command: ["tinty", "current"]
running: true
stdout: StdioCollector {
onStreamFinished: currentScheme.text = text
}
}
}
}
}
}