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.cpp139
1 files changed, 107 insertions, 32 deletions
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp
index b2f1c78..71cdea8 100644
--- a/noncore/apps/opie-console/function_keyboard.cpp
+++ b/noncore/apps/opie-console/function_keyboard.cpp
@@ -35,3 +35,3 @@ FunctionKeyboard::FunctionKeyboard(QWidget *parent) :
35 handle, 35 handle,
36 FKey (value_list[0], value_list[1].toUShort(), value_list[2].toUShort()) 36 FKey (value_list[0], value_list[1], value_list[2].toUShort(), value_list[3].toUShort())
37 ); 37 );
@@ -61,2 +61,9 @@ void FunctionKeyboard::changeCols(int c) {
61 61
62/*
63Key getKey(int row, int col) {
64
65 return keys[ "r" + QString::number(row) + "c" + QString::number(col) ];
66}
67*/
68
62void FunctionKeyboard::paintEvent(QPaintEvent *e) { 69void FunctionKeyboard::paintEvent(QPaintEvent *e) {
@@ -93,3 +100,3 @@ void FunctionKeyboard::paintEvent(QPaintEvent *e) {
93 Qt::AlignHCenter | Qt::AlignVCenter, 100 Qt::AlignHCenter | Qt::AlignVCenter,
94 keys[handle].getL() 101 keys[handle].label
95 ); 102 );
@@ -100,3 +107,3 @@ void FunctionKeyboard::paintEvent(QPaintEvent *e) {
100 107
101void FunctionKeyboard::paintKey(int row, int col) { 108void FunctionKeyboard::paintKey(uint row, uint col) {
102 109
@@ -111,3 +118,3 @@ void FunctionKeyboard::paintKey(int row, int col) {
111 Qt::AlignHCenter | Qt::AlignVCenter, 118 Qt::AlignHCenter | Qt::AlignVCenter,
112 keys["r" + QString::number(row) + "c" + QString::number(col)].getL() 119 keys["r" + QString::number(row) + "c" + QString::number(col)].label
113 ); 120 );
@@ -133,3 +140,3 @@ void FunctionKeyboard::mousePressEvent(QMouseEvent *e) {
133 FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; 140 FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)];
134 emit keyPressed(k.getU(), k.getQ(), 0, 1, 0, pressedRow, pressedCol); 141 emit keyPressed(k, pressedRow, pressedCol, 1);
135 142
@@ -146,3 +153,3 @@ void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) {
146 FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; 153 FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)];
147 emit keyPressed(k.getU(), k.getQ(), 0, 0, 0, pressedRow, pressedCol); 154 emit keyPressed(k, row, col, 0);
148 } 155 }
@@ -168,19 +175,20 @@ void FunctionKeyboard::loadDefaults() {
168 175
169 /* what keys should be default? */ 176 /* what keys should be default?
170 keys.insert( "r0c0", FKey ("F1", 4144, 0)); 177 keys.insert( "r0c0", FKey ("F1", 0, 4144, 0));
171 keys.insert( "r0c1", FKey ("F2", 4145, 0)); 178 keys.insert( "r0c1", FKey ("F2", 0, 4145, 0));
172 keys.insert( "r0c2", FKey ("F3", 4145, 0)); 179 keys.insert( "r0c2", FKey ("F3", 0, 4146, 0));
173 keys.insert( "r0c3", FKey ("F4", 4146, 0)); 180 keys.insert( "r0c3", FKey ("F4", 0, 4147, 0));
174 keys.insert( "r0c4", FKey ("F5", 4147, 0)); 181 keys.insert( "r0c4", FKey ("F5", 0, 4148, 0));
175 keys.insert( "r0c5", FKey ("F6", 4148, 0)); 182 keys.insert( "r0c5", FKey ("F6", 0, 4149, 0));
176 keys.insert( "r0c6", FKey ("F7", 4149, 0)); 183 keys.insert( "r0c6", FKey ("F7", 0, 4150, 0));
177 keys.insert( "r0c7", FKey ("F8", 4150, 0)); 184 keys.insert( "r0c7", FKey ("F8", 0, 4151, 0));
178 keys.insert( "r0c8", FKey ("F9", 4151, 0)); 185 keys.insert( "r0c8", FKey ("F9", 0, 4152, 0));
179 keys.insert( "r0c9", FKey ("F10", 4152, 0)); 186 keys.insert( "r0c9", FKey ("F10", 0, 4153, 0));
180 keys.insert( "r0c10", FKey ("F11", 4153, 0)); 187 keys.insert( "r0c10", FKey ("F11", 0, 4154, 0));
181 188
182 keys.insert( "r1c7", FKey ("Ho", 4112, 0)); 189 keys.insert( "r1c7", FKey ("Ho", 0, 4112, 0));
183 keys.insert( "r1c8", FKey ("End", 4113, 0)); 190 keys.insert( "r1c8", FKey ("End", 0, 4113, 0));
184 keys.insert( "r1c9", FKey ("PU", 4118, 0)); 191 keys.insert( "r1c9", FKey ("PU", 0, 4118, 0));
185 keys.insert( "r1c10", FKey ("PD", 4119, 0)); 192 keys.insert( "r1c10", FKey ("PD", 0, 4119, 0));
193 */
186 194
@@ -190,2 +198,8 @@ void FunctionKeyboard::loadDefaults() {
190 198
199<<<<<<< function_keyboard.cpp
200FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent) :
201 ProfileDialogKeyWidget(name, parent),
202 selectedRow(0), selectedCol(0)
203{
204=======
191FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na ) 205FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na )
@@ -193,2 +207,3 @@ FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* par
193 qWarning("FunctionKeyboardConfig"); 207 qWarning("FunctionKeyboardConfig");
208>>>>>>> 1.11
194 209
@@ -196,2 +211,4 @@ FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* par
196 kb = new FunctionKeyboard(this); 211 kb = new FunctionKeyboard(this);
212 connect (kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)),
213 this, SLOT(slotKeyPressed(FKey, ushort, ushort, bool)));
197 214
@@ -207,5 +224,5 @@ FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* par
207 l = new QLabel("Label", editKey); 224 l = new QLabel("Label", editKey);
208 /* 225 m_labels = new QComboBox(true, editKey);
209 m_labels = new QComboBox(false, editKey); 226 m_labels->setInsertionPolicy(QComboBox::AtCurrent);
210 labels->insertItem("text"); 227 m_labels->insertItem("custom");
211 228
@@ -218,3 +235,8 @@ FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* par
218 connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int))); 235 connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int)));
219 */ 236 connect (m_labels, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeLabelText(const QString&)));
237
238 l = new QLabel("KeyValue", editKey);
239 m_qvalues = new QComboBox(false, editKey);
240 m_qvalues->setInsertionPolicy(QComboBox::AtCurrent);
241 m_qvalues->insertItem("custom");
220 242
@@ -229,4 +251,21 @@ FunctionKeyboardConfig::~FunctionKeyboardConfig() {
229void FunctionKeyboardConfig::load (const Profile& prof) { 251void FunctionKeyboardConfig::load (const Profile& prof) {
230 //int i = prof.readNumEntry("keb_rows", 1); 252
231 m_rowBox->setValue( 2 ); 253 m_rowBox->setValue(prof.readNumEntry("keb_rows", 2));
254 m_colBox->setValue(prof.readNumEntry("keb_cols", 10));
255
256 /* load all the keys to the keyboard */
257 for (int i = 0; i <= m_rowBox->value() -1; i++)
258 for (int j = 0; j <= m_colBox->value() -1; j++) {
259
260 QString h = "r" + QString::number(i) + "c" + QString::number(j);
261 QString values = prof.readEntry("keb_" + h);
262
263 if (!values.isEmpty()) {
264
265 QStringList l = QStringList::split(QChar('|'), values, TRUE);
266 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());
268 }
269 }
270
232} 271}
@@ -235,2 +274,16 @@ void FunctionKeyboardConfig::save (Profile& prof) {
235 prof.writeEntry("keb_rows", m_rowBox->value()); 274 prof.writeEntry("keb_rows", m_rowBox->value());
275 prof.writeEntry("keb_cols", m_colBox->value());
276
277 QMap<QString, FKey>::Iterator it;
278 for ( it = kb->keys.begin(); it != kb->keys.end(); it++) {
279
280 FKey k = it.data();
281 QString entry = k.label + "|"
282 + k.pixFile + "|"
283 + QString::number(k.qcode) + "|"
284 + QString::number(k.unicode);
285
286 prof.writeEntry("keb_" + it.key(), entry);
287
288 }
236 289
@@ -248,4 +301,16 @@ void FunctionKeyboardConfig::slotChangeCols(int c) {
248} 301}
249void FunctionKeyboardConfig::slotKeyPressed(ushort, ushort, bool, bool, bool, ushort row, ushort col) { 302void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pressed) {
303
304 if (!pressed) return;
305
306 selectedRow = r, selectedCol = c;
250 307
308 if (k.pixFile.isEmpty()) {
309
310 m_labels->setCurrentItem(0);
311 m_labels->changeItem(k.label, 0);
312 m_labels->setEditable(true);
313
314 }
315 m_qvalues->changeItem(QString::number(k.qcode), 0);
251} 316}
@@ -256,3 +321,6 @@ void FunctionKeyboardConfig::slotChangeIcon(int index) {
256 // is text 321 // is text
257 //if(!labels->editable()) labels->setEditable(true); 322 m_labels->setEditable(true);
323 // why tf does the text get erased unless i do this?
324 m_labels->changeItem(m_labels->text(0), 0);
325
258 } else { 326 } else {
@@ -260,4 +328,11 @@ void FunctionKeyboardConfig::slotChangeIcon(int index) {
260 // is a pixmap 328 // is a pixmap
261 //if (labels->editable()) labels->setEditable(false); 329 m_labels->setEditable(false);
262 } 330 }
263} 331}
332void FunctionKeyboardConfig::slotChangeLabelText(const QString &label) {
333
334 kb->keys["r" + QString::number(selectedRow) +
335 "c" + QString::number(selectedCol)].label = label;
336
337 kb->paintKey(selectedRow, selectedCol);
338}