UI: close dialogs on settings close (#20541)
* this works * fix * fix * fix * blacklist * style * tabs * tabs * temporary * hideEvent * fix * changes * dont need this * works * no signal * Merge branch 'master' of github.com:commaai/openpilot into ui_close_after_timeout * works * cleanup * little more cleanup Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>pull/20740/head
parent
426faa02f0
commit
0fe155b7c3
|
@ -121,7 +121,7 @@ DevicePanel::DevicePanel(QWidget* parent) : QWidget(parent) {
|
|||
|
||||
QString resetCalibDesc = "openpilot requires the device to be mounted within 4° left or right and within 5° up or down. openpilot is continuously calibrating, resetting is rarely required.";
|
||||
ButtonControl *resetCalibBtn = new ButtonControl("Reset Calibration", "RESET", resetCalibDesc, [=]() {
|
||||
if (ConfirmationDialog::confirm("Are you sure you want to reset calibration?")) {
|
||||
if (ConfirmationDialog::confirm("Are you sure you want to reset calibration?", this)) {
|
||||
Params().remove("CalibrationParams");
|
||||
}
|
||||
}, "", this);
|
||||
|
@ -150,15 +150,15 @@ DevicePanel::DevicePanel(QWidget* parent) : QWidget(parent) {
|
|||
|
||||
offroad_btns.append(new ButtonControl("Review Training Guide", "REVIEW",
|
||||
"Review the rules, features, and limitations of openpilot", [=]() {
|
||||
if (ConfirmationDialog::confirm("Are you sure you want to review the training guide?")) {
|
||||
Params().remove("CompletedTrainingVersion");
|
||||
emit reviewTrainingGuide();
|
||||
}
|
||||
}, "", this));
|
||||
if (ConfirmationDialog::confirm("Are you sure you want to review the training guide?", this)) {
|
||||
Params().remove("CompletedTrainingVersion");
|
||||
emit reviewTrainingGuide();
|
||||
}
|
||||
}, "", this));
|
||||
|
||||
QString brand = params.getBool("Passive") ? "dashcam" : "openpilot";
|
||||
offroad_btns.append(new ButtonControl("Uninstall " + brand, "UNINSTALL", "", [=]() {
|
||||
if (ConfirmationDialog::confirm("Are you sure you want to uninstall?")) {
|
||||
if (ConfirmationDialog::confirm("Are you sure you want to uninstall?", this)) {
|
||||
Params().putBool("DoUninstall", true);
|
||||
}
|
||||
}, "", this));
|
||||
|
@ -176,7 +176,7 @@ DevicePanel::DevicePanel(QWidget* parent) : QWidget(parent) {
|
|||
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?")) {
|
||||
if (ConfirmationDialog::confirm("Are you sure you want to reboot?", this)) {
|
||||
Hardware::reboot();
|
||||
}
|
||||
});
|
||||
|
@ -185,7 +185,7 @@ DevicePanel::DevicePanel(QWidget* parent) : QWidget(parent) {
|
|||
poweroff_btn->setStyleSheet("background-color: #E22C2C;");
|
||||
power_layout->addWidget(poweroff_btn);
|
||||
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?", this)) {
|
||||
Hardware::poweroff();
|
||||
}
|
||||
});
|
||||
|
@ -358,6 +358,14 @@ void SettingsWindow::hideEvent(QHideEvent *event){
|
|||
#ifdef QCOM
|
||||
HardwareEon::close_activities();
|
||||
#endif
|
||||
|
||||
// TODO: this should be handled by the Dialog classes
|
||||
QList<QWidget*> children = findChildren<QWidget *>();
|
||||
for(auto &w : children){
|
||||
if(w->metaObject()->superClass()->className() == QString("QDialog")){
|
||||
w->close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsWindow::showEvent(QShowEvent *event){
|
||||
|
|
|
@ -111,7 +111,6 @@ void InputDialog::setMinLength(int length){
|
|||
minLength = length;
|
||||
}
|
||||
|
||||
|
||||
ConfirmationDialog::ConfirmationDialog(const QString &prompt_text, const QString &confirm_text, const QString &cancel_text,
|
||||
QWidget *parent):QDialog(parent) {
|
||||
setWindowFlags(Qt::Popup);
|
||||
|
@ -161,13 +160,13 @@ ConfirmationDialog::ConfirmationDialog(const QString &prompt_text, const QString
|
|||
setLayout(layout);
|
||||
}
|
||||
|
||||
bool ConfirmationDialog::alert(const QString &prompt_text) {
|
||||
ConfirmationDialog d = ConfirmationDialog(prompt_text, "Ok", "");
|
||||
bool ConfirmationDialog::alert(const QString &prompt_text, QWidget *parent) {
|
||||
ConfirmationDialog d = ConfirmationDialog(prompt_text, "Ok", "", parent);
|
||||
return d.exec();
|
||||
}
|
||||
|
||||
bool ConfirmationDialog::confirm(const QString &prompt_text) {
|
||||
ConfirmationDialog d = ConfirmationDialog(prompt_text);
|
||||
bool ConfirmationDialog::confirm(const QString &prompt_text, QWidget *parent) {
|
||||
ConfirmationDialog d = ConfirmationDialog(prompt_text, "Ok", "Cancel", parent);
|
||||
return d.exec();
|
||||
}
|
||||
|
||||
|
|
|
@ -44,8 +44,8 @@ class ConfirmationDialog : public QDialog {
|
|||
public:
|
||||
explicit ConfirmationDialog(const QString &prompt_text, const QString &confirm_text = "Ok",
|
||||
const QString &cancel_text = "Cancel", QWidget* parent = 0);
|
||||
static bool alert(const QString &prompt_text);
|
||||
static bool confirm(const QString &prompt_text);
|
||||
static bool alert(const QString &prompt_text, QWidget *parent = 0);
|
||||
static bool confirm(const QString &prompt_text, QWidget *parent = 0);
|
||||
|
||||
private:
|
||||
QLabel *prompt;
|
||||
|
|
Loading…
Reference in New Issue