move stuff into components

This commit is contained in:
Damocles 2026-04-12 01:00:05 +02:00
parent 14292e6683
commit 186c9a3aa2
3 changed files with 26 additions and 21 deletions

View file

@ -1,12 +1,20 @@
import QtQuick
import QtQuick.Controls
import "." as M
Text {
property string label: ""
property string tooltip: ""
text: label
color: M.Theme.base05
font.pixelSize: M.Theme.fontSize
font.family: M.Theme.fontFamily
verticalAlignment: Text.AlignVCenter
HoverHandler { id: _hover }
ToolTip {
visible: _hover.hovered && parent.tooltip !== ""
text: parent.tooltip
}
}

View file

@ -1,23 +1,14 @@
import QtQuick
import QtQuick.Controls
import Quickshell
import "." as M
Text {
M.BarLabel {
SystemClock {
id: clock
precision: SystemClock.Seconds
}
text: Qt.formatDateTime(clock.date, "ddd, dd. MMM HH:mm")
color: M.Theme.base05
font.pixelSize: M.Theme.fontSize + 1
font.family: M.Theme.fontFamily
verticalAlignment: Text.AlignVCenter
HoverHandler { id: hover }
ToolTip {
visible: hover.hovered
text: Qt.formatDateTime(clock.date, "dddd, dd. MMMM yyyy\nHH:mm:ss")
}
label: Qt.formatDateTime(clock.date, "ddd, dd. MMM HH:mm")
tooltip: Qt.formatDateTime(clock.date, "dddd, dd. MMMM yyyy\nHH:mm:ss")
}

View file

@ -2,10 +2,12 @@ import QtQuick
import Quickshell.Io
import "." as M
Text {
M.BarSection {
id: root
spacing: 4
tooltip: root.weatherTooltip
property string label: ""
property string weatherTooltip: ""
Process {
id: proc
@ -15,9 +17,11 @@ Text {
onStreamFinished: {
try {
const data = JSON.parse(text);
root.label = data.text ?? "";
label.text = data.text ?? "";
root.weatherTooltip = data.tooltip ?? "";
} catch (e) {
root.label = "";
label.text = "";
root.weatherTooltip = "";
}
}
}
@ -29,9 +33,11 @@ Text {
onTriggered: proc.running = true
}
text: root.label
Text {
id: label
color: M.Theme.base05
font.pixelSize: M.Theme.fontSize
font.family: M.Theme.iconFontFamily
verticalAlignment: Text.AlignVCenter
anchors.verticalCenter: parent.verticalCenter
}
}