Commit 615cda84 authored by dt's avatar dt
Browse files

Fix compile output to be readeable with dark themes

This changes the colors to be a mix of red/blue and the foreground
color. If the regular text color is either of those, well...
parent bf3a9e4e
......@@ -82,8 +82,8 @@ void AbstractProcessStep::setOutputParser(ProjectExplorer::IOutputParser *parser
m_outputParserChain = parser;
if (m_outputParserChain) {
connect(parser, SIGNAL(addOutput(QString, QTextCharFormat)),
this, SLOT(outputAdded(QString, QTextCharFormat)));
connect(parser, SIGNAL(addOutput(QString, ProjectExplorer::BuildStep::OutputFormat)),
this, SLOT(outputAdded(QString, ProjectExplorer::BuildStep::OutputFormat)));
connect(parser, SIGNAL(addTask(ProjectExplorer::Task)),
this, SLOT(taskAdded(ProjectExplorer::Task)));
}
......@@ -199,34 +199,27 @@ void AbstractProcessStep::run(QFutureInterface<bool> &fi)
void AbstractProcessStep::processStarted()
{
QTextCharFormat textCharFormat;
textCharFormat.setForeground(Qt::blue);
emit addOutput(tr("Starting: \"%1\" %2\n").arg(QDir::toNativeSeparators(m_command), m_arguments.join(" ")), textCharFormat);
emit addOutput(tr("Starting: \"%1\" %2\n").arg(QDir::toNativeSeparators(m_command), m_arguments.join(" ")), BuildStep::MessageOutput);
}
void AbstractProcessStep::processFinished(int exitCode, QProcess::ExitStatus status)
{
QTextCharFormat textCharFormat;
if (status == QProcess::NormalExit && exitCode == 0) {
textCharFormat.setForeground(Qt::blue);
emit addOutput(tr("The process \"%1\" exited normally.").arg(QDir::toNativeSeparators(m_command)), textCharFormat);
emit addOutput(tr("The process \"%1\" exited normally.")
.arg(QDir::toNativeSeparators(m_command)),
BuildStep::MessageOutput);
} else if (status == QProcess::NormalExit) {
textCharFormat.setForeground(Qt::red);
textCharFormat.setFontWeight(QFont::Bold);
emit addOutput(tr("The process \"%1\" exited with code %2.").arg(QDir::toNativeSeparators(m_command), QString::number(m_process->exitCode())), textCharFormat);
emit addOutput(tr("The process \"%1\" exited with code %2.")
.arg(QDir::toNativeSeparators(m_command), QString::number(m_process->exitCode())),
BuildStep::ErrorMessageOutput);
} else {
textCharFormat.setForeground(Qt::red);
textCharFormat.setFontWeight(QFont::Bold);
emit addOutput(tr("The process \"%1\" crashed.").arg(QDir::toNativeSeparators(m_command)), textCharFormat);
emit addOutput(tr("The process \"%1\" crashed.").arg(QDir::toNativeSeparators(m_command)), BuildStep::ErrorMessageOutput);
}
}
void AbstractProcessStep::processStartupFailed()
{
QTextCharFormat textCharFormat;
textCharFormat.setForeground(Qt::red);
textCharFormat.setFontWeight(QFont::Bold);
emit addOutput(tr("Could not start process \"%1\"").arg(QDir::toNativeSeparators(m_command)), textCharFormat);
emit addOutput(tr("Could not start process \"%1\"").arg(QDir::toNativeSeparators(m_command)), BuildStep::ErrorMessageOutput);
}
bool AbstractProcessStep::processSucceeded(int exitCode, QProcess::ExitStatus status)
......@@ -247,8 +240,7 @@ void AbstractProcessStep::stdOutput(const QString &line)
{
if (m_outputParserChain)
m_outputParserChain->stdOutput(line);
QTextCharFormat textCharFormat;
emit addOutput(line, textCharFormat);
emit addOutput(line, BuildStep::NormalOutput);
}
void AbstractProcessStep::processReadyReadStdError()
......@@ -264,9 +256,7 @@ void AbstractProcessStep::stdError(const QString &line)
{
if (m_outputParserChain)
m_outputParserChain->stdError(line);
QTextCharFormat textCharFormat;
textCharFormat.setForeground(Qt::red);
emit addOutput(line, textCharFormat);
emit addOutput(line, BuildStep::ErrorOutput);
}
void AbstractProcessStep::checkForCancel()
......@@ -327,9 +317,9 @@ void AbstractProcessStep::taskAdded(const ProjectExplorer::Task &task)
emit addTask(editable);
}
void AbstractProcessStep::outputAdded(const QString &string, const QTextCharFormat &textCharFormat)
void AbstractProcessStep::outputAdded(const QString &string, ProjectExplorer::BuildStep::OutputFormat format)
{
emit addOutput(string, textCharFormat);
emit addOutput(string, format);
}
void AbstractProcessStep::slotProcessFinished(int, QProcess::ExitStatus)
......
......@@ -148,7 +148,7 @@ private slots:
void taskAdded(const ProjectExplorer::Task &task);
void outputAdded(const QString &string, const QTextCharFormat &format);
void outputAdded(const QString &string, ProjectExplorer::BuildStep::OutputFormat format);
private:
QTimer *m_timer;
QFutureInterface<bool> *m_futureInterface;
......
......@@ -50,6 +50,7 @@
#include <QtCore/QDir>
#include <QtCore/QTimer>
#include <QtCore/QMetaType>
#include <qtconcurrent/QtConcurrentTools>
......@@ -96,6 +97,8 @@ BuildManager::BuildManager(ProjectExplorerPlugin *parent)
m_taskWindow = new TaskWindow(m_taskHub);
pm->addObject(m_taskWindow);
qRegisterMetaType<ProjectExplorer::BuildStep::OutputFormat>();
connect(m_taskWindow, SIGNAL(tasksChanged()),
this, SLOT(updateTaskCount()));
......@@ -156,8 +159,8 @@ void BuildManager::cancel()
disconnect(m_currentBuildStep, SIGNAL(addTask(ProjectExplorer::Task)),
this, SLOT(addToTaskWindow(ProjectExplorer::Task)));
disconnect(m_currentBuildStep, SIGNAL(addOutput(QString, QTextCharFormat)),
this, SLOT(addToOutputWindow(QString, QTextCharFormat)));
disconnect(m_currentBuildStep, SIGNAL(addOutput(QString, ProjectExplorer::BuildStep::OutputFormat)),
this, SLOT(addToOutputWindow(QString, ProjectExplorer::BuildStep::OutputFormat)));
decrementActiveBuildSteps(m_currentBuildStep->buildConfiguration()->target()->project());
m_progressFutureInterface->setProgressValueAndText(m_progress*100, tr("Build canceled")); //TODO NBS fix in qtconcurrent
......@@ -185,9 +188,7 @@ void BuildManager::finish()
void BuildManager::emitCancelMessage()
{
QTextCharFormat textCharFormat;
textCharFormat.setForeground(Qt::red);
emit addToOutputWindow(tr("Canceled build."), textCharFormat);
emit addToOutputWindow(tr("Canceled build."), BuildStep::ErrorMessageOutput);
}
void BuildManager::clearBuildQueue()
......@@ -196,8 +197,8 @@ void BuildManager::clearBuildQueue()
decrementActiveBuildSteps(bs->buildConfiguration()->target()->project());
disconnect(bs, SIGNAL(addTask(ProjectExplorer::Task)),
this, SLOT(addToTaskWindow(ProjectExplorer::Task)));
disconnect(bs, SIGNAL(addOutput(QString, QTextCharFormat)),
this, SLOT(addToOutputWindow(QString, QTextCharFormat)));
disconnect(bs, SIGNAL(addOutput(QString, ProjectExplorer::BuildStep::OutputFormat)),
this, SLOT(addToOutputWindow(QString, ProjectExplorer::BuildStep::OutputFormat)));
}
m_buildQueue.clear();
......@@ -287,7 +288,7 @@ void BuildManager::addToTaskWindow(const ProjectExplorer::Task &task)
m_taskHub->addTask(task);
}
void BuildManager::addToOutputWindow(const QString &string, const QTextCharFormat &format)
void BuildManager::addToOutputWindow(const QString &string, ProjectExplorer::BuildStep::OutputFormat format)
{
m_outputWindow->appendText(string, format);
}
......@@ -299,8 +300,8 @@ void BuildManager::nextBuildQueue()
disconnect(m_currentBuildStep, SIGNAL(addTask(ProjectExplorer::Task)),
this, SLOT(addToTaskWindow(ProjectExplorer::Task)));
disconnect(m_currentBuildStep, SIGNAL(addOutput(QString, QTextCharFormat)),
this, SLOT(addToOutputWindow(QString, QTextCharFormat)));
disconnect(m_currentBuildStep, SIGNAL(addOutput(QString, ProjectExplorer::BuildStep::OutputFormat)),
this, SLOT(addToOutputWindow(QString, ProjectExplorer::BuildStep::OutputFormat)));
++m_progress;
m_progressFutureInterface->setProgressValueAndText(m_progress*100, msgProgress(m_progress, m_maxProgress));
......@@ -311,10 +312,8 @@ void BuildManager::nextBuildQueue()
// Build Failure
const QString projectName = m_currentBuildStep->buildConfiguration()->target()->project()->displayName();
const QString targetName = m_currentBuildStep->buildConfiguration()->target()->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);
addToOutputWindow(tr("Error while building project %1 (target: %2)").arg(projectName, targetName), BuildStep::ErrorOutput);
addToOutputWindow(tr("When executing build step '%1'").arg(m_currentBuildStep->displayName()), BuildStep::ErrorOutput);
// NBS TODO fix in qtconcurrent
m_progressFutureInterface->setProgressValueAndText(m_progress*100, tr("Error while building project %1 (target: %2)").arg(projectName, targetName));
}
......@@ -344,10 +343,8 @@ void BuildManager::nextStep()
if (m_currentBuildStep->buildConfiguration()->target()->project() != m_previousBuildStepProject) {
const QString projectName = m_currentBuildStep->buildConfiguration()->target()->project()->displayName();
QTextCharFormat textCharFormat;
textCharFormat.setFontWeight(QFont::Bold);
addToOutputWindow(tr("Running build steps for project %1...")
.arg(projectName), textCharFormat);
.arg(projectName), BuildStep::MessageOutput);
m_previousBuildStepProject = m_currentBuildStep->buildConfiguration()->target()->project();
}
m_watcher.setFuture(QtConcurrent::run(&BuildStep::run, m_currentBuildStep));
......@@ -373,8 +370,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, QTextCharFormat)),
this, SLOT(addToOutputWindow(QString, QTextCharFormat)));
connect(bs, SIGNAL(addOutput(QString, ProjectExplorer::BuildStep::OutputFormat)),
this, SLOT(addToOutputWindow(QString, ProjectExplorer::BuildStep::OutputFormat)));
init = bs->init();
if (!init)
break;
......@@ -386,18 +383,16 @@ 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();
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);
addToOutputWindow(tr("Error while building project %1 (target: %2)").arg(projectName, targetName), BuildStep::ErrorOutput);
addToOutputWindow(tr("When executing build step '%1'").arg(bs->displayName()), BuildStep::ErrorOutput);
// 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, QTextCharFormat)),
this, SLOT(addToOutputWindow(QString, QTextCharFormat)));
disconnect(bs, SIGNAL(addOutput(QString, ProjectExplorer::BuildStep::OutputFormat)),
this, SLOT(addToOutputWindow(QString, ProjectExplorer::BuildStep::OutputFormat)));
}
return false;
}
......
......@@ -32,6 +32,7 @@
#include "projectexplorer_export.h"
#include "task.h"
#include "buildstep.h"
#include <QtCore/QObject>
#include <QtCore/QStringList>
......@@ -99,7 +100,7 @@ signals:
private slots:
void addToTaskWindow(const ProjectExplorer::Task &task);
void addToOutputWindow(const QString &string, const QTextCharFormat &textCharFormat);
void addToOutputWindow(const QString &string, ProjectExplorer::BuildStep::OutputFormat);
void nextBuildQueue();
void progressChanged();
......
......@@ -104,13 +104,15 @@ public:
BuildConfiguration *buildConfiguration() const;
enum OutputFormat { NormalOutput, ErrorOutput, MessageOutput, ErrorMessageOutput };
signals:
// Add a task.
void addTask(const ProjectExplorer::Task &task);
// The string is added to the generated output, usually in the output
// window.
// It should be in plain text, with the format in the parameter
void addOutput(const QString &string, const QTextCharFormat &textCharFormat);
void addOutput(const QString &string, ProjectExplorer::BuildStep::OutputFormat format);
private:
BuildConfiguration *m_buildConfiguration;
......@@ -171,4 +173,6 @@ signals:
} // namespace ProjectExplorer
Q_DECLARE_METATYPE(ProjectExplorer::BuildStep::OutputFormat)
#endif // BUILDSTEP_H
......@@ -95,9 +95,36 @@ QWidget *CompileOutputWindow::outputWidget(QWidget *)
return m_outputWindow;
}
void CompileOutputWindow::appendText(const QString &text, const QTextCharFormat &textCharFormat)
{
m_outputWindow->appendText(text, textCharFormat, MAX_LINECOUNT);
static QColor mix_colors(QColor a, QColor b)
{
return QColor((a.red() + b.red()) / 2, (a.green() + b.green()) / 2,
(a.blue() + b.blue()) / 2, (a.alpha() + b.alpha()) / 2);
}
void CompileOutputWindow::appendText(const QString &text, ProjectExplorer::BuildStep::OutputFormat format)
{
QPalette p = m_outputWindow->palette();
QTextCharFormat textFormat;
switch (format) {
case BuildStep::NormalOutput:
textFormat.setForeground(p.color(QPalette::Text));
textFormat.setFontWeight(QFont::Normal);
break;
case BuildStep::ErrorOutput:
textFormat.setForeground(mix_colors(p.color(QPalette::Text), QColor(Qt::red)));
textFormat.setFontWeight(QFont::Normal);
break;
case BuildStep::MessageOutput:
textFormat.setForeground(mix_colors(p.color(QPalette::Text), QColor(Qt::blue)));
break;
case BuildStep::ErrorMessageOutput:
textFormat.setForeground(mix_colors(p.color(QPalette::Text), QColor(Qt::red)));
textFormat.setFontWeight(QFont::Bold);
break;
}
m_outputWindow->appendText(text, textFormat, MAX_LINECOUNT);
}
void CompileOutputWindow::clearContents()
......
......@@ -31,6 +31,7 @@
#define COMPILEOUTPUTWINDOW_H
#include "outputwindow.h"
#include "buildstep.h"
#include <coreplugin/ioutputpane.h>
#include <QtCore/QHash>
......@@ -63,7 +64,7 @@ public:
int priorityInStatusBar() const;
void clearContents();
void visibilityChanged(bool visible);
void appendText(const QString &text, const QTextCharFormat &textCharFormat);
void appendText(const QString &text, ProjectExplorer::BuildStep::OutputFormat format);
bool canFocus();
bool hasFocus();
void setFocus();
......
......@@ -50,8 +50,8 @@ void IOutputParser::appendOutputParser(IOutputParser *parser)
}
m_parser = parser;
connect(parser, SIGNAL(addOutput(QString, QTextCharFormat)),
this, SLOT(outputAdded(QString, QTextCharFormat)), Qt::DirectConnection);
connect(parser, SIGNAL(addOutput(QString, ProjectExplorer::BuildStep::OutputFormat)),
this, SLOT(outputAdded(QString, ProjectExplorer::BuildStep::OutputFormat)), Qt::DirectConnection);
connect(parser, SIGNAL(addTask(ProjectExplorer::Task)),
this, SLOT(taskAdded(ProjectExplorer::Task)), Qt::DirectConnection);
}
......@@ -84,9 +84,9 @@ void IOutputParser::stdError(const QString &line)
m_parser->stdError(line);
}
void IOutputParser::outputAdded(const QString &string, const QTextCharFormat &textCharFormat)
void IOutputParser::outputAdded(const QString &string, ProjectExplorer::BuildStep::OutputFormat format)
{
emit addOutput(string, textCharFormat);
emit addOutput(string, format);
}
void IOutputParser::taskAdded(const ProjectExplorer::Task &task)
......
......@@ -32,6 +32,7 @@
#include "projectexplorer_export.h"
#include "task.h"
#include "buildstep.h"
#include <QtCore/QObject>
#include <QtCore/QString>
......@@ -67,14 +68,14 @@ signals:
/// added to the output.
/// Note: This is additional information. There is no need to add each
/// line!
void addOutput(const QString &string, const QTextCharFormat &format);
void addOutput(const QString &string, ProjectExplorer::BuildStep::OutputFormat 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, const QTextCharFormat &color);
virtual void outputAdded(const QString &string, ProjectExplorer::BuildStep::OutputFormat format);
/// 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);
......
......@@ -104,8 +104,7 @@ void OutputParserTester::testOutputMangling(const QString &input,
{
reset();
QTextCharFormat textCharFormat;
childParser()->outputAdded(input, textCharFormat);
childParser()->outputAdded(input, BuildStep::NormalOutput);
QCOMPARE(m_receivedOutput, output);
QVERIFY(m_receivedStdErrChildLine.isNull());
......
......@@ -135,9 +135,7 @@ bool MakeStep::init()
// Try to detect command in environment
const QString tmp = environment.searchInPath(makeCmd);
if (tmp.isEmpty()) {
QTextCharFormat textCharFormat;
textCharFormat.setForeground(Qt::red);
emit addOutput(tr("Could not find make command: %1 in the build environment").arg(makeCmd), textCharFormat);
emit addOutput(tr("Could not find make command: %1 in the build environment").arg(makeCmd), BuildStep::ErrorOutput);
return false;
}
makeCmd = tmp;
......
......@@ -201,17 +201,13 @@ void QMakeStep::run(QFutureInterface<bool> &fi)
canContinue = false;
}
if (!canContinue) {
QTextCharFormat textCharFormat;
textCharFormat.setForeground(Qt::blue);
emit addOutput(tr("Configuration is faulty, please check the Build Issues view for details."), textCharFormat);
emit addOutput(tr("Configuration is faulty, please check the Build Issues view for details."), BuildStep::MessageOutput);
fi.reportResult(false);
return;
}
if (!m_needToRunQMake) {
QTextCharFormat textCharFormat;
textCharFormat.setForeground(Qt::blue);
emit addOutput(tr("Configuration unchanged, skipping qmake step."), textCharFormat);
emit addOutput(tr("Configuration unchanged, skipping qmake step."), BuildStep::MessageOutput);
fi.reportResult(true);
return;
}
......
......@@ -170,7 +170,7 @@ void MaemoDeployStep::raiseError(const QString &errorString)
}
void MaemoDeployStep::writeOutput(const QString &text,
const QTextCharFormat &format)
ProjectExplorer::BuildStep::OutputFormat format)
{
emit addOutput(text, format);
}
......@@ -435,9 +435,7 @@ void MaemoDeployStep::handleInstallerOutput(const QByteArray &output)
void MaemoDeployStep::handleInstallerErrorOutput(const QByteArray &output)
{
QTextCharFormat format;
format.setForeground(QBrush(QColor("red")));
writeOutput(output, format);
writeOutput(output, BuildStep::ErrorOutput);
}
......
......@@ -99,8 +99,7 @@ private:
void ctor();
void raiseError(const QString &error);
void writeOutput(const QString &text,
const QTextCharFormat &format = QTextCharFormat());
void writeOutput(const QString &text, ProjectExplorer::BuildStep::OutputFormat = BuildStep::NormalOutput);
void addDeployTimesToMap(QVariantMap &map) const;
void getDeployTimesFromMap(const QVariantMap &map);
const MaemoPackageCreationStep *packagingStep() const;
......
......@@ -127,8 +127,7 @@ bool MaemoPackageCreationStep::createPackage()
if (!packagingNeeded())
return true;
QTextCharFormat textCharFormat;
emit addOutput(tr("Creating package file ..."), textCharFormat);
emit addOutput(tr("Creating package file ..."), BuildStep::MessageOutput);
QFile configFile(targetRoot() % QLatin1String("/config.sh"));
if (!configFile.open(QIODevice::ReadOnly)) {
raiseError(tr("Cannot open MADDE config file '%1'.")
......@@ -243,15 +242,14 @@ bool MaemoPackageCreationStep::createPackage()
}
}
emit addOutput(tr("Package created."), textCharFormat);
emit addOutput(tr("Package created."), BuildStep::MessageOutput);
deployStep()->deployables()->setUnmodified();
return true;
}
bool MaemoPackageCreationStep::runCommand(const QString &command)
{
QTextCharFormat textCharFormat;
emit addOutput(tr("Package Creation: Running command '%1'.").arg(command), textCharFormat);
emit addOutput(tr("Package Creation: Running command '%1'.").arg(command), BuildStep::MessageOutput);
QString perl;
#ifdef Q_OS_WIN
perl = maddeRoot() + QLatin1String("/bin/perl.exe ");
......@@ -281,13 +279,11 @@ bool MaemoPackageCreationStep::runCommand(const QString &command)
void MaemoPackageCreationStep::handleBuildOutput()
{
const QByteArray &stdOut = m_buildProc->readAllStandardOutput();
QTextCharFormat textCharFormat;
if (!stdOut.isEmpty())
emit addOutput(QString::fromLocal8Bit(stdOut), textCharFormat);
emit addOutput(QString::fromLocal8Bit(stdOut), BuildStep::NormalOutput);
const QByteArray &errorOut = m_buildProc->readAllStandardError();
if (!errorOut.isEmpty()) {
textCharFormat.setForeground(QBrush(QColor("red")));
emit addOutput(QString::fromLocal8Bit(errorOut), textCharFormat);
emit addOutput(QString::fromLocal8Bit(errorOut), BuildStep::ErrorOutput);
}
}
......@@ -373,8 +369,7 @@ QString MaemoPackageCreationStep::nativePath(const QFile &file) const
void MaemoPackageCreationStep::raiseError(const QString &shortMsg,
const QString &detailedMsg)
{
QTextCharFormat textCharFormat;
emit addOutput(detailedMsg.isNull() ? shortMsg : detailedMsg, textCharFormat);
emit addOutput(detailedMsg.isNull() ? shortMsg : detailedMsg, BuildStep::ErrorOutput);
emit addTask(Task(Task::Error, shortMsg, QString(), -1,
TASK_CATEGORY_BUILDSYSTEM));
}
......
Supports Markdown
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