forked from qt-creator/qt-creator
ProjectExplorer: Improve "import project" keyboard event handling
Pressing return in the path chooser used to activate the "Configure" button, which is not what users intend. Fixes: QTCREATORBUG-17471 Change-Id: I86bc0dd9c976da35026654c7873dc4b63e45593c Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include <utils/pathchooser.h>
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QTimer>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
@@ -60,6 +61,14 @@ ImportWidget::ImportWidget(QWidget *parent) :
|
||||
layout->addWidget(importButton);
|
||||
|
||||
connect(importButton, &QAbstractButton::clicked, this, &ImportWidget::handleImportRequest);
|
||||
connect(m_pathChooser->lineEdit(), &QLineEdit::returnPressed, this, [this] {
|
||||
if (m_pathChooser->isValid()) {
|
||||
handleImportRequest();
|
||||
|
||||
// The next return should trigger the "Configure" button.
|
||||
QTimer::singleShot(0, this, QOverload<>::of(&QWidget::setFocus));
|
||||
}
|
||||
});
|
||||
|
||||
detailsWidget->setWidget(widget);
|
||||
}
|
||||
@@ -70,6 +79,11 @@ void ImportWidget::setCurrentDirectory(const Utils::FilePath &dir)
|
||||
m_pathChooser->setFileName(dir);
|
||||
}
|
||||
|
||||
bool ImportWidget::lineEditHasFocus() const
|
||||
{
|
||||
return m_pathChooser->lineEdit()->hasFocus();
|
||||
}
|
||||
|
||||
void ImportWidget::handleImportRequest()
|
||||
{
|
||||
Utils::FilePath dir = m_pathChooser->fileName();
|
||||
|
||||
Reference in New Issue
Block a user