1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #include "checkoutprogresswizardpage.h"
34 #include "checkoutjobs.h"
35 #include "ui_checkoutprogresswizardpage.h"
37 #include <utils/qtcassert.h>
39 #include <QtGui/QApplication>
40 #include <QtGui/QCursor>
45 CheckoutProgressWizardPage::CheckoutProgressWizardPage(QWidget *parent) :
47 ui(new Ui::CheckoutProgressWizardPage),
51 setTitle(tr("Checkout"));
54 CheckoutProgressWizardPage::~CheckoutProgressWizardPage()
56 if (m_state == Running) // Paranoia!
57 QApplication::restoreOverrideCursor();
61 void CheckoutProgressWizardPage::start(const QSharedPointer<AbstractCheckoutJob> &job)
63 QTC_ASSERT(m_state != Running, return)
65 connect(job.data(), SIGNAL(output(QString)), ui->logPlainTextEdit, SLOT(appendPlainText(QString)));
66 connect(job.data(), SIGNAL(failed(QString)), this, SLOT(slotFailed(QString)));
67 connect(job.data(), SIGNAL(succeeded()), this, SLOT(slotSucceeded()));
68 QApplication::setOverrideCursor(Qt::WaitCursor);
69 ui->logPlainTextEdit->clear();
70 ui->statusLabel->setText(tr("Checkout started..."));
71 ui->statusLabel->setPalette(QPalette());
73 // Note: Process jobs can emit failed() right from
74 // the start() method on Windows.
78 void CheckoutProgressWizardPage::slotFailed(const QString &why)
80 ui->logPlainTextEdit->appendPlainText(why);
81 if (m_state == Running) {
83 QApplication::restoreOverrideCursor();
84 ui->statusLabel->setText(tr("Failed."));
85 QPalette palette = ui->statusLabel->palette();
86 palette.setColor(QPalette::Active, QPalette::Text, Qt::red);
87 ui->statusLabel->setPalette(palette);
88 emit terminated(false);
92 void CheckoutProgressWizardPage::slotSucceeded()
94 if (m_state == Running) {
96 QApplication::restoreOverrideCursor();
97 ui->statusLabel->setText(tr("Succeeded."));
98 QPalette palette = ui->statusLabel->palette();
99 palette.setColor(QPalette::Active, QPalette::Text, Qt::green);
100 ui->statusLabel->setPalette(palette);
101 emit completeChanged();
102 emit terminated(true);
106 void CheckoutProgressWizardPage::terminate()
112 bool CheckoutProgressWizardPage::isComplete() const
114 return m_state == Succeeded;
117 void CheckoutProgressWizardPage::changeEvent(QEvent *e)
119 QWizardPage::changeEvent(e);
121 case QEvent::LanguageChange:
122 ui->retranslateUi(this);
129 } // namespace Internal
130 } // namespace VCSBase