aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2022-09-19 12:08:38 +0200
committerJarek Kobus <jaroslaw.kobus@qt.io>2022-09-20 10:41:35 +0000
commitb795bd8042871cbfd741a365396184d51d6df64e (patch)
tree9c25ac7148dcbe4230b2de58536ea1efd90a8dc3 /src/plugins
parent5e10ea19c1123293ae048e1eb66c3cb77fc0ea7b (diff)
VcsPlugin: Use VcsCommand::done() signal instead of finished()
Conform to QtcProcess interface. Use result() when needed. Change-Id: Idd4c71d9a103e8649b08ec7787c2f286423a31ec Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/git/branchview.cpp2
-rw-r--r--src/plugins/git/gitclient.cpp37
-rw-r--r--src/plugins/gitlab/gitlabclonedialog.cpp55
-rw-r--r--src/plugins/vcsbase/vcsbaseclient.cpp21
-rw-r--r--src/plugins/vcsbase/vcsbasediffeditorcontroller.cpp5
-rw-r--r--src/plugins/vcsbase/vcsbaseeditor.cpp4
-rw-r--r--src/plugins/vcsbase/wizard/vcscommandpage.cpp4
7 files changed, 65 insertions, 63 deletions
diff --git a/src/plugins/git/branchview.cpp b/src/plugins/git/branchview.cpp
index 6c03b91d53..58a137dacb 100644
--- a/src/plugins/git/branchview.cpp
+++ b/src/plugins/git/branchview.cpp
@@ -420,7 +420,7 @@ bool BranchView::checkout()
const bool moveChanges = branchCheckoutDialog.moveLocalChangesToNextBranch();
const bool popStash = branchCheckoutDialog.popStashOfNextBranch();
if (command && (moveChanges || popStash)) {
- connect(command, &VcsCommand::finished,
+ connect(command, &VcsCommand::done,
this, [this, client, popMessageStart, moveChanges, popStash] {
if (moveChanges) {
client->endStashScope(m_repository);
diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp
index 8066adac9b..934337b4f4 100644
--- a/src/plugins/git/gitclient.cpp
+++ b/src/plugins/git/gitclient.cpp
@@ -320,7 +320,7 @@ void GitBaseDiffEditorController::updateBranchList()
VcsCommand *command = m_instance->vcsExec(baseDirectory(),
{"branch", noColorOption, "-a", "--contains", revision});
- connect(command, &VcsCommand::finished, this, [this, command] {
+ connect(command, &VcsCommand::done, this, [this, command] {
const QString remotePrefix = "remotes/";
const QString localPrefix = "<Local>";
const int prefixLength = remotePrefix.length();
@@ -731,7 +731,7 @@ public:
handler->setParent(command); // delete when command goes out of scope
command->addFlags(VcsCommand::ExpectRepoChanges);
- connect(command, &VcsCommand::finished, handler, [handler, command] {
+ connect(command, &VcsCommand::done, handler, [handler, command] {
handler->readStdOut(command->cleanedStdOut());
handler->readStdErr(command->cleanedStdErr());
});
@@ -1133,7 +1133,7 @@ void GitClient::status(const FilePath &workingDirectory) const
{
VcsOutputWindow::setRepository(workingDirectory);
VcsCommand *command = vcsExec(workingDirectory, {"status", "-u"}, nullptr, true);
- connect(command, &VcsCommand::finished, VcsOutputWindow::instance(),
+ connect(command, &VcsCommand::done, VcsOutputWindow::instance(),
&VcsOutputWindow::clearRepository, Qt::QueuedConnection);
}
@@ -1378,11 +1378,10 @@ VcsCommand *GitClient::checkout(const FilePath &workingDirectory, const QString
VcsCommand *command = vcsExec(
workingDirectory, arguments, nullptr, true,
VcsCommand::ExpectRepoChanges | VcsCommand::ShowSuccessMessage);
- connect(command, &VcsCommand::finished,
- this, [this, workingDirectory, stashMode](bool success) {
+ connect(command, &VcsCommand::done, this, [this, workingDirectory, stashMode, command] {
if (stashMode == StashMode::TryStash)
endStashScope(workingDirectory);
- if (success)
+ if (command->result() == ProcessResult::FinishedWithSuccess)
updateSubmodulesIfNeeded(workingDirectory, true);
});
return command;
@@ -1490,8 +1489,8 @@ void GitClient::removeStaleRemoteBranches(const FilePath &workingDirectory, cons
VcsCommand *command = vcsExec(workingDirectory, arguments, nullptr, true,
VcsCommand::ShowSuccessMessage);
- connect(command, &VcsCommand::finished, this, [workingDirectory](bool success) {
- if (success)
+ connect(command, &VcsCommand::done, this, [workingDirectory, command] {
+ if (command->result() == ProcessResult::FinishedWithSuccess)
GitPlugin::updateBranches(workingDirectory);
});
}
@@ -2319,7 +2318,7 @@ void GitClient::updateSubmodulesIfNeeded(const FilePath &workingDirectory, bool
VcsCommand *cmd = vcsExec(workingDirectory, {"submodule", "update"}, nullptr, true,
VcsCommand::ExpectRepoChanges);
- connect(cmd, &VcsCommand::finished, this, &GitClient::finishSubmoduleUpdate);
+ connect(cmd, &VcsCommand::done, this, &GitClient::finishSubmoduleUpdate);
}
void GitClient::finishSubmoduleUpdate()
@@ -3095,8 +3094,8 @@ void GitClient::fetch(const FilePath &workingDirectory, const QString &remote)
QStringList const arguments = {"fetch", (remote.isEmpty() ? "--all" : remote)};
VcsCommand *command = vcsExec(workingDirectory, arguments, nullptr, true,
VcsCommand::ShowSuccessMessage);
- connect(command, &VcsCommand::finished, this, [workingDirectory](bool success) {
- if (success)
+ connect(command, &VcsCommand::done, this, [workingDirectory, command] {
+ if (command->result() == ProcessResult::FinishedWithSuccess)
GitPlugin::updateBranches(workingDirectory);
});
}
@@ -3126,8 +3125,8 @@ void GitClient::pull(const FilePath &workingDirectory, bool rebase)
}
VcsCommand *command = vcsExecAbortable(workingDirectory, arguments, rebase, abortCommand);
- connect(command, &VcsCommand::finished, this, [this, workingDirectory](bool success) {
- if (success)
+ connect(command, &VcsCommand::done, this, [this, workingDirectory, command] {
+ if (command->result() == ProcessResult::FinishedWithSuccess)
updateSubmodulesIfNeeded(workingDirectory, true);
}, Qt::QueuedConnection);
}
@@ -3263,11 +3262,11 @@ public:
nullptr, true, VcsCommand::ShowSuccessMessage);
// Make command a parent of this in order to delete this when command is deleted
setParent(command);
- connect(command, &VcsCommand::finished, this, [=](bool success) {
+ connect(command, &VcsCommand::done, this, [=] {
QString pushFallbackCommand;
const PushFailure pushFailure = handleError(command->cleanedStdErr(),
&pushFallbackCommand);
- if (success) {
+ if (command->result() == ProcessResult::FinishedWithSuccess) {
GitPlugin::updateCurrentBranch();
return;
}
@@ -3288,8 +3287,8 @@ public:
VcsCommand *rePushCommand = m_gitClient->vcsExec(workingDir,
QStringList({"push", "--force-with-lease"}) + pushArgs,
nullptr, true, VcsCommand::ShowSuccessMessage);
- connect(rePushCommand, &VcsCommand::finished, this, [](bool success) {
- if (success)
+ connect(rePushCommand, &VcsCommand::done, this, [rePushCommand] {
+ if (rePushCommand->result() == ProcessResult::FinishedWithSuccess)
GitPlugin::updateCurrentBranch();
});
return;
@@ -3310,8 +3309,8 @@ public:
pushFallbackCommand.split(' ', Qt::SkipEmptyParts);
VcsCommand *rePushCommand = m_gitClient->vcsExec(workingDir,
fallbackCommandParts.mid(1), nullptr, true, VcsCommand::ShowSuccessMessage);
- connect(rePushCommand, &VcsCommand::finished, this, [workingDir](bool success) {
- if (success)
+ connect(rePushCommand, &VcsCommand::done, this, [workingDir, rePushCommand] {
+ if (rePushCommand->result() == ProcessResult::FinishedWithSuccess)
GitPlugin::updateBranches(workingDir);
});
});
diff --git a/src/plugins/gitlab/gitlabclonedialog.cpp b/src/plugins/gitlab/gitlabclonedialog.cpp
index 1ac219e437..3e9957e18d 100644
--- a/src/plugins/gitlab/gitlabclonedialog.cpp
+++ b/src/plugins/gitlab/gitlabclonedialog.cpp
@@ -40,6 +40,7 @@
#include <QPushButton>
#include <QVBoxLayout>
+using namespace Utils;
using namespace VcsBase;
namespace GitLab {
@@ -55,12 +56,12 @@ GitLabCloneDialog::GitLabCloneDialog(const Project &project, QWidget *parent)
m_repositoryCB = new QComboBox(this);
m_repositoryCB->addItems({project.sshUrl, project.httpUrl});
form->addRow(tr("Repository"), m_repositoryCB);
- m_pathChooser = new Utils::PathChooser(this);
- m_pathChooser->setExpectedKind(Utils::PathChooser::ExistingDirectory);
+ m_pathChooser = new PathChooser(this);
+ m_pathChooser->setExpectedKind(PathChooser::ExistingDirectory);
form->addRow(tr("Path"), m_pathChooser);
- m_directoryLE = new Utils::FancyLineEdit(this);
- m_directoryLE->setValidationFunction([this](Utils::FancyLineEdit *e, QString *msg) {
- const Utils::FilePath fullPath = m_pathChooser->filePath().pathAppended(e->text());
+ m_directoryLE = new FancyLineEdit(this);
+ m_directoryLE->setValidationFunction([this](FancyLineEdit *e, QString *msg) {
+ const FilePath fullPath = m_pathChooser->filePath().pathAppended(e->text());
bool alreadyExists = fullPath.exists();
if (alreadyExists && msg)
*msg = tr("Path \"%1\" already exists.").arg(fullPath.toUserOutput());
@@ -75,7 +76,7 @@ GitLabCloneDialog::GitLabCloneDialog(const Project &project, QWidget *parent)
m_cloneOutput->setReadOnly(true);
centerLayout->addWidget(m_cloneOutput);
layout->addLayout(centerLayout);
- m_infoLabel = new Utils::InfoLabel(this);
+ m_infoLabel = new InfoLabel(this);
layout->addWidget(m_infoLabel);
auto buttons = new QDialogButtonBox(QDialogButtonBox::Cancel, this);
m_cloneButton = new QPushButton(tr("Clone"), this);
@@ -91,11 +92,11 @@ GitLabCloneDialog::GitLabCloneDialog(const Project &project, QWidget *parent)
QTC_ASSERT(slashIndex > 0, return);
m_directoryLE->setText(path.mid(slashIndex + 1));
- connect(m_pathChooser, &Utils::PathChooser::textChanged, this, [this] {
+ connect(m_pathChooser, &PathChooser::textChanged, this, [this] {
m_directoryLE->validate();
GitLabCloneDialog::updateUi();
});
- connect(m_directoryLE, &Utils::FancyLineEdit::textChanged, this, &GitLabCloneDialog::updateUi);
+ connect(m_directoryLE, &FancyLineEdit::textChanged, this, &GitLabCloneDialog::updateUi);
connect(m_cloneButton, &QPushButton::clicked, this, &GitLabCloneDialog::cloneProject);
connect(m_cancelButton, &QPushButton::clicked,
this, &GitLabCloneDialog::cancel);
@@ -118,10 +119,10 @@ void GitLabCloneDialog::updateUi()
m_cloneButton->setEnabled(pathValid && directoryValid);
if (!pathValid) {
m_infoLabel->setText(m_pathChooser->errorMessage());
- m_infoLabel->setType(Utils::InfoLabel::Error);
+ m_infoLabel->setType(InfoLabel::Error);
} else if (!directoryValid) {
m_infoLabel->setText(m_directoryLE->errorMessage());
- m_infoLabel->setType(Utils::InfoLabel::Error);
+ m_infoLabel->setType(InfoLabel::Error);
}
m_infoLabel->setVisible(!pathValid || !directoryValid);
}
@@ -129,14 +130,14 @@ void GitLabCloneDialog::updateUi()
void GitLabCloneDialog::cloneProject()
{
VcsBasePluginPrivate *vc = static_cast<VcsBasePluginPrivate *>(
- Core::VcsManager::versionControl(Utils::Id::fromString("G.Git")));
+ Core::VcsManager::versionControl(Id::fromString("G.Git")));
QTC_ASSERT(vc, return);
const QStringList extraArgs = m_submodulesCB->isChecked() ? QStringList{ "--recursive" }
: QStringList{};
m_command = vc->createInitialCheckoutCommand(m_repositoryCB->currentText(),
m_pathChooser->absoluteFilePath(),
m_directoryLE->text(), extraArgs);
- const Utils::FilePath workingDirectory = m_pathChooser->absoluteFilePath();
+ const FilePath workingDirectory = m_pathChooser->absoluteFilePath();
m_command->setProgressiveOutput(true);
connect(m_command, &VcsCommand::stdOutText, this, [this](const QString &text) {
m_cloneOutput->appendPlainText(text);
@@ -144,7 +145,9 @@ void GitLabCloneDialog::cloneProject()
connect(m_command, &VcsCommand::stdErrText, this, [this](const QString &text) {
m_cloneOutput->appendPlainText(text);
});
- connect(m_command, &VcsCommand::finished, this, &GitLabCloneDialog::cloneFinished);
+ connect(m_command, &VcsCommand::done, this, [this] {
+ cloneFinished(m_command->result() == ProcessResult::FinishedWithSuccess);
+ });
QApplication::setOverrideCursor(Qt::WaitCursor);
m_cloneOutput->clear();
@@ -166,12 +169,12 @@ void GitLabCloneDialog::cancel()
}
}
-static Utils::FilePaths scanDirectoryForFiles(const Utils::FilePath &directory)
+static FilePaths scanDirectoryForFiles(const FilePath &directory)
{
- Utils::FilePaths result;
- const Utils::FilePaths entries = directory.dirEntries(QDir::AllEntries | QDir::NoDotAndDotDot);
+ FilePaths result;
+ const FilePaths entries = directory.dirEntries(QDir::AllEntries | QDir::NoDotAndDotDot);
- for (const Utils::FilePath &entry : entries) {
+ for (const FilePath &entry : entries) {
if (entry.isDir())
result.append(scanDirectoryForFiles(entry));
else
@@ -194,21 +197,19 @@ void GitLabCloneDialog::cloneFinished(bool success)
m_cloneOutput->appendPlainText(tr("Cloning succeeded.") + emptyLine);
m_cloneButton->setEnabled(false);
- const Utils::FilePath base = m_pathChooser->filePath().pathAppended(m_directoryLE->text());
- Utils::FilePaths filesWeMayOpen
- = Utils::filtered(scanDirectoryForFiles(base), [](const Utils::FilePath &f) {
- return ProjectExplorer::ProjectManager::canOpenProjectForMimeType(
- Utils::mimeTypeForFile(f));
+ const FilePath base = m_pathChooser->filePath().pathAppended(m_directoryLE->text());
+ FilePaths filesWeMayOpen = filtered(scanDirectoryForFiles(base), [](const FilePath &f) {
+ return ProjectExplorer::ProjectManager::canOpenProjectForMimeType(mimeTypeForFile(f));
});
// limit the files to the most top-level item(s)
int minimum = std::numeric_limits<int>::max();
- for (const Utils::FilePath &f : filesWeMayOpen) {
+ for (const FilePath &f : filesWeMayOpen) {
int parentCount = f.toString().count('/');
if (parentCount < minimum)
minimum = parentCount;
}
- filesWeMayOpen = Utils::filtered(filesWeMayOpen, [minimum](const Utils::FilePath &f) {
+ filesWeMayOpen = filtered(filesWeMayOpen, [minimum](const FilePath &f) {
return f.toString().count('/') == minimum;
});
@@ -219,8 +220,7 @@ void GitLabCloneDialog::cloneFinished(bool success)
"opened. Try importing the project as a generic project."));
accept();
} else {
- const QStringList pFiles = Utils::transform(filesWeMayOpen,
- [base](const Utils::FilePath &f) {
+ const QStringList pFiles = Utils::transform(filesWeMayOpen, [base](const FilePath &f) {
return f.relativePath(base).toUserOutput();
});
bool ok = false;
@@ -234,8 +234,7 @@ void GitLabCloneDialog::cloneFinished(bool success)
}
} else {
m_cloneOutput->appendPlainText(tr("Cloning failed.") + emptyLine);
- const Utils::FilePath fullPath = m_pathChooser->filePath()
- .pathAppended(m_directoryLE->text());
+ const FilePath fullPath = m_pathChooser->filePath().pathAppended(m_directoryLE->text());
fullPath.removeRecursively();
m_cloneButton->setEnabled(true);
m_cancelButton->setEnabled(true);
diff --git a/src/plugins/vcsbase/vcsbaseclient.cpp b/src/plugins/vcsbase/vcsbaseclient.cpp
index adf70c831a..a472ab33cc 100644
--- a/src/plugins/vcsbase/vcsbaseclient.cpp
+++ b/src/plugins/vcsbase/vcsbaseclient.cpp
@@ -81,7 +81,7 @@ VcsCommand *VcsBaseClientImpl::createCommand(const FilePath &workingDirectory,
if (editor) // assume that the commands output is the important thing
cmd->addFlags(VcsCommand::SilentOutput);
} else if (editor) {
- connect(cmd, &VcsCommand::finished, editor,
+ connect(cmd, &VcsCommand::done, editor,
[editor, cmd] { editor->setPlainText(cmd->cleanedStdOut()); });
}
@@ -412,8 +412,8 @@ void VcsBaseClient::revertFile(const FilePath &workingDir,
// Indicate repository change or file list
VcsCommand *cmd = createCommand(workingDir);
const QStringList files = QStringList(workingDir.pathAppended(file).toString());
- connect(cmd, &VcsCommand::finished, this, [this, files](bool success) {
- if (success)
+ connect(cmd, &VcsCommand::done, this, [this, files, cmd] {
+ if (cmd->result() == ProcessResult::FinishedWithSuccess)
emit changed(files);
}, Qt::QueuedConnection);
enqueueJob(cmd, args);
@@ -428,8 +428,8 @@ void VcsBaseClient::revertAll(const FilePath &workingDir,
// Indicate repository change or file list
VcsCommand *cmd = createCommand(workingDir);
const QStringList files = QStringList(workingDir.toString());
- connect(cmd, &VcsCommand::finished, this, [this, files](bool success) {
- if (success)
+ connect(cmd, &VcsCommand::done, this, [this, files, cmd] {
+ if (cmd->result() == ProcessResult::FinishedWithSuccess)
emit changed(files);
}, Qt::QueuedConnection);
enqueueJob(createCommand(workingDir), args);
@@ -443,8 +443,7 @@ void VcsBaseClient::status(const FilePath &workingDir,
args << extraOptions << file;
VcsOutputWindow::setRepository(workingDir);
VcsCommand *cmd = createCommand(workingDir, nullptr, VcsWindowOutputBind);
- connect(cmd, &VcsCommand::finished,
- VcsOutputWindow::instance(), &VcsOutputWindow::clearRepository,
+ connect(cmd, &VcsCommand::done, VcsOutputWindow::instance(), &VcsOutputWindow::clearRepository,
Qt::QueuedConnection);
enqueueJob(cmd, args);
}
@@ -454,7 +453,7 @@ void VcsBaseClient::emitParsedStatus(const FilePath &repository, const QStringLi
QStringList args(vcsCommandString(StatusCommand));
args << extraOptions;
VcsCommand *cmd = createCommand(repository);
- connect(cmd, &VcsCommand::finished, this, [this, cmd] { statusParser(cmd->cleanedStdOut()); });
+ connect(cmd, &VcsCommand::done, this, [this, cmd] { statusParser(cmd->cleanedStdOut()); });
enqueueJob(cmd, args);
}
@@ -528,8 +527,8 @@ void VcsBaseClient::update(const FilePath &repositoryRoot, const QString &revisi
QStringList args(vcsCommandString(UpdateCommand));
args << revisionSpec(revision) << extraOptions;
VcsCommand *cmd = createCommand(repositoryRoot);
- connect(cmd, &VcsCommand::finished, this, [this, repositoryRoot](bool success) {
- if (success)
+ connect(cmd, &VcsCommand::done, this, [this, repositoryRoot, cmd] {
+ if (cmd->result() == ProcessResult::FinishedWithSuccess)
emit changed(repositoryRoot.toString());
}, Qt::QueuedConnection);
enqueueJob(cmd, args);
@@ -552,7 +551,7 @@ void VcsBaseClient::commit(const FilePath &repositoryRoot,
args << extraOptions << files;
VcsCommand *cmd = createCommand(repositoryRoot, nullptr, VcsWindowOutputBind);
if (!commitMessageFile.isEmpty())
- connect(cmd, &VcsCommand::finished, [commitMessageFile] { QFile(commitMessageFile).remove(); });
+ connect(cmd, &VcsCommand::done, [commitMessageFile] { QFile(commitMessageFile).remove(); });
enqueueJob(cmd, args);
}
diff --git a/src/plugins/vcsbase/vcsbasediffeditorcontroller.cpp b/src/plugins/vcsbase/vcsbasediffeditorcontroller.cpp
index 4f8d83ca94..341c4bde94 100644
--- a/src/plugins/vcsbase/vcsbasediffeditorcontroller.cpp
+++ b/src/plugins/vcsbase/vcsbasediffeditorcontroller.cpp
@@ -148,8 +148,9 @@ void VcsBaseDiffEditorController::runCommand(const QList<QStringList> &args, uns
d->m_command = VcsBaseClient::createVcsCommand(workingDirectory(), d->m_processEnvironment);
d->m_command->setDisplayName(d->m_displayName);
d->m_command->setCodec(codec ? codec : EditorManager::defaultTextCodec());
- connect(d->m_command.data(), &VcsCommand::finished,
- this, [this](bool success) { d->commandFinished(success); });
+ connect(d->m_command.data(), &VcsCommand::done, this, [this] {
+ d->commandFinished(d->m_command->result() == ProcessResult::FinishedWithSuccess);
+ });
d->m_command->addFlags(flags);
for (const QStringList &arg : args) {
diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp
index a52fafb17b..a962953fb1 100644
--- a/src/plugins/vcsbase/vcsbaseeditor.cpp
+++ b/src/plugins/vcsbase/vcsbaseeditor.cpp
@@ -1394,7 +1394,9 @@ void VcsBaseEditorWidget::setCommand(VcsCommand *command)
if (command) {
d->m_progressIndicator = new ProgressIndicator(ProgressIndicatorSize::Large);
d->m_progressIndicator->attachToWidget(this);
- connect(command, &VcsCommand::finished, this, &VcsBaseEditorWidget::reportCommandFinished);
+ connect(command, &VcsCommand::done, this, [this] {
+ reportCommandFinished(d->m_command->result() == ProcessResult::FinishedWithSuccess);
+ });
QTimer::singleShot(100, this, &VcsBaseEditorWidget::showProgressIndicator);
}
}
diff --git a/src/plugins/vcsbase/wizard/vcscommandpage.cpp b/src/plugins/vcsbase/wizard/vcscommandpage.cpp
index bf86416f5f..73681ba726 100644
--- a/src/plugins/vcsbase/wizard/vcscommandpage.cpp
+++ b/src/plugins/vcsbase/wizard/vcscommandpage.cpp
@@ -365,7 +365,9 @@ void VcsCommandPage::start(VcsCommand *command)
connect(command, &VcsCommand::stdErrText, this, [this](const QString &text) {
m_formatter->appendMessage(text, StdErrFormat);
});
- connect(command, &VcsCommand::finished, this, &VcsCommandPage::finished);
+ connect(command, &VcsCommand::done, this, [this] {
+ finished(m_command->result() == ProcessResult::FinishedWithSuccess);
+ });
QApplication::setOverrideCursor(Qt::WaitCursor);
m_logPlainTextEdit->clear();
m_overwriteOutput = false;