-rw-r--r-- | noncore/apps/opie-console/function_keyboard.cpp | 139 | ||||
-rw-r--r-- | noncore/apps/opie-console/function_keyboard.h | 35 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 12 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.h | 3 |
4 files changed, 137 insertions, 52 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; | ||
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 | } |
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); |
262 | } | 330 | } |
263 | } | 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); | ||
338 | } | ||
diff --git a/noncore/apps/opie-console/function_keyboard.h b/noncore/apps/opie-console/function_keyboard.h index 05b991d..496d932 100644 --- a/noncore/apps/opie-console/function_keyboard.h +++ b/noncore/apps/opie-console/function_keyboard.h | |||
@@ -1,103 +1,112 @@ | |||
1 | #ifndef OPIE_FUNCTION_KEYBOARD_H | 1 | #ifndef OPIE_FUNCTION_KEYBOARD_H |
2 | #define OPIE_FUNCTION_KEYBOARD_H | 2 | #define OPIE_FUNCTION_KEYBOARD_H |
3 | 3 | ||
4 | #include <qpe/config.h> | 4 | #include <qpe/config.h> |
5 | #include <qpe/qpeapplication.h> | ||
5 | #include <qframe.h> | 6 | #include <qframe.h> |
6 | #include <qpainter.h> | 7 | #include <qpainter.h> |
7 | #include <qvbox.h> | 8 | #include <qvbox.h> |
8 | #include <qgroupbox.h> | 9 | #include <qgroupbox.h> |
9 | #include <qmap.h> | 10 | #include <qmap.h> |
10 | #include <qspinbox.h> | 11 | #include <qspinbox.h> |
11 | #include <qcombobox.h> | 12 | #include <qcombobox.h> |
12 | #include "profiledialogwidget.h" | 13 | #include "profiledialogwidget.h" |
13 | 14 | ||
14 | 15 | ||
15 | class FKey { | 16 | struct FKey { |
16 | |||
17 | public: | ||
18 | 17 | ||
19 | FKey(): qcode(0), unicode(0) {}; | 18 | FKey(): qcode(0), unicode(0) {}; |
20 | FKey(const QString &l, ushort q, ushort u): label(l), qcode(q), unicode(u) {}; | 19 | FKey(const QString &l, const QString &f, ushort q, ushort u): |
20 | label(l), pixFile(f), qcode(q), unicode(u) { | ||
21 | |||
22 | if (!f.isEmpty()) { | ||
21 | 23 | ||
22 | QString getL() { return label; } | 24 | pix = new QPixmap (QPEApplication::qpeDir() + "pics/console/keys/" + f); |
23 | ushort getQ() { return qcode; } | ||
24 | ushort getU() { return unicode; } | ||
25 | 25 | ||
26 | 26 | } | |
27 | private: | 27 | }; |
28 | 28 | ||
29 | QString label; | 29 | QString label; |
30 | QPixmap *pix; | ||
31 | QString pixFile; | ||
30 | ushort qcode; | 32 | ushort qcode; |
31 | ushort unicode; | 33 | ushort unicode; |
32 | }; | 34 | }; |
33 | 35 | ||
34 | class FunctionKeyboard : public QFrame { | 36 | class FunctionKeyboard : public QFrame { |
35 | Q_OBJECT | 37 | Q_OBJECT |
36 | 38 | ||
37 | public: | 39 | public: |
38 | FunctionKeyboard(QWidget *parent = 0); | 40 | FunctionKeyboard(QWidget *parent = 0); |
39 | ~FunctionKeyboard(); | 41 | ~FunctionKeyboard(); |
40 | 42 | ||
43 | friend class FunctionKeyboardConfig; | ||
44 | |||
41 | void changeRows(int); | 45 | void changeRows(int); |
42 | void changeCols(int); | 46 | void changeCols(int); |
43 | 47 | ||
48 | //Key getKey(int, int); | ||
49 | |||
44 | void paintEvent(QPaintEvent *); | 50 | void paintEvent(QPaintEvent *); |
45 | void paintKey(int, int); | 51 | void paintKey(uint, uint); |
46 | void mousePressEvent(QMouseEvent*); | 52 | void mousePressEvent(QMouseEvent*); |
47 | void mouseReleaseEvent(QMouseEvent*); | 53 | void mouseReleaseEvent(QMouseEvent*); |
48 | void resizeEvent(QResizeEvent*); | 54 | void resizeEvent(QResizeEvent*); |
49 | QSize sizeHint() const; | 55 | QSize sizeHint() const; |
50 | 56 | ||
51 | signals: | 57 | signals: |
52 | 58 | ||
53 | void keyPressed(ushort, ushort, bool, bool, bool, ushort, ushort); | 59 | void keyPressed(FKey, ushort, ushort, bool); |
54 | 60 | ||
55 | private: | 61 | private: |
56 | 62 | ||
57 | void loadDefaults(); | 63 | void loadDefaults(); |
58 | 64 | ||
59 | 65 | ||
60 | private: | 66 | private: |
61 | 67 | ||
62 | // thie key for the map is the row/col | 68 | // thie key for the map is the row/col |
63 | QMap<QString, FKey> keys; | 69 | QMap<QString, FKey> keys; |
64 | 70 | ||
65 | uint numRows; | 71 | uint numRows; |
66 | int test; | 72 | int test; |
67 | uint numCols; | 73 | uint numCols; |
68 | uint keyHeight; | 74 | uint keyHeight; |
69 | double keyWidth; // decimal point matters! | 75 | double keyWidth; // decimal point matters! |
70 | 76 | ||
71 | int pressedRow, pressedCol; | 77 | int pressedRow, pressedCol; |
72 | 78 | ||
73 | QObject *parent; | 79 | QObject *parent; |
74 | 80 | ||
75 | }; | 81 | }; |
76 | 82 | ||
77 | class FunctionKeyboardConfig : public ProfileDialogKeyWidget { | 83 | class FunctionKeyboardConfig : public ProfileDialogKeyWidget { |
78 | 84 | ||
79 | Q_OBJECT | 85 | Q_OBJECT |
80 | 86 | ||
81 | public: | 87 | public: |
82 | FunctionKeyboardConfig(const QString& name, QWidget *wid, const char* name = 0l ); | 88 | FunctionKeyboardConfig(const QString& name, QWidget *wid, const char* name = 0l ); |
83 | ~FunctionKeyboardConfig(); | 89 | ~FunctionKeyboardConfig(); |
84 | 90 | ||
85 | void load(const Profile&); | 91 | void load(const Profile&); |
86 | void save(Profile&); | 92 | void save(Profile&); |
87 | 93 | ||
88 | private slots: | 94 | private slots: |
89 | 95 | ||
90 | void slotKeyPressed(ushort, ushort, bool, bool, bool, ushort, ushort); | 96 | void slotKeyPressed(FKey, ushort, ushort, bool); |
91 | void slotChangeRows(int); | 97 | void slotChangeRows(int); |
92 | void slotChangeCols(int); | 98 | void slotChangeCols(int); |
93 | void slotChangeIcon(int); | 99 | void slotChangeIcon(int); |
100 | void slotChangeLabelText(const QString &); | ||
94 | 101 | ||
95 | private: | 102 | private: |
96 | 103 | ||
104 | ushort selectedRow, selectedCol; | ||
105 | |||
97 | FunctionKeyboard *kb; | 106 | FunctionKeyboard *kb; |
98 | QSpinBox *m_rowBox, *m_colBox; | 107 | QSpinBox *m_rowBox, *m_colBox; |
99 | QComboBox *m_labels; | 108 | QComboBox *m_labels, *m_qvalues; |
100 | 109 | ||
101 | }; | 110 | }; |
102 | 111 | ||
103 | #endif | 112 | #endif |
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index c1020fa..8e529a3 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -1,540 +1,540 @@ | |||
1 | #include <assert.h> | 1 | #include <assert.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qmenubar.h> | 4 | #include <qmenubar.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | #include <qpopupmenu.h> | 6 | #include <qpopupmenu.h> |
7 | #include <qtoolbar.h> | 7 | #include <qtoolbar.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qpushbutton.h> | 9 | #include <qpushbutton.h> |
10 | #include <qwhatsthis.h> | 10 | #include <qwhatsthis.h> |
11 | 11 | ||
12 | #include <qpe/resource.h> | 12 | #include <qpe/resource.h> |
13 | 13 | ||
14 | #include <opie/ofiledialog.h> | 14 | #include <opie/ofiledialog.h> |
15 | 15 | ||
16 | #include "keytrans.h" | 16 | #include "keytrans.h" |
17 | #include "profileeditordialog.h" | 17 | #include "profileeditordialog.h" |
18 | #include "configdialog.h" | 18 | #include "configdialog.h" |
19 | #include "default.h" | 19 | #include "default.h" |
20 | #include "metafactory.h" | 20 | #include "metafactory.h" |
21 | #include "profile.h" | 21 | #include "profile.h" |
22 | #include "profilemanager.h" | 22 | #include "profilemanager.h" |
23 | #include "mainwindow.h" | 23 | #include "mainwindow.h" |
24 | #include "tabwidget.h" | 24 | #include "tabwidget.h" |
25 | #include "transferdialog.h" | 25 | #include "transferdialog.h" |
26 | #include "function_keyboard.h" | 26 | #include "function_keyboard.h" |
27 | #include "emulation_handler.h" | 27 | #include "emulation_handler.h" |
28 | #include "script.h" | 28 | #include "script.h" |
29 | #include "quick_button.h" | 29 | #include "quick_button.h" |
30 | 30 | ||
31 | 31 | ||
32 | 32 | ||
33 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { | 33 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { |
34 | KeyTrans::loadAll(); | 34 | KeyTrans::loadAll(); |
35 | for (int i = 0; i < KeyTrans::count(); i++ ) { | 35 | for (int i = 0; i < KeyTrans::count(); i++ ) { |
36 | KeyTrans* s = KeyTrans::find(i ); | 36 | KeyTrans* s = KeyTrans::find(i ); |
37 | assert( s ); | 37 | assert( s ); |
38 | } | 38 | } |
39 | m_factory = new MetaFactory(); | 39 | m_factory = new MetaFactory(); |
40 | Default def(m_factory); | 40 | Default def(m_factory); |
41 | m_sessions.setAutoDelete( TRUE ); | 41 | m_sessions.setAutoDelete( TRUE ); |
42 | m_curSession = 0; | 42 | m_curSession = 0; |
43 | m_manager = new ProfileManager( m_factory ); | 43 | m_manager = new ProfileManager( m_factory ); |
44 | m_manager->load(); | 44 | m_manager->load(); |
45 | 45 | ||
46 | initUI(); | 46 | initUI(); |
47 | populateProfiles(); | 47 | populateProfiles(); |
48 | } | 48 | } |
49 | void MainWindow::initUI() { | 49 | void MainWindow::initUI() { |
50 | setToolBarsMovable( FALSE ); | 50 | setToolBarsMovable( FALSE ); |
51 | 51 | ||
52 | /* tool bar for the menu */ | 52 | /* tool bar for the menu */ |
53 | m_tool = new QToolBar( this ); | 53 | m_tool = new QToolBar( this ); |
54 | m_tool->setHorizontalStretchable( TRUE ); | 54 | m_tool->setHorizontalStretchable( TRUE ); |
55 | 55 | ||
56 | m_bar = new QMenuBar( m_tool ); | 56 | m_bar = new QMenuBar( m_tool ); |
57 | m_console = new QPopupMenu( this ); | 57 | m_console = new QPopupMenu( this ); |
58 | m_scripts = new QPopupMenu( this ); | 58 | m_scripts = new QPopupMenu( this ); |
59 | m_sessionsPop= new QPopupMenu( this ); | 59 | m_sessionsPop= new QPopupMenu( this ); |
60 | //m_settings = new QPopupMenu( this ); | 60 | //m_settings = new QPopupMenu( this ); |
61 | 61 | ||
62 | /* add a toolbar for icons */ | 62 | /* add a toolbar for icons */ |
63 | m_icons = new QToolBar(this); | 63 | m_icons = new QToolBar(this); |
64 | 64 | ||
65 | 65 | ||
66 | 66 | ||
67 | 67 | ||
68 | /* | 68 | /* |
69 | * the settings action | 69 | * the settings action |
70 | */ | 70 | */ |
71 | m_setProfiles = new QAction(tr("Configure Profiles"), | 71 | m_setProfiles = new QAction(tr("Configure Profiles"), |
72 | Resource::loadPixmap( "SettingsIcon" ), | 72 | Resource::loadPixmap( "SettingsIcon" ), |
73 | QString::null, 0, this, 0); | 73 | QString::null, 0, this, 0); |
74 | // m_setProfiles->addTo( m_settings ); | 74 | // m_setProfiles->addTo( m_settings ); |
75 | m_setProfiles->addTo( m_icons ); | 75 | m_setProfiles->addTo( m_icons ); |
76 | m_setProfiles->addTo( m_console ); | 76 | m_setProfiles->addTo( m_console ); |
77 | connect( m_setProfiles, SIGNAL(activated() ), | 77 | connect( m_setProfiles, SIGNAL(activated() ), |
78 | this, SLOT(slotConfigure() ) ); | 78 | this, SLOT(slotConfigure() ) ); |
79 | 79 | ||
80 | m_console->insertSeparator(); | 80 | m_console->insertSeparator(); |
81 | /* | 81 | /* |
82 | * new Action for new sessions | 82 | * new Action for new sessions |
83 | */ | 83 | */ |
84 | QAction* a = new QAction(tr("New Connection"), | 84 | QAction* a = new QAction(tr("New Connection"), |
85 | Resource::loadPixmap( "new" ), | 85 | Resource::loadPixmap( "new" ), |
86 | QString::null, 0, this, 0); | 86 | QString::null, 0, this, 0); |
87 | a->addTo( m_console ); | 87 | a->addTo( m_console ); |
88 | a->addTo( m_icons ); | 88 | a->addTo( m_icons ); |
89 | connect(a, SIGNAL(activated() ), | 89 | connect(a, SIGNAL(activated() ), |
90 | this, SLOT(slotNew() ) ); | 90 | this, SLOT(slotNew() ) ); |
91 | 91 | ||
92 | /* | 92 | /* |
93 | * connect action | 93 | * connect action |
94 | */ | 94 | */ |
95 | m_connect = new QAction(); | 95 | m_connect = new QAction(); |
96 | m_connect->setText( tr("Connect") ); | 96 | m_connect->setText( tr("Connect") ); |
97 | m_connect->addTo( m_console ); | 97 | m_connect->addTo( m_console ); |
98 | connect(m_connect, SIGNAL(activated() ), | 98 | connect(m_connect, SIGNAL(activated() ), |
99 | this, SLOT(slotConnect() ) ); | 99 | this, SLOT(slotConnect() ) ); |
100 | 100 | ||
101 | /* | 101 | /* |
102 | * disconnect action | 102 | * disconnect action |
103 | */ | 103 | */ |
104 | m_disconnect = new QAction(); | 104 | m_disconnect = new QAction(); |
105 | m_disconnect->setText( tr("Disconnect") ); | 105 | m_disconnect->setText( tr("Disconnect") ); |
106 | m_disconnect->addTo( m_console ); | 106 | m_disconnect->addTo( m_console ); |
107 | connect(m_disconnect, SIGNAL(activated() ), | 107 | connect(m_disconnect, SIGNAL(activated() ), |
108 | this, SLOT(slotDisconnect() ) ); | 108 | this, SLOT(slotDisconnect() ) ); |
109 | 109 | ||
110 | m_console->insertSeparator(); | 110 | m_console->insertSeparator(); |
111 | 111 | ||
112 | m_transfer = new QAction(); | 112 | m_transfer = new QAction(); |
113 | m_transfer->setText( tr("Transfer file...") ); | 113 | m_transfer->setText( tr("Transfer file...") ); |
114 | m_transfer->addTo( m_console ); | 114 | m_transfer->addTo( m_console ); |
115 | connect(m_transfer, SIGNAL(activated() ), | 115 | connect(m_transfer, SIGNAL(activated() ), |
116 | this, SLOT(slotTransfer() ) ); | 116 | this, SLOT(slotTransfer() ) ); |
117 | 117 | ||
118 | 118 | ||
119 | /* | 119 | /* |
120 | * fullscreen | 120 | * fullscreen |
121 | */ | 121 | */ |
122 | m_isFullscreen = false; | 122 | m_isFullscreen = false; |
123 | 123 | ||
124 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) | 124 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) |
125 | , QString::null, 0, this, 0); | 125 | , QString::null, 0, this, 0); |
126 | m_fullscreen->addTo( m_console ); | 126 | m_fullscreen->addTo( m_console ); |
127 | m_fullscreen->addTo( m_icons ); | 127 | m_fullscreen->addTo( m_icons ); |
128 | connect( m_fullscreen, SIGNAL( activated() ), | 128 | connect( m_fullscreen, SIGNAL( activated() ), |
129 | this, SLOT( slotFullscreen() ) ); | 129 | this, SLOT( slotFullscreen() ) ); |
130 | 130 | ||
131 | m_console->insertSeparator(); | 131 | m_console->insertSeparator(); |
132 | /* | 132 | /* |
133 | * terminate action | 133 | * terminate action |
134 | */ | 134 | */ |
135 | m_terminate = new QAction(); | 135 | m_terminate = new QAction(); |
136 | m_terminate->setText( tr("Terminate") ); | 136 | m_terminate->setText( tr("Terminate") ); |
137 | m_terminate->addTo( m_console ); | 137 | m_terminate->addTo( m_console ); |
138 | connect(m_terminate, SIGNAL(activated() ), | 138 | connect(m_terminate, SIGNAL(activated() ), |
139 | this, SLOT(slotTerminate() ) ); | 139 | this, SLOT(slotTerminate() ) ); |
140 | 140 | ||
141 | m_closewindow = new QAction(); | 141 | m_closewindow = new QAction(); |
142 | m_closewindow->setText( tr("Close Window") ); | 142 | m_closewindow->setText( tr("Close Window") ); |
143 | m_closewindow->addTo( m_console ); | 143 | m_closewindow->addTo( m_console ); |
144 | connect( m_closewindow, SIGNAL(activated() ), | 144 | connect( m_closewindow, SIGNAL(activated() ), |
145 | this, SLOT(slotClose() ) ); | 145 | this, SLOT(slotClose() ) ); |
146 | 146 | ||
147 | 147 | ||
148 | /* | 148 | /* |
149 | * script actions | 149 | * script actions |
150 | */ | 150 | */ |
151 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); | 151 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); |
152 | m_recordScript->addTo(m_scripts); | 152 | m_recordScript->addTo(m_scripts); |
153 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); | 153 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); |
154 | 154 | ||
155 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); | 155 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); |
156 | m_saveScript->addTo(m_scripts); | 156 | m_saveScript->addTo(m_scripts); |
157 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); | 157 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); |
158 | 158 | ||
159 | m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); | 159 | m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); |
160 | m_runScript->addTo(m_scripts); | 160 | m_runScript->addTo(m_scripts); |
161 | connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); | 161 | connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); |
162 | 162 | ||
163 | /* | 163 | /* |
164 | * action that open/closes the keyboard | 164 | * action that open/closes the keyboard |
165 | */ | 165 | */ |
166 | m_openKeys = new QAction (tr("Open Keyboard..."), | 166 | m_openKeys = new QAction (tr("Open Keyboard..."), |
167 | Resource::loadPixmap( "console/keyboard_icon.png" ), | 167 | Resource::loadPixmap( "console/keyboard_icon.png" ), |
168 | QString::null, 0, this, 0); | 168 | QString::null, 0, this, 0); |
169 | 169 | ||
170 | m_openKeys->setToggleAction(true); | 170 | m_openKeys->setToggleAction(true); |
171 | 171 | ||
172 | connect (m_openKeys, SIGNAL(toggled(bool)), | 172 | connect (m_openKeys, SIGNAL(toggled(bool)), |
173 | this, SLOT(slotOpenKeb(bool))); | 173 | this, SLOT(slotOpenKeb(bool))); |
174 | m_openKeys->addTo(m_icons); | 174 | m_openKeys->addTo(m_icons); |
175 | 175 | ||
176 | 176 | ||
177 | /* | 177 | /* |
178 | * action that open/closes the keyboard | 178 | * action that open/closes the keyboard |
179 | */ | 179 | */ |
180 | m_openButtons = new QAction ( tr( "Open Buttons..." ), | 180 | m_openButtons = new QAction ( tr( "Open Buttons..." ), |
181 | Resource::loadPixmap( "down" ), | 181 | Resource::loadPixmap( "down" ), |
182 | QString::null, 0, this, 0 ); | 182 | QString::null, 0, this, 0 ); |
183 | 183 | ||
184 | m_openButtons->setToggleAction( true ); | 184 | m_openButtons->setToggleAction( true ); |
185 | 185 | ||
186 | connect ( m_openButtons, SIGNAL( toggled( bool ) ), | 186 | connect ( m_openButtons, SIGNAL( toggled( bool ) ), |
187 | this, SLOT( slotOpenButtons( bool ) ) ); | 187 | this, SLOT( slotOpenButtons( bool ) ) ); |
188 | m_openButtons->addTo( m_icons ); | 188 | m_openButtons->addTo( m_icons ); |
189 | 189 | ||
190 | 190 | ||
191 | /* insert the submenu */ | 191 | /* insert the submenu */ |
192 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 192 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
193 | -1, 0); | 193 | -1, 0); |
194 | 194 | ||
195 | /* insert the connection menu */ | 195 | /* insert the connection menu */ |
196 | m_bar->insertItem( tr("Connection"), m_console ); | 196 | m_bar->insertItem( tr("Connection"), m_console ); |
197 | 197 | ||
198 | /* the scripts menu */ | 198 | /* the scripts menu */ |
199 | m_bar->insertItem( tr("Scripts"), m_scripts ); | 199 | m_bar->insertItem( tr("Scripts"), m_scripts ); |
200 | 200 | ||
201 | /* the settings menu */ | 201 | /* the settings menu */ |
202 | // m_bar->insertItem( tr("Settings"), m_settings ); | 202 | // m_bar->insertItem( tr("Settings"), m_settings ); |
203 | 203 | ||
204 | /* and the keyboard */ | 204 | /* and the keyboard */ |
205 | m_keyBar = new QToolBar(this); | 205 | m_keyBar = new QToolBar(this); |
206 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | 206 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); |
207 | m_keyBar->setHorizontalStretchable( TRUE ); | 207 | m_keyBar->setHorizontalStretchable( TRUE ); |
208 | m_keyBar->hide(); | 208 | m_keyBar->hide(); |
209 | 209 | ||
210 | m_kb = new FunctionKeyboard(m_keyBar); | 210 | m_kb = new FunctionKeyboard(m_keyBar); |
211 | connect(m_kb, SIGNAL(keyPressed(ushort, ushort, bool, bool, bool, ushort, ushort)), | 211 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), |
212 | this, SLOT(slotKeyReceived(ushort, ushort, bool, bool, bool, ushort, ushort))); | 212 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); |
213 | 213 | ||
214 | m_buttonBar = new QToolBar( this ); | 214 | m_buttonBar = new QToolBar( this ); |
215 | addToolBar( m_buttonBar, "Buttons", QMainWindow::Top, TRUE ); | 215 | addToolBar( m_buttonBar, "Buttons", QMainWindow::Top, TRUE ); |
216 | m_buttonBar->setHorizontalStretchable( TRUE ); | 216 | m_buttonBar->setHorizontalStretchable( TRUE ); |
217 | m_buttonBar->hide(); | 217 | m_buttonBar->hide(); |
218 | 218 | ||
219 | /* | ||
219 | m_qb = new QuickButton( m_buttonBar ); | 220 | m_qb = new QuickButton( m_buttonBar ); |
220 | connect( m_qb, SIGNAL( keyPressed( ushort, ushort, bool, bool, bool) ), | 221 | connect( m_qb, SIGNAL( keyPressed( ushort, ushort, bool, bool, bool) ), |
221 | this, SLOT( slotKeyReceived( ushort, ushort, bool, bool, bool) ) ); | 222 | this, SLOT( slotKeyReceived( ushort, ushort, bool, bool, bool) ) ); |
223 | */ | ||
222 | 224 | ||
223 | 225 | ||
224 | m_connect->setEnabled( false ); | 226 | m_connect->setEnabled( false ); |
225 | m_disconnect->setEnabled( false ); | 227 | m_disconnect->setEnabled( false ); |
226 | m_terminate->setEnabled( false ); | 228 | m_terminate->setEnabled( false ); |
227 | m_transfer->setEnabled( false ); | 229 | m_transfer->setEnabled( false ); |
228 | m_recordScript->setEnabled( false ); | 230 | m_recordScript->setEnabled( false ); |
229 | m_saveScript->setEnabled( false ); | 231 | m_saveScript->setEnabled( false ); |
230 | m_runScript->setEnabled( false ); | 232 | m_runScript->setEnabled( false ); |
231 | m_fullscreen->setEnabled( false ); | 233 | m_fullscreen->setEnabled( false ); |
232 | m_closewindow->setEnabled( false ); | 234 | m_closewindow->setEnabled( false ); |
233 | 235 | ||
234 | /* | 236 | /* |
235 | * connect to the menu activation | 237 | * connect to the menu activation |
236 | */ | 238 | */ |
237 | connect( m_sessionsPop, SIGNAL(activated( int ) ), | 239 | connect( m_sessionsPop, SIGNAL(activated( int ) ), |
238 | this, SLOT(slotProfile( int ) ) ); | 240 | this, SLOT(slotProfile( int ) ) ); |
239 | 241 | ||
240 | m_consoleWindow = new TabWidget( this, "blah"); | 242 | m_consoleWindow = new TabWidget( this, "blah"); |
241 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), | 243 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), |
242 | this, SLOT(slotSessionChanged(Session*) ) ); | 244 | this, SLOT(slotSessionChanged(Session*) ) ); |
243 | setCentralWidget( m_consoleWindow ); | 245 | setCentralWidget( m_consoleWindow ); |
244 | 246 | ||
245 | } | 247 | } |
246 | 248 | ||
247 | ProfileManager* MainWindow::manager() { | 249 | ProfileManager* MainWindow::manager() { |
248 | return m_manager; | 250 | return m_manager; |
249 | } | 251 | } |
250 | TabWidget* MainWindow::tabWidget() { | 252 | TabWidget* MainWindow::tabWidget() { |
251 | return m_consoleWindow; | 253 | return m_consoleWindow; |
252 | } | 254 | } |
253 | void MainWindow::populateProfiles() { | 255 | void MainWindow::populateProfiles() { |
254 | m_sessionsPop->clear(); | 256 | m_sessionsPop->clear(); |
255 | Profile::ValueList list = manager()->all(); | 257 | Profile::ValueList list = manager()->all(); |
256 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 258 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
257 | m_sessionsPop->insertItem( (*it).name() ); | 259 | m_sessionsPop->insertItem( (*it).name() ); |
258 | } | 260 | } |
259 | 261 | ||
260 | } | 262 | } |
261 | MainWindow::~MainWindow() { | 263 | MainWindow::~MainWindow() { |
262 | delete m_factory; | 264 | delete m_factory; |
263 | manager()->save(); | 265 | manager()->save(); |
264 | } | 266 | } |
265 | 267 | ||
266 | MetaFactory* MainWindow::factory() { | 268 | MetaFactory* MainWindow::factory() { |
267 | return m_factory; | 269 | return m_factory; |
268 | } | 270 | } |
269 | 271 | ||
270 | Session* MainWindow::currentSession() { | 272 | Session* MainWindow::currentSession() { |
271 | return m_curSession; | 273 | return m_curSession; |
272 | } | 274 | } |
273 | 275 | ||
274 | QList<Session> MainWindow::sessions() { | 276 | QList<Session> MainWindow::sessions() { |
275 | return m_sessions; | 277 | return m_sessions; |
276 | } | 278 | } |
277 | 279 | ||
278 | void MainWindow::slotNew() { | 280 | void MainWindow::slotNew() { |
279 | ProfileEditorDialog dlg(factory() ); | 281 | ProfileEditorDialog dlg(factory() ); |
280 | dlg.showMaximized(); | 282 | dlg.showMaximized(); |
281 | int ret = dlg.exec(); | 283 | int ret = dlg.exec(); |
282 | 284 | ||
283 | if ( ret == QDialog::Accepted ) { | 285 | if ( ret == QDialog::Accepted ) { |
284 | create( dlg.profile() ); | 286 | create( dlg.profile() ); |
285 | } | 287 | } |
286 | } | 288 | } |
287 | 289 | ||
288 | void MainWindow::slotRecordScript() { | 290 | void MainWindow::slotRecordScript() { |
289 | if (currentSession()) { | 291 | if (currentSession()) { |
290 | currentSession()->emulationHandler()->startRecording(); | 292 | currentSession()->emulationHandler()->startRecording(); |
291 | } | 293 | } |
292 | } | 294 | } |
293 | 295 | ||
294 | void MainWindow::slotSaveScript() { | 296 | void MainWindow::slotSaveScript() { |
295 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { | 297 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { |
296 | MimeTypes types; | 298 | MimeTypes types; |
297 | QStringList script; | 299 | QStringList script; |
298 | script << "text/plain"; | 300 | script << "text/plain"; |
299 | script << "text/all"; | 301 | script << "text/all"; |
300 | script << "application/octet-stream"; | 302 | script << "application/octet-stream"; |
301 | types.insert("Script", script); | 303 | types.insert("Script", script); |
302 | QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); | 304 | QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); |
303 | if (!filename.isEmpty()) { | 305 | if (!filename.isEmpty()) { |
304 | currentSession()->emulationHandler()->script()->saveTo(filename); | 306 | currentSession()->emulationHandler()->script()->saveTo(filename); |
305 | currentSession()->emulationHandler()->clearScript(); | 307 | currentSession()->emulationHandler()->clearScript(); |
306 | } | 308 | } |
307 | } | 309 | } |
308 | } | 310 | } |
309 | 311 | ||
310 | void MainWindow::slotRunScript() { | 312 | void MainWindow::slotRunScript() { |
311 | if (currentSession()) { | 313 | if (currentSession()) { |
312 | MimeTypes types; | 314 | MimeTypes types; |
313 | QStringList script; | 315 | QStringList script; |
314 | script << "text/plain"; | 316 | script << "text/plain"; |
315 | script << "text/all"; | 317 | script << "text/all"; |
316 | script << "application/octet-stream"; | 318 | script << "application/octet-stream"; |
317 | types.insert("Script", script); | 319 | types.insert("Script", script); |
318 | QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); | 320 | QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); |
319 | if (!filename.isEmpty()) { | 321 | if (!filename.isEmpty()) { |
320 | Script script(DocLnk(filename).file()); | 322 | Script script(DocLnk(filename).file()); |
321 | currentSession()->emulationHandler()->runScript(&script); | 323 | currentSession()->emulationHandler()->runScript(&script); |
322 | } | 324 | } |
323 | } | 325 | } |
324 | } | 326 | } |
325 | 327 | ||
326 | void MainWindow::slotConnect() { | 328 | void MainWindow::slotConnect() { |
327 | if ( currentSession() ) { | 329 | if ( currentSession() ) { |
328 | bool ret = currentSession()->layer()->open(); | 330 | bool ret = currentSession()->layer()->open(); |
329 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), | 331 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), |
330 | QObject::tr("Failed"), | 332 | QObject::tr("Failed"), |
331 | QObject::tr("Connecting failed for this session.")); | 333 | QObject::tr("Connecting failed for this session.")); |
332 | else { | 334 | else { |
333 | m_connect->setEnabled( false ); | 335 | m_connect->setEnabled( false ); |
334 | m_disconnect->setEnabled( true ); | 336 | m_disconnect->setEnabled( true ); |
335 | } | 337 | } |
336 | } | 338 | } |
337 | } | 339 | } |
338 | 340 | ||
339 | void MainWindow::slotDisconnect() { | 341 | void MainWindow::slotDisconnect() { |
340 | if ( currentSession() ) { | 342 | if ( currentSession() ) { |
341 | currentSession()->layer()->close(); | 343 | currentSession()->layer()->close(); |
342 | m_connect->setEnabled( true ); | 344 | m_connect->setEnabled( true ); |
343 | m_disconnect->setEnabled( false ); | 345 | m_disconnect->setEnabled( false ); |
344 | } | 346 | } |
345 | } | 347 | } |
346 | 348 | ||
347 | void MainWindow::slotTerminate() { | 349 | void MainWindow::slotTerminate() { |
348 | if ( currentSession() ) | 350 | if ( currentSession() ) |
349 | currentSession()->layer()->close(); | 351 | currentSession()->layer()->close(); |
350 | 352 | ||
351 | slotClose(); | 353 | slotClose(); |
352 | /* FIXME move to the next session */ | 354 | /* FIXME move to the next session */ |
353 | } | 355 | } |
354 | 356 | ||
355 | void MainWindow::slotConfigure() { | 357 | void MainWindow::slotConfigure() { |
356 | ConfigDialog conf( manager()->all(), factory() ); | 358 | ConfigDialog conf( manager()->all(), factory() ); |
357 | conf.showMaximized(); | 359 | conf.showMaximized(); |
358 | 360 | ||
359 | int ret = conf.exec(); | 361 | int ret = conf.exec(); |
360 | 362 | ||
361 | if ( QDialog::Accepted == ret ) { | 363 | if ( QDialog::Accepted == ret ) { |
362 | manager()->setProfiles( conf.list() ); | 364 | manager()->setProfiles( conf.list() ); |
363 | manager()->save(); | 365 | manager()->save(); |
364 | populateProfiles(); | 366 | populateProfiles(); |
365 | } | 367 | } |
366 | } | 368 | } |
367 | /* | 369 | /* |
368 | * we will remove | 370 | * we will remove |
369 | * this window from the tabwidget | 371 | * this window from the tabwidget |
370 | * remove it from the list | 372 | * remove it from the list |
371 | * delete it | 373 | * delete it |
372 | * and set the currentSession() | 374 | * and set the currentSession() |
373 | */ | 375 | */ |
374 | void MainWindow::slotClose() { | 376 | void MainWindow::slotClose() { |
375 | if (!currentSession() ) | 377 | if (!currentSession() ) |
376 | return; | 378 | return; |
377 | 379 | ||
378 | Session* ses = currentSession(); | 380 | Session* ses = currentSession(); |
379 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); | 381 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); |
380 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ | 382 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ |
381 | m_curSession = NULL; | 383 | m_curSession = NULL; |
382 | tabWidget()->remove( /*currentSession()*/ses ); | 384 | tabWidget()->remove( /*currentSession()*/ses ); |
383 | /*it's autodelete */ | 385 | /*it's autodelete */ |
384 | m_sessions.remove( ses ); | 386 | m_sessions.remove( ses ); |
385 | qWarning("after remove!!"); | 387 | qWarning("after remove!!"); |
386 | 388 | ||
387 | if (!currentSession() ) { | 389 | if (!currentSession() ) { |
388 | m_connect->setEnabled( false ); | 390 | m_connect->setEnabled( false ); |
389 | m_disconnect->setEnabled( false ); | 391 | m_disconnect->setEnabled( false ); |
390 | m_terminate->setEnabled( false ); | 392 | m_terminate->setEnabled( false ); |
391 | m_transfer->setEnabled( false ); | 393 | m_transfer->setEnabled( false ); |
392 | m_recordScript->setEnabled( false ); | 394 | m_recordScript->setEnabled( false ); |
393 | m_saveScript->setEnabled( false ); | 395 | m_saveScript->setEnabled( false ); |
394 | m_runScript->setEnabled( false ); | 396 | m_runScript->setEnabled( false ); |
395 | m_fullscreen->setEnabled( false ); | 397 | m_fullscreen->setEnabled( false ); |
396 | m_closewindow->setEnabled( false ); | 398 | m_closewindow->setEnabled( false ); |
397 | } | 399 | } |
398 | } | 400 | } |
399 | 401 | ||
400 | /* | 402 | /* |
401 | * We will get the name | 403 | * We will get the name |
402 | * Then the profile | 404 | * Then the profile |
403 | * and then we will make a profile | 405 | * and then we will make a profile |
404 | */ | 406 | */ |
405 | void MainWindow::slotProfile( int id) { | 407 | void MainWindow::slotProfile( int id) { |
406 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 408 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
407 | create( prof ); | 409 | create( prof ); |
408 | } | 410 | } |
409 | void MainWindow::create( const Profile& prof ) { | 411 | void MainWindow::create( const Profile& prof ) { |
410 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 412 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
411 | 413 | ||
412 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) | 414 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) |
413 | { | 415 | { |
414 | QMessageBox::warning(this, | 416 | QMessageBox::warning(this, |
415 | QObject::tr("Session failed"), | 417 | QObject::tr("Session failed"), |
416 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); | 418 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); |
417 | //if(ses) delete ses; | 419 | //if(ses) delete ses; |
418 | return; | 420 | return; |
419 | } | 421 | } |
420 | 422 | ||
421 | m_sessions.append( ses ); | 423 | m_sessions.append( ses ); |
422 | tabWidget()->add( ses ); | 424 | tabWidget()->add( ses ); |
423 | m_curSession = ses; | 425 | m_curSession = ses; |
424 | 426 | ||
425 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it | 427 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it |
426 | m_connect->setEnabled( true ); | 428 | m_connect->setEnabled( true ); |
427 | m_disconnect->setEnabled( false ); | 429 | m_disconnect->setEnabled( false ); |
428 | m_terminate->setEnabled( true ); | 430 | m_terminate->setEnabled( true ); |
429 | m_transfer->setEnabled( true ); | 431 | m_transfer->setEnabled( true ); |
430 | m_recordScript->setEnabled( true ); | 432 | m_recordScript->setEnabled( true ); |
431 | m_saveScript->setEnabled( true ); | 433 | m_saveScript->setEnabled( true ); |
432 | m_runScript->setEnabled( true ); | 434 | m_runScript->setEnabled( true ); |
433 | m_fullscreen->setEnabled( true ); | 435 | m_fullscreen->setEnabled( true ); |
434 | m_closewindow->setEnabled( true ); | 436 | m_closewindow->setEnabled( true ); |
435 | 437 | ||
436 | 438 | ||
437 | // is io_layer wants direct connection, then autoconnect | 439 | // is io_layer wants direct connection, then autoconnect |
438 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { | 440 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { |
439 | if (prof.autoConnect()) { | 441 | if (prof.autoConnect()) { |
440 | slotConnect(); | 442 | slotConnect(); |
441 | } | 443 | } |
442 | 444 | ||
443 | QWidget *w = currentSession()->widget(); | 445 | QWidget *w = currentSession()->widget(); |
444 | if(w) w->setFocus(); | 446 | if(w) w->setFocus(); |
445 | } | 447 | } |
446 | 448 | ||
447 | void MainWindow::slotTransfer() | 449 | void MainWindow::slotTransfer() |
448 | { | 450 | { |
449 | if ( currentSession() ) { | 451 | if ( currentSession() ) { |
450 | TransferDialog dlg(currentSession()->widgetStack(), this); | 452 | TransferDialog dlg(currentSession()->widgetStack(), this); |
451 | dlg.showMaximized(); | 453 | dlg.showMaximized(); |
452 | //currentSession()->widgetStack()->add(dlg); | 454 | //currentSession()->widgetStack()->add(dlg); |
453 | dlg.exec(); | 455 | dlg.exec(); |
454 | } | 456 | } |
455 | } | 457 | } |
456 | 458 | ||
457 | 459 | ||
458 | void MainWindow::slotOpenKeb(bool state) { | 460 | void MainWindow::slotOpenKeb(bool state) { |
459 | 461 | ||
460 | if (state) m_keyBar->show(); | 462 | if (state) m_keyBar->show(); |
461 | else m_keyBar->hide(); | 463 | else m_keyBar->hide(); |
462 | 464 | ||
463 | } | 465 | } |
464 | 466 | ||
465 | 467 | ||
466 | void MainWindow::slotOpenButtons( bool state ) { | 468 | void MainWindow::slotOpenButtons( bool state ) { |
467 | 469 | ||
468 | if ( state ) { | 470 | if ( state ) { |
469 | m_buttonBar->show(); | 471 | m_buttonBar->show(); |
470 | } else { | 472 | } else { |
471 | m_buttonBar->hide(); | 473 | m_buttonBar->hide(); |
472 | } | 474 | } |
473 | } | 475 | } |
474 | 476 | ||
475 | 477 | ||
476 | 478 | ||
477 | void MainWindow::slotSessionChanged( Session* ses ) { | 479 | void MainWindow::slotSessionChanged( Session* ses ) { |
478 | qWarning("changed!"); | 480 | qWarning("changed!"); |
479 | if ( ses ) { | 481 | if ( ses ) { |
480 | m_curSession = ses; | 482 | m_curSession = ses; |
481 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); | 483 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); |
482 | if ( m_curSession->layer()->isConnected() ) { | 484 | if ( m_curSession->layer()->isConnected() ) { |
483 | m_connect->setEnabled( false ); | 485 | m_connect->setEnabled( false ); |
484 | m_disconnect->setEnabled( true ); | 486 | m_disconnect->setEnabled( true ); |
485 | } else { | 487 | } else { |
486 | m_connect->setEnabled( true ); | 488 | m_connect->setEnabled( true ); |
487 | m_disconnect->setEnabled( false ); | 489 | m_disconnect->setEnabled( false ); |
488 | } | 490 | } |
489 | 491 | ||
490 | QWidget *w = m_curSession->widget(); | 492 | QWidget *w = m_curSession->widget(); |
491 | if(w) w->setFocus(); | 493 | if(w) w->setFocus(); |
492 | } | 494 | } |
493 | } | 495 | } |
494 | 496 | ||
495 | void MainWindow::slotFullscreen() { | 497 | void MainWindow::slotFullscreen() { |
496 | 498 | ||
497 | 499 | ||
498 | 500 | ||
499 | if ( m_isFullscreen ) { | 501 | if ( m_isFullscreen ) { |
500 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); | 502 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); |
501 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); | 503 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); |
502 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); | 504 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); |
503 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 505 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
504 | 506 | ||
505 | } else { | 507 | } else { |
506 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); | 508 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); |
507 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); | 509 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); |
508 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | 510 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop |
509 | , QPoint(0,0), false ); | 511 | , QPoint(0,0), false ); |
510 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); | 512 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); |
511 | ( m_curSession->widgetStack() )->setFocus(); | 513 | ( m_curSession->widgetStack() )->setFocus(); |
512 | ( m_curSession->widgetStack() )->show(); | 514 | ( m_curSession->widgetStack() )->show(); |
513 | 515 | ||
514 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); | 516 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); |
515 | 517 | ||
516 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 518 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
517 | } | 519 | } |
518 | 520 | ||
519 | m_isFullscreen = !m_isFullscreen; | 521 | m_isFullscreen = !m_isFullscreen; |
520 | } | 522 | } |
521 | 523 | ||
522 | 524 | ||
523 | void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool pressed, bool, ushort, ushort) { | 525 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { |
524 | |||
525 | //qWarning("unicode: %x, qkey: %x, %s", u, q, pressed ? "pressed" : "released"); | ||
526 | 526 | ||
527 | if ( m_curSession ) { | 527 | if ( m_curSession ) { |
528 | 528 | ||
529 | QEvent::Type state; | 529 | QEvent::Type state; |
530 | 530 | ||
531 | if (pressed) state = QEvent::KeyPress; | 531 | if (pressed) state = QEvent::KeyPress; |
532 | else state = QEvent::KeyRelease; | 532 | else state = QEvent::KeyRelease; |
533 | 533 | ||
534 | QKeyEvent ke(state, q, u, 0, QString(QChar(u))); | 534 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); |
535 | 535 | ||
536 | // where should i send this event? doesnt work sending it here | 536 | // where should i send this event? doesnt work sending it here |
537 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); | 537 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); |
538 | ke.ignore(); | 538 | ke.ignore(); |
539 | } | 539 | } |
540 | } | 540 | } |
diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h index 68f6fa8..0f52e76 100644 --- a/noncore/apps/opie-console/mainwindow.h +++ b/noncore/apps/opie-console/mainwindow.h | |||
@@ -1,123 +1,124 @@ | |||
1 | #ifndef OPIE_MAIN_WINDOW_H | 1 | #ifndef OPIE_MAIN_WINDOW_H |
2 | #define OPIE_MAIN_WINDOW_H | 2 | #define OPIE_MAIN_WINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | #include <qlist.h> | 5 | #include <qlist.h> |
6 | 6 | ||
7 | #include "session.h" | 7 | #include "session.h" |
8 | 8 | ||
9 | /** | 9 | /** |
10 | * this is the MainWindow of the new opie console | 10 | * this is the MainWindow of the new opie console |
11 | * it's also the dispatcher between the different | 11 | * it's also the dispatcher between the different |
12 | * actions supported by the gui | 12 | * actions supported by the gui |
13 | */ | 13 | */ |
14 | class QToolBar; | 14 | class QToolBar; |
15 | class QToolButton; | 15 | class QToolButton; |
16 | class QMenuBar; | 16 | class QMenuBar; |
17 | class QAction; | 17 | class QAction; |
18 | class MetaFactory; | 18 | class MetaFactory; |
19 | class TabWidget; | 19 | class TabWidget; |
20 | class ProfileManager; | 20 | class ProfileManager; |
21 | class Profile; | 21 | class Profile; |
22 | class FunctionKeyboard; | 22 | class FunctionKeyboard; |
23 | class FKey; | ||
23 | class QuickButton; | 24 | class QuickButton; |
24 | 25 | ||
25 | class MainWindow : public QMainWindow { | 26 | class MainWindow : public QMainWindow { |
26 | Q_OBJECT | 27 | Q_OBJECT |
27 | public: | 28 | public: |
28 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); | 29 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); |
29 | ~MainWindow(); | 30 | ~MainWindow(); |
30 | 31 | ||
31 | /** | 32 | /** |
32 | * our factory to generate IOLayer and so on | 33 | * our factory to generate IOLayer and so on |
33 | * | 34 | * |
34 | */ | 35 | */ |
35 | MetaFactory* factory(); | 36 | MetaFactory* factory(); |
36 | 37 | ||
37 | /** | 38 | /** |
38 | * A session contains a QWidget*, | 39 | * A session contains a QWidget*, |
39 | * an IOLayer* and some infos for us | 40 | * an IOLayer* and some infos for us |
40 | */ | 41 | */ |
41 | Session* currentSession(); | 42 | Session* currentSession(); |
42 | 43 | ||
43 | /** | 44 | /** |
44 | * the session list | 45 | * the session list |
45 | */ | 46 | */ |
46 | QList<Session> sessions(); | 47 | QList<Session> sessions(); |
47 | 48 | ||
48 | /** | 49 | /** |
49 | * | 50 | * |
50 | */ | 51 | */ |
51 | ProfileManager* manager(); | 52 | ProfileManager* manager(); |
52 | TabWidget* tabWidget(); | 53 | TabWidget* tabWidget(); |
53 | 54 | ||
54 | private slots: | 55 | private slots: |
55 | void slotNew(); | 56 | void slotNew(); |
56 | void slotConnect(); | 57 | void slotConnect(); |
57 | void slotDisconnect(); | 58 | void slotDisconnect(); |
58 | void slotTerminate(); | 59 | void slotTerminate(); |
59 | void slotConfigure(); | 60 | void slotConfigure(); |
60 | void slotClose(); | 61 | void slotClose(); |
61 | void slotProfile(int); | 62 | void slotProfile(int); |
62 | void slotTransfer(); | 63 | void slotTransfer(); |
63 | void slotOpenKeb(bool); | 64 | void slotOpenKeb(bool); |
64 | void slotOpenButtons(bool); | 65 | void slotOpenButtons(bool); |
65 | void slotRecordScript(); | 66 | void slotRecordScript(); |
66 | void slotSaveScript(); | 67 | void slotSaveScript(); |
67 | void slotRunScript(); | 68 | void slotRunScript(); |
68 | void slotFullscreen(); | 69 | void slotFullscreen(); |
69 | void slotSessionChanged( Session* ); | 70 | void slotSessionChanged( Session* ); |
70 | void slotKeyReceived(ushort, ushort, bool, bool, bool, ushort, ushort); | 71 | void slotKeyReceived(FKey, ushort, ushort, bool); |
71 | 72 | ||
72 | private: | 73 | private: |
73 | void initUI(); | 74 | void initUI(); |
74 | void populateProfiles(); | 75 | void populateProfiles(); |
75 | void create( const Profile& ); | 76 | void create( const Profile& ); |
76 | /** | 77 | /** |
77 | * the current session | 78 | * the current session |
78 | */ | 79 | */ |
79 | Session* m_curSession; | 80 | Session* m_curSession; |
80 | 81 | ||
81 | /** | 82 | /** |
82 | * the session list | 83 | * the session list |
83 | */ | 84 | */ |
84 | QList<Session> m_sessions; | 85 | QList<Session> m_sessions; |
85 | 86 | ||
86 | /** | 87 | /** |
87 | * the metafactory | 88 | * the metafactory |
88 | */ | 89 | */ |
89 | MetaFactory* m_factory; | 90 | MetaFactory* m_factory; |
90 | ProfileManager* m_manager; | 91 | ProfileManager* m_manager; |
91 | 92 | ||
92 | TabWidget* m_consoleWindow; | 93 | TabWidget* m_consoleWindow; |
93 | QToolBar* m_tool; | 94 | QToolBar* m_tool; |
94 | QToolBar* m_icons; | 95 | QToolBar* m_icons; |
95 | QToolBar* m_keyBar; | 96 | QToolBar* m_keyBar; |
96 | QToolBar* m_buttonBar; | 97 | QToolBar* m_buttonBar; |
97 | QMenuBar* m_bar; | 98 | QMenuBar* m_bar; |
98 | QPopupMenu* m_console; | 99 | QPopupMenu* m_console; |
99 | QPopupMenu* m_settings; | 100 | QPopupMenu* m_settings; |
100 | QPopupMenu* m_sessionsPop; | 101 | QPopupMenu* m_sessionsPop; |
101 | QPopupMenu* m_scripts; | 102 | QPopupMenu* m_scripts; |
102 | QAction* m_connect; | 103 | QAction* m_connect; |
103 | QAction* m_disconnect; | 104 | QAction* m_disconnect; |
104 | QAction* m_terminate; | 105 | QAction* m_terminate; |
105 | QAction* m_transfer; | 106 | QAction* m_transfer; |
106 | QAction* m_setProfiles; | 107 | QAction* m_setProfiles; |
107 | QAction* m_openKeys; | 108 | QAction* m_openKeys; |
108 | QAction* m_openButtons; | 109 | QAction* m_openButtons; |
109 | QAction* m_recordScript; | 110 | QAction* m_recordScript; |
110 | QAction* m_saveScript; | 111 | QAction* m_saveScript; |
111 | QAction* m_runScript; | 112 | QAction* m_runScript; |
112 | QAction* m_fullscreen; | 113 | QAction* m_fullscreen; |
113 | QAction* m_closewindow; | 114 | QAction* m_closewindow; |
114 | 115 | ||
115 | FunctionKeyboard *m_kb; | 116 | FunctionKeyboard *m_kb; |
116 | QuickButton *m_qb; | 117 | QuickButton *m_qb; |
117 | bool m_isFullscreen; | 118 | bool m_isFullscreen; |
118 | 119 | ||
119 | QWidget* savedParentFullscreen; | 120 | QWidget* savedParentFullscreen; |
120 | }; | 121 | }; |
121 | 122 | ||
122 | 123 | ||
123 | #endif | 124 | #endif |