Revision: 6247
Author: nogu.dev
Date: Thu Mar 11 04:29:59 2010
Log: * qt4/immodule/quiminputcontext.cpp
  - (getUserDefinedColor): New function.
  - (QUimInputContext::getPreeditAttrs):
    Honor reversed-preedit-foreground and reversed-preedit-background
    settings.
http://code.google.com/p/uim/source/detail?r=6247

Modified:
 /trunk/qt4/immodule/quiminputcontext.cpp

=======================================
--- /trunk/qt4/immodule/quiminputcontext.cpp    Thu Mar 11 04:29:49 2010
+++ /trunk/qt4/immodule/quiminputcontext.cpp    Thu Mar 11 04:29:59 2010
@@ -714,6 +714,14 @@

     return 0;
 }
+
+static QColor getUserDefinedColor( const char *symbol )
+{
+    char *literal = uim_scm_symbol_value_str( symbol );
+    QColor color( QString::fromAscii( literal ) );
+    free( literal );
+    return color;
+}

 QList<QInputMethodEvent::Attribute> QUimInputContext::getPreeditAttrs()
 {
@@ -754,8 +762,12 @@
                 segFmt.setBackground( fmt.foreground() );
 #else
                 // FIXME: Retrieve customized colors from the text widget
-                segFmt.setForeground( Qt::white );
-                segFmt.setBackground( Qt::black );
+                QColor color = getUserDefinedColor(
+                    "reversed-preedit-foreground" );
+ segFmt.setForeground( color.isValid() ? color : Qt::white );
+                color = getUserDefinedColor(
+                    "reversed-preedit-background" );
+ segFmt.setBackground( color.isValid() ? color : Qt::black );
 #endif
             }
             if ( uimAttr & UPreeditAttr_UnderLine ) {

Reply via email to