Not just parents, we also made the UI look nicer. 
old-commit-hash: 2eb81aa1d3
commatwo_master
grekiki 4 years ago committed by GitHub
parent 7bf38e240c
commit eea78cd686
  1. 16
      selfdrive/ui/qt/api.cc
  2. 3
      selfdrive/ui/qt/api.hpp
  3. 2
      selfdrive/ui/qt/offroad/onboarding.cc
  4. 65
      selfdrive/ui/qt/offroad/settings.cc
  5. 1
      selfdrive/ui/qt/offroad/settings.hpp
  6. 66
      selfdrive/ui/qt/offroad/wifi.cc
  7. 10
      selfdrive/ui/qt/widgets/drive_stats.cc
  8. 15
      selfdrive/ui/qt/widgets/input_field.cc
  9. 2
      selfdrive/ui/qt/widgets/keyboard.cc
  10. 15
      selfdrive/ui/qt/widgets/offroad_alerts.cc
  11. 58
      selfdrive/ui/qt/widgets/setup.cc

@ -44,11 +44,14 @@ QByteArray CommaApi::rsa_sign(QByteArray data) {
} }
QString CommaApi::create_jwt(QVector<QPair<QString, QJsonValue>> payloads, int expiry) { QString CommaApi::create_jwt(QVector<QPair<QString, QJsonValue>> payloads, int expiry) {
QString dongle_id = QString::fromStdString(Params().get("DongleId"));
QJsonObject header; QJsonObject header;
header.insert("alg", "RS256"); header.insert("alg", "RS256");
QJsonObject payload; QJsonObject payload;
QString dongle_id = QString::fromStdString(Params().get("DongleId"));
payload.insert("identity", dongle_id); payload.insert("identity", dongle_id);
auto t = QDateTime::currentSecsSinceEpoch(); auto t = QDateTime::currentSecsSinceEpoch();
payload.insert("nbf", t); payload.insert("nbf", t);
payload.insert("iat", t); payload.insert("iat", t);
@ -56,10 +59,12 @@ QString CommaApi::create_jwt(QVector<QPair<QString, QJsonValue>> payloads, int e
for (auto load : payloads) { for (auto load : payloads) {
payload.insert(load.first, load.second); payload.insert(load.first, load.second);
} }
QString jwt = QString jwt =
QJsonDocument(header).toJson(QJsonDocument::Compact).toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals) + QJsonDocument(header).toJson(QJsonDocument::Compact).toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals) +
'.' + '.' +
QJsonDocument(payload).toJson(QJsonDocument::Compact).toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals); QJsonDocument(payload).toJson(QJsonDocument::Compact).toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals);
auto hash = QCryptographicHash::hash(jwt.toUtf8(), QCryptographicHash::Sha256); auto hash = QCryptographicHash::hash(jwt.toUtf8(), QCryptographicHash::Sha256);
auto sig = rsa_sign(hash); auto sig = rsa_sign(hash);
jwt += '.' + sig.toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals); jwt += '.' + sig.toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals);
@ -71,11 +76,13 @@ QString CommaApi::create_jwt() {
} }
RequestRepeater::RequestRepeater(QWidget* parent, QString requestURL, int period_seconds, QVector<QPair<QString, QJsonValue>> payloads, bool disableWithScreen) RequestRepeater::RequestRepeater(QWidget* parent, QString requestURL, int period_seconds, QVector<QPair<QString, QJsonValue>> payloads, bool disableWithScreen)
: disableWithScreen(disableWithScreen) { : disableWithScreen(disableWithScreen), QObject(parent) {
networkAccessManager = new QNetworkAccessManager(parent); networkAccessManager = new QNetworkAccessManager(this);
QTimer* timer = new QTimer(this); QTimer* timer = new QTimer(this);
QObject::connect(timer, &QTimer::timeout, [=](){sendRequest(requestURL, payloads);}); QObject::connect(timer, &QTimer::timeout, [=](){sendRequest(requestURL, payloads);});
timer->start(period_seconds * 1000); timer->start(period_seconds * 1000);
networkTimer = new QTimer(this); networkTimer = new QTimer(this);
networkTimer->setSingleShot(true); networkTimer->setSingleShot(true);
networkTimer->setInterval(20000); // 20s before aborting networkTimer->setInterval(20000); // 20s before aborting
@ -94,12 +101,13 @@ void RequestRepeater::sendRequest(QString requestURL, QVector<QPair<QString, QJs
return; return;
} }
aborted = false; aborted = false;
callId = QRandomGenerator::global()->bounded(1000);
QString token = CommaApi::create_jwt(payloads); QString token = CommaApi::create_jwt(payloads);
QNetworkRequest request; QNetworkRequest request;
request.setUrl(QUrl(requestURL)); request.setUrl(QUrl(requestURL));
request.setRawHeader("Authorization", ("JWT " + token).toUtf8()); request.setRawHeader("Authorization", ("JWT " + token).toUtf8());
reply = networkAccessManager->get(request); reply = networkAccessManager->get(request);
networkTimer->start(); networkTimer->start();
connect(reply, SIGNAL(finished()), this, SLOT(requestFinished())); connect(reply, SIGNAL(finished()), this, SLOT(requestFinished()));
} }

@ -32,7 +32,6 @@ public:
bool active = true; bool active = true;
private: private:
bool disableWithScreen; bool disableWithScreen;
int callId;
QNetworkReply* reply; QNetworkReply* reply;
QNetworkAccessManager* networkAccessManager; QNetworkAccessManager* networkAccessManager;
QTimer* networkTimer; QTimer* networkTimer;
@ -44,4 +43,4 @@ private slots:
signals: signals:
void receivedResponse(QString response); void receivedResponse(QString response);
void failedResponse(QString errorString); void failedResponse(QString errorString);
}; };

@ -92,7 +92,7 @@ void OnboardingWindow::updateActiveScreen() {
} }
} }
OnboardingWindow::OnboardingWindow(QWidget *parent) { OnboardingWindow::OnboardingWindow(QWidget *parent) : QStackedWidget(parent) {
addWidget(terms_screen()); addWidget(terms_screen());
addWidget(training_screen()); addWidget(training_screen());

@ -18,6 +18,23 @@
#include "common/params.h" #include "common/params.h"
#include "common/util.h" #include "common/util.h"
QFrame* horizontal_line(QWidget* parent = 0){
QFrame* line = new QFrame(parent);
line->setFrameShape(QFrame::StyledPanel);
line->setStyleSheet("margin-left: 40px; margin-right: 40px; border-width: 1px; border-bottom-style: solid; border-color: gray;");
line->setFixedHeight(2);
return line;
}
QWidget* labelWidget(QString labelName, QString labelContent){
QHBoxLayout* labelLayout = new QHBoxLayout;
labelLayout->addWidget(new QLabel(labelName), 0, Qt::AlignLeft);
QLabel* paramContent = new QLabel(labelContent);
paramContent->setStyleSheet("color: #aaaaaa");
labelLayout->addWidget(paramContent, 0, Qt::AlignRight);
QWidget* labelWidget = new QWidget;
labelWidget->setLayout(labelLayout);
return labelWidget;
}
ParamsToggle::ParamsToggle(QString param, QString title, QString description, QString icon_path, QWidget *parent): QFrame(parent) , param(param) { ParamsToggle::ParamsToggle(QString param, QString title, QString description, QString icon_path, QWidget *parent): QFrame(parent) , param(param) {
QHBoxLayout *layout = new QHBoxLayout; QHBoxLayout *layout = new QHBoxLayout;
@ -61,38 +78,43 @@ void ParamsToggle::checkboxClicked(int state) {
QWidget * toggles_panel() { QWidget * toggles_panel() {
QVBoxLayout *toggles_list = new QVBoxLayout(); QVBoxLayout *toggles_list = new QVBoxLayout();
toggles_list->setMargin(50); toggles_list->setMargin(50);
toggles_list->setSpacing(25);
toggles_list->addWidget(new ParamsToggle("OpenpilotEnabledToggle", toggles_list->addWidget(new ParamsToggle("OpenpilotEnabledToggle",
"Enable openpilot", "Enable openpilot",
"Use the openpilot system for adaptive cruise control and lane keep driver assistance. Your attention is required at all times to use this feature. Changing this setting takes effect when the car is powered off.", "Use the openpilot system for adaptive cruise control and lane keep driver assistance. Your attention is required at all times to use this feature. Changing this setting takes effect when the car is powered off.",
"../assets/offroad/icon_openpilot.png" "../assets/offroad/icon_openpilot.png"
)); ));
toggles_list->addWidget(horizontal_line());
toggles_list->addWidget(new ParamsToggle("LaneChangeEnabled", toggles_list->addWidget(new ParamsToggle("LaneChangeEnabled",
"Enable Lane Change Assist", "Enable Lane Change Assist",
"Perform assisted lane changes with openpilot by checking your surroundings for safety, activating the turn signal and gently nudging the steering wheel towards your desired lane. openpilot is not capable of checking if a lane change is safe. You must continuously observe your surroundings to use this feature.", "Perform assisted lane changes with openpilot by checking your surroundings for safety, activating the turn signal and gently nudging the steering wheel towards your desired lane. openpilot is not capable of checking if a lane change is safe. You must continuously observe your surroundings to use this feature.",
"../assets/offroad/icon_road.png" "../assets/offroad/icon_road.png"
)); ));
toggles_list->addWidget(horizontal_line());
toggles_list->addWidget(new ParamsToggle("IsLdwEnabled", toggles_list->addWidget(new ParamsToggle("IsLdwEnabled",
"Enable Lane Departure Warnings", "Enable Lane Departure Warnings",
"Receive alerts to steer back into the lane when your vehicle drifts over a detected lane line without a turn signal activated while driving over 31mph (50kph).", "Receive alerts to steer back into the lane when your vehicle drifts over a detected lane line without a turn signal activated while driving over 31mph (50kph).",
"../assets/offroad/icon_warning.png" "../assets/offroad/icon_warning.png"
)); ));
toggles_list->addWidget(horizontal_line());
toggles_list->addWidget(new ParamsToggle("RecordFront", toggles_list->addWidget(new ParamsToggle("RecordFront",
"Record and Upload Driver Camera", "Record and Upload Driver Camera",
"Upload data from the driver facing camera and help improve the driver monitoring algorithm.", "Upload data from the driver facing camera and help improve the driver monitoring algorithm.",
"../assets/offroad/icon_network.png" "../assets/offroad/icon_network.png"
)); ));
toggles_list->addWidget(horizontal_line());
toggles_list->addWidget(new ParamsToggle("IsRHD", toggles_list->addWidget(new ParamsToggle("IsRHD",
"Enable Right-Hand Drive", "Enable Right-Hand Drive",
"Allow openpilot to obey left-hand traffic conventions and perform driver monitoring on right driver seat.", "Allow openpilot to obey left-hand traffic conventions and perform driver monitoring on right driver seat.",
"../assets/offroad/icon_openpilot_mirrored.png" "../assets/offroad/icon_openpilot_mirrored.png"
)); ));
toggles_list->addWidget(horizontal_line());
toggles_list->addWidget(new ParamsToggle("IsMetric", toggles_list->addWidget(new ParamsToggle("IsMetric",
"Use Metric System", "Use Metric System",
"Display speed in km/h instead of mp/h.", "Display speed in km/h instead of mp/h.",
"../assets/offroad/icon_metric.png" "../assets/offroad/icon_metric.png"
)); ));
toggles_list->addWidget(horizontal_line());
toggles_list->addWidget(new ParamsToggle("CommunityFeaturesToggle", toggles_list->addWidget(new ParamsToggle("CommunityFeaturesToggle",
"Enable Community Features", "Enable Community Features",
"Use features from the open source community that are not maintained or supported by comma.ai and have not been confirmed to meet the standard safety model. These features include community supported cars and community supported hardware. Be extra cautious when using these features", "Use features from the open source community that are not maintained or supported by comma.ai and have not been confirmed to meet the standard safety model. These features include community supported cars and community supported hardware. Be extra cautious when using these features",
@ -108,7 +130,7 @@ QWidget * device_panel() {
QVBoxLayout *device_layout = new QVBoxLayout; QVBoxLayout *device_layout = new QVBoxLayout;
device_layout->setMargin(100); device_layout->setMargin(100);
device_layout->setSpacing(50); device_layout->setSpacing(30);
Params params = Params(); Params params = Params();
std::vector<std::pair<std::string, std::string>> labels = { std::vector<std::pair<std::string, std::string>> labels = {
@ -123,21 +145,23 @@ QWidget * device_panel() {
//} //}
for (auto &l : labels) { for (auto &l : labels) {
QString text = QString::fromStdString(l.first + ": " + l.second); device_layout->addWidget(labelWidget(QString::fromStdString(l.first+":"), QString::fromStdString(l.second)), 0, Qt::AlignTop);
device_layout->addWidget(new QLabel(text));
} }
// TODO: show current calibration values // TODO: show current calibration values
QPushButton *clear_cal_btn = new QPushButton("Reset Calibration"); QPushButton *clear_cal_btn = new QPushButton("Reset Calibration");
device_layout->addWidget(clear_cal_btn); device_layout->addWidget(clear_cal_btn, 0, Qt::AlignBottom);
device_layout->addWidget(horizontal_line(), Qt::AlignBottom);
QObject::connect(clear_cal_btn, &QPushButton::released, [=]() { QObject::connect(clear_cal_btn, &QPushButton::released, [=]() {
Params().delete_db_value("CalibrationParams"); Params().delete_db_value("CalibrationParams");
}); });
QPushButton *poweroff_btn = new QPushButton("Power Off"); QPushButton *poweroff_btn = new QPushButton("Power Off");
device_layout->addWidget(poweroff_btn); device_layout->addWidget(poweroff_btn, Qt::AlignBottom);
device_layout->addWidget(horizontal_line(), Qt::AlignBottom);
QPushButton *reboot_btn = new QPushButton("Reboot"); QPushButton *reboot_btn = new QPushButton("Reboot");
device_layout->addWidget(reboot_btn); device_layout->addWidget(reboot_btn, Qt::AlignBottom);
device_layout->addWidget(horizontal_line(), Qt::AlignBottom);
#ifdef __aarch64__ #ifdef __aarch64__
QObject::connect(poweroff_btn, &QPushButton::released, [=]() { std::system("sudo poweroff"); }); QObject::connect(poweroff_btn, &QPushButton::released, [=]() { std::system("sudo poweroff"); });
QObject::connect(reboot_btn, &QPushButton::released, [=]() { std::system("sudo reboot"); }); QObject::connect(reboot_btn, &QPushButton::released, [=]() { std::system("sudo reboot"); });
@ -181,9 +205,13 @@ QWidget * developer_panel() {
labels.push_back({"OS Version", "AGNOS " + os_version}); labels.push_back({"OS Version", "AGNOS " + os_version});
} }
for (auto l : labels) { for (int i = 0; i<labels.size(); i++) {
QString text = QString::fromStdString(l.first + ": " + l.second); auto l = labels[i];
main_layout->addWidget(new QLabel(text)); main_layout->addWidget(labelWidget(QString::fromStdString(l.first+":"), QString::fromStdString(l.second)));
if(i+1<labels.size()) {
main_layout->addWidget(horizontal_line());
}
} }
QWidget *widget = new QWidget; QWidget *widget = new QWidget;
@ -197,7 +225,7 @@ QWidget * developer_panel() {
} }
QWidget * network_panel(QWidget * parent) { QWidget * network_panel(QWidget * parent) {
Networking *w = new Networking(); Networking *w = new Networking(parent);
QObject::connect(parent, SIGNAL(sidebarPressed()), w, SLOT(sidebarChange())); QObject::connect(parent, SIGNAL(sidebarPressed()), w, SLOT(sidebarChange()));
QObject::connect(w, SIGNAL(openKeyboard()), parent, SLOT(closeSidebar())); QObject::connect(w, SIGNAL(openKeyboard()), parent, SLOT(closeSidebar()));
QObject::connect(w, SIGNAL(closeKeyboard()), parent, SLOT(openSidebar())); QObject::connect(w, SIGNAL(closeKeyboard()), parent, SLOT(openSidebar()));
@ -227,7 +255,7 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) {
)"); )");
close_btn->setFixedSize(200, 200); close_btn->setFixedSize(200, 200);
sidebar_layout->addSpacing(45); sidebar_layout->addSpacing(45);
sidebar_layout->addWidget(close_btn, 0, Qt::AlignLeft); sidebar_layout->addWidget(close_btn, 0, Qt::AlignCenter);
QObject::connect(close_btn, SIGNAL(released()), this, SIGNAL(closeSettings())); QObject::connect(close_btn, SIGNAL(released()), this, SIGNAL(closeSettings()));
// setup panels // setup panels
@ -259,25 +287,24 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) {
)"); )");
nav_btns->addButton(btn); nav_btns->addButton(btn);
sidebar_layout->addWidget(btn, 0, Qt::AlignRight | Qt::AlignTop); sidebar_layout->addWidget(btn, 0, Qt::AlignRight);
panel_layout->addWidget(panel.second); panel_layout->addWidget(panel.second);
QObject::connect(btn, SIGNAL(released()), this, SLOT(setActivePanel())); QObject::connect(btn, SIGNAL(released()), this, SLOT(setActivePanel()));
QObject::connect(btn, &QPushButton::released, [=](){emit sidebarPressed();}); QObject::connect(btn, &QPushButton::released, [=](){emit sidebarPressed();});
} }
qobject_cast<QPushButton *>(nav_btns->buttons()[0])->setChecked(true); qobject_cast<QPushButton *>(nav_btns->buttons()[0])->setChecked(true);
sidebar_layout->addStretch(); sidebar_layout->setContentsMargins(50, 50, 100, 50);
// main settings layout, sidebar + main panel // main settings layout, sidebar + main panel
QHBoxLayout *settings_layout = new QHBoxLayout(); QHBoxLayout *settings_layout = new QHBoxLayout();
settings_layout->setContentsMargins(150, 50, 150, 50);
sidebar_widget = new QWidget; sidebar_widget = new QWidget;
sidebar_widget->setLayout(sidebar_layout); sidebar_widget->setLayout(sidebar_layout);
sidebar_widget->setFixedWidth(500);
settings_layout->addWidget(sidebar_widget); settings_layout->addWidget(sidebar_widget);
settings_layout->addSpacing(25);
QFrame *panel_frame = new QFrame; panel_frame = new QFrame;
panel_frame->setLayout(panel_layout); panel_frame->setLayout(panel_layout);
panel_frame->setStyleSheet(R"( panel_frame->setStyleSheet(R"(
QFrame { QFrame {
@ -288,7 +315,7 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) {
background-color: none; background-color: none;
} }
)"); )");
settings_layout->addWidget(panel_frame, 1, Qt::AlignRight); settings_layout->addWidget(panel_frame);
setLayout(settings_layout); setLayout(settings_layout);
setStyleSheet(R"( setStyleSheet(R"(
@ -307,5 +334,5 @@ void SettingsWindow::closeSidebar() {
} }
void SettingsWindow::openSidebar() { void SettingsWindow::openSidebar() {
sidebar_widget->setFixedWidth(300); sidebar_widget->setFixedWidth(500);
} }

@ -44,6 +44,7 @@ private:
std::map<QString, QWidget *> panels; std::map<QString, QWidget *> panels;
QButtonGroup *nav_btns; QButtonGroup *nav_btns;
QStackedLayout *panel_layout; QStackedLayout *panel_layout;
QFrame* panel_frame;
public slots: public slots:
void setActivePanel(); void setActivePanel();

@ -29,7 +29,7 @@ QWidget* layoutToWidget(QLayout* l, QWidget* parent){
// Networking functions // Networking functions
Networking::Networking(QWidget* parent){ Networking::Networking(QWidget* parent) : QWidget(parent){
try { try {
wifi = new WifiManager(this); wifi = new WifiManager(this);
} catch (std::exception &e) { } catch (std::exception &e) {
@ -45,14 +45,15 @@ Networking::Networking(QWidget* parent){
connect(wifi, SIGNAL(successfulConnection(QString)), this, SLOT(successfulConnection(QString))); connect(wifi, SIGNAL(successfulConnection(QString)), this, SLOT(successfulConnection(QString)));
s = new QStackedLayout(this); s = new QStackedLayout;
inputField = new InputField(this, 8); inputField = new InputField(this, 8);
connect(inputField, SIGNAL(emitText(QString)), this, SLOT(receiveText(QString))); connect(inputField, SIGNAL(emitText(QString)), this, SLOT(receiveText(QString)));
connect(inputField, SIGNAL(cancel()), this, SLOT(abortTextInput())); connect(inputField, SIGNAL(cancel()), this, SLOT(abortTextInput()));
inputField->setContentsMargins(100,0,100,0);
s->addWidget(inputField); s->addWidget(inputField);
QVBoxLayout* vlayout = new QVBoxLayout(this); QVBoxLayout* vlayout = new QVBoxLayout;
QPushButton* advancedSettings = new QPushButton("Advanced"); QPushButton* advancedSettings = new QPushButton("Advanced");
advancedSettings->setStyleSheet(R"(margin-right: 30px)"); advancedSettings->setStyleSheet(R"(margin-right: 30px)");
advancedSettings->setFixedSize(300, 100); advancedSettings->setFixedSize(300, 100);
@ -69,6 +70,8 @@ Networking::Networking(QWidget* parent){
an = new AdvancedNetworking(this, wifi); an = new AdvancedNetworking(this, wifi);
connect(an, &AdvancedNetworking::backPress, [=](){s->setCurrentIndex(1);}); connect(an, &AdvancedNetworking::backPress, [=](){s->setCurrentIndex(1);});
connect(an, &AdvancedNetworking::openKeyboard, [=](){emit openKeyboard();});
connect(an, &AdvancedNetworking::closeKeyboard, [=](){emit closeKeyboard();});
s->addWidget(an); s->addWidget(an);
s->setCurrentIndex(1); s->setCurrentIndex(1);
@ -93,6 +96,7 @@ Networking::Networking(QWidget* parent){
background-color: #222222; background-color: #222222;
} }
)"); )");
setLayout(s);
} }
void Networking::refresh(){ void Networking::refresh(){
@ -106,17 +110,20 @@ void Networking::connectToNetwork(Network n) {
inputField->setPromptText("Enter password for \"" + n.ssid + "\""); inputField->setPromptText("Enter password for \"" + n.ssid + "\"");
s->setCurrentIndex(0); s->setCurrentIndex(0);
selectedNetwork = n; selectedNetwork = n;
emit openKeyboard();
} }
} }
void Networking::abortTextInput(){ void Networking::abortTextInput(){
s->setCurrentIndex(1); s->setCurrentIndex(1);
emit closeKeyboard();
} }
void Networking::receiveText(QString text) { void Networking::receiveText(QString text) {
wifi->disconnect(); wifi->disconnect();
wifi->connect(selectedNetwork, text); wifi->connect(selectedNetwork, text);
s->setCurrentIndex(1); s->setCurrentIndex(1);
emit closeKeyboard();
} }
void Networking::wrongPassword(QString ssid) { void Networking::wrongPassword(QString ssid) {
@ -124,10 +131,20 @@ void Networking::wrongPassword(QString ssid) {
qDebug()<<"Wrong password, but we are already trying a new network"; qDebug()<<"Wrong password, but we are already trying a new network";
return; return;
} }
if(s->currentIndex()==2){
qDebug()<<"Wrong password, but we are in advanced settings";
return;
}
if(!this->isVisible()){
qDebug()<<"Wrong password, but we are not visible";
return;
}
for (Network n : wifi->seen_networks) { for (Network n : wifi->seen_networks) {
if (n.ssid == ssid) { if (n.ssid == ssid) {
inputField->setPromptText("Wrong password for \"" + n.ssid +"\""); inputField->setPromptText("Wrong password for \"" + n.ssid +"\"");
s->setCurrentIndex(0); s->setCurrentIndex(0);
emit openKeyboard();
return; return;
} }
} }
@ -154,16 +171,17 @@ QFrame* hline(QWidget* parent = 0){
// AdvancedNetworking functions // AdvancedNetworking functions
AdvancedNetworking::AdvancedNetworking(QWidget* parent, WifiManager* wifi): QWidget(parent), wifi(wifi){ AdvancedNetworking::AdvancedNetworking(QWidget* parent, WifiManager* wifi): QWidget(parent), wifi(wifi){
s = new QStackedLayout(this);// inputField and settings s = new QStackedLayout;// inputField and settings
inputField = new InputField(this, 8); inputField = new InputField(this, 8);
connect(inputField, SIGNAL(emitText(QString)), this, SLOT(receiveText(QString))); connect(inputField, SIGNAL(emitText(QString)), this, SLOT(receiveText(QString)));
connect(inputField, SIGNAL(cancel()), this, SLOT(abortTextInput())); connect(inputField, SIGNAL(cancel()), this, SLOT(abortTextInput()));
inputField->setContentsMargins(100,0,100,0);
s->addWidget(inputField); s->addWidget(inputField);
QVBoxLayout* vlayout = new QVBoxLayout(this); QVBoxLayout* vlayout = new QVBoxLayout;
//Back button //Back button
QHBoxLayout* backLayout = new QHBoxLayout(this); QHBoxLayout* backLayout = new QHBoxLayout;
QPushButton* back = new QPushButton("BACK"); QPushButton* back = new QPushButton("BACK");
back->setFixedWidth(500); back->setFixedWidth(500);
connect(back, &QPushButton::released, [=](){emit backPress();}); connect(back, &QPushButton::released, [=](){emit backPress();});
@ -171,9 +189,9 @@ AdvancedNetworking::AdvancedNetworking(QWidget* parent, WifiManager* wifi): QWid
vlayout->addWidget(layoutToWidget(backLayout, this), 0, Qt::AlignLeft); vlayout->addWidget(layoutToWidget(backLayout, this), 0, Qt::AlignLeft);
//Enable tethering layout //Enable tethering layout
QHBoxLayout* tetheringToggleLayout = new QHBoxLayout(this); QHBoxLayout* tetheringToggleLayout = new QHBoxLayout;
tetheringToggleLayout->addWidget(new QLabel("Enable tethering", this)); tetheringToggleLayout->addWidget(new QLabel("Enable tethering"));
Toggle* toggle_switch = new Toggle(this); Toggle* toggle_switch = new Toggle;
toggle_switch->setFixedSize(150, 100); toggle_switch->setFixedSize(150, 100);
tetheringToggleLayout->addWidget(toggle_switch); tetheringToggleLayout->addWidget(toggle_switch);
tetheringToggleLayout->addSpacing(40); tetheringToggleLayout->addSpacing(40);
@ -182,26 +200,26 @@ AdvancedNetworking::AdvancedNetworking(QWidget* parent, WifiManager* wifi): QWid
} }
QObject::connect(toggle_switch, SIGNAL(stateChanged(int)), this, SLOT(toggleTethering(int))); QObject::connect(toggle_switch, SIGNAL(stateChanged(int)), this, SLOT(toggleTethering(int)));
vlayout->addWidget(layoutToWidget(tetheringToggleLayout, this), 0); vlayout->addWidget(layoutToWidget(tetheringToggleLayout, this), 0);
vlayout->addWidget(hline(this), 0); vlayout->addWidget(hline(), 0);
//Change tethering password //Change tethering password
QHBoxLayout *tetheringPassword = new QHBoxLayout(this); QHBoxLayout *tetheringPassword = new QHBoxLayout;
tetheringPassword->addWidget(new QLabel("Edit tethering password", this), 1); tetheringPassword->addWidget(new QLabel("Edit tethering password"), 1);
editPasswordButton = new QPushButton("EDIT", this); editPasswordButton = new QPushButton("EDIT");
editPasswordButton->setFixedWidth(500); editPasswordButton->setFixedWidth(500);
connect(editPasswordButton, &QPushButton::released, [=](){inputField->setPromptText("Enter the new hotspot password"); s->setCurrentIndex(0);}); connect(editPasswordButton, &QPushButton::released, [=](){inputField->setPromptText("Enter the new hotspot password"); s->setCurrentIndex(0); emit openKeyboard();});
tetheringPassword->addWidget(editPasswordButton, 1, Qt::AlignRight); tetheringPassword->addWidget(editPasswordButton, 1, Qt::AlignRight);
vlayout->addWidget(layoutToWidget(tetheringPassword, this), 0); vlayout->addWidget(layoutToWidget(tetheringPassword, this), 0);
vlayout->addWidget(hline(this), 0); vlayout->addWidget(hline(), 0);
//IP adress //IP adress
QHBoxLayout* IPlayout = new QHBoxLayout(this); QHBoxLayout* IPlayout = new QHBoxLayout;
IPlayout->addWidget(new QLabel("IP address: "), 0); IPlayout->addWidget(new QLabel("IP address: "), 0);
ipLabel = new QLabel(wifi->ipv4_address); ipLabel = new QLabel(wifi->ipv4_address);
ipLabel->setStyleSheet("color: #aaaaaa"); ipLabel->setStyleSheet("color: #aaaaaa");
IPlayout->addWidget(ipLabel, 0, Qt::AlignRight); IPlayout->addWidget(ipLabel, 0, Qt::AlignRight);
vlayout->addWidget(layoutToWidget(IPlayout, this), 0); vlayout->addWidget(layoutToWidget(IPlayout, this), 0);
vlayout->addWidget(hline(this), 0); vlayout->addWidget(hline(), 0);
vlayout->addSpacing(300); vlayout->addSpacing(300);
// //Enable SSH // //Enable SSH
@ -256,10 +274,12 @@ void AdvancedNetworking::toggleTethering(int enable) {
void AdvancedNetworking::receiveText(QString text){ void AdvancedNetworking::receiveText(QString text){
wifi->changeTetheringPassword(text); wifi->changeTetheringPassword(text);
s->setCurrentIndex(1); s->setCurrentIndex(1);
emit closeKeyboard();
} }
void AdvancedNetworking::abortTextInput(){ void AdvancedNetworking::abortTextInput(){
s->setCurrentIndex(1); s->setCurrentIndex(1);
emit closeKeyboard();
} }
// WifiUI functions // WifiUI functions
@ -320,10 +340,10 @@ void WifiUI::refresh() {
QWidget * w = new QWidget; QWidget * w = new QWidget;
w->setLayout(hlayout); w->setLayout(hlayout);
vlayout->addWidget(w); vlayout->addWidget(w, 1);
// Don't add the last line // Don't add the last horizontal line
if (page * networks_per_page <= i+1 && i+1 < (page + 1) * networks_per_page && i+1 < wifi->seen_networks.size()) { if (page * networks_per_page <= i+1 && i+1 < (page + 1) * networks_per_page && i+1 < wifi->seen_networks.size()) {
vlayout->addWidget(hline(this)); vlayout->addWidget(hline(), 0);
} }
countWidgets++; countWidgets++;
} }
@ -333,7 +353,9 @@ void WifiUI::refresh() {
// Pad vlayout to prevert oversized network widgets in case of low visible network count // Pad vlayout to prevert oversized network widgets in case of low visible network count
for (int i = countWidgets; i < networks_per_page; i++) { for (int i = countWidgets; i < networks_per_page; i++) {
QWidget *w = new QWidget; QWidget *w = new QWidget;
vlayout->addWidget(w); // That we need to add w twice was determined empiricaly
vlayout->addWidget(w, 1);
vlayout->addWidget(w, 1);
} }
QHBoxLayout *prev_next_buttons = new QHBoxLayout;//Adding constructor exposes the qt bug QHBoxLayout *prev_next_buttons = new QHBoxLayout;//Adding constructor exposes the qt bug
@ -354,7 +376,7 @@ void WifiUI::refresh() {
QWidget *w = new QWidget; QWidget *w = new QWidget;
w->setLayout(prev_next_buttons); w->setLayout(prev_next_buttons);
vlayout->addWidget(w); vlayout->addWidget(w, 1, Qt::AlignBottom);
} }
void WifiUI::handleButton(QAbstractButton* button) { void WifiUI::handleButton(QAbstractButton* button) {

@ -42,15 +42,15 @@ QLayout* build_stat(QString name, int stat) {
QLabel* metric = new QLabel(QString("%1").arg(stat)); QLabel* metric = new QLabel(QString("%1").arg(stat));
metric->setStyleSheet(R"( metric->setStyleSheet(R"(
font-size: 72px; font-size: 80px;
font-weight: 700; font-weight: 600;
)"); )");
layout->addWidget(metric, 0, Qt::AlignLeft); layout->addWidget(metric, 0, Qt::AlignLeft);
QLabel* label = new QLabel(name); QLabel* label = new QLabel(name);
label->setStyleSheet(R"( label->setStyleSheet(R"(
font-size: 32px; font-size: 45px;
font-weight: 600; font-weight: 500;
)"); )");
layout->addWidget(label, 0, Qt::AlignLeft); layout->addWidget(label, 0, Qt::AlignLeft);
@ -104,7 +104,7 @@ DriveStats::DriveStats(QWidget* parent) : QWidget(parent) {
setStyleSheet(R"( setStyleSheet(R"(
QLabel { QLabel {
font-size: 48px; font-size: 48px;
font-weight: 600; font-weight: 500;
} }
)"); )");

@ -7,23 +7,24 @@ InputField::InputField(QWidget *parent, int minTextLength): QWidget(parent), min
layout->setSpacing(30); layout->setSpacing(30);
label = new QLabel(this); label = new QLabel(this);
label->setStyleSheet(R"(font-size: 55px;)"); label->setStyleSheet(R"(font-size: 70px; font-weight: 500;)");
layout->addWidget(label, 0, 0, Qt::AlignVCenter | Qt::AlignLeft); layout->addWidget(label, 0, 0,Qt::AlignLeft);
layout->setColumnStretch(0, 1); layout->setColumnStretch(0, 1);
QPushButton* cancel = new QPushButton("Cancel"); QPushButton* cancel = new QPushButton("Cancel");
cancel->setFixedSize(300, 150); cancel->setFixedSize(300, 150);
cancel->setStyleSheet(R"(padding: 0;)"); cancel->setStyleSheet(R"(padding: 0;)");
layout->addWidget(cancel, 0, 1, Qt::AlignVCenter | Qt::AlignRight); layout->addWidget(cancel, 0, 1, Qt::AlignRight);
QObject::connect(cancel, SIGNAL(released()), this, SLOT(emitEmpty())); QObject::connect(cancel, SIGNAL(released()), this, SLOT(emitEmpty()));
// text box // text box
line = new QLineEdit(); line = new QLineEdit();
line->setStyleSheet(R"( line->setStyleSheet(R"(
color: black; color: white;
background-color: white; background-color: #444444;
font-size: 45px; font-size: 80px;
padding: 25px; font-weight: 500;
padding: 10px;
)"); )");
layout->addWidget(line, 1, 0, 1, -1); layout->addWidget(line, 1, 0, 1, -1);

@ -28,7 +28,7 @@ KeyboardLayout::KeyboardLayout(QWidget *parent, std::vector<QVector<QString>> la
QPushButton* btn = new QPushButton(p); QPushButton* btn = new QPushButton(p);
btn->setFixedHeight(120); btn->setFixedHeight(120);
btn_group->addButton(btn); btn_group->addButton(btn);
hlayout->addSpacing(10); hlayout->addSpacing(30);
if (p == QString(" ")) { if (p == QString(" ")) {
hlayout->addWidget(btn, SPACEBAR_WIDTH); hlayout->addWidget(btn, SPACEBAR_WIDTH);
} else { } else {

@ -18,7 +18,7 @@ void cleanStackedWidget(QStackedWidget* swidget) {
} }
} }
OffroadAlert::OffroadAlert(QWidget* parent) { OffroadAlert::OffroadAlert(QWidget* parent) : QFrame(parent) {
QVBoxLayout *main_layout = new QVBoxLayout(); QVBoxLayout *main_layout = new QVBoxLayout();
main_layout->setMargin(25); main_layout->setMargin(25);
@ -30,11 +30,11 @@ OffroadAlert::OffroadAlert(QWidget* parent) {
main_layout->addLayout(footer_layout); main_layout->addLayout(footer_layout);
QPushButton *dismiss_btn = new QPushButton("Dismiss"); QPushButton *dismiss_btn = new QPushButton("Dismiss");
dismiss_btn->setFixedSize(453, 125); dismiss_btn->setFixedSize(400, 125);
footer_layout->addWidget(dismiss_btn, 0, Qt::AlignLeft); footer_layout->addWidget(dismiss_btn, 0, Qt::AlignLeft);
reboot_btn = new QPushButton("Reboot and Update"); reboot_btn = new QPushButton("Reboot and Update");
reboot_btn->setFixedSize(453, 125); reboot_btn->setFixedSize(600, 125);
reboot_btn->setVisible(false); reboot_btn->setVisible(false);
footer_layout->addWidget(reboot_btn, 0, Qt::AlignRight); footer_layout->addWidget(reboot_btn, 0, Qt::AlignRight);
@ -54,12 +54,13 @@ OffroadAlert::OffroadAlert(QWidget* parent) {
} }
QPushButton { QPushButton {
color: black; color: black;
font-size: 40px; font-size: 50px;
font-weight: 600; font-weight: 600;
border-radius: 20px; border-radius: 30px;
background-color: white; background-color: white;
} }
)"); )");
main_layout->setMargin(50);
} }
void OffroadAlert::refresh() { void OffroadAlert::refresh() {
@ -77,7 +78,6 @@ void OffroadAlert::refresh() {
QLabel *title = new QLabel("Update Available"); QLabel *title = new QLabel("Update Available");
title->setStyleSheet(R"( title->setStyleSheet(R"(
font-size: 72px; font-size: 72px;
font-weight: 700;
)"); )");
layout->addWidget(title, 0, Qt::AlignLeft | Qt::AlignTop); layout->addWidget(title, 0, Qt::AlignLeft | Qt::AlignTop);
@ -85,7 +85,6 @@ void OffroadAlert::refresh() {
QLabel *body = new QLabel(release_notes); QLabel *body = new QLabel(release_notes);
body->setStyleSheet(R"( body->setStyleSheet(R"(
font-size: 48px; font-size: 48px;
font-weight: 600;
)"); )");
layout->addWidget(body, 1, Qt::AlignLeft | Qt::AlignTop); layout->addWidget(body, 1, Qt::AlignLeft | Qt::AlignTop);
} else { } else {
@ -97,7 +96,6 @@ void OffroadAlert::refresh() {
QString style = R"( QString style = R"(
font-size: 48px; font-size: 48px;
font-weight: 600;
)"; )";
style.append("background-color: " + QString(alert.severity ? "#E22C2C" : "#292929")); style.append("background-color: " + QString(alert.severity ? "#E22C2C" : "#292929"));
l->setStyleSheet(style); l->setStyleSheet(style);
@ -106,7 +104,6 @@ void OffroadAlert::refresh() {
} }
layout->setSpacing(20); layout->setSpacing(20);
} }
QWidget *w = new QWidget(); QWidget *w = new QWidget();
w->setLayout(layout); w->setLayout(layout);
alerts_stack->addWidget(w); alerts_stack->addWidget(w);

@ -79,26 +79,26 @@ void PairingQRWidget::updateQrCode(QString text) {
} }
PrimeUserWidget::PrimeUserWidget(QWidget* parent) : QWidget(parent) { PrimeUserWidget::PrimeUserWidget(QWidget* parent) : QWidget(parent) {
mainLayout = new QVBoxLayout(this); mainLayout = new QVBoxLayout;
QLabel* commaPrime = new QLabel("COMMA PRIME", this); QLabel* commaPrime = new QLabel("COMMA PRIME");
commaPrime->setStyleSheet(R"( commaPrime->setStyleSheet(R"(
font-size: 60px; font-size: 60px;
)"); )");
mainLayout->addWidget(commaPrime); mainLayout->addWidget(commaPrime);
username = new QLabel("", this); username = new QLabel("");
mainLayout->addWidget(username); mainLayout->addWidget(username);
mainLayout->addSpacing(200); mainLayout->addSpacing(200);
QLabel* commaPoints = new QLabel("COMMA POINTS", this); QLabel* commaPoints = new QLabel("COMMA POINTS");
commaPoints->setStyleSheet(R"( commaPoints->setStyleSheet(R"(
font-size: 60px; font-size: 60px;
color: #b8b8b8; color: #b8b8b8;
)"); )");
mainLayout->addWidget(commaPoints); mainLayout->addWidget(commaPoints);
points = new QLabel("", this); points = new QLabel("");
mainLayout->addWidget(points); mainLayout->addWidget(points);
setLayout(mainLayout); setLayout(mainLayout);
@ -127,12 +127,12 @@ void PrimeUserWidget::replyFinished(QString response) {
} }
PrimeAdWidget::PrimeAdWidget(QWidget* parent) : QWidget(parent) { PrimeAdWidget::PrimeAdWidget(QWidget* parent) : QWidget(parent) {
QVBoxLayout* vlayout = new QVBoxLayout(this); QVBoxLayout* vlayout = new QVBoxLayout;
QLabel* upgradeNow = new QLabel("Upgrade now", this); QLabel* upgradeNow = new QLabel("Upgrade now");
vlayout->addWidget(upgradeNow); vlayout->addWidget(upgradeNow);
QLabel* description = new QLabel("Become a comma prime member in the comma app and get premium features!", this); QLabel* description = new QLabel("Become a comma prime member in the comma app and get premium features!");
description->setStyleSheet(R"( description->setStyleSheet(R"(
font-size: 50px; font-size: 50px;
color: #b8b8b8; color: #b8b8b8;
@ -144,7 +144,7 @@ PrimeAdWidget::PrimeAdWidget(QWidget* parent) : QWidget(parent) {
QVector<QString> features = {"✓ REMOTE ACCESS", "✓ 14 DAYS OF STORAGE", "✓ DEVELOPER PERKS"}; QVector<QString> features = {"✓ REMOTE ACCESS", "✓ 14 DAYS OF STORAGE", "✓ DEVELOPER PERKS"};
for (auto featureContent : features) { for (auto featureContent : features) {
QLabel* feature = new QLabel(featureContent, this); QLabel* feature = new QLabel(featureContent);
feature->setStyleSheet(R"( feature->setStyleSheet(R"(
font-size: 40px; font-size: 40px;
)"); )");
@ -159,35 +159,35 @@ PrimeAdWidget::PrimeAdWidget(QWidget* parent) : QWidget(parent) {
SetupWidget::SetupWidget(QWidget* parent) : QWidget(parent) { SetupWidget::SetupWidget(QWidget* parent) : QWidget(parent) {
QVBoxLayout* backgroundLayout = new QVBoxLayout(this); QVBoxLayout* backgroundLayout = new QVBoxLayout;
backgroundLayout->addSpacing(100); backgroundLayout->addSpacing(100);
QFrame* background = new QFrame(this); QFrame* background = new QFrame;
mainLayout = new QStackedLayout(this); mainLayout = new QStackedLayout;
QWidget* blankWidget = new QWidget(this); QWidget* blankWidget = new QWidget;
mainLayout->addWidget(blankWidget); mainLayout->addWidget(blankWidget);
QWidget* finishRegistration = new QWidget(this); QWidget* finishRegistration = new QWidget;
QVBoxLayout* finishRegistationLayout = new QVBoxLayout(this); QVBoxLayout* finishRegistationLayout = new QVBoxLayout;
finishRegistationLayout->addSpacing(50); finishRegistationLayout->addSpacing(30);
QPushButton* finishButton = new QPushButton("Finish registration", this); QPushButton* finishButton = new QPushButton("Finish registration");
finishButton->setFixedHeight(200); finishButton->setFixedHeight(200);
finishButton->setStyleSheet(R"( finishButton->setStyleSheet(R"(
border-radius: 30px; border-radius: 30px;
font-size: 60px; font-size: 55px;
font-weight: bold; background: #585858;
background: #787878;
)"); )");
QObject::connect(finishButton, SIGNAL(released()), this, SLOT(showQrCode())); QObject::connect(finishButton, SIGNAL(released()), this, SLOT(showQrCode()));
finishRegistationLayout->addWidget(finishButton); finishRegistationLayout->addWidget(finishButton);
QLabel* registrationDescription = new QLabel("Pair your device with comma connect app", this); QLabel* registrationDescription = new QLabel("Pair your Comma device with the Comma Connect app");
registrationDescription->setStyleSheet(R"( registrationDescription->setStyleSheet(R"(
font-size: 50px; font-size: 55px;
font-weight: 400;
)"); )");
registrationDescription->setWordWrap(true); registrationDescription->setWordWrap(true);
@ -196,31 +196,31 @@ SetupWidget::SetupWidget(QWidget* parent) : QWidget(parent) {
finishRegistration->setLayout(finishRegistationLayout); finishRegistration->setLayout(finishRegistationLayout);
mainLayout->addWidget(finishRegistration); mainLayout->addWidget(finishRegistration);
QVBoxLayout* qrLayout = new QVBoxLayout(this); QVBoxLayout* qrLayout = new QVBoxLayout;
QLabel* qrLabel = new QLabel("Pair with Comma Connect app!", this); QLabel* qrLabel = new QLabel("Pair with Comma Connect app!");
qrLabel->setStyleSheet(R"( qrLabel->setStyleSheet(R"(
font-size: 40px; font-size: 40px;
)"); )");
qrLayout->addWidget(qrLabel); qrLayout->addWidget(qrLabel);
qrLayout->addWidget(new PairingQRWidget(this)); qrLayout->addWidget(new PairingQRWidget);
QWidget* q = new QWidget(this); QWidget* q = new QWidget;
q->setLayout(qrLayout); q->setLayout(qrLayout);
mainLayout->addWidget(q); mainLayout->addWidget(q);
PrimeAdWidget* primeAd = new PrimeAdWidget(this); PrimeAdWidget* primeAd = new PrimeAdWidget;
mainLayout->addWidget(primeAd); mainLayout->addWidget(primeAd);
PrimeUserWidget* primeUserWidget = new PrimeUserWidget(this); PrimeUserWidget* primeUserWidget = new PrimeUserWidget;
mainLayout->addWidget(primeUserWidget); mainLayout->addWidget(primeUserWidget);
background->setLayout(mainLayout); background->setLayout(mainLayout);
background->setStyleSheet(R"( background->setStyleSheet(R"(
.QFrame { .QFrame {
border-radius: 40px; border-radius: 40px;
padding: 60px; padding: 40px;
} }
)"); )");
backgroundLayout->addWidget(background); backgroundLayout->addWidget(background);

Loading…
Cancel
Save