|
|
@ -72,7 +72,7 @@ QWidget * toggles_panel() { |
|
|
|
return widget; |
|
|
|
return widget; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QWidget * device_panel() { |
|
|
|
DevicePanel::DevicePanel(QWidget* parent) : QWidget(parent) { |
|
|
|
QVBoxLayout *device_layout = new QVBoxLayout; |
|
|
|
QVBoxLayout *device_layout = new QVBoxLayout; |
|
|
|
device_layout->setMargin(100); |
|
|
|
device_layout->setMargin(100); |
|
|
|
|
|
|
|
|
|
|
@ -116,35 +116,36 @@ QWidget * device_panel() { |
|
|
|
device_layout->addWidget(new ButtonControl("Uninstall " + brand, "UNINSTALL", |
|
|
|
device_layout->addWidget(new ButtonControl("Uninstall " + brand, "UNINSTALL", |
|
|
|
"", |
|
|
|
"", |
|
|
|
[=]() { |
|
|
|
[=]() { |
|
|
|
if (ConfirmationDialog::confirm("Are you srue you want to uninstall?")) { |
|
|
|
if (ConfirmationDialog::confirm("Are you sure you want to uninstall?")) { |
|
|
|
Params().write_db_value("DoUninstall", "1"); |
|
|
|
Params().write_db_value("DoUninstall", "1"); |
|
|
|
} |
|
|
|
} |
|
|
|
})); |
|
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
// power buttons
|
|
|
|
// power buttons
|
|
|
|
|
|
|
|
QHBoxLayout *power_layout = new QHBoxLayout(); |
|
|
|
|
|
|
|
power_layout->setSpacing(30); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QPushButton *reboot_btn = new QPushButton("Reboot"); |
|
|
|
|
|
|
|
power_layout->addWidget(reboot_btn); |
|
|
|
|
|
|
|
QObject::connect(reboot_btn, &QPushButton::released, [=]() { |
|
|
|
|
|
|
|
if (ConfirmationDialog::confirm("Are you sure you want to reboot?")) { |
|
|
|
|
|
|
|
Hardware::reboot(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
QPushButton *poweroff_btn = new QPushButton("Power Off"); |
|
|
|
QPushButton *poweroff_btn = new QPushButton("Power Off"); |
|
|
|
poweroff_btn->setStyleSheet("background-color: #E22C2C;"); |
|
|
|
poweroff_btn->setStyleSheet("background-color: #E22C2C;"); |
|
|
|
device_layout->addWidget(poweroff_btn, Qt::AlignBottom); |
|
|
|
power_layout->addWidget(poweroff_btn); |
|
|
|
QObject::connect(poweroff_btn, &QPushButton::released, [=]() { |
|
|
|
QObject::connect(poweroff_btn, &QPushButton::released, [=]() { |
|
|
|
if (ConfirmationDialog::confirm("Are you sure you want to power off?")) { |
|
|
|
if (ConfirmationDialog::confirm("Are you sure you want to power off?")) { |
|
|
|
Hardware::poweroff(); |
|
|
|
Hardware::poweroff(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
device_layout->addSpacing(20); |
|
|
|
device_layout->addLayout(power_layout); |
|
|
|
|
|
|
|
|
|
|
|
QPushButton *reboot_btn = new QPushButton("Reboot"); |
|
|
|
setLayout(device_layout); |
|
|
|
device_layout->addWidget(reboot_btn, Qt::AlignBottom); |
|
|
|
setStyleSheet(R"( |
|
|
|
QObject::connect(reboot_btn, &QPushButton::released, [=]() { |
|
|
|
|
|
|
|
if (ConfirmationDialog::confirm("Are you sure you want to reboot?")) { |
|
|
|
|
|
|
|
Hardware::reboot(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QWidget *widget = new QWidget; |
|
|
|
|
|
|
|
widget->setLayout(device_layout); |
|
|
|
|
|
|
|
widget->setStyleSheet(R"( |
|
|
|
|
|
|
|
QPushButton { |
|
|
|
QPushButton { |
|
|
|
padding: 0; |
|
|
|
padding: 0; |
|
|
|
height: 120px; |
|
|
|
height: 120px; |
|
|
@ -152,7 +153,6 @@ QWidget * device_panel() { |
|
|
|
background-color: #393939; |
|
|
|
background-color: #393939; |
|
|
|
} |
|
|
|
} |
|
|
|
)"); |
|
|
|
)"); |
|
|
|
return widget; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
DeveloperPanel::DeveloperPanel(QWidget* parent) : QFrame(parent) { |
|
|
|
DeveloperPanel::DeveloperPanel(QWidget* parent) : QFrame(parent) { |
|
|
@ -175,10 +175,11 @@ void DeveloperPanel::showEvent(QShowEvent *event) { |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < dev_params.size(); i++) { |
|
|
|
for (int i = 0; i < dev_params.size(); i++) { |
|
|
|
const auto &[name, value] = dev_params[i]; |
|
|
|
const auto &[name, value] = dev_params[i]; |
|
|
|
|
|
|
|
QString val = QString::fromStdString(value).trimmed(); |
|
|
|
if (labels.size() > i) { |
|
|
|
if (labels.size() > i) { |
|
|
|
labels[i]->setText(QString::fromStdString(value)); |
|
|
|
labels[i]->setText(val); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
labels.push_back(new LabelControl(name, QString::fromStdString(value))); |
|
|
|
labels.push_back(new LabelControl(name, val)); |
|
|
|
layout()->addWidget(labels[i]); |
|
|
|
layout()->addWidget(labels[i]); |
|
|
|
if (i < (dev_params.size() - 1)) { |
|
|
|
if (i < (dev_params.size() - 1)) { |
|
|
|
layout()->addWidget(horizontal_line()); |
|
|
|
layout()->addWidget(horizontal_line()); |
|
|
@ -248,7 +249,7 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) { |
|
|
|
|
|
|
|
|
|
|
|
// setup panels
|
|
|
|
// setup panels
|
|
|
|
QPair<QString, QWidget *> panels[] = { |
|
|
|
QPair<QString, QWidget *> panels[] = { |
|
|
|
{"Device", device_panel()}, |
|
|
|
{"Device", new DevicePanel(this)}, |
|
|
|
{"Network", network_panel(this)}, |
|
|
|
{"Network", network_panel(this)}, |
|
|
|
{"Toggles", toggles_panel()}, |
|
|
|
{"Toggles", toggles_panel()}, |
|
|
|
{"Developer", new DeveloperPanel()}, |
|
|
|
{"Developer", new DeveloperPanel()}, |
|
|
@ -278,7 +279,9 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) { |
|
|
|
sidebar_layout->addWidget(btn, 0, Qt::AlignRight); |
|
|
|
sidebar_layout->addWidget(btn, 0, Qt::AlignRight); |
|
|
|
|
|
|
|
|
|
|
|
panel_layout->addWidget(panel); |
|
|
|
panel_layout->addWidget(panel); |
|
|
|
QObject::connect(btn, &QPushButton::released, [=, w = panel]() { panel_layout->setCurrentWidget(w); }); |
|
|
|
QObject::connect(btn, &QPushButton::released, [=, w = panel]() { |
|
|
|
|
|
|
|
panel_layout->setCurrentWidget(w); |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
qobject_cast<QPushButton *>(nav_btns->buttons()[0])->setChecked(true); |
|
|
|
qobject_cast<QPushButton *>(nav_btns->buttons()[0])->setChecked(true); |
|
|
|
sidebar_layout->setContentsMargins(50, 50, 100, 50); |
|
|
|
sidebar_layout->setContentsMargins(50, 50, 100, 50); |
|
|
|