From f21d2023e86e8ba9c0725852a79394ec80baaf16 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Fri, 23 Jan 2015 10:00:45 +0100 Subject: 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 --- src/plugins/vcsbase/basecheckoutwizard.cpp | 7 +- src/plugins/vcsbase/basecheckoutwizard.h | 6 +- src/plugins/vcsbase/checkoutprogresswizardpage.cpp | 160 --------------------- src/plugins/vcsbase/checkoutprogresswizardpage.h | 90 ------------ src/plugins/vcsbase/vcsbase.pro | 2 - src/plugins/vcsbase/vcsbase.qbs | 2 - 6 files changed, 7 insertions(+), 260 deletions(-) delete mode 100644 src/plugins/vcsbase/checkoutprogresswizardpage.cpp delete mode 100644 src/plugins/vcsbase/checkoutprogresswizardpage.h (limited to 'src/plugins/vcsbase') diff --git a/src/plugins/vcsbase/basecheckoutwizard.cpp b/src/plugins/vcsbase/basecheckoutwizard.cpp index 1d48b588af..d24e10a940 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 +#include #include @@ -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 0b362c6284..ff8f850d2b 100644 --- a/src/plugins/vcsbase/basecheckoutwizard.h +++ b/src/plugins/vcsbase/basecheckoutwizard.h @@ -36,11 +36,11 @@ #include #include +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/checkoutprogresswizardpage.cpp b/src/plugins/vcsbase/checkoutprogresswizardpage.cpp deleted file mode 100644 index 662fb74720..0000000000 --- a/src/plugins/vcsbase/checkoutprogresswizardpage.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "checkoutprogresswizardpage.h" -#include "vcscommand.h" -#include "vcsbaseplugin.h" - -#include -#include - -#include -#include -#include -#include - -/*! - \class VcsBase::Internal::CheckoutProgressWizardPage - - \brief The CheckoutProgressWizardPage implements a page showing the - progress of an initial project checkout. - - Turns complete when the job succeeds. - - \sa VcsBase::BaseCheckoutWizard -*/ - -namespace VcsBase { -namespace Internal { - -CheckoutProgressWizardPage::CheckoutProgressWizardPage(QWidget *parent) : - QWizardPage(parent), - m_startedStatus(tr("Checkout started...")), - m_overwriteOutput(false), - m_state(Idle) -{ - resize(264, 200); - auto verticalLayout = new QVBoxLayout(this); - m_logPlainTextEdit = new QPlainTextEdit; - m_formatter = new Utils::OutputFormatter; - m_logPlainTextEdit->setReadOnly(true); - m_formatter->setPlainTextEdit(m_logPlainTextEdit); - - verticalLayout->addWidget(m_logPlainTextEdit); - - m_statusLabel = new QLabel; - verticalLayout->addWidget(m_statusLabel); - setTitle(tr("Checkout")); -} - -CheckoutProgressWizardPage::~CheckoutProgressWizardPage() -{ - QTC_ASSERT(m_state != Running, QApplication::restoreOverrideCursor()); - delete m_formatter; -} - -void CheckoutProgressWizardPage::setStartedStatus(const QString &startedStatus) -{ - m_startedStatus = startedStatus; -} - -void CheckoutProgressWizardPage::start(VcsCommand *command) -{ - if (!command) { - m_logPlainTextEdit->setPlainText(tr("No job running, please abort.")); - return; - } - - 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); - QApplication::setOverrideCursor(Qt::WaitCursor); - m_logPlainTextEdit->clear(); - m_overwriteOutput = false; - m_statusLabel->setText(m_startedStatus); - m_statusLabel->setPalette(QPalette()); - m_state = Running; - command->execute(); -} - -void CheckoutProgressWizardPage::slotFinished(bool ok, int exitCode, const QVariant &) -{ - QTC_ASSERT(m_state == Running, return); - - const bool success = (ok && exitCode == 0); - QString message; - QPalette palette; - - if (success) { - m_state = Succeeded; - message = tr("Succeeded."); - palette.setColor(QPalette::Active, QPalette::Text, Qt::green); - } else { - m_state = Failed; - message = tr("Failed."); - palette.setColor(QPalette::Active, QPalette::Text, Qt::red); - } - - m_statusLabel->setText(message); - m_statusLabel->setPalette(palette); - - QApplication::restoreOverrideCursor(); - - if (success) - emit completeChanged(); - emit terminated(success); -} - -void CheckoutProgressWizardPage::reportStdOut(const QString &text) -{ - m_formatter->appendMessage(text, Utils::StdOutFormat); -} - -void CheckoutProgressWizardPage::reportStdErr(const QString &text) -{ - m_formatter->appendMessage(text, Utils::StdErrFormat); -} - -void CheckoutProgressWizardPage::terminate() -{ - if (m_command) - m_command->cancel(); -} - -bool CheckoutProgressWizardPage::isComplete() const -{ - return m_state == Succeeded; -} - -} // namespace Internal -} // namespace VcsBase diff --git a/src/plugins/vcsbase/checkoutprogresswizardpage.h b/src/plugins/vcsbase/checkoutprogresswizardpage.h deleted file mode 100644 index 13c7e18217..0000000000 --- a/src/plugins/vcsbase/checkoutprogresswizardpage.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef CHECKOUTPROGRESSWIZARDPAGE_H -#define CHECKOUTPROGRESSWIZARDPAGE_H - -#include -#include - -QT_BEGIN_NAMESPACE -class QPlainTextEdit; -class QLabel; -QT_END_NAMESPACE - -namespace Utils { class OutputFormatter; } - -namespace VcsBase { -class VcsCommand; - -namespace Internal { - -class CheckoutProgressWizardPage : public QWizardPage -{ - Q_OBJECT - -public: - enum State { Idle, Running, Failed, Succeeded }; - - explicit CheckoutProgressWizardPage(QWidget *parent = 0); - ~CheckoutProgressWizardPage(); - - void setStartedStatus(const QString &startedStatus); - void start(VcsCommand *command); - - virtual bool isComplete() const; - bool isRunning() const{ return m_state == Running; } - - void terminate(); - -signals: - void terminated(bool success); - -private slots: - 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; - QLabel *m_statusLabel; - - VcsCommand *m_command; - QString m_startedStatus; - bool m_overwriteOutput; - - State m_state; -}; - -} // namespace Internal -} // namespace VcsBase - -#endif // CHECKOUTPROGRESSWIZARDPAGE_H diff --git a/src/plugins/vcsbase/vcsbase.pro b/src/plugins/vcsbase/vcsbase.pro index 80f0fcbeb5..7da27cbfd9 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 5b8d7a3358..733a6d5ab3 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", -- cgit v1.2.1