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
@@ -22,241 +22,241 @@ FunctionKeyboard::FunctionKeyboard(QWidget *parent) :
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
@@ -404,140 +404,137 @@ void MainWindow::slotClose() {
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}