3
Copyright (c) 2003-2009 uim Project http://code.google.com/p/uim/
7
Redistribution and use in source and binary forms, with or without
8
modification, are permitted provided that the following conditions
11
1. Redistributions of source code must retain the above copyright
12
notice, this list of conditions and the following disclaimer.
13
2. Redistributions in binary form must reproduce the above copyright
14
notice, this list of conditions and the following disclaimer in the
15
documentation and/or other materials provided with the distribution.
16
3. Neither the name of authors nor the names of its contributors
17
may be used to endorse or promote products derived from this software
18
without specific prior written permission.
20
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
21
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
24
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33
#ifndef UIM_QT4_PREF_CUSTOMWIDGETS_H
34
#define UIM_QT4_PREF_CUSTOMWIDGETS_H
37
#include <uim/uim-custom.h>
39
#include <QtCore/QList>
40
#include <QtGui/QCheckBox>
41
#include <QtGui/QComboBox>
42
#include <QtGui/QFrame>
43
#include <QtGui/QKeyEvent>
44
#include <QtGui/QLineEdit>
45
#include <QtGui/QSpinBox>
47
#include "ui_olisteditformbase.h"
48
#include "ui_keyeditformbase.h"
54
class UimCustomItemIface
57
explicit UimCustomItemIface( struct uim_custom *c = 0 )
62
uim_custom_cb_add( m_custom->symbol, this, UimCustomItemIface::update_cb );
64
virtual ~UimCustomItemIface()
66
if( m_custom ) uim_custom_free( m_custom );
69
/* Custom Update Callback */
70
static void update_cb( void *ptr, const char *custom_sym )
72
UimCustomItemIface *iface = (UimCustomItemIface*)ptr;
73
iface->updateItem( custom_sym );
76
virtual void update() = 0;
79
virtual void setDefault() = 0;
82
void setCustom( struct uim_custom *custom )
84
uim_bool rv = uim_custom_set( custom );
86
currentCustomValueChanged();
88
qFatal( "Failed to set value for \"%s\".", custom->symbol );
90
void updateItem( const char *custom_sym )
92
// remove current custom
93
if( m_custom ) uim_custom_free( m_custom );
95
m_custom = uim_custom_get( custom_sym );
98
virtual void currentCustomValueChanged() = 0;
101
struct uim_custom *m_custom;
104
//----------------------------------------------------------------------------------------
105
class CustomCheckBox : public QCheckBox, public UimCustomItemIface
110
explicit CustomCheckBox( struct uim_custom *c, QWidget *parent = 0 );
112
virtual void update();
113
virtual void setDefault();
115
void slotCustomToggled( bool check );
117
void currentCustomValueChanged(){ emit customValueChanged(); }
119
void customValueChanged();
122
//----------------------------------------------------------------------------------------
123
class CustomSpinBox : public QSpinBox, public UimCustomItemIface
128
CustomSpinBox( struct uim_custom *c, QWidget *parent );
130
virtual void update();
131
virtual void setDefault();
133
void slotCustomValueChanged( int value );
135
void currentCustomValueChanged(){ emit customValueChanged(); }
137
void customValueChanged();
140
//----------------------------------------------------------------------------------------
141
class CustomLineEdit : public QLineEdit, public UimCustomItemIface
146
CustomLineEdit( struct uim_custom *c, QWidget *parent );
148
virtual void update();
149
virtual void setDefault();
151
void slotCustomTextChanged( const QString &text );
153
void currentCustomValueChanged(){ emit customValueChanged(); }
155
void customValueChanged();
158
//----------------------------------------------------------------------------------------
159
class CustomPathnameEdit : public QFrame, public UimCustomItemIface
164
CustomPathnameEdit( struct uim_custom *c, QWidget *parent );
166
virtual void update();
167
virtual void setDefault();
169
void slotPathnameButtonClicked();
170
void slotCustomTextChanged( const QString & text );
172
QLineEdit *m_lineEdit;
173
QPushButton *m_fileButton;
174
QFileDialog *m_fileDialog;
176
void currentCustomValueChanged(){ emit customValueChanged(); }
178
void customValueChanged();
181
//----------------------------------------------------------------------------------------
182
class CustomChoiceCombo : public QComboBox, public UimCustomItemIface
187
CustomChoiceCombo( struct uim_custom *c, QWidget *parent );
189
virtual void update();
190
virtual void setDefault();
192
void slotActivated( int index );
194
void currentCustomValueChanged(){ emit customValueChanged(); }
196
void customValueChanged();
199
//----------------------------------------------------------------------------------------
200
class CustomOrderedListEdit : public QFrame, public UimCustomItemIface
205
CustomOrderedListEdit( struct uim_custom *c, QWidget *parent );
207
virtual void update();
208
virtual void setDefault();
210
void slotEditButtonClicked();
212
QLineEdit *m_lineEdit;
213
QPushButton *m_editButton;
215
QList<struct uim_custom_choice *> m_validItemList;
216
QList<struct uim_custom_choice *> m_itemList;
220
void currentCustomValueChanged(){ emit customValueChanged(); }
222
void customValueChanged();
225
class OListEditForm : public QDialog, public Ui_OListEditFormBase {
229
explicit OListEditForm( QWidget *parent = 0 );
230
virtual ~OListEditForm();
232
void addCheckItem( bool isActive, const QString &str );
233
QStringList activeItemLabels() const;
239
//----------------------------------------------------------------------------------------
240
class CustomKeyEdit : public QFrame, public UimCustomItemIface
245
CustomKeyEdit( struct uim_custom *c, QWidget *parent );
247
virtual void update();
248
virtual void setDefault();
252
void slotKeyButtonClicked();
254
QLineEdit *m_lineEdit;
255
QPushButton *m_editButton;
257
void currentCustomValueChanged(){ emit customValueChanged(); }
259
void customValueChanged();
262
class KeyEditForm : public QDialog, public Ui_KeyEditFormBase {
266
explicit KeyEditForm( QWidget *parent = 0 );
267
virtual ~KeyEditForm();
269
void addKeyItem( const QString &str );
270
const QStringList getKeyStrList();
272
void slotAddClicked();
273
void slotRemoveClicked();
274
void slotEditClicked();
275
void slotItemSelectionChanged();
278
class KeyGrabDialog : public QDialog {
282
explicit KeyGrabDialog( QWidget *parent = 0 );
284
QString getKeyStr() const { return m_keystr; }
286
virtual void keyPressEvent( QKeyEvent *e );
287
virtual void keyReleaseEvent( QKeyEvent *e );
294
Qt::KeyboardModifiers pressed_keystate;
295
QChar pressed_unichar;
299
#endif /* Not def: UIM_QT4_PREF_CUSTOMWIDGETS_H */