forked from qt-creator/qt-creator
Fixed the link style in the application output window.
Reviewed-by: Tobias Hunger
This commit is contained in:
@@ -88,7 +88,7 @@ void OutputFormatter::clearLastLine()
|
|||||||
cursor.removeSelectedText();
|
cursor.removeSelectedText();
|
||||||
}
|
}
|
||||||
|
|
||||||
static QColor mix_colors(QColor a, QColor b)
|
QColor OutputFormatter::mixColors(const QColor &a, const QColor &b)
|
||||||
{
|
{
|
||||||
return QColor((a.red() + 2 * b.red()) / 3, (a.green() + 2 * b.green()) / 3,
|
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);
|
(a.blue() + 2* b.blue()) / 3, (a.alpha() + 2 * b.alpha()) / 3);
|
||||||
@@ -108,11 +108,11 @@ void OutputFormatter::initFormats()
|
|||||||
|
|
||||||
// NormalMessageFormat
|
// NormalMessageFormat
|
||||||
m_formats[NormalMessageFormat].setFont(boldFont);
|
m_formats[NormalMessageFormat].setFont(boldFont);
|
||||||
m_formats[NormalMessageFormat].setForeground(mix_colors(p.color(QPalette::Text), QColor(Qt::blue)));
|
m_formats[NormalMessageFormat].setForeground(mixColors(p.color(QPalette::Text), QColor(Qt::blue)));
|
||||||
|
|
||||||
// ErrorMessageFormat
|
// ErrorMessageFormat
|
||||||
m_formats[ErrorMessageFormat].setFont(boldFont);
|
m_formats[ErrorMessageFormat].setFont(boldFont);
|
||||||
m_formats[ErrorMessageFormat].setForeground(mix_colors(p.color(QPalette::Text), QColor(Qt::red)));
|
m_formats[ErrorMessageFormat].setForeground(mixColors(p.color(QPalette::Text), QColor(Qt::red)));
|
||||||
|
|
||||||
// StdOutFormat
|
// StdOutFormat
|
||||||
m_formats[StdOutFormat].setFont(font);
|
m_formats[StdOutFormat].setFont(font);
|
||||||
@@ -120,7 +120,7 @@ void OutputFormatter::initFormats()
|
|||||||
|
|
||||||
// StdErrFormat
|
// StdErrFormat
|
||||||
m_formats[StdErrFormat].setFont(font);
|
m_formats[StdErrFormat].setFont(font);
|
||||||
m_formats[StdErrFormat].setForeground(mix_colors(p.color(QPalette::Text), QColor(Qt::red)));
|
m_formats[StdErrFormat].setForeground(mixColors(p.color(QPalette::Text), QColor(Qt::red)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputFormatter::handleLink(const QString &href)
|
void OutputFormatter::handleLink(const QString &href)
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
|
#include <QtGui/QColor>
|
||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QMouseEvent);
|
QT_FORWARD_DECLARE_CLASS(QMouseEvent);
|
||||||
QT_FORWARD_DECLARE_CLASS(QPlainTextEdit);
|
QT_FORWARD_DECLARE_CLASS(QPlainTextEdit);
|
||||||
@@ -71,6 +72,8 @@ protected:
|
|||||||
void clearLastLine();
|
void clearLastLine();
|
||||||
QTextCharFormat format(Format format);
|
QTextCharFormat format(Format format);
|
||||||
|
|
||||||
|
static QColor mixColors(const QColor &a, const QColor &b);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPlainTextEdit *m_plainTextEdit;
|
QPlainTextEdit *m_plainTextEdit;
|
||||||
QTextCharFormat *m_formats;
|
QTextCharFormat *m_formats;
|
||||||
|
|||||||
@@ -77,14 +77,6 @@ LinkResult QtOutputFormatter::matchLine(const QString &line) const
|
|||||||
|
|
||||||
void QtOutputFormatter::appendApplicationOutput(const QString &txt, bool onStdErr)
|
void QtOutputFormatter::appendApplicationOutput(const QString &txt, bool onStdErr)
|
||||||
{
|
{
|
||||||
// Do the initialization lazily, as we don't have a plaintext edit
|
|
||||||
// in the ctor
|
|
||||||
if (!m_linkFormat.isValid()) {
|
|
||||||
m_linkFormat.setForeground(plainTextEdit()->palette().link().color());
|
|
||||||
m_linkFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline);
|
|
||||||
m_linkFormat.setAnchor(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextCursor cursor(plainTextEdit()->document());
|
QTextCursor cursor(plainTextEdit()->document());
|
||||||
cursor.movePosition(QTextCursor::End);
|
cursor.movePosition(QTextCursor::End);
|
||||||
cursor.beginEditBlock();
|
cursor.beginEditBlock();
|
||||||
@@ -166,10 +158,18 @@ void QtOutputFormatter::appendApplicationOutput(const QString &txt, bool onStdEr
|
|||||||
|
|
||||||
void QtOutputFormatter::appendLine(QTextCursor &cursor, LinkResult lr, const QString &line, bool onStdErr)
|
void QtOutputFormatter::appendLine(QTextCursor &cursor, LinkResult lr, const QString &line, bool onStdErr)
|
||||||
{
|
{
|
||||||
cursor.insertText(line.left(lr.start), format(onStdErr ? StdErrFormat : StdOutFormat));
|
const QTextCharFormat normalFormat = format(onStdErr ? StdErrFormat : StdOutFormat);
|
||||||
m_linkFormat.setAnchorHref(lr.href);
|
cursor.insertText(line.left(lr.start), normalFormat);
|
||||||
cursor.insertText(line.mid(lr.start, lr.end - lr.start), m_linkFormat);
|
|
||||||
cursor.insertText(line.mid(lr.end), format(onStdErr ? StdErrFormat : StdOutFormat));
|
QTextCharFormat linkFormat = normalFormat;
|
||||||
|
const QColor textColor = plainTextEdit()->palette().color(QPalette::Text);
|
||||||
|
linkFormat.setForeground(mixColors(textColor, QColor(Qt::blue)));
|
||||||
|
linkFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline);
|
||||||
|
linkFormat.setAnchor(true);
|
||||||
|
linkFormat.setAnchorHref(lr.href);
|
||||||
|
cursor.insertText(line.mid(lr.start, lr.end - lr.start), linkFormat);
|
||||||
|
|
||||||
|
cursor.insertText(line.mid(lr.end), normalFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtOutputFormatter::handleLink(const QString &href)
|
void QtOutputFormatter::handleLink(const QString &href)
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ private:
|
|||||||
QRegExp m_qtAssert;
|
QRegExp m_qtAssert;
|
||||||
QRegExp m_qtTestFail;
|
QRegExp m_qtTestFail;
|
||||||
QWeakPointer<ProjectExplorer::Project> m_project;
|
QWeakPointer<ProjectExplorer::Project> m_project;
|
||||||
QTextCharFormat m_linkFormat;
|
|
||||||
QString m_lastLine;
|
QString m_lastLine;
|
||||||
QString m_deferedText;
|
QString m_deferedText;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user