diff --git a/src/plugins/vcsbase/checkoutprogresswizardpage.cpp b/src/libs/utils/shellcommandpage.cpp similarity index 67% rename from src/plugins/vcsbase/checkoutprogresswizardpage.cpp rename to src/libs/utils/shellcommandpage.cpp index 662fb747204894a8292e02477cb27c0b781ec75d..8cc6fcf229396547355271026178c8a0c1a11dc2 100644 --- a/src/plugins/vcsbase/checkoutprogresswizardpage.cpp +++ b/src/libs/utils/shellcommandpage.cpp @@ -28,12 +28,11 @@ ** ****************************************************************************/ -#include "checkoutprogresswizardpage.h" -#include "vcscommand.h" -#include "vcsbaseplugin.h" - -#include <utils/outputformatter.h> -#include <utils/qtcassert.h> +#include "shellcommandpage.h" +#include "shellcommand.h" +#include "outputformatter.h" +#include "qtcassert.h" +#include "theme/theme.h" #include <QApplication> #include <QLabel> @@ -41,22 +40,19 @@ #include <QVBoxLayout> /*! - \class VcsBase::Internal::CheckoutProgressWizardPage - - \brief The CheckoutProgressWizardPage implements a page showing the - progress of an initial project checkout. + \class Utils::ShellCommandPage - Turns complete when the job succeeds. + \brief The ShellCommandPage implements a page showing the + progress of a \c ShellCommand. - \sa VcsBase::BaseCheckoutWizard + Turns complete when the command succeeds. */ -namespace VcsBase { -namespace Internal { +namespace Utils { -CheckoutProgressWizardPage::CheckoutProgressWizardPage(QWidget *parent) : - QWizardPage(parent), - m_startedStatus(tr("Checkout started...")), +ShellCommandPage::ShellCommandPage(QWidget *parent) : + WizardPage(parent), + m_startedStatus(tr("Command started...")), m_overwriteOutput(false), m_state(Idle) { @@ -71,21 +67,21 @@ CheckoutProgressWizardPage::CheckoutProgressWizardPage(QWidget *parent) : m_statusLabel = new QLabel; verticalLayout->addWidget(m_statusLabel); - setTitle(tr("Checkout")); + setTitle(tr("Run Command")); } -CheckoutProgressWizardPage::~CheckoutProgressWizardPage() +ShellCommandPage::~ShellCommandPage() { QTC_ASSERT(m_state != Running, QApplication::restoreOverrideCursor()); delete m_formatter; } -void CheckoutProgressWizardPage::setStartedStatus(const QString &startedStatus) +void ShellCommandPage::setStartedStatus(const QString &startedStatus) { m_startedStatus = startedStatus; } -void CheckoutProgressWizardPage::start(VcsCommand *command) +void ShellCommandPage::start(ShellCommand *command) { if (!command) { m_logPlainTextEdit->setPlainText(tr("No job running, please abort.")); @@ -95,9 +91,9 @@ void CheckoutProgressWizardPage::start(VcsCommand *command) QTC_ASSERT(m_state != Running, return); m_command = command; command->setProgressiveOutput(true); - connect(command, &VcsCommand::stdOutText, this, &CheckoutProgressWizardPage::reportStdOut); - connect(command, &VcsCommand::stdErrText, this, &CheckoutProgressWizardPage::reportStdErr); - connect(command, &VcsCommand::finished, this, &CheckoutProgressWizardPage::slotFinished); + connect(command, &ShellCommand::stdOutText, this, &ShellCommandPage::reportStdOut); + connect(command, &ShellCommand::stdErrText, this, &ShellCommandPage::reportStdErr); + connect(command, &ShellCommand::finished, this, &ShellCommandPage::slotFinished); QApplication::setOverrideCursor(Qt::WaitCursor); m_logPlainTextEdit->clear(); m_overwriteOutput = false; @@ -107,7 +103,7 @@ void CheckoutProgressWizardPage::start(VcsCommand *command) 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); @@ -118,11 +114,11 @@ void CheckoutProgressWizardPage::slotFinished(bool ok, int exitCode, const QVari if (success) { m_state = Succeeded; message = tr("Succeeded."); - palette.setColor(QPalette::Active, QPalette::Text, Qt::green); + palette.setColor(QPalette::WindowText, creatorTheme()->color(Theme::TextColorNormal).name()); } else { m_state = 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); @@ -132,29 +128,28 @@ void CheckoutProgressWizardPage::slotFinished(bool ok, int exitCode, const QVari if (success) 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); } -void CheckoutProgressWizardPage::reportStdErr(const QString &text) +void ShellCommandPage::reportStdErr(const QString &text) { m_formatter->appendMessage(text, Utils::StdErrFormat); } -void CheckoutProgressWizardPage::terminate() +void ShellCommandPage::terminate() { if (m_command) m_command->cancel(); } -bool CheckoutProgressWizardPage::isComplete() const +bool ShellCommandPage::isComplete() const { return m_state == Succeeded; } -} // namespace Internal -} // namespace VcsBase +} // namespace Utils diff --git a/src/plugins/vcsbase/checkoutprogresswizardpage.h b/src/libs/utils/shellcommandpage.h similarity index 77% rename from src/plugins/vcsbase/checkoutprogresswizardpage.h rename to src/libs/utils/shellcommandpage.h index 13c7e18217e6e6396c5f495d70a37c76e2439b51..f648728debb77cfe0276cf6da3b96e0bb0c386ac 100644 --- a/src/plugins/vcsbase/checkoutprogresswizardpage.h +++ b/src/libs/utils/shellcommandpage.h @@ -28,36 +28,34 @@ ** ****************************************************************************/ -#ifndef CHECKOUTPROGRESSWIZARDPAGE_H -#define CHECKOUTPROGRESSWIZARDPAGE_H +#ifndef SHELLCOMMANDPAGE_H +#define SHELLCOMMANDPAGE_H -#include <QSharedPointer> -#include <QWizardPage> +#include "utils_global.h" + +#include "wizardpage.h" QT_BEGIN_NAMESPACE class QPlainTextEdit; class QLabel; QT_END_NAMESPACE -namespace Utils { class OutputFormatter; } - -namespace VcsBase { -class VcsCommand; - -namespace Internal { +namespace Utils { +class OutputFormatter; +class ShellCommand; -class CheckoutProgressWizardPage : public QWizardPage +class QTCREATOR_UTILS_EXPORT ShellCommandPage : public WizardPage { Q_OBJECT public: enum State { Idle, Running, Failed, Succeeded }; - explicit CheckoutProgressWizardPage(QWidget *parent = 0); - ~CheckoutProgressWizardPage(); + explicit ShellCommandPage(QWidget *parent = 0); + ~ShellCommandPage(); void setStartedStatus(const QString &startedStatus); - void start(VcsCommand *command); + void start(ShellCommand *command); virtual bool isComplete() const; bool isRunning() const{ return m_state == Running; } @@ -65,26 +63,24 @@ public: void terminate(); signals: - void terminated(bool success); + void finished(bool success); -private slots: +private: void slotFinished(bool ok, int exitCode, const QVariant &cookie); void reportStdOut(const QString &text); void reportStdErr(const QString &text); -private: QPlainTextEdit *m_logPlainTextEdit; - Utils::OutputFormatter *m_formatter; + OutputFormatter *m_formatter; QLabel *m_statusLabel; - VcsCommand *m_command; + ShellCommand *m_command; QString m_startedStatus; bool m_overwriteOutput; State m_state; }; -} // namespace Internal -} // namespace VcsBase +} // namespace Utils -#endif // CHECKOUTPROGRESSWIZARDPAGE_H +#endif // SHELLCOMMANDPAGE_H diff --git a/src/libs/utils/utils-lib.pri b/src/libs/utils/utils-lib.pri index 419b985914209b0a91de201a948b57935d627328..800920a46dd71c24bad86e700543514b26889225 100644 --- a/src/libs/utils/utils-lib.pri +++ b/src/libs/utils/utils-lib.pri @@ -13,6 +13,7 @@ SOURCES += $$PWD/environment.cpp \ $$PWD/qtcprocess.cpp \ $$PWD/reloadpromptutils.cpp \ $$PWD/shellcommand.cpp \ + $$PWD/shellcommandpage.cpp \ $$PWD/settingsselector.cpp \ $$PWD/stringutils.cpp \ $$PWD/textfieldcheckbox.cpp \ @@ -101,6 +102,7 @@ HEADERS += \ $$PWD/reloadpromptutils.h \ $$PWD/settingsselector.h \ $$PWD/shellcommand.h \ + $$PWD/shellcommandpage.h \ $$PWD/stringutils.h \ $$PWD/textfieldcheckbox.h \ $$PWD/textfieldcombobox.h \ diff --git a/src/libs/utils/utils.qbs b/src/libs/utils/utils.qbs index 6545bfba023d7bb54d6e023ad008b19d17cf1518..a3855fff540dc7dee0d91578724c99cadcad26a7 100644 --- a/src/libs/utils/utils.qbs +++ b/src/libs/utils/utils.qbs @@ -162,6 +162,8 @@ QtcLibrary { "settingsutils.h", "shellcommand.cpp", "shellcommand.h", + "shellcommandpage.cpp", + "shellcommandpage.h", "sleep.cpp", "sleep.h", "statuslabel.cpp", diff --git a/src/plugins/cvs/checkoutwizard.cpp b/src/plugins/cvs/checkoutwizard.cpp index 343ee8161e2467f7e19d56771f949035f0fe1481..334cd415c2386af30512fa4e6788474b709dcc51 100644 --- a/src/plugins/cvs/checkoutwizard.cpp +++ b/src/plugins/cvs/checkoutwizard.cpp @@ -73,6 +73,10 @@ VcsCommand *CheckoutWizard::createCommand(Utils::FileName *checkoutDir) const Utils::FileName binary = settings.binaryPath(); 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(); args << QLatin1String("checkout") << repository; const QString workingDirectory = cwp->path(); diff --git a/src/plugins/vcsbase/basecheckoutwizard.cpp b/src/plugins/vcsbase/basecheckoutwizard.cpp index 1d48b588af545c8144cee3034955ce2e2c5cd412..d24e10a9406e6759163e9ddd4b5ae662980e6002 100644 --- a/src/plugins/vcsbase/basecheckoutwizard.cpp +++ b/src/plugins/vcsbase/basecheckoutwizard.cpp @@ -30,9 +30,10 @@ #include "basecheckoutwizard.h" #include "basecheckoutwizardfactory.h" -#include "checkoutprogresswizardpage.h" +#include "vcscommand.h" #include <utils/qtcassert.h> +#include <utils/shellcommandpage.h> #include <QPushButton> @@ -47,12 +48,12 @@ namespace VcsBase { BaseCheckoutWizard::BaseCheckoutWizard(const Utils::FileName &path, QWidget *parent) : Utils::Wizard(parent), - m_progressPage(new Internal::CheckoutProgressWizardPage), + m_progressPage(new Utils::ShellCommandPage), m_progressPageId(-1) { Q_UNUSED(path); connect(this, &QWizard::currentIdChanged, this, &BaseCheckoutWizard::slotPageChanged); - connect(m_progressPage, &Internal::CheckoutProgressWizardPage::terminated, + connect(m_progressPage, &Utils::ShellCommandPage::finished, this, &BaseCheckoutWizard::slotTerminated); setOption(QWizard::NoBackButtonOnLastPage); } diff --git a/src/plugins/vcsbase/basecheckoutwizard.h b/src/plugins/vcsbase/basecheckoutwizard.h index 0b362c6284c9e7e64856e91084f7930780a2278b..ff8f850d2b39260adfc6d384a8fcf8caed77c575 100644 --- a/src/plugins/vcsbase/basecheckoutwizard.h +++ b/src/plugins/vcsbase/basecheckoutwizard.h @@ -36,11 +36,11 @@ #include <utils/fileutils.h> #include <utils/wizard.h> +namespace Utils { class ShellCommandPage; } + namespace VcsBase { class VcsCommand; -namespace Internal { class CheckoutProgressWizardPage; } - class VCSBASE_EXPORT BaseCheckoutWizard : public Utils::Wizard { Q_OBJECT @@ -62,7 +62,7 @@ private slots: virtual void reject(); private: - Internal::CheckoutProgressWizardPage *m_progressPage; + Utils::ShellCommandPage *m_progressPage; int m_progressPageId; Utils::FileName m_checkoutDir; }; diff --git a/src/plugins/vcsbase/vcsbase.pro b/src/plugins/vcsbase/vcsbase.pro index 80f0fcbeb5294df037ec6d927762b7876bab0e17..7da27cbfd9addccbcd81f1f7c680d58b94a52c1d 100644 --- a/src/plugins/vcsbase/vcsbase.pro +++ b/src/plugins/vcsbase/vcsbase.pro @@ -21,7 +21,6 @@ HEADERS += vcsbase_global.h \ nicknamedialog.h \ basecheckoutwizardfactory.h \ basecheckoutwizard.h \ - checkoutprogresswizardpage.h \ basecheckoutwizardpage.h \ vcsoutputwindow.h \ cleandialog.h \ @@ -52,7 +51,6 @@ SOURCES += vcsplugin.cpp \ nicknamedialog.cpp \ basecheckoutwizardfactory.cpp \ basecheckoutwizard.cpp \ - checkoutprogresswizardpage.cpp \ basecheckoutwizardpage.cpp \ vcsoutputwindow.cpp \ cleandialog.cpp \ diff --git a/src/plugins/vcsbase/vcsbase.qbs b/src/plugins/vcsbase/vcsbase.qbs index 5b8d7a335815fe50c0818589b1e5eca5ba39d8b4..733a6d5ab3b9e49e69ee053fff1947dce1ad9965 100644 --- a/src/plugins/vcsbase/vcsbase.qbs +++ b/src/plugins/vcsbase/vcsbase.qbs @@ -27,8 +27,6 @@ QtcPlugin { "basevcseditorfactory.h", "basevcssubmiteditorfactory.cpp", "basevcssubmiteditorfactory.h", - "checkoutprogresswizardpage.cpp", - "checkoutprogresswizardpage.h", "cleandialog.cpp", "cleandialog.h", "cleandialog.ui",