diff --git a/src/plugins/studiowelcome/qdsnewdialog.cpp b/src/plugins/studiowelcome/qdsnewdialog.cpp index 527204c80e8..943ca0be328 100644 --- a/src/plugins/studiowelcome/qdsnewdialog.cpp +++ b/src/plugins/studiowelcome/qdsnewdialog.cpp @@ -99,6 +99,8 @@ QdsNewDialog::QdsNewDialog(QWidget *parent) QObject::connect(&m_wizard, &WizardHandler::statusMessageChanged, this, &QdsNewDialog::onStatusMessageChanged); QObject::connect(&m_wizard, &WizardHandler::projectCanBeCreated, this, &QdsNewDialog::onProjectCanBeCreatedChanged); + m_dialog->installEventFilter(this); + QObject::connect(&m_wizard, &WizardHandler::wizardCreationFailed, this, [this]() { QMessageBox::critical(m_dialog, tr("New project"), tr("Failed to initialize data")); reject(); @@ -110,6 +112,17 @@ QdsNewDialog::QdsNewDialog(QWidget *parent) }); } +bool QdsNewDialog::eventFilter(QObject *obj, QEvent *event) +{ + if (obj == m_dialog && event->type() == QEvent::KeyPress + && static_cast(event)->key() == Qt::Key_Escape) { + reject(); + return true; + } + + return false; +} + void QdsNewDialog::onDeletingWizard() { m_screenSizeModel->setBackendModel(nullptr); diff --git a/src/plugins/studiowelcome/qdsnewdialog.h b/src/plugins/studiowelcome/qdsnewdialog.h index 670b39192d9..09a425c4996 100644 --- a/src/plugins/studiowelcome/qdsnewdialog.h +++ b/src/plugins/studiowelcome/qdsnewdialog.h @@ -42,6 +42,7 @@ class QStandardItemModel; QT_END_NAMESPACE namespace StudioWelcome { + class QdsNewDialog : public QObject, public Core::NewDialog { Q_OBJECT @@ -151,6 +152,7 @@ private: QString projectDescription() const { return m_qmlProjectDescription; } void updateScreenSizes(); + bool eventFilter(QObject *obj, QEvent *ev) override; private slots: void onDeletingWizard();