Diffstat (limited to 'examples/inputmethod/exampleboardimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | examples/inputmethod/exampleboardimpl.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/examples/inputmethod/exampleboardimpl.cpp b/examples/inputmethod/exampleboardimpl.cpp index 36989a2..6c7196b 100644 --- a/examples/inputmethod/exampleboardimpl.cpp +++ b/examples/inputmethod/exampleboardimpl.cpp | |||
@@ -1,54 +1,55 @@ | |||
1 | #include <qwidget.h> | 1 | #include <qwidget.h> |
2 | #include <qcheckbox.h> | 2 | #include <qcheckbox.h> |
3 | #include <qlabel.h> | 3 | #include <qlabel.h> |
4 | #include <qsignalmapper.h> | 4 | #include <qsignalmapper.h> |
5 | #include <qpushbutton.h> | 5 | #include <qpushbutton.h> |
6 | #include <qpe/resource.h> | 6 | |
7 | #include <opie2/oresource.h> | ||
7 | 8 | ||
8 | #include "exampleboardimpl.h" | 9 | #include "exampleboardimpl.h" |
9 | 10 | ||
10 | ExampleBoard::ExampleBoard(QWidget* par, WFlags fl ) | 11 | ExampleBoard::ExampleBoard(QWidget* par, WFlags fl ) |
11 | : QHBox(par, "name", fl ) | 12 | : QHBox(par, "name", fl ) |
12 | { | 13 | { |
13 | QCheckBox *box1 = new QCheckBox(tr("Alt"),this); | 14 | QCheckBox *box1 = new QCheckBox(tr("Alt"),this); |
14 | connect(box1,SIGNAL(toggled(bool)), | 15 | connect(box1,SIGNAL(toggled(bool)), |
15 | this,SLOT(slotAlt(bool))); | 16 | this,SLOT(slotAlt(bool))); |
16 | m_alt = box1; | 17 | m_alt = box1; |
17 | box1 = new QCheckBox(tr("Shift"),this ); | 18 | box1 = new QCheckBox(tr("Shift"),this ); |
18 | connect(box1,SIGNAL(toggled(bool)), | 19 | connect(box1,SIGNAL(toggled(bool)), |
19 | this,SLOT(slotShift(bool))); | 20 | this,SLOT(slotShift(bool))); |
20 | m_shi = box1; | 21 | m_shi = box1; |
21 | box1 = new QCheckBox(tr("Ctrl","Control Shortcut on keyboard"),this ); | 22 | box1 = new QCheckBox(tr("Ctrl","Control Shortcut on keyboard"),this ); |
22 | connect(box1,SIGNAL(toggled(bool)), | 23 | connect(box1,SIGNAL(toggled(bool)), |
23 | this,SLOT(slotCtrl(bool))); | 24 | this,SLOT(slotCtrl(bool))); |
24 | m_ctrl = box1; | 25 | m_ctrl = box1; |
25 | 26 | ||
26 | QSignalMapper *map = new QSignalMapper(this); | 27 | QSignalMapper *map = new QSignalMapper(this); |
27 | QPushButton *btn = new QPushButton("a",this); | 28 | QPushButton *btn = new QPushButton("a",this); |
28 | map->setMapping(btn,0); | 29 | map->setMapping(btn,0); |
29 | connect(btn,SIGNAL(clicked()),map,SLOT(map())); | 30 | connect(btn,SIGNAL(clicked()),map,SLOT(map())); |
30 | 31 | ||
31 | btn = new QPushButton("b",this); | 32 | btn = new QPushButton("b",this); |
32 | map->setMapping(btn,1); | 33 | map->setMapping(btn,1); |
33 | connect(btn,SIGNAL(clicked()),map,SLOT(map())); | 34 | connect(btn,SIGNAL(clicked()),map,SLOT(map())); |
34 | 35 | ||
35 | btn = new QPushButton("c",this); | 36 | btn = new QPushButton("c",this); |
36 | map->setMapping(btn,2); | 37 | map->setMapping(btn,2); |
37 | connect(btn,SIGNAL(clicked()),map,SLOT(map())); | 38 | connect(btn,SIGNAL(clicked()),map,SLOT(map())); |
38 | 39 | ||
39 | connect(map,SIGNAL(mapped(int)), | 40 | connect(map,SIGNAL(mapped(int)), |
40 | this,SLOT(slotKey(int))); | 41 | this,SLOT(slotKey(int))); |
41 | resetState(); | 42 | resetState(); |
42 | } | 43 | } |
43 | 44 | ||
44 | ExampleBoard::~ExampleBoard(){ | 45 | ExampleBoard::~ExampleBoard(){ |
45 | } | 46 | } |
46 | 47 | ||
47 | void ExampleBoard::resetState(){ | 48 | void ExampleBoard::resetState(){ |
48 | m_state = 0; | 49 | m_state = 0; |
49 | m_shi->setChecked(false); | 50 | m_shi->setChecked(false); |
50 | m_ctrl->setChecked(false); | 51 | m_ctrl->setChecked(false); |
51 | m_alt->setChecked(false); | 52 | m_alt->setChecked(false); |
52 | } | 53 | } |
53 | 54 | ||
54 | void ExampleBoard::slotKey(int _ke){ | 55 | void ExampleBoard::slotKey(int _ke){ |
@@ -73,85 +74,85 @@ void ExampleBoard::slotShift(bool b){ | |||
73 | m_state |= ShiftButton; | 74 | m_state |= ShiftButton; |
74 | else | 75 | else |
75 | m_state &= ~ShiftButton; | 76 | m_state &= ~ShiftButton; |
76 | } | 77 | } |
77 | 78 | ||
78 | void ExampleBoard::slotAlt(bool b){ | 79 | void ExampleBoard::slotAlt(bool b){ |
79 | if(b) | 80 | if(b) |
80 | m_state |= AltButton; | 81 | m_state |= AltButton; |
81 | else | 82 | else |
82 | m_state &= ~AltButton; | 83 | m_state &= ~AltButton; |
83 | } | 84 | } |
84 | 85 | ||
85 | void ExampleBoard::slotCtrl(bool b){ | 86 | void ExampleBoard::slotCtrl(bool b){ |
86 | if(b) | 87 | if(b) |
87 | m_state |= ControlButton; | 88 | m_state |= ControlButton; |
88 | else | 89 | else |
89 | m_state &= ~ControlButton; | 90 | m_state &= ~ControlButton; |
90 | } | 91 | } |
91 | 92 | ||
92 | 93 | ||
93 | 94 | ||
94 | ExampleboardImpl::ExampleboardImpl() | 95 | ExampleboardImpl::ExampleboardImpl() |
95 | : m_pickboard(0), m_icn(0) | 96 | : m_pickboard(0), m_icn(0) |
96 | { | 97 | { |
97 | } | 98 | } |
98 | 99 | ||
99 | ExampleboardImpl::~ExampleboardImpl() | 100 | ExampleboardImpl::~ExampleboardImpl() |
100 | { | 101 | { |
101 | delete m_pickboard; | 102 | delete m_pickboard; |
102 | delete m_icn; | 103 | delete m_icn; |
103 | } | 104 | } |
104 | 105 | ||
105 | QWidget *ExampleboardImpl::inputMethod( QWidget *parent, Qt::WFlags f ) | 106 | QWidget *ExampleboardImpl::inputMethod( QWidget *parent, Qt::WFlags f ) |
106 | { | 107 | { |
107 | if ( !m_pickboard ) | 108 | if ( !m_pickboard ) |
108 | m_pickboard = new ExampleBoard( parent, f ); | 109 | m_pickboard = new ExampleBoard( parent, f ); |
109 | return m_pickboard; | 110 | return m_pickboard; |
110 | } | 111 | } |
111 | 112 | ||
112 | void ExampleboardImpl::resetState() | 113 | void ExampleboardImpl::resetState() |
113 | { | 114 | { |
114 | if ( m_pickboard ) | 115 | if ( m_pickboard ) |
115 | m_pickboard->resetState(); | 116 | m_pickboard->resetState(); |
116 | } | 117 | } |
117 | 118 | ||
118 | QPixmap *ExampleboardImpl::icon() | 119 | QPixmap *ExampleboardImpl::icon() |
119 | { | 120 | { |
120 | if ( !m_icn ) | 121 | if ( !m_icn ) |
121 | m_icn = new QPixmap(Resource::loadPixmap("Tux")); | 122 | m_icn = new QPixmap(Opie::Core::OResource::loadPixmap("Tux", Opie::Core::OResource::SmallIcon)); |
122 | return m_icn; | 123 | return m_icn; |
123 | } | 124 | } |
124 | 125 | ||
125 | QString ExampleboardImpl::name() | 126 | QString ExampleboardImpl::name() |
126 | { | 127 | { |
127 | return QObject::tr("Example Input"); | 128 | return QObject::tr("Example Input"); |
128 | } | 129 | } |
129 | 130 | ||
130 | void ExampleboardImpl::onKeyPress( QObject *receiver, const char *slot ) | 131 | void ExampleboardImpl::onKeyPress( QObject *receiver, const char *slot ) |
131 | { | 132 | { |
132 | if ( m_pickboard ) | 133 | if ( m_pickboard ) |
133 | QObject::connect( m_pickboard, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot ); | 134 | QObject::connect( m_pickboard, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot ); |
134 | } | 135 | } |
135 | 136 | ||
136 | #ifndef QT_NO_COMPONENT | 137 | #ifndef QT_NO_COMPONENT |
137 | QRESULT ExampleboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | 138 | QRESULT ExampleboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) |
138 | { | 139 | { |
139 | *iface = 0; | 140 | *iface = 0; |
140 | if ( uuid == IID_QUnknown ) | 141 | if ( uuid == IID_QUnknown ) |
141 | *iface = this; | 142 | *iface = this; |
142 | else if ( uuid == IID_InputMethod ) | 143 | else if ( uuid == IID_InputMethod ) |
143 | *iface = this; | 144 | *iface = this; |
144 | else | 145 | else |
145 | return QS_FALSE; | 146 | return QS_FALSE; |
146 | 147 | ||
147 | if ( *iface ) | 148 | if ( *iface ) |
148 | (*iface)->addRef(); | 149 | (*iface)->addRef(); |
149 | return QS_OK; | 150 | return QS_OK; |
150 | } | 151 | } |
151 | 152 | ||
152 | Q_EXPORT_INTERFACE() | 153 | Q_EXPORT_INTERFACE() |
153 | { | 154 | { |
154 | Q_CREATE_INSTANCE( ExampleboardImpl ) | 155 | Q_CREATE_INSTANCE( ExampleboardImpl ) |
155 | } | 156 | } |
156 | #endif | 157 | #endif |
157 | 158 | ||