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

View file

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