Commit 30044e84 authored by dt's avatar dt

CMake Run Page: Colorize output and disable finish on cmake error

Task-Nr: QTCREATORBUG-2592
parent f1e8e737
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** 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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
Custom project wizard configuration example file. Note that by convention,
the project file goes last.
The "class" and "firstpage" attributes specify that it is a Qt 4 wizard and
leave room for the Qt 4 target page.
-->
<wizard version="1" kind="project"
class="qt4project" firstpage="10"
id="A.HelloWorld" category="B.CustomProjects">
<icon>console.png</icon>
<description>Creates a hello-world-project with custom message.</description>
<displayname>Hello World</displayname>;
<displaycategory>Custom Projects</displaycategory>
<files>
<file source="main.cpp" openeditor="true"/>
<file source="project.pro" target="%ProjectName%.pro" openproject="true"/>
</files>
<!-- Create a 2nd wizard page with parameters -->
<fieldpagetitle>Hello World Parameters</fieldpagetitle>
<fieldpagetitle xml:lang="de">Hallo Welt Parameter</fieldpagetitle>
<fields>
<field mandatory="true" name="MESSAGE">
<fieldcontrol class="QLineEdit" validator='^[^"]+$'
defaulttext="Hello world from project '%ProjectName:c%'!" />
<fielddescription>Hello world message:</fielddescription>
<fielddescription xml:lang="de">Hallo-Welt-Nachricht:</fielddescription>
</field>
<!-- Checkbox technique 1: Comment out network in profile according to user's wishes -->
<field name="NETWORK">
<fieldcontrol class="QCheckBox" truevalue="" falsevalue="# "/>
<fielddescription>Include network module</fielddescription>
<fielddescription xml:lang="de">Netzwerk-Modul verwenden</fielddescription>
</field>
<!-- Checkbox technique 2: Use preprocessor for profile according to user's wishes -->
<field name="SCRIPT">
<fieldcontrol class="QCheckBox"/>
<fielddescription>Include script module</fielddescription>
<fielddescription xml:lang="de">Script-Modul verwenden</fielddescription>
</field>
</fields>
</wizard>
......@@ -328,6 +328,11 @@ void CMakeRunPage::initWidgets()
pl.setVerticalStretch(1);
m_output->setSizePolicy(pl);
fl->addRow(m_output);
m_exitCodeLabel = new QLabel(this);
m_exitCodeLabel->setVisible(false);
fl->addRow(m_exitCodeLabel);
setTitle(tr("Run CMake"));
}
......@@ -460,7 +465,8 @@ void CMakeRunPage::runCMake()
if (m_cmakeWizard->cmakeManager()->isCMakeExecutableValid()) {
m_cmakeProcess = new QProcess();
connect(m_cmakeProcess, SIGNAL(readyRead()), this, SLOT(cmakeReadyRead()));
connect(m_cmakeProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(cmakeReadyReadStandardOutput()));
connect(m_cmakeProcess, SIGNAL(readyReadStandardError()), this, SLOT(cmakeReadyReadStandardError()));
connect(m_cmakeProcess, SIGNAL(finished(int)), this, SLOT(cmakeFinished()));
cmakeManager->createXmlFile(m_cmakeProcess, arguments, m_cmakeWizard->sourceDirectory(), m_buildDirectory, env, generator);
} else {
......@@ -470,20 +476,54 @@ void CMakeRunPage::runCMake()
}
}
void CMakeRunPage::cmakeReadyRead()
static QColor mix_colors(QColor a, QColor b)
{
return QColor((a.red() + 2 * b.red()) / 3, (a.green() + 2 * b.green()) / 3,
(a.blue() + 2* b.blue()) / 3, (a.alpha() + 2 * b.alpha()) / 3);
}
void CMakeRunPage::cmakeReadyReadStandardOutput()
{
QTextCursor cursor(m_output->document());
QTextCharFormat tf;
QFont font = m_output->font();
tf.setFont(font);
tf.setForeground(m_output->palette().color(QPalette::Text));
cursor.insertText(m_cmakeProcess->readAllStandardOutput(), tf);
}
void CMakeRunPage::cmakeReadyReadStandardError()
{
m_output->appendPlainText(m_cmakeProcess->readAll());
QTextCursor cursor(m_output->document());
QTextCharFormat tf;
QFont font = m_output->font();
QFont boldFont = font;
boldFont.setBold(true);
tf.setFont(boldFont);
tf.setForeground(mix_colors(m_output->palette().color(QPalette::Text), QColor(Qt::red)));
cursor.insertText(m_cmakeProcess->readAllStandardError(), tf);
}
void CMakeRunPage::cmakeFinished()
{
m_runCMake->setEnabled(true);
m_argumentsLineEdit->setEnabled(true);
if (m_cmakeProcess->exitCode() != 0) {
m_exitCodeLabel->setVisible(true);
m_exitCodeLabel->setText(tr("CMake exited with errors. Please check cmake output."));
m_complete = false;
} else {
m_exitCodeLabel->setVisible(false);
m_complete = true;
}
m_cmakeProcess->deleteLater();
m_cmakeProcess = 0;
m_cmakeWizard->setArguments(Utils::Environment::parseCombinedArgString(m_argumentsLineEdit->text()));
//TODO Actually test that running cmake was finished, for setting this bool
m_complete = true;
emit completeChanged();
}
......@@ -491,6 +531,7 @@ void CMakeRunPage::cleanupPage()
{
m_output->clear();
m_complete = false;
m_exitCodeLabel->setVisible(false);
emit completeChanged();
}
......
......@@ -133,7 +133,8 @@ public:
private slots:
void runCMake();
void cmakeFinished();
void cmakeReadyRead();
void cmakeReadyReadStandardOutput();
void cmakeReadyReadStandardError();
private:
void initWidgets();
CMakeOpenProjectWizard *m_cmakeWizard;
......@@ -144,6 +145,7 @@ private:
Utils::PathChooser *m_cmakeExecutable;
QComboBox *m_generatorComboBox;
QLabel *m_descriptionLabel;
QLabel *m_exitCodeLabel;
bool m_complete;
Mode m_mode;
QString m_buildDirectory;
......
......@@ -117,7 +117,6 @@ void CMakeManager::createXmlFile(QProcess *proc, const QStringList &arguments,
QString buildDirectoryPath = buildDirectory.absolutePath();
buildDirectory.mkpath(buildDirectoryPath);
proc->setWorkingDirectory(buildDirectoryPath);
proc->setProcessChannelMode(QProcess::MergedChannels);
proc->setEnvironment(env.toStringList());
const QString srcdir = buildDirectory.exists(QLatin1String("CMakeCache.txt")) ?
......
......@@ -94,7 +94,6 @@ static QColor mix_colors(QColor a, QColor b)
(a.blue() + 2* b.blue()) / 3, (a.alpha() + 2 * b.alpha()) / 3);
}
void OutputFormatter::initFormats()
{
QPalette p = plainTextEdit()->palette();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment