@@ -28,6 +28,9 @@ OnroadWindow::OnroadWindow(QWidget *parent) : QWidget(parent) {
28
28
split->setSpacing (0 );
29
29
split->addWidget (nvg);
30
30
31
+ buttons = new ButtonsWindow (this );
32
+ stacked_layout->addWidget (buttons);
33
+
31
34
stacked_layout->addWidget (split_wrapper);
32
35
33
36
alerts = new OnroadAlerts (this );
@@ -43,6 +46,8 @@ OnroadWindow::OnroadWindow(QWidget *parent) : QWidget(parent) {
43
46
}
44
47
45
48
void OnroadWindow::updateState (const UIState &s) {
49
+ buttons->updateState (s);
50
+
46
51
SubMaster &sm = *(s.sm );
47
52
QColor bgColor = bg_colors[s.status ];
48
53
if (sm.updated (" controlsState" )) {
@@ -100,6 +105,64 @@ void OnroadWindow::paintEvent(QPaintEvent *event) {
100
105
101
106
// ***** onroad widgets *****
102
107
108
+ ButtonsWindow::ButtonsWindow (QWidget *parent) : QWidget(parent) {
109
+ QVBoxLayout *main_layout = new QVBoxLayout (this );
110
+
111
+ QWidget *btns_wrapper = new QWidget;
112
+ QHBoxLayout *btns_layout = new QHBoxLayout (btns_wrapper);
113
+ btns_layout->setSpacing (0 );
114
+ btns_layout->setContentsMargins (0 , 0 , 15 , 15 );
115
+
116
+ main_layout->addWidget (btns_wrapper, 0 , Qt::AlignBottom);
117
+
118
+ // mlButton = new QPushButton("Toggle Model Long");
119
+ // mlButton->setStyleSheet("font-size: 50px; border-radius: 25px; border-color: #b83737;");
120
+ // QObject::connect(mlButton, &QPushButton::clicked, [=]() {
121
+ // mlButton->setStyleSheet("font-size: 50px; border-radius: 25px; border-color: #37b868;");
122
+ // });
123
+ // mlButton->setFixedWidth(525);
124
+ // mlButton->setFixedHeight(150);
125
+ // btns_layout->addStretch();
126
+ // btns_layout->addWidget(mlButton, 0, Qt::AlignCenter);
127
+
128
+ dfButton = new QPushButton (" DF\n profile" );
129
+ QObject::connect (dfButton, &QPushButton::clicked, [=]() {
130
+ QUIState::ui_state.scene .dfButtonStatus = dfStatus < 3 ? dfStatus + 1 : 0 ; // wrap back around
131
+ });
132
+ dfButton->setFixedWidth (200 );
133
+ dfButton->setFixedHeight (200 );
134
+ // btns_layout->addStretch();
135
+ btns_layout->addWidget (dfButton, 0 , Qt::AlignRight);
136
+
137
+ setStyleSheet (R"(
138
+ QPushButton {
139
+ color: white;
140
+ text-align: center;
141
+ padding: 0px;
142
+ border-width: 12px;
143
+ border-style: solid;
144
+ background-color: transparent;
145
+ }
146
+ )" );
147
+ }
148
+
149
+ void ButtonsWindow::updateState (const UIState &s) {
150
+ updateDfButton (s.scene .dfButtonStatus ); // update dynamic follow profile button
151
+ // updateMlButton(s.scene.dfButtonStatus); // update model longitudinal button // TODO: add model long back first
152
+ }
153
+
154
+ void ButtonsWindow::updateDfButton (int status) {
155
+ if (dfStatus != status) { // updates (resets) on car start, or on button press
156
+ dfStatus = status;
157
+ dfButton->setStyleSheet (QString (" font-size: 45px; border-radius: 100px; border-color: %1" ).arg (dfButtonColors.at (dfStatus)));
158
+
159
+ MessageBuilder msg;
160
+ auto dfButtonStatus = msg.initEvent ().initDynamicFollowButton ();
161
+ dfButtonStatus.setStatus (dfStatus);
162
+ QUIState::ui_state.pm ->send (" dynamicFollowButton" , msg);
163
+ }
164
+ }
165
+
103
166
void OnroadAlerts::updateAlert (const Alert &a, const QColor &color) {
104
167
if (!alert.equal (a) || color != bg) {
105
168
alert = a;
0 commit comments