This commit is contained in:
Your Name
2024-04-27 13:43:16 -05:00
parent 21363ce751
commit ea1aad5ed1
128 changed files with 3533 additions and 1918 deletions

3
selfdrive/ui/qt/widgets/cameraview.cc Executable file → Normal file
View File

@@ -41,6 +41,8 @@ const char frame_fragment_shader[] =
"out vec4 colorOut;\n"
"void main() {\n"
" colorOut = texture(uTexture, vTexCoord);\n"
// gamma to improve worst case visibility when dark
" colorOut.rgb = pow(colorOut.rgb, vec3(1.0/1.28));\n"
"}\n";
#else
#ifdef __APPLE__
@@ -217,7 +219,6 @@ void CameraWidget::updateFrameMat() {
if (active_stream_type == VISION_STREAM_DRIVER) {
if (stream_width > 0 && stream_height > 0) {
frame_mat = get_driver_view_transform(w, h, stream_width, stream_height);
frame_mat.v[0] *= -1.0;
}
} else {
// Project point at "infinity" to compute x and y offsets

0
selfdrive/ui/qt/widgets/cameraview.h Executable file → Normal file
View File

0
selfdrive/ui/qt/widgets/controls.cc Executable file → Normal file
View File

29
selfdrive/ui/qt/widgets/controls.h Executable file → Normal file
View File

@@ -127,15 +127,15 @@ public:
QObject::connect(&toggle, &Toggle::stateChanged, this, &ToggleControl::toggleFlipped);
}
void setVisualOn() {
toggle.togglePosition();
}
void setEnabled(bool enabled) {
toggle.setEnabled(enabled);
toggle.update();
}
void refresh() {
toggle.togglePosition();
}
signals:
void toggleFlipped(bool state);
@@ -206,7 +206,7 @@ public:
background-color: #4a4a4a;
}
QPushButton:checked:enabled {
background-color: #0048FF;
background-color: #33Ab4C;
}
QPushButton:disabled {
color: #33E4E4E4;
@@ -227,10 +227,8 @@ public:
button_group->addButton(button, i);
}
QObject::connect(button_group, QOverload<int, bool>::of(&QButtonGroup::buttonToggled), [=](int id, bool checked) {
if (checked) {
params.put(key, std::to_string(id));
}
QObject::connect(button_group, QOverload<int>::of(&QButtonGroup::buttonClicked), [=](int id) {
params.put(key, std::to_string(id));
});
}
@@ -240,6 +238,19 @@ public:
}
}
void setCheckedButton(int id) {
button_group->button(id)->setChecked(true);
}
void refresh() {
int value = atoi(params.get(key).c_str());
button_group->button(value)->setChecked(true);
}
void showEvent(QShowEvent *event) override {
refresh();
}
private:
std::string key;
Params params;

40
selfdrive/ui/qt/widgets/drive_stats.cc Executable file → Normal file
View File

@@ -5,7 +5,6 @@
#include <QJsonObject>
#include <QVBoxLayout>
#include "common/params.h"
#include "selfdrive/ui/qt/request_repeater.h"
#include "selfdrive/ui/qt/util.h"
@@ -16,19 +15,19 @@ static QLabel* newLabel(const QString& text, const QString &type) {
}
DriveStats::DriveStats(QWidget* parent) : QFrame(parent) {
metric_ = Params().getBool("IsMetric");
metric_ = params.getBool("IsMetric");
QVBoxLayout* main_layout = new QVBoxLayout(this);
main_layout->setContentsMargins(50, 50, 50, 60);
main_layout->setContentsMargins(50, 25, 50, 20);
auto add_stats_layouts = [=](const QString &title, StatsLabels& labels) {
auto add_stats_layouts = [=](const QString &title, StatsLabels& labels, bool FrogPilot=false) {
QGridLayout* grid_layout = new QGridLayout;
grid_layout->setVerticalSpacing(10);
grid_layout->setContentsMargins(0, 10, 0, 10);
int row = 0;
grid_layout->addWidget(newLabel(title, "title"), row++, 0, 1, 3);
grid_layout->addItem(new QSpacerItem(0, 50), row++, 0, 1, 1);
grid_layout->addWidget(newLabel(title, FrogPilot ? "frogpilot_title" : "title"), row++, 0, 1, 3);
grid_layout->addItem(new QSpacerItem(0, 10), row++, 0, 1, 1);
grid_layout->addWidget(labels.routes = newLabel("0", "number"), row, 0, Qt::AlignLeft);
grid_layout->addWidget(labels.distance = newLabel("0", "number"), row, 1, Qt::AlignLeft);
@@ -39,11 +38,12 @@ DriveStats::DriveStats(QWidget* parent) : QFrame(parent) {
grid_layout->addWidget(newLabel(tr("Hours"), "unit"), row + 1, 2, Qt::AlignLeft);
main_layout->addLayout(grid_layout);
main_layout->addStretch(1);
};
add_stats_layouts(tr("ALL TIME"), all_);
main_layout->addStretch();
add_stats_layouts(tr("PAST WEEK"), week_);
add_stats_layouts(tr("FROGPILOT"), frogPilot_, true);
if (auto dongleId = getDongleId()) {
QString url = CommaApi::BASE_URL + "/v1.1/devices/" + *dongleId + "/stats";
@@ -57,13 +57,25 @@ DriveStats::DriveStats(QWidget* parent) : QFrame(parent) {
border-radius: 10px;
}
QLabel[type="title"] { font-size: 51px; font-weight: 500; }
QLabel[type="number"] { font-size: 78px; font-weight: 500; }
QLabel[type="unit"] { font-size: 51px; font-weight: 300; color: #A0A0A0; }
QLabel[type="title"] { font-size: 50px; font-weight: 500; }
QLabel[type="frogpilot_title"] { font-size: 50px; font-weight: 500; color: #178643; }
QLabel[type="number"] { font-size: 65px; font-weight: 400; }
QLabel[type="unit"] { font-size: 50px; font-weight: 300; color: #A0A0A0; }
)");
}
void DriveStats::updateStats() {
QJsonObject json = stats_.object();
auto updateFrogPilot = [this](const QJsonObject& obj, StatsLabels& labels) {
labels.routes->setText(QString::number(paramsStorage.getInt("FrogPilotDrives")));
labels.distance->setText(QString::number(int(paramsStorage.getFloat("FrogPilotKilometers") * (metric_ ? 1 : KM_TO_MILE))));
labels.distance_unit->setText(getDistanceUnit());
labels.hours->setText(QString::number(int(paramsStorage.getFloat("FrogPilotMinutes") / 60)));
};
updateFrogPilot(json["frogpilot"].toObject(), frogPilot_);
auto update = [=](const QJsonObject& obj, StatsLabels& labels) {
labels.routes->setText(QString::number((int)obj["routes"].toDouble()));
labels.distance->setText(QString::number(int(obj["distance"].toDouble() * (metric_ ? MILE_TO_KM : 1))));
@@ -71,7 +83,6 @@ void DriveStats::updateStats() {
labels.hours->setText(QString::number((int)(obj["minutes"].toDouble() / 60)));
};
QJsonObject json = stats_.object();
update(json["all"].toObject(), all_);
update(json["week"].toObject(), week_);
}
@@ -89,9 +100,6 @@ void DriveStats::parseResponse(const QString& response, bool success) {
}
void DriveStats::showEvent(QShowEvent* event) {
bool metric = Params().getBool("IsMetric");
if (metric_ != metric) {
metric_ = metric;
updateStats();
}
metric_ = params.getBool("IsMetric");
updateStats();
}

6
selfdrive/ui/qt/widgets/drive_stats.h Executable file → Normal file
View File

@@ -3,6 +3,8 @@
#include <QJsonDocument>
#include <QLabel>
#include "common/params.h"
class DriveStats : public QFrame {
Q_OBJECT
@@ -15,10 +17,12 @@ private:
inline QString getDistanceUnit() const { return metric_ ? tr("KM") : tr("Miles"); }
bool metric_;
Params params;
Params paramsStorage{"/persist/params"};
QJsonDocument stats_;
struct StatsLabels {
QLabel *routes, *distance, *distance_unit, *hours;
} all_, week_;
} all_, week_, frogPilot_;
private slots:
void parseResponse(const QString &response, bool success);

0
selfdrive/ui/qt/widgets/input.cc Executable file → Normal file
View File

0
selfdrive/ui/qt/widgets/input.h Executable file → Normal file
View File

0
selfdrive/ui/qt/widgets/keyboard.cc Executable file → Normal file
View File

0
selfdrive/ui/qt/widgets/keyboard.h Executable file → Normal file
View File

10
selfdrive/ui/qt/widgets/offroad_alerts.cc Executable file → Normal file
View File

@@ -37,13 +37,9 @@ AbstractAlert::AbstractAlert(bool hasRebootBtn, QWidget *parent) : QFrame(parent
disable_check_btn->setFixedSize(625, 125);
footer_layout->addWidget(disable_check_btn, 1, Qt::AlignBottom | Qt::AlignCenter);
QObject::connect(disable_check_btn, &QPushButton::clicked, [=]() {
if (!params.getBool("FireTheBabysitter")) {
params.putBool("FireTheBabysitter", true);
}
if (!params.getBool("OfflineMode")) {
params.putBool("OfflineMode", true);
}
Hardware::reboot();
params.putBool("SnoozeUpdate", true);
params.putBool("DeviceManagement", true);
params.putBool("OfflineMode", true);
});
QObject::connect(disable_check_btn, &QPushButton::clicked, this, &AbstractAlert::dismiss);
disable_check_btn->setStyleSheet(R"(color: white; background-color: #4F4F4F;)");

0
selfdrive/ui/qt/widgets/offroad_alerts.h Executable file → Normal file
View File

0
selfdrive/ui/qt/widgets/prime.cc Executable file → Normal file
View File

0
selfdrive/ui/qt/widgets/prime.h Executable file → Normal file
View File

0
selfdrive/ui/qt/widgets/scrollview.cc Executable file → Normal file
View File

1
selfdrive/ui/qt/widgets/scrollview.h Executable file → Normal file
View File

@@ -10,6 +10,7 @@ public:
// FrogPilot functions
void restorePosition(int previousScrollPosition);
protected:
void hideEvent(QHideEvent *e) override;
};

0
selfdrive/ui/qt/widgets/ssh_keys.cc Executable file → Normal file
View File

0
selfdrive/ui/qt/widgets/ssh_keys.h Executable file → Normal file
View File

2
selfdrive/ui/qt/widgets/toggle.cc Executable file → Normal file
View File

@@ -75,7 +75,7 @@ void Toggle::setEnabled(bool value) {
enabled = value;
if (value) {
circleColor.setRgb(0xfafafa);
green.setRgb(0x0048FF);
green.setRgb(0x33ab4c);
} else {
circleColor.setRgb(0x888888);
green.setRgb(0x227722);

0
selfdrive/ui/qt/widgets/toggle.h Executable file → Normal file
View File

31
selfdrive/ui/qt/widgets/wifi.cc Executable file → Normal file
View File

@@ -81,6 +81,34 @@ WiFiPromptWidget::WiFiPromptWidget(QWidget *parent) : QFrame(parent) {
}
stack->addWidget(uploading);
QWidget *notUploading = new QWidget;
QVBoxLayout *not_uploading_layout = new QVBoxLayout(notUploading);
not_uploading_layout->setContentsMargins(64, 56, 64, 56);
not_uploading_layout->setSpacing(36);
{
QHBoxLayout *title_layout = new QHBoxLayout;
{
QLabel *title = new QLabel(tr("Uploading disabled"));
title->setStyleSheet("font-size: 64px; font-weight: 600;");
title->setWordWrap(true);
title->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
title_layout->addWidget(title);
title_layout->addStretch();
QLabel *icon = new QLabel;
QPixmap pixmap("../frogpilot/assets/other_images/icon_wifi_uploading_disabled.svg");
icon->setPixmap(pixmap.scaledToWidth(120, Qt::SmoothTransformation));
title_layout->addWidget(icon);
}
not_uploading_layout->addLayout(title_layout);
QLabel *desc = new QLabel(tr("Toggle off the 'Disable Uploading' toggle to enable uploads."));
desc->setStyleSheet("font-size: 48px; font-weight: 400;");
desc->setWordWrap(true);
not_uploading_layout->addWidget(desc);
}
stack->addWidget(notUploading);
setStyleSheet(R"(
WiFiPromptWidget {
background-color: #333333;
@@ -99,5 +127,6 @@ void WiFiPromptWidget::updateState(const UIState &s) {
auto network_type = sm["deviceState"].getDeviceState().getNetworkType();
auto uploading = network_type == cereal::DeviceState::NetworkType::WIFI ||
network_type == cereal::DeviceState::NetworkType::ETHERNET;
stack->setCurrentIndex(uploading ? 1 : 0);
bool uploading_disabled = params.getBool("DeviceManagement") && params.getBool("NoUploads");
stack->setCurrentIndex(uploading_disabled ? 2 : uploading ? 1 : 0);
}

4
selfdrive/ui/qt/widgets/wifi.h Executable file → Normal file
View File

@@ -18,6 +18,10 @@ signals:
public slots:
void updateState(const UIState &s);
private:
// FrogPilot variables
Params params;
protected:
QStackedLayout *stack;
};