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 **************************************************************************/
32 #include "maemopublishingresultpagefremantlefree.h"
33 #include "ui_maemopublishingresultpagefremantlefree.h"
35 #include <QtGui/QAbstractButton>
37 namespace Qt4ProjectManager {
39 typedef MaemoPublisherFremantleFree MPFF;
41 MaemoPublishingResultPageFremantleFree::MaemoPublishingResultPageFremantleFree(MPFF *publisher,
42 QWidget *parent) : QWizardPage(parent), m_publisher(publisher),
43 ui(new Ui::MaemoPublishingResultPageFremantleFree)
45 m_lastOutputType = MPFF::StatusOutput;
49 MaemoPublishingResultPageFremantleFree::~MaemoPublishingResultPageFremantleFree()
54 void MaemoPublishingResultPageFremantleFree::initializePage()
56 cancelButton()->disconnect();
57 connect(cancelButton(), SIGNAL(clicked()), SLOT(handleCancelRequest()));
58 connect(m_publisher, SIGNAL(finished()), SLOT(handleFinished()));
60 SIGNAL(progressReport(QString, MaemoPublisherFremantleFree::OutputType)),
61 SLOT(handleProgress(QString, MaemoPublisherFremantleFree::OutputType)));
62 m_publisher->publish();
65 void MaemoPublishingResultPageFremantleFree::handleFinished()
67 handleProgress(m_publisher->resultString(), MPFF::StatusOutput);
69 cancelButton()->setEnabled(false);
70 emit completeChanged();
73 void MaemoPublishingResultPageFremantleFree::handleProgress(const QString &text,
74 MPFF::OutputType type)
76 const QString color = QLatin1String(type == MPFF::StatusOutput
77 || type == MPFF::ToolStatusOutput ? "blue" : "red");
78 ui->progressTextEdit->setTextColor(QColor(color));
79 const bool bold = type == MPFF::StatusOutput
80 || type == MPFF::ErrorOutput ? true : false;
81 QFont font = ui->progressTextEdit->currentFont();
83 ui->progressTextEdit->setCurrentFont(font);
85 if (type == MPFF::StatusOutput || type == MPFF::ErrorOutput
86 || m_lastOutputType == MPFF::StatusOutput
87 || m_lastOutputType == MPFF::ErrorOutput) {
88 ui->progressTextEdit->append(text);
90 ui->progressTextEdit->insertPlainText(text);
92 ui->progressTextEdit->moveCursor(QTextCursor::End);
93 m_lastOutputType = type;
96 void MaemoPublishingResultPageFremantleFree::handleCancelRequest()
98 cancelButton()->setEnabled(false);
99 m_publisher->cancel();
102 QAbstractButton *MaemoPublishingResultPageFremantleFree::cancelButton() const
104 return wizard()->button(QWizard::CancelButton);
107 } // namespace Internal
108 } // namespace Qt4ProjectManager