Skip to content

Commit 4bc9b21

Browse files
committed
RemorseTimer: Add square boundary for the content so the gauge stays a circle
On non-square screens the countdown gauge got stretched into an oval. This wraps the arc and labels in a centered Math.min(width, height) square so it stays circular also when the component is not fullscreen. Re #44.
1 parent 8180067 commit 4bc9b21

1 file changed

Lines changed: 52 additions & 42 deletions

File tree

src/controls/qml/RemorseTimer.qml

Lines changed: 52 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -147,55 +147,65 @@ Rectangle {
147147
onTriggered: remorseTimer.countdownSeconds--
148148
}
149149

150-
SegmentedArc {
151-
id: countdownArc
152-
anchors {
153-
horizontalCenter: parent.horizontalCenter
154-
verticalCenter: parent.verticalCenter
150+
// Content is sized against a centered square (the shorter screen edge)
151+
// instead of Dims, so it stays correct on non-square screens and when the
152+
// parent is not full-screen.
153+
Item {
154+
id: gaugeArea
155+
anchors.centerIn: parent
156+
height: Math.min(parent.width, parent.height + flatTireHeight)
157+
width: height
158+
159+
SegmentedArc {
160+
id: countdownArc
161+
anchors {
162+
horizontalCenter: parent.horizontalCenter
163+
verticalCenter: parent.verticalCenter
164+
}
165+
width: parent.width * 0.22
166+
height: width
167+
segmentAmount: remorseTimer.gaugeSegmentAmount
168+
inputValue: remorseTimer.arcValue
169+
fgColor: "#ffffff"
170+
bgColor: Qt.rgba(1, 1, 1, 0.2)
171+
start: remorseTimer.gaugeStartDegree
172+
endFromStart: remorseTimer.gaugeEndFromStartDegree
155173
}
156-
width: Dims.l(22)
157-
height: width
158-
segmentAmount: remorseTimer.gaugeSegmentAmount
159-
inputValue: remorseTimer.arcValue
160-
fgColor: "#ffffff"
161-
bgColor: Qt.rgba(1, 1, 1, 0.2)
162-
start: remorseTimer.gaugeStartDegree
163-
endFromStart: remorseTimer.gaugeEndFromStartDegree
164-
}
165174

166-
Label {
167-
id: countdownLabel
168-
anchors.centerIn: countdownArc
169-
font {
170-
pixelSize: Dims.l(18)
171-
styleName: "SemiBoldCondensed"
175+
Label {
176+
id: countdownLabel
177+
anchors.centerIn: countdownArc
178+
font {
179+
pixelSize: parent.width * 0.18
180+
styleName: "SemiBoldCondensed"
181+
}
182+
color: "#ffffff"
183+
text: remorseTimer.countdownSeconds
184+
z: countdownArc.z + 1
172185
}
173-
color: "#ffffff"
174-
text: remorseTimer.countdownSeconds
175-
z: countdownArc.z + 1
176-
}
177186

178-
Label {
179-
id: actionLabel
180-
anchors {
181-
horizontalCenter: parent.horizontalCenter
182-
bottom: countdownArc.top
183-
bottomMargin: Dims.l(1)
187+
Label {
188+
id: actionLabel
189+
anchors {
190+
horizontalCenter: parent.horizontalCenter
191+
bottom: countdownArc.top
192+
bottomMargin: parent.width * 0.01
193+
}
194+
font.pixelSize: parent.width * 0.06
195+
color: "#ffffff"
196+
text: action
184197
}
185-
font.pixelSize: Dims.l(6)
186-
color: "#ffffff"
187-
text: action
188-
}
189198

190-
Label {
191-
id: cancelLabel
192-
anchors {
193-
horizontalCenter: parent.horizontalCenter
194-
top: countdownArc.bottom
195-
topMargin: Dims.l(1)
199+
Label {
200+
id: cancelLabel
201+
anchors {
202+
horizontalCenter: parent.horizontalCenter
203+
top: countdownArc.bottom
204+
topMargin: parent.width * 0.01
205+
}
206+
font.pixelSize: parent.width * 0.06
207+
color: "#ffffff"
196208
}
197-
font.pixelSize: Dims.l(6)
198-
color: "#ffffff"
199209
}
200210

201211
MouseArea {

0 commit comments

Comments
 (0)