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