forked from qt-creator/qt-creator
Git: Use PathChooser for Actions on Commits
Change-Id: Id88648cd35856d2767a0ba7a09e2c9171ba22b34 Reviewed-by: Robert Loehning <robert.loehning@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
558c08e2c5
commit
bc9c57756b
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include <coreplugin/vcsmanager.h>
|
#include <coreplugin/vcsmanager.h>
|
||||||
|
|
||||||
|
#include <utils/pathchooser.h>
|
||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
@@ -60,19 +61,19 @@ ChangeSelectionDialog::ChangeSelectionDialog(const QString &workingDirectory, Co
|
|||||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
m_gitExecutable = GitPlugin::instance()->client()->vcsBinary();
|
m_gitExecutable = GitPlugin::instance()->client()->vcsBinary();
|
||||||
m_ui->setupUi(this);
|
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_gitEnvironment = GitPlugin::instance()->client()->processEnvironment();
|
||||||
m_ui->changeNumberEdit->setFocus();
|
m_ui->changeNumberEdit->setFocus();
|
||||||
m_ui->changeNumberEdit->selectAll();
|
m_ui->changeNumberEdit->selectAll();
|
||||||
|
|
||||||
connect(m_ui->changeNumberEdit, &Utils::CompletingLineEdit::textChanged,
|
connect(m_ui->changeNumberEdit, &CompletingLineEdit::textChanged,
|
||||||
this, &ChangeSelectionDialog::changeTextChanged);
|
this, &ChangeSelectionDialog::changeTextChanged);
|
||||||
connect(m_ui->workingDirectoryEdit, &QLineEdit::textChanged,
|
connect(m_ui->workingDirectoryChooser, &PathChooser::pathChanged,
|
||||||
this, &ChangeSelectionDialog::recalculateDetails);
|
this, &ChangeSelectionDialog::recalculateDetails);
|
||||||
connect(m_ui->workingDirectoryEdit, &QLineEdit::textChanged,
|
connect(m_ui->workingDirectoryChooser, &PathChooser::pathChanged,
|
||||||
this, &ChangeSelectionDialog::recalculateCompletion);
|
this, &ChangeSelectionDialog::recalculateCompletion);
|
||||||
connect(m_ui->selectDirectoryButton, &QPushButton::clicked,
|
|
||||||
this, &ChangeSelectionDialog::chooseWorkingDirectory);
|
|
||||||
connect(m_ui->selectFromHistoryButton, &QPushButton::clicked,
|
connect(m_ui->selectFromHistoryButton, &QPushButton::clicked,
|
||||||
this, &ChangeSelectionDialog::selectCommitFromRecentHistory);
|
this, &ChangeSelectionDialog::selectCommitFromRecentHistory);
|
||||||
connect(m_ui->showButton, &QPushButton::clicked,
|
connect(m_ui->showButton, &QPushButton::clicked,
|
||||||
@@ -133,20 +134,9 @@ void ChangeSelectionDialog::selectCommitFromRecentHistory()
|
|||||||
m_ui->changeNumberEdit->setText(dialog.commit());
|
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
|
QString ChangeSelectionDialog::workingDirectory() const
|
||||||
{
|
{
|
||||||
const QString workingDir = m_ui->workingDirectoryEdit->text();
|
const QString workingDir = m_ui->workingDirectoryChooser->path();
|
||||||
if (workingDir.isEmpty() || !QDir(workingDir).exists())
|
if (workingDir.isEmpty() || !QDir(workingDir).exists())
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
@@ -244,16 +234,9 @@ void ChangeSelectionDialog::recalculateDetails()
|
|||||||
enableButtons(false);
|
enableButtons(false);
|
||||||
|
|
||||||
const QString workingDir = workingDirectory();
|
const QString workingDir = workingDirectory();
|
||||||
QPalette palette = m_ui->workingDirectoryEdit->palette();
|
|
||||||
Theme *theme = creatorTheme();
|
|
||||||
if (workingDir.isEmpty()) {
|
if (workingDir.isEmpty()) {
|
||||||
m_ui->detailsText->setPlainText(tr("Error: Bad working directory."));
|
m_ui->detailsText->setPlainText(tr("Error: Bad working directory."));
|
||||||
palette.setColor(QPalette::Text, theme->color(Theme::TextColorError));
|
|
||||||
m_ui->workingDirectoryEdit->setPalette(palette);
|
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
palette.setColor(QPalette::Text, theme->color(Theme::TextColorNormal));
|
|
||||||
m_ui->workingDirectoryEdit->setPalette(palette);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString ref = change();
|
const QString ref = change();
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ public:
|
|||||||
ChangeCommand command() const;
|
ChangeCommand command() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void chooseWorkingDirectory();
|
|
||||||
void selectCommitFromRecentHistory();
|
void selectCommitFromRecentHistory();
|
||||||
void setDetails(int exitCode);
|
void setDetails(int exitCode);
|
||||||
void recalculateCompletion();
|
void recalculateCompletion();
|
||||||
|
|||||||
@@ -24,15 +24,8 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1" colspan="2">
|
||||||
<widget class="QLineEdit" name="workingDirectoryEdit"/>
|
<widget class="Utils::PathChooser" name="workingDirectoryChooser" native="true"/>
|
||||||
</item>
|
|
||||||
<item row="0" column="2">
|
|
||||||
<widget class="QPushButton" name="selectDirectoryButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Browse &Directory...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="changeLabel">
|
<widget class="QLabel" name="changeLabel">
|
||||||
@@ -128,6 +121,12 @@
|
|||||||
<extends>QLineEdit</extends>
|
<extends>QLineEdit</extends>
|
||||||
<header location="global">utils/completinglineedit.h</header>
|
<header location="global">utils/completinglineedit.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>Utils::PathChooser</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header location="global">utils/pathchooser.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
|
|||||||
Reference in New Issue
Block a user