Author: kzk
Date: Tue Mar  1 21:38:39 2005
New Revision: 737

Removed:
   trunk/qt/pref-keygrabformbase.ui
Modified:
   trunk/qt/Makefile.am
   trunk/qt/pref-customwidgets.cpp
   trunk/qt/pref-customwidgets.h
   trunk/qt/pref-qt.cpp
   trunk/qt/pref-qt.h

Log:
* This commit aims to be compatible in key grabbing
  between uim-pref-gtk and uim-pref-qt

* qt/pref-customwidgets.h
* qt/pref-customwidgets.cpp
  - use KeyGrabDialog instead of KeyGrabForm
* qt/pref-keygrabformbase.ui
  - deleted
* qt/Makefile.am
  - remove pref-keygrabformbase.ui
* qt/pref-qt.h
* qt/pref-qt.cpp
  - delete class SubgroupData


Modified: trunk/qt/Makefile.am
==============================================================================
--- trunk/qt/Makefile.am        (original)
+++ trunk/qt/Makefile.am        Tue Mar  1 21:38:39 2005
@@ -1,4 +1,4 @@
-EXTRA_DIST = pref-keyeditformbase.ui  pref-keygrabformbase.ui  
pref-olisteditformbase.ui bushu.t
+EXTRA_DIST = pref-keyeditformbase.ui  pref-olisteditformbase.ui bushu.t
 
 if QT
 
@@ -45,10 +45,7 @@
        pref-olisteditformbase.moc \
        pref-keyeditformbase.cpp \
        pref-keyeditformbase.h \
-       pref-keyeditformbase.moc \
-       pref-keygrabformbase.cpp \
-       pref-keygrabformbase.h \
-       pref-keygrabformbase.moc
+       pref-keyeditformbase.moc
 
 noinst_HEADERS = $(HEADER_FILES)
 
@@ -124,8 +121,8 @@
 
 # Pref
 uim_pref_qt_SOURCES = \
-       pref-olisteditformbase.cpp pref-keyeditformbase.cpp 
pref-keygrabformbase.cpp \
-       pref-olisteditformbase.h   pref-keyeditformbase.h   
pref-keygrabformbase.h   \
+       pref-olisteditformbase.cpp pref-keyeditformbase.cpp \
+       pref-olisteditformbase.h   pref-keyeditformbase.h   \
        pref-qt.cpp pref-customwidgets.cpp pref-kseparator.cpp qtgettext.h 
pref-qt.h \
        pref-customwidgets.h pref-kseparator.h
 
@@ -133,8 +130,8 @@
 uim_pref_qt_LDFLAGS  = $(QT_LDFLAGS)
 uim_pref_qt_LDADD    = $(top_builddir)/uim/libuim-custom.la 
$(top_builddir)/uim/libuim.la
 
-pref-customwidgets.h:pref-olisteditformbase.h pref-keyeditformbase.h 
pref-keygrabformbase.h
-pref-qt.h:pref-olisteditformbase.h pref-keyeditformbase.h 
pref-keygrabformbase.h
+pref-customwidgets.h:pref-olisteditformbase.h pref-keyeditformbase.h
+pref-qt.h:pref-olisteditformbase.h pref-keyeditformbase.h
 
 pref-qt.cpp: pref-qt.moc
 pref-customwidgets.cpp: pref-customwidgets.moc
@@ -153,13 +150,6 @@
        mv pref-keyeditformbase.cpp.tmp pref-keyeditformbase.cpp
 pref-keyeditformbase.h:
        $(UIC) $(top_srcdir)/qt/pref-keyeditformbase.ui -o 
pref-keyeditformbase.h
-
-pref-keygrabformbase.cpp: pref-keygrabformbase.h pref-keygrabformbase.moc
-       $(UIC) $(top_srcdir)/qt/pref-keygrabformbase.ui -i 
pref-keygrabformbase.h > pref-keygrabformbase.cpp.tmp
-       echo '#include "pref-keygrabformbase.moc"' >> 
pref-keygrabformbase.cpp.tmp
-       mv pref-keygrabformbase.cpp.tmp pref-keygrabformbase.cpp
-pref-keygrabformbase.h:
-       $(UIC) $(top_srcdir)/qt/pref-keygrabformbase.ui -o 
pref-keygrabformbase.h
 
 uim_chardict_qt_SOURCES = \
        chardict-qt.cpp chardict-qt.h \

Modified: trunk/qt/pref-customwidgets.cpp
==============================================================================
--- trunk/qt/pref-customwidgets.cpp     (original)
+++ trunk/qt/pref-customwidgets.cpp     Tue Mar  1 21:38:39 2005
@@ -168,7 +168,7 @@
     QObject::connect( m_lineEdit, SIGNAL(textChanged(const QString &)),
                       this, SLOT(slotCustomTextChanged(const QString &)) );
 
-    m_fileButton = new QToolButton( this );
+    m_fileButton = new QPushButton( this );
     m_fileButton->setText( _("File") );
     QObject::connect( m_fileButton, SIGNAL(clicked()),
                       this, SLOT(slotPathnameButtonClicked()) );
@@ -306,7 +306,7 @@
     m_lineEdit = new QLineEdit( this );
     m_lineEdit->setReadOnly( true );
 
-    m_editButton = new QToolButton( this );
+    m_editButton = new QPushButton( this );
     m_editButton->setText( _("Edit") );
     QObject::connect( m_editButton, SIGNAL(clicked()),
                       this, SLOT(slotEditButtonClicked()) );
@@ -588,7 +588,7 @@
     m_lineEdit = new QLineEdit( this );
     m_lineEdit->setReadOnly( true );
 
-    m_editButton = new QToolButton( this );
+    m_editButton = new QPushButton( this );
     m_editButton->setText( _("Edit") );
     QObject::connect( m_editButton, SIGNAL(clicked()),
                       this, SLOT(slotKeyButtonClicked()) );
@@ -776,8 +776,8 @@
 
 void KeyEditForm::slotAddClicked()
 {
-    KeyGrabForm *d = new KeyGrabForm( this );
-    if( d->exec() == KeyGrabForm::Accepted )
+    KeyGrabDialog *d = new KeyGrabDialog( this );
+    if( d->exec() == KeyGrabDialog::Accepted )
     {
         QString keystr = d->getKeyStr();
         if( !keystr.isEmpty() )
@@ -802,8 +802,8 @@
     QListViewItem *selectedItem = m_listView->selectedItem();
     if( selectedItem )
     {
-        KeyGrabForm *d = new KeyGrabForm( this );
-        if( d->exec() == KeyGrabForm::Accepted )
+        KeyGrabDialog *d = new KeyGrabDialog( this );
+        if( d->exec() == KeyGrabDialog::Accepted )
         {
             QString keystr = d->getKeyStr();
             if( !keystr.isEmpty() )
@@ -829,210 +829,158 @@
     }
 }
 
-KeyGrabForm::KeyGrabForm( QWidget *parent, const char *name )
-    : KeyGrabFormBase( parent, name )
+KeyGrabDialog::KeyGrabDialog( QWidget *parent, const char *name )
+    : QDialog( parent, name ),
+      pressed_keyval( 0 ),
+      pressed_keystate( Qt::NoButton ),
+      m_keystr( 0 )
 {
-    m_shiftCheckBox->installEventFilter( this );
-    m_controlCheckBox->installEventFilter( this );
-    m_altCheckBox->installEventFilter( this );
-    m_keyLineEdit->installEventFilter( this );
-    m_okButton->installEventFilter( this );
-    m_cancelButton->installEventFilter( this );
+    QVBoxLayout *vboxLayout = new QVBoxLayout( this );
+    QLabel *l = new QLabel( _("Press keys to grab (e.g. <Control>a)"), this );
+    vboxLayout->addWidget( l );
 
-    m_keyLineEdit->setInputMethodEnabled( false );
+    setCaption( _("Key Grab Dialog") );
 }
 
-void KeyGrabForm::keyPressEvent( QKeyEvent *e )
+void KeyGrabDialog::keyPressEvent( QKeyEvent *e )
 {
-#if DEBUG_KEY_EDIT
-    qDebug( "key press!!! - %d:%d", e->key(), e->stateAfter() );
-#endif
+    pressed_keyval = e->key();
+    pressed_keystate = e->state();
+}
+
+void KeyGrabDialog::keyReleaseEvent( QKeyEvent *e )
+{
+    // create keystr
+    setKeyStr();
+
+    // end this dialog
+    accept();
+}
+
+void KeyGrabDialog::setKeyStr()
+{
+    QString keystr = QString::null;
+    int keyval = pressed_keyval;
+    ButtonState mod = pressed_keystate;
 
-    int qkey = e->key();
-    QString keystr = "";
     /*
      * Ignore Shift modifier for printable char keys for
      * easy-to-recognize key configuration.  uim-custom performs
      * implicit shift key encoding/decoding appropriately.
      */
-    if ( ((qkey >= 256 || !isgraph(qkey))) && (e->stateAfter() & 
Qt::ShiftButton) )
-    {
-        if( qkey != Qt::Key_Shift )
-            keystr.append( "<Shift>" );
-        m_shiftCheckBox->setChecked( true );
-    }
-    else
-    {
-        m_shiftCheckBox->setChecked( false );
-    }
+    if( ((keyval >= 256) || !isgraph(keyval)) &&
+        (mod & Qt::ShiftButton) )
+        keystr += "<Shift>";
+    if( mod & Qt::ControlButton )
+        keystr += "<Control>";
+    if( mod & Qt::AltButton )
+        keystr += "<Alt>";
 
-    if ( e->stateAfter() & Qt::ControlButton )
-    {
-        if( qkey != Qt::Key_Control )
-            keystr.append( "<Control>" );
-        m_controlCheckBox->setChecked( true );
-    }
-    else
-    {
-        m_controlCheckBox->setChecked( false );
-    }
-
-    if ( e->stateAfter() & Qt::AltButton )
-    {
-        if( qkey != Qt::Key_Alt )
-            keystr.append( "<Alt>" );
-        m_altCheckBox->setChecked( true );
-    }
-    else
-    {
-        m_altCheckBox->setChecked( false );
-    }
-
-    QString editString = "";
-    switch( qkey )
-    {
-        /* normal keys */
+    switch( keyval ) {
     case Qt::Key_Space:
-        /*
-         * "space" is not proper uim keysym and only exists for user
-         * convenience. It is converted to " " by uim-custom
-         */
-        editString.append( "space" );
+        keystr += "space";
         break;
     case Qt::Key_BackSpace:
-        editString.append( "backspace" );
+        keystr += "backspace";
         break;
     case Qt::Key_Delete:
-        editString.append( "delete" );
+        keystr += "delete";
         break;
     case Qt::Key_Insert:
-        editString.append( "insert" );
+        keystr += "insert";
         break;
     case Qt::Key_Escape:
-        editString.append( "escape" );
+        keystr += "escape";
         break;
     case Qt::Key_Tab:
-        editString.append( "tab" );
+        keystr += "tab";
         break;
     case Qt::Key_Return:
-        editString.append( "return" );
+        keystr += "return";
         break;
     case Qt::Key_Left:
-        editString.append( "left" );
+        keystr += "left";
         break;
     case Qt::Key_Up:
-        editString.append( "up" );
+        keystr += "up";
         break;
     case Qt::Key_Right:
-        editString.append( "right" );
+        keystr += "right";
         break;
     case Qt::Key_Down:
-        editString.append( "right" );
+        keystr += "down";
         break;
     case Qt::Key_Prior:
-        editString.append( "prior" );
+        keystr += "prior";
         break;
     case Qt::Key_Next:
-        editString.append( "next" );
+        keystr += "next";
         break;
     case Qt::Key_Home:
-        editString.append( "home" );
+        keystr += "home";
         break;
     case Qt::Key_End:
-        editString.append( "end" );
+        keystr += "end";
         break;
 #ifdef QT_IMMODULE
     case Qt::Key_Kanji:
     case Qt::Key_Zenkaku_Hankaku:
-        editString.append( "zenkaku-hankaku" );
+        keystr += "zenkaku-hankaku";
         break;
     case Qt::Key_Multi_key:
-        editString.append( "Multi_key" );
+        keystr += "Multi_key";
         break;
     case Qt::Key_Mode_switch:
-        editString.append( "Mode_switch" );
+        keystr += "Mode_switch";
         break;
     case Qt::Key_Henkan:
-        editString.append( "Henkan_Mode" );
+        keystr += "Henkan_Mode";
         break;
     case Qt::Key_Muhenkan:
-        editString.append( "Muhenkan" );
+        keystr += "Muhenkan";
         break;
 #endif /* Def: QT_IMMODULE */
     case Qt::Key_Shift:
-        m_shiftCheckBox->setChecked( true );
-        editString.append( "Shift_key" );
+        keystr += "Shift_key";
         break;
     case Qt::Key_Control:
-        m_controlCheckBox->setChecked( true );
-        editString.append( "Control_key" );
+        keystr += "Control_key";
         break;
     case Qt::Key_Alt:
-        m_altCheckBox->setChecked( true );
-        editString.append( "Alt_key" );
+        keystr += "Alt_key";
         break;
     case Qt::Key_Meta:
-        editString.append( "Meta_key" );
+        keystr += "Meta_key";
         break;
     case Qt::Key_Super_L:
     case Qt::Key_Super_R:
-        editString.append( "Super_key" );
+        keystr += "Super_key";
         break;
     case Qt::Key_Hyper_L:
     case Qt::Key_Hyper_R:
-        editString.append( "Hyper_key" );
+        keystr += "Hyper_key";
         break;
     default:
-        if( Qt::Key_F1 <= qkey && qkey <= Qt::Key_F35 ) {
-            int n = qkey - Qt::Key_F1 + 1;
-            editString.append( "F" );
-            editString.append( QString::number( n ) );
+        if( keyval >= Qt::Key_F1 && keyval <= Qt::Key_F35 )
+        {
+            keystr += "F" + QString::number( keyval - Qt::Key_F1 + 1 );
+            break;
         }
-        else if( isascii( qkey ) )
+        else if( keyval < 256 )
         {
-            QString ch = QChar( qkey );
-            if( e->stateAfter() & Qt::ShiftButton )
-            {
+            QChar ch = QChar( keyval );
+            
+            if( mod & Qt::ShiftButton ) 
                 ch = ch.upper();
-            }
             else
-            {
                 ch = ch.lower();
-            }
-            editString.append( ch );
-        }
-        else
-        {
-            /* unknown key */
-            qDebug( "unknown key" );
-            return;
+
+            keystr += ch;
         }
     }
 
-    if( qkey == Qt::Key_Shift || qkey == Qt::Key_Control || qkey == 
Qt::Key_Alt )
-        m_keyLineEdit->setText( "" );
-    else
-        m_keyLineEdit->setText( editString );
-
-
-    keystr.append( editString );
-#if DEBUG_KEY_EDIT
-    qDebug( "keystr = %s", (const char *)keystr.local8Bit() );
-#endif
-
     m_keystr = keystr;
+        
 }
-
-bool KeyGrabForm::eventFilter( QObject * watched, QEvent * e )
-{
-    if( e->type() == QEvent::KeyPress )
-    {
-        keyPressEvent( (QKeyEvent*)e );
-        return true;
-    }
-
-    return false;
-}
-
 
 #include "pref-customwidgets.moc"

Modified: trunk/qt/pref-customwidgets.h
==============================================================================
--- trunk/qt/pref-customwidgets.h       (original)
+++ trunk/qt/pref-customwidgets.h       Tue Mar  1 21:38:39 2005
@@ -58,7 +58,6 @@
 
 #include "pref-olisteditformbase.h"
 #include "pref-keyeditformbase.h"
-#include "pref-keygrabformbase.h"
 
 class UimCustomItemIface
 {
@@ -179,7 +178,7 @@
     void slotCustomTextChanged( const QString & text );
 private:
     QLineEdit *m_lineEdit;
-    QToolButton *m_fileButton;
+    QPushButton *m_fileButton;
 protected:
     void currentCustomValueChanged(){ emit customValueChanged(); }
 signals:
@@ -218,7 +217,7 @@
     void slotEditButtonClicked();
 private:
     QLineEdit *m_lineEdit;
-    QToolButton *m_editButton;
+    QPushButton *m_editButton;
 
     QPtrList<struct uim_custom_choice> m_validItemList;
     QPtrList<struct uim_custom_choice> m_itemList;
@@ -259,7 +258,7 @@
     void slotKeyButtonClicked();
 private:
     QLineEdit *m_lineEdit;
-    QToolButton *m_editButton;
+    QPushButton *m_editButton;
 protected:
     void currentCustomValueChanged(){ emit customValueChanged(); }
 signals:
@@ -281,20 +280,24 @@
     void slotSelectionChanged( QListViewItem * );
 };
 
-class KeyGrabForm : public KeyGrabFormBase {
+class KeyGrabDialog : public QDialog {
     Q_OBJECT
 
 public:
-    KeyGrabForm( QWidget *parent = 0, const char *name = 0 );
+    KeyGrabDialog( QWidget *parent = 0, const char *name = 0 );
 
     QString getKeyStr() const { return m_keystr; }
 
-protected:
     virtual void keyPressEvent( QKeyEvent *e );
-    virtual bool eventFilter( QObject * watched, QEvent * e );
+    virtual void keyReleaseEvent( QKeyEvent *e );
+
+protected:
+    void setKeyStr();
 
 protected:
-    QString m_keystr;
+    int pressed_keyval;
+    ButtonState pressed_keystate;
+    QString m_keystr; 
 };
 
 #endif /* Not def: _CUSTOMWIDGETS_H_ */

Modified: trunk/qt/pref-qt.cpp
==============================================================================
--- trunk/qt/pref-qt.cpp        (original)
+++ trunk/qt/pref-qt.cpp        Tue Mar  1 21:38:39 2005
@@ -596,61 +596,6 @@
     }
 }
 
-#if 0
-//-----------------------------------------------------------------------------------
-SubgroupData::SubgroupData( QWidget*parentWidget, const char 
*parent_group_name )
-{
-    char **sub_groups = uim_custom_group_subgroups( parent_group_name );
-    char **sgrp;
-    for( sgrp = sub_groups; *sgrp; sgrp++ )
-    {
-        struct uim_custom_group *sgroup_custom =  uim_custom_group_get( *sgrp 
);
-        /*
-         * 2004-01-31 Kazuki Ohta <[EMAIL PROTECTED]>
-         *
-         * The subgroup "main" doesn't contain any contents.
-         * So, we need to create default QVGroupBox for it.
-         */
-        QVGroupBox *gvbox;
-        if( QString::compare( *sgrp, "main" ) == 0 )
-        {
-            gvbox = NULL;
-        }
-        else
-        {
-            gvbox = new QVGroupBox( _FU8(sgroup_custom->label), parentWidget );
-            parentWidget->layout()->add( gvbox );
-        }
-
-        char **custom_syms = uim_custom_collect_by_group( *sgrp );
-        if( !custom_syms )
-            continue;
-
-        for( char **custom_sym = custom_syms; *custom_sym; custom_sym++ )
-        {
-            gvboxMap[QString(*custom_sym)] = gvbox;
-        }
-        uim_custom_symbol_list_free( custom_syms );
-
-
-        uim_custom_group_free( sgroup_custom );
-    }
-    uim_custom_symbol_list_free( sub_groups );
-}
-
-SubgroupData::~SubgroupData()
-{
-    gvboxMap.clear();    
-}
-
-QVGroupBox * SubgroupData::searchGroupVBoxByCustomSym( const char *custom_sym 
) const
-{
-    if (gvboxMap.find(custom_sym) == gvboxMap.end())
-        return NULL;
-    return gvboxMap[QString(custom_sym)];
-}
-#endif
-
 
//--------------------------------------------------------------------------------------
 int main( int argc, char **argv )
 {

Modified: trunk/qt/pref-qt.h
==============================================================================
--- trunk/qt/pref-qt.h  (original)
+++ trunk/qt/pref-qt.h  Tue Mar  1 21:38:39 2005
@@ -137,18 +137,4 @@
     QPtrList<UimCustomItemIface> m_customIfaceList;
 };
 
-#if 0
-class SubgroupData {
-public:
-    SubgroupData( QWidget *parentWidget, const char *parent_group_name );
-    ~SubgroupData();
-
-    QVGroupBox *searchGroupVBoxByCustomSym( const char *custom_sym ) const;
-
-protected:
-    QMap<QString, QVGroupBox*> gvboxMap;
-};
-#endif
-
-
 #endif /* Not def: _UIM_PREF_QT_H_ */

Reply via email to