forked from qt-creator/qt-creator
Utils: Add a WizardPage to show progress of a ShellCommand
Use the new page in favor of the CheckoutProgressWizardPage. Change-Id: I7801c146fa67d6fcf550616f3798a7a919aafb96 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -28,12 +28,11 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "checkoutprogresswizardpage.h"
|
#include "shellcommandpage.h"
|
||||||
#include "vcscommand.h"
|
#include "shellcommand.h"
|
||||||
#include "vcsbaseplugin.h"
|
#include "outputformatter.h"
|
||||||
|
#include "qtcassert.h"
|
||||||
#include <utils/outputformatter.h>
|
#include "theme/theme.h"
|
||||||
#include <utils/qtcassert.h>
|
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
@@ -41,22 +40,19 @@
|
|||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class VcsBase::Internal::CheckoutProgressWizardPage
|
\class Utils::ShellCommandPage
|
||||||
|
|
||||||
\brief The CheckoutProgressWizardPage implements a page showing the
|
\brief The ShellCommandPage implements a page showing the
|
||||||
progress of an initial project checkout.
|
progress of a \c ShellCommand.
|
||||||
|
|
||||||
Turns complete when the job succeeds.
|
Turns complete when the command succeeds.
|
||||||
|
|
||||||
\sa VcsBase::BaseCheckoutWizard
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace VcsBase {
|
namespace Utils {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
CheckoutProgressWizardPage::CheckoutProgressWizardPage(QWidget *parent) :
|
ShellCommandPage::ShellCommandPage(QWidget *parent) :
|
||||||
QWizardPage(parent),
|
WizardPage(parent),
|
||||||
m_startedStatus(tr("Checkout started...")),
|
m_startedStatus(tr("Command started...")),
|
||||||
m_overwriteOutput(false),
|
m_overwriteOutput(false),
|
||||||
m_state(Idle)
|
m_state(Idle)
|
||||||
{
|
{
|
||||||
@@ -71,21 +67,21 @@ CheckoutProgressWizardPage::CheckoutProgressWizardPage(QWidget *parent) :
|
|||||||
|
|
||||||
m_statusLabel = new QLabel;
|
m_statusLabel = new QLabel;
|
||||||
verticalLayout->addWidget(m_statusLabel);
|
verticalLayout->addWidget(m_statusLabel);
|
||||||
setTitle(tr("Checkout"));
|
setTitle(tr("Run Command"));
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckoutProgressWizardPage::~CheckoutProgressWizardPage()
|
ShellCommandPage::~ShellCommandPage()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_state != Running, QApplication::restoreOverrideCursor());
|
QTC_ASSERT(m_state != Running, QApplication::restoreOverrideCursor());
|
||||||
delete m_formatter;
|
delete m_formatter;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckoutProgressWizardPage::setStartedStatus(const QString &startedStatus)
|
void ShellCommandPage::setStartedStatus(const QString &startedStatus)
|
||||||
{
|
{
|
||||||
m_startedStatus = startedStatus;
|
m_startedStatus = startedStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckoutProgressWizardPage::start(VcsCommand *command)
|
void ShellCommandPage::start(ShellCommand *command)
|
||||||
{
|
{
|
||||||
if (!command) {
|
if (!command) {
|
||||||
m_logPlainTextEdit->setPlainText(tr("No job running, please abort."));
|
m_logPlainTextEdit->setPlainText(tr("No job running, please abort."));
|
||||||
@@ -95,9 +91,9 @@ void CheckoutProgressWizardPage::start(VcsCommand *command)
|
|||||||
QTC_ASSERT(m_state != Running, return);
|
QTC_ASSERT(m_state != Running, return);
|
||||||
m_command = command;
|
m_command = command;
|
||||||
command->setProgressiveOutput(true);
|
command->setProgressiveOutput(true);
|
||||||
connect(command, &VcsCommand::stdOutText, this, &CheckoutProgressWizardPage::reportStdOut);
|
connect(command, &ShellCommand::stdOutText, this, &ShellCommandPage::reportStdOut);
|
||||||
connect(command, &VcsCommand::stdErrText, this, &CheckoutProgressWizardPage::reportStdErr);
|
connect(command, &ShellCommand::stdErrText, this, &ShellCommandPage::reportStdErr);
|
||||||
connect(command, &VcsCommand::finished, this, &CheckoutProgressWizardPage::slotFinished);
|
connect(command, &ShellCommand::finished, this, &ShellCommandPage::slotFinished);
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
m_logPlainTextEdit->clear();
|
m_logPlainTextEdit->clear();
|
||||||
m_overwriteOutput = false;
|
m_overwriteOutput = false;
|
||||||
@@ -107,7 +103,7 @@ void CheckoutProgressWizardPage::start(VcsCommand *command)
|
|||||||
command->execute();
|
command->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckoutProgressWizardPage::slotFinished(bool ok, int exitCode, const QVariant &)
|
void ShellCommandPage::slotFinished(bool ok, int exitCode, const QVariant &)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_state == Running, return);
|
QTC_ASSERT(m_state == Running, return);
|
||||||
|
|
||||||
@@ -118,11 +114,11 @@ void CheckoutProgressWizardPage::slotFinished(bool ok, int exitCode, const QVari
|
|||||||
if (success) {
|
if (success) {
|
||||||
m_state = Succeeded;
|
m_state = Succeeded;
|
||||||
message = tr("Succeeded.");
|
message = tr("Succeeded.");
|
||||||
palette.setColor(QPalette::Active, QPalette::Text, Qt::green);
|
palette.setColor(QPalette::WindowText, creatorTheme()->color(Theme::TextColorNormal).name());
|
||||||
} else {
|
} else {
|
||||||
m_state = Failed;
|
m_state = Failed;
|
||||||
message = tr("Failed.");
|
message = tr("Failed.");
|
||||||
palette.setColor(QPalette::Active, QPalette::Text, Qt::red);
|
palette.setColor(QPalette::WindowText, creatorTheme()->color(Theme::TextColorError).name());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_statusLabel->setText(message);
|
m_statusLabel->setText(message);
|
||||||
@@ -132,29 +128,28 @@ void CheckoutProgressWizardPage::slotFinished(bool ok, int exitCode, const QVari
|
|||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
emit completeChanged();
|
emit completeChanged();
|
||||||
emit terminated(success);
|
emit finished(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckoutProgressWizardPage::reportStdOut(const QString &text)
|
void ShellCommandPage::reportStdOut(const QString &text)
|
||||||
{
|
{
|
||||||
m_formatter->appendMessage(text, Utils::StdOutFormat);
|
m_formatter->appendMessage(text, Utils::StdOutFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckoutProgressWizardPage::reportStdErr(const QString &text)
|
void ShellCommandPage::reportStdErr(const QString &text)
|
||||||
{
|
{
|
||||||
m_formatter->appendMessage(text, Utils::StdErrFormat);
|
m_formatter->appendMessage(text, Utils::StdErrFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckoutProgressWizardPage::terminate()
|
void ShellCommandPage::terminate()
|
||||||
{
|
{
|
||||||
if (m_command)
|
if (m_command)
|
||||||
m_command->cancel();
|
m_command->cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckoutProgressWizardPage::isComplete() const
|
bool ShellCommandPage::isComplete() const
|
||||||
{
|
{
|
||||||
return m_state == Succeeded;
|
return m_state == Succeeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Utils
|
||||||
} // namespace VcsBase
|
|
||||||
@@ -28,36 +28,34 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef CHECKOUTPROGRESSWIZARDPAGE_H
|
#ifndef SHELLCOMMANDPAGE_H
|
||||||
#define CHECKOUTPROGRESSWIZARDPAGE_H
|
#define SHELLCOMMANDPAGE_H
|
||||||
|
|
||||||
#include <QSharedPointer>
|
#include "utils_global.h"
|
||||||
#include <QWizardPage>
|
|
||||||
|
#include "wizardpage.h"
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QPlainTextEdit;
|
class QPlainTextEdit;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Utils { class OutputFormatter; }
|
namespace Utils {
|
||||||
|
class OutputFormatter;
|
||||||
|
class ShellCommand;
|
||||||
|
|
||||||
namespace VcsBase {
|
class QTCREATOR_UTILS_EXPORT ShellCommandPage : public WizardPage
|
||||||
class VcsCommand;
|
|
||||||
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class CheckoutProgressWizardPage : public QWizardPage
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum State { Idle, Running, Failed, Succeeded };
|
enum State { Idle, Running, Failed, Succeeded };
|
||||||
|
|
||||||
explicit CheckoutProgressWizardPage(QWidget *parent = 0);
|
explicit ShellCommandPage(QWidget *parent = 0);
|
||||||
~CheckoutProgressWizardPage();
|
~ShellCommandPage();
|
||||||
|
|
||||||
void setStartedStatus(const QString &startedStatus);
|
void setStartedStatus(const QString &startedStatus);
|
||||||
void start(VcsCommand *command);
|
void start(ShellCommand *command);
|
||||||
|
|
||||||
virtual bool isComplete() const;
|
virtual bool isComplete() const;
|
||||||
bool isRunning() const{ return m_state == Running; }
|
bool isRunning() const{ return m_state == Running; }
|
||||||
@@ -65,26 +63,24 @@ public:
|
|||||||
void terminate();
|
void terminate();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void terminated(bool success);
|
void finished(bool success);
|
||||||
|
|
||||||
private slots:
|
private:
|
||||||
void slotFinished(bool ok, int exitCode, const QVariant &cookie);
|
void slotFinished(bool ok, int exitCode, const QVariant &cookie);
|
||||||
void reportStdOut(const QString &text);
|
void reportStdOut(const QString &text);
|
||||||
void reportStdErr(const QString &text);
|
void reportStdErr(const QString &text);
|
||||||
|
|
||||||
private:
|
|
||||||
QPlainTextEdit *m_logPlainTextEdit;
|
QPlainTextEdit *m_logPlainTextEdit;
|
||||||
Utils::OutputFormatter *m_formatter;
|
OutputFormatter *m_formatter;
|
||||||
QLabel *m_statusLabel;
|
QLabel *m_statusLabel;
|
||||||
|
|
||||||
VcsCommand *m_command;
|
ShellCommand *m_command;
|
||||||
QString m_startedStatus;
|
QString m_startedStatus;
|
||||||
bool m_overwriteOutput;
|
bool m_overwriteOutput;
|
||||||
|
|
||||||
State m_state;
|
State m_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Utils
|
||||||
} // namespace VcsBase
|
|
||||||
|
|
||||||
#endif // CHECKOUTPROGRESSWIZARDPAGE_H
|
#endif // SHELLCOMMANDPAGE_H
|
||||||
@@ -13,6 +13,7 @@ SOURCES += $$PWD/environment.cpp \
|
|||||||
$$PWD/qtcprocess.cpp \
|
$$PWD/qtcprocess.cpp \
|
||||||
$$PWD/reloadpromptutils.cpp \
|
$$PWD/reloadpromptutils.cpp \
|
||||||
$$PWD/shellcommand.cpp \
|
$$PWD/shellcommand.cpp \
|
||||||
|
$$PWD/shellcommandpage.cpp \
|
||||||
$$PWD/settingsselector.cpp \
|
$$PWD/settingsselector.cpp \
|
||||||
$$PWD/stringutils.cpp \
|
$$PWD/stringutils.cpp \
|
||||||
$$PWD/textfieldcheckbox.cpp \
|
$$PWD/textfieldcheckbox.cpp \
|
||||||
@@ -101,6 +102,7 @@ HEADERS += \
|
|||||||
$$PWD/reloadpromptutils.h \
|
$$PWD/reloadpromptutils.h \
|
||||||
$$PWD/settingsselector.h \
|
$$PWD/settingsselector.h \
|
||||||
$$PWD/shellcommand.h \
|
$$PWD/shellcommand.h \
|
||||||
|
$$PWD/shellcommandpage.h \
|
||||||
$$PWD/stringutils.h \
|
$$PWD/stringutils.h \
|
||||||
$$PWD/textfieldcheckbox.h \
|
$$PWD/textfieldcheckbox.h \
|
||||||
$$PWD/textfieldcombobox.h \
|
$$PWD/textfieldcombobox.h \
|
||||||
|
|||||||
@@ -162,6 +162,8 @@ QtcLibrary {
|
|||||||
"settingsutils.h",
|
"settingsutils.h",
|
||||||
"shellcommand.cpp",
|
"shellcommand.cpp",
|
||||||
"shellcommand.h",
|
"shellcommand.h",
|
||||||
|
"shellcommandpage.cpp",
|
||||||
|
"shellcommandpage.h",
|
||||||
"sleep.cpp",
|
"sleep.cpp",
|
||||||
"sleep.h",
|
"sleep.h",
|
||||||
"statuslabel.cpp",
|
"statuslabel.cpp",
|
||||||
|
|||||||
@@ -73,6 +73,10 @@ VcsCommand *CheckoutWizard::createCommand(Utils::FileName *checkoutDir)
|
|||||||
const Utils::FileName binary = settings.binaryPath();
|
const Utils::FileName binary = settings.binaryPath();
|
||||||
QStringList args;
|
QStringList args;
|
||||||
|
|
||||||
|
// cwp->repository() contains the CVS module to check out only.
|
||||||
|
// The CVSROOT (== actual repository) for that module is part of the CVS settings.
|
||||||
|
// The checkout will always go into a new subfolder named after the CVS module.
|
||||||
|
|
||||||
const QString repository = cwp->repository();
|
const QString repository = cwp->repository();
|
||||||
args << QLatin1String("checkout") << repository;
|
args << QLatin1String("checkout") << repository;
|
||||||
const QString workingDirectory = cwp->path();
|
const QString workingDirectory = cwp->path();
|
||||||
|
|||||||
@@ -30,9 +30,10 @@
|
|||||||
|
|
||||||
#include "basecheckoutwizard.h"
|
#include "basecheckoutwizard.h"
|
||||||
#include "basecheckoutwizardfactory.h"
|
#include "basecheckoutwizardfactory.h"
|
||||||
#include "checkoutprogresswizardpage.h"
|
#include "vcscommand.h"
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
#include <utils/shellcommandpage.h>
|
||||||
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
@@ -47,12 +48,12 @@ namespace VcsBase {
|
|||||||
|
|
||||||
BaseCheckoutWizard::BaseCheckoutWizard(const Utils::FileName &path, QWidget *parent) :
|
BaseCheckoutWizard::BaseCheckoutWizard(const Utils::FileName &path, QWidget *parent) :
|
||||||
Utils::Wizard(parent),
|
Utils::Wizard(parent),
|
||||||
m_progressPage(new Internal::CheckoutProgressWizardPage),
|
m_progressPage(new Utils::ShellCommandPage),
|
||||||
m_progressPageId(-1)
|
m_progressPageId(-1)
|
||||||
{
|
{
|
||||||
Q_UNUSED(path);
|
Q_UNUSED(path);
|
||||||
connect(this, &QWizard::currentIdChanged, this, &BaseCheckoutWizard::slotPageChanged);
|
connect(this, &QWizard::currentIdChanged, this, &BaseCheckoutWizard::slotPageChanged);
|
||||||
connect(m_progressPage, &Internal::CheckoutProgressWizardPage::terminated,
|
connect(m_progressPage, &Utils::ShellCommandPage::finished,
|
||||||
this, &BaseCheckoutWizard::slotTerminated);
|
this, &BaseCheckoutWizard::slotTerminated);
|
||||||
setOption(QWizard::NoBackButtonOnLastPage);
|
setOption(QWizard::NoBackButtonOnLastPage);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,11 +36,11 @@
|
|||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/wizard.h>
|
#include <utils/wizard.h>
|
||||||
|
|
||||||
|
namespace Utils { class ShellCommandPage; }
|
||||||
|
|
||||||
namespace VcsBase {
|
namespace VcsBase {
|
||||||
class VcsCommand;
|
class VcsCommand;
|
||||||
|
|
||||||
namespace Internal { class CheckoutProgressWizardPage; }
|
|
||||||
|
|
||||||
class VCSBASE_EXPORT BaseCheckoutWizard : public Utils::Wizard
|
class VCSBASE_EXPORT BaseCheckoutWizard : public Utils::Wizard
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -62,7 +62,7 @@ private slots:
|
|||||||
virtual void reject();
|
virtual void reject();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Internal::CheckoutProgressWizardPage *m_progressPage;
|
Utils::ShellCommandPage *m_progressPage;
|
||||||
int m_progressPageId;
|
int m_progressPageId;
|
||||||
Utils::FileName m_checkoutDir;
|
Utils::FileName m_checkoutDir;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ HEADERS += vcsbase_global.h \
|
|||||||
nicknamedialog.h \
|
nicknamedialog.h \
|
||||||
basecheckoutwizardfactory.h \
|
basecheckoutwizardfactory.h \
|
||||||
basecheckoutwizard.h \
|
basecheckoutwizard.h \
|
||||||
checkoutprogresswizardpage.h \
|
|
||||||
basecheckoutwizardpage.h \
|
basecheckoutwizardpage.h \
|
||||||
vcsoutputwindow.h \
|
vcsoutputwindow.h \
|
||||||
cleandialog.h \
|
cleandialog.h \
|
||||||
@@ -52,7 +51,6 @@ SOURCES += vcsplugin.cpp \
|
|||||||
nicknamedialog.cpp \
|
nicknamedialog.cpp \
|
||||||
basecheckoutwizardfactory.cpp \
|
basecheckoutwizardfactory.cpp \
|
||||||
basecheckoutwizard.cpp \
|
basecheckoutwizard.cpp \
|
||||||
checkoutprogresswizardpage.cpp \
|
|
||||||
basecheckoutwizardpage.cpp \
|
basecheckoutwizardpage.cpp \
|
||||||
vcsoutputwindow.cpp \
|
vcsoutputwindow.cpp \
|
||||||
cleandialog.cpp \
|
cleandialog.cpp \
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ QtcPlugin {
|
|||||||
"basevcseditorfactory.h",
|
"basevcseditorfactory.h",
|
||||||
"basevcssubmiteditorfactory.cpp",
|
"basevcssubmiteditorfactory.cpp",
|
||||||
"basevcssubmiteditorfactory.h",
|
"basevcssubmiteditorfactory.h",
|
||||||
"checkoutprogresswizardpage.cpp",
|
|
||||||
"checkoutprogresswizardpage.h",
|
|
||||||
"cleandialog.cpp",
|
"cleandialog.cpp",
|
||||||
"cleandialog.h",
|
"cleandialog.h",
|
||||||
"cleandialog.ui",
|
"cleandialog.ui",
|
||||||
|
|||||||
Reference in New Issue
Block a user