RunFlags: Add ProgressiveOutput flag

It replaces VcsCommand::setProgressiveOutput() property.

Change-Id: Icebd2205a5b489f60ded1eeee21e2deacbfde1fe
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Jarek Kobus
2022-10-06 15:06:09 +02:00
parent 98c4e342f8
commit 363731a8c8
5 changed files with 24 additions and 30 deletions

View File

@@ -138,7 +138,7 @@ void GitLabCloneDialog::cloneProject()
m_pathChooser->absoluteFilePath(),
m_directoryLE->text(), extraArgs);
const FilePath workingDirectory = m_pathChooser->absoluteFilePath();
m_command->setProgressiveOutput(true);
m_command->addFlags(RunFlags::ProgressiveOutput);
connect(m_command, &VcsCommand::stdOutText, this, [this](const QString &text) {
m_cloneOutput->appendPlainText(text);
});

View File

@@ -110,8 +110,6 @@ public:
QFutureInterface<void> m_futureInterface;
RunFlags m_flags = RunFlags::None;
bool m_progressiveOutput = false;
};
QString VcsCommandPrivate::displayName() const
@@ -184,19 +182,20 @@ void VcsCommandPrivate::setupProcess(QtcProcess *process, const Job &job)
void VcsCommandPrivate::installStdCallbacks(QtcProcess *process)
{
if (!(m_flags & RunFlags::MergeOutputChannels)
&& (m_progressiveOutput || !(m_flags & RunFlags::SuppressStdErr))) {
if (!(m_flags & RunFlags::MergeOutputChannels) && (m_flags & RunFlags::ProgressiveOutput
|| !(m_flags & RunFlags::SuppressStdErr))) {
process->setStdErrCallback([this](const QString &text) {
if (m_progressParser)
m_progressParser->parseProgress(text);
if (!(m_flags & RunFlags::SuppressStdErr))
emit q->appendError(text);
if (m_progressiveOutput)
if (m_flags & RunFlags::ProgressiveOutput)
emit q->stdErrText(text);
});
}
// connect stdout to the output window if desired
if (m_progressParser || m_progressiveOutput || (m_flags & RunFlags::ShowStdOut)) {
if (m_progressParser || m_flags & RunFlags::ProgressiveOutput
|| m_flags & RunFlags::ShowStdOut) {
process->setStdOutCallback([this](const QString &text) {
if (m_progressParser)
m_progressParser->parseProgress(text);
@@ -206,7 +205,7 @@ void VcsCommandPrivate::installStdCallbacks(QtcProcess *process)
else
emit q->append(text);
}
if (m_progressiveOutput)
if (m_flags & RunFlags::ProgressiveOutput)
emit q->stdOutText(text);
});
}
@@ -422,11 +421,6 @@ void VcsCommand::setProgressParser(ProgressParser *parser)
d->m_progressParser = parser;
}
void VcsCommand::setProgressiveOutput(bool progressive)
{
d->m_progressiveOutput = progressive;
}
ProgressParser::ProgressParser() :
m_futureMutex(new QMutex)
{ }

View File

@@ -97,7 +97,6 @@ public:
void setCodec(QTextCodec *codec);
void setProgressParser(ProgressParser *parser);
void setProgressiveOutput(bool progressive);
static CommandResult runBlocking(const Utils::FilePath &workingDirectory,
const Utils::Environment &environmentconst,

View File

@@ -10,18 +10,19 @@ namespace VcsBase {
enum class RunFlags {
None = 0, // Empty.
// QtcProcess related
MergeOutputChannels = (1 << 0), // See QProcess::ProcessChannelMode::MergedChannels.
ForceCLocale = (1 << 1), // Force C-locale, sets LANG and LANGUAGE env vars to "C".
UseEventLoop = (1 << 2), // Use event loop when executed in UI thread with
// runBlocking().
MergeOutputChannels = (1 << 0), // See QProcess::ProcessChannelMode::MergedChannels.
ForceCLocale = (1 << 1), // Force C-locale, sets LANG and LANGUAGE env vars to "C".
UseEventLoop = (1 << 2), // Use event loop when executed in UI thread with
// runBlocking().
// Decorator related
SuppressStdErr = (1 << 3), // Suppress standard error output.
SuppressFailMessage = (1 << 4), // No message about command failure.
SuppressCommandLogging = (1 << 5), // No starting command log entry.
ShowSuccessMessage = (1 << 6), // Show message about successful completion of command.
ShowStdOut = (1 << 7), // Show standard output.
SilentOutput = (1 << 8), // Only when ShowStdOut is set to true, outputs silently.
ExpectRepoChanges = (1 << 9), // Expect changes in repository by the command
SuppressStdErr = (1 << 3), // Suppress standard error output.
SuppressFailMessage = (1 << 4), // No message about command failure.
SuppressCommandLogging = (1 << 5), // No starting command log entry.
ShowSuccessMessage = (1 << 6), // Show message about successful completion of command.
ShowStdOut = (1 << 7), // Show standard output.
SilentOutput = (1 << 8), // Only when ShowStdOut is set to true, outputs silently.
ProgressiveOutput = (1 << 9), // Emit stdOutText() and stdErrText() signals.
ExpectRepoChanges = (1 << 10), // Expect changes in repository by the command.
NoOutput = SuppressStdErr | SuppressFailMessage | SuppressCommandLogging
};

View File

@@ -358,14 +358,14 @@ void VcsCommandPage::start(VcsCommand *command)
QTC_ASSERT(m_state != Running, return);
m_command = command;
command->setProgressiveOutput(true);
connect(command, &VcsCommand::stdOutText, this, [this](const QString &text) {
m_command->addFlags(RunFlags::ProgressiveOutput);
connect(m_command, &VcsCommand::stdOutText, this, [this](const QString &text) {
m_formatter->appendMessage(text, StdOutFormat);
});
connect(command, &VcsCommand::stdErrText, this, [this](const QString &text) {
connect(m_command, &VcsCommand::stdErrText, this, [this](const QString &text) {
m_formatter->appendMessage(text, StdErrFormat);
});
connect(command, &VcsCommand::done, this, [this] {
connect(m_command, &VcsCommand::done, this, [this] {
finished(m_command->result() == ProcessResult::FinishedWithSuccess);
});
QApplication::setOverrideCursor(Qt::WaitCursor);
@@ -374,7 +374,7 @@ void VcsCommandPage::start(VcsCommand *command)
m_statusLabel->setText(m_startedStatus);
m_statusLabel->setPalette(QPalette());
m_state = Running;
command->start();
m_command->start();
wizard()->button(QWizard::BackButton)->setEnabled(false);
}