Blame SOURCES/0037-Update-the-preedit-styling-mapping.patch

f38a11
From 3ddd4dcb1790920ce2598ebdbe14c95bdba55005 Mon Sep 17 00:00:00 2001
b814f0
From: Weng Xuetian <wengxt@gmail.com>
b814f0
Date: Wed, 22 Dec 2021 10:42:38 -0800
f38a11
Subject: [PATCH 37/40] Update the preedit styling mapping
b814f0
b814f0
- None mapping to no style.
b814f0
- Default/Underline mapping to underline.
b814f0
- Highlight/Selection mapping to background color/text color with highlight/highlight
b814f0
text with underline.
b814f0
- Active/Inactive mapping to bold text with underline.
b814f0
- Incorrect mapping to red wave underline.
b814f0
b814f0
Pick-to: 5.15 6.2 6.3
b814f0
Change-Id: Iab51d671b8f83aece8596f7f7610de19343fcceb
b814f0
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
b814f0
(cherry picked from commit f1fb5d9e568a24e213ee41e82a1142cef56f1098)
b814f0
---
b814f0
 .../qwaylandinputmethodeventbuilder.cpp       | 31 ++++++++++++-------
b814f0
 1 file changed, 20 insertions(+), 11 deletions(-)
b814f0
b814f0
diff --git a/src/shared/qwaylandinputmethodeventbuilder.cpp b/src/shared/qwaylandinputmethodeventbuilder.cpp
b814f0
index 458d818e..f50ccf30 100644
b814f0
--- a/src/shared/qwaylandinputmethodeventbuilder.cpp
b814f0
+++ b/src/shared/qwaylandinputmethodeventbuilder.cpp
b814f0
@@ -39,7 +39,10 @@
b814f0
 
b814f0
 #include "qwaylandinputmethodeventbuilder_p.h"
b814f0
 
b814f0
+#include <QBrush>
b814f0
+#include <QGuiApplication>
b814f0
 #include <QInputMethod>
b814f0
+#include <QPalette>
b814f0
 #include <QTextCharFormat>
b814f0
 
b814f0
 #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
b814f0
@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
b814f0
     QTextCharFormat format;
b814f0
 
b814f0
     switch (style) {
b814f0
-    case 0:
b814f0
-    case 1:
b814f0
+    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
b814f0
+        break;
b814f0
+    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
b814f0
+    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
b814f0
         format.setFontUnderline(true);
b814f0
         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
b814f0
         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
b814f0
         break;
b814f0
-    case 2:
b814f0
-    case 3:
b814f0
+    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
b814f0
+    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
b814f0
         format.setFontWeight(QFont::Bold);
b814f0
         format.setFontUnderline(true);
b814f0
         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
b814f0
         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
b814f0
         break;
b814f0
-    case 4:
b814f0
-        format.setFontUnderline(true);
b814f0
-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
b814f0
-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
b814f0
+    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
b814f0
+    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
b814f0
+        {
b814f0
+            format.setFontUnderline(true);
b814f0
+            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
b814f0
+            QPalette palette = qApp->palette();
b814f0
+            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
b814f0
+            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
b814f0
+            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
b814f0
+        }
b814f0
         break;
b814f0
-    case 5:
b814f0
+    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
b814f0
         format.setFontUnderline(true);
b814f0
         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
b814f0
         format.setUnderlineColor(QColor(Qt::red));
b814f0
         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
b814f0
         break;
b814f0
-//    case QtWayland::wl_text_input::preedit_style_selection:
b814f0
-//    case QtWayland::wl_text_input::preedit_style_none:
b814f0
     default:
b814f0
         break;
b814f0
     }
b814f0
-- 
b814f0
2.35.1
b814f0