diff --git a/shell/plugins/panels/elsewhen/CityRow.qml b/shell/plugins/panels/elsewhen/CityRow.qml index 42d4e028..95c7b0c7 100644 --- a/shell/plugins/panels/elsewhen/CityRow.qml +++ b/shell/plugins/panels/elsewhen/CityRow.qml @@ -173,6 +173,11 @@ Rectangle { elide: Text.ElideRight } + // Takes the slack, so the weather sits against the time column in every row. + Item { + Layout.fillWidth: true + } + Caption { Layout.alignment: Qt.AlignBaseline text: Model.tempLabel(row.panel.facts[Model.factsKey(row.rowData)], row.panel.units) @@ -299,6 +304,8 @@ Rectangle { Column { id: timeBlock + // One width for every row, so the labels beside it line up. + width: Math.max(row.panel.timeColumnWidth, implicitWidth) anchors.right: parent.right anchors.rightMargin: Style.spacing.rowPaddingX anchors.verticalCenter: rowLabels.verticalCenter diff --git a/shell/plugins/panels/elsewhen/Panel.qml b/shell/plugins/panels/elsewhen/Panel.qml index 5c635e86..773cc9f6 100644 --- a/shell/plugins/panels/elsewhen/Panel.qml +++ b/shell/plugins/panels/elsewhen/Panel.qml @@ -355,6 +355,26 @@ Panel { readonly property real capGap: Math.max(0, nameFontMetrics.height - nameFontMetrics.descent + nameCapMetrics.tightBoundingRect.y) + // The widest a row's time gets, so every row's weather lines up against one + // column rather than hugging "4:06" in one row and "10:06" in the next. + TextMetrics { + id: widestTimeMetrics + font.family: root.fontFamily + font.pixelSize: Style.font.heading + font.weight: Font.DemiBold + text: "00:00" + } + + TextMetrics { + id: meridiemMetrics + font.family: root.fontFamily + font.pixelSize: Style.font.caption + text: "PM" + } + + readonly property real timeColumnWidth: Math.ceil(widestTimeMetrics.advanceWidth + + (hour24 ? 0 : Style.spacing.xs + meridiemMetrics.advanceWidth)) + function tick() { nowMs = Date.now() localOffsetMinutes = -(new Date().getTimezoneOffset()) @@ -738,9 +758,11 @@ Panel { } onTabRequested: function(direction) { root.switchPanel(direction) } // "+" searches in either view; "j" jumps on the globe, "a" adds on the list. + // "t" flips 24-hour and AM/PM time, like clicking a row's time. onTextKey: function(text) { var key = text.toLowerCase() if (key === "r") root.refresh() + else if (key === "t") root.toggleHour24() else if (root.globeMode && (key === "+" || key === "j")) { if (globeLoader.item) globeLoader.item.startJump() } else if (!root.globeMode && (key === "+" || key === "a")) {