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.";
|
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, [=]() {
|
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");
|
Params().remove("CalibrationParams");
|
||||||
}
|
}
|
||||||
}, "", this);
|
}, "", this);
|
||||||
|
@ -150,15 +150,15 @@ DevicePanel::DevicePanel(QWidget* parent) : QWidget(parent) {
|
||||||
|
|
||||||
offroad_btns.append(new ButtonControl("Review Training Guide", "REVIEW",
|
offroad_btns.append(new ButtonControl("Review Training Guide", "REVIEW",
|
||||||
"Review the rules, features, and limitations of openpilot", [=]() {
|
"Review the rules, features, and limitations of openpilot", [=]() {
|
||||||
if (ConfirmationDialog::confirm("Are you sure you want to review the training guide?")) {
|
if (ConfirmationDialog::confirm("Are you sure you want to review the training guide?", this)) {
|
||||||
Params().remove("CompletedTrainingVersion");
|
Params().remove("CompletedTrainingVersion");
|
||||||
emit reviewTrainingGuide();
|
emit reviewTrainingGuide();
|
||||||
}
|
}
|
||||||
}, "", this));
|
}, "", this));
|
||||||
|
|
||||||
QString brand = params.getBool("Passive") ? "dashcam" : "openpilot";
|
QString brand = params.getBool("Passive") ? "dashcam" : "openpilot";
|
||||||
offroad_btns.append(new ButtonControl("Uninstall " + brand, "UNINSTALL", "", [=]() {
|
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);
|
Params().putBool("DoUninstall", true);
|
||||||
}
|
}
|
||||||
}, "", this));
|
}, "", this));
|
||||||
|
@ -176,7 +176,7 @@ DevicePanel::DevicePanel(QWidget* parent) : QWidget(parent) {
|
||||||
QPushButton *reboot_btn = new QPushButton("Reboot");
|
QPushButton *reboot_btn = new QPushButton("Reboot");
|
||||||
power_layout->addWidget(reboot_btn);
|
power_layout->addWidget(reboot_btn);
|
||||||
QObject::connect(reboot_btn, &QPushButton::released, [=]() {
|
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();
|
Hardware::reboot();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -185,7 +185,7 @@ DevicePanel::DevicePanel(QWidget* parent) : QWidget(parent) {
|
||||||
poweroff_btn->setStyleSheet("background-color: #E22C2C;");
|
poweroff_btn->setStyleSheet("background-color: #E22C2C;");
|
||||||
power_layout->addWidget(poweroff_btn);
|
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?", this)) {
|
||||||
Hardware::poweroff();
|
Hardware::poweroff();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -358,6 +358,14 @@ void SettingsWindow::hideEvent(QHideEvent *event){
|
||||||
#ifdef QCOM
|
#ifdef QCOM
|
||||||
HardwareEon::close_activities();
|
HardwareEon::close_activities();
|
||||||
#endif
|
#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){
|
void SettingsWindow::showEvent(QShowEvent *event){
|
||||||
|
|
|
@ -111,7 +111,6 @@ void InputDialog::setMinLength(int length){
|
||||||
minLength = length;
|
minLength = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ConfirmationDialog::ConfirmationDialog(const QString &prompt_text, const QString &confirm_text, const QString &cancel_text,
|
ConfirmationDialog::ConfirmationDialog(const QString &prompt_text, const QString &confirm_text, const QString &cancel_text,
|
||||||
QWidget *parent):QDialog(parent) {
|
QWidget *parent):QDialog(parent) {
|
||||||
setWindowFlags(Qt::Popup);
|
setWindowFlags(Qt::Popup);
|
||||||
|
@ -161,13 +160,13 @@ ConfirmationDialog::ConfirmationDialog(const QString &prompt_text, const QString
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfirmationDialog::alert(const QString &prompt_text) {
|
bool ConfirmationDialog::alert(const QString &prompt_text, QWidget *parent) {
|
||||||
ConfirmationDialog d = ConfirmationDialog(prompt_text, "Ok", "");
|
ConfirmationDialog d = ConfirmationDialog(prompt_text, "Ok", "", parent);
|
||||||
return d.exec();
|
return d.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfirmationDialog::confirm(const QString &prompt_text) {
|
bool ConfirmationDialog::confirm(const QString &prompt_text, QWidget *parent) {
|
||||||
ConfirmationDialog d = ConfirmationDialog(prompt_text);
|
ConfirmationDialog d = ConfirmationDialog(prompt_text, "Ok", "Cancel", parent);
|
||||||
return d.exec();
|
return d.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,8 @@ class ConfirmationDialog : public QDialog {
|
||||||
public:
|
public:
|
||||||
explicit ConfirmationDialog(const QString &prompt_text, const QString &confirm_text = "Ok",
|
explicit ConfirmationDialog(const QString &prompt_text, const QString &confirm_text = "Ok",
|
||||||
const QString &cancel_text = "Cancel", QWidget* parent = 0);
|
const QString &cancel_text = "Cancel", QWidget* parent = 0);
|
||||||
static bool alert(const QString &prompt_text);
|
static bool alert(const QString &prompt_text, QWidget *parent = 0);
|
||||||
static bool confirm(const QString &prompt_text);
|
static bool confirm(const QString &prompt_text, QWidget *parent = 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QLabel *prompt;
|
QLabel *prompt;
|
||||||
|
|
Loading…
Reference in New Issue