From ff8692fa391ccb6ea889002a6fff14419a5e68c6 Mon Sep 17 00:00:00 2001 From: fekt Date: Fri, 4 Nov 2022 20:38:10 -0400 Subject: [PATCH] Wizard UX fixes Fixed cancelEvent slot, disabled back butttons, removed close button since cancel button displays alert and can close app instead of loading GUI with light server error. --- src/firsttimewizard.cpp | 25 ++++++++++++++++++------- src/firsttimewizard.h | 3 +-- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/firsttimewizard.cpp b/src/firsttimewizard.cpp index 7ea273e..30b6d88 100644 --- a/src/firsttimewizard.cpp +++ b/src/firsttimewizard.cpp @@ -49,9 +49,13 @@ void FirstTimeWizard::slot_change_theme(const QString& theme_name) { } -FirstTimeWizard::FirstTimeWizard(bool dangerous, QString server) -{ +FirstTimeWizard::FirstTimeWizard(bool dangerous, QString server){ qDebug() << __func__ << ": dangerous=" << dangerous << " server=" << server; + + // Set window flags and disable close button - force user to use Wizard's cancel button to prevent funk + this->setWindowFlags(this->windowFlags() | Qt::CustomizeWindowHint); + this->setWindowFlags(this->windowFlags() & ~Qt::WindowCloseButtonHint); + // Include css QString theme_name; try @@ -127,7 +131,6 @@ void FirstTimeWizard::initializePage() { void NewOrRestorePage::initializePage() { qDebug() << "NewOrRestorePage:" <<__func__; - } NewOrRestorePage::NewOrRestorePage(FirstTimeWizard *parent) : QWizardPage(parent) { @@ -146,7 +149,9 @@ NewOrRestorePage::NewOrRestorePage(FirstTimeWizard *parent) : QWizardPage(parent setButtonText(QWizard::CommitButton, tr("Next")); + // Remove back button parent->setOption(QWizard::NoBackButtonOnStartPage); + parent->setOption(QWizard::NoBackButtonOnLastPage); form.txtPassword->setEnabled(false); form.txtConfirmPassword->setEnabled(false); @@ -263,6 +268,10 @@ NewOrRestorePage::NewOrRestorePage(FirstTimeWizard *parent) : QWizardPage(parent parent->button(QWizard::CommitButton)->setEnabled(false); parent->button(QWizard::NextButton)->setEnabled(false); + + // Connect cancelEvent + disconnect(parent->button(QWizard::CancelButton ), SIGNAL( clicked() ), parent, SLOT( reject() ) ); + connect(parent->button(QWizard::CancelButton ), SIGNAL( clicked() ), parent, SLOT( cancelEvent() ) ); } NewSeedPage::NewSeedPage(FirstTimeWizard *parent) : QWizardPage(parent) { @@ -298,7 +307,6 @@ void NewSeedPage::initializePage() { parent->setSeed(seed); parent->setBirthday(birthday); form.birthday->setPlainText(birthday); - parent->button(QWizard::CancelButton)->setEnabled(false); disconnect(parent->button(QWizard::CancelButton ), SIGNAL( clicked() ), parent, SLOT( reject() ) ); connect(parent->button(QWizard::CancelButton ), SIGNAL( clicked() ), parent, SLOT( cancelEvent() ) ); qDebug() << __func__ << ": page initialized with birthday=" << birthday; @@ -308,10 +316,13 @@ void NewSeedPage::initializePage() { void FirstTimeWizard::cancelEvent() { qDebug() << __func__; - if( QMessageBox::question( this, ( "Quit Setup" ), ( "Setup is not complete yet. Are you sure you want to quit setup?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { + if( QMessageBox::question( this, tr(( "Quit Setup" )), tr(( "Setup is not complete yet. Are you sure you want to quit setup and close the app?" )), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { qDebug() << __func__ << ": wizard canceled"; - // allow cancel - reject(); + // Allow cancel + reject(); + + // Close the app + qApp->exit(); } } diff --git a/src/firsttimewizard.h b/src/firsttimewizard.h index 8af3510..3c74ed1 100644 --- a/src/firsttimewizard.h +++ b/src/firsttimewizard.h @@ -23,11 +23,10 @@ public: QString _seed; void setSeed(QString Seed); void setBirthday(QString Birthday); - void cancelEvent(); public slots: void slot_change_theme(const QString& themeName); - + void cancelEvent(); protected: int nextId() const;