1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #include "checkoutprogresswizardpage.h"
35 #include "checkoutjobs.h"
36 #include "ui_checkoutprogresswizardpage.h"
38 #include <utils/qtcassert.h>
40 #include <QtGui/QApplication>
41 #include <QtGui/QCursor>
46 CheckoutProgressWizardPage::CheckoutProgressWizardPage(QWidget *parent) :
48 ui(new Ui::CheckoutProgressWizardPage),
52 setTitle(tr("Checkout"));
55 CheckoutProgressWizardPage::~CheckoutProgressWizardPage()
57 if (m_state == Running) // Paranoia!
58 QApplication::restoreOverrideCursor();
62 void CheckoutProgressWizardPage::start(const QSharedPointer<AbstractCheckoutJob> &job)
64 QTC_ASSERT(m_state != Running, return)
66 connect(job.data(), SIGNAL(output(QString)), ui->logPlainTextEdit, SLOT(appendPlainText(QString)));
67 connect(job.data(), SIGNAL(failed(QString)), this, SLOT(slotFailed(QString)));
68 connect(job.data(), SIGNAL(succeeded()), this, SLOT(slotSucceeded()));
69 QApplication::setOverrideCursor(Qt::WaitCursor);
70 ui->logPlainTextEdit->clear();
71 ui->statusLabel->setText(tr("Checkout started..."));
72 ui->statusLabel->setPalette(QPalette());
74 // Note: Process jobs can emit failed() right from
75 // the start() method on Windows.
79 void CheckoutProgressWizardPage::slotFailed(const QString &why)
81 ui->logPlainTextEdit->appendPlainText(why);
82 if (m_state == Running) {
84 QApplication::restoreOverrideCursor();
85 ui->statusLabel->setText(tr("Failed."));
86 QPalette palette = ui->statusLabel->palette();
87 palette.setColor(QPalette::Active, QPalette::Text, Qt::red);
88 ui->statusLabel->setPalette(palette);
89 emit terminated(false);
93 void CheckoutProgressWizardPage::slotSucceeded()
95 if (m_state == Running) {
97 QApplication::restoreOverrideCursor();
98 ui->statusLabel->setText(tr("Succeeded."));
99 QPalette palette = ui->statusLabel->palette();
100 palette.setColor(QPalette::Active, QPalette::Text, Qt::green);
101 ui->statusLabel->setPalette(palette);
102 emit completeChanged();
103 emit terminated(true);
107 void CheckoutProgressWizardPage::terminate()
113 bool CheckoutProgressWizardPage::isComplete() const
115 return m_state == Succeeded;
118 void CheckoutProgressWizardPage::changeEvent(QEvent *e)
120 QWizardPage::changeEvent(e);
122 case QEvent::LanguageChange:
123 ui->retranslateUi(this);
130 } // namespace Internal
131 } // namespace VCSBase