summaryrefslogtreecommitdiff
authorjosef <josef>2002-10-26 11:56:08 (UTC)
committer josef <josef>2002-10-26 11:56:08 (UTC)
commit0d58e14f2bcfa2a1f5c9a197d5bb544571824207 (patch) (unidiff)
tree86a60a7b02f5458263982a77d2d05f3b49672ced
parent88504fa6ed3e4ec1c11d3e1cde13c821b1a9b846 (diff)
downloadopie-0d58e14f2bcfa2a1f5c9a197d5bb544571824207.zip
opie-0d58e14f2bcfa2a1f5c9a197d5bb544571824207.tar.gz
opie-0d58e14f2bcfa2a1f5c9a197d5bb544571824207.tar.bz2
- Ah! That's how to use the widget stack
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index e3c3c38..936b1b2 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -207,520 +207,521 @@ void MainWindow::initUI() {
207 /* 207 /*
208 * disconnect action 208 * disconnect action
209 */ 209 */
210 m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), 210 m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"),
211 QString::null, 0, this, 0 ); 211 QString::null, 0, this, 0 );
212 m_disconnect->addTo( m_console ); 212 m_disconnect->addTo( m_console );
213 connect(m_disconnect, SIGNAL(activated() ), 213 connect(m_disconnect, SIGNAL(activated() ),
214 this, SLOT(slotDisconnect() ) ); 214 this, SLOT(slotDisconnect() ) );
215 215
216 m_console->insertSeparator(); 216 m_console->insertSeparator();
217 217
218 m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, 218 m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null,
219 0, this, 0 ); 219 0, this, 0 );
220 m_transfer->addTo( m_console ); 220 m_transfer->addTo( m_console );
221 connect(m_transfer, SIGNAL(activated() ), 221 connect(m_transfer, SIGNAL(activated() ),
222 this, SLOT(slotTransfer() ) ); 222 this, SLOT(slotTransfer() ) );
223 223
224 224
225 /* 225 /*
226 * fullscreen 226 * fullscreen
227 */ 227 */
228 m_isFullscreen = false; 228 m_isFullscreen = false;
229 229
230 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) 230 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" )
231 , QString::null, 0, this, 0); 231 , QString::null, 0, this, 0);
232 m_fullscreen->addTo( m_console ); 232 m_fullscreen->addTo( m_console );
233 connect( m_fullscreen, SIGNAL( activated() ), 233 connect( m_fullscreen, SIGNAL( activated() ),
234 this, SLOT( slotFullscreen() ) ); 234 this, SLOT( slotFullscreen() ) );
235 235
236 m_console->insertSeparator(); 236 m_console->insertSeparator();
237 /* 237 /*
238 * terminate action 238 * terminate action
239 */ 239 */
240 m_terminate = new QAction(); 240 m_terminate = new QAction();
241 m_terminate->setText( tr("Terminate") ); 241 m_terminate->setText( tr("Terminate") );
242 m_terminate->addTo( m_console ); 242 m_terminate->addTo( m_console );
243 connect(m_terminate, SIGNAL(activated() ), 243 connect(m_terminate, SIGNAL(activated() ),
244 this, SLOT(slotTerminate() ) ); 244 this, SLOT(slotTerminate() ) );
245 245
246 m_closewindow = new QAction(); 246 m_closewindow = new QAction();
247 m_closewindow->setText( tr("Close Window") ); 247 m_closewindow->setText( tr("Close Window") );
248 m_closewindow->addTo( m_console ); 248 m_closewindow->addTo( m_console );
249 connect( m_closewindow, SIGNAL(activated() ), 249 connect( m_closewindow, SIGNAL(activated() ),
250 this, SLOT(slotClose() ) ); 250 this, SLOT(slotClose() ) );
251 251
252 252
253 /* 253 /*
254 * script actions 254 * script actions
255 */ 255 */
256 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); 256 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0);
257 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); 257 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int)));
258 258
259 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); 259 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
260 m_recordScript->addTo(m_scripts); 260 m_recordScript->addTo(m_scripts);
261 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); 261 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript()));
262 262
263 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); 263 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0);
264 m_saveScript->addTo(m_scripts); 264 m_saveScript->addTo(m_scripts);
265 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); 265 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript()));
266 266
267 267
268 /* 268 /*
269 * action that open/closes the keyboard 269 * action that open/closes the keyboard
270 */ 270 */
271 m_openKeys = new QAction (tr("Open Keyboard..."), 271 m_openKeys = new QAction (tr("Open Keyboard..."),
272 Resource::loadPixmap( "console/keys/keyboard_icon" ), 272 Resource::loadPixmap( "console/keys/keyboard_icon" ),
273 QString::null, 0, this, 0); 273 QString::null, 0, this, 0);
274 m_openKeys->setToggleAction(true); 274 m_openKeys->setToggleAction(true);
275 connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); 275 connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool)));
276 276
277 /* insert the submenu */ 277 /* insert the submenu */
278 m_console->insertItem(tr("New from Profile"), m_sessionsPop, 278 m_console->insertItem(tr("New from Profile"), m_sessionsPop,
279 -1, 0); 279 -1, 0);
280 280
281 /* insert the connection menu */ 281 /* insert the connection menu */
282 m_bar->insertItem( tr("Connection"), m_console ); 282 m_bar->insertItem( tr("Connection"), m_console );
283 283
284 /* the scripts menu */ 284 /* the scripts menu */
285 m_bar->insertItem( tr("Scripts"), m_scripts ); 285 m_bar->insertItem( tr("Scripts"), m_scripts );
286 286
287 /* and the keyboard */ 287 /* and the keyboard */
288 m_keyBar = new QToolBar(this); 288 m_keyBar = new QToolBar(this);
289 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); 289 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE );
290 m_keyBar->setHorizontalStretchable( TRUE ); 290 m_keyBar->setHorizontalStretchable( TRUE );
291 m_keyBar->hide(); 291 m_keyBar->hide();
292 292
293 m_kb = new FunctionKeyboard(m_keyBar); 293 m_kb = new FunctionKeyboard(m_keyBar);
294 connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), 294 connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)),
295 this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); 295 this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool)));
296 296
297 297
298 QAction *a = new QAction(tr("Copy"), 298 QAction *a = new QAction(tr("Copy"),
299 Resource::loadPixmap("copy"), QString::null, 299 Resource::loadPixmap("copy"), QString::null,
300 0, this, 0 ); 300 0, this, 0 );
301 //a->addTo( m_icons ); 301 //a->addTo( m_icons );
302 connect( a, SIGNAL(activated() ), 302 connect( a, SIGNAL(activated() ),
303 this, SLOT(slotCopy() ) ); 303 this, SLOT(slotCopy() ) );
304 304
305 QAction *paste = new QAction(tr("Paste"), 305 QAction *paste = new QAction(tr("Paste"),
306 Resource::loadPixmap("paste"), QString::null, 306 Resource::loadPixmap("paste"), QString::null,
307 0, this, 0 ); 307 0, this, 0 );
308 connect( paste, SIGNAL(activated() ), 308 connect( paste, SIGNAL(activated() ),
309 this, SLOT(slotPaste() ) ); 309 this, SLOT(slotPaste() ) );
310 310
311 311
312 newCon->addTo( m_icons ); 312 newCon->addTo( m_icons );
313 m_setProfiles->addTo( m_icons ); 313 m_setProfiles->addTo( m_icons );
314 paste->addTo( m_icons ); 314 paste->addTo( m_icons );
315 m_openKeys->addTo(m_icons); 315 m_openKeys->addTo(m_icons);
316 m_fullscreen->addTo( m_icons ); 316 m_fullscreen->addTo( m_icons );
317 317
318 m_connect->setEnabled( false ); 318 m_connect->setEnabled( false );
319 m_disconnect->setEnabled( false ); 319 m_disconnect->setEnabled( false );
320 m_terminate->setEnabled( false ); 320 m_terminate->setEnabled( false );
321 m_transfer->setEnabled( false ); 321 m_transfer->setEnabled( false );
322 m_scripts->setItemEnabled(m_runScript_id, false); 322 m_scripts->setItemEnabled(m_runScript_id, false);
323 m_recordScript->setEnabled( false ); 323 m_recordScript->setEnabled( false );
324 m_saveScript->setEnabled( false ); 324 m_saveScript->setEnabled( false );
325 m_fullscreen->setEnabled( false ); 325 m_fullscreen->setEnabled( false );
326 m_closewindow->setEnabled( false ); 326 m_closewindow->setEnabled( false );
327 327
328 /* 328 /*
329 * connect to the menu activation 329 * connect to the menu activation
330 */ 330 */
331 connect( m_sessionsPop, SIGNAL(activated( int ) ), 331 connect( m_sessionsPop, SIGNAL(activated( int ) ),
332 this, SLOT(slotProfile( int ) ) ); 332 this, SLOT(slotProfile( int ) ) );
333 333
334 m_consoleWindow = new TabWidget( this, "blah"); 334 m_consoleWindow = new TabWidget( this, "blah");
335 connect(m_consoleWindow, SIGNAL(activated(Session*) ), 335 connect(m_consoleWindow, SIGNAL(activated(Session*) ),
336 this, SLOT(slotSessionChanged(Session*) ) ); 336 this, SLOT(slotSessionChanged(Session*) ) );
337 setCentralWidget( m_consoleWindow ); 337 setCentralWidget( m_consoleWindow );
338 338
339} 339}
340 340
341ProfileManager* MainWindow::manager() { 341ProfileManager* MainWindow::manager() {
342 return m_manager; 342 return m_manager;
343} 343}
344TabWidget* MainWindow::tabWidget() { 344TabWidget* MainWindow::tabWidget() {
345 return m_consoleWindow; 345 return m_consoleWindow;
346} 346}
347void MainWindow::populateProfiles() { 347void MainWindow::populateProfiles() {
348 m_sessionsPop->clear(); 348 m_sessionsPop->clear();
349 Profile::ValueList list = manager()->all(); 349 Profile::ValueList list = manager()->all();
350 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { 350 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) {
351 m_sessionsPop->insertItem( (*it).name() ); 351 m_sessionsPop->insertItem( (*it).name() );
352 } 352 }
353 353
354} 354}
355 355
356void MainWindow::populateScripts() { 356void MainWindow::populateScripts() {
357 m_scriptsPop->clear(); 357 m_scriptsPop->clear();
358 m_scriptsData.clear(); 358 m_scriptsData.clear();
359 DocLnkSet files(QPEApplication::documentDir(), "text/plain"); 359 DocLnkSet files(QPEApplication::documentDir(), "text/plain");
360 QListIterator<DocLnk> dit(files.children()); 360 QListIterator<DocLnk> dit(files.children());
361 for (; dit.current(); ++dit) { 361 for (; dit.current(); ++dit) {
362 if (*dit && (*dit)->name().length()>0) { 362 if (*dit && (*dit)->name().length()>0) {
363 QFileInfo info((*dit)->file()); 363 QFileInfo info((*dit)->file());
364 if (info.extension(false) == "script") { 364 if (info.extension(false) == "script") {
365 m_scriptsData.append(new DocLnk(**dit)); 365 m_scriptsData.append(new DocLnk(**dit));
366 m_scriptsPop->insertItem((*dit)->name()); 366 m_scriptsPop->insertItem((*dit)->name());
367 } 367 }
368 } 368 }
369 } 369 }
370 370
371} 371}
372 372
373MainWindow::~MainWindow() { 373MainWindow::~MainWindow() {
374 delete m_factory; 374 delete m_factory;
375 manager()->save(); 375 manager()->save();
376} 376}
377 377
378MetaFactory* MainWindow::factory() { 378MetaFactory* MainWindow::factory() {
379 return m_factory; 379 return m_factory;
380} 380}
381 381
382Session* MainWindow::currentSession() { 382Session* MainWindow::currentSession() {
383 return m_curSession; 383 return m_curSession;
384} 384}
385 385
386QList<Session> MainWindow::sessions() { 386QList<Session> MainWindow::sessions() {
387 return m_sessions; 387 return m_sessions;
388} 388}
389 389
390void MainWindow::slotNew() { 390void MainWindow::slotNew() {
391 ProfileEditorDialog dlg(factory() ); 391 ProfileEditorDialog dlg(factory() );
392 dlg.showMaximized(); 392 dlg.showMaximized();
393 dlg.setCaption( tr("New Connection") ); 393 dlg.setCaption( tr("New Connection") );
394 int ret = dlg.exec(); 394 int ret = dlg.exec();
395 395
396 if ( ret == QDialog::Accepted ) { 396 if ( ret == QDialog::Accepted ) {
397 create( dlg.profile() ); 397 create( dlg.profile() );
398 } 398 }
399} 399}
400 400
401void MainWindow::slotRecordScript() { 401void MainWindow::slotRecordScript() {
402 if (currentSession()) { 402 if (currentSession()) {
403 currentSession()->emulationHandler()->startRecording(); 403 currentSession()->emulationHandler()->startRecording();
404 m_saveScript->setEnabled(true); 404 m_saveScript->setEnabled(true);
405 m_recordScript->setEnabled(false); 405 m_recordScript->setEnabled(false);
406 } 406 }
407} 407}
408 408
409void MainWindow::slotSaveScript() { 409void MainWindow::slotSaveScript() {
410 if (currentSession() && currentSession()->emulationHandler()->isRecording()) { 410 if (currentSession() && currentSession()->emulationHandler()->isRecording()) {
411 QMap<QString, QStringList> map; 411 QMap<QString, QStringList> map;
412 QStringList text; 412 QStringList text;
413 text << "text/plain"; 413 text << "text/plain";
414 map.insert(tr("Script"), text ); 414 map.insert(tr("Script"), text );
415 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); 415 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
416 if (!filename.isEmpty()) { 416 if (!filename.isEmpty()) {
417 QFileInfo info(filename); 417 QFileInfo info(filename);
418 if (info.extension(FALSE) != "script") 418 if (info.extension(FALSE) != "script")
419 filename += ".script"; 419 filename += ".script";
420 DocLnk nf; 420 DocLnk nf;
421 nf.setType("text/plain"); 421 nf.setType("text/plain");
422 nf.setFile(filename); 422 nf.setFile(filename);
423 nf.setName(info.fileName()); 423 nf.setName(info.fileName());
424 FileManager fm; 424 FileManager fm;
425 fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); 425 fm.saveFile(nf, currentSession()->emulationHandler()->script()->script());
426 currentSession()->emulationHandler()->clearScript(); 426 currentSession()->emulationHandler()->clearScript();
427 m_saveScript->setEnabled(false); 427 m_saveScript->setEnabled(false);
428 m_recordScript->setEnabled(true); 428 m_recordScript->setEnabled(true);
429 populateScripts(); 429 populateScripts();
430 } 430 }
431 } 431 }
432} 432}
433 433
434void MainWindow::slotRunScript(int id) { 434void MainWindow::slotRunScript(int id) {
435 if (currentSession()) { 435 if (currentSession()) {
436 int index = m_scriptsPop->indexOf(id); 436 int index = m_scriptsPop->indexOf(id);
437 DocLnk *lnk = m_scriptsData.at(index); 437 DocLnk *lnk = m_scriptsData.at(index);
438 QString filePath = lnk->file(); 438 QString filePath = lnk->file();
439 Script script(filePath); 439 Script script(filePath);
440 currentSession()->emulationHandler()->runScript(&script); 440 currentSession()->emulationHandler()->runScript(&script);
441 } 441 }
442} 442}
443 443
444void MainWindow::slotConnect() { 444void MainWindow::slotConnect() {
445 if ( currentSession() ) { 445 if ( currentSession() ) {
446 bool ret = currentSession()->layer()->open(); 446 bool ret = currentSession()->layer()->open();
447 if(!ret) QMessageBox::warning(currentSession()->widgetStack(), 447 if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
448 QObject::tr("Failed"), 448 QObject::tr("Failed"),
449 QObject::tr("Connecting failed for this session.")); 449 QObject::tr("Connecting failed for this session."));
450 else { 450 else {
451 m_connect->setEnabled( false ); 451 m_connect->setEnabled( false );
452 m_disconnect->setEnabled( true ); 452 m_disconnect->setEnabled( true );
453 453
454 // if it does not support file transfer, disable the menu entry 454 // if it does not support file transfer, disable the menu entry
455 if ( ( m_curSession->layer() )->supports()[1] == 0 ) { 455 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
456 m_transfer->setEnabled( false ); 456 m_transfer->setEnabled( false );
457 } else { 457 } else {
458 m_transfer->setEnabled( true ); 458 m_transfer->setEnabled( true );
459 } 459 }
460 460
461 m_recordScript->setEnabled( true ); 461 m_recordScript->setEnabled( true );
462 m_scripts->setItemEnabled(m_runScript_id, true); 462 m_scripts->setItemEnabled(m_runScript_id, true);
463 } 463 }
464 } 464 }
465} 465}
466 466
467void MainWindow::slotDisconnect() { 467void MainWindow::slotDisconnect() {
468 if ( currentSession() ) { 468 if ( currentSession() ) {
469 currentSession()->layer()->close(); 469 currentSession()->layer()->close();
470 m_connect->setEnabled( true ); 470 m_connect->setEnabled( true );
471 m_disconnect->setEnabled( false ); 471 m_disconnect->setEnabled( false );
472 m_transfer->setEnabled( false ); 472 m_transfer->setEnabled( false );
473 m_recordScript->setEnabled( false); 473 m_recordScript->setEnabled( false);
474 m_saveScript->setEnabled( false ); 474 m_saveScript->setEnabled( false );
475 m_scripts->setItemEnabled(m_runScript_id, false); 475 m_scripts->setItemEnabled(m_runScript_id, false);
476 } 476 }
477} 477}
478 478
479void MainWindow::slotTerminate() { 479void MainWindow::slotTerminate() {
480 if ( currentSession() ) 480 if ( currentSession() )
481 currentSession()->layer()->close(); 481 currentSession()->layer()->close();
482 482
483 slotClose(); 483 slotClose();
484 /* FIXME move to the next session */ 484 /* FIXME move to the next session */
485} 485}
486 486
487void MainWindow::slotConfigure() { 487void MainWindow::slotConfigure() {
488 ConfigDialog conf( manager()->all(), factory() ); 488 ConfigDialog conf( manager()->all(), factory() );
489 conf.showMaximized(); 489 conf.showMaximized();
490 490
491 int ret = conf.exec(); 491 int ret = conf.exec();
492 492
493 if ( QDialog::Accepted == ret ) { 493 if ( QDialog::Accepted == ret ) {
494 manager()->setProfiles( conf.list() ); 494 manager()->setProfiles( conf.list() );
495 manager()->save(); 495 manager()->save();
496 populateProfiles(); 496 populateProfiles();
497 } 497 }
498} 498}
499/* 499/*
500 * we will remove 500 * we will remove
501 * this window from the tabwidget 501 * this window from the tabwidget
502 * remove it from the list 502 * remove it from the list
503 * delete it 503 * delete it
504 * and set the currentSession() 504 * and set the currentSession()
505 */ 505 */
506void MainWindow::slotClose() { 506void MainWindow::slotClose() {
507 if (!currentSession() ) 507 if (!currentSession() )
508 return; 508 return;
509 509
510 Session* ses = currentSession(); 510 Session* ses = currentSession();
511 qWarning("removing! currentSession %s", currentSession()->name().latin1() ); 511 qWarning("removing! currentSession %s", currentSession()->name().latin1() );
512 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ 512 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */
513 m_curSession = NULL; 513 m_curSession = NULL;
514 tabWidget()->remove( /*currentSession()*/ses ); 514 tabWidget()->remove( /*currentSession()*/ses );
515 /*it's autodelete */ 515 /*it's autodelete */
516 m_sessions.remove( ses ); 516 m_sessions.remove( ses );
517 qWarning("after remove!!"); 517 qWarning("after remove!!");
518 518
519 if (!currentSession() ) { 519 if (!currentSession() ) {
520 m_connect->setEnabled( false ); 520 m_connect->setEnabled( false );
521 m_disconnect->setEnabled( false ); 521 m_disconnect->setEnabled( false );
522 m_terminate->setEnabled( false ); 522 m_terminate->setEnabled( false );
523 m_transfer->setEnabled( false ); 523 m_transfer->setEnabled( false );
524 m_recordScript->setEnabled( false ); 524 m_recordScript->setEnabled( false );
525 m_saveScript->setEnabled( false ); 525 m_saveScript->setEnabled( false );
526 m_scripts->setItemEnabled(m_runScript_id, false); 526 m_scripts->setItemEnabled(m_runScript_id, false);
527 m_fullscreen->setEnabled( false ); 527 m_fullscreen->setEnabled( false );
528 m_closewindow->setEnabled( false ); 528 m_closewindow->setEnabled( false );
529 } 529 }
530 530
531 m_kb->loadDefaults(); 531 m_kb->loadDefaults();
532} 532}
533 533
534/* 534/*
535 * We will get the name 535 * We will get the name
536 * Then the profile 536 * Then the profile
537 * and then we will make a profile 537 * and then we will make a profile
538 */ 538 */
539void MainWindow::slotProfile( int id) { 539void MainWindow::slotProfile( int id) {
540 Profile prof = manager()->profile( m_sessionsPop->text( id) ); 540 Profile prof = manager()->profile( m_sessionsPop->text( id) );
541 create( prof ); 541 create( prof );
542} 542}
543void MainWindow::create( const Profile& prof ) { 543void MainWindow::create( const Profile& prof ) {
544 if(m_curSession) 544 if(m_curSession)
545 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); 545 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
546 546
547 Session *ses = manager()->fromProfile( prof, tabWidget() ); 547 Session *ses = manager()->fromProfile( prof, tabWidget() );
548 548
549 if((!ses) || (!ses->layer()) || (!ses->widgetStack())) 549 if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
550 { 550 {
551 QMessageBox::warning(this, 551 QMessageBox::warning(this,
552 QObject::tr("Session failed"), 552 QObject::tr("Session failed"),
553 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); 553 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>"));
554 //if(ses) delete ses; 554 //if(ses) delete ses;
555 return; 555 return;
556 } 556 }
557 557
558 m_sessions.append( ses ); 558 m_sessions.append( ses );
559 tabWidget()->add( ses ); 559 tabWidget()->add( ses );
560 tabWidget()->repaint(); 560 tabWidget()->repaint();
561 m_curSession = ses; 561 m_curSession = ses;
562 562
563 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it 563 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it
564 m_connect->setEnabled( true ); 564 m_connect->setEnabled( true );
565 m_disconnect->setEnabled( false ); 565 m_disconnect->setEnabled( false );
566 m_terminate->setEnabled( true ); 566 m_terminate->setEnabled( true );
567 m_fullscreen->setEnabled( true ); 567 m_fullscreen->setEnabled( true );
568 m_closewindow->setEnabled( true ); 568 m_closewindow->setEnabled( true );
569 m_transfer->setEnabled( false ); 569 m_transfer->setEnabled( false );
570 m_recordScript->setEnabled( false ); 570 m_recordScript->setEnabled( false );
571 m_saveScript->setEnabled( false ); 571 m_saveScript->setEnabled( false );
572 m_scripts->setItemEnabled(m_runScript_id, false); 572 m_scripts->setItemEnabled(m_runScript_id, false);
573 573
574 // is io_layer wants direct connection, then autoconnect 574 // is io_layer wants direct connection, then autoconnect
575 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { 575 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) {
576 if (prof.autoConnect()) { 576 if (prof.autoConnect()) {
577 slotConnect(); 577 slotConnect();
578 } 578 }
579 579
580 580
581 QWidget *w = currentSession()->widget(); 581 QWidget *w = currentSession()->widget();
582 if(w) w->setFocus(); 582 if(w) w->setFocus();
583 583
584 m_kb->load(currentSession()->profile()); 584 m_kb->load(currentSession()->profile());
585} 585}
586 586
587void MainWindow::slotTransfer() 587void MainWindow::slotTransfer()
588{ 588{
589 if ( currentSession() ) { 589 if ( currentSession() ) {
590 Session *mysession = currentSession(); 590 Session *mysession = currentSession();
591 TransferDialog dlg(mysession->widgetStack(), this); 591 TransferDialog dlg(/*mysession->widgetStack()*/this, this);
592 mysession->setTransferDialog(&dlg); 592 mysession->setTransferDialog(&dlg);
593 dlg.show(); 593 //dlg.reparent(mysession->widgetStack(), QPoint(0, 0));
594 //dlg.showMaximized(); 594 //dlg.showMaximized();
595 //currentSession()->widgetStack()->add(dlg); 595 currentSession()->widgetStack()->addWidget(&dlg, -1);
596 dlg.show();
596 //dlg.exec(); 597 //dlg.exec();
597 while(dlg.isRunning()) qApp->processEvents(); 598 while(dlg.isRunning()) qApp->processEvents();
598 mysession->setTransferDialog(0l); 599 mysession->setTransferDialog(0l);
599 } 600 }
600} 601}
601 602
602 603
603void MainWindow::slotOpenKeb(bool state) { 604void MainWindow::slotOpenKeb(bool state) {
604 605
605 if (state) m_keyBar->show(); 606 if (state) m_keyBar->show();
606 else m_keyBar->hide(); 607 else m_keyBar->hide();
607 608
608} 609}
609 610
610 611
611void MainWindow::slotOpenButtons( bool state ) { 612void MainWindow::slotOpenButtons( bool state ) {
612 613
613 if ( state ) { 614 if ( state ) {
614 m_buttonBar->show(); 615 m_buttonBar->show();
615 } else { 616 } else {
616 m_buttonBar->hide(); 617 m_buttonBar->hide();
617 } 618 }
618} 619}
619 620
620 621
621 622
622void MainWindow::slotSessionChanged( Session* ses ) { 623void MainWindow::slotSessionChanged( Session* ses ) {
623 qWarning("changed!"); 624 qWarning("changed!");
624 625
625 if(m_curSession) 626 if(m_curSession)
626 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); 627 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
627 if(ses) 628 if(ses)
628 if(ses->transferDialog()) ses->transferDialog()->show(); 629 if(ses->transferDialog()) ses->transferDialog()->show();
629 630
630 if ( ses ) { 631 if ( ses ) {
631 m_curSession = ses; 632 m_curSession = ses;
632 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); 633 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) );
633 if ( m_curSession->layer()->isConnected() ) { 634 if ( m_curSession->layer()->isConnected() ) {
634 m_connect->setEnabled( false ); 635 m_connect->setEnabled( false );
635 m_disconnect->setEnabled( true ); 636 m_disconnect->setEnabled( true );
636 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); 637 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording());
637 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); 638 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording());
638 m_scripts->setItemEnabled(m_runScript_id, true); 639 m_scripts->setItemEnabled(m_runScript_id, true);
639 } else { 640 } else {
640 m_connect->setEnabled( true ); 641 m_connect->setEnabled( true );
641 m_disconnect->setEnabled( false ); 642 m_disconnect->setEnabled( false );
642 m_recordScript->setEnabled( false ); 643 m_recordScript->setEnabled( false );
643 m_saveScript->setEnabled( false ); 644 m_saveScript->setEnabled( false );
644 m_scripts->setItemEnabled(m_runScript_id, false); 645 m_scripts->setItemEnabled(m_runScript_id, false);
645 } 646 }
646 647
647 if ( ( m_curSession->layer() )->supports()[1] == 0 ) { 648 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
648 m_transfer->setEnabled( false ); 649 m_transfer->setEnabled( false );
649 } else { 650 } else {
650 m_transfer->setEnabled( true ); 651 m_transfer->setEnabled( true );
651 } 652 }
652 653
653 QWidget *w = m_curSession->widget(); 654 QWidget *w = m_curSession->widget();
654 if(w) w->setFocus(); 655 if(w) w->setFocus();
655 656
656 m_kb->load(currentSession()->profile()); 657 m_kb->load(currentSession()->profile());
657 } 658 }
658} 659}
659 660
660void MainWindow::slotFullscreen() { 661void MainWindow::slotFullscreen() {
661 662
662 663
663 664
664 if ( m_isFullscreen ) { 665 if ( m_isFullscreen ) {
665 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); 666 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true );
666 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); 667 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() );
667 ( m_curSession->emulationHandler() )->cornerButton()->hide(); 668 ( m_curSession->emulationHandler() )->cornerButton()->hide();
668 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 669 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
669 670
670 } else { 671 } else {
671 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); 672 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget();
672 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); 673 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame );
673 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop 674 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop
674 , QPoint(0,0), false ); 675 , QPoint(0,0), false );
675 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); 676 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() );
676 ( m_curSession->widgetStack() )->setFocus(); 677 ( m_curSession->widgetStack() )->setFocus();
677 ( m_curSession->widgetStack() )->show(); 678 ( m_curSession->widgetStack() )->show();
678 679
679 ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); 680 ( ( m_curSession->emulationHandler() )->cornerButton() )->show();
680 681
681 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 682 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
682 } 683 }
683 684
684 m_isFullscreen = !m_isFullscreen; 685 m_isFullscreen = !m_isFullscreen;
685} 686}
686 687
687 688
688void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { 689void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) {
689 690
690 if ( m_curSession ) { 691 if ( m_curSession ) {
691 692
692 QEvent::Type state; 693 QEvent::Type state;
693 694
694 if (pressed) state = QEvent::KeyPress; 695 if (pressed) state = QEvent::KeyPress;
695 else state = QEvent::KeyRelease; 696 else state = QEvent::KeyRelease;
696 697
697 QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); 698 QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode)));
698 699
699 // is this the best way to do this? cant figure out any other way to work 700 // is this the best way to do this? cant figure out any other way to work
700 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); 701 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke);
701 ke.ignore(); 702 ke.ignore();
702 } 703 }
703} 704}
704void MainWindow::slotCopy() { 705void MainWindow::slotCopy() {
705 if (!currentSession() ) return; 706 if (!currentSession() ) return;
706 currentSession()->emulationHandler()->copy(); 707 currentSession()->emulationHandler()->copy();
707} 708}
708void MainWindow::slotPaste() { 709void MainWindow::slotPaste() {
709 if (!currentSession() ) return; 710 if (!currentSession() ) return;
710 currentSession()->emulationHandler()->paste(); 711 currentSession()->emulationHandler()->paste();
711} 712}
712 713
713/* 714/*
714 * Save the session 715 * Save the session
715 */ 716 */
716 717
717void MainWindow::slotSaveSession() { 718void MainWindow::slotSaveSession() {
718 if (!currentSession() ) { 719 if (!currentSession() ) {
719 QMessageBox::information(this, tr("Save Connection"), 720 QMessageBox::information(this, tr("Save Connection"),
720 tr("<qt>There is no Connection.</qt>"), 1 ); 721 tr("<qt>There is no Connection.</qt>"), 1 );
721 return; 722 return;
722 } 723 }
723 manager()->add( currentSession()->profile() ); 724 manager()->add( currentSession()->profile() );
724 manager()->save(); 725 manager()->save();
725 populateProfiles(); 726 populateProfiles();
726} 727}