diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2019-06-26 17:05:14 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2019-06-27 13:21:57 +0000 |
commit | a111f251261159b50e92d6866f2058c66b43e390 (patch) | |
tree | 0db9ae8c462b1f8e71048c7662e15da12bb8ab8e /src/plugins/projectexplorer/importwidget.cpp | |
parent | f25408c4364c977c97511ccad1b61ecd7b3df872 (diff) | |
download | qt-creator-a111f251261159b50e92d6866f2058c66b43e390.tar.gz |
Project import: Fix focus issue
If the user presses return in the path chooser, and the directory does
not contain a proper build, then a message box will come up, after which
the focus might not be at the path chooser anymore, which breaks our
(admittedly somewhat brittle) logic. So we now keep an explicit state
that tells us whether the parent widget should be allowed to handle the
return key or not.
Amends 50dc5674d30e.
Change-Id: Ia4643b57641fda591292d20e6883e1c8bc281c0f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/projectexplorer/importwidget.cpp')
-rw-r--r-- | src/plugins/projectexplorer/importwidget.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/plugins/projectexplorer/importwidget.cpp b/src/plugins/projectexplorer/importwidget.cpp index eac2c44c94..33db7d48df 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() |