add theme switcher
This commit is contained in:
parent
143889683b
commit
d69ec48728
9 changed files with 126 additions and 68 deletions
29
modules/Services/State.qml
Normal file
29
modules/Services/State.qml
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
pragma Singleton
|
||||
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import QtQuick
|
||||
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
property alias s: stateAdapter
|
||||
property alias v: state
|
||||
FileView {
|
||||
id: state
|
||||
path: Qt.resolvedUrl(Quickshell.shellDir + "/settings/state.json")
|
||||
watchChanges: true
|
||||
onLoadFailed: {
|
||||
writeAdapter()
|
||||
}
|
||||
onAdapterUpdated: writeAdapter()
|
||||
onFileChanged: reload()
|
||||
adapter: JsonAdapter {
|
||||
id: stateAdapter
|
||||
property bool themeSwitcherVisible: false
|
||||
}
|
||||
|
||||
}
|
||||
Component.onCompleted: console.log("say gex")
|
||||
|
||||
}
|
||||
|
|
@ -9,14 +9,14 @@ import qs
|
|||
import qs.settings
|
||||
import qs.widgets
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.AllButtons
|
||||
}
|
||||
clip: true
|
||||
FloatingWindow {
|
||||
id: child
|
||||
implicitWidth: 800
|
||||
implicitHeight: 600
|
||||
visible: Config.cfg.themeSwitcherVisible
|
||||
color: Colors.base00
|
||||
title: "qs-themepicker"
|
||||
onClosed: Config.cfg.themeSwitcherVisible = false
|
||||
Process {
|
||||
id: getSchemes
|
||||
property list<string> schemes
|
||||
|
|
@ -28,20 +28,62 @@ Rectangle {
|
|||
}
|
||||
}
|
||||
}
|
||||
ListView {
|
||||
id: schemeList
|
||||
orientation: ListView.Horizontal
|
||||
anchors.fill: root
|
||||
model: getSchemes.schemes
|
||||
delegate: Rectangle {
|
||||
id: container
|
||||
required property string modelData
|
||||
color: Colors.base01
|
||||
height: 30
|
||||
implicitWidth: schemeName.width + 16
|
||||
Rectangle {
|
||||
anchors.fill: child.contentItem
|
||||
anchors.centerIn: child.contentItem
|
||||
anchors.margins: 10
|
||||
radius: Config.cfg.appearance.rounding / 1.5
|
||||
color: Colors.base01
|
||||
clip: true
|
||||
RowLayout {
|
||||
id: contentLayout
|
||||
anchors.fill: parent
|
||||
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: schemeName
|
||||
text: container.modelData
|
||||
id: currentScheme
|
||||
text: ""
|
||||
Process {
|
||||
id: getCurrentScheme
|
||||
command: ["tinty", "current"]
|
||||
running: true
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: currentScheme.text = text
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,19 +3,25 @@ import qs.widgets
|
|||
import QtQuick
|
||||
import Quickshell
|
||||
import qs.modules.Services
|
||||
import qs.modules.applets
|
||||
import qs.settings
|
||||
|
||||
BarComponent {
|
||||
implicitWidth: text.width
|
||||
required property ShellScreen barScreen
|
||||
StyledText {
|
||||
id: text
|
||||
anchors.centerIn: parent
|
||||
text: "temp!!!"
|
||||
}
|
||||
MouseArea {
|
||||
id: clickHandler
|
||||
acceptedButtons: Qt.LeftButton
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
anchors.fill: parent
|
||||
onClicked: { WidgetTracker.toggle("colorschemes", parent.barScreen) }
|
||||
id: clickHandler
|
||||
acceptedButtons: Qt.LeftButton
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
Config.cfg.themeSwitcherVisible = true
|
||||
}
|
||||
}
|
||||
ThemeSwitcher {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,19 +114,6 @@ Variants {
|
|||
}
|
||||
}
|
||||
}
|
||||
ThemeSwitcher {
|
||||
z: 1
|
||||
id: colorschemes
|
||||
property bool shown: WidgetTracker.current === "colorschemes" && root.shown
|
||||
visible: shown
|
||||
focus: shown
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.topMargin: Config.cfg.bar.floating ? Config.cfg.bar.height + 20 : Config.cfg.bar.height + 10
|
||||
anchors.margins: 20
|
||||
implicitHeight: 60
|
||||
}
|
||||
MouseArea {
|
||||
id: dismisser
|
||||
z: 0
|
||||
|
|
|
|||
Loading…
Reference in a new issue