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 | 92 |
1 files changed, 86 insertions, 6 deletions
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp index 100fdfc..977a384 100644 --- a/noncore/apps/opie-console/function_keyboard.cpp +++ b/noncore/apps/opie-console/function_keyboard.cpp | |||
@@ -1,2 +1,5 @@ | |||
1 | #include "function_keyboard.h" | 1 | #include "function_keyboard.h" |
2 | |||
3 | #include <qpe/resource.h> | ||
4 | #include <qpe/qpeapplication.h> | ||
2 | #include <qsizepolicy.h> | 5 | #include <qsizepolicy.h> |
@@ -6,2 +9,8 @@ | |||
6 | #include <qlayout.h> | 9 | #include <qlayout.h> |
10 | #include <qspinbox.h> | ||
11 | #include <qlabel.h> | ||
12 | #include <qcombobox.h> | ||
13 | #include <qdir.h> | ||
14 | |||
15 | /* FunctionKeyboard {{{1 */ | ||
7 | 16 | ||
@@ -40,2 +49,14 @@ FunctionKeyboard::~FunctionKeyboard() { | |||
40 | 49 | ||
50 | void FunctionKeyboard::changeRows(int r) { | ||
51 | |||
52 | numRows = r; | ||
53 | repaint(false); | ||
54 | } | ||
55 | void FunctionKeyboard::changeCols(int c) { | ||
56 | |||
57 | numCols = c; | ||
58 | keyWidth = (double)width()/numCols; // have to reset this thing too | ||
59 | repaint(false); | ||
60 | } | ||
61 | |||
41 | void FunctionKeyboard::paintEvent(QPaintEvent *e) { | 62 | void FunctionKeyboard::paintEvent(QPaintEvent *e) { |
@@ -93,2 +114,10 @@ void FunctionKeyboard::paintKey(int row, int col) { | |||
93 | 114 | ||
115 | if (row == numRows) { | ||
116 | |||
117 | // sometimes it doesnt draw the last line | ||
118 | p.drawLine((col+1) * keyWidth -2, row * keyHeight, | ||
119 | (col+1) * keyWidth -2, (row + 1) * keyHeight | ||
120 | ); | ||
121 | } | ||
122 | |||
94 | } | 123 | } |
@@ -104,3 +133,3 @@ void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { | |||
104 | FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; | 133 | FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; |
105 | emit keyPressed(k.getU(), k.getQ(), 0, 1, 0); | 134 | emit keyPressed(k.getU(), k.getQ(), 0, 1, 0, pressedRow, pressedCol); |
106 | 135 | ||
@@ -117,3 +146,3 @@ void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { | |||
117 | FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; | 146 | FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; |
118 | emit keyPressed(k.getU(), k.getQ(), 0, 0, 0); | 147 | emit keyPressed(k.getU(), k.getQ(), 0, 0, 0, pressedRow, pressedCol); |
119 | } | 148 | } |
@@ -159,2 +188,3 @@ void FunctionKeyboard::loadDefaults() { | |||
159 | 188 | ||
189 | /* FunctionKeyboardConfig {{{1 */ | ||
160 | 190 | ||
@@ -164,5 +194,26 @@ FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* par | |||
164 | 194 | ||
165 | FunctionKeyboard *kb = new FunctionKeyboard(this); | 195 | kb = new FunctionKeyboard(this); |
196 | |||
166 | QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimentions"), this); | 197 | QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimentions"), this); |
167 | QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit"), this); | 198 | QLabel *l = new QLabel("Rows", dimentions); |
199 | QSpinBox *m_rowBox = new QSpinBox(1, 15, 1, dimentions); | ||
200 | connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int))); | ||
201 | l = new QLabel("Columns", dimentions); | ||
202 | m_colBox = new QSpinBox(1, 15, 1, dimentions); | ||
203 | connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int))); | ||
204 | |||
205 | QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this); | ||
206 | l = new QLabel("Label", editKey); | ||
207 | /* | ||
208 | m_labels = new QComboBox(false, editKey); | ||
209 | labels->insertItem("text"); | ||
210 | |||
211 | QStringList files = QDir(QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList(); | ||
212 | |||
213 | for (uint i = 0; i < files.count(); i++) { | ||
214 | |||
215 | m_labels->insertItem(Resource::loadPixmap("console/keys/" + files[i])); | ||
216 | } | ||
217 | connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int))); | ||
218 | */ | ||
168 | 219 | ||
@@ -176,7 +227,36 @@ FunctionKeyboardConfig::~FunctionKeyboardConfig() { | |||
176 | } | 227 | } |
177 | void FunctionKeyboardConfig::load (const Profile& ) { | 228 | void FunctionKeyboardConfig::load (const Profile& prof) { |
229 | int i = prof.readNumEntry("keb_rows", 1); | ||
230 | //m_rowBox->setValue(i); | ||
231 | } | ||
232 | void FunctionKeyboardConfig::save (Profile& prof) { | ||
233 | |||
234 | //prof.writeEntry("keb_rows", m_rowBox->value()); | ||
235 | |||
236 | } | ||
237 | void FunctionKeyboardConfig::slotChangeRows(int r) { | ||
238 | |||
239 | kb->changeRows(r); | ||
240 | |||
241 | // have to do this so the whole thing gets redrawn | ||
242 | kb->hide(); kb->show(); | ||
243 | } | ||
244 | void FunctionKeyboardConfig::slotChangeCols(int c) { | ||
245 | |||
246 | kb->changeCols(c); | ||
247 | } | ||
248 | void FunctionKeyboardConfig::slotKeyPressed(ushort, ushort, bool, bool, bool, ushort row, ushort col) { | ||
178 | 249 | ||
179 | } | 250 | } |
180 | void FunctionKeyboardConfig::save (Profile& ) { | 251 | void FunctionKeyboardConfig::slotChangeIcon(int index) { |
181 | 252 | ||
253 | if (index == 0) { | ||
254 | |||
255 | // is text | ||
256 | //if(!labels->editable()) labels->setEditable(true); | ||
257 | } else { | ||
258 | |||
259 | // is a pixmap | ||
260 | //if (labels->editable()) labels->setEditable(false); | ||
261 | } | ||
182 | } | 262 | } |