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.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp index 977a384..c314949 100644 --- a/noncore/apps/opie-console/function_keyboard.cpp +++ b/noncore/apps/opie-console/function_keyboard.cpp | |||
@@ -70,193 +70,193 @@ void FunctionKeyboard::paintEvent(QPaintEvent *e) { | |||
70 | /* those decimals do count! becomes short if use plain int */ | 70 | /* those decimals do count! becomes short if use plain int */ |
71 | for (double i = 0; i <= width(); i += keyWidth) { | 71 | for (double i = 0; i <= width(); i += keyWidth) { |
72 | 72 | ||
73 | p.drawLine((int)i, 0, (int)i, height()); | 73 | p.drawLine((int)i, 0, (int)i, height()); |
74 | } | 74 | } |
75 | 75 | ||
76 | // sometimes the last line doesnt get drawn | 76 | // sometimes the last line doesnt get drawn |
77 | p.drawLine(width() -1, 0, width() -1, height()); | 77 | p.drawLine(width() -1, 0, width() -1, height()); |
78 | 78 | ||
79 | for (int i = 0; i <= height(); i += keyHeight) { | 79 | for (int i = 0; i <= height(); i += keyHeight) { |
80 | 80 | ||
81 | p.drawLine(0, i, width(), i); | 81 | p.drawLine(0, i, width(), i); |
82 | } | 82 | } |
83 | 83 | ||
84 | for (uint r = 0; r < numRows; r++) { | 84 | for (uint r = 0; r < numRows; r++) { |
85 | for (uint c = 0; c < numCols; c++) { | 85 | for (uint c = 0; c < numCols; c++) { |
86 | 86 | ||
87 | QString handle = "r" + QString::number(r) + "c" + QString::number(c); | 87 | QString handle = "r" + QString::number(r) + "c" + QString::number(c); |
88 | if (keys.contains(handle)) { | 88 | if (keys.contains(handle)) { |
89 | 89 | ||
90 | p.drawText( | 90 | p.drawText( |
91 | c * keyWidth + 1, r * keyHeight + 1, | 91 | c * keyWidth + 1, r * keyHeight + 1, |
92 | keyWidth, keyHeight, | 92 | keyWidth, keyHeight, |
93 | Qt::AlignHCenter | Qt::AlignVCenter, | 93 | Qt::AlignHCenter | Qt::AlignVCenter, |
94 | keys[handle].getL() | 94 | keys[handle].getL() |
95 | ); | 95 | ); |
96 | } | 96 | } |
97 | } | 97 | } |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | void FunctionKeyboard::paintKey(int row, int col) { | 101 | void FunctionKeyboard::paintKey(int row, int col) { |
102 | 102 | ||
103 | QPainter p(this); | 103 | QPainter p(this); |
104 | 104 | ||
105 | p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1), | 105 | p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1), |
106 | QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)), | 106 | QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)), |
107 | (pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255)); | 107 | (pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255)); |
108 | p.drawText( | 108 | p.drawText( |
109 | col * keyWidth + 1, row * keyHeight + 1, | 109 | col * keyWidth + 1, row * keyHeight + 1, |
110 | keyWidth, keyHeight, | 110 | keyWidth, keyHeight, |
111 | Qt::AlignHCenter | Qt::AlignVCenter, | 111 | Qt::AlignHCenter | Qt::AlignVCenter, |
112 | keys["r" + QString::number(row) + "c" + QString::number(col)].getL() | 112 | keys["r" + QString::number(row) + "c" + QString::number(col)].getL() |
113 | ); | 113 | ); |
114 | 114 | ||
115 | if (row == numRows) { | 115 | if (row == numRows) { |
116 | 116 | ||
117 | // sometimes it doesnt draw the last line | 117 | // sometimes it doesnt draw the last line |
118 | p.drawLine((col+1) * keyWidth -2, row * keyHeight, | 118 | p.drawLine((col+1) * keyWidth -2, row * keyHeight, |
119 | (col+1) * keyWidth -2, (row + 1) * keyHeight | 119 | (col+1) * keyWidth -2, (row + 1) * keyHeight |
120 | ); | 120 | ); |
121 | } | 121 | } |
122 | 122 | ||
123 | } | 123 | } |
124 | 124 | ||
125 | void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { | 125 | void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { |
126 | 126 | ||
127 | pressedRow = e->y() / keyHeight; | 127 | pressedRow = e->y() / keyHeight; |
128 | pressedCol = (int) (e->x() / keyWidth); | 128 | pressedCol = (int) (e->x() / keyWidth); |
129 | 129 | ||
130 | paintKey(pressedRow, pressedCol); | 130 | paintKey(pressedRow, pressedCol); |
131 | 131 | ||
132 | // emit that sucker! | 132 | // emit that sucker! |
133 | FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; | 133 | FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; |
134 | emit keyPressed(k.getU(), k.getQ(), 0, 1, 0, pressedRow, pressedCol); | 134 | emit keyPressed(k.getU(), k.getQ(), 0, 1, 0, pressedRow, pressedCol); |
135 | 135 | ||
136 | } | 136 | } |
137 | 137 | ||
138 | void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { | 138 | void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { |
139 | 139 | ||
140 | if (pressedRow != -1 && pressedRow != -1) { | 140 | if (pressedRow != -1 && pressedRow != -1) { |
141 | 141 | ||
142 | int row = pressedRow; pressedRow = -1; | 142 | int row = pressedRow; pressedRow = -1; |
143 | int col = pressedCol; pressedCol = -1; | 143 | int col = pressedCol; pressedCol = -1; |
144 | paintKey(row, col); | 144 | paintKey(row, col); |
145 | 145 | ||
146 | FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; | 146 | FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; |
147 | emit keyPressed(k.getU(), k.getQ(), 0, 0, 0, pressedRow, pressedCol); | 147 | emit keyPressed(k.getU(), k.getQ(), 0, 0, 0, pressedRow, pressedCol); |
148 | } | 148 | } |
149 | 149 | ||
150 | } | 150 | } |
151 | 151 | ||
152 | 152 | ||
153 | void FunctionKeyboard::resizeEvent(QResizeEvent*) { | 153 | void FunctionKeyboard::resizeEvent(QResizeEvent*) { |
154 | 154 | ||
155 | /* set he default font height/width */ | 155 | /* set he default font height/width */ |
156 | QFontMetrics fm=fontMetrics(); | 156 | QFontMetrics fm=fontMetrics(); |
157 | keyHeight = fm.lineSpacing() + 2; | 157 | keyHeight = fm.lineSpacing() + 2; |
158 | keyWidth = (double)width()/numCols; | 158 | keyWidth = (double)width()/numCols; |
159 | 159 | ||
160 | } | 160 | } |
161 | 161 | ||
162 | QSize FunctionKeyboard::sizeHint() const { | 162 | QSize FunctionKeyboard::sizeHint() const { |
163 | 163 | ||
164 | return QSize(width(), keyHeight * numRows + 1); | 164 | return QSize(width(), keyHeight * numRows + 1); |
165 | } | 165 | } |
166 | 166 | ||
167 | void FunctionKeyboard::loadDefaults() { | 167 | void FunctionKeyboard::loadDefaults() { |
168 | 168 | ||
169 | /* what keys should be default? */ | 169 | /* what keys should be default? */ |
170 | keys.insert( "r0c0", FKey ("F1", 4144, 0)); | 170 | keys.insert( "r0c0", FKey ("F1", 4144, 0)); |
171 | keys.insert( "r0c1", FKey ("F2", 4145, 0)); | 171 | keys.insert( "r0c1", FKey ("F2", 4145, 0)); |
172 | keys.insert( "r0c2", FKey ("F3", 4145, 0)); | 172 | keys.insert( "r0c2", FKey ("F3", 4145, 0)); |
173 | keys.insert( "r0c3", FKey ("F4", 4146, 0)); | 173 | keys.insert( "r0c3", FKey ("F4", 4146, 0)); |
174 | keys.insert( "r0c4", FKey ("F5", 4147, 0)); | 174 | keys.insert( "r0c4", FKey ("F5", 4147, 0)); |
175 | keys.insert( "r0c5", FKey ("F6", 4148, 0)); | 175 | keys.insert( "r0c5", FKey ("F6", 4148, 0)); |
176 | keys.insert( "r0c6", FKey ("F7", 4149, 0)); | 176 | keys.insert( "r0c6", FKey ("F7", 4149, 0)); |
177 | keys.insert( "r0c7", FKey ("F8", 4150, 0)); | 177 | keys.insert( "r0c7", FKey ("F8", 4150, 0)); |
178 | keys.insert( "r0c8", FKey ("F9", 4151, 0)); | 178 | keys.insert( "r0c8", FKey ("F9", 4151, 0)); |
179 | keys.insert( "r0c9", FKey ("F10", 4152, 0)); | 179 | keys.insert( "r0c9", FKey ("F10", 4152, 0)); |
180 | keys.insert( "r0c10", FKey ("F11", 4153, 0)); | 180 | keys.insert( "r0c10", FKey ("F11", 4153, 0)); |
181 | 181 | ||
182 | keys.insert( "r1c7", FKey ("Ho", 4112, 0)); | 182 | keys.insert( "r1c7", FKey ("Ho", 4112, 0)); |
183 | keys.insert( "r1c8", FKey ("End", 4113, 0)); | 183 | keys.insert( "r1c8", FKey ("End", 4113, 0)); |
184 | keys.insert( "r1c9", FKey ("PU", 4118, 0)); | 184 | keys.insert( "r1c9", FKey ("PU", 4118, 0)); |
185 | keys.insert( "r1c10", FKey ("PD", 4119, 0)); | 185 | keys.insert( "r1c10", FKey ("PD", 4119, 0)); |
186 | 186 | ||
187 | } | 187 | } |
188 | 188 | ||
189 | /* FunctionKeyboardConfig {{{1 */ | 189 | /* FunctionKeyboardConfig {{{1 */ |
190 | 190 | ||
191 | FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent) : | 191 | FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na ) |
192 | ProfileDialogKeyWidget(name, parent) { | 192 | : ProfileDialogKeyWidget(name, parent, na) { |
193 | 193 | ||
194 | 194 | ||
195 | kb = new FunctionKeyboard(this); | 195 | kb = new FunctionKeyboard(this); |
196 | 196 | ||
197 | QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimentions"), this); | 197 | QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimentions"), this); |
198 | QLabel *l = new QLabel("Rows", dimentions); | 198 | QLabel *l = new QLabel("Rows", dimentions); |
199 | QSpinBox *m_rowBox = new QSpinBox(1, 15, 1, dimentions); | 199 | QSpinBox *m_rowBox = new QSpinBox(1, 15, 1, dimentions); |
200 | connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int))); | 200 | connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int))); |
201 | l = new QLabel("Columns", dimentions); | 201 | l = new QLabel("Columns", dimentions); |
202 | m_colBox = new QSpinBox(1, 15, 1, dimentions); | 202 | m_colBox = new QSpinBox(1, 15, 1, dimentions); |
203 | connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int))); | 203 | connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int))); |
204 | 204 | ||
205 | QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this); | 205 | QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this); |
206 | l = new QLabel("Label", editKey); | 206 | l = new QLabel("Label", editKey); |
207 | /* | 207 | /* |
208 | m_labels = new QComboBox(false, editKey); | 208 | m_labels = new QComboBox(false, editKey); |
209 | labels->insertItem("text"); | 209 | labels->insertItem("text"); |
210 | 210 | ||
211 | QStringList files = QDir(QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList(); | 211 | QStringList files = QDir(QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList(); |
212 | 212 | ||
213 | for (uint i = 0; i < files.count(); i++) { | 213 | for (uint i = 0; i < files.count(); i++) { |
214 | 214 | ||
215 | m_labels->insertItem(Resource::loadPixmap("console/keys/" + files[i])); | 215 | m_labels->insertItem(Resource::loadPixmap("console/keys/" + files[i])); |
216 | } | 216 | } |
217 | connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int))); | 217 | connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int))); |
218 | */ | 218 | */ |
219 | 219 | ||
220 | QVBoxLayout *root = new QVBoxLayout(this, 2); | 220 | QVBoxLayout *root = new QVBoxLayout(this, 2); |
221 | root->addWidget(kb); | 221 | root->addWidget(kb); |
222 | root->addWidget(dimentions); | 222 | root->addWidget(dimentions); |
223 | root->addWidget(editKey); | 223 | root->addWidget(editKey); |
224 | } | 224 | } |
225 | FunctionKeyboardConfig::~FunctionKeyboardConfig() { | 225 | FunctionKeyboardConfig::~FunctionKeyboardConfig() { |
226 | 226 | ||
227 | } | 227 | } |
228 | void FunctionKeyboardConfig::load (const Profile& prof) { | 228 | void FunctionKeyboardConfig::load (const Profile& prof) { |
229 | int i = prof.readNumEntry("keb_rows", 1); | 229 | //int i = prof.readNumEntry("keb_rows", 1); |
230 | //m_rowBox->setValue(i); | 230 | m_rowBox->setValue( 2 ); |
231 | } | 231 | } |
232 | void FunctionKeyboardConfig::save (Profile& prof) { | 232 | void FunctionKeyboardConfig::save (Profile& prof) { |
233 | 233 | ||
234 | //prof.writeEntry("keb_rows", m_rowBox->value()); | 234 | prof.writeEntry("keb_rows", m_rowBox->value()); |
235 | 235 | ||
236 | } | 236 | } |
237 | void FunctionKeyboardConfig::slotChangeRows(int r) { | 237 | void FunctionKeyboardConfig::slotChangeRows(int r) { |
238 | 238 | ||
239 | kb->changeRows(r); | 239 | kb->changeRows(r); |
240 | 240 | ||
241 | // have to do this so the whole thing gets redrawn | 241 | // have to do this so the whole thing gets redrawn |
242 | kb->hide(); kb->show(); | 242 | kb->hide(); kb->show(); |
243 | } | 243 | } |
244 | void FunctionKeyboardConfig::slotChangeCols(int c) { | 244 | void FunctionKeyboardConfig::slotChangeCols(int c) { |
245 | 245 | ||
246 | kb->changeCols(c); | 246 | kb->changeCols(c); |
247 | } | 247 | } |
248 | void FunctionKeyboardConfig::slotKeyPressed(ushort, ushort, bool, bool, bool, ushort row, ushort col) { | 248 | void FunctionKeyboardConfig::slotKeyPressed(ushort, ushort, bool, bool, bool, ushort row, ushort col) { |
249 | 249 | ||
250 | } | 250 | } |
251 | void FunctionKeyboardConfig::slotChangeIcon(int index) { | 251 | void FunctionKeyboardConfig::slotChangeIcon(int index) { |
252 | 252 | ||
253 | if (index == 0) { | 253 | if (index == 0) { |
254 | 254 | ||
255 | // is text | 255 | // is text |
256 | //if(!labels->editable()) labels->setEditable(true); | 256 | //if(!labels->editable()) labels->setEditable(true); |
257 | } else { | 257 | } else { |
258 | 258 | ||
259 | // is a pixmap | 259 | // is a pixmap |
260 | //if (labels->editable()) labels->setEditable(false); | 260 | //if (labels->editable()) labels->setEditable(false); |
261 | } | 261 | } |
262 | } | 262 | } |