2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "compileoutputwindow.h"
|
|
|
|
|
#include "buildmanager.h"
|
2010-06-30 16:39:32 +02:00
|
|
|
#include "showoutputtaskhandler.h"
|
|
|
|
|
#include "task.h"
|
2011-04-14 10:39:09 +02:00
|
|
|
#include "projectexplorerconstants.h"
|
|
|
|
|
#include "projectexplorer.h"
|
|
|
|
|
#include "projectexplorersettings.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-04-14 10:39:09 +02:00
|
|
|
#include <coreplugin/icontext.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <find/basetextfind.h>
|
|
|
|
|
#include <aggregation/aggregate.h>
|
2010-06-30 16:39:32 +02:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include <QtGui/QKeyEvent>
|
|
|
|
|
#include <QtGui/QIcon>
|
2010-07-13 16:36:37 +02:00
|
|
|
#include <QtGui/QTextCharFormat>
|
2010-06-30 16:39:32 +02:00
|
|
|
#include <QtGui/QTextBlock>
|
|
|
|
|
#include <QtGui/QTextCursor>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtGui/QTextEdit>
|
2009-04-29 14:23:54 +02:00
|
|
|
#include <QtGui/QScrollBar>
|
2010-01-25 15:09:16 +01:00
|
|
|
#include <QtGui/QPlainTextEdit>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace ProjectExplorer::Internal;
|
|
|
|
|
|
2010-07-02 15:54:41 +02:00
|
|
|
namespace {
|
2010-08-11 15:34:32 +02:00
|
|
|
const int MAX_LINECOUNT = 50000;
|
2010-07-02 15:54:41 +02:00
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
CompileOutputWindow::CompileOutputWindow(BuildManager * /*bm*/)
|
|
|
|
|
{
|
2011-04-14 10:39:09 +02:00
|
|
|
Core::Context context(Constants::C_COMPILE_OUTPUT);
|
2011-04-21 13:42:17 +02:00
|
|
|
m_outputWindow = new Core::OutputWindow(context);
|
2010-07-12 14:01:42 +02:00
|
|
|
m_outputWindow->setWindowTitle(tr("Compile Output"));
|
2011-05-20 19:48:44 +02:00
|
|
|
m_outputWindow->setWindowIcon(QIcon(QLatin1String(Constants::ICON_WINDOW)));
|
2010-07-12 14:01:42 +02:00
|
|
|
m_outputWindow->setReadOnly(true);
|
2011-02-04 14:51:55 +01:00
|
|
|
m_outputWindow->setUndoRedoEnabled(false);
|
2011-04-29 09:36:04 +02:00
|
|
|
m_outputWindow->setMaxLineCount(MAX_LINECOUNT);
|
2010-07-12 14:01:42 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
Aggregation::Aggregate *agg = new Aggregation::Aggregate;
|
2010-07-12 14:01:42 +02:00
|
|
|
agg->add(m_outputWindow);
|
|
|
|
|
agg->add(new Find::BaseTextFind(m_outputWindow));
|
2010-06-08 15:04:42 +02:00
|
|
|
|
|
|
|
|
qRegisterMetaType<QTextCharFormat>("QTextCharFormat");
|
2010-06-30 16:39:32 +02:00
|
|
|
|
|
|
|
|
m_handler = new ShowOutputTaskHandler(this);
|
|
|
|
|
ExtensionSystem::PluginManager::instance()->addObject(m_handler);
|
2011-04-14 10:39:09 +02:00
|
|
|
connect(ProjectExplorerPlugin::instance(), SIGNAL(settingsChanged()),
|
|
|
|
|
this, SLOT(updateWordWrapMode()));
|
|
|
|
|
updateWordWrapMode();
|
2010-06-30 16:39:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CompileOutputWindow::~CompileOutputWindow()
|
|
|
|
|
{
|
|
|
|
|
ExtensionSystem::PluginManager::instance()->removeObject(m_handler);
|
|
|
|
|
delete m_handler;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-14 10:39:09 +02:00
|
|
|
void CompileOutputWindow::updateWordWrapMode()
|
|
|
|
|
{
|
|
|
|
|
m_outputWindow->setWordWrapEnabled(ProjectExplorerPlugin::instance()->projectExplorerSettings().wrapAppOutput);
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-27 13:47:06 +02:00
|
|
|
bool CompileOutputWindow::hasFocus() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-07-12 14:01:42 +02:00
|
|
|
return m_outputWindow->hasFocus();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-27 13:47:06 +02:00
|
|
|
bool CompileOutputWindow::canFocus() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CompileOutputWindow::setFocus()
|
|
|
|
|
{
|
2010-07-12 14:01:42 +02:00
|
|
|
m_outputWindow->setFocus();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWidget *CompileOutputWindow::outputWidget(QWidget *)
|
|
|
|
|
{
|
2010-07-12 14:01:42 +02:00
|
|
|
return m_outputWindow;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-15 10:29:38 +02:00
|
|
|
static QColor mix_colors(QColor a, QColor b)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-07-27 15:21:51 +02:00
|
|
|
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);
|
2010-07-15 10:29:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-29 09:36:04 +02:00
|
|
|
m_outputWindow->appendText(text, textFormat);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CompileOutputWindow::clearContents()
|
|
|
|
|
{
|
2010-07-12 14:01:42 +02:00
|
|
|
m_outputWindow->clear();
|
2010-06-30 16:39:32 +02:00
|
|
|
m_taskPositions.clear();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-12 14:01:42 +02:00
|
|
|
void CompileOutputWindow::visibilityChanged(bool)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-07-12 14:01:42 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int CompileOutputWindow::priorityInStatusBar() const
|
|
|
|
|
{
|
|
|
|
|
return 50;
|
|
|
|
|
}
|
2009-04-30 12:50:52 +02:00
|
|
|
|
2011-09-27 13:47:06 +02:00
|
|
|
bool CompileOutputWindow::canNext() const
|
2009-04-30 12:50:52 +02:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-27 13:47:06 +02:00
|
|
|
bool CompileOutputWindow::canPrevious() const
|
2009-04-30 12:50:52 +02:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CompileOutputWindow::goToNext()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CompileOutputWindow::goToPrev()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-27 13:47:06 +02:00
|
|
|
bool CompileOutputWindow::canNavigate() const
|
2009-04-30 12:50:52 +02:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2010-06-30 16:39:32 +02:00
|
|
|
|
|
|
|
|
void CompileOutputWindow::registerPositionOf(const Task &task)
|
|
|
|
|
{
|
2010-07-12 14:01:42 +02:00
|
|
|
int blocknumber = m_outputWindow->blockCount();
|
2010-07-02 15:54:41 +02:00
|
|
|
if (blocknumber > MAX_LINECOUNT)
|
|
|
|
|
return;
|
2010-08-04 14:50:46 +02:00
|
|
|
m_taskPositions.insert(task.taskId, blocknumber);
|
2010-06-30 16:39:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CompileOutputWindow::knowsPositionOf(const Task &task)
|
|
|
|
|
{
|
|
|
|
|
return (m_taskPositions.contains(task.taskId));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CompileOutputWindow::showPositionOf(const Task &task)
|
|
|
|
|
{
|
|
|
|
|
int position = m_taskPositions.value(task.taskId);
|
2010-07-12 14:01:42 +02:00
|
|
|
QTextCursor newCursor(m_outputWindow->document()->findBlockByNumber(position));
|
2010-06-30 16:39:32 +02:00
|
|
|
newCursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
|
2010-07-12 14:01:42 +02:00
|
|
|
m_outputWindow->setTextCursor(newCursor);
|
2010-06-30 16:39:32 +02:00
|
|
|
}
|