summaryrefslogtreecommitdiff
authorhash <hash>2002-10-22 16:01:27 (UTC)
committer hash <hash>2002-10-22 16:01:27 (UTC)
commit6843a1bd8f8e679c220431f8377abcd2ffd2019b (patch) (unidiff)
treecec84037b60d0ae1e69c69a21e6da2dea3aaf5b6
parentdca783a6564d7d0d8c857cef8586167bc0609647 (diff)
downloadopie-6843a1bd8f8e679c220431f8377abcd2ffd2019b.zip
opie-6843a1bd8f8e679c220431f8377abcd2ffd2019b.tar.gz
opie-6843a1bd8f8e679c220431f8377abcd2ffd2019b.tar.bz2
cant figure out why modifying a private var in FunctionKeyboardConfig causes it to segfault.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/function_keyboard.cpp92
-rw-r--r--noncore/apps/opie-console/function_keyboard.h19
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp6
-rw-r--r--noncore/apps/opie-console/mainwindow.h2
4 files changed, 108 insertions, 11 deletions
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp
index 100fdfc..977a384 100644
--- a/noncore/apps/opie-console/function_keyboard.cpp
+++ b/noncore/apps/opie-console/function_keyboard.cpp
@@ -1,182 +1,262 @@
1#include "function_keyboard.h" 1#include "function_keyboard.h"
2
3#include <qpe/resource.h>
4#include <qpe/qpeapplication.h>
2#include <qsizepolicy.h> 5#include <qsizepolicy.h>
3#include <qevent.h> 6#include <qevent.h>
4#include <qwindowsystem_qws.h> 7#include <qwindowsystem_qws.h>
5#include <qapplication.h> 8#include <qapplication.h>
6#include <qlayout.h> 9#include <qlayout.h>
10#include <qspinbox.h>
11#include <qlabel.h>
12#include <qcombobox.h>
13#include <qdir.h>
14
15/* FunctionKeyboard {{{1 */
7 16
8FunctionKeyboard::FunctionKeyboard(QWidget *parent) : 17FunctionKeyboard::FunctionKeyboard(QWidget *parent) :
9 QFrame(parent), numRows(2), numCols(11), 18 QFrame(parent), numRows(2), numCols(11),
10 pressedRow(0), pressedCol(0) { 19 pressedRow(0), pressedCol(0) {
11 20
12 setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); 21 setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed));
13 22
14 Config conf("opie-console-keys"); 23 Config conf("opie-console-keys");
15 conf.setGroup("keys"); 24 conf.setGroup("keys");
16 for (uint r = 0; r < numRows; r++) 25 for (uint r = 0; r < numRows; r++)
17 for (uint c = 0; c < numCols; c++) { 26 for (uint c = 0; c < numCols; c++) {
18 27
19 QString handle = "r" + QString::number(r) + "c" + QString::number(c); 28 QString handle = "r" + QString::number(r) + "c" + QString::number(c);
20 QStringList value_list = conf.readListEntry( handle, '|'); 29 QStringList value_list = conf.readListEntry( handle, '|');
21 30
22 if (value_list.isEmpty()) continue; 31 if (value_list.isEmpty()) continue;
23 32
24 keys.insert( 33 keys.insert(
25 34
26 handle, 35 handle,
27 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())
28 ); 37 );
29 } 38 }
30 //qWarning("loaded %d keys", keys.count()); 39 //qWarning("loaded %d keys", keys.count());
31 if (keys.isEmpty()) loadDefaults(); 40 if (keys.isEmpty()) loadDefaults();
32 41
33 42
34 43
35} 44}
36 45
37FunctionKeyboard::~FunctionKeyboard() { 46FunctionKeyboard::~FunctionKeyboard() {
38 47
39} 48}
40 49
50void FunctionKeyboard::changeRows(int r) {
51
52 numRows = r;
53 repaint(false);
54}
55void FunctionKeyboard::changeCols(int c) {
56
57 numCols = c;
58 keyWidth = (double)width()/numCols; // have to reset this thing too
59 repaint(false);
60}
61
41void FunctionKeyboard::paintEvent(QPaintEvent *e) { 62void FunctionKeyboard::paintEvent(QPaintEvent *e) {
42 63
43 QPainter p(this); 64 QPainter p(this);
44 p.setClipRect(e->rect()); 65 p.setClipRect(e->rect());
45 p.fillRect(0, 0, width(), height(), QColor(255,255,255)); 66 p.fillRect(0, 0, width(), height(), QColor(255,255,255));
46 67
47 p.setPen(QColor(0,0,0)); 68 p.setPen(QColor(0,0,0));
48 69
49 /* those decimals do count! becomes short if use plain int */ 70 /* those decimals do count! becomes short if use plain int */
50 for (double i = 0; i <= width(); i += keyWidth) { 71 for (double i = 0; i <= width(); i += keyWidth) {
51 72
52 p.drawLine((int)i, 0, (int)i, height()); 73 p.drawLine((int)i, 0, (int)i, height());
53 } 74 }
54 75
55 // sometimes the last line doesnt get drawn 76 // sometimes the last line doesnt get drawn
56 p.drawLine(width() -1, 0, width() -1, height()); 77 p.drawLine(width() -1, 0, width() -1, height());
57 78
58 for (int i = 0; i <= height(); i += keyHeight) { 79 for (int i = 0; i <= height(); i += keyHeight) {
59 80
60 p.drawLine(0, i, width(), i); 81 p.drawLine(0, i, width(), i);
61 } 82 }
62 83
63 for (uint r = 0; r < numRows; r++) { 84 for (uint r = 0; r < numRows; r++) {
64 for (uint c = 0; c < numCols; c++) { 85 for (uint c = 0; c < numCols; c++) {
65 86
66 QString handle = "r" + QString::number(r) + "c" + QString::number(c); 87 QString handle = "r" + QString::number(r) + "c" + QString::number(c);
67 if (keys.contains(handle)) { 88 if (keys.contains(handle)) {
68 89
69 p.drawText( 90 p.drawText(
70 c * keyWidth + 1, r * keyHeight + 1, 91 c * keyWidth + 1, r * keyHeight + 1,
71 keyWidth, keyHeight, 92 keyWidth, keyHeight,
72 Qt::AlignHCenter | Qt::AlignVCenter, 93 Qt::AlignHCenter | Qt::AlignVCenter,
73 keys[handle].getL() 94 keys[handle].getL()
74 ); 95 );
75 } 96 }
76 } 97 }
77 } 98 }
78} 99}
79 100
80void FunctionKeyboard::paintKey(int row, int col) { 101void FunctionKeyboard::paintKey(int row, int col) {
81 102
82 QPainter p(this); 103 QPainter p(this);
83 104
84 p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1), 105 p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1),
85 QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)), 106 QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)),
86 (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));
87 p.drawText( 108 p.drawText(
88 col * keyWidth + 1, row * keyHeight + 1, 109 col * keyWidth + 1, row * keyHeight + 1,
89 keyWidth, keyHeight, 110 keyWidth, keyHeight,
90 Qt::AlignHCenter | Qt::AlignVCenter, 111 Qt::AlignHCenter | Qt::AlignVCenter,
91 keys["r" + QString::number(row) + "c" + QString::number(col)].getL() 112 keys["r" + QString::number(row) + "c" + QString::number(col)].getL()
92 ); 113 );
93 114
115 if (row == numRows) {
116
117 // sometimes it doesnt draw the last line
118 p.drawLine((col+1) * keyWidth -2, row * keyHeight,
119 (col+1) * keyWidth -2, (row + 1) * keyHeight
120 );
121 }
122
94} 123}
95 124
96void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { 125void FunctionKeyboard::mousePressEvent(QMouseEvent *e) {
97 126
98 pressedRow = e->y() / keyHeight; 127 pressedRow = e->y() / keyHeight;
99 pressedCol = (int) (e->x() / keyWidth); 128 pressedCol = (int) (e->x() / keyWidth);
100 129
101 paintKey(pressedRow, pressedCol); 130 paintKey(pressedRow, pressedCol);
102 131
103 // emit that sucker! 132 // emit that sucker!
104 FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; 133 FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)];
105 emit keyPressed(k.getU(), k.getQ(), 0, 1, 0); 134 emit keyPressed(k.getU(), k.getQ(), 0, 1, 0, pressedRow, pressedCol);
106 135
107} 136}
108 137
109void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { 138void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) {
110 139
111 if (pressedRow != -1 && pressedRow != -1) { 140 if (pressedRow != -1 && pressedRow != -1) {
112 141
113 int row = pressedRow; pressedRow = -1; 142 int row = pressedRow; pressedRow = -1;
114 int col = pressedCol; pressedCol = -1; 143 int col = pressedCol; pressedCol = -1;
115 paintKey(row, col); 144 paintKey(row, col);
116 145
117 FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; 146 FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)];
118 emit keyPressed(k.getU(), k.getQ(), 0, 0, 0); 147 emit keyPressed(k.getU(), k.getQ(), 0, 0, 0, pressedRow, pressedCol);
119 } 148 }
120 149
121} 150}
122 151
123 152
124void FunctionKeyboard::resizeEvent(QResizeEvent*) { 153void FunctionKeyboard::resizeEvent(QResizeEvent*) {
125 154
126 /* set he default font height/width */ 155 /* set he default font height/width */
127 QFontMetrics fm=fontMetrics(); 156 QFontMetrics fm=fontMetrics();
128 keyHeight = fm.lineSpacing() + 2; 157 keyHeight = fm.lineSpacing() + 2;
129 keyWidth = (double)width()/numCols; 158 keyWidth = (double)width()/numCols;
130 159
131} 160}
132 161
133QSize FunctionKeyboard::sizeHint() const { 162QSize FunctionKeyboard::sizeHint() const {
134 163
135 return QSize(width(), keyHeight * numRows + 1); 164 return QSize(width(), keyHeight * numRows + 1);
136} 165}
137 166
138void FunctionKeyboard::loadDefaults() { 167void FunctionKeyboard::loadDefaults() {
139 168
140 /* what keys should be default? */ 169 /* what keys should be default? */
141 keys.insert( "r0c0", FKey ("F1", 4144, 0)); 170 keys.insert( "r0c0", FKey ("F1", 4144, 0));
142 keys.insert( "r0c1", FKey ("F2", 4145, 0)); 171 keys.insert( "r0c1", FKey ("F2", 4145, 0));
143 keys.insert( "r0c2", FKey ("F3", 4145, 0)); 172 keys.insert( "r0c2", FKey ("F3", 4145, 0));
144 keys.insert( "r0c3", FKey ("F4", 4146, 0)); 173 keys.insert( "r0c3", FKey ("F4", 4146, 0));
145 keys.insert( "r0c4", FKey ("F5", 4147, 0)); 174 keys.insert( "r0c4", FKey ("F5", 4147, 0));
146 keys.insert( "r0c5", FKey ("F6", 4148, 0)); 175 keys.insert( "r0c5", FKey ("F6", 4148, 0));
147 keys.insert( "r0c6", FKey ("F7", 4149, 0)); 176 keys.insert( "r0c6", FKey ("F7", 4149, 0));
148 keys.insert( "r0c7", FKey ("F8", 4150, 0)); 177 keys.insert( "r0c7", FKey ("F8", 4150, 0));
149 keys.insert( "r0c8", FKey ("F9", 4151, 0)); 178 keys.insert( "r0c8", FKey ("F9", 4151, 0));
150 keys.insert( "r0c9", FKey ("F10", 4152, 0)); 179 keys.insert( "r0c9", FKey ("F10", 4152, 0));
151 keys.insert( "r0c10", FKey ("F11", 4153, 0)); 180 keys.insert( "r0c10", FKey ("F11", 4153, 0));
152 181
153 keys.insert( "r1c7", FKey ("Ho", 4112, 0)); 182 keys.insert( "r1c7", FKey ("Ho", 4112, 0));
154 keys.insert( "r1c8", FKey ("End", 4113, 0)); 183 keys.insert( "r1c8", FKey ("End", 4113, 0));
155 keys.insert( "r1c9", FKey ("PU", 4118, 0)); 184 keys.insert( "r1c9", FKey ("PU", 4118, 0));
156 keys.insert( "r1c10", FKey ("PD", 4119, 0)); 185 keys.insert( "r1c10", FKey ("PD", 4119, 0));
157 186
158} 187}
159 188
189/* FunctionKeyboardConfig {{{1 */
160 190
161FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent) : 191FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent) :
162 ProfileDialogKeyWidget(name, parent) { 192 ProfileDialogKeyWidget(name, parent) {
163 193
164 194
165 FunctionKeyboard *kb = new FunctionKeyboard(this); 195 kb = new FunctionKeyboard(this);
196
166 QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimentions"), this); 197 QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimentions"), this);
167 QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit"), this); 198 QLabel *l = new QLabel("Rows", dimentions);
199 QSpinBox *m_rowBox = new QSpinBox(1, 15, 1, dimentions);
200 connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int)));
201 l = new QLabel("Columns", dimentions);
202 m_colBox = new QSpinBox(1, 15, 1, dimentions);
203 connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int)));
204
205 QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this);
206 l = new QLabel("Label", editKey);
207 /*
208 m_labels = new QComboBox(false, editKey);
209 labels->insertItem("text");
210
211 QStringList files = QDir(QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList();
212
213 for (uint i = 0; i < files.count(); i++) {
214
215 m_labels->insertItem(Resource::loadPixmap("console/keys/" + files[i]));
216 }
217 connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int)));
218 */
168 219
169 QVBoxLayout *root = new QVBoxLayout(this, 2); 220 QVBoxLayout *root = new QVBoxLayout(this, 2);
170 root->addWidget(kb); 221 root->addWidget(kb);
171 root->addWidget(dimentions); 222 root->addWidget(dimentions);
172 root->addWidget(editKey); 223 root->addWidget(editKey);
173} 224}
174FunctionKeyboardConfig::~FunctionKeyboardConfig() { 225FunctionKeyboardConfig::~FunctionKeyboardConfig() {
175 226
176} 227}
177void FunctionKeyboardConfig::load (const Profile& ) { 228void FunctionKeyboardConfig::load (const Profile& prof) {
229 int i = prof.readNumEntry("keb_rows", 1);
230 //m_rowBox->setValue(i);
231}
232void FunctionKeyboardConfig::save (Profile& prof) {
233
234 //prof.writeEntry("keb_rows", m_rowBox->value());
235
236}
237void FunctionKeyboardConfig::slotChangeRows(int r) {
238
239 kb->changeRows(r);
240
241 // have to do this so the whole thing gets redrawn
242 kb->hide(); kb->show();
243}
244void FunctionKeyboardConfig::slotChangeCols(int c) {
245
246 kb->changeCols(c);
247}
248void FunctionKeyboardConfig::slotKeyPressed(ushort, ushort, bool, bool, bool, ushort row, ushort col) {
178 249
179} 250}
180void FunctionKeyboardConfig::save (Profile& ) { 251void FunctionKeyboardConfig::slotChangeIcon(int index) {
181 252
253 if (index == 0) {
254
255 // is text
256 //if(!labels->editable()) labels->setEditable(true);
257 } else {
258
259 // is a pixmap
260 //if (labels->editable()) labels->setEditable(false);
261 }
182} 262}
diff --git a/noncore/apps/opie-console/function_keyboard.h b/noncore/apps/opie-console/function_keyboard.h
index 2be74b4..efeff6d 100644
--- a/noncore/apps/opie-console/function_keyboard.h
+++ b/noncore/apps/opie-console/function_keyboard.h
@@ -1,83 +1,100 @@
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>
11#include <qcombobox.h>
10#include "profiledialogwidget.h" 12#include "profiledialogwidget.h"
11 13
14
12class FKey { 15class FKey {
13 16
14public: 17public:
15 18
16 FKey(): qcode(0), unicode(0) {}; 19 FKey(): qcode(0), unicode(0) {};
17 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) {};
18 21
19 QString getL() { return label; } 22 QString getL() { return label; }
20 ushort getQ() { return qcode; } 23 ushort getQ() { return qcode; }
21 ushort getU() { return unicode; } 24 ushort getU() { return unicode; }
22 25
23 26
24private: 27private:
25 28
26 QString label; 29 QString label;
27 ushort qcode; 30 ushort qcode;
28 ushort unicode; 31 ushort unicode;
29}; 32};
30 33
31class FunctionKeyboard : public QFrame { 34class FunctionKeyboard : public QFrame {
32 Q_OBJECT 35 Q_OBJECT
33 36
34public: 37public:
35 FunctionKeyboard(QWidget *parent = 0); 38 FunctionKeyboard(QWidget *parent = 0);
36 ~FunctionKeyboard(); 39 ~FunctionKeyboard();
37 40
41 void changeRows(int);
42 void changeCols(int);
43
38 void paintEvent(QPaintEvent *); 44 void paintEvent(QPaintEvent *);
39 void paintKey(int, int); 45 void paintKey(int, int);
40 void mousePressEvent(QMouseEvent*); 46 void mousePressEvent(QMouseEvent*);
41 void mouseReleaseEvent(QMouseEvent*); 47 void mouseReleaseEvent(QMouseEvent*);
42 void resizeEvent(QResizeEvent*); 48 void resizeEvent(QResizeEvent*);
43 QSize sizeHint() const; 49 QSize sizeHint() const;
44 50
45signals: 51signals:
46 52
47 void keyPressed(ushort, ushort, bool, bool, bool); 53 void keyPressed(ushort, ushort, bool, bool, bool, ushort, ushort);
48 54
49private: 55private:
50 56
51 void loadDefaults(); 57 void loadDefaults();
52 58
53 59
54private: 60private:
55 61
56 // thie key for the map is the row/col 62 // thie key for the map is the row/col
57 QMap<QString, FKey> keys; 63 QMap<QString, FKey> keys;
58 64
59 uint numRows; 65 uint numRows;
60 uint numCols; 66 uint numCols;
61 uint keyHeight; 67 uint keyHeight;
62 double keyWidth; // decimal point matters! 68 double keyWidth; // decimal point matters!
63 69
64 int pressedRow, pressedCol; 70 int pressedRow, pressedCol;
65 71
66 QObject *parent; 72 QObject *parent;
67 73
68}; 74};
69 75
70class FunctionKeyboardConfig : public ProfileDialogKeyWidget { 76class FunctionKeyboardConfig : public ProfileDialogKeyWidget {
71 Q_OBJECT 77 Q_OBJECT
72public: 78public:
73 FunctionKeyboardConfig(const QString& name, QWidget *wid); 79 FunctionKeyboardConfig(const QString& name, QWidget *wid);
74 ~FunctionKeyboardConfig(); 80 ~FunctionKeyboardConfig();
75 81
76 void load(const Profile&); 82 void load(const Profile&);
77 void save(Profile&); 83 void save(Profile&);
78 84
85private slots:
86
87 void slotKeyPressed(ushort, ushort, bool, bool, bool, ushort, ushort);
88 void slotChangeRows(int);
89 void slotChangeCols(int);
90 void slotChangeIcon(int);
91
79private: 92private:
80 93
94 FunctionKeyboard *kb;
95 QSpinBox *m_rowBox, *m_colBox;
96 QComboBox *m_labels;
97
81}; 98};
82 99
83#endif 100#endif
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 89f3516..30dd21c 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,543 +1,543 @@
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)), 211 connect(m_kb, SIGNAL(keyPressed(ushort, ushort, bool, bool, bool, ushort, ushort)),
212 this, SLOT(slotKeyReceived(ushort, ushort, bool, bool, bool))); 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), false );
501 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 501 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken );
502 502
503 setCentralWidget( m_consoleWindow ); 503 setCentralWidget( m_consoleWindow );
504 ( m_curSession->widgetStack() )->show(); 504 ( m_curSession->widgetStack() )->show();
505 ( m_curSession->emulationHandler() )->cornerButton()->hide(); 505 ( m_curSession->emulationHandler() )->cornerButton()->hide();
506 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 506 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
507 507
508 } else { 508 } else {
509 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); 509 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget();
510 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); 510 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame );
511 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop 511 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop
512 , QPoint(0,0), false ); 512 , QPoint(0,0), false );
513 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); 513 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() );
514 ( m_curSession->widgetStack() )->setFocus(); 514 ( m_curSession->widgetStack() )->setFocus();
515 ( m_curSession->widgetStack() )->show(); 515 ( m_curSession->widgetStack() )->show();
516 516
517 ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); 517 ( ( m_curSession->emulationHandler() )->cornerButton() )->show();
518 518
519 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 519 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
520 } 520 }
521 521
522 m_isFullscreen = !m_isFullscreen; 522 m_isFullscreen = !m_isFullscreen;
523} 523}
524 524
525 525
526void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool pressed, bool) { 526void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool pressed, bool, ushort, ushort) {
527 527
528 //qWarning("unicode: %x, qkey: %x, %s", u, q, pressed ? "pressed" : "released"); 528 //qWarning("unicode: %x, qkey: %x, %s", u, q, pressed ? "pressed" : "released");
529 529
530 if ( m_curSession ) { 530 if ( m_curSession ) {
531 531
532 QEvent::Type state; 532 QEvent::Type state;
533 533
534 if (pressed) state = QEvent::KeyPress; 534 if (pressed) state = QEvent::KeyPress;
535 else state = QEvent::KeyRelease; 535 else state = QEvent::KeyRelease;
536 536
537 QKeyEvent ke(state, q, u, 0, QString(QChar(u))); 537 QKeyEvent ke(state, q, u, 0, QString(QChar(u)));
538 538
539 // where should i send this event? doesnt work sending it here 539 // where should i send this event? doesnt work sending it here
540 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); 540 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke);
541 ke.ignore(); 541 ke.ignore();
542 } 542 }
543} 543}
diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h
index cc4ef76..68f6fa8 100644
--- a/noncore/apps/opie-console/mainwindow.h
+++ b/noncore/apps/opie-console/mainwindow.h
@@ -1,123 +1,123 @@
1#ifndef OPIE_MAIN_WINDOW_H 1#ifndef OPIE_MAIN_WINDOW_H
2#define OPIE_MAIN_WINDOW_H 2#define OPIE_MAIN_WINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qlist.h> 5#include <qlist.h>
6 6
7#include "session.h" 7#include "session.h"
8 8
9/** 9/**
10 * this is the MainWindow of the new opie console 10 * this is the MainWindow of the new opie console
11 * it's also the dispatcher between the different 11 * it's also the dispatcher between the different
12 * actions supported by the gui 12 * actions supported by the gui
13 */ 13 */
14class QToolBar; 14class QToolBar;
15class QToolButton; 15class QToolButton;
16class QMenuBar; 16class QMenuBar;
17class QAction; 17class QAction;
18class MetaFactory; 18class MetaFactory;
19class TabWidget; 19class TabWidget;
20class ProfileManager; 20class ProfileManager;
21class Profile; 21class Profile;
22class FunctionKeyboard; 22class FunctionKeyboard;
23class QuickButton; 23class QuickButton;
24 24
25class MainWindow : public QMainWindow { 25class MainWindow : public QMainWindow {
26 Q_OBJECT 26 Q_OBJECT
27public: 27public:
28 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); 28 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 );
29 ~MainWindow(); 29 ~MainWindow();
30 30
31 /** 31 /**
32 * our factory to generate IOLayer and so on 32 * our factory to generate IOLayer and so on
33 * 33 *
34 */ 34 */
35 MetaFactory* factory(); 35 MetaFactory* factory();
36 36
37 /** 37 /**
38 * A session contains a QWidget*, 38 * A session contains a QWidget*,
39 * an IOLayer* and some infos for us 39 * an IOLayer* and some infos for us
40 */ 40 */
41 Session* currentSession(); 41 Session* currentSession();
42 42
43 /** 43 /**
44 * the session list 44 * the session list
45 */ 45 */
46 QList<Session> sessions(); 46 QList<Session> sessions();
47 47
48 /** 48 /**
49 * 49 *
50 */ 50 */
51 ProfileManager* manager(); 51 ProfileManager* manager();
52 TabWidget* tabWidget(); 52 TabWidget* tabWidget();
53 53
54private slots: 54private slots:
55 void slotNew(); 55 void slotNew();
56 void slotConnect(); 56 void slotConnect();
57 void slotDisconnect(); 57 void slotDisconnect();
58 void slotTerminate(); 58 void slotTerminate();
59 void slotConfigure(); 59 void slotConfigure();
60 void slotClose(); 60 void slotClose();
61 void slotProfile(int); 61 void slotProfile(int);
62 void slotTransfer(); 62 void slotTransfer();
63 void slotOpenKeb(bool); 63 void slotOpenKeb(bool);
64 void slotOpenButtons(bool); 64 void slotOpenButtons(bool);
65 void slotRecordScript(); 65 void slotRecordScript();
66 void slotSaveScript(); 66 void slotSaveScript();
67 void slotRunScript(); 67 void slotRunScript();
68 void slotFullscreen(); 68 void slotFullscreen();
69 void slotSessionChanged( Session* ); 69 void slotSessionChanged( Session* );
70 void slotKeyReceived(ushort, ushort, bool, bool, bool); 70 void slotKeyReceived(ushort, ushort, bool, bool, bool, ushort, ushort);
71 71
72private: 72private:
73 void initUI(); 73 void initUI();
74 void populateProfiles(); 74 void populateProfiles();
75 void create( const Profile& ); 75 void create( const Profile& );
76 /** 76 /**
77 * the current session 77 * the current session
78 */ 78 */
79 Session* m_curSession; 79 Session* m_curSession;
80 80
81 /** 81 /**
82 * the session list 82 * the session list
83 */ 83 */
84 QList<Session> m_sessions; 84 QList<Session> m_sessions;
85 85
86 /** 86 /**
87 * the metafactory 87 * the metafactory
88 */ 88 */
89 MetaFactory* m_factory; 89 MetaFactory* m_factory;
90 ProfileManager* m_manager; 90 ProfileManager* m_manager;
91 91
92 TabWidget* m_consoleWindow; 92 TabWidget* m_consoleWindow;
93 QToolBar* m_tool; 93 QToolBar* m_tool;
94 QToolBar* m_icons; 94 QToolBar* m_icons;
95 QToolBar* m_keyBar; 95 QToolBar* m_keyBar;
96 QToolBar* m_buttonBar; 96 QToolBar* m_buttonBar;
97 QMenuBar* m_bar; 97 QMenuBar* m_bar;
98 QPopupMenu* m_console; 98 QPopupMenu* m_console;
99 QPopupMenu* m_settings; 99 QPopupMenu* m_settings;
100 QPopupMenu* m_sessionsPop; 100 QPopupMenu* m_sessionsPop;
101 QPopupMenu* m_scripts; 101 QPopupMenu* m_scripts;
102 QAction* m_connect; 102 QAction* m_connect;
103 QAction* m_disconnect; 103 QAction* m_disconnect;
104 QAction* m_terminate; 104 QAction* m_terminate;
105 QAction* m_transfer; 105 QAction* m_transfer;
106 QAction* m_setProfiles; 106 QAction* m_setProfiles;
107 QAction* m_openKeys; 107 QAction* m_openKeys;
108 QAction* m_openButtons; 108 QAction* m_openButtons;
109 QAction* m_recordScript; 109 QAction* m_recordScript;
110 QAction* m_saveScript; 110 QAction* m_saveScript;
111 QAction* m_runScript; 111 QAction* m_runScript;
112 QAction* m_fullscreen; 112 QAction* m_fullscreen;
113 QAction* m_closewindow; 113 QAction* m_closewindow;
114 114
115 FunctionKeyboard *m_kb; 115 FunctionKeyboard *m_kb;
116 QuickButton *m_qb; 116 QuickButton *m_qb;
117 bool m_isFullscreen; 117 bool m_isFullscreen;
118 118
119 QWidget* savedParentFullscreen; 119 QWidget* savedParentFullscreen;
120}; 120};
121 121
122 122
123#endif 123#endif