forked from qt-creator/qt-creator
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 50dc5674d3
.
Change-Id: Ia4643b57641fda591292d20e6883e1c8bc281c0f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -63,10 +63,14 @@ ImportWidget::ImportWidget(QWidget *parent) :
|
|||||||
connect(importButton, &QAbstractButton::clicked, this, &ImportWidget::handleImportRequest);
|
connect(importButton, &QAbstractButton::clicked, this, &ImportWidget::handleImportRequest);
|
||||||
connect(m_pathChooser->lineEdit(), &QLineEdit::returnPressed, this, [this] {
|
connect(m_pathChooser->lineEdit(), &QLineEdit::returnPressed, this, [this] {
|
||||||
if (m_pathChooser->isValid()) {
|
if (m_pathChooser->isValid()) {
|
||||||
|
m_ownsReturnKey = true;
|
||||||
handleImportRequest();
|
handleImportRequest();
|
||||||
|
|
||||||
// The next return should trigger the "Configure" button.
|
// 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);
|
m_pathChooser->setFileName(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImportWidget::lineEditHasFocus() const
|
bool ImportWidget::ownsReturnKey() const
|
||||||
{
|
{
|
||||||
return m_pathChooser->lineEdit()->hasFocus();
|
return m_ownsReturnKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImportWidget::handleImportRequest()
|
void ImportWidget::handleImportRequest()
|
||||||
|
@@ -44,7 +44,7 @@ public:
|
|||||||
|
|
||||||
void setCurrentDirectory(const Utils::FilePath &dir);
|
void setCurrentDirectory(const Utils::FilePath &dir);
|
||||||
|
|
||||||
bool lineEditHasFocus() const;
|
bool ownsReturnKey() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void importFrom(const Utils::FilePath &dir);
|
void importFrom(const Utils::FilePath &dir);
|
||||||
@@ -53,6 +53,7 @@ private:
|
|||||||
void handleImportRequest();
|
void handleImportRequest();
|
||||||
|
|
||||||
Utils::PathChooser *m_pathChooser;
|
Utils::PathChooser *m_pathChooser;
|
||||||
|
bool m_ownsReturnKey = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -330,7 +330,7 @@ void TargetSetupPage::setProjectImporter(ProjectImporter *importer)
|
|||||||
|
|
||||||
bool TargetSetupPage::importLineEditHasFocus() const
|
bool TargetSetupPage::importLineEditHasFocus() const
|
||||||
{
|
{
|
||||||
return m_importWidget->lineEditHasFocus();
|
return m_importWidget->ownsReturnKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TargetSetupPage::setNoteText(const QString &text)
|
void TargetSetupPage::setNoteText(const QString &text)
|
||||||
|
Reference in New Issue
Block a user