summaryrefslogtreecommitdiff
path: root/src/plugins/projectexplorer
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2019-06-06 17:59:30 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2019-06-12 11:03:10 +0000
commit50dc5674d30e93ef2ef957eb0d2e620c1c486784 (patch)
tree48c925f6d4a73f83f95a52f7083c1a61a3e076df /src/plugins/projectexplorer
parentd96c2e5d1677c25943a9d77bbefbc9300f647968 (diff)
downloadqt-creator-50dc5674d30e93ef2ef957eb0d2e620c1c486784.tar.gz
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>
Diffstat (limited to 'src/plugins/projectexplorer')
-rw-r--r--src/plugins/projectexplorer/importwidget.cpp14
-rw-r--r--src/plugins/projectexplorer/importwidget.h2
-rw-r--r--src/plugins/projectexplorer/targetsettingspanel.cpp2
-rw-r--r--src/plugins/projectexplorer/targetsetuppage.cpp5
-rw-r--r--src/plugins/projectexplorer/targetsetuppage.h1
5 files changed, 24 insertions, 0 deletions
diff --git a/src/plugins/projectexplorer/importwidget.cpp b/src/plugins/projectexplorer/importwidget.cpp
index 369e59b60b..eac2c44c94 100644
--- a/src/plugins/projectexplorer/importwidget.cpp
+++ b/src/plugins/projectexplorer/importwidget.cpp
@@ -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();
diff --git a/src/plugins/projectexplorer/importwidget.h b/src/plugins/projectexplorer/importwidget.h
index b9ecdd16ac..8999bc117d 100644
--- a/src/plugins/projectexplorer/importwidget.h
+++ b/src/plugins/projectexplorer/importwidget.h
@@ -44,6 +44,8 @@ public:
void setCurrentDirectory(const Utils::FilePath &dir);
+ bool lineEditHasFocus() const;
+
signals:
void importFrom(const Utils::FilePath &dir);
diff --git a/src/plugins/projectexplorer/targetsettingspanel.cpp b/src/plugins/projectexplorer/targetsettingspanel.cpp
index c8e707a549..91dee3dd6d 100644
--- a/src/plugins/projectexplorer/targetsettingspanel.cpp
+++ b/src/plugins/projectexplorer/targetsettingspanel.cpp
@@ -95,6 +95,8 @@ protected:
void keyPressEvent(QKeyEvent *event) override
{
+ if (m_targetSetupPage && m_targetSetupPage->importLineEditHasFocus())
+ return;
if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) {
event->accept();
if (m_targetSetupPage)
diff --git a/src/plugins/projectexplorer/targetsetuppage.cpp b/src/plugins/projectexplorer/targetsetuppage.cpp
index ab7d13a76e..0a750199fe 100644
--- a/src/plugins/projectexplorer/targetsetuppage.cpp
+++ b/src/plugins/projectexplorer/targetsetuppage.cpp
@@ -328,6 +328,11 @@ void TargetSetupPage::setProjectImporter(ProjectImporter *importer)
initializePage();
}
+bool TargetSetupPage::importLineEditHasFocus() const
+{
+ return m_importWidget->lineEditHasFocus();
+}
+
void TargetSetupPage::setNoteText(const QString &text)
{
m_ui->descriptionLabel->setText(text);
diff --git a/src/plugins/projectexplorer/targetsetuppage.h b/src/plugins/projectexplorer/targetsetuppage.h
index cbd0305c04..102ffbd57c 100644
--- a/src/plugins/projectexplorer/targetsetuppage.h
+++ b/src/plugins/projectexplorer/targetsetuppage.h
@@ -70,6 +70,7 @@ public:
void setPreferredKitPredicate(const ProjectExplorer::Kit::Predicate &predicate);
void setProjectPath(const QString &dir);
void setProjectImporter(ProjectImporter *importer);
+ bool importLineEditHasFocus() const;
/// Sets whether the targetsetupage uses a scrollarea
/// to host the widgets from the factories