diff --git a/src/plugins/projectexplorer/importwidget.cpp b/src/plugins/projectexplorer/importwidget.cpp index eac2c44c945..33db7d48df2 100644 --- a/src/plugins/projectexplorer/importwidget.cpp +++ b/src/plugins/projectexplorer/importwidget.cpp @@ -63,10 +63,14 @@ ImportWidget::ImportWidget(QWidget *parent) : connect(importButton, &QAbstractButton::clicked, this, &ImportWidget::handleImportRequest); connect(m_pathChooser->lineEdit(), &QLineEdit::returnPressed, this, [this] { if (m_pathChooser->isValid()) { + m_ownsReturnKey = true; handleImportRequest(); // The next return should trigger the "Configure" button. - QTimer::singleShot(0, this, QOverload<>::of(&QWidget::setFocus)); + QTimer::singleShot(0, this, [this] { + setFocus(); + m_ownsReturnKey = false; + }); } }); @@ -79,9 +83,9 @@ void ImportWidget::setCurrentDirectory(const Utils::FilePath &dir) m_pathChooser->setFileName(dir); } -bool ImportWidget::lineEditHasFocus() const +bool ImportWidget::ownsReturnKey() const { - return m_pathChooser->lineEdit()->hasFocus(); + return m_ownsReturnKey; } void ImportWidget::handleImportRequest() diff --git a/src/plugins/projectexplorer/importwidget.h b/src/plugins/projectexplorer/importwidget.h index 8999bc117d0..5c63beecdb7 100644 --- a/src/plugins/projectexplorer/importwidget.h +++ b/src/plugins/projectexplorer/importwidget.h @@ -44,7 +44,7 @@ public: void setCurrentDirectory(const Utils::FilePath &dir); - bool lineEditHasFocus() const; + bool ownsReturnKey() const; signals: void importFrom(const Utils::FilePath &dir); @@ -53,6 +53,7 @@ private: void handleImportRequest(); Utils::PathChooser *m_pathChooser; + bool m_ownsReturnKey = false; }; } // namespace Internal diff --git a/src/plugins/projectexplorer/targetsetuppage.cpp b/src/plugins/projectexplorer/targetsetuppage.cpp index 0a750199fe7..b5d2bfe3de0 100644 --- a/src/plugins/projectexplorer/targetsetuppage.cpp +++ b/src/plugins/projectexplorer/targetsetuppage.cpp @@ -330,7 +330,7 @@ void TargetSetupPage::setProjectImporter(ProjectImporter *importer) bool TargetSetupPage::importLineEditHasFocus() const { - return m_importWidget->lineEditHasFocus(); + return m_importWidget->ownsReturnKey(); } void TargetSetupPage::setNoteText(const QString &text)