From bc9c57756b71c8681a3604aa70461735ceb1da09 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Wed, 3 Feb 2016 20:44:08 +0200 Subject: [PATCH] Git: Use PathChooser for Actions on Commits Change-Id: Id88648cd35856d2767a0ba7a09e2c9171ba22b34 Reviewed-by: Robert Loehning --- src/plugins/git/changeselectiondialog.cpp | 33 ++++++----------------- src/plugins/git/changeselectiondialog.h | 1 - src/plugins/git/changeselectiondialog.ui | 17 ++++++------ 3 files changed, 16 insertions(+), 35 deletions(-) diff --git a/src/plugins/git/changeselectiondialog.cpp b/src/plugins/git/changeselectiondialog.cpp index 2eceb10904a..84b33798fb1 100644 --- a/src/plugins/git/changeselectiondialog.cpp +++ b/src/plugins/git/changeselectiondialog.cpp @@ -31,6 +31,7 @@ #include +#include #include #include @@ -60,19 +61,19 @@ ChangeSelectionDialog::ChangeSelectionDialog(const QString &workingDirectory, Co setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); m_gitExecutable = GitPlugin::instance()->client()->vcsBinary(); m_ui->setupUi(this); - m_ui->workingDirectoryEdit->setText(workingDirectory); + m_ui->workingDirectoryChooser->setExpectedKind(PathChooser::ExistingDirectory); + m_ui->workingDirectoryChooser->setPromptDialogTitle(tr("Select Git Directory")); + m_ui->workingDirectoryChooser->setPath(workingDirectory); m_gitEnvironment = GitPlugin::instance()->client()->processEnvironment(); m_ui->changeNumberEdit->setFocus(); m_ui->changeNumberEdit->selectAll(); - connect(m_ui->changeNumberEdit, &Utils::CompletingLineEdit::textChanged, + connect(m_ui->changeNumberEdit, &CompletingLineEdit::textChanged, this, &ChangeSelectionDialog::changeTextChanged); - connect(m_ui->workingDirectoryEdit, &QLineEdit::textChanged, + connect(m_ui->workingDirectoryChooser, &PathChooser::pathChanged, this, &ChangeSelectionDialog::recalculateDetails); - connect(m_ui->workingDirectoryEdit, &QLineEdit::textChanged, + connect(m_ui->workingDirectoryChooser, &PathChooser::pathChanged, this, &ChangeSelectionDialog::recalculateCompletion); - connect(m_ui->selectDirectoryButton, &QPushButton::clicked, - this, &ChangeSelectionDialog::chooseWorkingDirectory); connect(m_ui->selectFromHistoryButton, &QPushButton::clicked, this, &ChangeSelectionDialog::selectCommitFromRecentHistory); connect(m_ui->showButton, &QPushButton::clicked, @@ -133,20 +134,9 @@ void ChangeSelectionDialog::selectCommitFromRecentHistory() m_ui->changeNumberEdit->setText(dialog.commit()); } -void ChangeSelectionDialog::chooseWorkingDirectory() -{ - QString folder = QFileDialog::getExistingDirectory(this, tr("Select Git Directory"), - m_ui->workingDirectoryEdit->text()); - - if (folder.isEmpty()) - return; - - m_ui->workingDirectoryEdit->setText(folder); -} - QString ChangeSelectionDialog::workingDirectory() const { - const QString workingDir = m_ui->workingDirectoryEdit->text(); + const QString workingDir = m_ui->workingDirectoryChooser->path(); if (workingDir.isEmpty() || !QDir(workingDir).exists()) return QString(); @@ -244,16 +234,9 @@ void ChangeSelectionDialog::recalculateDetails() enableButtons(false); const QString workingDir = workingDirectory(); - QPalette palette = m_ui->workingDirectoryEdit->palette(); - Theme *theme = creatorTheme(); if (workingDir.isEmpty()) { m_ui->detailsText->setPlainText(tr("Error: Bad working directory.")); - palette.setColor(QPalette::Text, theme->color(Theme::TextColorError)); - m_ui->workingDirectoryEdit->setPalette(palette); return; - } else { - palette.setColor(QPalette::Text, theme->color(Theme::TextColorNormal)); - m_ui->workingDirectoryEdit->setPalette(palette); } const QString ref = change(); diff --git a/src/plugins/git/changeselectiondialog.h b/src/plugins/git/changeselectiondialog.h index 653c6b6f825..d04c88b3879 100644 --- a/src/plugins/git/changeselectiondialog.h +++ b/src/plugins/git/changeselectiondialog.h @@ -68,7 +68,6 @@ public: ChangeCommand command() const; private: - void chooseWorkingDirectory(); void selectCommitFromRecentHistory(); void setDetails(int exitCode); void recalculateCompletion(); diff --git a/src/plugins/git/changeselectiondialog.ui b/src/plugins/git/changeselectiondialog.ui index 10ddde79abc..3ccd3f31eaa 100644 --- a/src/plugins/git/changeselectiondialog.ui +++ b/src/plugins/git/changeselectiondialog.ui @@ -24,15 +24,8 @@ - - - - - - - Browse &Directory... - - + + @@ -128,6 +121,12 @@ QLineEdit
utils/completinglineedit.h
+ + Utils::PathChooser + QWidget +
utils/pathchooser.h
+ 1 +