summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 55e9836..27407d9 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,531 +1,533 @@
1#include <assert.h> 1#include <assert.h>
2 2
3
4
5#include <qaction.h> 3#include <qaction.h>
6#include <qmenubar.h> 4#include <qmenubar.h>
7#include <qlabel.h> 5#include <qlabel.h>
8#include <qpopupmenu.h> 6#include <qpopupmenu.h>
9#include <qtoolbar.h> 7#include <qtoolbar.h>
10#include <qmessagebox.h> 8#include <qmessagebox.h>
11#include <qpushbutton.h> 9#include <qpushbutton.h>
12#include <qwhatsthis.h> 10#include <qwhatsthis.h>
13 11
14#include <qpe/resource.h> 12#include <qpe/resource.h>
15#include <opie/ofiledialog.h>
16 13
14#include <opie/ofiledialog.h>
17 15
18#include "keytrans.h" 16#include "keytrans.h"
19#include "profileeditordialog.h" 17#include "profileeditordialog.h"
20#include "configdialog.h" 18#include "configdialog.h"
21#include "default.h" 19#include "default.h"
22#include "metafactory.h" 20#include "metafactory.h"
23#include "profile.h" 21#include "profile.h"
24#include "profilemanager.h" 22#include "profilemanager.h"
25#include "mainwindow.h" 23#include "mainwindow.h"
26#include "tabwidget.h" 24#include "tabwidget.h"
27#include "transferdialog.h" 25#include "transferdialog.h"
28#include "function_keyboard.h" 26#include "function_keyboard.h"
29#include "emulation_handler.h" 27#include "emulation_handler.h"
30#include "script.h" 28#include "script.h"
31#include "quick_button.h" 29#include "quick_button.h"
32 30
33 31
34 32
35MainWindow::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) {
36 KeyTrans::loadAll(); 34 KeyTrans::loadAll();
37 for (int i = 0; i < KeyTrans::count(); i++ ) { 35 for (int i = 0; i < KeyTrans::count(); i++ ) {
38 KeyTrans* s = KeyTrans::find(i ); 36 KeyTrans* s = KeyTrans::find(i );
39 assert( s ); 37 assert( s );
40 } 38 }
41 m_factory = new MetaFactory(); 39 m_factory = new MetaFactory();
42 Default def(m_factory); 40 Default def(m_factory);
43 m_sessions.setAutoDelete( TRUE ); 41 m_sessions.setAutoDelete( TRUE );
44 m_curSession = 0; 42 m_curSession = 0;
45 m_manager = new ProfileManager( m_factory ); 43 m_manager = new ProfileManager( m_factory );
46 m_manager->load(); 44 m_manager->load();
47 45
48 initUI(); 46 initUI();
49 populateProfiles(); 47 populateProfiles();
50} 48}
51void MainWindow::initUI() { 49void MainWindow::initUI() {
52 setToolBarsMovable( FALSE ); 50 setToolBarsMovable( FALSE );
53 51
54 /* tool bar for the menu */ 52 /* tool bar for the menu */
55 m_tool = new QToolBar( this ); 53 m_tool = new QToolBar( this );
56 m_tool->setHorizontalStretchable( TRUE ); 54 m_tool->setHorizontalStretchable( TRUE );
57 55
58 m_bar = new QMenuBar( m_tool ); 56 m_bar = new QMenuBar( m_tool );
59 m_console = new QPopupMenu( this ); 57 m_console = new QPopupMenu( this );
60 m_scripts = new QPopupMenu( this ); 58 m_scripts = new QPopupMenu( this );
61 m_sessionsPop= new QPopupMenu( this ); 59 m_sessionsPop= new QPopupMenu( this );
62 //m_settings = new QPopupMenu( this ); 60 //m_settings = new QPopupMenu( this );
63 61
64 /* add a toolbar for icons */ 62 /* add a toolbar for icons */
65 m_icons = new QToolBar(this); 63 m_icons = new QToolBar(this);
66 64
67 65
68 66
69 67
70 /* 68 /*
71 * the settings action 69 * the settings action
72 */ 70 */
73 m_setProfiles = new QAction(tr("Configure Profiles"), 71 m_setProfiles = new QAction(tr("Configure Profiles"),
74 Resource::loadPixmap( "SettingsIcon" ), 72 Resource::loadPixmap( "SettingsIcon" ),
75 QString::null, 0, this, 0); 73 QString::null, 0, this, 0);
76 // m_setProfiles->addTo( m_settings ); 74 // m_setProfiles->addTo( m_settings );
77 m_setProfiles->addTo( m_icons ); 75 m_setProfiles->addTo( m_icons );
78 m_setProfiles->addTo( m_console ); 76 m_setProfiles->addTo( m_console );
79 connect( m_setProfiles, SIGNAL(activated() ), 77 connect( m_setProfiles, SIGNAL(activated() ),
80 this, SLOT(slotConfigure() ) ); 78 this, SLOT(slotConfigure() ) );
81 79
82 80
83 /* 81 /*
84 * new Action for new sessions 82 * new Action for new sessions
85 */ 83 */
86 QAction* a = new QAction(tr("New Connection"), 84 QAction* a = new QAction(tr("New Connection"),
87 Resource::loadPixmap( "new" ), 85 Resource::loadPixmap( "new" ),
88 QString::null, 0, this, 0); 86 QString::null, 0, this, 0);
89 a->addTo( m_console ); 87 a->addTo( m_console );
90 a->addTo( m_icons ); 88 a->addTo( m_icons );
91 connect(a, SIGNAL(activated() ), 89 connect(a, SIGNAL(activated() ),
92 this, SLOT(slotNew() ) ); 90 this, SLOT(slotNew() ) );
93 91
94 /* 92 /*
95 * connect action 93 * connect action
96 */ 94 */
97 m_connect = new QAction(); 95 m_connect = new QAction();
98 m_connect->setText( tr("Connect") ); 96 m_connect->setText( tr("Connect") );
99 m_connect->addTo( m_console ); 97 m_connect->addTo( m_console );
100 connect(m_connect, SIGNAL(activated() ), 98 connect(m_connect, SIGNAL(activated() ),
101 this, SLOT(slotConnect() ) ); 99 this, SLOT(slotConnect() ) );
102 100
103 /* 101 /*
104 * disconnect action 102 * disconnect action
105 */ 103 */
106 m_disconnect = new QAction(); 104 m_disconnect = new QAction();
107 m_disconnect->setText( tr("Disconnect") ); 105 m_disconnect->setText( tr("Disconnect") );
108 m_disconnect->addTo( m_console ); 106 m_disconnect->addTo( m_console );
109 connect(m_disconnect, SIGNAL(activated() ), 107 connect(m_disconnect, SIGNAL(activated() ),
110 this, SLOT(slotDisconnect() ) ); 108 this, SLOT(slotDisconnect() ) );
111 109
112 m_transfer = new QAction(); 110 m_transfer = new QAction();
113 m_transfer->setText( tr("Transfer file...") ); 111 m_transfer->setText( tr("Transfer file...") );
114 m_transfer->addTo( m_console ); 112 m_transfer->addTo( m_console );
115 connect(m_transfer, SIGNAL(activated() ), 113 connect(m_transfer, SIGNAL(activated() ),
116 this, SLOT(slotTransfer() ) ); 114 this, SLOT(slotTransfer() ) );
117 115
118 116
119 /* 117 /*
120 * fullscreen 118 * fullscreen
121 */ 119 */
122 m_isFullscreen = false; 120 m_isFullscreen = false;
123 121
124 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) 122 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" )
125 , QString::null, 0, this, 0); 123 , QString::null, 0, this, 0);
126 m_fullscreen->addTo( m_console ); 124 m_fullscreen->addTo( m_console );
127 m_fullscreen->addTo( m_icons ); 125 m_fullscreen->addTo( m_icons );
128 connect( m_fullscreen, SIGNAL( activated() ), 126 connect( m_fullscreen, SIGNAL( activated() ),
129 this, SLOT( slotFullscreen() ) ); 127 this, SLOT( slotFullscreen() ) );
130 128
131 /* 129 /*
132 * terminate action 130 * terminate action
133 */ 131 */
134 m_terminate = new QAction(); 132 m_terminate = new QAction();
135 m_terminate->setText( tr("Terminate") ); 133 m_terminate->setText( tr("Terminate") );
136 m_terminate->addTo( m_console ); 134 m_terminate->addTo( m_console );
137 connect(m_terminate, SIGNAL(activated() ), 135 connect(m_terminate, SIGNAL(activated() ),
138 this, SLOT(slotTerminate() ) ); 136 this, SLOT(slotTerminate() ) );
139 137
140 m_closewindow = new QAction(); 138 m_closewindow = new QAction();
141 m_closewindow->setText( tr("Close Window") ); 139 m_closewindow->setText( tr("Close Window") );
142 m_closewindow->addTo( m_console ); 140 m_closewindow->addTo( m_console );
143 connect( m_closewindow, SIGNAL(activated() ), 141 connect( m_closewindow, SIGNAL(activated() ),
144 this, SLOT(slotClose() ) ); 142 this, SLOT(slotClose() ) );
145 143
146 144
147 /* 145 /*
148 * script actions 146 * script actions
149 */ 147 */
150 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); 148 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
151 m_recordScript->addTo(m_scripts); 149 m_recordScript->addTo(m_scripts);
152 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); 150 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript()));
153 151
154 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); 152 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0);
155 m_saveScript->addTo(m_scripts); 153 m_saveScript->addTo(m_scripts);
156 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); 154 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript()));
157 155
158 m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); 156 m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0);
159 m_runScript->addTo(m_scripts); 157 m_runScript->addTo(m_scripts);
160 connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); 158 connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript()));
161 159
162 /* 160 /*
163 * action that open/closes the keyboard 161 * action that open/closes the keyboard
164 */ 162 */
165 m_openKeys = new QAction (tr("Open Keyboard..."), 163 m_openKeys = new QAction (tr("Open Keyboard..."),
166 Resource::loadPixmap( "down" ), 164 Resource::loadPixmap( "down" ),
167 QString::null, 0, this, 0); 165 QString::null, 0, this, 0);
168 166
169 m_openKeys->setToggleAction(true); 167 m_openKeys->setToggleAction(true);
170 168
171 connect (m_openKeys, SIGNAL(toggled(bool)), 169 connect (m_openKeys, SIGNAL(toggled(bool)),
172 this, SLOT(slotOpenKeb(bool))); 170 this, SLOT(slotOpenKeb(bool)));
173 m_openKeys->addTo(m_icons); 171 m_openKeys->addTo(m_icons);
174 172
175 173
176 /* 174 /*
177 * action that open/closes the keyboard 175 * action that open/closes the keyboard
178 */ 176 */
179 m_openButtons = new QAction ( tr( "Open Buttons..." ), 177 m_openButtons = new QAction ( tr( "Open Buttons..." ),
180 Resource::loadPixmap( "down" ), 178 Resource::loadPixmap( "down" ),
181 QString::null, 0, this, 0 ); 179 QString::null, 0, this, 0 );
182 180
183 m_openButtons->setToggleAction( true ); 181 m_openButtons->setToggleAction( true );
184 182
185 connect ( m_openButtons, SIGNAL( toggled( bool ) ), 183 connect ( m_openButtons, SIGNAL( toggled( bool ) ),
186 this, SLOT( slotOpenButtons( bool ) ) ); 184 this, SLOT( slotOpenButtons( bool ) ) );
187 m_openButtons->addTo( m_icons ); 185 m_openButtons->addTo( m_icons );
188 186
189 187
190 /* insert the submenu */ 188 /* insert the submenu */
191 m_console->insertItem(tr("New from Profile"), m_sessionsPop, 189 m_console->insertItem(tr("New from Profile"), m_sessionsPop,
192 -1, 0); 190 -1, 0);
193 191
194 /* insert the connection menu */ 192 /* insert the connection menu */
195 m_bar->insertItem( tr("Connection"), m_console ); 193 m_bar->insertItem( tr("Connection"), m_console );
196 194
197 /* the scripts menu */ 195 /* the scripts menu */
198 m_bar->insertItem( tr("Scripts"), m_scripts ); 196 m_bar->insertItem( tr("Scripts"), m_scripts );
199 197
200 /* the settings menu */ 198 /* the settings menu */
201 // m_bar->insertItem( tr("Settings"), m_settings ); 199 // m_bar->insertItem( tr("Settings"), m_settings );
202 200
203 /* and the keyboard */ 201 /* and the keyboard */
204 m_keyBar = new QToolBar(this); 202 m_keyBar = new QToolBar(this);
205 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); 203 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE );
206 m_keyBar->setHorizontalStretchable( TRUE ); 204 m_keyBar->setHorizontalStretchable( TRUE );
207 m_keyBar->hide(); 205 m_keyBar->hide();
208 206
209 m_kb = new FunctionKeyboard(m_keyBar); 207 m_kb = new FunctionKeyboard(m_keyBar);
210 connect(m_kb, SIGNAL(keyPressed(ushort, ushort, bool, bool, bool)), 208 connect(m_kb, SIGNAL(keyPressed(ushort, ushort, bool, bool, bool)),
211 this, SLOT(slotKeyReceived(ushort, ushort, bool, bool, bool))); 209 this, SLOT(slotKeyReceived(ushort, ushort, bool, bool, bool)));
212 210
213 m_buttonBar = new QToolBar( this ); 211 m_buttonBar = new QToolBar( this );
214 addToolBar( m_buttonBar, "Buttons", QMainWindow::Top, TRUE ); 212 addToolBar( m_buttonBar, "Buttons", QMainWindow::Top, TRUE );
215 m_buttonBar->setHorizontalStretchable( TRUE ); 213 m_buttonBar->setHorizontalStretchable( TRUE );
216 m_buttonBar->hide(); 214 m_buttonBar->hide();
217 215
218 m_qb = new QuickButton( m_buttonBar ); 216 m_qb = new QuickButton( m_buttonBar );
219 connect( m_qb, SIGNAL( keyPressed( ushort, ushort, bool, bool, bool) ), 217 connect( m_qb, SIGNAL( keyPressed( ushort, ushort, bool, bool, bool) ),
220 this, SLOT( slotKeyReceived( ushort, ushort, bool, bool, bool) ) ); 218 this, SLOT( slotKeyReceived( ushort, ushort, bool, bool, bool) ) );
221 219
222 220
223 m_connect->setEnabled( false ); 221 m_connect->setEnabled( false );
224 m_disconnect->setEnabled( false ); 222 m_disconnect->setEnabled( false );
225 m_terminate->setEnabled( false ); 223 m_terminate->setEnabled( false );
226 m_transfer->setEnabled( false ); 224 m_transfer->setEnabled( false );
227 m_recordScript->setEnabled( false ); 225 m_recordScript->setEnabled( false );
228 m_saveScript->setEnabled( false ); 226 m_saveScript->setEnabled( false );
229 m_runScript->setEnabled( false ); 227 m_runScript->setEnabled( false );
230 m_fullscreen->setEnabled( false ); 228 m_fullscreen->setEnabled( false );
231 m_closewindow->setEnabled( false ); 229 m_closewindow->setEnabled( false );
232 230
233 /* 231 /*
234 * connect to the menu activation 232 * connect to the menu activation
235 */ 233 */
236 connect( m_sessionsPop, SIGNAL(activated( int ) ), 234 connect( m_sessionsPop, SIGNAL(activated( int ) ),
237 this, SLOT(slotProfile( int ) ) ); 235 this, SLOT(slotProfile( int ) ) );
238 236
239 m_consoleWindow = new TabWidget( this, "blah"); 237 m_consoleWindow = new TabWidget( this, "blah");
240 connect(m_consoleWindow, SIGNAL(activated(Session*) ), 238 connect(m_consoleWindow, SIGNAL(activated(Session*) ),
241 this, SLOT(slotSessionChanged(Session*) ) ); 239 this, SLOT(slotSessionChanged(Session*) ) );
242 setCentralWidget( m_consoleWindow ); 240 setCentralWidget( m_consoleWindow );
243 241
244} 242}
245 243
246ProfileManager* MainWindow::manager() { 244ProfileManager* MainWindow::manager() {
247 return m_manager; 245 return m_manager;
248} 246}
249TabWidget* MainWindow::tabWidget() { 247TabWidget* MainWindow::tabWidget() {
250 return m_consoleWindow; 248 return m_consoleWindow;
251} 249}
252void MainWindow::populateProfiles() { 250void MainWindow::populateProfiles() {
253 m_sessionsPop->clear(); 251 m_sessionsPop->clear();
254 Profile::ValueList list = manager()->all(); 252 Profile::ValueList list = manager()->all();
255 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { 253 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) {
256 m_sessionsPop->insertItem( (*it).name() ); 254 m_sessionsPop->insertItem( (*it).name() );
257 } 255 }
258 256
259} 257}
260MainWindow::~MainWindow() { 258MainWindow::~MainWindow() {
261 delete m_factory; 259 delete m_factory;
262 manager()->save(); 260 manager()->save();
263} 261}
264 262
265MetaFactory* MainWindow::factory() { 263MetaFactory* MainWindow::factory() {
266 return m_factory; 264 return m_factory;
267} 265}
268 266
269Session* MainWindow::currentSession() { 267Session* MainWindow::currentSession() {
270 return m_curSession; 268 return m_curSession;
271} 269}
272 270
273QList<Session> MainWindow::sessions() { 271QList<Session> MainWindow::sessions() {
274 return m_sessions; 272 return m_sessions;
275} 273}
276 274
277void MainWindow::slotNew() { 275void MainWindow::slotNew() {
278 ProfileEditorDialog dlg(factory() ); 276 ProfileEditorDialog dlg(factory() );
279 dlg.showMaximized(); 277 dlg.showMaximized();
280 int ret = dlg.exec(); 278 int ret = dlg.exec();
281 279
282 if ( ret == QDialog::Accepted ) { 280 if ( ret == QDialog::Accepted ) {
283 create( dlg.profile() ); 281 create( dlg.profile() );
284 } 282 }
285} 283}
286 284
287void MainWindow::slotRecordScript() { 285void MainWindow::slotRecordScript() {
288/* if (currentSession()) { 286/* if (currentSession()) {
289 currentSession()->emulationLayer()->startRecording(); 287 currentSession()->emulationLayer()->startRecording();
290 } 288 }
291 */ 289 */
292} 290}
293 291
294void MainWindow::slotSaveScript() { 292void MainWindow::slotSaveScript() {
295/* if (currentSession() && currentSession()->emulationLayer()->isRecording()) { 293/* if (currentSession() && currentSession()->emulationLayer()->isRecording()) {
296 MimeTypes types; 294 MimeTypes types;
297 QStringList script; 295 QStringList script;
298 script << "text/plain"; 296 script << "text/plain";
299 types.insert("Script", script); 297 types.insert("Script", script);
300 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); 298 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types);
301 if (!filename.isEmpty()) { 299 if (!filename.isEmpty()) {
302 currentSession()->emulationLayer()->script()->saveTo(filename); 300 currentSession()->emulationLayer()->script()->saveTo(filename);
303 currentSession()->emulationLayer()->clearScript(); 301 currentSession()->emulationLayer()->clearScript();
304 } 302 }
305 } 303 }
306 */ 304 */
307} 305}
308 306
309void MainWindow::slotRunScript() { 307void MainWindow::slotRunScript() {
310/* 308/*
311 if (currentSession()) { 309 if (currentSession()) {
312 MimeTypes types; 310 MimeTypes types;
313 QStringList script; 311 QStringList script;
314 script << "text/plain"; 312 script << "text/plain";
315 types.insert("Script", script); 313 types.insert("Script", script);
316 QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); 314 QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types);
317 if (!filename.isEmpty()) { 315 if (!filename.isEmpty()) {
318 Script script(DocLnk(filename).file()); 316 Script script(DocLnk(filename).file());
319 currentSession()->emulationLayer()->runScript(&script); 317 currentSession()->emulationLayer()->runScript(&script);
320 } 318 }
321 } 319 }
322 */ 320 */
323} 321}
324 322
325void MainWindow::slotConnect() { 323void MainWindow::slotConnect() {
326 if ( currentSession() ) { 324 if ( currentSession() ) {
327 bool ret = currentSession()->layer()->open(); 325 bool ret = currentSession()->layer()->open();
328 if(!ret) QMessageBox::warning(currentSession()->widgetStack(), 326 if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
329 QObject::tr("Failed"), 327 QObject::tr("Failed"),
330 QObject::tr("Connecting failed for this session.")); 328 QObject::tr("Connecting failed for this session."));
331 else { 329 else {
332 m_connect->setEnabled( false ); 330 m_connect->setEnabled( false );
333 m_disconnect->setEnabled( true ); 331 m_disconnect->setEnabled( true );
334 } 332 }
335 } 333 }
336} 334}
337 335
338void MainWindow::slotDisconnect() { 336void MainWindow::slotDisconnect() {
339 if ( currentSession() ) { 337 if ( currentSession() ) {
340 currentSession()->layer()->close(); 338 currentSession()->layer()->close();
341 m_connect->setEnabled( true ); 339 m_connect->setEnabled( true );
342 m_disconnect->setEnabled( false ); 340 m_disconnect->setEnabled( false );
343 } 341 }
344} 342}
345 343
346void MainWindow::slotTerminate() { 344void MainWindow::slotTerminate() {
347 if ( currentSession() ) 345 if ( currentSession() )
348 currentSession()->layer()->close(); 346 currentSession()->layer()->close();
349 347
350 slotClose(); 348 slotClose();
351 /* FIXME move to the next session */ 349 /* FIXME move to the next session */
352} 350}
353 351
354void MainWindow::slotConfigure() { 352void MainWindow::slotConfigure() {
355 ConfigDialog conf( manager()->all(), factory() ); 353 ConfigDialog conf( manager()->all(), factory() );
356 conf.showMaximized(); 354 conf.showMaximized();
357 355
358 int ret = conf.exec(); 356 int ret = conf.exec();
359 357
360 if ( QDialog::Accepted == ret ) { 358 if ( QDialog::Accepted == ret ) {
361 manager()->setProfiles( conf.list() ); 359 manager()->setProfiles( conf.list() );
362 manager()->save(); 360 manager()->save();
363 populateProfiles(); 361 populateProfiles();
364 } 362 }
365} 363}
366/* 364/*
367 * we will remove 365 * we will remove
368 * this window from the tabwidget 366 * this window from the tabwidget
369 * remove it from the list 367 * remove it from the list
370 * delete it 368 * delete it
371 * and set the currentSession() 369 * and set the currentSession()
372 */ 370 */
373void MainWindow::slotClose() { 371void MainWindow::slotClose() {
374 if (!currentSession() ) 372 if (!currentSession() )
375 return; 373 return;
376 374
377 Session* ses = currentSession(); 375 Session* ses = currentSession();
378 qWarning("removing! currentSession %s", currentSession()->name().latin1() ); 376 qWarning("removing! currentSession %s", currentSession()->name().latin1() );
379 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ 377 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */
380 m_curSession = NULL; 378 m_curSession = NULL;
381 tabWidget()->remove( /*currentSession()*/ses ); 379 tabWidget()->remove( /*currentSession()*/ses );
382 /*it's autodelete */ 380 /*it's autodelete */
383 m_sessions.remove( ses ); 381 m_sessions.remove( ses );
384 qWarning("after remove!!"); 382 qWarning("after remove!!");
385 383
386 if (!currentSession() ) { 384 if (!currentSession() ) {
387 m_connect->setEnabled( false ); 385 m_connect->setEnabled( false );
388 m_disconnect->setEnabled( false ); 386 m_disconnect->setEnabled( false );
389 m_terminate->setEnabled( false ); 387 m_terminate->setEnabled( false );
390 m_transfer->setEnabled( false ); 388 m_transfer->setEnabled( false );
391 m_recordScript->setEnabled( false ); 389 m_recordScript->setEnabled( false );
392 m_saveScript->setEnabled( false ); 390 m_saveScript->setEnabled( false );
393 m_runScript->setEnabled( false ); 391 m_runScript->setEnabled( false );
394 m_fullscreen->setEnabled( false ); 392 m_fullscreen->setEnabled( false );
395 m_closewindow->setEnabled( false ); 393 m_closewindow->setEnabled( false );
396 } 394 }
397} 395}
398 396
399/* 397/*
400 * We will get the name 398 * We will get the name
401 * Then the profile 399 * Then the profile
402 * and then we will make a profile 400 * and then we will make a profile
403 */ 401 */
404void MainWindow::slotProfile( int id) { 402void MainWindow::slotProfile( int id) {
405 Profile prof = manager()->profile( m_sessionsPop->text( id) ); 403 Profile prof = manager()->profile( m_sessionsPop->text( id) );
406 create( prof ); 404 create( prof );
407} 405}
408void MainWindow::create( const Profile& prof ) { 406void MainWindow::create( const Profile& prof ) {
409 Session *ses = manager()->fromProfile( prof, tabWidget() ); 407 Session *ses = manager()->fromProfile( prof, tabWidget() );
410 408
411 if((!ses) || (!ses->layer()) || (!ses->widgetStack())) 409 if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
412 { 410 {
413 QMessageBox::warning(this, 411 QMessageBox::warning(this,
414 QObject::tr("Session failed"), 412 QObject::tr("Session failed"),
415 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); 413 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>"));
416 //if(ses) delete ses; 414 //if(ses) delete ses;
417 return; 415 return;
418 } 416 }
419 417
420 m_sessions.append( ses ); 418 m_sessions.append( ses );
421 tabWidget()->add( ses ); 419 tabWidget()->add( ses );
422 m_curSession = ses; 420 m_curSession = ses;
423 421
424 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it 422 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it
425 m_connect->setEnabled( true ); 423 m_connect->setEnabled( true );
426 m_disconnect->setEnabled( false ); 424 m_disconnect->setEnabled( false );
427 m_terminate->setEnabled( true ); 425 m_terminate->setEnabled( true );
428 m_transfer->setEnabled( true ); 426 m_transfer->setEnabled( true );
429 m_recordScript->setEnabled( true ); 427 m_recordScript->setEnabled( true );
430 m_saveScript->setEnabled( true ); 428 m_saveScript->setEnabled( true );
431 m_runScript->setEnabled( true ); 429 m_runScript->setEnabled( true );
432 m_fullscreen->setEnabled( true ); 430 m_fullscreen->setEnabled( true );
433 m_closewindow->setEnabled( true ); 431 m_closewindow->setEnabled( true );
434 432
435 433
436 // is io_layer wants direct connection, then autoconnect 434 // is io_layer wants direct connection, then autoconnect
437 if ( ( m_curSession->layer() )->supports()[0] = 1 ) { 435 if ( ( m_curSession->layer() )->supports()[0] = 1 ) {
438 slotConnect(); 436 slotConnect();
439 } 437 }
440} 438}
441 439
442void MainWindow::slotTransfer() 440void MainWindow::slotTransfer()
443{ 441{
444 if ( currentSession() ) { 442 if ( currentSession() ) {
445 TransferDialog dlg(currentSession()->widgetStack(), this); 443 TransferDialog dlg(currentSession()->widgetStack(), this);
446 dlg.showMaximized(); 444 dlg.showMaximized();
447 //currentSession()->widgetStack()->add(dlg); 445 //currentSession()->widgetStack()->add(dlg);
448 dlg.exec(); 446 dlg.exec();
449 } 447 }
450} 448}
451 449
452 450
453void MainWindow::slotOpenKeb(bool state) { 451void MainWindow::slotOpenKeb(bool state) {
454 452
455 if (state) m_keyBar->show(); 453 if (state) m_keyBar->show();
456 else m_keyBar->hide(); 454 else m_keyBar->hide();
457 455
458} 456}
459 457
460 458
461void MainWindow::slotOpenButtons( bool state ) { 459void MainWindow::slotOpenButtons( bool state ) {
462 460
463 if ( state ) { 461 if ( state ) {
464 m_buttonBar->show(); 462 m_buttonBar->show();
465 } else { 463 } else {
466 m_buttonBar->hide(); 464 m_buttonBar->hide();
467 } 465 }
468} 466}
469 467
470 468
471 469
472void MainWindow::slotSessionChanged( Session* ses ) { 470void MainWindow::slotSessionChanged( Session* ses ) {
473 qWarning("changed!"); 471 qWarning("changed!");
474 if ( ses ) { 472 if ( ses ) {
475 m_curSession = ses; 473 m_curSession = ses;
476 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); 474 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) );
477 if ( m_curSession->layer()->isConnected() ) { 475 if ( m_curSession->layer()->isConnected() ) {
478 m_connect->setEnabled( false ); 476 m_connect->setEnabled( false );
479 m_disconnect->setEnabled( true ); 477 m_disconnect->setEnabled( true );
480 } else { 478 } else {
481 m_connect->setEnabled( true ); 479 m_connect->setEnabled( true );
482 m_disconnect->setEnabled( false ); 480 m_disconnect->setEnabled( false );
483 } 481 }
484 } 482 }
485} 483}
486 484
487void MainWindow::slotFullscreen() { 485void MainWindow::slotFullscreen() {
488 486
487
488
489 if ( m_isFullscreen ) { 489 if ( m_isFullscreen ) {
490 ( m_curSession->widgetStack() )->reparent( m_consoleWindow, 0, QPoint(0,0), false ); 490 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), false );
491 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 491 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken );
492
492 setCentralWidget( m_consoleWindow ); 493 setCentralWidget( m_consoleWindow );
493 ( m_curSession->widgetStack() )->show(); 494 ( m_curSession->widgetStack() )->show();
494 ( m_curSession->emulationHandler() )->cornerButton()->hide(); 495 ( m_curSession->emulationHandler() )->cornerButton()->hide();
495 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 496 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
496 497
497 } else { 498 } else {
499 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget();
498 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); 500 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame );
499 ( m_curSession->widgetStack() )->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop 501 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop
500 , QPoint(0,0), false ); 502 , QPoint(0,0), false );
501 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); 503 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() );
502 ( m_curSession->widgetStack() )->setFocus(); 504 ( m_curSession->widgetStack() )->setFocus();
503 ( m_curSession->widgetStack() )->show(); 505 ( m_curSession->widgetStack() )->show();
504 506
505 ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); 507 ( ( m_curSession->emulationHandler() )->cornerButton() )->show();
506 508
507 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 509 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
508 } 510 }
509 511
510 m_isFullscreen = !m_isFullscreen; 512 m_isFullscreen = !m_isFullscreen;
511} 513}
512 514
513 515
514void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool pressed, bool) { 516void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool pressed, bool) {
515 517
516 qWarning("unicode: %x, qkey: %x, %s", u, q, pressed ? "pressed" : "released"); 518 qWarning("unicode: %x, qkey: %x, %s", u, q, pressed ? "pressed" : "released");
517 519
518 if ( m_curSession ) { 520 if ( m_curSession ) {
519 521
520 QEvent::Type state; 522 QEvent::Type state;
521 523
522 if (pressed) state = QEvent::KeyPress; 524 if (pressed) state = QEvent::KeyPress;
523 else state = QEvent::KeyRelease; 525 else state = QEvent::KeyRelease;
524 526
525 QKeyEvent ke(state, q, u, 0, QString(QChar(u))); 527 QKeyEvent ke(state, q, u, 0, QString(QChar(u)));
526 528
527 // where should i send this event? doesnt work sending it here 529 // where should i send this event? doesnt work sending it here
528 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); 530 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke);
529 ke.ignore(); 531 ke.ignore();
530 } 532 }
531} 533}