diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-08-20 12:59:40 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-08-21 01:28:26 +0200 |
commit | b963888b1c7ff01f0815752c4212808ee8ecf244 (patch) | |
tree | 0e1d3b1bd906ba86fd4c02b37f9a398ef6302b99 /src/plugins/platforms/cocoa | |
parent | fa6e490374afc9cc64cbe25c031bbec7cd7bef44 (diff) |
macOS: Handle more NSUnderlineStyles during text composition
Pick-to: 6.2
Change-Id: I2a6cf612506d19736eab007f687a03f6d6595b62
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview_complextext.mm | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview_complextext.mm b/src/plugins/platforms/cocoa/qnsview_complextext.mm index a22d19d0ed..0d1027d705 100644 --- a/src/plugins/platforms/cocoa/qnsview_complextext.mm +++ b/src/plugins/platforms/cocoa/qnsview_complextext.mm @@ -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]) |