Commit 62119132 authored by Claudio Cambra's avatar Claudio Cambra
Browse files

Week view hour label now adjusts to font and format

parent a0981f1b
Pipeline #96953 canceled with stage
...@@ -43,7 +43,8 @@ Kirigami.Page { ...@@ -43,7 +43,8 @@ Kirigami.Page {
readonly property real dayWidth: ((root.width - hourLabelWidth - leftPadding - scrollbarWidth) / daysToShow) - gridLineWidth readonly property real dayWidth: ((root.width - hourLabelWidth - leftPadding - scrollbarWidth) / daysToShow) - gridLineWidth
readonly property real incidenceSpacing: Kirigami.Units.smallSpacing / 2 readonly property real incidenceSpacing: Kirigami.Units.smallSpacing / 2
readonly property real gridLineWidth: 1.0 readonly property real gridLineWidth: 1.0
readonly property real hourLabelWidth: Kirigami.Units.gridUnit * 3.5 readonly property real hourLabelWidth: fontMetrics.boundingRect(new Date(0,0,0,2,0,0,0).toLocaleTimeString(Qt.locale(), Locale.NarrowFormat)).width +
Kirigami.Units.largeSpacing * 2
readonly property real periodHeight: Kirigami.Units.gridUnit / 2 readonly property real periodHeight: Kirigami.Units.gridUnit / 2
Kirigami.Theme.inherit: false Kirigami.Theme.inherit: false
...@@ -111,6 +112,10 @@ Kirigami.Page { ...@@ -111,6 +112,10 @@ Kirigami.Page {
padding: 0 padding: 0
FontMetrics {
id: fontMetrics
}
PathView { PathView {
id: pathView id: pathView
...@@ -204,10 +209,6 @@ Kirigami.Page { ...@@ -204,10 +209,6 @@ Kirigami.Page {
delegate: Kirigami.Heading { delegate: Kirigami.Heading {
id: dayHeading id: dayHeading
FontMetrics {
id: dayTitleMetrics
}
property date headingDate: DateUtils.addDaysToDate(viewLoader.startDate, index) property date headingDate: DateUtils.addDaysToDate(viewLoader.startDate, index)
property bool isToday: headingDate.getDate() === root.currentDay && property bool isToday: headingDate.getDate() === root.currentDay &&
headingDate.getMonth() === root.currentMonth && headingDate.getMonth() === root.currentMonth &&
...@@ -223,9 +224,9 @@ Kirigami.Page { ...@@ -223,9 +224,9 @@ Kirigami.Page {
const shortText = mediumText.slice(0,1) + " " + headingDate.toLocaleDateString(Qt.locale(), "<b>dd</b>"); const shortText = mediumText.slice(0,1) + " " + headingDate.toLocaleDateString(Qt.locale(), "<b>dd</b>");
if(dayTitleMetrics.boundingRect(longText).width < width) { if(fontMetrics.boundingRect(longText).width < width) {
return longText; return longText;
} else if(dayTitleMetrics.boundingRect(mediumText).width < width) { } else if(fontMetrics.boundingRect(mediumText).width < width) {
return mediumText; return mediumText;
} else { } else {
return shortText; return shortText;
...@@ -614,10 +615,6 @@ Kirigami.Page { ...@@ -614,10 +615,6 @@ Kirigami.Page {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
width: root.hourLabelWidth width: root.hourLabelWidth
FontMetrics {
id: fontMetrics
}
Loader { Loader {
id: currentTimeLabelLoader id: currentTimeLabelLoader
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment