summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/function_keyboard.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-console/function_keyboard.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/function_keyboard.cpp9
1 files changed, 2 insertions, 7 deletions
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp
index 71cdea8..9d58383 100644
--- a/noncore/apps/opie-console/function_keyboard.cpp
+++ b/noncore/apps/opie-console/function_keyboard.cpp
@@ -103,202 +103,197 @@ void FunctionKeyboard::paintEvent(QPaintEvent *e) {
103 } 103 }
104 } 104 }
105 } 105 }
106} 106}
107 107
108void FunctionKeyboard::paintKey(uint row, uint col) { 108void FunctionKeyboard::paintKey(uint row, uint col) {
109 109
110 QPainter p(this); 110 QPainter p(this);
111 111
112 p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1), 112 p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1),
113 QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)), 113 QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)),
114 (pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255)); 114 (pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255));
115 p.drawText( 115 p.drawText(
116 col * keyWidth + 1, row * keyHeight + 1, 116 col * keyWidth + 1, row * keyHeight + 1,
117 keyWidth, keyHeight, 117 keyWidth, keyHeight,
118 Qt::AlignHCenter | Qt::AlignVCenter, 118 Qt::AlignHCenter | Qt::AlignVCenter,
119 keys["r" + QString::number(row) + "c" + QString::number(col)].label 119 keys["r" + QString::number(row) + "c" + QString::number(col)].label
120 ); 120 );
121 121
122 if (row == numRows) { 122 if (row == numRows) {
123 123
124 // sometimes it doesnt draw the last line 124 // sometimes it doesnt draw the last line
125 p.drawLine((col+1) * keyWidth -2, row * keyHeight, 125 p.drawLine((col+1) * keyWidth -2, row * keyHeight,
126 (col+1) * keyWidth -2, (row + 1) * keyHeight 126 (col+1) * keyWidth -2, (row + 1) * keyHeight
127 ); 127 );
128 } 128 }
129 129
130} 130}
131 131
132void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { 132void FunctionKeyboard::mousePressEvent(QMouseEvent *e) {
133 133
134 pressedRow = e->y() / keyHeight; 134 pressedRow = e->y() / keyHeight;
135 pressedCol = (int) (e->x() / keyWidth); 135 pressedCol = (int) (e->x() / keyWidth);
136 136
137 paintKey(pressedRow, pressedCol); 137 paintKey(pressedRow, pressedCol);
138 138
139 // emit that sucker! 139 // emit that sucker!
140 FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; 140 FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)];
141 emit keyPressed(k, pressedRow, pressedCol, 1); 141 emit keyPressed(k, pressedRow, pressedCol, 1);
142 142
143} 143}
144 144
145void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { 145void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) {
146 146
147 if (pressedRow != -1 && pressedRow != -1) { 147 if (pressedRow != -1 && pressedRow != -1) {
148 148
149 int row = pressedRow; pressedRow = -1; 149 int row = pressedRow; pressedRow = -1;
150 int col = pressedCol; pressedCol = -1; 150 int col = pressedCol; pressedCol = -1;
151 paintKey(row, col); 151 paintKey(row, col);
152 152
153 FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; 153 FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)];
154 emit keyPressed(k, row, col, 0); 154 emit keyPressed(k, row, col, 0);
155 } 155 }
156 156
157} 157}
158 158
159 159
160void FunctionKeyboard::resizeEvent(QResizeEvent*) { 160void FunctionKeyboard::resizeEvent(QResizeEvent*) {
161 161
162 /* set he default font height/width */ 162 /* set he default font height/width */
163 QFontMetrics fm=fontMetrics(); 163 QFontMetrics fm=fontMetrics();
164 keyHeight = fm.lineSpacing() + 2; 164 keyHeight = fm.lineSpacing() + 2;
165 keyWidth = (double)width()/numCols; 165 keyWidth = (double)width()/numCols;
166 166
167} 167}
168 168
169QSize FunctionKeyboard::sizeHint() const { 169QSize FunctionKeyboard::sizeHint() const {
170 170
171 return QSize(width(), keyHeight * numRows + 1); 171 return QSize(width(), keyHeight * numRows + 1);
172} 172}
173 173
174void FunctionKeyboard::loadDefaults() { 174void FunctionKeyboard::loadDefaults() {
175 175
176 /* what keys should be default? 176 /* what keys should be default?
177 keys.insert( "r0c0", FKey ("F1", 0, 4144, 0)); 177 keys.insert( "r0c0", FKey ("F1", 0, 4144, 0));
178 keys.insert( "r0c1", FKey ("F2", 0, 4145, 0)); 178 keys.insert( "r0c1", FKey ("F2", 0, 4145, 0));
179 keys.insert( "r0c2", FKey ("F3", 0, 4146, 0)); 179 keys.insert( "r0c2", FKey ("F3", 0, 4146, 0));
180 keys.insert( "r0c3", FKey ("F4", 0, 4147, 0)); 180 keys.insert( "r0c3", FKey ("F4", 0, 4147, 0));
181 keys.insert( "r0c4", FKey ("F5", 0, 4148, 0)); 181 keys.insert( "r0c4", FKey ("F5", 0, 4148, 0));
182 keys.insert( "r0c5", FKey ("F6", 0, 4149, 0)); 182 keys.insert( "r0c5", FKey ("F6", 0, 4149, 0));
183 keys.insert( "r0c6", FKey ("F7", 0, 4150, 0)); 183 keys.insert( "r0c6", FKey ("F7", 0, 4150, 0));
184 keys.insert( "r0c7", FKey ("F8", 0, 4151, 0)); 184 keys.insert( "r0c7", FKey ("F8", 0, 4151, 0));
185 keys.insert( "r0c8", FKey ("F9", 0, 4152, 0)); 185 keys.insert( "r0c8", FKey ("F9", 0, 4152, 0));
186 keys.insert( "r0c9", FKey ("F10", 0, 4153, 0)); 186 keys.insert( "r0c9", FKey ("F10", 0, 4153, 0));
187 keys.insert( "r0c10", FKey ("F11", 0, 4154, 0)); 187 keys.insert( "r0c10", FKey ("F11", 0, 4154, 0));
188 188
189 keys.insert( "r1c7", FKey ("Ho", 0, 4112, 0)); 189 keys.insert( "r1c7", FKey ("Ho", 0, 4112, 0));
190 keys.insert( "r1c8", FKey ("End", 0, 4113, 0)); 190 keys.insert( "r1c8", FKey ("End", 0, 4113, 0));
191 keys.insert( "r1c9", FKey ("PU", 0, 4118, 0)); 191 keys.insert( "r1c9", FKey ("PU", 0, 4118, 0));
192 keys.insert( "r1c10", FKey ("PD", 0, 4119, 0)); 192 keys.insert( "r1c10", FKey ("PD", 0, 4119, 0));
193 */ 193 */
194 194
195} 195}
196 196
197/* FunctionKeyboardConfig {{{1 */ 197/* FunctionKeyboardConfig {{{1 */
198 198
199<<<<<<< function_keyboard.cpp 199FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na )
200FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent) : 200 : ProfileDialogKeyWidget(name, parent, na),
201 ProfileDialogKeyWidget(name, parent),
202 selectedRow(0), selectedCol(0) 201 selectedRow(0), selectedCol(0)
203{ 202{
204=======
205FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na )
206 : ProfileDialogKeyWidget(name, parent, na) {
207 qWarning("FunctionKeyboardConfig"); 203 qWarning("FunctionKeyboardConfig");
208>>>>>>> 1.11
209 204
210 205
211 kb = new FunctionKeyboard(this); 206 kb = new FunctionKeyboard(this);
212 connect (kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), 207 connect (kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)),
213 this, SLOT(slotKeyPressed(FKey, ushort, ushort, bool))); 208 this, SLOT(slotKeyPressed(FKey, ushort, ushort, bool)));
214 209
215 QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimentions"), this); 210 QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimentions"), this);
216 QLabel *l = new QLabel("Rows", dimentions); 211 QLabel *l = new QLabel("Rows", dimentions);
217 m_rowBox = new QSpinBox(1, 15, 1, dimentions); 212 m_rowBox = new QSpinBox(1, 15, 1, dimentions);
218 connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int))); 213 connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int)));
219 l = new QLabel("Columns", dimentions); 214 l = new QLabel("Columns", dimentions);
220 m_colBox = new QSpinBox(1, 15, 1, dimentions); 215 m_colBox = new QSpinBox(1, 15, 1, dimentions);
221 connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int))); 216 connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int)));
222 217
223 QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this); 218 QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this);
224 l = new QLabel("Label", editKey); 219 l = new QLabel("Label", editKey);
225 m_labels = new QComboBox(true, editKey); 220 m_labels = new QComboBox(true, editKey);
226 m_labels->setInsertionPolicy(QComboBox::AtCurrent); 221 m_labels->setInsertionPolicy(QComboBox::AtCurrent);
227 m_labels->insertItem("custom"); 222 m_labels->insertItem("custom");
228 223
229 QStringList files = QDir(QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList(); 224 QStringList files = QDir(QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList();
230 225
231 for (uint i = 0; i < files.count(); i++) { 226 for (uint i = 0; i < files.count(); i++) {
232 227
233 m_labels->insertItem(Resource::loadPixmap("console/keys/" + files[i])); 228 m_labels->insertItem(Resource::loadPixmap("console/keys/" + files[i]));
234 } 229 }
235 connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int))); 230 connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int)));
236 connect (m_labels, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeLabelText(const QString&))); 231 connect (m_labels, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeLabelText(const QString&)));
237 232
238 l = new QLabel("KeyValue", editKey); 233 l = new QLabel("KeyValue", editKey);
239 m_qvalues = new QComboBox(false, editKey); 234 m_qvalues = new QComboBox(false, editKey);
240 m_qvalues->setInsertionPolicy(QComboBox::AtCurrent); 235 m_qvalues->setInsertionPolicy(QComboBox::AtCurrent);
241 m_qvalues->insertItem("custom"); 236 m_qvalues->insertItem("custom");
242 237
243 QVBoxLayout *root = new QVBoxLayout(this, 2); 238 QVBoxLayout *root = new QVBoxLayout(this, 2);
244 root->addWidget(kb); 239 root->addWidget(kb);
245 root->addWidget(dimentions); 240 root->addWidget(dimentions);
246 root->addWidget(editKey); 241 root->addWidget(editKey);
247} 242}
248FunctionKeyboardConfig::~FunctionKeyboardConfig() { 243FunctionKeyboardConfig::~FunctionKeyboardConfig() {
249 244
250} 245}
251void FunctionKeyboardConfig::load (const Profile& prof) { 246void FunctionKeyboardConfig::load (const Profile& prof) {
252 247
253 m_rowBox->setValue(prof.readNumEntry("keb_rows", 2)); 248 m_rowBox->setValue(prof.readNumEntry("keb_rows", 2));
254 m_colBox->setValue(prof.readNumEntry("keb_cols", 10)); 249 m_colBox->setValue(prof.readNumEntry("keb_cols", 10));
255 250
256 /* load all the keys to the keyboard */ 251 /* load all the keys to the keyboard */
257 for (int i = 0; i <= m_rowBox->value() -1; i++) 252 for (int i = 0; i <= m_rowBox->value() -1; i++)
258 for (int j = 0; j <= m_colBox->value() -1; j++) { 253 for (int j = 0; j <= m_colBox->value() -1; j++) {
259 254
260 QString h = "r" + QString::number(i) + "c" + QString::number(j); 255 QString h = "r" + QString::number(i) + "c" + QString::number(j);
261 QString values = prof.readEntry("keb_" + h); 256 QString values = prof.readEntry("keb_" + h);
262 257
263 if (!values.isEmpty()) { 258 if (!values.isEmpty()) {
264 259
265 QStringList l = QStringList::split(QChar('|'), values, TRUE); 260 QStringList l = QStringList::split(QChar('|'), values, TRUE);
266 kb->keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt()); 261 kb->keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt());
267 //qWarning("loading key... %s %s %s %d %d", values.ascii(), l[0].ascii(), l[1].ascii(), l[2].toInt(), l[3].toInt()); 262 //qWarning("loading key... %s %s %s %d %d", values.ascii(), l[0].ascii(), l[1].ascii(), l[2].toInt(), l[3].toInt());
268 } 263 }
269 } 264 }
270 265
271} 266}
272void FunctionKeyboardConfig::save (Profile& prof) { 267void FunctionKeyboardConfig::save (Profile& prof) {
273 268
274 prof.writeEntry("keb_rows", m_rowBox->value()); 269 prof.writeEntry("keb_rows", m_rowBox->value());
275 prof.writeEntry("keb_cols", m_colBox->value()); 270 prof.writeEntry("keb_cols", m_colBox->value());
276 271
277 QMap<QString, FKey>::Iterator it; 272 QMap<QString, FKey>::Iterator it;
278 for ( it = kb->keys.begin(); it != kb->keys.end(); it++) { 273 for ( it = kb->keys.begin(); it != kb->keys.end(); it++) {
279 274
280 FKey k = it.data(); 275 FKey k = it.data();
281 QString entry = k.label + "|" 276 QString entry = k.label + "|"
282 + k.pixFile + "|" 277 + k.pixFile + "|"
283 + QString::number(k.qcode) + "|" 278 + QString::number(k.qcode) + "|"
284 + QString::number(k.unicode); 279 + QString::number(k.unicode);
285 280
286 prof.writeEntry("keb_" + it.key(), entry); 281 prof.writeEntry("keb_" + it.key(), entry);
287 282
288 } 283 }
289 284
290} 285}
291void FunctionKeyboardConfig::slotChangeRows(int r) { 286void FunctionKeyboardConfig::slotChangeRows(int r) {
292 287
293 kb->changeRows(r); 288 kb->changeRows(r);
294 289
295 // have to do this so the whole thing gets redrawn 290 // have to do this so the whole thing gets redrawn
296 kb->hide(); kb->show(); 291 kb->hide(); kb->show();
297} 292}
298void FunctionKeyboardConfig::slotChangeCols(int c) { 293void FunctionKeyboardConfig::slotChangeCols(int c) {
299 294
300 kb->changeCols(c); 295 kb->changeCols(c);
301} 296}
302void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pressed) { 297void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pressed) {
303 298
304 if (!pressed) return; 299 if (!pressed) return;