Revision: 6557
Author: ek.kato
Date: Tue Jul 20 20:46:46 2010
Log: * qt/switcher-qt.h
* qt/switcher-qt.cpp
  - (UimImSwitcher::saveDefaultIm) : New.
  - (UimImSwitcher::UimImSwitcher) : Enable uim_custom.
  - (UimImSwitcher::slotChangeInputMethod) : Save default IM upon
    ID_CHANGE_WHOLE_DESKTOP.
* qt/Makefile.am (uim_im_switcher_qt_LDADD) : Add libuim-custom.
* qt4/switcher/qt4.h
* qt4/switcher/qt4.cpp
* qt4/switcher/uim-im-switcher-qt4.pro.in
  - Likewise.

http://code.google.com/p/uim/source/detail?r=6557

Modified:
 /trunk/qt/Makefile.am
 /trunk/qt/switcher-qt.cpp
 /trunk/qt/switcher-qt.h
 /trunk/qt4/switcher/qt4.cpp
 /trunk/qt4/switcher/qt4.h
 /trunk/qt4/switcher/uim-im-switcher-qt4.pro.in

=======================================
--- /trunk/qt/Makefile.am       Mon May 12 08:24:03 2008
+++ /trunk/qt/Makefile.am       Tue Jul 20 20:46:46 2010
@@ -165,7 +165,8 @@
 uim_im_switcher_qt_CXXFLAGS = $(QT_CXXFLAGS)
 uim_im_switcher_qt_LDFLAGS  = $(QT_LDFLAGS)
 uim_im_switcher_qt_LDADD    = $(top_builddir)/uim/libuim-scm.la \
-                             $(top_builddir)/uim/libuim.la
+                             $(top_builddir)/uim/libuim.la \
+                             $(top_builddir)/uim/libuim-custom.la
 switcher-qt.cpp: switcher-qt.moc


=======================================
--- /trunk/qt/switcher-qt.cpp   Thu May  6 04:41:07 2010
+++ /trunk/qt/switcher-qt.cpp   Tue Jul 20 20:46:46 2010
@@ -48,11 +48,14 @@
 #include <stdlib.h>
 #include <locale.h>

+#include <uim/uim-scm.h>
+#include <uim/uim-custom.h>
 #include "qtgettext.h"

 #define NAME_COLUMN 0

 static int uim_fd;
+static bool customEnabled;
 static QSocketNotifier *notifier = NULL;

 int main( int argc, char **argv )
@@ -89,6 +92,9 @@
     /* to load input method list */
     uim_helper_send_message( uim_fd, "im_list_get\n" );

+    uim_init();
+    customEnabled = uim_custom_enable();
+
     /* create GUI */
     createGUI();
 }
@@ -173,6 +179,7 @@
     {
     case ID_CHANGE_WHOLE_DESKTOP:
         sendMessageImChange( "im_change_whole_desktop\n" );
+        saveDefaultIm();
         break;
     case ID_CHANGE_THIS_APPLICATION_ONLY:
         sendMessageImChange( "im_change_this_application_only\n" );
@@ -203,6 +210,22 @@

     uim_helper_send_message( uim_fd, ( const char* ) msg.utf8() );
 }
+
+void UimImSwitcher::saveDefaultIm()
+{
+    if ( customEnabled )
+    {
+        QString imName = selectedImName();
+        if ( imName.isEmpty() )
+            return ;
+
+        uim_scm_callf( "custom-set-value!",
+                       "yy",
+                       "custom-preserved-default-im-name",
+                       ( const char* ) imName.utf8() );
+        uim_custom_save_custom( "custom-preserved-default-im-name" );
+    }
+}

 QString UimImSwitcher::selectedImName() const
 {
=======================================
--- /trunk/qt/switcher-qt.h     Sun Apr  4 20:35:54 2010
+++ /trunk/qt/switcher-qt.h     Tue Jul 20 20:46:46 2010
@@ -62,6 +62,7 @@
     void createGUI();

     void sendMessageImChange( const QString &change_type );
+    void saveDefaultIm();
     QString selectedImName() const;

     void checkHelperConnection();
=======================================
--- /trunk/qt4/switcher/qt4.cpp Sat May  8 02:13:21 2010
+++ /trunk/qt4/switcher/qt4.cpp Tue Jul 20 20:46:46 2010
@@ -51,11 +51,14 @@
 #include <cstdlib>
 #include <clocale>

+#include <uim/uim-scm.h>
+#include <uim/uim-custom.h>
 #include "qtgettext.h"

 static const int NAME_COLUMN = 0;

 static int uim_fd;
+static bool customEnabled;
 static QSocketNotifier *notifier = 0;

 int main( int argc, char **argv )
@@ -91,6 +94,9 @@
     /* to load input method list */
     uim_helper_send_message( uim_fd, "im_list_get\n" );

+    uim_init();
+    customEnabled = uim_custom_enable();
+
     /* create GUI */
     createGUI();
 }
@@ -178,7 +184,10 @@
 void UimImSwitcher::slotChangeInputMethod()
 {
     if ( wholeButton->isChecked() )
+    {
         sendMessageImChange( "im_change_whole_desktop\n" );
+        saveDefaultIm();
+    }
     else if ( applicationButton->isChecked() )
         sendMessageImChange( "im_change_this_application_only\n" );
     else if ( textButton->isChecked() )
@@ -204,6 +213,22 @@
     uim_helper_send_message( uim_fd, msg.toUtf8().data() );
 }

+void UimImSwitcher::saveDefaultIm()
+{
+    if ( customEnabled )
+    {
+        QString imName = selectedImName();
+        if ( imName.isEmpty() )
+            return ;
+
+        uim_scm_callf( "custom-set-value!",
+                       "yy",
+                       "custom-preserved-default-im-name",
+                       imName.toUtf8().data() );
+        uim_custom_save_custom( "custom-preserved-default-im-name" );
+    }
+}
+
 QString UimImSwitcher::selectedImName() const
 {
     QList<QTableWidgetItem *> selectedItems = listview->selectedItems();
=======================================
--- /trunk/qt4/switcher/qt4.h   Sun Apr  4 20:35:54 2010
+++ /trunk/qt4/switcher/qt4.h   Tue Jul 20 20:46:46 2010
@@ -56,6 +56,7 @@
     void createGUI();

     void sendMessageImChange( const QString &change_type );
+    void saveDefaultIm();
     QString selectedImName() const;

     void checkHelperConnection();
=======================================
--- /trunk/qt4/switcher/uim-im-switcher-qt4.pro.in      Tue Mar  2 23:14:47 2010
+++ /trunk/qt4/switcher/uim-im-switcher-qt4.pro.in      Tue Jul 20 20:46:46 2010
@@ -8,7 +8,7 @@
 QMAKE_LIBDIR += @abs_top_builddir@/replace
 QMAKE_LIBDIR += @abs_top_builddir@/uim/.libs
 QMAKE_LIBDIR += @abs_top_builddir@/replace/.libs
-LIBS += -lreplace -luim -luim-scm -luim-x-util @LIBINTL@
+LIBS += -lreplace -luim -luim-scm -luim-custom @LIBINTL@

 QMAKE_CFLAGS_DEBUG     += @CFLAGS@   @X_CFLAGS@
 QMAKE_CFLAGS_RELEASE   += @CFLAGS@   @X_CFLAGS@

Reply via email to