diff --git a/modules/BarLabel.qml b/modules/BarLabel.qml index c16119f..d92d0f3 100644 --- a/modules/BarLabel.qml +++ b/modules/BarLabel.qml @@ -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 + } } diff --git a/modules/Clock.qml b/modules/Clock.qml index 0b2a7f9..6506124 100644 --- a/modules/Clock.qml +++ b/modules/Clock.qml @@ -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") } diff --git a/modules/Weather.qml b/modules/Weather.qml index 2b65aaf..94f8bd6 100644 --- a/modules/Weather.qml +++ b/modules/Weather.qml @@ -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 - color: M.Theme.base05 - font.pixelSize: M.Theme.fontSize - font.family: M.Theme.iconFontFamily - verticalAlignment: Text.AlignVCenter + Text { + id: label + color: M.Theme.base05 + font.pixelSize: M.Theme.fontSize + font.family: M.Theme.iconFontFamily + anchors.verticalCenter: parent.verticalCenter + } }