From 0a4b3b9cd1095f05651bff685d02c809db8768a9 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Fri, 13 Dec 2019 12:24:02 -0600 Subject: Qt UI: Handle cancel/exit of wizard using the proper pattern --- ui/qt5/horizonwizard.cc | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'ui/qt5/horizonwizard.cc') diff --git a/ui/qt5/horizonwizard.cc b/ui/qt5/horizonwizard.cc index cdeac28..a71b824 100644 --- a/ui/qt5/horizonwizard.cc +++ b/ui/qt5/horizonwizard.cc @@ -238,25 +238,6 @@ HorizonWizard::HorizonWizard(QWidget *parent) : QWizard(parent) { help.exec(); }); - /* REQ: UI.Global.Cancel.Confirm */ - button(CancelButton)->disconnect(this); - QObject::connect(button(CancelButton), &QAbstractButton::clicked, - [=](bool) { - QMessageBox cancel(QMessageBox::Question, - tr("Exit Adélie Linux System Installation"), - #ifdef HAS_INSTALL_ENV - tr("Adélie Linux has not yet been set up on your computer. Exiting will reboot your computer. Do you wish to exit?"), - #else - tr("You have not yet completed the System Installation wizard. No installfile will be generated. Do you wish to exit?"), - #endif - QMessageBox::Yes | QMessageBox::No, - this); - cancel.setDefaultButton(QMessageBox::No); - if(cancel.exec() == QMessageBox::Yes) { - reject(); - } - }); - /* REQ: Iface.UI.ButtonAccel */ setButtonText(HelpButton, tr("&Help (F1)")); setButtonText(CancelButton, tr("E&xit (F3)")); @@ -273,9 +254,6 @@ HorizonWizard::HorizonWizard(QWidget *parent) : QWizard(parent) { button(HelpButton), &QAbstractButton::click); f1->setWhatsThis(tr("Activates the Help screen.")); - esc = new QShortcut(Qt::Key_Escape, this); - connect(esc, &QShortcut::activated, - button(CancelButton), &QAbstractButton::click); f3 = new QShortcut(Qt::Key_F3, this); connect(f3, &QShortcut::activated, button(CancelButton), &QAbstractButton::click); @@ -469,3 +447,23 @@ void HorizonWizard::accept() { done(QDialog::Accepted); } + +void HorizonWizard::reject() { + /* REQ: UI.Global.Cancel.Confirm */ + QMessageBox cancel(QMessageBox::Question, + tr("Exit Adélie Linux System Installation"), + #ifdef HAS_INSTALL_ENV + tr("Adélie Linux has not yet been set up on your computer. Exiting will reboot your computer. Do you wish to exit?"), + #else + tr("You have not yet completed the System Installation wizard. No installfile will be generated. Do you wish to exit?"), + #endif + QMessageBox::Yes | QMessageBox::No, + this); + cancel.setDefaultButton(QMessageBox::No); + + if(cancel.exec() == QMessageBox::Yes) { + done(QDialog::Rejected); + } else { + return; + } +} -- cgit v1.2.3-60-g2f50