QTextHtmlParser: restore the default link color from app palette
The default link color used to be resolved to the link color of the application palette, but got lost during the Qt 5 modularization (see commits7351a43
and3f9a7f9
). Task-number: QTBUG-28998 Change-Id: I7f07427f6c03f83c557100938ad9f7a39349d303 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
parent
163bbeb218
commit
a83983d861
@ -46,7 +46,7 @@
|
||||
#include <qstack.h>
|
||||
#include <qdebug.h>
|
||||
#include <qthread.h>
|
||||
#include <qcoreapplication.h>
|
||||
#include <qguiapplication.h>
|
||||
|
||||
#include "qtextdocument.h"
|
||||
#include "qtextformat_p.h"
|
||||
@ -1066,7 +1066,7 @@ void QTextHtmlParserNode::initializeProperties(const QTextHtmlParserNode *parent
|
||||
&& !attributes.at(i + 1).isEmpty()) {
|
||||
hasHref = true;
|
||||
charFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline);
|
||||
charFormat.setForeground(Qt::blue);
|
||||
charFormat.setForeground(QGuiApplication::palette().link());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include <qabstracttextdocumentlayout.h>
|
||||
#include <qtextlist.h>
|
||||
#include <qtextcodec.h>
|
||||
#include <qguiapplication.h>
|
||||
#include <qurl.h>
|
||||
#include <qpainter.h>
|
||||
#include <qfontmetrics.h>
|
||||
@ -187,6 +188,9 @@ private slots:
|
||||
|
||||
void QTBUG27354_spaceAndSoftSpace();
|
||||
void cssInheritance();
|
||||
|
||||
void QTBUG28998_linkColor();
|
||||
|
||||
private:
|
||||
void backgroundImage_checkExpectedHtml(const QTextDocument &doc);
|
||||
|
||||
@ -2974,5 +2978,29 @@ void tst_QTextDocument::cssInheritance()
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QTextDocument::QTBUG28998_linkColor()
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Link, QColor("tomato"));
|
||||
QGuiApplication::setPalette(pal);
|
||||
|
||||
QTextDocument doc;
|
||||
doc.setHtml("<a href=\"http://www.qt-project.org\">Qt</a>");
|
||||
|
||||
QCOMPARE(doc.blockCount(), 1);
|
||||
QTextBlock block = doc.firstBlock();
|
||||
QVERIFY(block.isValid());
|
||||
|
||||
QTextFragment fragment = block.begin().fragment();
|
||||
QVERIFY(fragment.isValid());
|
||||
|
||||
QTextCharFormat format = fragment.charFormat();
|
||||
QVERIFY(format.isValid());
|
||||
QVERIFY(format.isAnchor());
|
||||
QCOMPARE(format.anchorHref(), QStringLiteral("http://www.qt-project.org"));
|
||||
|
||||
QCOMPARE(format.foreground(), pal.link());
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QTextDocument)
|
||||
#include "tst_qtextdocument.moc"
|
||||
|
Loading…
Reference in New Issue
Block a user