forked from qt-creator/qt-creator
Git: Use QtcProcess in ChangeSelectionDialog
Change-Id: I7a9d408c007de1f6ea0d17f6fff9cc8b4dcb7b9c Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -156,13 +156,13 @@ void ChangeSelectionDialog::acceptCommand(ChangeCommand command)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Set commit message in details
|
//! Set commit message in details
|
||||||
void ChangeSelectionDialog::setDetails(int exitCode)
|
void ChangeSelectionDialog::setDetails()
|
||||||
{
|
{
|
||||||
Theme *theme = creatorTheme();
|
Theme *theme = creatorTheme();
|
||||||
|
|
||||||
QPalette palette;
|
QPalette palette;
|
||||||
if (exitCode == 0) {
|
if (m_process->result() == QtcProcess::FinishedWithSuccess) {
|
||||||
m_ui->detailsText->setPlainText(QString::fromUtf8(m_process->readAllStandardOutput()));
|
m_ui->detailsText->setPlainText(m_process->stdOut());
|
||||||
palette.setColor(QPalette::Text, theme->color(Theme::TextColorNormal));
|
palette.setColor(QPalette::Text, theme->color(Theme::TextColorNormal));
|
||||||
m_ui->changeNumberEdit->setPalette(palette);
|
m_ui->changeNumberEdit->setPalette(palette);
|
||||||
} else {
|
} else {
|
||||||
@@ -228,15 +228,14 @@ void ChangeSelectionDialog::recalculateDetails()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_process = new QProcess(this);
|
m_process = new QtcProcess(this);
|
||||||
m_process->setWorkingDirectory(workingDir.toString());
|
m_process->setWorkingDirectory(workingDir);
|
||||||
m_process->setProcessEnvironment(m_gitEnvironment.toProcessEnvironment());
|
m_process->setEnvironment(m_gitEnvironment);
|
||||||
|
m_process->setCommand({m_gitExecutable, {"show", "--decorate", "--stat=80", ref}});
|
||||||
|
|
||||||
connect(m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
connect(m_process, &QtcProcess::finished, this, &ChangeSelectionDialog::setDetails);
|
||||||
this, &ChangeSelectionDialog::setDetails);
|
|
||||||
|
|
||||||
m_process->start(m_gitExecutable.toString(), {"show", "--decorate", "--stat=80", ref});
|
m_process->start();
|
||||||
m_process->closeWriteChannel();
|
|
||||||
if (!m_process->waitForStarted())
|
if (!m_process->waitForStarted())
|
||||||
m_ui->detailsText->setPlainText(tr("Error: Could not start Git."));
|
m_ui->detailsText->setPlainText(tr("Error: Could not start Git."));
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -32,10 +32,11 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QProcess;
|
|
||||||
class QStringListModel;
|
class QStringListModel;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace Utils { class QtcProcess; }
|
||||||
|
|
||||||
namespace Git {
|
namespace Git {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -64,7 +65,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void selectCommitFromRecentHistory();
|
void selectCommitFromRecentHistory();
|
||||||
void setDetails(int exitCode);
|
void setDetails();
|
||||||
void recalculateCompletion();
|
void recalculateCompletion();
|
||||||
void recalculateDetails();
|
void recalculateDetails();
|
||||||
void changeTextChanged(const QString &text);
|
void changeTextChanged(const QString &text);
|
||||||
@@ -75,7 +76,7 @@ private:
|
|||||||
|
|
||||||
Ui::ChangeSelectionDialog *m_ui;
|
Ui::ChangeSelectionDialog *m_ui;
|
||||||
|
|
||||||
QProcess *m_process = nullptr;
|
Utils::QtcProcess *m_process = nullptr;
|
||||||
Utils::FilePath m_gitExecutable;
|
Utils::FilePath m_gitExecutable;
|
||||||
Utils::Environment m_gitEnvironment;
|
Utils::Environment m_gitEnvironment;
|
||||||
ChangeCommand m_command = NoCommand;
|
ChangeCommand m_command = NoCommand;
|
||||||
|
|||||||
Reference in New Issue
Block a user