mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-30 11:02:19 +08:00
fix reverse gear alert text cutoff (#20888)
* fix reverse gear alert text cutoff * offset removed old-commit-hash: ff16145f4de95b67815104596ec46da09b3f704a
This commit is contained in:
@@ -115,17 +115,15 @@ void OnroadAlerts::stopSounds() {
|
||||
void OnroadAlerts::paintEvent(QPaintEvent *event) {
|
||||
QPainter p(this);
|
||||
|
||||
if (alert_size == cereal::ControlsState::AlertSize::NONE) {
|
||||
return;
|
||||
}
|
||||
static std::map<cereal::ControlsState::AlertSize, const int> alert_sizes = {
|
||||
{cereal::ControlsState::AlertSize::NONE, 0},
|
||||
{cereal::ControlsState::AlertSize::SMALL, 271},
|
||||
{cereal::ControlsState::AlertSize::MID, 420},
|
||||
{cereal::ControlsState::AlertSize::FULL, height()},
|
||||
};
|
||||
int h = alert_sizes[alert_size];
|
||||
if (h == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
QRect r = QRect(0, height() - h, width(), h);
|
||||
|
||||
// draw background + gradient
|
||||
@@ -158,10 +156,9 @@ void OnroadAlerts::paintEvent(QPaintEvent *event) {
|
||||
configFont(p, "Open Sans", 66, "Regular");
|
||||
p.drawText(QRect(0, c.y() + 21, width(), 90), Qt::AlignHCenter, text2);
|
||||
} else if (alert_size == cereal::ControlsState::AlertSize::FULL) {
|
||||
// TODO: offset from center to match old NVG UI, but why was it this way?
|
||||
bool l = text1.length() > 15;
|
||||
configFont(p, "Open Sans", l ? 132 : 177, "Bold");
|
||||
p.drawText(QRect(0, r.y() + (l ? 240 : 270), width(), 350), Qt::AlignHCenter | Qt::TextWordWrap, text1);
|
||||
p.drawText(QRect(0, r.y() + (l ? 240 : 270), width(), 600), Qt::AlignHCenter | Qt::TextWordWrap, text1);
|
||||
configFont(p, "Open Sans", 88, "Regular");
|
||||
p.drawText(QRect(0, r.height() - (l ? 361 : 420), width(), 300), Qt::AlignHCenter | Qt::TextWordWrap, text2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user