|
|
@ -20,50 +20,37 @@ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 *hlayout = new QHBoxLayout; |
|
|
|
QHBoxLayout *layout = new QHBoxLayout; |
|
|
|
|
|
|
|
layout->setSpacing(50); |
|
|
|
|
|
|
|
|
|
|
|
// Parameter image
|
|
|
|
// Parameter image
|
|
|
|
hlayout->addSpacing(25); |
|
|
|
|
|
|
|
if (icon_path.length()) { |
|
|
|
if (icon_path.length()) { |
|
|
|
QPixmap pix(icon_path); |
|
|
|
QPixmap pix(icon_path); |
|
|
|
QLabel *icon = new QLabel(); |
|
|
|
QLabel *icon = new QLabel(); |
|
|
|
icon->setPixmap(pix.scaledToWidth(100, Qt::SmoothTransformation)); |
|
|
|
icon->setPixmap(pix.scaledToWidth(80, Qt::SmoothTransformation)); |
|
|
|
icon->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
|
|
|
icon->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); |
|
|
|
hlayout->addWidget(icon); |
|
|
|
layout->addWidget(icon); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
hlayout->addSpacing(100); |
|
|
|
layout->addSpacing(80); |
|
|
|
} |
|
|
|
} |
|
|
|
hlayout->addSpacing(25); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Name of the parameter
|
|
|
|
// Name of the parameter
|
|
|
|
QLabel *label = new QLabel(title); |
|
|
|
QLabel *label = new QLabel(title); |
|
|
|
label->setWordWrap(true); |
|
|
|
label->setStyleSheet(R"(font-size: 50px;)"); |
|
|
|
|
|
|
|
layout->addWidget(label); |
|
|
|
|
|
|
|
|
|
|
|
// toggle switch
|
|
|
|
// toggle switch
|
|
|
|
Toggle* toggle_switch = new Toggle(this); |
|
|
|
Toggle *toggle = new Toggle(this); |
|
|
|
toggle_switch->setFixedSize(150, 100); |
|
|
|
toggle->setFixedSize(150, 100); |
|
|
|
|
|
|
|
layout->addWidget(toggle); |
|
|
|
|
|
|
|
QObject::connect(toggle, SIGNAL(stateChanged(int)), this, SLOT(checkboxClicked(int))); |
|
|
|
|
|
|
|
|
|
|
|
// TODO: show descriptions on tap
|
|
|
|
// set initial state from param
|
|
|
|
hlayout->addWidget(label); |
|
|
|
|
|
|
|
hlayout->addSpacing(50); |
|
|
|
|
|
|
|
hlayout->addWidget(toggle_switch); |
|
|
|
|
|
|
|
hlayout->addSpacing(20); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setLayout(hlayout); |
|
|
|
|
|
|
|
if (Params().read_db_bool(param.toStdString().c_str())) { |
|
|
|
if (Params().read_db_bool(param.toStdString().c_str())) { |
|
|
|
toggle_switch->togglePosition(); |
|
|
|
toggle->togglePosition(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setStyleSheet(R"( |
|
|
|
setLayout(layout); |
|
|
|
QLabel { |
|
|
|
|
|
|
|
font-size: 50px; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
* { |
|
|
|
|
|
|
|
background-color: #114265; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
)"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QObject::connect(toggle_switch, SIGNAL(stateChanged(int)), this, SLOT(checkboxClicked(int))); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ParamsToggle::checkboxClicked(int state) { |
|
|
|
void ParamsToggle::checkboxClicked(int state) { |
|
|
@ -72,8 +59,8 @@ 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->setSpacing(25); |
|
|
|
toggles_list->setSpacing(25); |
|
|
|
|
|
|
|
|
|
|
|
toggles_list->addWidget(new ParamsToggle("OpenpilotEnabledToggle", |
|
|
|
toggles_list->addWidget(new ParamsToggle("OpenpilotEnabledToggle", |
|
|
@ -120,6 +107,7 @@ QWidget * toggles_panel() { |
|
|
|
QWidget * device_panel() { |
|
|
|
QWidget * device_panel() { |
|
|
|
|
|
|
|
|
|
|
|
QVBoxLayout *device_layout = new QVBoxLayout; |
|
|
|
QVBoxLayout *device_layout = new QVBoxLayout; |
|
|
|
|
|
|
|
device_layout->setMargin(100); |
|
|
|
device_layout->setSpacing(50); |
|
|
|
device_layout->setSpacing(50); |
|
|
|
|
|
|
|
|
|
|
|
Params params = Params(); |
|
|
|
Params params = Params(); |
|
|
@ -164,7 +152,10 @@ QWidget * device_panel() { |
|
|
|
widget->setLayout(device_layout); |
|
|
|
widget->setLayout(device_layout); |
|
|
|
widget->setStyleSheet(R"( |
|
|
|
widget->setStyleSheet(R"( |
|
|
|
QPushButton { |
|
|
|
QPushButton { |
|
|
|
padding: 60px; |
|
|
|
padding: 0; |
|
|
|
|
|
|
|
height: 120px; |
|
|
|
|
|
|
|
border-radius: 15px; |
|
|
|
|
|
|
|
background-color: #393939; |
|
|
|
} |
|
|
|
} |
|
|
|
)"); |
|
|
|
)"); |
|
|
|
return widget; |
|
|
|
return widget; |
|
|
@ -172,6 +163,7 @@ QWidget * device_panel() { |
|
|
|
|
|
|
|
|
|
|
|
QWidget * developer_panel() { |
|
|
|
QWidget * developer_panel() { |
|
|
|
QVBoxLayout *main_layout = new QVBoxLayout; |
|
|
|
QVBoxLayout *main_layout = new QVBoxLayout; |
|
|
|
|
|
|
|
main_layout->setMargin(100); |
|
|
|
|
|
|
|
|
|
|
|
// TODO: enable SSH toggle and github keys
|
|
|
|
// TODO: enable SSH toggle and github keys
|
|
|
|
|
|
|
|
|
|
|
@ -217,67 +209,84 @@ void SettingsWindow::setActivePanel() { |
|
|
|
panel_layout->setCurrentWidget(panels[btn->text()]); |
|
|
|
panel_layout->setCurrentWidget(panels[btn->text()]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SettingsWindow::SettingsWindow(QWidget *parent) : QWidget(parent) { |
|
|
|
SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) { |
|
|
|
// two main layouts
|
|
|
|
// setup two main layouts
|
|
|
|
QVBoxLayout *sidebar_layout = new QVBoxLayout(); |
|
|
|
QVBoxLayout *sidebar_layout = new QVBoxLayout(); |
|
|
|
|
|
|
|
sidebar_layout->setMargin(0); |
|
|
|
panel_layout = new QStackedLayout(); |
|
|
|
panel_layout = new QStackedLayout(); |
|
|
|
|
|
|
|
|
|
|
|
// close button
|
|
|
|
// close button
|
|
|
|
QPushButton *close_button = new QPushButton("X"); |
|
|
|
QPushButton *close_btn = new QPushButton("X"); |
|
|
|
close_button->setStyleSheet(R"( |
|
|
|
close_btn->setStyleSheet(R"( |
|
|
|
QPushButton { |
|
|
|
font-size: 65px; |
|
|
|
padding: 50px; |
|
|
|
font-weight: bold; |
|
|
|
font-weight: bold; |
|
|
|
border 1px grey solid; |
|
|
|
font-size: 110px; |
|
|
|
border-radius: 75px; |
|
|
|
} |
|
|
|
background-color: #393939; |
|
|
|
)"); |
|
|
|
)"); |
|
|
|
sidebar_layout->addWidget(close_button); |
|
|
|
close_btn->setFixedSize(150, 150); |
|
|
|
QObject::connect(close_button, SIGNAL(released()), this, SIGNAL(closeSettings())); |
|
|
|
sidebar_layout->addSpacing(45); |
|
|
|
|
|
|
|
sidebar_layout->addWidget(close_btn, 0, Qt::AlignHCenter); |
|
|
|
|
|
|
|
QObject::connect(close_btn, SIGNAL(released()), this, SIGNAL(closeSettings())); |
|
|
|
|
|
|
|
|
|
|
|
// setup panels
|
|
|
|
// setup panels
|
|
|
|
panels = { |
|
|
|
panels = { |
|
|
|
{"developer", developer_panel()}, |
|
|
|
{"Developer", developer_panel()}, |
|
|
|
{"device", device_panel()}, |
|
|
|
{"Device", device_panel()}, |
|
|
|
{"network", network_panel(this)}, |
|
|
|
{"Network", network_panel(this)}, |
|
|
|
{"toggles", toggles_panel()}, |
|
|
|
{"Toggles", toggles_panel()}, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sidebar_layout->addSpacing(45); |
|
|
|
nav_btns = new QButtonGroup(); |
|
|
|
nav_btns = new QButtonGroup(); |
|
|
|
for (auto &panel : panels) { |
|
|
|
for (auto &panel : panels) { |
|
|
|
QPushButton *btn = new QPushButton(panel.first); |
|
|
|
QPushButton *btn = new QPushButton(panel.first); |
|
|
|
btn->setCheckable(true); |
|
|
|
btn->setCheckable(true); |
|
|
|
btn->setStyleSheet(R"( |
|
|
|
btn->setStyleSheet(R"( |
|
|
|
QPushButton { |
|
|
|
QPushButton { |
|
|
|
padding-top: 35px; |
|
|
|
color: grey; |
|
|
|
padding-bottom: 35px; |
|
|
|
|
|
|
|
border: none; |
|
|
|
border: none; |
|
|
|
background: none; |
|
|
|
background: none; |
|
|
|
font-size: 55px; |
|
|
|
font-size: 65px; |
|
|
|
|
|
|
|
font-weight: bold; |
|
|
|
|
|
|
|
padding-top: 35px; |
|
|
|
|
|
|
|
padding-bottom: 35px; |
|
|
|
} |
|
|
|
} |
|
|
|
QPushButton:checked { |
|
|
|
QPushButton:checked { |
|
|
|
font-size: 50px; |
|
|
|
color: white; |
|
|
|
font-weight: bold; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
)"); |
|
|
|
)"); |
|
|
|
|
|
|
|
|
|
|
|
nav_btns->addButton(btn); |
|
|
|
nav_btns->addButton(btn); |
|
|
|
sidebar_layout->addWidget(btn, 0, Qt::AlignRight); |
|
|
|
sidebar_layout->addWidget(btn, 0, Qt::AlignRight | Qt::AlignTop); |
|
|
|
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_cast<QPushButton *>(nav_btns->buttons()[0])->setChecked(true); |
|
|
|
qobject_cast<QPushButton *>(nav_btns->buttons()[0])->setChecked(true); |
|
|
|
|
|
|
|
sidebar_layout->addStretch(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// main settings layout, sidebar + main panel
|
|
|
|
QHBoxLayout *settings_layout = new QHBoxLayout(); |
|
|
|
QHBoxLayout *settings_layout = new QHBoxLayout(); |
|
|
|
settings_layout->setMargin(0); |
|
|
|
settings_layout->setContentsMargins(150, 50, 150, 50); |
|
|
|
settings_layout->addSpacing(45); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sidebar_widget = new QWidget; |
|
|
|
sidebar_widget = new QWidget; |
|
|
|
sidebar_widget->setLayout(sidebar_layout); |
|
|
|
sidebar_widget->setLayout(sidebar_layout); |
|
|
|
settings_layout->addWidget(sidebar_widget); |
|
|
|
settings_layout->addWidget(sidebar_widget); |
|
|
|
|
|
|
|
|
|
|
|
settings_layout->addSpacing(45); |
|
|
|
settings_layout->addSpacing(25); |
|
|
|
settings_layout->addLayout(panel_layout); |
|
|
|
|
|
|
|
settings_layout->addSpacing(45); |
|
|
|
QFrame *panel_frame = new QFrame; |
|
|
|
|
|
|
|
panel_frame->setLayout(panel_layout); |
|
|
|
|
|
|
|
panel_frame->setStyleSheet(R"( |
|
|
|
|
|
|
|
QFrame { |
|
|
|
|
|
|
|
border-radius: 30px; |
|
|
|
|
|
|
|
background-color: #292929; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
* { |
|
|
|
|
|
|
|
background-color: none; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
)"); |
|
|
|
|
|
|
|
settings_layout->addWidget(panel_frame, 1, Qt::AlignRight); |
|
|
|
|
|
|
|
|
|
|
|
setLayout(settings_layout); |
|
|
|
setLayout(settings_layout); |
|
|
|
setStyleSheet(R"( |
|
|
|
setStyleSheet(R"( |
|
|
@ -285,6 +294,9 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QWidget(parent) { |
|
|
|
color: white; |
|
|
|
color: white; |
|
|
|
font-size: 50px; |
|
|
|
font-size: 50px; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
SettingsWindow { |
|
|
|
|
|
|
|
background-color: black; |
|
|
|
|
|
|
|
} |
|
|
|
)"); |
|
|
|
)"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|