diff --git a/src/plugins/projectexplorer/abstractprocessstep.cpp b/src/plugins/projectexplorer/abstractprocessstep.cpp index 55d94dd474e2aa35fe80d1309af555e55c08a1a1..a6d5c13bd9f8355512066d82ab044ae4ab4f69dd 100644 --- a/src/plugins/projectexplorer/abstractprocessstep.cpp +++ b/src/plugins/projectexplorer/abstractprocessstep.cpp @@ -82,8 +82,8 @@ void AbstractProcessStep::setOutputParser(ProjectExplorer::IOutputParser *parser m_outputParserChain = parser; if (m_outputParserChain) { - connect(parser, SIGNAL(addOutput(QString)), - this, SLOT(outputAdded(QString))); + connect(parser, SIGNAL(addOutput(QString, QTextCharFormat)), + this, SLOT(outputAdded(QString, QTextCharFormat))); connect(parser, SIGNAL(addTask(ProjectExplorer::Task)), this, SLOT(taskAdded(ProjectExplorer::Task))); } @@ -199,22 +199,34 @@ void AbstractProcessStep::run(QFutureInterface<bool> &fi) void AbstractProcessStep::processStarted() { - emit addOutput(tr("<font color=\"#0000ff\">Starting: \"%1\" %2</font>\n").arg(m_command, Qt::escape(m_arguments.join(" ")))); + QTextCharFormat textCharFormat; + textCharFormat.setForeground(Qt::blue); + emit addOutput(tr("Starting: \"%1\" %2\n").arg(m_command, m_arguments.join(" ")), textCharFormat); } void AbstractProcessStep::processFinished(int exitCode, QProcess::ExitStatus status) { - if (status == QProcess::NormalExit && exitCode == 0) - emit addOutput(tr("<font color=\"#0000ff\">The process \"%1\" exited normally.</font>").arg(m_command)); - else if (status == QProcess::NormalExit) - emit addOutput(tr("<font color=\"#ff0000\"><b>The process \"%1\" exited with code %2.</b></font>").arg(m_command, m_process->exitCode())); - else - emit addOutput(tr("<font color=\"#ff0000\"><b>The process \"%1\" crashed.</b></font>").arg(m_command)); + QTextCharFormat textCharFormat; + if (status == QProcess::NormalExit && exitCode == 0) { + textCharFormat.setForeground(Qt::blue); + emit addOutput(tr("The process \"%1\" exited normally.").arg(m_command), textCharFormat); + } else if (status == QProcess::NormalExit) { + textCharFormat.setForeground(Qt::red); + textCharFormat.setFontWeight(QFont::Bold); + emit addOutput(tr("The process \"%1\" exited with code %2.").arg(m_command, m_process->exitCode()), textCharFormat); + } else { + textCharFormat.setForeground(Qt::red); + textCharFormat.setFontWeight(QFont::Bold); + emit addOutput(tr("The process \"%1\" crashed.").arg(m_command), textCharFormat); + } } void AbstractProcessStep::processStartupFailed() { - emit addOutput(tr("<font color=\"#ff0000\"><b>Could not start process \"%1\"</b></font>").arg(m_command)); + QTextCharFormat textCharFormat; + textCharFormat.setForeground(Qt::red); + textCharFormat.setFontWeight(QFont::Bold); + emit addOutput(tr("Could not start process \"%1\"").arg(m_command), textCharFormat); } bool AbstractProcessStep::processSucceeded(int exitCode, QProcess::ExitStatus status) @@ -235,7 +247,8 @@ void AbstractProcessStep::stdOutput(const QString &line) { if (m_outputParserChain) m_outputParserChain->stdOutput(line); - emit addOutput(Qt::escape(line)); + QTextCharFormat textCharFormat; + emit addOutput(Qt::escape(line), textCharFormat); } void AbstractProcessStep::processReadyReadStdError() @@ -251,7 +264,9 @@ void AbstractProcessStep::stdError(const QString &line) { if (m_outputParserChain) m_outputParserChain->stdError(line); - emit addOutput(QLatin1String("<font color=\"#ff0000\">") + Qt::escape(line) + QLatin1String("</font>")); + QTextCharFormat textCharFormat; + textCharFormat.setForeground(Qt::red); + emit addOutput(line, textCharFormat); } void AbstractProcessStep::checkForCancel() @@ -312,9 +327,9 @@ void AbstractProcessStep::taskAdded(const ProjectExplorer::Task &task) emit addTask(editable); } -void AbstractProcessStep::outputAdded(const QString &string) +void AbstractProcessStep::outputAdded(const QString &string, const QTextCharFormat &textCharFormat) { - emit addOutput(string); + emit addOutput(string, textCharFormat); } void AbstractProcessStep::slotProcessFinished(int, QProcess::ExitStatus) diff --git a/src/plugins/projectexplorer/abstractprocessstep.h b/src/plugins/projectexplorer/abstractprocessstep.h index 98399fdab2b00273120eaf928964fe19fb2a2cf8..de4498a8f431d0bdb38b0e637c990d97884a07fa 100644 --- a/src/plugins/projectexplorer/abstractprocessstep.h +++ b/src/plugins/projectexplorer/abstractprocessstep.h @@ -147,8 +147,8 @@ private slots: void checkForCancel(); void taskAdded(const ProjectExplorer::Task &task); - void outputAdded(const QString &string); + void outputAdded(const QString &string, const QTextCharFormat &format); private: QTimer *m_timer; QFutureInterface<bool> *m_futureInterface; diff --git a/src/plugins/projectexplorer/buildmanager.cpp b/src/plugins/projectexplorer/buildmanager.cpp index f538d8d47a5c8e2150b6336ace1012ca89a7e97c..a2f307075d229616030f4da222c3995e131c26da 100644 --- a/src/plugins/projectexplorer/buildmanager.cpp +++ b/src/plugins/projectexplorer/buildmanager.cpp @@ -180,7 +180,9 @@ void BuildManager::finish() void BuildManager::emitCancelMessage() { - emit addToOutputWindow(tr("<font color=\"#ff0000\">Canceled build.</font>")); + QTextCharFormat textCharFormat; + textCharFormat.setForeground(Qt::red); + emit addToOutputWindow(tr("Canceled build."), textCharFormat); } void BuildManager::clearBuildQueue() @@ -282,9 +284,9 @@ void BuildManager::addToTaskWindow(const ProjectExplorer::Task &task) m_taskWindow->addTask(task); } -void BuildManager::addToOutputWindow(const QString &string) +void BuildManager::addToOutputWindow(const QString &string, const QTextCharFormat &format) { - m_outputWindow->appendText(string); + m_outputWindow->appendText(string, format); } void BuildManager::nextBuildQueue() @@ -294,8 +296,8 @@ void BuildManager::nextBuildQueue() disconnect(m_currentBuildStep, SIGNAL(addTask(ProjectExplorer::Task)), this, SLOT(addToTaskWindow(ProjectExplorer::Task))); - disconnect(m_currentBuildStep, SIGNAL(addOutput(QString)), - this, SLOT(addToOutputWindow(QString))); + disconnect(m_currentBuildStep, SIGNAL(addOutput(QString, QTextCharFormat)), + this, SLOT(addToOutputWindow(QString, QTextCharFormat))); ++m_progress; m_progressFutureInterface->setProgressValueAndText(m_progress*100, msgProgress(m_progress, m_maxProgress)); @@ -306,8 +308,10 @@ void BuildManager::nextBuildQueue() // Build Failure const QString projectName = m_currentBuildStep->buildConfiguration()->target()->project()->displayName(); const QString targetName = m_currentBuildStep->buildConfiguration()->target()->displayName(); - addToOutputWindow(tr("<font color=\"#ff0000\">Error while building project %1 (target: %2)</font>").arg(projectName, targetName)); - addToOutputWindow(tr("<font color=\"#ff0000\">When executing build step '%1'</font>").arg(m_currentBuildStep->displayName())); + QTextCharFormat textCharFormat; + textCharFormat.setForeground(Qt::red); + addToOutputWindow(tr("Error while building project %1 (target: %2)").arg(projectName, targetName), textCharFormat); + addToOutputWindow(tr("When executing build step '%1'").arg(m_currentBuildStep->displayName()), textCharFormat); // NBS TODO fix in qtconcurrent m_progressFutureInterface->setProgressValueAndText(m_progress*100, tr("Error while building project %1 (target: %2)").arg(projectName, targetName)); } @@ -337,8 +341,10 @@ void BuildManager::nextStep() if (m_currentBuildStep->buildConfiguration()->target()->project() != m_previousBuildStepProject) { const QString projectName = m_currentBuildStep->buildConfiguration()->target()->project()->displayName(); - addToOutputWindow(tr("<b>Running build steps for project %2...</b>") - .arg(projectName)); + QTextCharFormat textCharFormat; + textCharFormat.setFontWeight(QFont::Bold); + addToOutputWindow(tr("Running build steps for project %2...") + .arg(projectName), textCharFormat); m_previousBuildStepProject = m_currentBuildStep->buildConfiguration()->target()->project(); } m_watcher.setFuture(QtConcurrent::run(&BuildStep::run, m_currentBuildStep)); @@ -363,8 +369,8 @@ bool BuildManager::buildQueueAppend(QList<BuildStep *> steps) BuildStep *bs = steps.at(i); connect(bs, SIGNAL(addTask(ProjectExplorer::Task)), this, SLOT(addToTaskWindow(ProjectExplorer::Task))); - connect(bs, SIGNAL(addOutput(QString)), - this, SLOT(addToOutputWindow(QString))); + connect(bs, SIGNAL(addOutput(QString, QTextCharFormat)), + this, SLOT(addToOutputWindow(QString, QTextCharFormat))); init = bs->init(); if (!init) break; @@ -376,16 +382,18 @@ bool BuildManager::buildQueueAppend(QList<BuildStep *> steps) // print something for the user const QString projectName = bs->buildConfiguration()->target()->project()->displayName(); const QString targetName = bs->buildConfiguration()->target()->displayName(); - addToOutputWindow(tr("<font color=\"#ff0000\">Error while building project %1 (target: %2)</font>").arg(projectName, targetName)); - addToOutputWindow(tr("<font color=\"#ff0000\">When executing build step '%1'</font>").arg(bs->displayName())); + QTextCharFormat textCharFormat; + textCharFormat.setForeground(Qt::red); + addToOutputWindow(tr("Error while building project %1 (target: %2)").arg(projectName, targetName), textCharFormat); + addToOutputWindow(tr("When executing build step '%1'").arg(bs->displayName()), textCharFormat); // disconnect the buildsteps again for (int j = 0; j <= i; ++j) { BuildStep *bs = steps.at(j); disconnect(bs, SIGNAL(addTask(ProjectExplorer::Task)), this, SLOT(addToTaskWindow(ProjectExplorer::Task))); - disconnect(bs, SIGNAL(addOutput(QString)), - this, SLOT(addToOutputWindow(QString))); + disconnect(bs, SIGNAL(addOutput(QString, QTextCharFormat)), + this, SLOT(addToOutputWindow(QString, QTextCharFormat))); } return false; } diff --git a/src/plugins/projectexplorer/buildmanager.h b/src/plugins/projectexplorer/buildmanager.h index dda5c10c31357f8d167b1047e162950c9c6d27db..648790b0f02f515373d706c0a7e9beda3352f762 100644 --- a/src/plugins/projectexplorer/buildmanager.h +++ b/src/plugins/projectexplorer/buildmanager.h @@ -95,7 +95,7 @@ signals: private slots: void addToTaskWindow(const ProjectExplorer::Task &task); - void addToOutputWindow(const QString &string); + void addToOutputWindow(const QString &string, const QTextCharFormat &textCharFormat); void nextBuildQueue(); void progressChanged(); diff --git a/src/plugins/projectexplorer/buildstep.h b/src/plugins/projectexplorer/buildstep.h index fb92427e6ccd66d7c240bd9590852f047c5f2f29..9a8739ce2d5f3e5beb95d3f0285db263eccfe76b 100644 --- a/src/plugins/projectexplorer/buildstep.h +++ b/src/plugins/projectexplorer/buildstep.h @@ -105,8 +105,8 @@ signals: void addTask(const ProjectExplorer::Task &task); // The string is added to the generated output, usually in the output // window. - // It should be in html format, that is properly escaped - void addOutput(const QString &string); + // It should be in plain text, with the format in the parameter + void addOutput(const QString &string, const QTextCharFormat &textCharFormat); private: BuildConfiguration *m_buildConfiguration; diff --git a/src/plugins/projectexplorer/compileoutputwindow.cpp b/src/plugins/projectexplorer/compileoutputwindow.cpp index 8bbfe18e6511ef74814b51df0057268ef9d05a98..a0856c76753cdc6b915f83c1c98dcee0e7997318 100644 --- a/src/plugins/projectexplorer/compileoutputwindow.cpp +++ b/src/plugins/projectexplorer/compileoutputwindow.cpp @@ -52,6 +52,8 @@ CompileOutputWindow::CompileOutputWindow(BuildManager * /*bm*/) Aggregation::Aggregate *agg = new Aggregation::Aggregate; agg->add(m_textEdit); agg->add(new Find::BaseTextFind(m_textEdit)); + + qRegisterMetaType<QTextCharFormat>("QTextCharFormat"); } bool CompileOutputWindow::hasFocus() @@ -74,9 +76,16 @@ QWidget *CompileOutputWindow::outputWidget(QWidget *) return m_textEdit; } -void CompileOutputWindow::appendText(const QString &text) +void CompileOutputWindow::appendText(const QString &text, const QTextCharFormat &textCharFormat) { - m_textEdit->appendHtml(text); + QString textWithNewline = text; + if (!textWithNewline.endsWith("\n")) + textWithNewline.append("\n"); + QTextCursor cursor = QTextCursor(m_textEdit->document()); + cursor.movePosition(QTextCursor::End); + cursor.beginEditBlock(); + cursor.insertText(textWithNewline, textCharFormat); + cursor.endEditBlock(); } void CompileOutputWindow::clearContents() diff --git a/src/plugins/projectexplorer/compileoutputwindow.h b/src/plugins/projectexplorer/compileoutputwindow.h index e74d4e4ec2afc10e041bae8ebd02b38b3e584884..1bdd118c5042a65c654a6fa7fc8fcb55aaae8e22 100644 --- a/src/plugins/projectexplorer/compileoutputwindow.h +++ b/src/plugins/projectexplorer/compileoutputwindow.h @@ -31,6 +31,8 @@ #define COMPILEOUTPUTWINDOW_H #include <coreplugin/ioutputpane.h> +#include <QtGui/QColor> +#include <QtGui/QTextCharFormat> QT_BEGIN_NAMESPACE class QPlainTextEdit; @@ -54,7 +56,7 @@ public: int priorityInStatusBar() const; void clearContents(); void visibilityChanged(bool visible); - void appendText(const QString &text); + void appendText(const QString &text, const QTextCharFormat &textCharFormat); bool canFocus(); bool hasFocus(); void setFocus(); diff --git a/src/plugins/projectexplorer/ioutputparser.cpp b/src/plugins/projectexplorer/ioutputparser.cpp index 6cf1a4da5fed01f6e698124555887c8ccf93e204..ca5b8ba6eb928d926e21a058b064c05c8e4f05a5 100644 --- a/src/plugins/projectexplorer/ioutputparser.cpp +++ b/src/plugins/projectexplorer/ioutputparser.cpp @@ -50,8 +50,8 @@ void IOutputParser::appendOutputParser(IOutputParser *parser) } m_parser = parser; - connect(parser, SIGNAL(addOutput(QString)), - this, SLOT(outputAdded(QString)), Qt::DirectConnection); + connect(parser, SIGNAL(addOutput(QString, QTextCharFormat)), + this, SLOT(outputAdded(QString, QTextCharFormat)), Qt::DirectConnection); connect(parser, SIGNAL(addTask(ProjectExplorer::Task)), this, SLOT(taskAdded(ProjectExplorer::Task)), Qt::DirectConnection); } @@ -59,8 +59,8 @@ void IOutputParser::appendOutputParser(IOutputParser *parser) IOutputParser *IOutputParser::takeOutputParserChain() { IOutputParser *parser = m_parser; - disconnect(parser, SIGNAL(addOutput(QString)), - this, SLOT(outputAdded(QString))); + disconnect(parser, SIGNAL(addOutput(QString, QTextCharFormat)), + this, SLOT(outputAdded(QString, QTextCharFormat))); disconnect(parser, SIGNAL(addTask(ProjectExplorer::Task)), this, SLOT(taskAdded(ProjectExplorer::Task))); m_parser = 0; @@ -84,9 +84,9 @@ void IOutputParser::stdError(const QString &line) m_parser->stdError(line); } -void IOutputParser::outputAdded(const QString &string) +void IOutputParser::outputAdded(const QString &string, const QTextCharFormat &textCharFormat) { - emit addOutput(string); + emit addOutput(string, textCharFormat); } void IOutputParser::taskAdded(const ProjectExplorer::Task &task) diff --git a/src/plugins/projectexplorer/ioutputparser.h b/src/plugins/projectexplorer/ioutputparser.h index da761334604b7e12906a424baac7ceaa4f2a3e62..058b5a75b2917b3b59345a70f771afa428113b85 100644 --- a/src/plugins/projectexplorer/ioutputparser.h +++ b/src/plugins/projectexplorer/ioutputparser.h @@ -67,14 +67,14 @@ signals: /// added to the output. /// Note: This is additional information. There is no need to add each /// line! - void addOutput(const QString &string); + void addOutput(const QString &string, const QTextCharFormat &format); /// Should be emitted for each task seen in the output. void addTask(const ProjectExplorer::Task &task); public slots: /// Subparsers have their addOutput signal connected to this slot. /// This method can be overwritten to change the string. - virtual void outputAdded(const QString &string); + virtual void outputAdded(const QString &string, const QTextCharFormat &color); /// Subparsers have their addTask signal connected to this slot. /// This method can be overwritten to change the task. virtual void taskAdded(const ProjectExplorer::Task &task); diff --git a/src/plugins/projectexplorer/outputparser_test.cpp b/src/plugins/projectexplorer/outputparser_test.cpp index 28a83b50011a1e5a246bfa1e15e2dc3e43b663dc..7bf6c66800e4096206fbe119bac022e439a6a3e4 100644 --- a/src/plugins/projectexplorer/outputparser_test.cpp +++ b/src/plugins/projectexplorer/outputparser_test.cpp @@ -104,7 +104,8 @@ void OutputParserTester::testOutputMangling(const QString &input, { reset(); - childParser()->outputAdded(input); + QTextCharFormat textCharFormat; + childParser()->outputAdded(input, textCharFormat); QCOMPARE(m_receivedOutput, output); QVERIFY(m_receivedStdErrChildLine.isNull()); @@ -139,7 +140,7 @@ void OutputParserTester::appendOutputParser(IOutputParser *parser) parser->appendOutputParser(this); } -void OutputParserTester::outputAdded(const QString &line) +void OutputParserTester::outputAdded(const QString &line, const QTextCharFormat &textCharFormat) { if (!m_receivedOutput.isEmpty()) m_receivedOutput.append(QChar('\n')); diff --git a/src/plugins/projectexplorer/outputparser_test.h b/src/plugins/projectexplorer/outputparser_test.h index 8241766bb5bb6602fcdeeb17548401558ad35d2f..5d3a4d2d0b1b18fc32e0bbd3facba0dc46a3d63c 100644 --- a/src/plugins/projectexplorer/outputparser_test.h +++ b/src/plugins/projectexplorer/outputparser_test.h @@ -71,7 +71,7 @@ public: void appendOutputParser(IOutputParser *parser); private slots: - void outputAdded(const QString &line); + void outputAdded(const QString &line, const QTextCharFormat &textCharFormat); void taskAdded(const ProjectExplorer::Task &task); private: diff --git a/src/plugins/qt4projectmanager/makestep.cpp b/src/plugins/qt4projectmanager/makestep.cpp index fb3184ac82bc8c3a791e882e77b6cf7c8dea9ecb..02eaf9832ff666f7ba107b3603bb7b66c098a4c9 100644 --- a/src/plugins/qt4projectmanager/makestep.cpp +++ b/src/plugins/qt4projectmanager/makestep.cpp @@ -135,8 +135,9 @@ bool MakeStep::init() // Try to detect command in environment const QString tmp = environment.searchInPath(makeCmd); if (tmp.isEmpty()) { - emit addOutput(tr("<font color=\"#ff0000\">Could not find make command: %1 "\ - "in the build environment</font>").arg(makeCmd)); + QTextCharFormat textCharFormat; + textCharFormat.setForeground(Qt::red); + emit addOutput(tr("Could not find make command: %1 in the build environment").arg(makeCmd), textCharFormat); return false; } makeCmd = tmp; diff --git a/src/plugins/qt4projectmanager/qmakestep.cpp b/src/plugins/qt4projectmanager/qmakestep.cpp index 9b42e389bd66023a89365268e04d1024eb6d5809..12629bf29618c3e19e73ba0b7c7692f0fea7e5d8 100644 --- a/src/plugins/qt4projectmanager/qmakestep.cpp +++ b/src/plugins/qt4projectmanager/qmakestep.cpp @@ -198,13 +198,17 @@ void QMakeStep::run(QFutureInterface<bool> &fi) canContinue = false; } if (!canContinue) { - emit addOutput(tr("<font color=\"#0000ff\">Configuration is faulty, please check the Build Issues view for details.</font>")); + QTextCharFormat textCharFormat; + textCharFormat.setForeground(Qt::blue); + emit addOutput(tr("Configuration is faulty, please check the Build Issues view for details."), textCharFormat); fi.reportResult(false); return; } if (!m_needToRunQMake) { - emit addOutput(tr("<font color=\"#0000ff\">Configuration unchanged, skipping qmake step.</font>")); + QTextCharFormat textCharFormat; + textCharFormat.setForeground(Qt::blue); + emit addOutput(tr("Configuration unchanged, skipping qmake step."), textCharFormat); fi.reportResult(true); return; } diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp index c43a2f1bea31f2ac88cf21285e5b0de7e03ff37d..0a007795970fc5e112b2d2ef73000c1f00b3856f 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp @@ -114,7 +114,8 @@ bool MaemoPackageCreationStep::createPackage() if (!packagingNeeded()) return true; - emit addOutput(tr("Creating package file ...")); + QTextCharFormat textCharFormat; + emit addOutput(tr("Creating package file ..."), textCharFormat); QFile configFile(targetRoot() % QLatin1String("/config.sh")); if (!configFile.open(QIODevice::ReadOnly)) { raiseError(tr("Cannot open MADDE config file '%1'.") @@ -213,14 +214,15 @@ bool MaemoPackageCreationStep::createPackage() return false; } - emit addOutput(tr("Package created.")); + emit addOutput(tr("Package created."), textCharFormat); m_packageContents->setUnModified(); return true; } bool MaemoPackageCreationStep::runCommand(QProcess &proc, const QString &command) { - emit addOutput(tr("Package Creation: Running command '%1'.").arg(command)); + QTextCharFormat textCharFormat; + emit addOutput(tr("Package Creation: Running command '%1'.").arg(command), textCharFormat); QString perl; #ifdef Q_OS_WIN perl = maddeRoot() + QLatin1String("/bin/perl.exe "); @@ -323,7 +325,8 @@ QString MaemoPackageCreationStep::nativePath(const QFile &file) const void MaemoPackageCreationStep::raiseError(const QString &shortMsg, const QString &detailedMsg) { - emit addOutput(detailedMsg.isNull() ? shortMsg : detailedMsg); + QTextCharFormat textCharFormat; + emit addOutput(detailedMsg.isNull() ? shortMsg : detailedMsg, textCharFormat); emit addTask(Task(Task::Error, shortMsg, QString(), -1, TASK_CATEGORY_BUILDSYSTEM)); }