macOS: Handle more NSUnderlineStyles during text composition
Pick-to: 6.2 Change-Id: I2a6cf612506d19736eab007f687a03f6d6595b62 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
fa6e490374
commit
b963888b1c
@ -150,8 +150,28 @@
|
||||
qCDebug(lcQpaKeys) << "Decorating range" << range << "based on" << attributes;
|
||||
QTextCharFormat format;
|
||||
|
||||
if (NSNumber *underlineStyle = attributes[NSUnderlineStyleAttributeName])
|
||||
format.setFontUnderline(true); // FIXME: Support all NSUnderlineStyles
|
||||
if (NSNumber *underlineStyle = attributes[NSUnderlineStyleAttributeName]) {
|
||||
format.setFontUnderline(true);
|
||||
NSUnderlineStyle style = underlineStyle.integerValue;
|
||||
if (style & NSUnderlineStylePatternDot)
|
||||
format.setUnderlineStyle(QTextCharFormat::DotLine);
|
||||
else if (style & NSUnderlineStylePatternDash)
|
||||
format.setUnderlineStyle(QTextCharFormat::DashUnderline);
|
||||
else if (style & NSUnderlineStylePatternDashDot)
|
||||
format.setUnderlineStyle(QTextCharFormat::DashDotLine);
|
||||
if (style & NSUnderlineStylePatternDashDotDot)
|
||||
format.setUnderlineStyle(QTextCharFormat::DashDotDotLine);
|
||||
else
|
||||
format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
|
||||
|
||||
// Unfortunately QTextCharFormat::UnderlineStyle does not distinguish
|
||||
// between NSUnderlineStyle{Single,Thick,Double}, which is used by CJK
|
||||
// input methods to highlight the selected clause segments, so we fake
|
||||
// it using QTextCharFormat::WaveUnderline.
|
||||
if ((style & NSUnderlineStyleThick) == NSUnderlineStyleThick
|
||||
|| (style & NSUnderlineStyleDouble) == NSUnderlineStyleDouble)
|
||||
format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
|
||||
}
|
||||
if (NSColor *underlineColor = attributes[NSUnderlineColorAttributeName])
|
||||
format.setUnderlineColor(qt_mac_toQColor(underlineColor));
|
||||
if (NSColor *foregroundColor = attributes[NSForegroundColorAttributeName])
|
||||
|
Loading…
Reference in New Issue
Block a user