Clock: height calculation similar to NPill to avoid discrepancies
This commit is contained in:
parent
9e47d91be2
commit
97bfcbb9e8
1 changed files with 11 additions and 11 deletions
|
|
@ -36,10 +36,10 @@ Rectangle {
|
||||||
readonly property string displayFormat: widgetSettings.displayFormat !== undefined ? widgetSettings.displayFormat : widgetMetadata.displayFormat
|
readonly property string displayFormat: widgetSettings.displayFormat !== undefined ? widgetSettings.displayFormat : widgetMetadata.displayFormat
|
||||||
|
|
||||||
// Use compact mode for vertical bars
|
// Use compact mode for vertical bars
|
||||||
readonly property bool useCompactMode: barPosition === "left" || barPosition === "right"
|
readonly property bool verticalMode: barPosition === "left" || barPosition === "right"
|
||||||
|
|
||||||
implicitWidth: useCompactMode ? Math.round(Style.capsuleHeight * scaling) : Math.round(layout.implicitWidth + Style.marginM * 2 * scaling)
|
implicitWidth: verticalMode ? Math.round(Style.capsuleHeight * scaling) : Math.round(layout.implicitWidth + Style.marginM * 2 * scaling)
|
||||||
implicitHeight: useCompactMode ? Math.round(Style.capsuleHeight * 2.5 * scaling) : Math.round(Style.capsuleHeight * scaling)
|
implicitHeight: verticalMode ? Math.round(Style.capsuleHeight * 2.5 * scaling) : Math.round(Style.baseWidgetSize * 0.8 * scaling) // Match NPill
|
||||||
|
|
||||||
radius: Math.round(Style.radiusS * scaling)
|
radius: Math.round(Style.radiusS * scaling)
|
||||||
color: Color.mSurfaceVariant
|
color: Color.mSurfaceVariant
|
||||||
|
|
@ -52,18 +52,18 @@ Rectangle {
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: layout
|
id: layout
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
spacing: useCompactMode ? -2 * scaling : -3 * scaling
|
spacing: verticalMode ? -2 * scaling : -3 * scaling
|
||||||
|
|
||||||
// Compact mode for vertical bars - Time section (HH, MM)
|
// Compact mode for vertical bars - Time section (HH, MM)
|
||||||
Repeater {
|
Repeater {
|
||||||
model: useCompactMode ? 2 : 1
|
model: verticalMode ? 2 : 1
|
||||||
NText {
|
NText {
|
||||||
readonly property bool showSeconds: (displayFormat === "time-seconds")
|
readonly property bool showSeconds: (displayFormat === "time-seconds")
|
||||||
readonly property bool inlineDate: (displayFormat === "time-date")
|
readonly property bool inlineDate: (displayFormat === "time-date")
|
||||||
readonly property var now: Time.date
|
readonly property var now: Time.date
|
||||||
|
|
||||||
text: {
|
text: {
|
||||||
if (useCompactMode) {
|
if (verticalMode) {
|
||||||
// Compact mode: time section (first 2 lines)
|
// Compact mode: time section (first 2 lines)
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
|
|
@ -126,7 +126,7 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
font.family: Settings.data.ui.fontFixed
|
font.family: Settings.data.ui.fontFixed
|
||||||
font.pointSize: useCompactMode ? Style.fontSizeXXS * scaling : Style.fontSizeXS * scaling
|
font.pointSize: verticalMode ? Style.fontSizeXXS * scaling : Style.fontSizeXS * scaling
|
||||||
font.weight: Style.fontWeightBold
|
font.weight: Style.fontWeightBold
|
||||||
color: Color.mPrimary
|
color: Color.mPrimary
|
||||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||||
|
|
@ -135,7 +135,7 @@ Rectangle {
|
||||||
|
|
||||||
// Separator line for compact mode (between time and date)
|
// Separator line for compact mode (between time and date)
|
||||||
Rectangle {
|
Rectangle {
|
||||||
visible: useCompactMode
|
visible: verticalMode
|
||||||
Layout.preferredWidth: 20 * scaling
|
Layout.preferredWidth: 20 * scaling
|
||||||
Layout.preferredHeight: 2 * scaling
|
Layout.preferredHeight: 2 * scaling
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
|
@ -148,12 +148,12 @@ Rectangle {
|
||||||
|
|
||||||
// Compact mode for vertical bars - Date section (DD, MM)
|
// Compact mode for vertical bars - Date section (DD, MM)
|
||||||
Repeater {
|
Repeater {
|
||||||
model: useCompactMode ? 2 : 0
|
model: verticalMode ? 2 : 0
|
||||||
NText {
|
NText {
|
||||||
readonly property var now: Time.date
|
readonly property var now: Time.date
|
||||||
|
|
||||||
text: {
|
text: {
|
||||||
if (useCompactMode) {
|
if (verticalMode) {
|
||||||
// Compact mode: date section (last 2 lines)
|
// Compact mode: date section (last 2 lines)
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
|
|
@ -178,7 +178,7 @@ Rectangle {
|
||||||
|
|
||||||
// Second line for normal mode (date)
|
// Second line for normal mode (date)
|
||||||
NText {
|
NText {
|
||||||
visible: !useCompactMode && (displayFormat === "time-date-short")
|
visible: !verticalMode && (displayFormat === "time-date-short")
|
||||||
text: {
|
text: {
|
||||||
const now = Time.date
|
const now = Time.date
|
||||||
const day = now.getDate().toString().padStart(2, '0')
|
const day = now.getDate().toString().padStart(2, '0')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue