|  |  | @ -5,7 +5,7 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "selfdrive/common/swaglog.h" |  |  |  | #include "selfdrive/common/swaglog.h" | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "selfdrive/common/timing.h" |  |  |  | #include "selfdrive/common/timing.h" | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "selfdrive/ui/paint.h" |  |  |  | #include "selfdrive/ui/paint.h" | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "selfdrive/ui/qt/qt_window.h" |  |  |  | #include "selfdrive/ui/qt/util.h" | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | OnroadWindow::OnroadWindow(QWidget *parent) : QWidget(parent) { |  |  |  | OnroadWindow::OnroadWindow(QWidget *parent) : QWidget(parent) { | 
			
		
	
		
		
			
				
					
					|  |  |  |   layout = new QStackedLayout(); |  |  |  |   layout = new QStackedLayout(); | 
			
		
	
	
		
		
			
				
					|  |  | @ -17,76 +17,44 @@ OnroadWindow::OnroadWindow(QWidget *parent) : QWidget(parent) { | 
			
		
	
		
		
			
				
					
					|  |  |  |   QObject::connect(this, &OnroadWindow::update, nvg, &NvgWindow::update); |  |  |  |   QObject::connect(this, &OnroadWindow::update, nvg, &NvgWindow::update); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   alerts = new OnroadAlerts(this); |  |  |  |   alerts = new OnroadAlerts(this); | 
			
		
	
		
		
			
				
					
					|  |  |  |   QObject::connect(this, &OnroadWindow::update, alerts, &OnroadAlerts::update); |  |  |  |   QObject::connect(this, &OnroadWindow::update, alerts, &OnroadAlerts::updateState); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   QObject::connect(this, &OnroadWindow::offroadTransition, alerts, &OnroadAlerts::offroadTransition); |  |  |  |   QObject::connect(this, &OnroadWindow::offroadTransition, alerts, &OnroadAlerts::offroadTransition); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   layout->addWidget(alerts); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   // hack to align the onroad alerts, better way to do this?
 |  |  |  |   // setup stacking order
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   QVBoxLayout *alerts_container = new QVBoxLayout(this); |  |  |  |   alerts->raise(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   alerts_container->setMargin(0); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   alerts_container->addStretch(1); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   alerts_container->addWidget(alerts, 0, Qt::AlignBottom); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   QWidget *w = new QWidget(this); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   w->setLayout(alerts_container); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   layout->addWidget(w); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   // alerts on top
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   layout->setCurrentWidget(w); |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   setLayout(layout); |  |  |  |   setLayout(layout); | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | // ***** onroad widgets *****
 |  |  |  | // ***** onroad widgets *****
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | OnroadAlerts::OnroadAlerts(QWidget *parent) : QFrame(parent) { |  |  |  | OnroadAlerts::OnroadAlerts(QWidget *parent) : QWidget(parent) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   layout = new QVBoxLayout(this); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   layout->setSpacing(40); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   layout->setMargin(20); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   title = new QLabel(); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   title->setWordWrap(true); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   title->setAlignment(Qt::AlignCenter); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   layout->addWidget(title); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   msg = new QLabel(); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   msg->setWordWrap(true); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   msg->setAlignment(Qt::AlignCenter); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   layout->addWidget(msg); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   layout->addStretch(1); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   layout->insertStretch(0, 1); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   setLayout(layout); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   setStyleSheet("color: white;"); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   setVisible(false); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   // setup sounds
 |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   for (auto &kv : sound_map) { |  |  |  |   for (auto &kv : sound_map) { | 
			
		
	
		
		
			
				
					
					|  |  |  |     auto path = QUrl::fromLocalFile(kv.second.first); |  |  |  |     auto path = QUrl::fromLocalFile(kv.second.first); | 
			
		
	
		
		
			
				
					
					|  |  |  |     sounds[kv.first].setSource(path); |  |  |  |     sounds[kv.first].setSource(path); | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | void OnroadAlerts::update(const UIState &s) { |  |  |  | void OnroadAlerts::updateState(const UIState &s) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   SubMaster &sm = *(s.sm); |  |  |  |   SubMaster &sm = *(s.sm); | 
			
		
	
		
		
			
				
					
					|  |  |  |   if (sm.updated("carState")) { |  |  |  |   if (sm.updated("carState")) { | 
			
		
	
		
		
			
				
					
					|  |  |  |     // scale volume with speed
 |  |  |  |     // scale volume with speed
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     volume = util::map_val(sm["carState"].getCarState().getVEgo(), 0.f, 20.f, |  |  |  |     volume = util::map_val(sm["carState"].getCarState().getVEgo(), 0.f, 20.f, | 
			
		
	
		
		
			
				
					
					|  |  |  |                            Hardware::MIN_VOLUME, Hardware::MAX_VOLUME); |  |  |  |                            Hardware::MIN_VOLUME, Hardware::MAX_VOLUME); | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   if (s.scene.deviceState.getStarted()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |     if (sm.updated("controlsState")) { |  |  |  |     if (sm.updated("controlsState")) { | 
			
		
	
		
		
			
				
					
					|  |  |  |       const cereal::ControlsState::Reader &cs = sm["controlsState"].getControlsState(); |  |  |  |       const cereal::ControlsState::Reader &cs = sm["controlsState"].getControlsState(); | 
			
		
	
		
		
			
				
					
					|  |  |  |       updateAlert(QString::fromStdString(cs.getAlertText1()), QString::fromStdString(cs.getAlertText2()), |  |  |  |       updateAlert(QString::fromStdString(cs.getAlertText1()), QString::fromStdString(cs.getAlertText2()), | 
			
		
	
		
		
			
				
					
					|  |  |  |                   cs.getAlertBlinkingRate(), cs.getAlertType(), cs.getAlertSize(), cs.getAlertSound()); |  |  |  |                   cs.getAlertBlinkingRate(), cs.getAlertType(), cs.getAlertSize(), cs.getAlertSound()); | 
			
		
	
		
		
			
				
					
					|  |  |  |   } else { |  |  |  |     } else if ((sm.frame - s.scene.started_frame) > 10 * UI_FREQ) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |       // Handle controls timeout
 |  |  |  |       // Handle controls timeout
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     if (s.scene.deviceState.getStarted() && (sm.frame - s.scene.started_frame) > 10 * UI_FREQ) { |  |  |  |       if (sm.rcv_frame("controlsState") < s.scene.started_frame) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |       const uint64_t cs_frame = sm.rcv_frame("controlsState"); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       if (cs_frame < s.scene.started_frame) { |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         // car is started, but controlsState hasn't been seen at all
 |  |  |  |         // car is started, but controlsState hasn't been seen at all
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         updateAlert("openpilot Unavailable", "Waiting for controls to start", 0, |  |  |  |         updateAlert("openpilot Unavailable", "Waiting for controls to start", 0, | 
			
		
	
		
		
			
				
					
					|  |  |  |                     "controlsWaiting", cereal::ControlsState::AlertSize::MID, AudibleAlert::NONE); |  |  |  |                     "controlsWaiting", cereal::ControlsState::AlertSize::MID, AudibleAlert::NONE); | 
			
		
	
		
		
			
				
					
					|  |  |  |       } else if ((sm.frame - cs_frame) > 5 * UI_FREQ) { |  |  |  |       } else if ((sm.frame - sm.rcv_frame("controlsState")) > 5 * UI_FREQ) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         // car is started, but controls is lagging or died
 |  |  |  |         // car is started, but controls is lagging or died
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         updateAlert("TAKE CONTROL IMMEDIATELY", "Controls Unresponsive", 0, |  |  |  |         updateAlert("TAKE CONTROL IMMEDIATELY", "Controls Unresponsive", 0, | 
			
		
	
		
		
			
				
					
					|  |  |  |                     "controlsUnresponsive", cereal::ControlsState::AlertSize::FULL, AudibleAlert::CHIME_WARNING_REPEAT); |  |  |  |                     "controlsUnresponsive", cereal::ControlsState::AlertSize::FULL, AudibleAlert::CHIME_WARNING_REPEAT); | 
			
		
	
	
		
		
			
				
					|  |  | @ -97,23 +65,19 @@ void OnroadAlerts::update(const UIState &s) { | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   if (isVisible()) { |  |  |  |   // TODO: add blinking back if performant
 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   //float alpha = 0.375 * cos((millis_since_boot() / 1000) * 2 * M_PI * blinking_rate) + 0.625;
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   auto c = bg_colors[s.status]; |  |  |  |   auto c = bg_colors[s.status]; | 
			
		
	
		
		
			
				
					
					|  |  |  |     float alpha = 0.375 * cos((millis_since_boot() / 1000) * 2 * M_PI * blinking_rate) + 0.625; |  |  |  |   bg.setRgbF(c.r, c.g, c.b, c.a); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     bg.setRgb(c.r*255, c.g*255, c.b*255, c.a*alpha*255); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | void OnroadAlerts::offroadTransition(bool offroad) { |  |  |  | void OnroadAlerts::offroadTransition(bool offroad) { | 
			
		
	
		
		
			
				
					
					|  |  |  |   stopSounds(); |  |  |  |   updateAlert("", "", 0, "", cereal::ControlsState::AlertSize::NONE, AudibleAlert::NONE); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   setVisible(false); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   alert_type = ""; |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | void OnroadAlerts::updateAlert(const QString &text1, const QString &text2, float blink_rate, |  |  |  | void OnroadAlerts::updateAlert(const QString &t1, const QString &t2, float blink_rate, | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                                const std::string &type, cereal::ControlsState::AlertSize size, AudibleAlert sound) { |  |  |  |                                const std::string &type, cereal::ControlsState::AlertSize size, AudibleAlert sound) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |   if (alert_type.compare(type) == 0 && text1.compare(t1) == 0) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   if (alert_type.compare(type) == 0) { |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     return; |  |  |  |     return; | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -122,28 +86,13 @@ void OnroadAlerts::updateAlert(const QString &text1, const QString &text2, float | 
			
		
	
		
		
			
				
					
					|  |  |  |     playSound(sound); |  |  |  |     playSound(sound); | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   text1 = t1; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   text2 = t2; | 
			
		
	
		
		
			
				
					
					|  |  |  |   alert_type = type; |  |  |  |   alert_type = type; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   alert_size = size; | 
			
		
	
		
		
			
				
					
					|  |  |  |   blinking_rate = blink_rate; |  |  |  |   blinking_rate = blink_rate; | 
			
		
	
		
		
			
				
					
					|  |  |  |   title->setText(text1); |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   msg->setText(text2); |  |  |  |   update(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   msg->setVisible(!msg->text().isEmpty()); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   if (size == cereal::ControlsState::AlertSize::SMALL) { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     setFixedHeight(241); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     title->setStyleSheet("font-size: 70px; font-weight: 500;"); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   } else if (size == cereal::ControlsState::AlertSize::MID) { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     setFixedHeight(390); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     msg->setStyleSheet("font-size: 65px; font-weight: 400;"); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     title->setStyleSheet("font-size: 80px; font-weight: 500;"); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   } else if (size == cereal::ControlsState::AlertSize::FULL) { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     setFixedHeight(vwp_h); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     int title_size = (title->text().size() > 15) ? 130 : 110; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     title->setStyleSheet(QString("font-size: %1px; font-weight: 500;").arg(title_size)); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     msg->setStyleSheet("font-size: 90px; font-weight: 400;"); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   setVisible(size != cereal::ControlsState::AlertSize::NONE); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   repaint(); |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | void OnroadAlerts::playSound(AudibleAlert alert) { |  |  |  | void OnroadAlerts::playSound(AudibleAlert alert) { | 
			
		
	
	
		
		
			
				
					|  |  | @ -164,9 +113,57 @@ void OnroadAlerts::stopSounds() { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | void OnroadAlerts::paintEvent(QPaintEvent *event) { |  |  |  | void OnroadAlerts::paintEvent(QPaintEvent *event) { | 
			
		
	
		
		
			
				
					
					|  |  |  |   QPainter p(this); |  |  |  |   QPainter p(this); | 
			
		
	
		
		
			
				
					
					|  |  |  |   p.setBrush(QBrush(bg)); |  |  |  | 
 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   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
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   p.setPen(Qt::NoPen); |  |  |  |   p.setPen(Qt::NoPen); | 
			
		
	
		
		
			
				
					
					|  |  |  |   p.drawRect(rect()); |  |  |  |   p.setCompositionMode(QPainter::CompositionMode_DestinationOver); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   p.setBrush(QBrush(bg)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   p.drawRect(r); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   QLinearGradient g(0, r.y(), 0, r.bottom()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   g.setColorAt(0, QColor::fromRgbF(0, 0, 0, 0.05)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   g.setColorAt(1, QColor::fromRgbF(0, 0, 0, 0.35)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   p.setBrush(QBrush(g)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   p.fillRect(r, g); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   p.setCompositionMode(QPainter::CompositionMode_SourceOver); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   // remove bottom border
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   r = QRect(0, height() - h, width(), h - 30); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   // text
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   const QPoint c = r.center(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   p.setPen(QColor(0xff, 0xff, 0xff)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   p.setRenderHint(QPainter::TextAntialiasing); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   if (alert_size == cereal::ControlsState::AlertSize::SMALL) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     configFont(p, "Open Sans", 74, "SemiBold"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     p.drawText(r, Qt::AlignCenter, text1); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   } else if (alert_size == cereal::ControlsState::AlertSize::MID) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     configFont(p, "Open Sans", 88, "Bold"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     p.drawText(QRect(0, c.y() - 125, width(), 150), Qt::AlignHCenter | Qt::AlignTop, text1); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     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() - 60, 350), Qt::AlignHCenter | Qt::TextWordWrap, text1); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     configFont(p, "Open Sans", 88, "Regular"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     p.drawText(QRect(0, r.height() - (l ? 361 : 420), width() - 60, 300), Qt::AlignHCenter | Qt::TextWordWrap, text2); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | NvgWindow::~NvgWindow() { |  |  |  | NvgWindow::~NvgWindow() { | 
			
		
	
	
		
		
			
				
					|  |  | 
 |