commit
9b6b1a0b7d
62 changed files with 705 additions and 232 deletions
@ -1 +1 @@ |
||||
Subproject commit afafa0a2a537d775842ab2e1bf20cb9a33b34f9a |
||||
Subproject commit 3bae09cf6527674d7eda3a9956242aad94a8f3d2 |
@ -1 +1 @@ |
||||
#define COMMA_VERSION "0.8.17" |
||||
#define COMMA_VERSION "0.9.0" |
||||
|
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.8 KiB |
@ -1 +1 @@ |
||||
aa2d370836588fd80b648dbed8d156765ec804d5 |
||||
959e63af52d9efdb62156cab4b773f88b154fd75 |
||||
|
@ -0,0 +1,75 @@ |
||||
#include "selfdrive/ui/qt/offroad/experimental_mode.h" |
||||
|
||||
#include <QDebug> |
||||
#include <QHBoxLayout> |
||||
#include <QPainter> |
||||
#include <QStyle> |
||||
|
||||
#include "selfdrive/ui/ui.h" |
||||
|
||||
ExperimentalModeButton::ExperimentalModeButton(QWidget *parent) : QPushButton(parent) { |
||||
chill_pixmap = QPixmap("../assets/img_couch.svg").scaledToWidth(img_width, Qt::SmoothTransformation); |
||||
experimental_pixmap = QPixmap("../assets/img_experimental_grey.svg").scaledToWidth(img_width, Qt::SmoothTransformation); |
||||
|
||||
// go to toggles and expand experimental mode description
|
||||
connect(this, &QPushButton::clicked, [=]() { emit openSettings(2, "ExperimentalMode"); }); |
||||
|
||||
setFixedHeight(125); |
||||
QHBoxLayout *main_layout = new QHBoxLayout; |
||||
main_layout->setContentsMargins(horizontal_padding, 0, horizontal_padding, 0); |
||||
|
||||
mode_label = new QLabel; |
||||
mode_icon = new QLabel; |
||||
mode_icon->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
||||
|
||||
main_layout->addWidget(mode_label, 1, Qt::AlignLeft); |
||||
main_layout->addWidget(mode_icon, 0, Qt::AlignRight); |
||||
|
||||
setLayout(main_layout); |
||||
|
||||
setStyleSheet(R"( |
||||
QPushButton { |
||||
border: none; |
||||
} |
||||
|
||||
QLabel { |
||||
font-size: 45px; |
||||
font-weight: 300; |
||||
text-align: left; |
||||
font-family: JetBrainsMono; |
||||
color: #000000; |
||||
} |
||||
)"); |
||||
} |
||||
|
||||
void ExperimentalModeButton::paintEvent(QPaintEvent *event) { |
||||
QPainter p(this); |
||||
p.setPen(Qt::NoPen); |
||||
p.setRenderHint(QPainter::Antialiasing); |
||||
|
||||
QPainterPath path; |
||||
path.addRoundedRect(rect(), 10, 10); |
||||
|
||||
// gradient
|
||||
bool pressed = isDown(); |
||||
QLinearGradient gradient(rect().left(), 0, rect().right(), 0); |
||||
if (experimental_mode) { |
||||
gradient.setColorAt(0, QColor(255, 155, 63, pressed ? 0xcc : 0xff)); |
||||
gradient.setColorAt(1, QColor(219, 56, 34, pressed ? 0xcc : 0xff)); |
||||
} else { |
||||
gradient.setColorAt(0, QColor(20, 255, 171, pressed ? 0xcc : 0xff)); |
||||
gradient.setColorAt(1, QColor(35, 149, 255, pressed ? 0xcc : 0xff)); |
||||
} |
||||
p.fillPath(path, gradient); |
||||
|
||||
// vertical line
|
||||
p.setPen(QPen(QColor(0, 0, 0, 0x4d), 3, Qt::SolidLine)); |
||||
int line_x = rect().right() - img_width - (2 * horizontal_padding); |
||||
p.drawLine(line_x, rect().bottom(), line_x, rect().top()); |
||||
} |
||||
|
||||
void ExperimentalModeButton::showEvent(QShowEvent *event) { |
||||
experimental_mode = params.getBool("ExperimentalMode"); |
||||
mode_icon->setPixmap(experimental_mode ? experimental_pixmap : chill_pixmap); |
||||
mode_label->setText(experimental_mode ? tr("EXPERIMENTAL MODE ON") : tr("CHILL MODE ON")); |
||||
} |
@ -0,0 +1,31 @@ |
||||
#pragma once |
||||
|
||||
#include <QLabel> |
||||
#include <QPushButton> |
||||
|
||||
#include "common/params.h" |
||||
|
||||
class ExperimentalModeButton : public QPushButton { |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit ExperimentalModeButton(QWidget* parent = 0); |
||||
|
||||
signals: |
||||
void openSettings(int index = 0, const QString &toggle = ""); |
||||
|
||||
private: |
||||
void showEvent(QShowEvent *event) override; |
||||
|
||||
Params params; |
||||
bool experimental_mode; |
||||
int img_width = 100; |
||||
int horizontal_padding = 30; |
||||
QPixmap experimental_pixmap; |
||||
QPixmap chill_pixmap; |
||||
QLabel *mode_label; |
||||
QLabel *mode_icon; |
||||
|
||||
protected: |
||||
void paintEvent(QPaintEvent *event) override; |
||||
}; |
Loading…
Reference in new issue