Fixed the link style in the application output window.

Reviewed-by: Tobias Hunger
This commit is contained in:
Erik Verbruggen
2010-10-18 13:33:55 +02:00
parent f3834f010b
commit deb2ccd2ca
4 changed files with 19 additions and 17 deletions

View File

@@ -77,14 +77,6 @@ LinkResult QtOutputFormatter::matchLine(const QString &line) const
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());
cursor.movePosition(QTextCursor::End);
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)
{
cursor.insertText(line.left(lr.start), format(onStdErr ? StdErrFormat : StdOutFormat));
m_linkFormat.setAnchorHref(lr.href);
cursor.insertText(line.mid(lr.start, lr.end - lr.start), m_linkFormat);
cursor.insertText(line.mid(lr.end), format(onStdErr ? StdErrFormat : StdOutFormat));
const QTextCharFormat normalFormat = format(onStdErr ? StdErrFormat : StdOutFormat);
cursor.insertText(line.left(lr.start), normalFormat);
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)