author | hash <hash> | 2002-10-24 06:14:10 (UTC) |
---|---|---|
committer | hash <hash> | 2002-10-24 06:14:10 (UTC) |
commit | bdd884e37dc1ee1969d317b29e926768ea5a14df (patch) (unidiff) | |
tree | 30353735e07c853be3c8458b413c4bf0d7bf58bc /noncore/apps/opie-console/function_keyboard.cpp | |
parent | f09549e37fee6decd56168043209e8051b8757fb (diff) | |
download | opie-bdd884e37dc1ee1969d317b29e926768ea5a14df.zip opie-bdd884e37dc1ee1969d317b29e926768ea5a14df.tar.gz opie-bdd884e37dc1ee1969d317b29e926768ea5a14df.tar.bz2 |
still a work in progress
Diffstat (limited to 'noncore/apps/opie-console/function_keyboard.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/function_keyboard.cpp | 139 |
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 | |||
@@ -1,263 +1,338 @@ | |||
1 | #include "function_keyboard.h" | 1 | #include "function_keyboard.h" |
2 | 2 | ||
3 | #include <qpe/resource.h> | 3 | #include <qpe/resource.h> |
4 | #include <qpe/qpeapplication.h> | 4 | #include <qpe/qpeapplication.h> |
5 | #include <qsizepolicy.h> | 5 | #include <qsizepolicy.h> |
6 | #include <qevent.h> | 6 | #include <qevent.h> |
7 | #include <qwindowsystem_qws.h> | 7 | #include <qwindowsystem_qws.h> |
8 | #include <qapplication.h> | 8 | #include <qapplication.h> |
9 | #include <qlayout.h> | 9 | #include <qlayout.h> |
10 | #include <qspinbox.h> | 10 | #include <qspinbox.h> |
11 | #include <qlabel.h> | 11 | #include <qlabel.h> |
12 | #include <qcombobox.h> | 12 | #include <qcombobox.h> |
13 | #include <qdir.h> | 13 | #include <qdir.h> |
14 | 14 | ||
15 | /* FunctionKeyboard {{{1 */ | 15 | /* FunctionKeyboard {{{1 */ |
16 | 16 | ||
17 | FunctionKeyboard::FunctionKeyboard(QWidget *parent) : | 17 | FunctionKeyboard::FunctionKeyboard(QWidget *parent) : |
18 | QFrame(parent), numRows(2), numCols(11), | 18 | QFrame(parent), numRows(2), numCols(11), |
19 | pressedRow(0), pressedCol(0) { | 19 | pressedRow(0), pressedCol(0) { |
20 | 20 | ||
21 | setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); | 21 | setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); |
22 | 22 | ||
23 | Config conf("opie-console-keys"); | 23 | Config conf("opie-console-keys"); |
24 | conf.setGroup("keys"); | 24 | conf.setGroup("keys"); |
25 | for (uint r = 0; r < numRows; r++) | 25 | for (uint r = 0; r < numRows; r++) |
26 | for (uint c = 0; c < numCols; c++) { | 26 | for (uint c = 0; c < numCols; c++) { |
27 | 27 | ||
28 | QString handle = "r" + QString::number(r) + "c" + QString::number(c); | 28 | QString handle = "r" + QString::number(r) + "c" + QString::number(c); |
29 | QStringList value_list = conf.readListEntry( handle, '|'); | 29 | QStringList value_list = conf.readListEntry( handle, '|'); |
30 | 30 | ||
31 | if (value_list.isEmpty()) continue; | 31 | if (value_list.isEmpty()) continue; |
32 | 32 | ||
33 | keys.insert( | 33 | keys.insert( |
34 | 34 | ||
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 | ); |
38 | } | 38 | } |
39 | //qWarning("loaded %d keys", keys.count()); | 39 | //qWarning("loaded %d keys", keys.count()); |
40 | if (keys.isEmpty()) loadDefaults(); | 40 | if (keys.isEmpty()) loadDefaults(); |
41 | 41 | ||
42 | 42 | ||
43 | 43 | ||
44 | } | 44 | } |
45 | 45 | ||
46 | FunctionKeyboard::~FunctionKeyboard() { | 46 | FunctionKeyboard::~FunctionKeyboard() { |
47 | 47 | ||
48 | } | 48 | } |
49 | 49 | ||
50 | void FunctionKeyboard::changeRows(int r) { | 50 | void FunctionKeyboard::changeRows(int r) { |
51 | 51 | ||
52 | numRows = r; | 52 | numRows = r; |
53 | repaint(false); | 53 | repaint(false); |
54 | } | 54 | } |
55 | void FunctionKeyboard::changeCols(int c) { | 55 | void FunctionKeyboard::changeCols(int c) { |
56 | 56 | ||
57 | numCols = c; | 57 | numCols = c; |
58 | keyWidth = (double)width()/numCols; // have to reset this thing too | 58 | keyWidth = (double)width()/numCols; // have to reset this thing too |
59 | repaint(false); | 59 | repaint(false); |
60 | } | 60 | } |
61 | 61 | ||
62 | /* | ||
63 | Key getKey(int row, int col) { | ||
64 | |||
65 | return keys[ "r" + QString::number(row) + "c" + QString::number(col) ]; | ||
66 | } | ||
67 | */ | ||
68 | |||
62 | void FunctionKeyboard::paintEvent(QPaintEvent *e) { | 69 | void FunctionKeyboard::paintEvent(QPaintEvent *e) { |
63 | 70 | ||
64 | QPainter p(this); | 71 | QPainter p(this); |
65 | p.setClipRect(e->rect()); | 72 | p.setClipRect(e->rect()); |
66 | p.fillRect(0, 0, width(), height(), QColor(255,255,255)); | 73 | p.fillRect(0, 0, width(), height(), QColor(255,255,255)); |
67 | 74 | ||
68 | p.setPen(QColor(0,0,0)); | 75 | p.setPen(QColor(0,0,0)); |
69 | 76 | ||
70 | /* those decimals do count! becomes short if use plain int */ | 77 | /* those decimals do count! becomes short if use plain int */ |
71 | for (double i = 0; i <= width(); i += keyWidth) { | 78 | for (double i = 0; i <= width(); i += keyWidth) { |
72 | 79 | ||
73 | p.drawLine((int)i, 0, (int)i, height()); | 80 | p.drawLine((int)i, 0, (int)i, height()); |
74 | } | 81 | } |
75 | 82 | ||
76 | // sometimes the last line doesnt get drawn | 83 | // sometimes the last line doesnt get drawn |
77 | p.drawLine(width() -1, 0, width() -1, height()); | 84 | p.drawLine(width() -1, 0, width() -1, height()); |
78 | 85 | ||
79 | for (int i = 0; i <= height(); i += keyHeight) { | 86 | for (int i = 0; i <= height(); i += keyHeight) { |
80 | 87 | ||
81 | p.drawLine(0, i, width(), i); | 88 | p.drawLine(0, i, width(), i); |
82 | } | 89 | } |
83 | 90 | ||
84 | for (uint r = 0; r < numRows; r++) { | 91 | for (uint r = 0; r < numRows; r++) { |
85 | for (uint c = 0; c < numCols; c++) { | 92 | for (uint c = 0; c < numCols; c++) { |
86 | 93 | ||
87 | QString handle = "r" + QString::number(r) + "c" + QString::number(c); | 94 | QString handle = "r" + QString::number(r) + "c" + QString::number(c); |
88 | if (keys.contains(handle)) { | 95 | if (keys.contains(handle)) { |
89 | 96 | ||
90 | p.drawText( | 97 | p.drawText( |
91 | c * keyWidth + 1, r * keyHeight + 1, | 98 | c * keyWidth + 1, r * keyHeight + 1, |
92 | keyWidth, keyHeight, | 99 | keyWidth, keyHeight, |
93 | Qt::AlignHCenter | Qt::AlignVCenter, | 100 | Qt::AlignHCenter | Qt::AlignVCenter, |
94 | keys[handle].getL() | 101 | keys[handle].label |
95 | ); | 102 | ); |
96 | } | 103 | } |
97 | } | 104 | } |
98 | } | 105 | } |
99 | } | 106 | } |
100 | 107 | ||
101 | void FunctionKeyboard::paintKey(int row, int col) { | 108 | void FunctionKeyboard::paintKey(uint row, uint col) { |
102 | 109 | ||
103 | QPainter p(this); | 110 | QPainter p(this); |
104 | 111 | ||
105 | p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1), | 112 | p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1), |
106 | QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)), | 113 | QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)), |
107 | (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)); |
108 | p.drawText( | 115 | p.drawText( |
109 | col * keyWidth + 1, row * keyHeight + 1, | 116 | col * keyWidth + 1, row * keyHeight + 1, |
110 | keyWidth, keyHeight, | 117 | keyWidth, keyHeight, |
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 | ); |
114 | 121 | ||
115 | if (row == numRows) { | 122 | if (row == numRows) { |
116 | 123 | ||
117 | // sometimes it doesnt draw the last line | 124 | // sometimes it doesnt draw the last line |
118 | p.drawLine((col+1) * keyWidth -2, row * keyHeight, | 125 | p.drawLine((col+1) * keyWidth -2, row * keyHeight, |
119 | (col+1) * keyWidth -2, (row + 1) * keyHeight | 126 | (col+1) * keyWidth -2, (row + 1) * keyHeight |
120 | ); | 127 | ); |
121 | } | 128 | } |
122 | 129 | ||
123 | } | 130 | } |
124 | 131 | ||
125 | void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { | 132 | void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { |
126 | 133 | ||
127 | pressedRow = e->y() / keyHeight; | 134 | pressedRow = e->y() / keyHeight; |
128 | pressedCol = (int) (e->x() / keyWidth); | 135 | pressedCol = (int) (e->x() / keyWidth); |
129 | 136 | ||
130 | paintKey(pressedRow, pressedCol); | 137 | paintKey(pressedRow, pressedCol); |
131 | 138 | ||
132 | // emit that sucker! | 139 | // emit that sucker! |
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 | ||
136 | } | 143 | } |
137 | 144 | ||
138 | void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { | 145 | void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { |
139 | 146 | ||
140 | if (pressedRow != -1 && pressedRow != -1) { | 147 | if (pressedRow != -1 && pressedRow != -1) { |
141 | 148 | ||
142 | int row = pressedRow; pressedRow = -1; | 149 | int row = pressedRow; pressedRow = -1; |
143 | int col = pressedCol; pressedCol = -1; | 150 | int col = pressedCol; pressedCol = -1; |
144 | paintKey(row, col); | 151 | paintKey(row, col); |
145 | 152 | ||
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 | } |
149 | 156 | ||
150 | } | 157 | } |
151 | 158 | ||
152 | 159 | ||
153 | void FunctionKeyboard::resizeEvent(QResizeEvent*) { | 160 | void FunctionKeyboard::resizeEvent(QResizeEvent*) { |
154 | 161 | ||
155 | /* set he default font height/width */ | 162 | /* set he default font height/width */ |
156 | QFontMetrics fm=fontMetrics(); | 163 | QFontMetrics fm=fontMetrics(); |
157 | keyHeight = fm.lineSpacing() + 2; | 164 | keyHeight = fm.lineSpacing() + 2; |
158 | keyWidth = (double)width()/numCols; | 165 | keyWidth = (double)width()/numCols; |
159 | 166 | ||
160 | } | 167 | } |
161 | 168 | ||
162 | QSize FunctionKeyboard::sizeHint() const { | 169 | QSize FunctionKeyboard::sizeHint() const { |
163 | 170 | ||
164 | return QSize(width(), keyHeight * numRows + 1); | 171 | return QSize(width(), keyHeight * numRows + 1); |
165 | } | 172 | } |
166 | 173 | ||
167 | void FunctionKeyboard::loadDefaults() { | 174 | 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 | ||
187 | } | 195 | } |
188 | 196 | ||
189 | /* FunctionKeyboardConfig {{{1 */ | 197 | /* FunctionKeyboardConfig {{{1 */ |
190 | 198 | ||
199 | <<<<<<< function_keyboard.cpp | ||
200 | FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent) : | ||
201 | ProfileDialogKeyWidget(name, parent), | ||
202 | selectedRow(0), selectedCol(0) | ||
203 | { | ||
204 | ======= | ||
191 | FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na ) | 205 | FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na ) |
192 | : ProfileDialogKeyWidget(name, parent, na) { | 206 | : ProfileDialogKeyWidget(name, parent, na) { |
193 | qWarning("FunctionKeyboardConfig"); | 207 | qWarning("FunctionKeyboardConfig"); |
208 | >>>>>>> 1.11 | ||
194 | 209 | ||
195 | 210 | ||
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 | ||
198 | QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimentions"), this); | 215 | QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimentions"), this); |
199 | QLabel *l = new QLabel("Rows", dimentions); | 216 | QLabel *l = new QLabel("Rows", dimentions); |
200 | m_rowBox = new QSpinBox(1, 15, 1, dimentions); | 217 | m_rowBox = new QSpinBox(1, 15, 1, dimentions); |
201 | connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int))); | 218 | connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int))); |
202 | l = new QLabel("Columns", dimentions); | 219 | l = new QLabel("Columns", dimentions); |
203 | m_colBox = new QSpinBox(1, 15, 1, dimentions); | 220 | m_colBox = new QSpinBox(1, 15, 1, dimentions); |
204 | connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int))); | 221 | connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int))); |
205 | 222 | ||
206 | QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this); | 223 | QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this); |
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 | ||
212 | QStringList files = QDir(QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList(); | 229 | QStringList files = QDir(QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList(); |
213 | 230 | ||
214 | for (uint i = 0; i < files.count(); i++) { | 231 | for (uint i = 0; i < files.count(); i++) { |
215 | 232 | ||
216 | m_labels->insertItem(Resource::loadPixmap("console/keys/" + files[i])); | 233 | m_labels->insertItem(Resource::loadPixmap("console/keys/" + files[i])); |
217 | } | 234 | } |
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 | ||
221 | QVBoxLayout *root = new QVBoxLayout(this, 2); | 243 | QVBoxLayout *root = new QVBoxLayout(this, 2); |
222 | root->addWidget(kb); | 244 | root->addWidget(kb); |
223 | root->addWidget(dimentions); | 245 | root->addWidget(dimentions); |
224 | root->addWidget(editKey); | 246 | root->addWidget(editKey); |
225 | } | 247 | } |
226 | FunctionKeyboardConfig::~FunctionKeyboardConfig() { | 248 | FunctionKeyboardConfig::~FunctionKeyboardConfig() { |
227 | 249 | ||
228 | } | 250 | } |
229 | void FunctionKeyboardConfig::load (const Profile& prof) { | 251 | void 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 | } |
233 | void FunctionKeyboardConfig::save (Profile& prof) { | 272 | void FunctionKeyboardConfig::save (Profile& prof) { |
234 | 273 | ||
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 | ||
237 | } | 290 | } |
238 | void FunctionKeyboardConfig::slotChangeRows(int r) { | 291 | void FunctionKeyboardConfig::slotChangeRows(int r) { |
239 | 292 | ||
240 | kb->changeRows(r); | 293 | kb->changeRows(r); |
241 | 294 | ||
242 | // have to do this so the whole thing gets redrawn | 295 | // have to do this so the whole thing gets redrawn |
243 | kb->hide(); kb->show(); | 296 | kb->hide(); kb->show(); |
244 | } | 297 | } |
245 | void FunctionKeyboardConfig::slotChangeCols(int c) { | 298 | void FunctionKeyboardConfig::slotChangeCols(int c) { |
246 | 299 | ||
247 | kb->changeCols(c); | 300 | kb->changeCols(c); |
248 | } | 301 | } |
249 | void FunctionKeyboardConfig::slotKeyPressed(ushort, ushort, bool, bool, bool, ushort row, ushort col) { | 302 | void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pressed) { |
303 | |||
304 | if (!pressed) return; | ||
250 | 305 | ||
306 | selectedRow = r, selectedCol = c; | ||
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 | } |
252 | void FunctionKeyboardConfig::slotChangeIcon(int index) { | 317 | void FunctionKeyboardConfig::slotChangeIcon(int index) { |
253 | 318 | ||
254 | if (index == 0) { | 319 | if (index == 0) { |
255 | 320 | ||
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 { |
259 | 327 | ||
260 | // is a pixmap | 328 | // is a pixmap |
261 | //if (labels->editable()) labels->setEditable(false); | 329 | m_labels->setEditable(false); |
330 | } | ||
262 | } | 331 | } |
332 | void 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); | ||
263 | } | 338 | } |