Skip to content

Commit dfc3e83

Browse files
committed
qml: correct mini block clock gradient direction
1 parent 10123f9 commit dfc3e83

2 files changed

Lines changed: 37 additions & 7 deletions

File tree

qml/components/blockclockdial.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,16 @@ void BlockClockDial::setupSyncedGradient(const QRectF& bounds)
6969
m_synced_gradient_bounds = bounds;
7070
m_synced_gradient.setCenter(bounds.center());
7171
m_synced_gradient.setAngle(90);
72-
m_synced_gradient.setColorAt(0, m_confirmation_colors[5]);
73-
m_synced_gradient.setColorAt(0.16, m_confirmation_colors[5]);
74-
m_synced_gradient.setColorAt(0.32, m_confirmation_colors[4]);
75-
m_synced_gradient.setColorAt(0.48, m_confirmation_colors[3]);
76-
m_synced_gradient.setColorAt(0.64, m_confirmation_colors[2]);
77-
m_synced_gradient.setColorAt(0.8, m_confirmation_colors[1]);
78-
m_synced_gradient.setColorAt(1, m_confirmation_colors[0]);
72+
// The dial advances clockwise while conical gradients advance
73+
// counter-clockwise. Mirror the stops so older time is more confirmed and
74+
// the color moves toward zero confirmations as the dial advances.
75+
m_synced_gradient.setColorAt(0, m_confirmation_colors[0]);
76+
m_synced_gradient.setColorAt(0.2, m_confirmation_colors[1]);
77+
m_synced_gradient.setColorAt(0.36, m_confirmation_colors[2]);
78+
m_synced_gradient.setColorAt(0.52, m_confirmation_colors[3]);
79+
m_synced_gradient.setColorAt(0.68, m_confirmation_colors[4]);
80+
m_synced_gradient.setColorAt(0.84, m_confirmation_colors[5]);
81+
m_synced_gradient.setColorAt(1, m_confirmation_colors[5]);
7982
m_synced_gradient_needs_update = false;
8083
}
8184

test/test_blockclockdial.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ class BlockClockDialTests : public QObject
117117
private Q_SLOTS:
118118
void ibdProgressRendersImmediateHalfArc();
119119
void syncedGradientToggleChangesRenderedColors();
120+
void syncedGradientRunsFromOlderToNewerConfirmationColors();
120121
void syncedGradientUpdatesWhenConfirmationColorsChange();
121122
void connectingDelayControlsInitialAnimation();
122123
void inactiveDialStopsAnimationAndRetainsLatestState();
@@ -175,6 +176,32 @@ void BlockClockDialTests::syncedGradientToggleChangesRenderedColors()
175176
.arg(gradient_right.name(QColor::HexArgb), gradient_bottom.name(QColor::HexArgb))));
176177
}
177178

179+
void BlockClockDialTests::syncedGradientRunsFromOlderToNewerConfirmationColors()
180+
{
181+
BlockClockDial dial;
182+
ConfigureDial(dial);
183+
dial.setAnimateDial(false);
184+
dial.setConnected(true);
185+
dial.setSynced(true);
186+
dial.setShowBlockSegments(false);
187+
dial.setUseGradientArcWhenSynced(true);
188+
dial.setCurrentTimeFraction(0.75);
189+
190+
const QImage image{RenderDial(dial)};
191+
const QColor older_color{image.pixelColor(DialPoint(0.05))};
192+
const QColor middle_color{image.pixelColor(DialPoint(0.375))};
193+
const QColor newer_color{image.pixelColor(DialPoint(0.70))};
194+
195+
QVERIFY(ColorDistance(older_color, CONFIRMATION_COLORS[5]) <
196+
ColorDistance(older_color, CONFIRMATION_COLORS[0]));
197+
QVERIFY(ColorDistance(newer_color, CONFIRMATION_COLORS[0]) <
198+
ColorDistance(older_color, CONFIRMATION_COLORS[0]));
199+
QVERIFY(ColorDistance(older_color, CONFIRMATION_COLORS[5]) <
200+
ColorDistance(newer_color, CONFIRMATION_COLORS[5]));
201+
QVERIFY(older_color.green() > middle_color.green());
202+
QVERIFY(middle_color.green() > newer_color.green());
203+
}
204+
178205
void BlockClockDialTests::syncedGradientUpdatesWhenConfirmationColorsChange()
179206
{
180207
BlockClockDial dial;

0 commit comments

Comments
 (0)