Web lists-archives.org

[PATCH] IM choose support for KWrite




Hi,

I have created a path for KWrite to support additional Input Method
engines, which are provided by qt plugins. This patch adds 'Select IM'
item with list of available IM engines to editor's context menu.

--
WBR,
Anton Mikhalyov
--- ./a/kdebase/apps/kwrite/kwritemain.cpp	2008-02-10 23:49:35.000000000 +0300
+++ ./b/kdebase/apps/kwrite/kwritemain.cpp	2008-02-11 00:26:57.000000000 +0300
@@ -53,6 +53,10 @@
 #include <QtCore/QTimer>
 #include <QtCore/QTextCodec>
 
+#include <QtGui/QMenu>
+#include <QtGui/QInputContext>
+
+
 QList<KTextEditor::Document*> KWrite::docList;
 QList<KWrite*> KWrite::winList;
 
@@ -107,8 +111,31 @@
   createShellGUI( true );
   guiFactory()->addClient( m_view );
 
-  // install a working kate part popup dialog thingy
-  m_view->setContextMenu ((QMenu*)(factory()->container("ktexteditor_popup", this)) );
+  // install a working kate part p dialog thingy
+  QMenu* popupMenu = (QMenu*)(factory()->container("ktexteditor_popup", this));
+
+  #ifndef QT_NO_IM
+
+  QInputContext* inputContext = kapp->inputContext();
+  if (inputContext != NULL)
+  {
+    const QList<QAction*> inputMethods = inputContext->actions();
+
+    if (inputMethods.count() > 1)
+    {
+      QList<QAction*>::ConstIterator it = inputMethods.begin();
+      
+      while (it != inputMethods.end())
+      {
+        popupMenu->addAction(*it);
+        it++;
+      }
+    }
+  }
+
+  #endif // QT_NO_IM
+
+  m_view->setContextMenu ( popupMenu );
 
   // init with more useful size, stolen from konq :)
   if (!initialGeometrySet())
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<