summaryrefslogtreecommitdiff
authordrw <drw>2005-05-16 18:56:02 (UTC)
committer drw <drw>2005-05-16 18:56:02 (UTC)
commit348314c7411500e23ca467289ed92e446be9121b (patch) (unidiff)
treef2eea2bec6b6e49f66d4a373b94d2e73f6937c46
parent17b9be61d7de14dea0d662a496e3d08bc9b1662e (diff)
downloadopie-348314c7411500e23ca467289ed92e446be9121b.zip
opie-348314c7411500e23ca467289ed92e446be9121b.tar.gz
opie-348314c7411500e23ca467289ed92e446be9121b.tar.bz2
Resource -> OResource
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/function_keyboard.cpp9
-rw-r--r--noncore/apps/opie-console/function_keyboard.h5
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp42
3 files changed, 30 insertions, 26 deletions
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp
index 0abe0d9..389618c 100644
--- a/noncore/apps/opie-console/function_keyboard.cpp
+++ b/noncore/apps/opie-console/function_keyboard.cpp
@@ -1,423 +1,422 @@
1#include "function_keyboard.h" 1#include "function_keyboard.h"
2 2
3/* QT */ 3/* QT */
4#include <qlayout.h> 4#include <qlayout.h>
5#include <qlistbox.h> 5#include <qlistbox.h>
6#include <qlabel.h> 6#include <qlabel.h>
7#include <qdir.h> 7#include <qdir.h>
8 8
9#define DEFAULT_ROWS 2 9#define DEFAULT_ROWS 2
10#define DEFAULT_COLS 12 10#define DEFAULT_COLS 12
11 11
12/* FunctionKeyboard {{{1 */ 12/* FunctionKeyboard {{{1 */
13 13
14FunctionKeyboard::FunctionKeyboard(QWidget *parent) : 14FunctionKeyboard::FunctionKeyboard(QWidget *parent) :
15 QFrame(parent), numRows(DEFAULT_ROWS), numCols(DEFAULT_COLS), 15 QFrame(parent), numRows(DEFAULT_ROWS), numCols(DEFAULT_COLS),
16 pressedRow(0), pressedCol(0) { 16 pressedRow(0), pressedCol(0) {
17 17
18 setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); 18 setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed));
19 19
20 /* 20 /*
21 * all the saving/loading is now done in a profile. downside is that you cant modify 21 * all the saving/loading is now done in a profile. downside is that you cant modify
22 * the keyboard for all profiles, but must do it on a profile-basis 22 * the keyboard for all profiles, but must do it on a profile-basis
23 * 23 *
24 24
25 Config conf("opie-console-keys"); 25 Config conf("opie-console-keys");
26 conf.setGroup("keys"); 26 conf.setGroup("keys");
27 for (uint r = 0; r < numRows; r++) 27 for (uint r = 0; r < numRows; r++)
28 for (uint c = 0; c < numCols; c++) { 28 for (uint c = 0; c < numCols; c++) {
29 29
30 QString handle = "r" + QString::number(r) + "c" + QString::number(c); 30 QString handle = "r" + QString::number(r) + "c" + QString::number(c);
31 QStringList value_list = conf.readListEntry( handle, '|'); 31 QStringList value_list = conf.readListEntry( handle, '|');
32 32
33 if (value_list.isEmpty()) continue; 33 if (value_list.isEmpty()) continue;
34 34
35 keys.insert( 35 keys.insert(
36 36
37 handle, 37 handle,
38 FKey (value_list[0], value_list[1], value_list[2].toUShort(), value_list[3].toUShort()) 38 FKey (value_list[0], value_list[1], value_list[2].toUShort(), value_list[3].toUShort())
39 ); 39 );
40 } 40 }
41 */ 41 */
42 if (keys.isEmpty()) loadDefaults(); 42 if (keys.isEmpty()) loadDefaults();
43 43
44 44
45 45
46} 46}
47 47
48FunctionKeyboard::~FunctionKeyboard() {} 48FunctionKeyboard::~FunctionKeyboard() {}
49 49
50void FunctionKeyboard::changeRows(int r) { 50void FunctionKeyboard::changeRows(int r) {
51 51
52 numRows = r; 52 numRows = r;
53 53
54 // have to do this so the whole thing gets redrawn 54 // have to do this so the whole thing gets redrawn
55 hide(); show(); 55 hide(); show();
56} 56}
57void FunctionKeyboard::changeCols(int c) { 57void FunctionKeyboard::changeCols(int c) {
58 58
59 numCols = c; 59 numCols = c;
60 keyWidth = (double)width()/numCols; // have to reset this thing too 60 keyWidth = (double)width()/numCols; // have to reset this thing too
61 repaint(false); 61 repaint(false);
62} 62}
63void FunctionKeyboard::load (const Profile& prof) { 63void FunctionKeyboard::load (const Profile& prof) {
64 64
65 keys.clear(); 65 keys.clear();
66 66
67 numRows = prof.readNumEntry("keb_rows", 2); 67 numRows = prof.readNumEntry("keb_rows", 2);
68 numCols = prof.readNumEntry("keb_cols", 10); 68 numCols = prof.readNumEntry("keb_cols", 10);
69 keyWidth = (double)width()/numCols; // have to reset this thing too 69 keyWidth = (double)width()/numCols; // have to reset this thing too
70 70
71 /* load all the keys to the keyboard */ 71 /* load all the keys to the keyboard */
72 for (ushort i = 0; i <= numRows - 1; i++) 72 for (ushort i = 0; i <= numRows - 1; i++)
73 for (ushort j = 0; j <= numCols - 1; j++) { 73 for (ushort j = 0; j <= numCols - 1; j++) {
74 74
75 QString h = "r" + QString::number(i) + "c" + QString::number(j); 75 QString h = "r" + QString::number(i) + "c" + QString::number(j);
76 QString values = prof.readEntry("keb_" + h); 76 QString values = prof.readEntry("keb_" + h);
77 77
78 if (!values.isEmpty()) { 78 if (!values.isEmpty()) {
79 79
80 QStringList l = QStringList::split(QChar('|'), values, TRUE); 80 QStringList l = QStringList::split(QChar('|'), values, TRUE);
81 keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt()); 81 keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt());
82 82
83 // load pixmap if used 83 // load pixmap if used
84 if (!l[1].isEmpty()) { 84 if (!l[1].isEmpty()) {
85 85
86 keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) ); 86 keys[h].pix = new QPixmap( Opie::Core::OResource::loadPixmap( "console/keys/" + l[1] ) );
87 } 87 }
88 } 88 }
89 } 89 }
90 90
91 if (keys.isEmpty()) loadDefaults(); 91 if (keys.isEmpty()) loadDefaults();
92 92
93 hide(); 93 hide();
94 show(); 94 show();
95 95
96} 96}
97 97
98void FunctionKeyboard::paintEvent(QPaintEvent *e) { 98void FunctionKeyboard::paintEvent(QPaintEvent *e) {
99 99
100 QPainter p(this); 100 QPainter p(this);
101 p.setClipRect(e->rect()); 101 p.setClipRect(e->rect());
102 p.fillRect(0, 0, width(), height(), QColor(255,255,255)); 102 p.fillRect(0, 0, width(), height(), QColor(255,255,255));
103 103
104 p.setPen(QColor(0,0,0)); 104 p.setPen(QColor(0,0,0));
105 105
106 /* those decimals do count! becomes short if use plain int */ 106 /* those decimals do count! becomes short if use plain int */
107 for (double i = 0; i <= width(); i += keyWidth) { 107 for (double i = 0; i <= width(); i += keyWidth) {
108 108
109 p.drawLine((int)i, 0, (int)i, height()); 109 p.drawLine((int)i, 0, (int)i, height());
110 } 110 }
111 111
112 // sometimes the last line doesnt get drawn 112 // sometimes the last line doesnt get drawn
113 p.drawLine(width() -1, 0, width() -1, height()); 113 p.drawLine(width() -1, 0, width() -1, height());
114 114
115 for (int i = 0; i <= height(); i += keyHeight) { 115 for (int i = 0; i <= height(); i += keyHeight) {
116 116
117 p.drawLine(0, i, width(), i); 117 p.drawLine(0, i, width(), i);
118 } 118 }
119 119
120 for (uint r = 0; r < numRows; r++) { 120 for (uint r = 0; r < numRows; r++) {
121 for (uint c = 0; c < numCols; c++) { 121 for (uint c = 0; c < numCols; c++) {
122 122
123 QString handle = "r" + QString::number(r) + "c" + QString::number(c); 123 QString handle = "r" + QString::number(r) + "c" + QString::number(c);
124 if (keys.contains(handle)) { 124 if (keys.contains(handle)) {
125 125
126 if (keys[handle].pixFile.isEmpty()) 126 if (keys[handle].pixFile.isEmpty())
127 p.drawText( c * keyWidth + 1, r * keyHeight + 1, 127 p.drawText( c * keyWidth + 1, r * keyHeight + 1,
128 keyWidth, keyHeight, 128 keyWidth, keyHeight,
129 Qt::AlignHCenter | Qt::AlignVCenter, 129 Qt::AlignHCenter | Qt::AlignVCenter,
130 keys[handle].label 130 keys[handle].label
131 ); 131 );
132 else { 132 else {
133 133
134 ushort centerX = (ushort)(c *keyWidth) + (ushort)(keyWidth - keys[handle].pix->width()) / 2; 134 ushort centerX = (ushort)(c *keyWidth) + (ushort)(keyWidth - keys[handle].pix->width()) / 2;
135 ushort centerY = r * keyHeight + (keyHeight - keys[handle].pix->height()) / 2; 135 ushort centerY = r * keyHeight + (keyHeight - keys[handle].pix->height()) / 2;
136 p.drawPixmap(centerX, centerY, *keys[handle].pix); 136 p.drawPixmap(centerX, centerY, *keys[handle].pix);
137 } 137 }
138 } 138 }
139 } 139 }
140 } 140 }
141} 141}
142 142
143void FunctionKeyboard::paintKey(uint row, uint col) { 143void FunctionKeyboard::paintKey(uint row, uint col) {
144 144
145 QPainter p(this); 145 QPainter p(this);
146 146
147 p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1), 147 p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1),
148 QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)), 148 QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)),
149 (pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255)); 149 (pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255));
150 150
151 QString handle ("r" + QString::number(row) + "c" + QString::number(col)); 151 QString handle ("r" + QString::number(row) + "c" + QString::number(col));
152 if (keys[handle].pixFile.isEmpty()) 152 if (keys[handle].pixFile.isEmpty())
153 p.drawText( 153 p.drawText(
154 col * keyWidth + 1, row * keyHeight + 1, 154 col * keyWidth + 1, row * keyHeight + 1,
155 keyWidth, keyHeight, 155 keyWidth, keyHeight,
156 Qt::AlignHCenter | Qt::AlignVCenter, 156 Qt::AlignHCenter | Qt::AlignVCenter,
157 keys[handle].label 157 keys[handle].label
158 ); 158 );
159 else { 159 else {
160 160
161 ushort centerX = (ushort)(col *keyWidth) + (ushort)(keyWidth - keys[handle].pix->width()) / 2; 161 ushort centerX = (ushort)(col *keyWidth) + (ushort)(keyWidth - keys[handle].pix->width()) / 2;
162 ushort centerY = row * keyHeight + (keyHeight - keys[handle].pix->height()) / 2; 162 ushort centerY = row * keyHeight + (keyHeight - keys[handle].pix->height()) / 2;
163 p.drawPixmap(centerX, centerY, *keys[handle].pix); 163 p.drawPixmap(centerX, centerY, *keys[handle].pix);
164 } 164 }
165 165
166 if (col == numCols - 1) { 166 if (col == numCols - 1) {
167 167
168 // sometimes it doesnt draw the last line 168 // sometimes it doesnt draw the last line
169 169
170 p.drawLine((col+1) * keyWidth -1, row * keyHeight, 170 p.drawLine((col+1) * keyWidth -1, row * keyHeight,
171 (col+1) * keyWidth -1, (row + 1) * keyHeight 171 (col+1) * keyWidth -1, (row + 1) * keyHeight
172 ); 172 );
173 } 173 }
174 174
175} 175}
176 176
177void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { 177void FunctionKeyboard::mousePressEvent(QMouseEvent *e) {
178 178
179 pressedRow = e->y() / keyHeight; 179 pressedRow = e->y() / keyHeight;
180 pressedCol = (int) (e->x() / keyWidth); 180 pressedCol = (int) (e->x() / keyWidth);
181 181
182 paintKey(pressedRow, pressedCol); 182 paintKey(pressedRow, pressedCol);
183 183
184 // emit that sucker! 184 // emit that sucker!
185 FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; 185 FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)];
186 emit keyPressed(k, pressedRow, pressedCol, 1); 186 emit keyPressed(k, pressedRow, pressedCol, 1);
187 187
188} 188}
189 189
190void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { 190void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) {
191 191
192 if (pressedRow != -1 && pressedRow != -1) { 192 if (pressedRow != -1 && pressedRow != -1) {
193 193
194 int row = pressedRow; pressedRow = -1; 194 int row = pressedRow; pressedRow = -1;
195 int col = pressedCol; pressedCol = -1; 195 int col = pressedCol; pressedCol = -1;
196 paintKey(row, col); 196 paintKey(row, col);
197 197
198 FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; 198 FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)];
199 emit keyPressed(k, row, col, 0); 199 emit keyPressed(k, row, col, 0);
200 } 200 }
201 201
202} 202}
203 203
204 204
205void FunctionKeyboard::resizeEvent(QResizeEvent*) { 205void FunctionKeyboard::resizeEvent(QResizeEvent*) {
206 206
207 /* set he default font height/width */ 207 /* set he default font height/width */
208 QFontMetrics fm=fontMetrics(); 208 QFontMetrics fm=fontMetrics();
209 keyHeight = fm.lineSpacing() + 2; 209 keyHeight = fm.lineSpacing() + 2;
210 keyWidth = (double)width()/numCols; 210 keyWidth = (double)width()/numCols;
211 211
212} 212}
213 213
214QSize FunctionKeyboard::sizeHint() const { 214QSize FunctionKeyboard::sizeHint() const {
215 215
216 return QSize(width(), keyHeight * numRows + 1); 216 return QSize(width(), keyHeight * numRows + 1);
217} 217}
218 218
219void FunctionKeyboard::loadDefaults() { 219void FunctionKeyboard::loadDefaults() {
220 220
221 numRows = DEFAULT_ROWS; 221 numRows = DEFAULT_ROWS;
222 numCols = DEFAULT_COLS; 222 numCols = DEFAULT_COLS;
223 keyWidth = (double)width()/numCols; // have to reset this thing too 223 keyWidth = (double)width()/numCols; // have to reset this thing too
224 224
225 keys.insert( "r0c0", FKey ("Enter", "enter", Qt::Key_Enter, 0)); 225 keys.insert( "r0c0", FKey ("Enter", "enter", Qt::Key_Enter, 0));
226 keys.insert( "r0c1", FKey ("Space", "space", Qt::Key_Space, Qt::Key_Space)); 226 keys.insert( "r0c1", FKey ("Space", "space", Qt::Key_Space, Qt::Key_Space));
227 keys.insert( "r0c2", FKey ("Tab", "tab", Qt::Key_Tab, 0)); 227 keys.insert( "r0c2", FKey ("Tab", "tab", Qt::Key_Tab, 0));
228 keys.insert( "r0c3", FKey ("Up", "up", Qt::Key_Up, 0)); 228 keys.insert( "r0c3", FKey ("Up", "up", Qt::Key_Up, 0));
229 keys.insert( "r0c4", FKey ("Down", "down", Qt::Key_Down, 0)); 229 keys.insert( "r0c4", FKey ("Down", "down", Qt::Key_Down, 0));
230 230
231 keys.insert( "r0c7", FKey ("Ho", 0, 4112, 0)); 231 keys.insert( "r0c7", FKey ("Ho", 0, 4112, 0));
232 keys.insert( "r0c8", FKey ("End", 0, 4113, 0)); 232 keys.insert( "r0c8", FKey ("End", 0, 4113, 0));
233 keys.insert( "r0c9", FKey ("Pu", 0, 4118, 0)); 233 keys.insert( "r0c9", FKey ("Pu", 0, 4118, 0));
234 keys.insert( "r0c10", FKey ("Pd", 0, 4119, 0)); 234 keys.insert( "r0c10", FKey ("Pd", 0, 4119, 0));
235 keys.insert( "r0c11", FKey ("Esc", 0, Qt::Key_Escape, 0xfff)); 235 keys.insert( "r0c11", FKey ("Esc", 0, Qt::Key_Escape, 0xfff));
236 236
237 keys.insert( "r1c0", FKey ("F1", 0, 4144, 0)); 237 keys.insert( "r1c0", FKey ("F1", 0, 4144, 0));
238 keys.insert( "r1c1", FKey ("F2", 0, 4145, 0)); 238 keys.insert( "r1c1", FKey ("F2", 0, 4145, 0));
239 keys.insert( "r1c2", FKey ("F3", 0, 4146, 0)); 239 keys.insert( "r1c2", FKey ("F3", 0, 4146, 0));
240 keys.insert( "r1c3", FKey ("F4", 0, 4147, 0)); 240 keys.insert( "r1c3", FKey ("F4", 0, 4147, 0));
241 keys.insert( "r1c4", FKey ("F5", 0, 4148, 0)); 241 keys.insert( "r1c4", FKey ("F5", 0, 4148, 0));
242 keys.insert( "r1c5", FKey ("F6", 0, 4149, 0)); 242 keys.insert( "r1c5", FKey ("F6", 0, 4149, 0));
243 keys.insert( "r1c6", FKey ("F7", 0, 4150, 0)); 243 keys.insert( "r1c6", FKey ("F7", 0, 4150, 0));
244 keys.insert( "r1c7", FKey ("F8", 0, 4151, 0)); 244 keys.insert( "r1c7", FKey ("F8", 0, 4151, 0));
245 keys.insert( "r1c8", FKey ("F9", 0, 4152, 0)); 245 keys.insert( "r1c8", FKey ("F9", 0, 4152, 0));
246 keys.insert( "r1c9", FKey ("F10", 0, 4153, 0)); 246 keys.insert( "r1c9", FKey ("F10", 0, 4153, 0));
247 keys.insert( "r1c10", FKey ("F11", 0, 4154, 0)); 247 keys.insert( "r1c10", FKey ("F11", 0, 4154, 0));
248 keys.insert( "r1c11", FKey ("F12", 0, 4155, 0)); 248 keys.insert( "r1c11", FKey ("F12", 0, 4155, 0));
249 249
250 250
251} 251}
252 252
253/* FunctionKeyboardConfig {{{1 */ 253/* FunctionKeyboardConfig {{{1 */
254 254
255FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na ) 255FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na )
256 : ProfileDialogKeyWidget(name, parent, na), 256 : ProfileDialogKeyWidget(name, parent, na),
257 selectedRow(0), selectedCol(0) 257 selectedRow(0), selectedCol(0)
258{ 258{
259 kb = new FunctionKeyboard(this); 259 kb = new FunctionKeyboard(this);
260 connect (kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)), 260 connect (kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)),
261 this, SLOT(slotKeyPressed(FKey,ushort,ushort,bool))); 261 this, SLOT(slotKeyPressed(FKey,ushort,ushort,bool)));
262 262
263 QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimensions"), this); 263 QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimensions"), this);
264 QLabel *l = new QLabel(tr("Rows"), dimentions); 264 QLabel *l = new QLabel(tr("Rows"), dimentions);
265 m_rowBox = new QSpinBox(1, 15, 1, dimentions); 265 m_rowBox = new QSpinBox(1, 15, 1, dimentions);
266 connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int))); 266 connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int)));
267 l = new QLabel(tr("Columns"), dimentions); 267 l = new QLabel(tr("Columns"), dimentions);
268 m_colBox = new QSpinBox(1, 15, 1, dimentions); 268 m_colBox = new QSpinBox(1, 15, 1, dimentions);
269 connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int))); 269 connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int)));
270 270
271 QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this); 271 QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this);
272 l = new QLabel(tr("Label"), editKey); 272 l = new QLabel(tr("Label"), editKey);
273 m_labels = new QComboBox(true, editKey); 273 m_labels = new QComboBox(true, editKey);
274 m_labels->setInsertionPolicy(QComboBox::AtCurrent); 274 m_labels->setInsertionPolicy(QComboBox::AtCurrent);
275 m_labels->insertItem(""); 275 m_labels->insertItem("");
276 276
277 QStringList files = QDir( QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList(); 277 QStringList files = QDir( QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList();
278 278
279 for (uint i = 0; i < files.count(); i++) { 279 for (uint i = 0; i < files.count(); i++) {
280 280 m_labels->insertItem( Opie::Core::OResource::loadPixmap("console/keys/" + files[i]), files[i]);
281 m_labels->insertItem( Resource::loadPixmap("console/keys/" + files[i]), files[i]);
282 } 281 }
283 connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int))); 282 connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int)));
284 connect (m_labels, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeLabelText(const QString&))); 283 connect (m_labels, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeLabelText(const QString&)));
285 284
286 l = new QLabel(tr("Q Keycode", "Qt Key Code for the OnScreen Keyboard"), editKey); 285 l = new QLabel(tr("Q Keycode", "Qt Key Code for the OnScreen Keyboard"), editKey);
287 m_qvalues = new QComboBox(true, editKey); 286 m_qvalues = new QComboBox(true, editKey);
288 m_qvalues->setInsertionPolicy(QComboBox::AtTop); 287 m_qvalues->setInsertionPolicy(QComboBox::AtTop);
289 m_qvalues->setDuplicatesEnabled(false); 288 m_qvalues->setDuplicatesEnabled(false);
290 m_qvalues->insertItem(""); 289 m_qvalues->insertItem("");
291 connect (m_qvalues, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeQCode(const QString&))); 290 connect (m_qvalues, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeQCode(const QString&)));
292 291
293 l = new QLabel(tr("Unicode Value", "The Unicode value of the key"), editKey); 292 l = new QLabel(tr("Unicode Value", "The Unicode value of the key"), editKey);
294 m_uniValues = new QComboBox(true, editKey); 293 m_uniValues = new QComboBox(true, editKey);
295 m_uniValues->setInsertionPolicy(QComboBox::AtTop); 294 m_uniValues->setInsertionPolicy(QComboBox::AtTop);
296 m_uniValues->setDuplicatesEnabled(false); 295 m_uniValues->setDuplicatesEnabled(false);
297 m_uniValues->insertItem(""); 296 m_uniValues->insertItem("");
298 connect (m_uniValues, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeUnicode(const QString&))); 297 connect (m_uniValues, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeUnicode(const QString&)));
299 298
300 QVBoxLayout *root = new QVBoxLayout(this, 2); 299 QVBoxLayout *root = new QVBoxLayout(this, 2);
301 root->addWidget(kb); 300 root->addWidget(kb);
302 root->addWidget(dimentions); 301 root->addWidget(dimentions);
303 root->addWidget(editKey); 302 root->addWidget(editKey);
304} 303}
305FunctionKeyboardConfig::~FunctionKeyboardConfig() { 304FunctionKeyboardConfig::~FunctionKeyboardConfig() {
306 305
307} 306}
308void FunctionKeyboardConfig::load (const Profile& prof) { 307void FunctionKeyboardConfig::load (const Profile& prof) {
309 308
310 kb->keys.clear(); 309 kb->keys.clear();
311 kb->loadDefaults(); 310 kb->loadDefaults();
312 311
313 m_rowBox->setValue(prof.readNumEntry("keb_rows", 2)); 312 m_rowBox->setValue(prof.readNumEntry("keb_rows", 2));
314 m_colBox->setValue(prof.readNumEntry("keb_cols", 10)); 313 m_colBox->setValue(prof.readNumEntry("keb_cols", 10));
315 314
316 /* load all the keys to the keyboard */ 315 /* load all the keys to the keyboard */
317 for (int i = 0; i <= m_rowBox->value() -1; i++) 316 for (int i = 0; i <= m_rowBox->value() -1; i++)
318 for (int j = 0; j <= m_colBox->value() -1; j++) { 317 for (int j = 0; j <= m_colBox->value() -1; j++) {
319 318
320 QString h = "r" + QString::number(i) + "c" + QString::number(j); 319 QString h = "r" + QString::number(i) + "c" + QString::number(j);
321 QString values = prof.readEntry("keb_" + h); 320 QString values = prof.readEntry("keb_" + h);
322 321
323 if (!values.isEmpty()) { 322 if (!values.isEmpty()) {
324 323
325 QStringList l = QStringList::split(QChar('|'), values, TRUE); 324 QStringList l = QStringList::split(QChar('|'), values, TRUE);
326 kb->keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt()); 325 kb->keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt());
327 326
328 // load pixmap if used 327 // load pixmap if used
329 if (!l[1].isEmpty()) { 328 if (!l[1].isEmpty()) {
330 329
331 kb->keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) ); 330 kb->keys[h].pix = new QPixmap( Opie::Core::OResource::loadPixmap( "console/keys/" + l[1] ) );
332 } 331 }
333 } 332 }
334 } 333 }
335 334
336} 335}
337void FunctionKeyboardConfig::save (Profile& prof) { 336void FunctionKeyboardConfig::save (Profile& prof) {
338 337
339 prof.writeEntry("keb_rows", m_rowBox->value()); 338 prof.writeEntry("keb_rows", m_rowBox->value());
340 prof.writeEntry("keb_cols", m_colBox->value()); 339 prof.writeEntry("keb_cols", m_colBox->value());
341 340
342 QMap<QString, FKey>::Iterator it; 341 QMap<QString, FKey>::Iterator it;
343 for ( it = kb->keys.begin(); it != kb->keys.end(); it++) { 342 for ( it = kb->keys.begin(); it != kb->keys.end(); it++) {
344 343
345 FKey k = it.data(); 344 FKey k = it.data();
346 QString entry = k.label + "|" 345 QString entry = k.label + "|"
347 + k.pixFile + "|" 346 + k.pixFile + "|"
348 + QString::number(k.qcode) + "|" 347 + QString::number(k.qcode) + "|"
349 + QString::number(k.unicode); 348 + QString::number(k.unicode);
350 349
351 prof.writeEntry("keb_" + it.key(), entry); 350 prof.writeEntry("keb_" + it.key(), entry);
352 351
353 } 352 }
354 353
355} 354}
356void FunctionKeyboardConfig::slotChangeRows(int r) { 355void FunctionKeyboardConfig::slotChangeRows(int r) {
357 356
358 kb->changeRows(r); 357 kb->changeRows(r);
359 358
360} 359}
361void FunctionKeyboardConfig::slotChangeCols(int c) { 360void FunctionKeyboardConfig::slotChangeCols(int c) {
362 361
363 kb->changeCols(c); 362 kb->changeCols(c);
364} 363}
365void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pressed) { 364void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pressed) {
366 365
367 if (!pressed) return; 366 if (!pressed) return;
368 367
369 selectedHandle = "r" + QString::number(r) + 368 selectedHandle = "r" + QString::number(r) +
370 "c" + QString::number(c); 369 "c" + QString::number(c);
371 selectedRow = r; 370 selectedRow = r;
372 selectedCol = c; 371 selectedCol = c;
373 372
374 if (k.pixFile.isEmpty()) { 373 if (k.pixFile.isEmpty()) {
375 374
376 m_labels->setEditable(true); 375 m_labels->setEditable(true);
377 m_labels->setCurrentItem(0); 376 m_labels->setCurrentItem(0);
378 m_labels->changeItem(k.label, 0); 377 m_labels->changeItem(k.label, 0);
379 378
380 } else { 379 } else {
381 380
382 // any better way to select the pixmap? 381 // any better way to select the pixmap?
383 m_labels->setCurrentItem((m_labels->listBox())->index((m_labels->listBox())->findItem(kb->keys[selectedHandle].pixFile))); 382 m_labels->setCurrentItem((m_labels->listBox())->index((m_labels->listBox())->findItem(kb->keys[selectedHandle].pixFile)));
384 m_labels->setEditable(false); 383 m_labels->setEditable(false);
385 } 384 }
386 m_qvalues->changeItem(QString::number(k.qcode), 0); 385 m_qvalues->changeItem(QString::number(k.qcode), 0);
387 m_uniValues->changeItem(QString::number(k.unicode), 0); 386 m_uniValues->changeItem(QString::number(k.unicode), 0);
388} 387}
389void FunctionKeyboardConfig::slotChangeIcon(int index) { 388void FunctionKeyboardConfig::slotChangeIcon(int index) {
390 389
391 if (index == 0) { 390 if (index == 0) {
392 391
393 // is text 392 // is text
394 m_labels->setEditable(true); 393 m_labels->setEditable(true);
395 // why tf does the text get erased unless i do this? 394 // why tf does the text get erased unless i do this?
396 m_labels->changeItem(m_labels->text(0), 0); 395 m_labels->changeItem(m_labels->text(0), 0);
397 396
398 kb->keys[selectedHandle].pixFile = ""; 397 kb->keys[selectedHandle].pixFile = "";
399 delete kb->keys[selectedHandle].pix; 398 delete kb->keys[selectedHandle].pix;
400 399
401 } else { 400 } else {
402 401
403 // is a pixmap 402 // is a pixmap
404 m_labels->setEditable(false); 403 m_labels->setEditable(false);
405 kb->keys[selectedHandle].pixFile = m_labels->currentText(); 404 kb->keys[selectedHandle].pixFile = m_labels->currentText();
406 kb->keys[selectedHandle].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + m_labels->currentText() ) ); 405 kb->keys[selectedHandle].pix = new QPixmap( Opie::Core::OResource::loadPixmap( "console/keys/" + m_labels->currentText() ) );
407 } 406 }
408 kb->paintKey(selectedRow, selectedCol); 407 kb->paintKey(selectedRow, selectedCol);
409} 408}
410void FunctionKeyboardConfig::slotChangeLabelText(const QString &label) { 409void FunctionKeyboardConfig::slotChangeLabelText(const QString &label) {
411 410
412 kb->keys[selectedHandle].label = label; 411 kb->keys[selectedHandle].label = label;
413 412
414 kb->paintKey(selectedRow, selectedCol); 413 kb->paintKey(selectedRow, selectedCol);
415} 414}
416void FunctionKeyboardConfig::slotChangeQCode(const QString& qcode) { 415void FunctionKeyboardConfig::slotChangeQCode(const QString& qcode) {
417 416
418 kb->keys[selectedHandle].qcode = qcode.toUInt(); 417 kb->keys[selectedHandle].qcode = qcode.toUInt();
419} 418}
420void FunctionKeyboardConfig::slotChangeUnicode(const QString& uni) { 419void FunctionKeyboardConfig::slotChangeUnicode(const QString& uni) {
421 420
422 kb->keys[selectedHandle].unicode = uni.toUInt(); 421 kb->keys[selectedHandle].unicode = uni.toUInt();
423} 422}
diff --git a/noncore/apps/opie-console/function_keyboard.h b/noncore/apps/opie-console/function_keyboard.h
index a60ff4b..b7e211c 100644
--- a/noncore/apps/opie-console/function_keyboard.h
+++ b/noncore/apps/opie-console/function_keyboard.h
@@ -1,112 +1,113 @@
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 <opie2/oresource.h>
5
4#include <qpe/config.h> 6#include <qpe/config.h>
5#include <qpe/resource.h>
6#include <qpe/qpeapplication.h> 7#include <qpe/qpeapplication.h>
7#include <qframe.h> 8#include <qframe.h>
8#include <qpainter.h> 9#include <qpainter.h>
9#include <qvbox.h> 10#include <qvbox.h>
10#include <qgroupbox.h> 11#include <qgroupbox.h>
11#include <qmap.h> 12#include <qmap.h>
12#include <qspinbox.h> 13#include <qspinbox.h>
13#include <qcombobox.h> 14#include <qcombobox.h>
14#include "profiledialogwidget.h" 15#include "profiledialogwidget.h"
15 16
16 17
17struct FKey { 18struct FKey {
18 19
19 FKey(): qcode(0), unicode(0) {}; 20 FKey(): qcode(0), unicode(0) {};
20 FKey(const QString &l, const QString &f, ushort q, ushort u): 21 FKey(const QString &l, const QString &f, ushort q, ushort u):
21 label(l), pixFile(f), qcode(q), unicode(u) { 22 label(l), pixFile(f), qcode(q), unicode(u) {
22 23
23 if (!f.isEmpty()) { 24 if (!f.isEmpty()) {
24 25
25 pix = new QPixmap ( Resource::loadPixmap("console/keys/" + f ) ); 26 pix = new QPixmap ( Opie::Core::OResource::loadPixmap("console/keys/" + f ) );
26 } 27 }
27 }; 28 };
28 29
29 QString label; 30 QString label;
30 QPixmap *pix; 31 QPixmap *pix;
31 QString pixFile; 32 QString pixFile;
32 ushort qcode; 33 ushort qcode;
33 ushort unicode; 34 ushort unicode;
34}; 35};
35 36
36class FunctionKeyboard : public QFrame { 37class FunctionKeyboard : public QFrame {
37 Q_OBJECT 38 Q_OBJECT
38 39
39public: 40public:
40 FunctionKeyboard(QWidget *parent = 0); 41 FunctionKeyboard(QWidget *parent = 0);
41 ~FunctionKeyboard(); 42 ~FunctionKeyboard();
42 43
43 friend class FunctionKeyboardConfig; 44 friend class FunctionKeyboardConfig;
44 45
45 void changeRows(int); 46 void changeRows(int);
46 void changeCols(int); 47 void changeCols(int);
47 48
48 void load(const Profile &); 49 void load(const Profile &);
49 void loadDefaults(); 50 void loadDefaults();
50 51
51 void paintEvent(QPaintEvent *); 52 void paintEvent(QPaintEvent *);
52 void paintKey(uint, uint); 53 void paintKey(uint, uint);
53 void mousePressEvent(QMouseEvent*); 54 void mousePressEvent(QMouseEvent*);
54 void mouseReleaseEvent(QMouseEvent*); 55 void mouseReleaseEvent(QMouseEvent*);
55 void resizeEvent(QResizeEvent*); 56 void resizeEvent(QResizeEvent*);
56 QSize sizeHint() const; 57 QSize sizeHint() const;
57 58
58signals: 59signals:
59 60
60 void keyPressed(FKey, ushort, ushort, bool); 61 void keyPressed(FKey, ushort, ushort, bool);
61 62
62 63
63private: 64private:
64 65
65 // thie key for the map is the row/col 66 // thie key for the map is the row/col
66 QMap<QString, FKey> keys; 67 QMap<QString, FKey> keys;
67 68
68 uint numRows; 69 uint numRows;
69 int test; 70 int test;
70 uint numCols; 71 uint numCols;
71 uint keyHeight; 72 uint keyHeight;
72 double keyWidth; // decimal point matters! 73 double keyWidth; // decimal point matters!
73 74
74 int pressedRow, pressedCol; 75 int pressedRow, pressedCol;
75 76
76 QObject *parent; 77 QObject *parent;
77 78
78}; 79};
79 80
80class FunctionKeyboardConfig : public ProfileDialogKeyWidget { 81class FunctionKeyboardConfig : public ProfileDialogKeyWidget {
81 82
82 Q_OBJECT 83 Q_OBJECT
83 84
84public: 85public:
85 FunctionKeyboardConfig(const QString& name, QWidget *wid, const char* name = 0l ); 86 FunctionKeyboardConfig(const QString& name, QWidget *wid, const char* name = 0l );
86 ~FunctionKeyboardConfig(); 87 ~FunctionKeyboardConfig();
87 88
88 void load(const Profile&); 89 void load(const Profile&);
89 void save(Profile&); 90 void save(Profile&);
90 91
91private slots: 92private slots:
92 93
93 void slotKeyPressed(FKey, ushort, ushort, bool); 94 void slotKeyPressed(FKey, ushort, ushort, bool);
94 void slotChangeRows(int); 95 void slotChangeRows(int);
95 void slotChangeCols(int); 96 void slotChangeCols(int);
96 void slotChangeIcon(int); 97 void slotChangeIcon(int);
97 void slotChangeLabelText(const QString &); 98 void slotChangeLabelText(const QString &);
98 void slotChangeQCode(const QString &); 99 void slotChangeQCode(const QString &);
99 void slotChangeUnicode(const QString &); 100 void slotChangeUnicode(const QString &);
100 101
101private: 102private:
102 103
103 QString selectedHandle; 104 QString selectedHandle;
104 ushort selectedRow, selectedCol; 105 ushort selectedRow, selectedCol;
105 106
106 FunctionKeyboard *kb; 107 FunctionKeyboard *kb;
107 QSpinBox *m_rowBox, *m_colBox; 108 QSpinBox *m_rowBox, *m_colBox;
108 QComboBox *m_labels, *m_qvalues, *m_uniValues; 109 QComboBox *m_labels, *m_qvalues, *m_uniValues;
109 110
110}; 111};
111 112
112#endif 113#endif
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index eaa78c8..45a662c 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,789 +1,793 @@
1#include "TEmulation.h" 1#include "TEmulation.h"
2#include "profileeditordialog.h" 2#include "profileeditordialog.h"
3#include "configdialog.h" 3#include "configdialog.h"
4#include "default.h" 4#include "default.h"
5#include "profilemanager.h" 5#include "profilemanager.h"
6#include "mainwindow.h" 6#include "mainwindow.h"
7#include "tabwidget.h" 7#include "tabwidget.h"
8#include "transferdialog.h" 8#include "transferdialog.h"
9#include "function_keyboard.h" 9#include "function_keyboard.h"
10#include "emulation_handler.h" 10#include "emulation_handler.h"
11#include "script.h" 11#include "script.h"
12#include "fixit.h" 12#include "fixit.h"
13 13
14/* OPIE */ 14/* OPIE */
15#include <opie2/ofiledialog.h> 15#include <opie2/ofiledialog.h>
16#include <opie2/oresource.h>
16#include <qpe/filemanager.h> 17#include <qpe/filemanager.h>
17using namespace Opie::Ui; 18using namespace Opie::Ui;
18 19
19/* QT */ 20/* QT */
20#include <qaction.h> 21#include <qaction.h>
21#include <qmenubar.h> 22#include <qmenubar.h>
22#include <qtoolbar.h> 23#include <qtoolbar.h>
23#include <qmessagebox.h> 24#include <qmessagebox.h>
24#include <qwhatsthis.h> 25#include <qwhatsthis.h>
25#include <qfileinfo.h> 26#include <qfileinfo.h>
26 27
27/* STD */ 28/* STD */
28#include <assert.h> 29#include <assert.h>
29 30
30#include <opie2/oconfig.h> 31#include <opie2/oconfig.h>
31 32
32MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { 33MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) {
33 34
34#ifdef FSCKED_DISTRI 35#ifdef FSCKED_DISTRI
35 FixIt fix; 36 FixIt fix;
36 fix.fixIt(); 37 fix.fixIt();
37#endif 38#endif
38 39
39 setCaption(QObject::tr("Opie Console") ); 40 setCaption(QObject::tr("Opie Console") );
40 KeyTrans::loadAll(); 41 KeyTrans::loadAll();
41 for (int i = 0; i < KeyTrans::count(); i++ ) { 42 for (int i = 0; i < KeyTrans::count(); i++ ) {
42 KeyTrans* s = KeyTrans::find(i ); 43 KeyTrans* s = KeyTrans::find(i );
43 assert( s ); 44 assert( s );
44 } 45 }
45 m_factory = new MetaFactory(); 46 m_factory = new MetaFactory();
46 Default def(m_factory); 47 Default def(m_factory);
47 m_sessions.setAutoDelete( TRUE ); 48 m_sessions.setAutoDelete( TRUE );
48 m_curSession = 0; 49 m_curSession = 0;
49 m_manager = new ProfileManager( m_factory ); 50 m_manager = new ProfileManager( m_factory );
50 m_manager->load(); 51 m_manager->load();
51 m_scriptsData.setAutoDelete(TRUE); 52 m_scriptsData.setAutoDelete(TRUE);
52 53
53 initUI(); 54 initUI();
54 populateProfiles(); 55 populateProfiles();
55 populateScripts(); 56 populateScripts();
56} 57}
57 58
58void MainWindow::initUI() { 59void MainWindow::initUI() {
59 60
60 setToolBarsMovable( FALSE ); 61 setToolBarsMovable( FALSE );
61 62
62 /* tool bar for the menu */ 63 /* tool bar for the menu */
63 m_tool = new QToolBar( this ); 64 m_tool = new QToolBar( this );
64 m_tool->setHorizontalStretchable( TRUE ); 65 m_tool->setHorizontalStretchable( TRUE );
65 66
66 m_bar = new QMenuBar( m_tool ); 67 m_bar = new QMenuBar( m_tool );
67 m_console = new QPopupMenu( this ); 68 m_console = new QPopupMenu( this );
68 m_scripts = new QPopupMenu( this ); 69 m_scripts = new QPopupMenu( this );
69 m_sessionsPop= new QPopupMenu( this ); 70 m_sessionsPop= new QPopupMenu( this );
70 m_scriptsPop = new QPopupMenu( this ); 71 m_scriptsPop = new QPopupMenu( this );
71 72
72 /* add a toolbar for icons */ 73 /* add a toolbar for icons */
73 m_icons = new QToolBar(this); 74 m_icons = new QToolBar(this);
74 75
75 /* 76 /*
76 * the settings action 77 * the settings action
77 */ 78 */
78 m_setProfiles = new QAction(tr("Configure Profiles"), 79 m_setProfiles = new QAction(tr("Configure Profiles"),
79 Resource::loadPixmap( "SettingsIcon" ), 80 Opie::Core::OResource::loadPixmap( "SettingsIcon", Opie::Core::OResource::SmallIcon ),
80 QString::null, 0, this, 0); 81 QString::null, 0, this, 0);
81 m_setProfiles->addTo( m_console ); 82 m_setProfiles->addTo( m_console );
82 connect( m_setProfiles, SIGNAL(activated() ), 83 connect( m_setProfiles, SIGNAL(activated() ),
83 this, SLOT(slotConfigure() ) ); 84 this, SLOT(slotConfigure() ) );
84 85
85 m_console->insertSeparator(); 86 m_console->insertSeparator();
86 /* 87 /*
87 * new Action for new sessions 88 * new Action for new sessions
88 */ 89 */
89 QAction* newCon = new QAction(tr("New Profile"), 90 QAction* newCon = new QAction(tr("New Profile"),
90 Resource::loadPixmap( "new" ), 91 Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ),
91 QString::null, 0, this, 0); 92 QString::null, 0, this, 0);
92 newCon->addTo( m_console ); 93 newCon->addTo( m_console );
93 connect( newCon, SIGNAL(activated() ), 94 connect( newCon, SIGNAL(activated() ),
94 this, SLOT(slotNew() ) ); 95 this, SLOT(slotNew() ) );
95 96
96 m_console->insertSeparator(); 97 m_console->insertSeparator();
97 98
98 QAction *saveCon = new QAction( tr("Save Profile" ), 99 QAction *saveCon = new QAction( tr("Save Profile" ),
99 Resource::loadPixmap( "save" ), QString::null, 100 Opie::Core::OResource::loadPixmap( "save", Opie::Core::OResource::SmallIcon ), QString::null,
100 0, this, 0 ); 101 0, this, 0 );
101 saveCon->addTo( m_console ); 102 saveCon->addTo( m_console );
102 connect( saveCon, SIGNAL(activated() ), 103 connect( saveCon, SIGNAL(activated() ),
103 this, SLOT(slotSaveSession() ) ); 104 this, SLOT(slotSaveSession() ) );
104 m_console->insertSeparator(); 105 m_console->insertSeparator();
105 106
106 /* 107 /*
107 * connect action 108 * connect action
108 */ 109 */
109 m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), 110 m_connect = new QAction( tr("Connect"), Opie::Core::OResource::loadPixmap("console/connected",
110 QString::null, 0, this, 0 ); 111 Opie::Core::OResource::SmallIcon ), QString::null, 0, this, 0 );
111 m_connect->addTo( m_console ); 112 m_connect->addTo( m_console );
112 connect(m_connect, SIGNAL(activated() ), 113 connect(m_connect, SIGNAL(activated() ),
113 this, SLOT(slotConnect() ) ); 114 this, SLOT(slotConnect() ) );
114 115
115 /* 116 /*
116 * disconnect action 117 * disconnect action
117 */ 118 */
118 m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), 119 m_disconnect = new QAction( tr("Disconnect"), Opie::Core::OResource::loadPixmap("console/notconnected",
119 QString::null, 0, this, 0 ); 120 Opie::Core::OResource::SmallIcon ), QString::null, 0, this, 0 );
120 m_disconnect->addTo( m_console ); 121 m_disconnect->addTo( m_console );
121 connect(m_disconnect, SIGNAL(activated() ), 122 connect(m_disconnect, SIGNAL(activated() ),
122 this, SLOT(slotDisconnect() ) ); 123 this, SLOT(slotDisconnect() ) );
123 124
124 m_console->insertSeparator(); 125 m_console->insertSeparator();
125 126
126#ifndef EAST 127#ifndef EAST
127 m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 ); 128 m_quickLaunch = new QAction( tr("QuickLaunch"),
129 Opie::Core::OResource::loadPixmap("console/konsole_mini", Opie::Core::OResource::SmallIcon ),
130 QString::null, 0, this, 0 );
128 m_quickLaunch->addTo( m_icons ); 131 m_quickLaunch->addTo( m_icons );
129 connect( m_quickLaunch, SIGNAL( activated() ), 132 connect( m_quickLaunch, SIGNAL( activated() ),
130 this, SLOT( slotQuickLaunch() ) ); 133 this, SLOT( slotQuickLaunch() ) );
131#endif 134#endif
132 135
133 QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) ); 136 QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) );
134 137
135 m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, 138 m_transfer = new QAction( tr("Transfer file..."), Opie::Core::OResource::loadPixmap("pass", Opie::Core::OResource::SmallIcon ),
136 0, this, 0 ); 139 QString::null, 0, this, 0 );
137 m_transfer->addTo( m_console ); 140 m_transfer->addTo( m_console );
138 connect(m_transfer, SIGNAL(activated() ), 141 connect(m_transfer, SIGNAL(activated() ),
139 this, SLOT(slotTransfer() ) ); 142 this, SLOT(slotTransfer() ) );
140 143
141 144
142 145
143 /* 146 /*
144 * immediate change of line wrap policy 147 * immediate change of line wrap policy
145 */ 148 */
146 m_isWrapped = true; 149 m_isWrapped = true;
147 m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0, true ); 150 m_wrap = new QAction( tr("Line wrap"), Opie::Core::OResource::loadPixmap( "linewrap", Opie::Core::OResource::SmallIcon ),
151 QString::null, 0, this, 0, true );
148 m_wrap->addTo( m_console ); 152 m_wrap->addTo( m_console );
149 m_wrap->setOn( true ); 153 m_wrap->setOn( true );
150 connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); 154 connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) );
151 155
152 /* 156 /*
153 * fullscreen 157 * fullscreen
154 */ 158 */
155 m_isFullscreen = false; 159 m_isFullscreen = false;
156 160
157 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) 161 m_fullscreen = new QAction( tr("Full screen"), Opie::Core::OResource::loadPixmap( "fullscreen",
158 , QString::null, 0, this, 0 ); 162 Opie::Core::OResource::SmallIcon ), QString::null, 0, this, 0 );
159 m_fullscreen->addTo( m_console ); 163 m_fullscreen->addTo( m_console );
160 connect( m_fullscreen, SIGNAL( activated() ), 164 connect( m_fullscreen, SIGNAL( activated() ),
161 this, SLOT( slotFullscreen() ) ); 165 this, SLOT( slotFullscreen() ) );
162 166
163 m_console->insertSeparator(); 167 m_console->insertSeparator();
164 168
165 m_recordLog = new QAction(); 169 m_recordLog = new QAction();
166 m_recordLog->setText( tr("Start log") ); 170 m_recordLog->setText( tr("Start log") );
167 m_recordLog->addTo( m_console ); 171 m_recordLog->addTo( m_console );
168 connect(m_recordLog, SIGNAL(activated() ), 172 connect(m_recordLog, SIGNAL(activated() ),
169 this, SLOT( slotSaveLog() ) ); 173 this, SLOT( slotSaveLog() ) );
170 m_recordingLog = false; 174 m_recordingLog = false;
171 175
172 QAction *a = new QAction(); 176 QAction *a = new QAction();
173 a->setText( tr("Save history") ); 177 a->setText( tr("Save history") );
174 a->addTo( m_console ); 178 a->addTo( m_console );
175 connect(a, SIGNAL(activated() ), 179 connect(a, SIGNAL(activated() ),
176 this, SLOT(slotSaveHistory() ) ); 180 this, SLOT(slotSaveHistory() ) );
177 /* 181 /*
178 * terminate action 182 * terminate action
179 */ 183 */
180 m_terminate = new QAction(); 184 m_terminate = new QAction();
181 m_terminate->setText( tr("Terminate") ); 185 m_terminate->setText( tr("Terminate") );
182 m_terminate->addTo( m_console ); 186 m_terminate->addTo( m_console );
183 connect(m_terminate, SIGNAL(activated() ), 187 connect(m_terminate, SIGNAL(activated() ),
184 this, SLOT(slotTerminate() ) ); 188 this, SLOT(slotTerminate() ) );
185 189
186 m_closewindow = new QAction(); 190 m_closewindow = new QAction();
187 m_closewindow->setText( tr("Close Window") ); 191 m_closewindow->setText( tr("Close Window") );
188 m_closewindow->addTo( m_console ); 192 m_closewindow->addTo( m_console );
189 connect( m_closewindow, SIGNAL(activated() ), 193 connect( m_closewindow, SIGNAL(activated() ),
190 this, SLOT(slotClose() ) ); 194 this, SLOT(slotClose() ) );
191 195
192 196
193 /* 197 /*
194 * script actions 198 * script actions
195 */ 199 */
196 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); 200 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0);
197 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); 201 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int)));
198 202
199 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); 203 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
200 m_recordScript->addTo(m_scripts); 204 m_recordScript->addTo(m_scripts);
201 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); 205 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript()));
202 206
203 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); 207 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0);
204 m_saveScript->addTo(m_scripts); 208 m_saveScript->addTo(m_scripts);
205 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); 209 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript()));
206 210
207 211
208 212
209 213
210 /* 214 /*
211 * action that open/closes the keyboard 215 * action that open/closes the keyboard
212 */ 216 */
213 m_openKeys = new QAction (tr("Open Keyboard..."), 217 m_openKeys = new QAction (tr("Open Keyboard..."),
214 Resource::loadPixmap( "console/keys/keyboard_icon" ), 218 Opie::Core::OResource::loadPixmap( "console/keys/keyboard_icon", Opie::Core::OResource::SmallIcon ),
215 QString::null, 0, this, 0); 219 QString::null, 0, this, 0);
216 m_openKeys->setToggleAction(true); 220 m_openKeys->setToggleAction(true);
217 connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); 221 connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool)));
218 222
219 /* insert the submenu */ 223 /* insert the submenu */
220 m_console->insertItem(tr("New from Profile"), m_sessionsPop, 224 m_console->insertItem(tr("New from Profile"), m_sessionsPop,
221 -1, 0); 225 -1, 0);
222 226
223 /* insert the connection menu */ 227 /* insert the connection menu */
224 m_bar->insertItem( tr("Connection"), m_console ); 228 m_bar->insertItem( tr("Connection"), m_console );
225 229
226 /* the scripts menu */ 230 /* the scripts menu */
227#ifdef EAST 231#ifdef EAST
228 Opie::Core::OConfig cfg("opie-console"); 232 Opie::Core::OConfig cfg("opie-console");
229 cfg.setGroup("10east"); 233 cfg.setGroup("10east");
230 if( !cfg.readEntry("scripthide",0) ) { 234 if( !cfg.readEntry("scripthide",0) ) {
231 m_bar->insertItem( tr("Scripts"), m_scripts ); 235 m_bar->insertItem( tr("Scripts"), m_scripts );
232 } 236 }
233#endif 237#endif
234 238
235 /* and the keyboard */ 239 /* and the keyboard */
236 m_keyBar = new QToolBar(this); 240 m_keyBar = new QToolBar(this);
237 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); 241 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE );
238 m_keyBar->setHorizontalStretchable( TRUE ); 242 m_keyBar->setHorizontalStretchable( TRUE );
239 m_keyBar->hide(); 243 m_keyBar->hide();
240 244
241 m_kb = new FunctionKeyboard(m_keyBar); 245 m_kb = new FunctionKeyboard(m_keyBar);
242 connect(m_kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)), 246 connect(m_kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)),
243 this, SLOT(slotKeyReceived(FKey,ushort,ushort,bool))); 247 this, SLOT(slotKeyReceived(FKey,ushort,ushort,bool)));
244 248
245 249
246 a = new QAction(tr("Copy"), 250 a = new QAction(tr("Copy"),
247 Resource::loadPixmap("copy"), QString::null, 251 Opie::Core::OResource::loadPixmap("copy", Opie::Core::OResource::SmallIcon ), QString::null,
248 0, this, 0 ); 252 0, this, 0 );
249 //a->addTo( m_icons ); 253 //a->addTo( m_icons );
250 connect( a, SIGNAL(activated() ), 254 connect( a, SIGNAL(activated() ),
251 this, SLOT(slotCopy() ) ); 255 this, SLOT(slotCopy() ) );
252 256
253 QAction *paste = new QAction(tr("Paste"), 257 QAction *paste = new QAction(tr("Paste"),
254 Resource::loadPixmap("paste"), QString::null, 258 Opie::Core::OResource::loadPixmap("paste", Opie::Core::OResource::SmallIcon ), QString::null,
255 0, this, 0 ); 259 0, this, 0 );
256 connect( paste, SIGNAL(activated() ), 260 connect( paste, SIGNAL(activated() ),
257 this, SLOT(slotPaste() ) ); 261 this, SLOT(slotPaste() ) );
258 262
259 263
260 newCon->addTo( m_icons ); 264 newCon->addTo( m_icons );
261 //m_setProfiles->addTo( m_icons ); 265 //m_setProfiles->addTo( m_icons );
262 paste->addTo( m_icons ); 266 paste->addTo( m_icons );
263 m_openKeys->addTo(m_icons); 267 m_openKeys->addTo(m_icons);
264 m_fullscreen->addTo( m_icons ); 268 m_fullscreen->addTo( m_icons );
265 269
266 m_connect->setEnabled( false ); 270 m_connect->setEnabled( false );
267 m_disconnect->setEnabled( false ); 271 m_disconnect->setEnabled( false );
268 m_terminate->setEnabled( false ); 272 m_terminate->setEnabled( false );
269 m_transfer->setEnabled( false ); 273 m_transfer->setEnabled( false );
270 m_scripts->setItemEnabled(m_runScript_id, false); 274 m_scripts->setItemEnabled(m_runScript_id, false);
271 m_recordScript->setEnabled( false ); 275 m_recordScript->setEnabled( false );
272 m_saveScript->setEnabled( false ); 276 m_saveScript->setEnabled( false );
273 m_fullscreen->setEnabled( false ); 277 m_fullscreen->setEnabled( false );
274 m_closewindow->setEnabled( false ); 278 m_closewindow->setEnabled( false );
275 m_wrap->setEnabled( false ); 279 m_wrap->setEnabled( false );
276 280
277 /* 281 /*
278 * connect to the menu activation 282 * connect to the menu activation
279 */ 283 */
280 connect( m_sessionsPop, SIGNAL(activated(int) ), 284 connect( m_sessionsPop, SIGNAL(activated(int) ),
281 this, SLOT(slotProfile(int) ) ); 285 this, SLOT(slotProfile(int) ) );
282 286
283 m_consoleWindow = new TabWidget( this, "blah"); 287 m_consoleWindow = new TabWidget( this, "blah");
284 connect(m_consoleWindow, SIGNAL(activated(Session*) ), 288 connect(m_consoleWindow, SIGNAL(activated(Session*) ),
285 this, SLOT(slotSessionChanged(Session*) ) ); 289 this, SLOT(slotSessionChanged(Session*) ) );
286 setCentralWidget( m_consoleWindow ); 290 setCentralWidget( m_consoleWindow );
287 291
288 slotQuickLaunch(); 292 slotQuickLaunch();
289} 293}
290 294
291ProfileManager* MainWindow::manager() { 295ProfileManager* MainWindow::manager() {
292 return m_manager; 296 return m_manager;
293} 297}
294TabWidget* MainWindow::tabWidget() { 298TabWidget* MainWindow::tabWidget() {
295 return m_consoleWindow; 299 return m_consoleWindow;
296} 300}
297void MainWindow::populateProfiles() { 301void MainWindow::populateProfiles() {
298 m_sessionsPop->clear(); 302 m_sessionsPop->clear();
299 Profile::ValueList list = manager()->all(); 303 Profile::ValueList list = manager()->all();
300 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { 304 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) {
301 m_sessionsPop->insertItem( (*it).name() ); 305 m_sessionsPop->insertItem( (*it).name() );
302 } 306 }
303 307
304} 308}
305 309
306void MainWindow::populateScripts() { 310void MainWindow::populateScripts() {
307 m_scriptsPop->clear(); 311 m_scriptsPop->clear();
308 m_scriptsData.clear(); 312 m_scriptsData.clear();
309 DocLnkSet files(QPEApplication::documentDir(), "text/plain"); 313 DocLnkSet files(QPEApplication::documentDir(), "text/plain");
310 QListIterator<DocLnk> dit(files.children()); 314 QListIterator<DocLnk> dit(files.children());
311 for (; dit.current(); ++dit) { 315 for (; dit.current(); ++dit) {
312 if (*dit && (*dit)->name().length()>0) { 316 if (*dit && (*dit)->name().length()>0) {
313 QFileInfo info((*dit)->file()); 317 QFileInfo info((*dit)->file());
314 if (info.extension(false) == "script") { 318 if (info.extension(false) == "script") {
315 m_scriptsData.append(new DocLnk(**dit)); 319 m_scriptsData.append(new DocLnk(**dit));
316 m_scriptsPop->insertItem((*dit)->name()); 320 m_scriptsPop->insertItem((*dit)->name());
317 } 321 }
318 } 322 }
319 } 323 }
320 324
321} 325}
322 326
323MainWindow::~MainWindow() { 327MainWindow::~MainWindow() {
324 delete m_factory; 328 delete m_factory;
325 manager()->save(); 329 manager()->save();
326#ifdef FSCKED_DISTRI 330#ifdef FSCKED_DISTRI
327 FixIt fix; 331 FixIt fix;
328 fix.breakIt(); 332 fix.breakIt();
329#endif 333#endif
330} 334}
331 335
332MetaFactory* MainWindow::factory() { 336MetaFactory* MainWindow::factory() {
333 return m_factory; 337 return m_factory;
334} 338}
335 339
336Session* MainWindow::currentSession() { 340Session* MainWindow::currentSession() {
337 return m_curSession; 341 return m_curSession;
338} 342}
339 343
340QList<Session> MainWindow::sessions() { 344QList<Session> MainWindow::sessions() {
341 return m_sessions; 345 return m_sessions;
342} 346}
343 347
344void MainWindow::slotNew() { 348void MainWindow::slotNew() {
345 ProfileEditorDialog dlg(factory() ); 349 ProfileEditorDialog dlg(factory() );
346 dlg.setCaption( tr("New Connection") ); 350 dlg.setCaption( tr("New Connection") );
347 int ret = QPEApplication::execDialog( &dlg ); 351 int ret = QPEApplication::execDialog( &dlg );
348 352
349 if ( ret == QDialog::Accepted ) { 353 if ( ret == QDialog::Accepted ) {
350 create( dlg.profile() ); 354 create( dlg.profile() );
351 } 355 }
352} 356}
353 357
354void MainWindow::slotRecordScript() { 358void MainWindow::slotRecordScript() {
355 if (currentSession()) { 359 if (currentSession()) {
356 currentSession()->emulationHandler()->startRecording(); 360 currentSession()->emulationHandler()->startRecording();
357 m_saveScript->setEnabled(true); 361 m_saveScript->setEnabled(true);
358 m_recordScript->setEnabled(false); 362 m_recordScript->setEnabled(false);
359 } 363 }
360} 364}
361 365
362void MainWindow::slotSaveScript() { 366void MainWindow::slotSaveScript() {
363 if (currentSession() && currentSession()->emulationHandler()->isRecording()) { 367 if (currentSession() && currentSession()->emulationHandler()->isRecording()) {
364 QMap<QString, QStringList> map; 368 QMap<QString, QStringList> map;
365 QStringList text; 369 QStringList text;
366 text << "text/plain"; 370 text << "text/plain";
367 map.insert(tr("Script"), text ); 371 map.insert(tr("Script"), text );
368 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); 372 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
369 if (!filename.isEmpty()) { 373 if (!filename.isEmpty()) {
370 QFileInfo info(filename); 374 QFileInfo info(filename);
371 if (info.extension(FALSE) != "script") 375 if (info.extension(FALSE) != "script")
372 filename += ".script"; 376 filename += ".script";
373 DocLnk nf; 377 DocLnk nf;
374 nf.setType("text/plain"); 378 nf.setType("text/plain");
375 nf.setFile(filename); 379 nf.setFile(filename);
376 nf.setName(info.fileName()); 380 nf.setName(info.fileName());
377 FileManager fm; 381 FileManager fm;
378 fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); 382 fm.saveFile(nf, currentSession()->emulationHandler()->script()->script());
379 currentSession()->emulationHandler()->clearScript(); 383 currentSession()->emulationHandler()->clearScript();
380 m_saveScript->setEnabled(false); 384 m_saveScript->setEnabled(false);
381 m_recordScript->setEnabled(true); 385 m_recordScript->setEnabled(true);
382 populateScripts(); 386 populateScripts();
383 } 387 }
384 } 388 }
385} 389}
386 390
387void MainWindow::slotRunScript(int id) { 391void MainWindow::slotRunScript(int id) {
388 if (currentSession()) { 392 if (currentSession()) {
389 int index = m_scriptsPop->indexOf(id); 393 int index = m_scriptsPop->indexOf(id);
390 DocLnk *lnk = m_scriptsData.at(index); 394 DocLnk *lnk = m_scriptsData.at(index);
391 QString filePath = lnk->file(); 395 QString filePath = lnk->file();
392 Script script(filePath); 396 Script script(filePath);
393 currentSession()->emulationHandler()->runScript(&script); 397 currentSession()->emulationHandler()->runScript(&script);
394 } 398 }
395} 399}
396 400
397void MainWindow::slotConnect() { 401void MainWindow::slotConnect() {
398 if ( currentSession() ) { 402 if ( currentSession() ) {
399 bool ret = currentSession()->layer()->open(); 403 bool ret = currentSession()->layer()->open();
400 if(!ret) QMessageBox::warning(currentSession()->widgetStack(), 404 if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
401 QObject::tr("Failed"), 405 QObject::tr("Failed"),
402 QObject::tr("Connecting failed for this session.")); 406 QObject::tr("Connecting failed for this session."));
403 else { 407 else {
404 m_connect->setEnabled( false ); 408 m_connect->setEnabled( false );
405 m_disconnect->setEnabled( true ); 409 m_disconnect->setEnabled( true );
406 410
407 // if it does not support file transfer, disable the menu entry 411 // if it does not support file transfer, disable the menu entry
408 if ( ( m_curSession->layer() )->supports()[1] == 0 ) { 412 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
409 m_transfer->setEnabled( false ); 413 m_transfer->setEnabled( false );
410 } else { 414 } else {
411 m_transfer->setEnabled( true ); 415 m_transfer->setEnabled( true );
412 } 416 }
413 417
414 m_recordScript->setEnabled( true ); 418 m_recordScript->setEnabled( true );
415 m_scripts->setItemEnabled(m_runScript_id, true); 419 m_scripts->setItemEnabled(m_runScript_id, true);
416 } 420 }
417 } 421 }
418} 422}
419 423
420void MainWindow::slotDisconnect() { 424void MainWindow::slotDisconnect() {
421 if ( currentSession() ) { 425 if ( currentSession() ) {
422 currentSession()->layer()->close(); 426 currentSession()->layer()->close();
423 m_connect->setEnabled( true ); 427 m_connect->setEnabled( true );
424 m_disconnect->setEnabled( false ); 428 m_disconnect->setEnabled( false );
425 m_transfer->setEnabled( false ); 429 m_transfer->setEnabled( false );
426 m_recordScript->setEnabled( false); 430 m_recordScript->setEnabled( false);
427 m_saveScript->setEnabled( false ); 431 m_saveScript->setEnabled( false );
428 m_scripts->setItemEnabled(m_runScript_id, false); 432 m_scripts->setItemEnabled(m_runScript_id, false);
429 } 433 }
430} 434}
431 435
432void MainWindow::slotTerminate() { 436void MainWindow::slotTerminate() {
433 if ( currentSession() ) 437 if ( currentSession() )
434 currentSession()->layer()->close(); 438 currentSession()->layer()->close();
435 439
436 slotClose(); 440 slotClose();
437 /* FIXME move to the next session */ 441 /* FIXME move to the next session */
438} 442}
439 443
440 444
441 445
442void MainWindow::slotQuickLaunch() { 446void MainWindow::slotQuickLaunch() {
443 447
444 Profile prof = manager()->profile( "default" ); 448 Profile prof = manager()->profile( "default" );
445 if ( prof.name() == "default" ) { 449 if ( prof.name() == "default" ) {
446 create( prof ); 450 create( prof );
447 } else { 451 } else {
448 #ifndef EAST 452 #ifndef EAST
449 Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 ); 453 Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 );
450 newProf.setAutoConnect( true ); 454 newProf.setAutoConnect( true );
451 create( newProf ); 455 create( newProf );
452 slotSaveSession(); 456 slotSaveSession();
453 #endif 457 #endif
454 } 458 }
455} 459}
456 460
457void MainWindow::slotConfigure() { 461void MainWindow::slotConfigure() {
458 ConfigDialog conf( manager()->all(), factory() ); 462 ConfigDialog conf( manager()->all(), factory() );
459 463
460 int ret = QPEApplication::execDialog( &conf ); 464 int ret = QPEApplication::execDialog( &conf );
461 465
462 if ( QDialog::Accepted == ret ) { 466 if ( QDialog::Accepted == ret ) {
463 manager()->setProfiles( conf.list() ); 467 manager()->setProfiles( conf.list() );
464 manager()->save(); 468 manager()->save();
465 populateProfiles(); 469 populateProfiles();
466 } 470 }
467} 471}
468/* 472/*
469 * we will remove 473 * we will remove
470 * this window from the tabwidget 474 * this window from the tabwidget
471 * remove it from the list 475 * remove it from the list
472 * delete it 476 * delete it
473 * and set the currentSession() 477 * and set the currentSession()
474 */ 478 */
475void MainWindow::slotClose() { 479void MainWindow::slotClose() {
476 if (!currentSession() ) 480 if (!currentSession() )
477 return; 481 return;
478 482
479 Session* ses = currentSession(); 483 Session* ses = currentSession();
480 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ 484 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */
481 m_curSession = NULL; 485 m_curSession = NULL;
482 tabWidget()->remove( /*currentSession()*/ses ); 486 tabWidget()->remove( /*currentSession()*/ses );
483 /*it's autodelete */ 487 /*it's autodelete */
484 m_sessions.remove( ses ); 488 m_sessions.remove( ses );
485 489
486 if (!currentSession() ) { 490 if (!currentSession() ) {
487 m_connect->setEnabled( false ); 491 m_connect->setEnabled( false );
488 m_disconnect->setEnabled( false ); 492 m_disconnect->setEnabled( false );
489 m_terminate->setEnabled( false ); 493 m_terminate->setEnabled( false );
490 m_transfer->setEnabled( false ); 494 m_transfer->setEnabled( false );
491 m_recordScript->setEnabled( false ); 495 m_recordScript->setEnabled( false );
492 m_saveScript->setEnabled( false ); 496 m_saveScript->setEnabled( false );
493 m_scripts->setItemEnabled(m_runScript_id, false); 497 m_scripts->setItemEnabled(m_runScript_id, false);
494 m_fullscreen->setEnabled( false ); 498 m_fullscreen->setEnabled( false );
495 m_wrap->setEnabled( false ); 499 m_wrap->setEnabled( false );
496 m_closewindow->setEnabled( false ); 500 m_closewindow->setEnabled( false );
497 } 501 }
498 502
499 m_kb->loadDefaults(); 503 m_kb->loadDefaults();
500} 504}
501 505
502/* 506/*
503 * We will get the name 507 * We will get the name
504 * Then the profile 508 * Then the profile
505 * and then we will make a profile 509 * and then we will make a profile
506 */ 510 */
507void MainWindow::slotProfile( int id) { 511void MainWindow::slotProfile( int id) {
508 Profile prof = manager()->profile( m_sessionsPop->text( id) ); 512 Profile prof = manager()->profile( m_sessionsPop->text( id) );
509 create( prof ); 513 create( prof );
510} 514}
511 515
512 516
513 517
514void MainWindow::create( const Profile& prof ) { 518void MainWindow::create( const Profile& prof ) {
515 char *homeDir = getenv("HOME"); 519 char *homeDir = getenv("HOME");
516 520
517 if ( homeDir ) 521 if ( homeDir )
518 ::chdir( homeDir ); 522 ::chdir( homeDir );
519 523
520 if(m_curSession) 524 if(m_curSession)
521 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); 525 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
522 526
523 Session *ses = manager()->fromProfile( prof, tabWidget() ); 527 Session *ses = manager()->fromProfile( prof, tabWidget() );
524 528
525 if((!ses) || (!ses->layer()) || (!ses->widgetStack())) 529 if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
526 { 530 {
527 QMessageBox::warning(this, 531 QMessageBox::warning(this,
528 QObject::tr("Session failed"), 532 QObject::tr("Session failed"),
529 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); 533 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>"));
530 //if(ses) delete ses; 534 //if(ses) delete ses;
531 return; 535 return;
532 } 536 }
533 537
534 m_sessions.append( ses ); 538 m_sessions.append( ses );
535 tabWidget()->add( ses ); 539 tabWidget()->add( ses );
536 tabWidget()->repaint(); 540 tabWidget()->repaint();
537 m_curSession = ses; 541 m_curSession = ses;
538 542
539 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it 543 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it
540 m_connect->setEnabled( true ); 544 m_connect->setEnabled( true );
541 m_disconnect->setEnabled( false ); 545 m_disconnect->setEnabled( false );
542 m_terminate->setEnabled( true ); 546 m_terminate->setEnabled( true );
543 m_fullscreen->setEnabled( true ); 547 m_fullscreen->setEnabled( true );
544 m_wrap->setEnabled( true ); 548 m_wrap->setEnabled( true );
545 m_closewindow->setEnabled( true ); 549 m_closewindow->setEnabled( true );
546 m_transfer->setEnabled( false ); 550 m_transfer->setEnabled( false );
547 m_recordScript->setEnabled( false ); 551 m_recordScript->setEnabled( false );
548 m_saveScript->setEnabled( false ); 552 m_saveScript->setEnabled( false );
549 m_scripts->setItemEnabled(m_runScript_id, false); 553 m_scripts->setItemEnabled(m_runScript_id, false);
550 554
551 // is io_layer wants direct connection, then autoconnect 555 // is io_layer wants direct connection, then autoconnect
552 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { 556 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) {
553 if (prof.autoConnect()) { 557 if (prof.autoConnect()) {
554 slotConnect(); 558 slotConnect();
555 } 559 }
556 560
557 QWidget *w = currentSession()->widget(); 561 QWidget *w = currentSession()->widget();
558 if(w) w->setFocus(); 562 if(w) w->setFocus();
559 563
560 if(currentSession()->profile().readNumEntry("Wrap", 80)){ 564 if(currentSession()->profile().readNumEntry("Wrap", 80)){
561 m_isWrapped = true; 565 m_isWrapped = true;
562 } else { 566 } else {
563 m_isWrapped = false; 567 m_isWrapped = false;
564 } 568 }
565 569
566 m_kb->load(currentSession()->profile()); 570 m_kb->load(currentSession()->profile());
567} 571}
568 572
569void MainWindow::slotTransfer() 573void MainWindow::slotTransfer()
570{ 574{
571 if ( currentSession() ) { 575 if ( currentSession() ) {
572 Session *mysession = currentSession(); 576 Session *mysession = currentSession();
573 TransferDialog dlg(/*mysession->widgetStack()*/this, this); 577 TransferDialog dlg(/*mysession->widgetStack()*/this, this);
574 mysession->setTransferDialog(&dlg); 578 mysession->setTransferDialog(&dlg);
575 //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); 579 //dlg.reparent(mysession->widgetStack(), QPoint(0, 0));
576 //dlg.showMaximized(); 580 //dlg.showMaximized();
577 currentSession()->widgetStack()->addWidget(&dlg, -1); 581 currentSession()->widgetStack()->addWidget(&dlg, -1);
578 dlg.show(); 582 dlg.show();
579 //dlg.exec(); 583 //dlg.exec();
580 while(dlg.isRunning()) qApp->processEvents(); 584 while(dlg.isRunning()) qApp->processEvents();
581 mysession->setTransferDialog(0l); 585 mysession->setTransferDialog(0l);
582 } 586 }
583} 587}
584 588
585 589
586void MainWindow::slotOpenKeb(bool state) { 590void MainWindow::slotOpenKeb(bool state) {
587 591
588 if (state) m_keyBar->show(); 592 if (state) m_keyBar->show();
589 else m_keyBar->hide(); 593 else m_keyBar->hide();
590 594
591} 595}
592 596
593 597
594void MainWindow::slotOpenButtons( bool state ) { 598void MainWindow::slotOpenButtons( bool state ) {
595 599
596 if ( state ) { 600 if ( state ) {
597 m_buttonBar->show(); 601 m_buttonBar->show();
598 } else { 602 } else {
599 m_buttonBar->hide(); 603 m_buttonBar->hide();
600 } 604 }
601} 605}
602 606
603 607
604 608
605void MainWindow::slotSessionChanged( Session* ses ) { 609void MainWindow::slotSessionChanged( Session* ses ) {
606 if(m_curSession) 610 if(m_curSession)
607 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); 611 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
608 if(ses) 612 if(ses)
609 if(ses->transferDialog()) ses->transferDialog()->show(); 613 if(ses->transferDialog()) ses->transferDialog()->show();
610 614
611 if ( ses ) { 615 if ( ses ) {
612 m_curSession = ses; 616 m_curSession = ses;
613 if ( m_curSession->layer()->isConnected() ) { 617 if ( m_curSession->layer()->isConnected() ) {
614 m_connect->setEnabled( false ); 618 m_connect->setEnabled( false );
615 m_disconnect->setEnabled( true ); 619 m_disconnect->setEnabled( true );
616 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); 620 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording());
617 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); 621 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording());
618 m_scripts->setItemEnabled(m_runScript_id, true); 622 m_scripts->setItemEnabled(m_runScript_id, true);
619 } else { 623 } else {
620 m_connect->setEnabled( true ); 624 m_connect->setEnabled( true );
621 m_disconnect->setEnabled( false ); 625 m_disconnect->setEnabled( false );
622 m_recordScript->setEnabled( false ); 626 m_recordScript->setEnabled( false );
623 m_saveScript->setEnabled( false ); 627 m_saveScript->setEnabled( false );
624 m_scripts->setItemEnabled(m_runScript_id, false); 628 m_scripts->setItemEnabled(m_runScript_id, false);
625 } 629 }
626 630
627 if ( ( currentSession()->emulationHandler()->isLogging() ) ) { 631 if ( ( currentSession()->emulationHandler()->isLogging() ) ) {
628 m_recordLog->setText( tr("Stop log") ); 632 m_recordLog->setText( tr("Stop log") );
629 } else { 633 } else {
630 m_recordLog->setText( tr("Start log") ); 634 m_recordLog->setText( tr("Start log") );
631 } 635 }
632 636
633 if ( ( m_curSession->layer() )->supports()[1] == 0 ) { 637 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
634 m_transfer->setEnabled( false ); 638 m_transfer->setEnabled( false );
635 } else { 639 } else {
636 m_transfer->setEnabled( true ); 640 m_transfer->setEnabled( true );
637 } 641 }
638 642
639 QWidget *w = m_curSession->widget(); 643 QWidget *w = m_curSession->widget();
640 if(w) w->setFocus(); 644 if(w) w->setFocus();
641 645
642 if(currentSession()->profile().readNumEntry("Wrap", 80)){ 646 if(currentSession()->profile().readNumEntry("Wrap", 80)){
643 m_isWrapped = true; 647 m_isWrapped = true;
644 } else { 648 } else {
645 m_isWrapped = false; 649 m_isWrapped = false;
646 } 650 }
647 651
648 m_kb->load(currentSession()->profile()); 652 m_kb->load(currentSession()->profile());
649 } 653 }
650} 654}
651 655
652void MainWindow::slotWrap() 656void MainWindow::slotWrap()
653{ 657{
654 if(m_curSession) 658 if(m_curSession)
655 { 659 {
656 EmulationHandler *e = m_curSession->emulationHandler(); 660 EmulationHandler *e = m_curSession->emulationHandler();
657 if(e) 661 if(e)
658 { 662 {
659 e->setWrap( m_isWrapped ? 80:0 ); 663 e->setWrap( m_isWrapped ? 80:0 );
660 m_isWrapped = !m_isWrapped; 664 m_isWrapped = !m_isWrapped;
661 } 665 }
662 } 666 }
663} 667}
664 668
665void MainWindow::slotFullscreen() { 669void MainWindow::slotFullscreen() {
666 670
667 671
668 672
669 if ( m_isFullscreen ) { 673 if ( m_isFullscreen ) {
670 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); 674 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true );
671 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); 675 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() );
672 ( m_curSession->emulationHandler() )->cornerButton()->hide(); 676 ( m_curSession->emulationHandler() )->cornerButton()->hide();
673 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 677 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
674 678
675 } else { 679 } else {
676 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); 680 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget();
677 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); 681 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame );
678 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop 682 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop
679 , QPoint(0,0), false ); 683 , QPoint(0,0), false );
680 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); 684 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() );
681 ( m_curSession->widgetStack() )->setFocus(); 685 ( m_curSession->widgetStack() )->setFocus();
682 ( m_curSession->widgetStack() )->show(); 686 ( m_curSession->widgetStack() )->show();
683 687
684 ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); 688 ( ( m_curSession->emulationHandler() )->cornerButton() )->show();
685 689
686 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 690 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
687 } 691 }
688 692
689 m_isFullscreen = !m_isFullscreen; 693 m_isFullscreen = !m_isFullscreen;
690} 694}
691 695
692 696
693void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { 697void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) {
694 698
695 if ( m_curSession ) { 699 if ( m_curSession ) {
696 700
697 QEvent::Type state; 701 QEvent::Type state;
698 702
699 if (pressed) state = QEvent::KeyPress; 703 if (pressed) state = QEvent::KeyPress;
700 else state = QEvent::KeyRelease; 704 else state = QEvent::KeyRelease;
701 705
702 QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); 706 QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode)));
703 707
704 // is this the best way to do this? cant figure out any other way to work 708 // is this the best way to do this? cant figure out any other way to work
705 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); 709 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke);
706 ke.ignore(); 710 ke.ignore();
707 } 711 }
708} 712}
709void MainWindow::slotCopy() { 713void MainWindow::slotCopy() {
710 if (!currentSession() ) return; 714 if (!currentSession() ) return;
711 currentSession()->emulationHandler()->copy(); 715 currentSession()->emulationHandler()->copy();
712} 716}
713void MainWindow::slotPaste() { 717void MainWindow::slotPaste() {
714 if (!currentSession() ) return; 718 if (!currentSession() ) return;
715 currentSession()->emulationHandler()->paste(); 719 currentSession()->emulationHandler()->paste();
716} 720}
717 721
718/* 722/*
719 * Save the session 723 * Save the session
720 */ 724 */
721 725
722void MainWindow::slotSaveSession() { 726void MainWindow::slotSaveSession() {
723 if (!currentSession() ) { 727 if (!currentSession() ) {
724 QMessageBox::information(this, tr("Save Connection"), 728 QMessageBox::information(this, tr("Save Connection"),
725 tr("<qt>There is no Connection.</qt>"), 1 ); 729 tr("<qt>There is no Connection.</qt>"), 1 );
726 return; 730 return;
727 } 731 }
728 manager()->add( currentSession()->profile() ); 732 manager()->add( currentSession()->profile() );
729 manager()->save(); 733 manager()->save();
730 populateProfiles(); 734 populateProfiles();
731} 735}
732 736
733 737
734 738
735void MainWindow::slotSaveLog() { 739void MainWindow::slotSaveLog() {
736 740
737 if( currentSession()->emulationHandler()->isLogging() ) { 741 if( currentSession()->emulationHandler()->isLogging() ) {
738 DocLnk nf; 742 DocLnk nf;
739 QString m_logName = currentSession()->emulationHandler()->logFileName(); 743 QString m_logName = currentSession()->emulationHandler()->logFileName();
740 QFileInfo info(m_logName); 744 QFileInfo info(m_logName);
741 nf.setType("text/plain"); 745 nf.setType("text/plain");
742 nf.setFile(m_logName); 746 nf.setFile(m_logName);
743 nf.setName(info.fileName()); 747 nf.setName(info.fileName());
744 nf.writeLink(); 748 nf.writeLink();
745 m_recordLog->setText( tr("Start log") ); 749 m_recordLog->setText( tr("Start log") );
746 m_recordingLog = false; 750 m_recordingLog = false;
747 currentSession()->emulationHandler()->clearLog(); 751 currentSession()->emulationHandler()->clearLog();
748 } else { 752 } else {
749 QMap<QString, QStringList> map; 753 QMap<QString, QStringList> map;
750 QStringList text; 754 QStringList text;
751 text << "text/plain"; 755 text << "text/plain";
752 map.insert(tr("Log"), text ); 756 map.insert(tr("Log"), text );
753 Opie::Core::OConfig cfg("opie-console"); 757 Opie::Core::OConfig cfg("opie-console");
754 cfg.setGroup("defaults"); 758 cfg.setGroup("defaults");
755 QString startDir = cfg.readEntry("defaultlogdir", QPEApplication::documentDir() ); 759 QString startDir = cfg.readEntry("defaultlogdir", QPEApplication::documentDir() );
756 QString m_logName = OFileDialog::getSaveFileName(2, startDir, QString::null, map, 0, startDir); 760 QString m_logName = OFileDialog::getSaveFileName(2, startDir, QString::null, map, 0, startDir);
757 if (m_logName.isEmpty() ) return; 761 if (m_logName.isEmpty() ) return;
758 762
759 m_recordLog->setText( tr("Stop log") ); 763 m_recordLog->setText( tr("Stop log") );
760 m_recordingLog = true; 764 m_recordingLog = true;
761 currentSession()->emulationHandler()->startLogging(m_logName); 765 currentSession()->emulationHandler()->startLogging(m_logName);
762 } 766 }
763} 767}
764 768
765void MainWindow::slotSaveHistory() { 769void MainWindow::slotSaveHistory() {
766 QMap<QString, QStringList> map; 770 QMap<QString, QStringList> map;
767 QStringList text; 771 QStringList text;
768 text << "text/plain"; 772 text << "text/plain";
769 map.insert(tr("History"), text ); 773 map.insert(tr("History"), text );
770 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); 774 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
771 if (filename.isEmpty() ) return; 775 if (filename.isEmpty() ) return;
772 776
773 QFileInfo info(filename); 777 QFileInfo info(filename);
774 778
775 DocLnk nf; 779 DocLnk nf;
776 nf.setType("text/plain"); 780 nf.setType("text/plain");
777 nf.setFile(filename); 781 nf.setFile(filename);
778 nf.setName(info.fileName()); 782 nf.setName(info.fileName());
779 783
780 784
781 QFile file(filename); 785 QFile file(filename);
782 file.open(IO_WriteOnly ); 786 file.open(IO_WriteOnly );
783 QTextStream str(&file ); 787 QTextStream str(&file );
784 if ( currentSession() ) 788 if ( currentSession() )
785 currentSession()->emulationHandler()->emulation()->streamHistory(&str); 789 currentSession()->emulationHandler()->emulation()->streamHistory(&str);
786 790
787 file.close(); 791 file.close();
788 nf.writeLink(); 792 nf.writeLink();
789} 793}