forked from Shinonome/dots-hyprland
hefty: bar: center time
This commit is contained in:
@@ -0,0 +1,38 @@
|
|||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Layouts
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property alias text: textWidget.text
|
||||||
|
property alias horizontalAlignment: textWidget.horizontalAlignment
|
||||||
|
property alias verticalAlignment: textWidget.verticalAlignment
|
||||||
|
property alias font: textWidget.font
|
||||||
|
property alias color: textWidget.color
|
||||||
|
|
||||||
|
// In many cases the baseline is a bit high to accomodate the dangling parts of "g" and "y",
|
||||||
|
// making most text (especiall number-only text) not well-balanced.
|
||||||
|
// This adjusts the rounding to make sure the text gets lowered if not internally pixel-aligned
|
||||||
|
property bool lowerBias: true
|
||||||
|
|
||||||
|
implicitWidth: textMetrics.width
|
||||||
|
implicitHeight: textMetrics.height
|
||||||
|
|
||||||
|
TextMetrics {
|
||||||
|
id: textMetrics
|
||||||
|
font: root.font
|
||||||
|
text: root.text
|
||||||
|
}
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
id: textWidget
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
y: {
|
||||||
|
const value = (parent.height - textMetrics.height) / 2;
|
||||||
|
return root.lowerBias ? Math.ceil(value) : Math.round(value);
|
||||||
|
}
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -59,10 +59,10 @@ W.ButtonMouseArea {
|
|||||||
sourceComponent: RowLayout {
|
sourceComponent: RowLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
W.StyledText {
|
W.VisuallyCenteredStyledText {
|
||||||
Layout.leftMargin: root.layoutParentTopLeftRadius * root.parentRadiusToPaddingRatio
|
Layout.leftMargin: root.layoutParentTopLeftRadius * root.parentRadiusToPaddingRatio
|
||||||
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
|
||||||
horizontalAlignment: Text.AlignHCenter
|
Layout.fillHeight: true
|
||||||
font.pixelSize: C.Appearance.font.pixelSize.large
|
font.pixelSize: C.Appearance.font.pixelSize.large
|
||||||
color: C.Appearance.colors.colOnLayer1
|
color: C.Appearance.colors.colOnLayer1
|
||||||
text: S.DateTime.time
|
text: S.DateTime.time
|
||||||
|
|||||||
Reference in New Issue
Block a user