forked from Shinonome/dots-hyprland
refactor fixed width text
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
import QtQuick
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property alias longestText: longestTextMetrics.text
|
||||||
|
property alias font: longestTextMetrics.font
|
||||||
|
|
||||||
|
implicitWidth: longestTextMetrics.width
|
||||||
|
implicitHeight: longestTextMetrics.height
|
||||||
|
|
||||||
|
TextMetrics {
|
||||||
|
id: longestTextMetrics
|
||||||
|
text: root.longestText
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,31 +1,23 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
|
import qs.modules.common.widgets as W
|
||||||
|
|
||||||
Item {
|
W.FixedWidthTextContainer {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property string longestText
|
|
||||||
property alias text: textItem.text
|
property alias text: textItem.text
|
||||||
property alias font: textItem.font
|
|
||||||
property alias horizontalAlignment: textItem.horizontalAlignment
|
property alias horizontalAlignment: textItem.horizontalAlignment
|
||||||
property alias verticalAlignment: textItem.verticalAlignment
|
property alias verticalAlignment: textItem.verticalAlignment
|
||||||
property alias color: textItem.color
|
property alias color: textItem.color
|
||||||
|
|
||||||
implicitWidth: longestTextMetrics.width
|
font {
|
||||||
implicitHeight: longestTextMetrics.height
|
family: Looks.font.family.ui
|
||||||
|
pixelSize: Looks.font.pixelSize.large
|
||||||
TextMetrics {
|
weight: Looks.font.weight.regular
|
||||||
id: longestTextMetrics
|
|
||||||
text: root.longestText
|
|
||||||
font {
|
|
||||||
family: Looks.font.family.ui
|
|
||||||
pixelSize: Looks.font.pixelSize.large
|
|
||||||
weight: Looks.font.weight.regular
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WText {
|
WText {
|
||||||
id: textItem
|
id: textItem
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
font.pixelSize: Looks.font.pixelSize.large
|
font: root.font
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user