summaryrefslogtreecommitdiff
authorhash <hash>2002-10-24 16:24:00 (UTC)
committer hash <hash>2002-10-24 16:24:00 (UTC)
commitf8875264ece878f5bb7e8e528200f6ba437138c5 (patch) (unidiff)
tree343ef25aae76316e4931f15b63938388ff0d5dd8
parent07811d76c261ece00a45589a2eb9d2bb8971943e (diff)
downloadopie-f8875264ece878f5bb7e8e528200f6ba437138c5.zip
opie-f8875264ece878f5bb7e8e528200f6ba437138c5.tar.gz
opie-f8875264ece878f5bb7e8e528200f6ba437138c5.tar.bz2
got rid of those warnings
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/function_keyboard.cpp4
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp2
2 files changed, 3 insertions, 3 deletions
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp
index fa11701..3da8d61 100644
--- a/noncore/apps/opie-console/function_keyboard.cpp
+++ b/noncore/apps/opie-console/function_keyboard.cpp
@@ -1,388 +1,388 @@
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 <qlistbox.h> 11#include <qlistbox.h>
12#include <qlabel.h> 12#include <qlabel.h>
13#include <qcombobox.h> 13#include <qcombobox.h>
14#include <qdir.h> 14#include <qdir.h>
15 15
16/* FunctionKeyboard {{{1 */ 16/* FunctionKeyboard {{{1 */
17 17
18FunctionKeyboard::FunctionKeyboard(QWidget *parent) : 18FunctionKeyboard::FunctionKeyboard(QWidget *parent) :
19 QFrame(parent), numRows(2), numCols(11), 19 QFrame(parent), numRows(2), numCols(11),
20 pressedRow(0), pressedCol(0) { 20 pressedRow(0), pressedCol(0) {
21 21
22 setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); 22 setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed));
23 23
24 /* 24 /*
25 * all the saving/loading is now done in a profile. downside is that you cant modify 25 * all the saving/loading is now done in a profile. downside is that you cant modify
26 * the keyboard for all profiles, but must do it on a profile-basis 26 * the keyboard for all profiles, but must do it on a profile-basis
27 * 27 *
28 28
29 Config conf("opie-console-keys"); 29 Config conf("opie-console-keys");
30 conf.setGroup("keys"); 30 conf.setGroup("keys");
31 for (uint r = 0; r < numRows; r++) 31 for (uint r = 0; r < numRows; r++)
32 for (uint c = 0; c < numCols; c++) { 32 for (uint c = 0; c < numCols; c++) {
33 33
34 QString handle = "r" + QString::number(r) + "c" + QString::number(c); 34 QString handle = "r" + QString::number(r) + "c" + QString::number(c);
35 QStringList value_list = conf.readListEntry( handle, '|'); 35 QStringList value_list = conf.readListEntry( handle, '|');
36 36
37 if (value_list.isEmpty()) continue; 37 if (value_list.isEmpty()) continue;
38 38
39 keys.insert( 39 keys.insert(
40 40
41 handle, 41 handle,
42 FKey (value_list[0], value_list[1], value_list[2].toUShort(), value_list[3].toUShort()) 42 FKey (value_list[0], value_list[1], value_list[2].toUShort(), value_list[3].toUShort())
43 ); 43 );
44 } 44 }
45 //qWarning("loaded %d keys", keys.count()); 45 //qWarning("loaded %d keys", keys.count());
46 */ 46 */
47 if (keys.isEmpty()) loadDefaults(); 47 if (keys.isEmpty()) loadDefaults();
48 48
49 49
50 50
51} 51}
52 52
53FunctionKeyboard::~FunctionKeyboard() {} 53FunctionKeyboard::~FunctionKeyboard() {}
54 54
55void FunctionKeyboard::changeRows(int r) { 55void FunctionKeyboard::changeRows(int r) {
56 56
57 numRows = r; 57 numRows = r;
58 repaint(false); 58 repaint(false);
59} 59}
60void FunctionKeyboard::changeCols(int c) { 60void FunctionKeyboard::changeCols(int c) {
61 61
62 numCols = c; 62 numCols = c;
63 keyWidth = (double)width()/numCols; // have to reset this thing too 63 keyWidth = (double)width()/numCols; // have to reset this thing too
64 repaint(false); 64 repaint(false);
65} 65}
66 66
67void FunctionKeyboard::paintEvent(QPaintEvent *e) { 67void FunctionKeyboard::paintEvent(QPaintEvent *e) {
68 68
69 QPainter p(this); 69 QPainter p(this);
70 p.setClipRect(e->rect()); 70 p.setClipRect(e->rect());
71 p.fillRect(0, 0, width(), height(), QColor(255,255,255)); 71 p.fillRect(0, 0, width(), height(), QColor(255,255,255));
72 72
73 p.setPen(QColor(0,0,0)); 73 p.setPen(QColor(0,0,0));
74 74
75 /* those decimals do count! becomes short if use plain int */ 75 /* those decimals do count! becomes short if use plain int */
76 for (double i = 0; i <= width(); i += keyWidth) { 76 for (double i = 0; i <= width(); i += keyWidth) {
77 77
78 p.drawLine((int)i, 0, (int)i, height()); 78 p.drawLine((int)i, 0, (int)i, height());
79 } 79 }
80 80
81 // sometimes the last line doesnt get drawn 81 // sometimes the last line doesnt get drawn
82 p.drawLine(width() -1, 0, width() -1, height()); 82 p.drawLine(width() -1, 0, width() -1, height());
83 83
84 for (int i = 0; i <= height(); i += keyHeight) { 84 for (int i = 0; i <= height(); i += keyHeight) {
85 85
86 p.drawLine(0, i, width(), i); 86 p.drawLine(0, i, width(), i);
87 } 87 }
88 88
89 for (uint r = 0; r < numRows; r++) { 89 for (uint r = 0; r < numRows; r++) {
90 for (uint c = 0; c < numCols; c++) { 90 for (uint c = 0; c < numCols; c++) {
91 91
92 QString handle = "r" + QString::number(r) + "c" + QString::number(c); 92 QString handle = "r" + QString::number(r) + "c" + QString::number(c);
93 if (keys.contains(handle)) { 93 if (keys.contains(handle)) {
94 94
95 if (keys[handle].pixFile.isEmpty()) 95 if (keys[handle].pixFile.isEmpty())
96 p.drawText( c * keyWidth + 1, r * keyHeight + 1, 96 p.drawText( c * keyWidth + 1, r * keyHeight + 1,
97 keyWidth, keyHeight, 97 keyWidth, keyHeight,
98 Qt::AlignHCenter | Qt::AlignVCenter, 98 Qt::AlignHCenter | Qt::AlignVCenter,
99 keys[handle].label 99 keys[handle].label
100 ); 100 );
101 else { 101 else {
102 102
103 ushort centerX = c *keyWidth + (keyWidth - keys[handle].pix->width()) / 2; 103 ushort centerX = (ushort)(c *keyWidth) + (ushort)(keyWidth - keys[handle].pix->width()) / 2;
104 ushort centerY = r * keyHeight + (keyHeight - keys[handle].pix->height()) / 2; 104 ushort centerY = r * keyHeight + (keyHeight - keys[handle].pix->height()) / 2;
105 p.drawPixmap(centerX, centerY, *keys[handle].pix); 105 p.drawPixmap(centerX, centerY, *keys[handle].pix);
106 } 106 }
107 } 107 }
108 } 108 }
109 } 109 }
110} 110}
111 111
112void FunctionKeyboard::paintKey(uint row, uint col) { 112void FunctionKeyboard::paintKey(uint row, uint col) {
113 113
114 QPainter p(this); 114 QPainter p(this);
115 115
116 p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1), 116 p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1),
117 QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)), 117 QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)),
118 (pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255)); 118 (pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255));
119 119
120 QString handle ("r" + QString::number(row) + "c" + QString::number(col)); 120 QString handle ("r" + QString::number(row) + "c" + QString::number(col));
121 if (keys[handle].pixFile.isEmpty()) 121 if (keys[handle].pixFile.isEmpty())
122 p.drawText( 122 p.drawText(
123 col * keyWidth + 1, row * keyHeight + 1, 123 col * keyWidth + 1, row * keyHeight + 1,
124 keyWidth, keyHeight, 124 keyWidth, keyHeight,
125 Qt::AlignHCenter | Qt::AlignVCenter, 125 Qt::AlignHCenter | Qt::AlignVCenter,
126 keys[handle].label 126 keys[handle].label
127 ); 127 );
128 else { 128 else {
129 129
130 ushort centerX = col *keyWidth + (keyWidth - keys[handle].pix->width()) / 2; 130 ushort centerX = (ushort)(col *keyWidth) + (ushort)(keyWidth - keys[handle].pix->width()) / 2;
131 ushort centerY = row * keyHeight + (keyHeight - keys[handle].pix->height()) / 2; 131 ushort centerY = row * keyHeight + (keyHeight - keys[handle].pix->height()) / 2;
132 p.drawPixmap(centerX, centerY, *keys[handle].pix); 132 p.drawPixmap(centerX, centerY, *keys[handle].pix);
133 } 133 }
134 134
135 if (col == numCols - 1) { 135 if (col == numCols - 1) {
136 136
137 // sometimes it doesnt draw the last line 137 // sometimes it doesnt draw the last line
138 138
139 p.drawLine((col+1) * keyWidth -1, row * keyHeight, 139 p.drawLine((col+1) * keyWidth -1, row * keyHeight,
140 (col+1) * keyWidth -1, (row + 1) * keyHeight 140 (col+1) * keyWidth -1, (row + 1) * keyHeight
141 ); 141 );
142 } 142 }
143 143
144} 144}
145 145
146void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { 146void FunctionKeyboard::mousePressEvent(QMouseEvent *e) {
147 147
148 pressedRow = e->y() / keyHeight; 148 pressedRow = e->y() / keyHeight;
149 pressedCol = (int) (e->x() / keyWidth); 149 pressedCol = (int) (e->x() / keyWidth);
150 150
151 paintKey(pressedRow, pressedCol); 151 paintKey(pressedRow, pressedCol);
152 152
153 // emit that sucker! 153 // emit that sucker!
154 FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; 154 FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)];
155 emit keyPressed(k, pressedRow, pressedCol, 1); 155 emit keyPressed(k, pressedRow, pressedCol, 1);
156 156
157} 157}
158 158
159void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { 159void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) {
160 160
161 if (pressedRow != -1 && pressedRow != -1) { 161 if (pressedRow != -1 && pressedRow != -1) {
162 162
163 int row = pressedRow; pressedRow = -1; 163 int row = pressedRow; pressedRow = -1;
164 int col = pressedCol; pressedCol = -1; 164 int col = pressedCol; pressedCol = -1;
165 paintKey(row, col); 165 paintKey(row, col);
166 166
167 FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; 167 FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)];
168 emit keyPressed(k, row, col, 0); 168 emit keyPressed(k, row, col, 0);
169 } 169 }
170 170
171} 171}
172 172
173 173
174void FunctionKeyboard::resizeEvent(QResizeEvent*) { 174void FunctionKeyboard::resizeEvent(QResizeEvent*) {
175 175
176 /* set he default font height/width */ 176 /* set he default font height/width */
177 QFontMetrics fm=fontMetrics(); 177 QFontMetrics fm=fontMetrics();
178 keyHeight = fm.lineSpacing() + 2; 178 keyHeight = fm.lineSpacing() + 2;
179 keyWidth = (double)width()/numCols; 179 keyWidth = (double)width()/numCols;
180 180
181} 181}
182 182
183QSize FunctionKeyboard::sizeHint() const { 183QSize FunctionKeyboard::sizeHint() const {
184 184
185 return QSize(width(), keyHeight * numRows + 1); 185 return QSize(width(), keyHeight * numRows + 1);
186} 186}
187 187
188void FunctionKeyboard::loadDefaults() { 188void FunctionKeyboard::loadDefaults() {
189 189
190 keys.insert( "r0c0", FKey ("Enter", "enter", Qt::Key_Enter, 0)); 190 keys.insert( "r0c0", FKey ("Enter", "enter", Qt::Key_Enter, 0));
191 keys.insert( "r0c1", FKey ("Space", "space", Qt::Key_Space, Qt::Key_Space)); 191 keys.insert( "r0c1", FKey ("Space", "space", Qt::Key_Space, Qt::Key_Space));
192 keys.insert( "r0c2", FKey ("Tab", "tab", Qt::Key_Tab, 0)); 192 keys.insert( "r0c2", FKey ("Tab", "tab", Qt::Key_Tab, 0));
193 keys.insert( "r0c3", FKey ("Up", "up", Qt::Key_Up, 0)); 193 keys.insert( "r0c3", FKey ("Up", "up", Qt::Key_Up, 0));
194 keys.insert( "r0c4", FKey ("Down", "down", Qt::Key_Down, 0)); 194 keys.insert( "r0c4", FKey ("Down", "down", Qt::Key_Down, 0));
195 195
196 keys.insert( "r0c7", FKey ("Ho", 0, 4112, 0)); 196 keys.insert( "r0c7", FKey ("Ho", 0, 4112, 0));
197 keys.insert( "r0c8", FKey ("End", 0, 4113, 0)); 197 keys.insert( "r0c8", FKey ("End", 0, 4113, 0));
198 keys.insert( "r0c9", FKey ("PU", 0, 4118, 0)); 198 keys.insert( "r0c9", FKey ("PU", 0, 4118, 0));
199 keys.insert( "r0c10", FKey ("PD", 0, 4119, 0)); 199 keys.insert( "r0c10", FKey ("PD", 0, 4119, 0));
200 200
201 keys.insert( "r1c0", FKey ("F1", 0, 4144, 0)); 201 keys.insert( "r1c0", FKey ("F1", 0, 4144, 0));
202 keys.insert( "r1c1", FKey ("F2", 0, 4145, 0)); 202 keys.insert( "r1c1", FKey ("F2", 0, 4145, 0));
203 keys.insert( "r1c2", FKey ("F3", 0, 4146, 0)); 203 keys.insert( "r1c2", FKey ("F3", 0, 4146, 0));
204 keys.insert( "r1c3", FKey ("F4", 0, 4147, 0)); 204 keys.insert( "r1c3", FKey ("F4", 0, 4147, 0));
205 keys.insert( "r1c4", FKey ("F5", 0, 4148, 0)); 205 keys.insert( "r1c4", FKey ("F5", 0, 4148, 0));
206 keys.insert( "r1c5", FKey ("F6", 0, 4149, 0)); 206 keys.insert( "r1c5", FKey ("F6", 0, 4149, 0));
207 keys.insert( "r1c6", FKey ("F7", 0, 4150, 0)); 207 keys.insert( "r1c6", FKey ("F7", 0, 4150, 0));
208 keys.insert( "r1c7", FKey ("F8", 0, 4151, 0)); 208 keys.insert( "r1c7", FKey ("F8", 0, 4151, 0));
209 keys.insert( "r1c8", FKey ("F9", 0, 4152, 0)); 209 keys.insert( "r1c8", FKey ("F9", 0, 4152, 0));
210 keys.insert( "r1c9", FKey ("F10", 0, 4153, 0)); 210 keys.insert( "r1c9", FKey ("F10", 0, 4153, 0));
211 keys.insert( "r1c10", FKey ("F11", 0, 4154, 0)); 211 keys.insert( "r1c10", FKey ("F11", 0, 4154, 0));
212 212
213 213
214} 214}
215 215
216/* FunctionKeyboardConfig {{{1 */ 216/* FunctionKeyboardConfig {{{1 */
217 217
218FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na ) 218FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na )
219 : ProfileDialogKeyWidget(name, parent, na), 219 : ProfileDialogKeyWidget(name, parent, na),
220 selectedRow(0), selectedCol(0) 220 selectedRow(0), selectedCol(0)
221{ 221{
222 qWarning("FunctionKeyboardConfig"); 222 qWarning("FunctionKeyboardConfig");
223 223
224 224
225 kb = new FunctionKeyboard(this); 225 kb = new FunctionKeyboard(this);
226 connect (kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), 226 connect (kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)),
227 this, SLOT(slotKeyPressed(FKey, ushort, ushort, bool))); 227 this, SLOT(slotKeyPressed(FKey, ushort, ushort, bool)));
228 228
229 QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimentions"), this); 229 QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimentions"), this);
230 QLabel *l = new QLabel("Rows", dimentions); 230 QLabel *l = new QLabel("Rows", dimentions);
231 m_rowBox = new QSpinBox(1, 15, 1, dimentions); 231 m_rowBox = new QSpinBox(1, 15, 1, dimentions);
232 connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int))); 232 connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int)));
233 l = new QLabel("Columns", dimentions); 233 l = new QLabel("Columns", dimentions);
234 m_colBox = new QSpinBox(1, 15, 1, dimentions); 234 m_colBox = new QSpinBox(1, 15, 1, dimentions);
235 connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int))); 235 connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int)));
236 236
237 QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this); 237 QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this);
238 l = new QLabel("Label", editKey); 238 l = new QLabel("Label", editKey);
239 m_labels = new QComboBox(true, editKey); 239 m_labels = new QComboBox(true, editKey);
240 m_labels->setInsertionPolicy(QComboBox::AtCurrent); 240 m_labels->setInsertionPolicy(QComboBox::AtCurrent);
241 m_labels->insertItem(""); 241 m_labels->insertItem("");
242 242
243 QStringList files = QDir( QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList(); 243 QStringList files = QDir( QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList();
244 244
245 for (uint i = 0; i < files.count(); i++) { 245 for (uint i = 0; i < files.count(); i++) {
246 246
247 m_labels->insertItem( Resource::loadPixmap("console/keys/" + files[i]), files[i]); 247 m_labels->insertItem( Resource::loadPixmap("console/keys/" + files[i]), files[i]);
248 } 248 }
249 connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int))); 249 connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int)));
250 connect (m_labels, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeLabelText(const QString&))); 250 connect (m_labels, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeLabelText(const QString&)));
251 251
252 l = new QLabel("Q Keycode", editKey); 252 l = new QLabel("Q Keycode", editKey);
253 m_qvalues = new QComboBox(true, editKey); 253 m_qvalues = new QComboBox(true, editKey);
254 m_qvalues->setInsertionPolicy(QComboBox::AtTop); 254 m_qvalues->setInsertionPolicy(QComboBox::AtTop);
255 m_qvalues->setDuplicatesEnabled(false); 255 m_qvalues->setDuplicatesEnabled(false);
256 m_qvalues->insertItem(""); 256 m_qvalues->insertItem("");
257 connect (m_qvalues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeQCode(const QString&))); 257 connect (m_qvalues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeQCode(const QString&)));
258 258
259 l = new QLabel("Unicode Value", editKey); 259 l = new QLabel("Unicode Value", editKey);
260 m_uniValues = new QComboBox(true, editKey); 260 m_uniValues = new QComboBox(true, editKey);
261 m_uniValues->setInsertionPolicy(QComboBox::AtTop); 261 m_uniValues->setInsertionPolicy(QComboBox::AtTop);
262 m_uniValues->setDuplicatesEnabled(false); 262 m_uniValues->setDuplicatesEnabled(false);
263 m_uniValues->insertItem(""); 263 m_uniValues->insertItem("");
264 connect (m_uniValues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeUnicode(const QString&))); 264 connect (m_uniValues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeUnicode(const QString&)));
265 265
266 QVBoxLayout *root = new QVBoxLayout(this, 2); 266 QVBoxLayout *root = new QVBoxLayout(this, 2);
267 root->addWidget(kb); 267 root->addWidget(kb);
268 root->addWidget(dimentions); 268 root->addWidget(dimentions);
269 root->addWidget(editKey); 269 root->addWidget(editKey);
270} 270}
271FunctionKeyboardConfig::~FunctionKeyboardConfig() { 271FunctionKeyboardConfig::~FunctionKeyboardConfig() {
272 272
273} 273}
274void FunctionKeyboardConfig::load (const Profile& prof) { 274void FunctionKeyboardConfig::load (const Profile& prof) {
275 275
276 m_rowBox->setValue(prof.readNumEntry("keb_rows", 2)); 276 m_rowBox->setValue(prof.readNumEntry("keb_rows", 2));
277 m_colBox->setValue(prof.readNumEntry("keb_cols", 10)); 277 m_colBox->setValue(prof.readNumEntry("keb_cols", 10));
278 278
279 /* load all the keys to the keyboard */ 279 /* load all the keys to the keyboard */
280 for (int i = 0; i <= m_rowBox->value() -1; i++) 280 for (int i = 0; i <= m_rowBox->value() -1; i++)
281 for (int j = 0; j <= m_colBox->value() -1; j++) { 281 for (int j = 0; j <= m_colBox->value() -1; j++) {
282 282
283 QString h = "r" + QString::number(i) + "c" + QString::number(j); 283 QString h = "r" + QString::number(i) + "c" + QString::number(j);
284 QString values = prof.readEntry("keb_" + h); 284 QString values = prof.readEntry("keb_" + h);
285 285
286 if (!values.isEmpty()) { 286 if (!values.isEmpty()) {
287 287
288 QStringList l = QStringList::split(QChar('|'), values, TRUE); 288 QStringList l = QStringList::split(QChar('|'), values, TRUE);
289 kb->keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt()); 289 kb->keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt());
290 290
291 // load pixmap if used 291 // load pixmap if used
292 if (!l[1].isEmpty()) { 292 if (!l[1].isEmpty()) {
293 293
294 kb->keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) ); 294 kb->keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) );
295 } 295 }
296 } 296 }
297 } 297 }
298 298
299} 299}
300void FunctionKeyboardConfig::save (Profile& prof) { 300void FunctionKeyboardConfig::save (Profile& prof) {
301 301
302 prof.writeEntry("keb_rows", m_rowBox->value()); 302 prof.writeEntry("keb_rows", m_rowBox->value());
303 prof.writeEntry("keb_cols", m_colBox->value()); 303 prof.writeEntry("keb_cols", m_colBox->value());
304 304
305 QMap<QString, FKey>::Iterator it; 305 QMap<QString, FKey>::Iterator it;
306 for ( it = kb->keys.begin(); it != kb->keys.end(); it++) { 306 for ( it = kb->keys.begin(); it != kb->keys.end(); it++) {
307 307
308 FKey k = it.data(); 308 FKey k = it.data();
309 QString entry = k.label + "|" 309 QString entry = k.label + "|"
310 + k.pixFile + "|" 310 + k.pixFile + "|"
311 + QString::number(k.qcode) + "|" 311 + QString::number(k.qcode) + "|"
312 + QString::number(k.unicode); 312 + QString::number(k.unicode);
313 313
314 prof.writeEntry("keb_" + it.key(), entry); 314 prof.writeEntry("keb_" + it.key(), entry);
315 315
316 } 316 }
317 317
318} 318}
319void FunctionKeyboardConfig::slotChangeRows(int r) { 319void FunctionKeyboardConfig::slotChangeRows(int r) {
320 320
321 kb->changeRows(r); 321 kb->changeRows(r);
322 322
323 // have to do this so the whole thing gets redrawn 323 // have to do this so the whole thing gets redrawn
324 kb->hide(); kb->show(); 324 kb->hide(); kb->show();
325} 325}
326void FunctionKeyboardConfig::slotChangeCols(int c) { 326void FunctionKeyboardConfig::slotChangeCols(int c) {
327 327
328 kb->changeCols(c); 328 kb->changeCols(c);
329} 329}
330void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pressed) { 330void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pressed) {
331 331
332 if (!pressed) return; 332 if (!pressed) return;
333 333
334 selectedHandle = "r" + QString::number(r) + 334 selectedHandle = "r" + QString::number(r) +
335 "c" + QString::number(c); 335 "c" + QString::number(c);
336 selectedRow = r; 336 selectedRow = r;
337 selectedCol = c; 337 selectedCol = c;
338 338
339 if (k.pixFile.isEmpty()) { 339 if (k.pixFile.isEmpty()) {
340 340
341 m_labels->setEditable(true); 341 m_labels->setEditable(true);
342 m_labels->setCurrentItem(0); 342 m_labels->setCurrentItem(0);
343 m_labels->changeItem(k.label, 0); 343 m_labels->changeItem(k.label, 0);
344 344
345 } else { 345 } else {
346 346
347 // any better way to select the pixmap? 347 // any better way to select the pixmap?
348 m_labels->setCurrentItem((m_labels->listBox())->index((m_labels->listBox())->findItem(kb->keys[selectedHandle].pixFile))); 348 m_labels->setCurrentItem((m_labels->listBox())->index((m_labels->listBox())->findItem(kb->keys[selectedHandle].pixFile)));
349 m_labels->setEditable(false); 349 m_labels->setEditable(false);
350 } 350 }
351 m_qvalues->changeItem(QString::number(k.qcode), 0); 351 m_qvalues->changeItem(QString::number(k.qcode), 0);
352 m_uniValues->changeItem(QString::number(k.unicode), 0); 352 m_uniValues->changeItem(QString::number(k.unicode), 0);
353} 353}
354void FunctionKeyboardConfig::slotChangeIcon(int index) { 354void FunctionKeyboardConfig::slotChangeIcon(int index) {
355 355
356 if (index == 0) { 356 if (index == 0) {
357 357
358 // is text 358 // is text
359 m_labels->setEditable(true); 359 m_labels->setEditable(true);
360 // why tf does the text get erased unless i do this? 360 // why tf does the text get erased unless i do this?
361 m_labels->changeItem(m_labels->text(0), 0); 361 m_labels->changeItem(m_labels->text(0), 0);
362 362
363 kb->keys[selectedHandle].pixFile = ""; 363 kb->keys[selectedHandle].pixFile = "";
364 delete kb->keys[selectedHandle].pix; 364 delete kb->keys[selectedHandle].pix;
365 365
366 } else { 366 } else {
367 367
368 // is a pixmap 368 // is a pixmap
369 m_labels->setEditable(false); 369 m_labels->setEditable(false);
370 kb->keys[selectedHandle].pixFile = m_labels->currentText(); 370 kb->keys[selectedHandle].pixFile = m_labels->currentText();
371 kb->keys[selectedHandle].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + m_labels->currentText() ) ); 371 kb->keys[selectedHandle].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + m_labels->currentText() ) );
372 } 372 }
373 kb->paintKey(selectedRow, selectedCol); 373 kb->paintKey(selectedRow, selectedCol);
374} 374}
375void FunctionKeyboardConfig::slotChangeLabelText(const QString &label) { 375void FunctionKeyboardConfig::slotChangeLabelText(const QString &label) {
376 376
377 kb->keys[selectedHandle].label = label; 377 kb->keys[selectedHandle].label = label;
378 378
379 kb->paintKey(selectedRow, selectedCol); 379 kb->paintKey(selectedRow, selectedCol);
380} 380}
381void FunctionKeyboardConfig::slotChangeQCode(const QString& qcode) { 381void FunctionKeyboardConfig::slotChangeQCode(const QString& qcode) {
382 382
383 kb->keys[selectedHandle].qcode = qcode.toUInt(); 383 kb->keys[selectedHandle].qcode = qcode.toUInt();
384} 384}
385void FunctionKeyboardConfig::slotChangeUnicode(const QString& uni) { 385void FunctionKeyboardConfig::slotChangeUnicode(const QString& uni) {
386 386
387 kb->keys[selectedHandle].unicode = uni.toUInt(); 387 kb->keys[selectedHandle].unicode = uni.toUInt();
388} 388}
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 406586c..b177fa5 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -52,540 +52,540 @@ void MainWindow::initUI() {
52 m_tool = new QToolBar( this ); 52 m_tool = new QToolBar( this );
53 m_tool->setHorizontalStretchable( TRUE ); 53 m_tool->setHorizontalStretchable( TRUE );
54 54
55 m_bar = new QMenuBar( m_tool ); 55 m_bar = new QMenuBar( m_tool );
56 m_console = new QPopupMenu( this ); 56 m_console = new QPopupMenu( this );
57 m_scripts = new QPopupMenu( this ); 57 m_scripts = new QPopupMenu( this );
58 m_sessionsPop= new QPopupMenu( this ); 58 m_sessionsPop= new QPopupMenu( this );
59 //m_settings = new QPopupMenu( this ); 59 //m_settings = new QPopupMenu( this );
60 60
61 /* add a toolbar for icons */ 61 /* add a toolbar for icons */
62 m_icons = new QToolBar(this); 62 m_icons = new QToolBar(this);
63 63
64 64
65 65
66 66
67 /* 67 /*
68 * the settings action 68 * the settings action
69 */ 69 */
70 m_setProfiles = new QAction(tr("Configure Profiles"), 70 m_setProfiles = new QAction(tr("Configure Profiles"),
71 Resource::loadPixmap( "SettingsIcon" ), 71 Resource::loadPixmap( "SettingsIcon" ),
72 QString::null, 0, this, 0); 72 QString::null, 0, this, 0);
73 // m_setProfiles->addTo( m_settings ); 73 // m_setProfiles->addTo( m_settings );
74 m_setProfiles->addTo( m_icons ); 74 m_setProfiles->addTo( m_icons );
75 m_setProfiles->addTo( m_console ); 75 m_setProfiles->addTo( m_console );
76 connect( m_setProfiles, SIGNAL(activated() ), 76 connect( m_setProfiles, SIGNAL(activated() ),
77 this, SLOT(slotConfigure() ) ); 77 this, SLOT(slotConfigure() ) );
78 78
79 m_console->insertSeparator(); 79 m_console->insertSeparator();
80 /* 80 /*
81 * new Action for new sessions 81 * new Action for new sessions
82 */ 82 */
83 QAction* a = new QAction(tr("New Connection"), 83 QAction* a = new QAction(tr("New Connection"),
84 Resource::loadPixmap( "new" ), 84 Resource::loadPixmap( "new" ),
85 QString::null, 0, this, 0); 85 QString::null, 0, this, 0);
86 a->addTo( m_console ); 86 a->addTo( m_console );
87 a->addTo( m_icons ); 87 a->addTo( m_icons );
88 connect(a, SIGNAL(activated() ), 88 connect(a, SIGNAL(activated() ),
89 this, SLOT(slotNew() ) ); 89 this, SLOT(slotNew() ) );
90 90
91 m_console->insertSeparator(); 91 m_console->insertSeparator();
92 /* save icon is not available */ 92 /* save icon is not available */
93 a = new QAction(tr("Save Connection"), 93 a = new QAction(tr("Save Connection"),
94 Resource::loadPixmap("save"), QString::null, 94 Resource::loadPixmap("save"), QString::null,
95 0, this, 0 ); 95 0, this, 0 );
96 a->addTo( m_console ); 96 a->addTo( m_console );
97 connect(a, SIGNAL(activated() ), 97 connect(a, SIGNAL(activated() ),
98 this, SLOT(slotSaveSession() ) ); 98 this, SLOT(slotSaveSession() ) );
99 m_console->insertSeparator(); 99 m_console->insertSeparator();
100 100
101 /* 101 /*
102 * connect action 102 * connect action
103 */ 103 */
104 m_connect = new QAction(); 104 m_connect = new QAction();
105 m_connect->setText( tr("Connect") ); 105 m_connect->setText( tr("Connect") );
106 m_connect->addTo( m_console ); 106 m_connect->addTo( m_console );
107 connect(m_connect, SIGNAL(activated() ), 107 connect(m_connect, SIGNAL(activated() ),
108 this, SLOT(slotConnect() ) ); 108 this, SLOT(slotConnect() ) );
109 109
110 /* 110 /*
111 * disconnect action 111 * disconnect action
112 */ 112 */
113 m_disconnect = new QAction(); 113 m_disconnect = new QAction();
114 m_disconnect->setText( tr("Disconnect") ); 114 m_disconnect->setText( tr("Disconnect") );
115 m_disconnect->addTo( m_console ); 115 m_disconnect->addTo( m_console );
116 connect(m_disconnect, SIGNAL(activated() ), 116 connect(m_disconnect, SIGNAL(activated() ),
117 this, SLOT(slotDisconnect() ) ); 117 this, SLOT(slotDisconnect() ) );
118 118
119 m_console->insertSeparator(); 119 m_console->insertSeparator();
120 120
121 m_transfer = new QAction(); 121 m_transfer = new QAction();
122 m_transfer->setText( tr("Transfer file...") ); 122 m_transfer->setText( tr("Transfer file...") );
123 m_transfer->addTo( m_console ); 123 m_transfer->addTo( m_console );
124 connect(m_transfer, SIGNAL(activated() ), 124 connect(m_transfer, SIGNAL(activated() ),
125 this, SLOT(slotTransfer() ) ); 125 this, SLOT(slotTransfer() ) );
126 126
127 127
128 /* 128 /*
129 * fullscreen 129 * fullscreen
130 */ 130 */
131 m_isFullscreen = false; 131 m_isFullscreen = false;
132 132
133 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) 133 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" )
134 , QString::null, 0, this, 0); 134 , QString::null, 0, this, 0);
135 m_fullscreen->addTo( m_console ); 135 m_fullscreen->addTo( m_console );
136 m_fullscreen->addTo( m_icons ); 136 m_fullscreen->addTo( m_icons );
137 connect( m_fullscreen, SIGNAL( activated() ), 137 connect( m_fullscreen, SIGNAL( activated() ),
138 this, SLOT( slotFullscreen() ) ); 138 this, SLOT( slotFullscreen() ) );
139 139
140 m_console->insertSeparator(); 140 m_console->insertSeparator();
141 /* 141 /*
142 * terminate action 142 * terminate action
143 */ 143 */
144 m_terminate = new QAction(); 144 m_terminate = new QAction();
145 m_terminate->setText( tr("Terminate") ); 145 m_terminate->setText( tr("Terminate") );
146 m_terminate->addTo( m_console ); 146 m_terminate->addTo( m_console );
147 connect(m_terminate, SIGNAL(activated() ), 147 connect(m_terminate, SIGNAL(activated() ),
148 this, SLOT(slotTerminate() ) ); 148 this, SLOT(slotTerminate() ) );
149 149
150 m_closewindow = new QAction(); 150 m_closewindow = new QAction();
151 m_closewindow->setText( tr("Close Window") ); 151 m_closewindow->setText( tr("Close Window") );
152 m_closewindow->addTo( m_console ); 152 m_closewindow->addTo( m_console );
153 connect( m_closewindow, SIGNAL(activated() ), 153 connect( m_closewindow, SIGNAL(activated() ),
154 this, SLOT(slotClose() ) ); 154 this, SLOT(slotClose() ) );
155 155
156 156
157 /* 157 /*
158 * script actions 158 * script actions
159 */ 159 */
160 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); 160 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
161 m_recordScript->addTo(m_scripts); 161 m_recordScript->addTo(m_scripts);
162 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); 162 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript()));
163 163
164 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); 164 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0);
165 m_saveScript->addTo(m_scripts); 165 m_saveScript->addTo(m_scripts);
166 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); 166 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript()));
167 167
168 m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); 168 m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0);
169 m_runScript->addTo(m_scripts); 169 m_runScript->addTo(m_scripts);
170 connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); 170 connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript()));
171 171
172 /* 172 /*
173 * action that open/closes the keyboard 173 * action that open/closes the keyboard
174 */ 174 */
175 m_openKeys = new QAction (tr("Open Keyboard..."), 175 m_openKeys = new QAction (tr("Open Keyboard..."),
176 Resource::loadPixmap( "console/keys/keyboard_icon" ), 176 Resource::loadPixmap( "console/keys/keyboard_icon" ),
177 QString::null, 0, this, 0); 177 QString::null, 0, this, 0);
178 178
179 m_openKeys->setToggleAction(true); 179 m_openKeys->setToggleAction(true);
180 180
181 connect (m_openKeys, SIGNAL(toggled(bool)), 181 connect (m_openKeys, SIGNAL(toggled(bool)),
182 this, SLOT(slotOpenKeb(bool))); 182 this, SLOT(slotOpenKeb(bool)));
183 m_openKeys->addTo(m_icons); 183 m_openKeys->addTo(m_icons);
184 184
185 /* insert the submenu */ 185 /* insert the submenu */
186 m_console->insertItem(tr("New from Profile"), m_sessionsPop, 186 m_console->insertItem(tr("New from Profile"), m_sessionsPop,
187 -1, 0); 187 -1, 0);
188 188
189 /* insert the connection menu */ 189 /* insert the connection menu */
190 m_bar->insertItem( tr("Connection"), m_console ); 190 m_bar->insertItem( tr("Connection"), m_console );
191 191
192 /* the scripts menu */ 192 /* the scripts menu */
193 m_bar->insertItem( tr("Scripts"), m_scripts ); 193 m_bar->insertItem( tr("Scripts"), m_scripts );
194 194
195 /* the settings menu */ 195 /* the settings menu */
196 // m_bar->insertItem( tr("Settings"), m_settings ); 196 // m_bar->insertItem( tr("Settings"), m_settings );
197 197
198 /* and the keyboard */ 198 /* and the keyboard */
199 m_keyBar = new QToolBar(this); 199 m_keyBar = new QToolBar(this);
200 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); 200 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE );
201 m_keyBar->setHorizontalStretchable( TRUE ); 201 m_keyBar->setHorizontalStretchable( TRUE );
202 m_keyBar->hide(); 202 m_keyBar->hide();
203 203
204 m_kb = new FunctionKeyboard(m_keyBar); 204 m_kb = new FunctionKeyboard(m_keyBar);
205 connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), 205 connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)),
206 this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); 206 this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool)));
207 207
208 m_buttonBar = new QToolBar( this ); 208 m_buttonBar = new QToolBar( this );
209 addToolBar( m_buttonBar, "Buttons", QMainWindow::Top, TRUE ); 209 addToolBar( m_buttonBar, "Buttons", QMainWindow::Top, TRUE );
210 m_buttonBar->setHorizontalStretchable( TRUE ); 210 m_buttonBar->setHorizontalStretchable( TRUE );
211 m_buttonBar->hide(); 211 m_buttonBar->hide();
212 212
213 a = new QAction(tr("Copy"), 213 a = new QAction(tr("Copy"),
214 Resource::loadPixmap("copy"), QString::null, 214 Resource::loadPixmap("copy"), QString::null,
215 0, this, 0 ); 215 0, this, 0 );
216 //a->addTo( m_icons ); 216 //a->addTo( m_icons );
217 connect( a, SIGNAL(activated() ), 217 connect( a, SIGNAL(activated() ),
218 this, SLOT(slotCopy() ) ); 218 this, SLOT(slotCopy() ) );
219 219
220 a = new QAction(tr("Paste"), 220 a = new QAction(tr("Paste"),
221 Resource::loadPixmap("paste"), QString::null, 221 Resource::loadPixmap("paste"), QString::null,
222 0, this, 0 ); 222 0, this, 0 );
223 a->addTo( m_icons ); 223 a->addTo( m_icons );
224 connect( a, SIGNAL(activated() ), 224 connect( a, SIGNAL(activated() ),
225 this, SLOT(slotPaste() ) ); 225 this, SLOT(slotPaste() ) );
226 226
227 227
228 m_connect->setEnabled( false ); 228 m_connect->setEnabled( false );
229 m_disconnect->setEnabled( false ); 229 m_disconnect->setEnabled( false );
230 m_terminate->setEnabled( false ); 230 m_terminate->setEnabled( false );
231 m_transfer->setEnabled( false ); 231 m_transfer->setEnabled( false );
232 m_recordScript->setEnabled( false ); 232 m_recordScript->setEnabled( false );
233 m_saveScript->setEnabled( false ); 233 m_saveScript->setEnabled( false );
234 m_runScript->setEnabled( false ); 234 m_runScript->setEnabled( false );
235 m_fullscreen->setEnabled( false ); 235 m_fullscreen->setEnabled( false );
236 m_closewindow->setEnabled( false ); 236 m_closewindow->setEnabled( false );
237 237
238 /* 238 /*
239 * connect to the menu activation 239 * connect to the menu activation
240 */ 240 */
241 connect( m_sessionsPop, SIGNAL(activated( int ) ), 241 connect( m_sessionsPop, SIGNAL(activated( int ) ),
242 this, SLOT(slotProfile( int ) ) ); 242 this, SLOT(slotProfile( int ) ) );
243 243
244 m_consoleWindow = new TabWidget( this, "blah"); 244 m_consoleWindow = new TabWidget( this, "blah");
245 connect(m_consoleWindow, SIGNAL(activated(Session*) ), 245 connect(m_consoleWindow, SIGNAL(activated(Session*) ),
246 this, SLOT(slotSessionChanged(Session*) ) ); 246 this, SLOT(slotSessionChanged(Session*) ) );
247 setCentralWidget( m_consoleWindow ); 247 setCentralWidget( m_consoleWindow );
248 248
249} 249}
250 250
251ProfileManager* MainWindow::manager() { 251ProfileManager* MainWindow::manager() {
252 return m_manager; 252 return m_manager;
253} 253}
254TabWidget* MainWindow::tabWidget() { 254TabWidget* MainWindow::tabWidget() {
255 return m_consoleWindow; 255 return m_consoleWindow;
256} 256}
257void MainWindow::populateProfiles() { 257void MainWindow::populateProfiles() {
258 m_sessionsPop->clear(); 258 m_sessionsPop->clear();
259 Profile::ValueList list = manager()->all(); 259 Profile::ValueList list = manager()->all();
260 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { 260 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) {
261 m_sessionsPop->insertItem( (*it).name() ); 261 m_sessionsPop->insertItem( (*it).name() );
262 } 262 }
263 263
264} 264}
265MainWindow::~MainWindow() { 265MainWindow::~MainWindow() {
266 delete m_factory; 266 delete m_factory;
267 manager()->save(); 267 manager()->save();
268} 268}
269 269
270MetaFactory* MainWindow::factory() { 270MetaFactory* MainWindow::factory() {
271 return m_factory; 271 return m_factory;
272} 272}
273 273
274Session* MainWindow::currentSession() { 274Session* MainWindow::currentSession() {
275 return m_curSession; 275 return m_curSession;
276} 276}
277 277
278QList<Session> MainWindow::sessions() { 278QList<Session> MainWindow::sessions() {
279 return m_sessions; 279 return m_sessions;
280} 280}
281 281
282void MainWindow::slotNew() { 282void MainWindow::slotNew() {
283 ProfileEditorDialog dlg(factory() ); 283 ProfileEditorDialog dlg(factory() );
284 dlg.showMaximized(); 284 dlg.showMaximized();
285 int ret = dlg.exec(); 285 int ret = dlg.exec();
286 286
287 if ( ret == QDialog::Accepted ) { 287 if ( ret == QDialog::Accepted ) {
288 create( dlg.profile() ); 288 create( dlg.profile() );
289 } 289 }
290} 290}
291 291
292void MainWindow::slotRecordScript() { 292void MainWindow::slotRecordScript() {
293 if (currentSession()) { 293 if (currentSession()) {
294 currentSession()->emulationHandler()->startRecording(); 294 currentSession()->emulationHandler()->startRecording();
295 } 295 }
296} 296}
297 297
298void MainWindow::slotSaveScript() { 298void MainWindow::slotSaveScript() {
299 if (currentSession() && currentSession()->emulationHandler()->isRecording()) { 299 if (currentSession() && currentSession()->emulationHandler()->isRecording()) {
300 MimeTypes types; 300 MimeTypes types;
301 QStringList script; 301 QStringList script;
302 script << "text/plain"; 302 script << "text/plain";
303 script << "text/all"; 303 script << "text/all";
304 script << "application/octet-stream"; 304 script << "application/octet-stream";
305 types.insert("Script", script); 305 types.insert("Script", script);
306 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); 306 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types);
307 if (!filename.isEmpty()) { 307 if (!filename.isEmpty()) {
308 currentSession()->emulationHandler()->script()->saveTo(filename); 308 currentSession()->emulationHandler()->script()->saveTo(filename);
309 currentSession()->emulationHandler()->clearScript(); 309 currentSession()->emulationHandler()->clearScript();
310 } 310 }
311 } 311 }
312} 312}
313 313
314void MainWindow::slotRunScript() { 314void MainWindow::slotRunScript() {
315 if (currentSession()) { 315 if (currentSession()) {
316 MimeTypes types; 316 MimeTypes types;
317 QStringList script; 317 QStringList script;
318 script << "text/plain"; 318 script << "text/plain";
319 script << "text/all"; 319 script << "text/all";
320 script << "application/octet-stream"; 320 script << "application/octet-stream";
321 types.insert("Script", script); 321 types.insert("Script", script);
322 QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); 322 QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types);
323 if (!filename.isEmpty()) { 323 if (!filename.isEmpty()) {
324 Script script(DocLnk(filename).file()); 324 Script script(DocLnk(filename).file());
325 currentSession()->emulationHandler()->runScript(&script); 325 currentSession()->emulationHandler()->runScript(&script);
326 } 326 }
327 } 327 }
328} 328}
329 329
330void MainWindow::slotConnect() { 330void MainWindow::slotConnect() {
331 if ( currentSession() ) { 331 if ( currentSession() ) {
332 bool ret = currentSession()->layer()->open(); 332 bool ret = currentSession()->layer()->open();
333 if(!ret) QMessageBox::warning(currentSession()->widgetStack(), 333 if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
334 QObject::tr("Failed"), 334 QObject::tr("Failed"),
335 QObject::tr("Connecting failed for this session.")); 335 QObject::tr("Connecting failed for this session."));
336 else { 336 else {
337 m_connect->setEnabled( false ); 337 m_connect->setEnabled( false );
338 m_disconnect->setEnabled( true ); 338 m_disconnect->setEnabled( true );
339 m_transfer->setEnabled( true ); 339 m_transfer->setEnabled( true );
340 m_recordScript->setEnabled( true ); 340 m_recordScript->setEnabled( true );
341 m_saveScript->setEnabled( true ); 341 m_saveScript->setEnabled( true );
342 m_runScript->setEnabled( true ); 342 m_runScript->setEnabled( true );
343 } 343 }
344 } 344 }
345} 345}
346 346
347void MainWindow::slotDisconnect() { 347void MainWindow::slotDisconnect() {
348 if ( currentSession() ) { 348 if ( currentSession() ) {
349 currentSession()->layer()->close(); 349 currentSession()->layer()->close();
350 m_connect->setEnabled( true ); 350 m_connect->setEnabled( true );
351 m_disconnect->setEnabled( false ); 351 m_disconnect->setEnabled( false );
352 m_transfer->setEnabled( false ); 352 m_transfer->setEnabled( false );
353 m_recordScript->setEnabled( false); 353 m_recordScript->setEnabled( false);
354 m_saveScript->setEnabled( false ); 354 m_saveScript->setEnabled( false );
355 m_runScript->setEnabled( false ); 355 m_runScript->setEnabled( false );
356 } 356 }
357} 357}
358 358
359void MainWindow::slotTerminate() { 359void MainWindow::slotTerminate() {
360 if ( currentSession() ) 360 if ( currentSession() )
361 currentSession()->layer()->close(); 361 currentSession()->layer()->close();
362 362
363 slotClose(); 363 slotClose();
364 /* FIXME move to the next session */ 364 /* FIXME move to the next session */
365} 365}
366 366
367void MainWindow::slotConfigure() { 367void MainWindow::slotConfigure() {
368 ConfigDialog conf( manager()->all(), factory() ); 368 ConfigDialog conf( manager()->all(), factory() );
369 conf.showMaximized(); 369 conf.showMaximized();
370 370
371 int ret = conf.exec(); 371 int ret = conf.exec();
372 372
373 if ( QDialog::Accepted == ret ) { 373 if ( QDialog::Accepted == ret ) {
374 manager()->setProfiles( conf.list() ); 374 manager()->setProfiles( conf.list() );
375 manager()->save(); 375 manager()->save();
376 populateProfiles(); 376 populateProfiles();
377 } 377 }
378} 378}
379/* 379/*
380 * we will remove 380 * we will remove
381 * this window from the tabwidget 381 * this window from the tabwidget
382 * remove it from the list 382 * remove it from the list
383 * delete it 383 * delete it
384 * and set the currentSession() 384 * and set the currentSession()
385 */ 385 */
386void MainWindow::slotClose() { 386void MainWindow::slotClose() {
387 if (!currentSession() ) 387 if (!currentSession() )
388 return; 388 return;
389 389
390 Session* ses = currentSession(); 390 Session* ses = currentSession();
391 qWarning("removing! currentSession %s", currentSession()->name().latin1() ); 391 qWarning("removing! currentSession %s", currentSession()->name().latin1() );
392 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ 392 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */
393 m_curSession = NULL; 393 m_curSession = NULL;
394 tabWidget()->remove( /*currentSession()*/ses ); 394 tabWidget()->remove( /*currentSession()*/ses );
395 /*it's autodelete */ 395 /*it's autodelete */
396 m_sessions.remove( ses ); 396 m_sessions.remove( ses );
397 qWarning("after remove!!"); 397 qWarning("after remove!!");
398 398
399 if (!currentSession() ) { 399 if (!currentSession() ) {
400 m_connect->setEnabled( false ); 400 m_connect->setEnabled( false );
401 m_disconnect->setEnabled( false ); 401 m_disconnect->setEnabled( false );
402 m_terminate->setEnabled( false ); 402 m_terminate->setEnabled( false );
403 m_transfer->setEnabled( false ); 403 m_transfer->setEnabled( false );
404 m_recordScript->setEnabled( false ); 404 m_recordScript->setEnabled( false );
405 m_saveScript->setEnabled( false ); 405 m_saveScript->setEnabled( false );
406 m_runScript->setEnabled( false ); 406 m_runScript->setEnabled( false );
407 m_fullscreen->setEnabled( false ); 407 m_fullscreen->setEnabled( false );
408 m_closewindow->setEnabled( false ); 408 m_closewindow->setEnabled( false );
409 } 409 }
410} 410}
411 411
412/* 412/*
413 * We will get the name 413 * We will get the name
414 * Then the profile 414 * Then the profile
415 * and then we will make a profile 415 * and then we will make a profile
416 */ 416 */
417void MainWindow::slotProfile( int id) { 417void MainWindow::slotProfile( int id) {
418 Profile prof = manager()->profile( m_sessionsPop->text( id) ); 418 Profile prof = manager()->profile( m_sessionsPop->text( id) );
419 create( prof ); 419 create( prof );
420} 420}
421void MainWindow::create( const Profile& prof ) { 421void MainWindow::create( const Profile& prof ) {
422 Session *ses = manager()->fromProfile( prof, tabWidget() ); 422 Session *ses = manager()->fromProfile( prof, tabWidget() );
423 423
424 if((!ses) || (!ses->layer()) || (!ses->widgetStack())) 424 if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
425 { 425 {
426 QMessageBox::warning(this, 426 QMessageBox::warning(this,
427 QObject::tr("Session failed"), 427 QObject::tr("Session failed"),
428 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); 428 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>"));
429 //if(ses) delete ses; 429 //if(ses) delete ses;
430 return; 430 return;
431 } 431 }
432 432
433 m_sessions.append( ses ); 433 m_sessions.append( ses );
434 tabWidget()->add( ses ); 434 tabWidget()->add( ses );
435 tabWidget()->repaint(); 435 tabWidget()->repaint();
436 m_curSession = ses; 436 m_curSession = ses;
437 437
438 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it 438 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it
439 m_connect->setEnabled( true ); 439 m_connect->setEnabled( true );
440 m_disconnect->setEnabled( false ); 440 m_disconnect->setEnabled( false );
441 m_terminate->setEnabled( true ); 441 m_terminate->setEnabled( true );
442 m_fullscreen->setEnabled( true ); 442 m_fullscreen->setEnabled( true );
443 m_closewindow->setEnabled( true ); 443 m_closewindow->setEnabled( true );
444 m_transfer->setEnabled( false ); 444 m_transfer->setEnabled( false );
445 m_recordScript->setEnabled( false ); 445 m_recordScript->setEnabled( false );
446 m_saveScript->setEnabled( false ); 446 m_saveScript->setEnabled( false );
447 m_runScript->setEnabled( false ); 447 m_runScript->setEnabled( false );
448 448
449 // is io_layer wants direct connection, then autoconnect 449 // is io_layer wants direct connection, then autoconnect
450 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { 450 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) {
451 if (prof.autoConnect()) { 451 if (prof.autoConnect()) {
452 slotConnect(); 452 slotConnect();
453 } 453 }
454 454
455 455
456 456
457 QWidget *w = currentSession()->widget(); 457 QWidget *w = currentSession()->widget();
458 if(w) w->setFocus(); 458 if(w) w->setFocus();
459} 459}
460 460
461void MainWindow::slotTransfer() 461void MainWindow::slotTransfer()
462{ 462{
463 if ( currentSession() ) { 463 if ( currentSession() ) {
464 TransferDialog dlg(currentSession()->widgetStack(), this); 464 TransferDialog dlg(currentSession()->widgetStack(), this);
465 dlg.showMaximized(); 465 dlg.showMaximized();
466 //currentSession()->widgetStack()->add(dlg); 466 //currentSession()->widgetStack()->add(dlg);
467 dlg.exec(); 467 dlg.exec();
468 } 468 }
469} 469}
470 470
471 471
472void MainWindow::slotOpenKeb(bool state) { 472void MainWindow::slotOpenKeb(bool state) {
473 473
474 if (state) m_keyBar->show(); 474 if (state) m_keyBar->show();
475 else m_keyBar->hide(); 475 else m_keyBar->hide();
476 476
477} 477}
478 478
479 479
480void MainWindow::slotOpenButtons( bool state ) { 480void MainWindow::slotOpenButtons( bool state ) {
481 481
482 if ( state ) { 482 if ( state ) {
483 m_buttonBar->show(); 483 m_buttonBar->show();
484 } else { 484 } else {
485 m_buttonBar->hide(); 485 m_buttonBar->hide();
486 } 486 }
487} 487}
488 488
489 489
490 490
491void MainWindow::slotSessionChanged( Session* ses ) { 491void MainWindow::slotSessionChanged( Session* ses ) {
492 qWarning("changed!"); 492 qWarning("changed!");
493 if ( ses ) { 493 if ( ses ) {
494 m_curSession = ses; 494 m_curSession = ses;
495 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); 495 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) );
496 if ( m_curSession->layer()->isConnected() ) { 496 if ( m_curSession->layer()->isConnected() ) {
497 m_connect->setEnabled( false ); 497 m_connect->setEnabled( false );
498 m_disconnect->setEnabled( true ); 498 m_disconnect->setEnabled( true );
499 m_recordScript->setEnabled( true ); 499 m_recordScript->setEnabled( true );
500 m_saveScript->setEnabled( true ); 500 m_saveScript->setEnabled( true );
501 m_runScript->setEnabled( true ); 501 m_runScript->setEnabled( true );
502 } else { 502 } else {
503 m_connect->setEnabled( true ); 503 m_connect->setEnabled( true );
504 m_disconnect->setEnabled( false ); 504 m_disconnect->setEnabled( false );
505 m_recordScript->setEnabled( false ); 505 m_recordScript->setEnabled( false );
506 m_saveScript->setEnabled( false ); 506 m_saveScript->setEnabled( false );
507 m_runScript->setEnabled( false ); 507 m_runScript->setEnabled( false );
508 } 508 }
509 509
510 if ( ( m_curSession->layer() )->supports()[1] == 0 ) { 510 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
511 m_transfer->setEnabled( false ); 511 m_transfer->setEnabled( false );
512 } else { 512 } else {
513 m_transfer->setEnabled( true ); 513 m_transfer->setEnabled( true );
514 } 514 }
515 515
516 516
517 517
518 518
519 519
520 QWidget *w = m_curSession->widget(); 520 QWidget *w = m_curSession->widget();
521 if(w) w->setFocus(); 521 if(w) w->setFocus();
522 } 522 }
523} 523}
524 524
525void MainWindow::slotFullscreen() { 525void MainWindow::slotFullscreen() {
526 526
527 527
528 528
529 if ( m_isFullscreen ) { 529 if ( m_isFullscreen ) {
530 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); 530 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true );
531 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); 531 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() );
532 ( m_curSession->emulationHandler() )->cornerButton()->hide(); 532 ( m_curSession->emulationHandler() )->cornerButton()->hide();
533 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 533 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
534 534
535 } else { 535 } else {
536 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); 536 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget();
537 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); 537 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame );
538 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop 538 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop
539 , QPoint(0,0), false ); 539 , QPoint(0,0), false );
540 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); 540 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() );
541 ( m_curSession->widgetStack() )->setFocus(); 541 ( m_curSession->widgetStack() )->setFocus();
542 ( m_curSession->widgetStack() )->show(); 542 ( m_curSession->widgetStack() )->show();
543 543
544 ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); 544 ( ( m_curSession->emulationHandler() )->cornerButton() )->show();
545 545
546 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 546 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
547 } 547 }
548 548
549 m_isFullscreen = !m_isFullscreen; 549 m_isFullscreen = !m_isFullscreen;
550} 550}
551 551
552 552
553void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { 553void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) {
554 554
555 if ( m_curSession ) { 555 if ( m_curSession ) {
556 556
557 QEvent::Type state; 557 QEvent::Type state;
558 558
559 if (pressed) state = QEvent::KeyPress; 559 if (pressed) state = QEvent::KeyPress;
560 else state = QEvent::KeyRelease; 560 else state = QEvent::KeyRelease;
561 561
562 QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); 562 QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode)));
563 563
564 // where should i send this event? doesnt work sending it here 564 // is this the best way to do this? cant figure out any other way to work
565 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); 565 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke);
566 ke.ignore(); 566 ke.ignore();
567 } 567 }
568} 568}
569void MainWindow::slotCopy() { 569void MainWindow::slotCopy() {
570 if (!currentSession() ) return; 570 if (!currentSession() ) return;
571 currentSession()->emulationHandler()->copy(); 571 currentSession()->emulationHandler()->copy();
572} 572}
573void MainWindow::slotPaste() { 573void MainWindow::slotPaste() {
574 if (!currentSession() ) return; 574 if (!currentSession() ) return;
575 currentSession()->emulationHandler()->paste(); 575 currentSession()->emulationHandler()->paste();
576} 576}
577 577
578/* 578/*
579 * Save the session 579 * Save the session
580 */ 580 */
581 581
582void MainWindow::slotSaveSession() { 582void MainWindow::slotSaveSession() {
583 if (!currentSession() ) { 583 if (!currentSession() ) {
584 QMessageBox::information(this, tr("Save Connection"), 584 QMessageBox::information(this, tr("Save Connection"),
585 tr("<qt>There is no Connection.</qt>"), 1 ); 585 tr("<qt>There is no Connection.</qt>"), 1 );
586 return; 586 return;
587 } 587 }
588 manager()->add( currentSession()->profile() ); 588 manager()->add( currentSession()->profile() );
589 manager()->save(); 589 manager()->save();
590 populateProfiles(); 590 populateProfiles();
591} 591}