wip
This commit is contained in:
@@ -62,6 +62,33 @@ OscarPilotBasicPanel::OscarPilotBasicPanel(OscarSettingsWindow *parent) : FrogPi
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
// power buttons
|
||||
QHBoxLayout *power_layout = new QHBoxLayout();
|
||||
power_layout->setSpacing(30);
|
||||
|
||||
QPushButton *reboot_btn = new QPushButton(tr("Reboot"));
|
||||
reboot_btn->setObjectName("reboot_btn");
|
||||
power_layout->addWidget(reboot_btn);
|
||||
QObject::connect(reboot_btn, &QPushButton::clicked, this, &OscarPilotBasicPanel::reboot);
|
||||
|
||||
QPushButton *poweroff_btn = new QPushButton(tr("Power Off"));
|
||||
poweroff_btn->setObjectName("poweroff_btn");
|
||||
power_layout->addWidget(poweroff_btn);
|
||||
QObject::connect(poweroff_btn, &QPushButton::clicked, this, &OscarPilotBasicPanel::poweroff);
|
||||
|
||||
if (!Hardware::PC()) {
|
||||
connect(uiState(), &UIState::offroadTransition, poweroff_btn, &QPushButton::setVisible);
|
||||
}
|
||||
|
||||
setStyleSheet(R"(
|
||||
#reboot_btn { height: 120px; border-radius: 15px; background-color: #393939; }
|
||||
#reboot_btn:pressed { background-color: #4a4a4a; }
|
||||
#poweroff_btn { height: 120px; border-radius: 15px; background-color: #E22C2C; }
|
||||
#poweroff_btn:pressed { background-color: #FF2424; }
|
||||
)");
|
||||
addItem(power_layout);
|
||||
}
|
||||
|
||||
void OscarPilotBasicPanel::updateToggles() {
|
||||
@@ -91,3 +118,30 @@ void OscarPilotBasicPanel::hideSubToggles() {
|
||||
void OscarPilotBasicPanel::hideEvent(QHideEvent *event) {
|
||||
hideSubToggles();
|
||||
}
|
||||
|
||||
|
||||
void OscarPilotBasicPanel::reboot() {
|
||||
if (!uiState()->engaged()) {
|
||||
if (ConfirmationDialog::confirm(tr("Are you sure you want to reboot?"), tr("Reboot"), this)) {
|
||||
// Check engaged again in case it changed while the dialog was open
|
||||
if (!uiState()->engaged()) {
|
||||
params.putBool("DoReboot", true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ConfirmationDialog::alert(tr("Disengage to Reboot"), this);
|
||||
}
|
||||
}
|
||||
|
||||
void OscarPilotBasicPanel::poweroff() {
|
||||
if (!uiState()->engaged()) {
|
||||
if (ConfirmationDialog::confirm(tr("Are you sure you want to power off?"), tr("Power Off"), this)) {
|
||||
// Check engaged again in case it changed while the dialog was open
|
||||
if (!uiState()->engaged()) {
|
||||
params.putBool("DoShutdown", true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ConfirmationDialog::alert(tr("Disengage to Power Off"), this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ public:
|
||||
signals:
|
||||
void closeParentToggle();
|
||||
void openParentToggle();
|
||||
void poweroff();
|
||||
void reboot();
|
||||
|
||||
private:
|
||||
void hideEvent(QHideEvent *event);
|
||||
|
||||
@@ -83,11 +83,16 @@ OscarSettingsWindow::OscarSettingsWindow(QWidget *parent) : QFrame(parent) {
|
||||
QObject::connect(frogpilotControls, &FrogPilotControlsPanel::closeParentToggle, this, [this]() {frogPilotTogglesOpen = false;});
|
||||
QObject::connect(frogpilotControls, &FrogPilotControlsPanel::openParentToggle, this, [this]() {frogPilotTogglesOpen = true;});
|
||||
|
||||
// DevicePanel *device = new DevicePanel(this);
|
||||
// QObject::connect(device, &DevicePanel::reviewTrainingGuide, this, &SettingsWindow::reviewTrainingGuide);
|
||||
// QObject::connect(device, &DevicePanel::showDriverView, this, &SettingsWindow::showDriverView);
|
||||
|
||||
QList<QPair<QString, QWidget *>> panels = {
|
||||
{tr("Basic"), new OscarPilotBasicPanel(this)},
|
||||
{tr("Advanced"), frogpilotControls},
|
||||
{tr("Network"), new Networking(this)},
|
||||
{tr("Software"), new SoftwarePanel(this)},
|
||||
// {tr("Device"), new DevicePanel(this)},
|
||||
// FrogPilotControlsPanel
|
||||
// {tr("OscarCloud"), basic},
|
||||
// {tr("Logging"), basic}, // Log / Upload driver cam, Routes
|
||||
|
||||
@@ -427,9 +427,9 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) {
|
||||
});
|
||||
|
||||
// setup panels
|
||||
DevicePanel *device = new DevicePanel(this);
|
||||
QObject::connect(device, &DevicePanel::reviewTrainingGuide, this, &SettingsWindow::reviewTrainingGuide);
|
||||
QObject::connect(device, &DevicePanel::showDriverView, this, &SettingsWindow::showDriverView);
|
||||
// DevicePanel *device = new DevicePanel(this);
|
||||
// QObject::connect(device, &DevicePanel::reviewTrainingGuide, this, &SettingsWindow::reviewTrainingGuide);
|
||||
// QObject::connect(device, &DevicePanel::showDriverView, this, &SettingsWindow::showDriverView);
|
||||
|
||||
TogglesPanel *toggles = new TogglesPanel(this);
|
||||
QObject::connect(this, &SettingsWindow::expandToggleDescription, toggles, &TogglesPanel::expandToggleDescription);
|
||||
|
||||
Reference in New Issue
Block a user