author | harlekin <harlekin> | 2003-03-21 23:38:17 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-03-21 23:38:17 (UTC) |
commit | ab8cb739c666f5f22049258a4bcbb06d1e1ad0c4 (patch) (unidiff) | |
tree | 82690d415f22ffe554d4fcfe359ee8121b90d888 | |
parent | 43b0fded770624c907aae043e88449f80040d7df (diff) | |
download | opie-ab8cb739c666f5f22049258a4bcbb06d1e1ad0c4.zip opie-ab8cb739c666f5f22049258a4bcbb06d1e1ad0c4.tar.gz opie-ab8cb739c666f5f22049258a4bcbb06d1e1ad0c4.tar.bz2 |
even better then poping up an error dialog: make a new profile
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index a6fc30b..3acbfad 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -317,198 +317,205 @@ void MainWindow::slotNew() { | |||
317 | ProfileEditorDialog dlg(factory() ); | 317 | ProfileEditorDialog dlg(factory() ); |
318 | dlg.showMaximized(); | 318 | dlg.showMaximized(); |
319 | dlg.setCaption( tr("New Connection") ); | 319 | dlg.setCaption( tr("New Connection") ); |
320 | int ret = dlg.exec(); | 320 | int ret = dlg.exec(); |
321 | 321 | ||
322 | if ( ret == QDialog::Accepted ) { | 322 | if ( ret == QDialog::Accepted ) { |
323 | create( dlg.profile() ); | 323 | create( dlg.profile() ); |
324 | } | 324 | } |
325 | } | 325 | } |
326 | 326 | ||
327 | void MainWindow::slotRecordScript() { | 327 | void MainWindow::slotRecordScript() { |
328 | if (currentSession()) { | 328 | if (currentSession()) { |
329 | currentSession()->emulationHandler()->startRecording(); | 329 | currentSession()->emulationHandler()->startRecording(); |
330 | m_saveScript->setEnabled(true); | 330 | m_saveScript->setEnabled(true); |
331 | m_recordScript->setEnabled(false); | 331 | m_recordScript->setEnabled(false); |
332 | } | 332 | } |
333 | } | 333 | } |
334 | 334 | ||
335 | void MainWindow::slotSaveScript() { | 335 | void MainWindow::slotSaveScript() { |
336 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { | 336 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { |
337 | QMap<QString, QStringList> map; | 337 | QMap<QString, QStringList> map; |
338 | QStringList text; | 338 | QStringList text; |
339 | text << "text/plain"; | 339 | text << "text/plain"; |
340 | map.insert(tr("Script"), text ); | 340 | map.insert(tr("Script"), text ); |
341 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | 341 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
342 | if (!filename.isEmpty()) { | 342 | if (!filename.isEmpty()) { |
343 | QFileInfo info(filename); | 343 | QFileInfo info(filename); |
344 | if (info.extension(FALSE) != "script") | 344 | if (info.extension(FALSE) != "script") |
345 | filename += ".script"; | 345 | filename += ".script"; |
346 | DocLnk nf; | 346 | DocLnk nf; |
347 | nf.setType("text/plain"); | 347 | nf.setType("text/plain"); |
348 | nf.setFile(filename); | 348 | nf.setFile(filename); |
349 | nf.setName(info.fileName()); | 349 | nf.setName(info.fileName()); |
350 | FileManager fm; | 350 | FileManager fm; |
351 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); | 351 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); |
352 | currentSession()->emulationHandler()->clearScript(); | 352 | currentSession()->emulationHandler()->clearScript(); |
353 | m_saveScript->setEnabled(false); | 353 | m_saveScript->setEnabled(false); |
354 | m_recordScript->setEnabled(true); | 354 | m_recordScript->setEnabled(true); |
355 | populateScripts(); | 355 | populateScripts(); |
356 | } | 356 | } |
357 | } | 357 | } |
358 | } | 358 | } |
359 | 359 | ||
360 | void MainWindow::slotRunScript(int id) { | 360 | void MainWindow::slotRunScript(int id) { |
361 | if (currentSession()) { | 361 | if (currentSession()) { |
362 | int index = m_scriptsPop->indexOf(id); | 362 | int index = m_scriptsPop->indexOf(id); |
363 | DocLnk *lnk = m_scriptsData.at(index); | 363 | DocLnk *lnk = m_scriptsData.at(index); |
364 | QString filePath = lnk->file(); | 364 | QString filePath = lnk->file(); |
365 | Script script(filePath); | 365 | Script script(filePath); |
366 | currentSession()->emulationHandler()->runScript(&script); | 366 | currentSession()->emulationHandler()->runScript(&script); |
367 | } | 367 | } |
368 | } | 368 | } |
369 | 369 | ||
370 | void MainWindow::slotConnect() { | 370 | void MainWindow::slotConnect() { |
371 | if ( currentSession() ) { | 371 | if ( currentSession() ) { |
372 | bool ret = currentSession()->layer()->open(); | 372 | bool ret = currentSession()->layer()->open(); |
373 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), | 373 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), |
374 | QObject::tr("Failed"), | 374 | QObject::tr("Failed"), |
375 | QObject::tr("Connecting failed for this session.")); | 375 | QObject::tr("Connecting failed for this session.")); |
376 | else { | 376 | else { |
377 | m_connect->setEnabled( false ); | 377 | m_connect->setEnabled( false ); |
378 | m_disconnect->setEnabled( true ); | 378 | m_disconnect->setEnabled( true ); |
379 | 379 | ||
380 | // if it does not support file transfer, disable the menu entry | 380 | // if it does not support file transfer, disable the menu entry |
381 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { | 381 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { |
382 | m_transfer->setEnabled( false ); | 382 | m_transfer->setEnabled( false ); |
383 | } else { | 383 | } else { |
384 | m_transfer->setEnabled( true ); | 384 | m_transfer->setEnabled( true ); |
385 | } | 385 | } |
386 | 386 | ||
387 | m_recordScript->setEnabled( true ); | 387 | m_recordScript->setEnabled( true ); |
388 | m_scripts->setItemEnabled(m_runScript_id, true); | 388 | m_scripts->setItemEnabled(m_runScript_id, true); |
389 | } | 389 | } |
390 | } | 390 | } |
391 | } | 391 | } |
392 | 392 | ||
393 | void MainWindow::slotDisconnect() { | 393 | void MainWindow::slotDisconnect() { |
394 | if ( currentSession() ) { | 394 | if ( currentSession() ) { |
395 | currentSession()->layer()->close(); | 395 | currentSession()->layer()->close(); |
396 | m_connect->setEnabled( true ); | 396 | m_connect->setEnabled( true ); |
397 | m_disconnect->setEnabled( false ); | 397 | m_disconnect->setEnabled( false ); |
398 | m_transfer->setEnabled( false ); | 398 | m_transfer->setEnabled( false ); |
399 | m_recordScript->setEnabled( false); | 399 | m_recordScript->setEnabled( false); |
400 | m_saveScript->setEnabled( false ); | 400 | m_saveScript->setEnabled( false ); |
401 | m_scripts->setItemEnabled(m_runScript_id, false); | 401 | m_scripts->setItemEnabled(m_runScript_id, false); |
402 | } | 402 | } |
403 | } | 403 | } |
404 | 404 | ||
405 | void MainWindow::slotTerminate() { | 405 | void MainWindow::slotTerminate() { |
406 | if ( currentSession() ) | 406 | if ( currentSession() ) |
407 | currentSession()->layer()->close(); | 407 | currentSession()->layer()->close(); |
408 | 408 | ||
409 | slotClose(); | 409 | slotClose(); |
410 | /* FIXME move to the next session */ | 410 | /* FIXME move to the next session */ |
411 | } | 411 | } |
412 | 412 | ||
413 | |||
414 | |||
415 | |||
416 | |||
417 | |||
413 | void MainWindow::slotQuickLaunch() { | 418 | void MainWindow::slotQuickLaunch() { |
414 | Profile prof = manager()->profile( "default" ); | 419 | Profile prof = manager()->profile( "default" ); |
415 | if ( prof.name() == "default" ) { | 420 | if ( prof.name() == "default" ) { |
416 | create( prof ); | 421 | create( prof ); |
417 | } else { | 422 | } else { |
418 | QMessageBox::warning(this, tr("Failure"),tr("please configure one profile named \"default\"")); | 423 | Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 ); |
424 | newProf.setAutoConnect( true ); | ||
425 | create( newProf ); | ||
419 | } | 426 | } |
420 | 427 | ||
421 | } | 428 | } |
422 | 429 | ||
423 | void MainWindow::slotConfigure() { | 430 | void MainWindow::slotConfigure() { |
424 | ConfigDialog conf( manager()->all(), factory() ); | 431 | ConfigDialog conf( manager()->all(), factory() ); |
425 | conf.showMaximized(); | 432 | conf.showMaximized(); |
426 | 433 | ||
427 | int ret = conf.exec(); | 434 | int ret = conf.exec(); |
428 | 435 | ||
429 | if ( QDialog::Accepted == ret ) { | 436 | if ( QDialog::Accepted == ret ) { |
430 | manager()->setProfiles( conf.list() ); | 437 | manager()->setProfiles( conf.list() ); |
431 | manager()->save(); | 438 | manager()->save(); |
432 | populateProfiles(); | 439 | populateProfiles(); |
433 | } | 440 | } |
434 | } | 441 | } |
435 | /* | 442 | /* |
436 | * we will remove | 443 | * we will remove |
437 | * this window from the tabwidget | 444 | * this window from the tabwidget |
438 | * remove it from the list | 445 | * remove it from the list |
439 | * delete it | 446 | * delete it |
440 | * and set the currentSession() | 447 | * and set the currentSession() |
441 | */ | 448 | */ |
442 | void MainWindow::slotClose() { | 449 | void MainWindow::slotClose() { |
443 | if (!currentSession() ) | 450 | if (!currentSession() ) |
444 | return; | 451 | return; |
445 | 452 | ||
446 | Session* ses = currentSession(); | 453 | Session* ses = currentSession(); |
447 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); | 454 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); |
448 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ | 455 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ |
449 | m_curSession = NULL; | 456 | m_curSession = NULL; |
450 | tabWidget()->remove( /*currentSession()*/ses ); | 457 | tabWidget()->remove( /*currentSession()*/ses ); |
451 | /*it's autodelete */ | 458 | /*it's autodelete */ |
452 | m_sessions.remove( ses ); | 459 | m_sessions.remove( ses ); |
453 | qWarning("after remove!!"); | 460 | qWarning("after remove!!"); |
454 | 461 | ||
455 | if (!currentSession() ) { | 462 | if (!currentSession() ) { |
456 | m_connect->setEnabled( false ); | 463 | m_connect->setEnabled( false ); |
457 | m_disconnect->setEnabled( false ); | 464 | m_disconnect->setEnabled( false ); |
458 | m_terminate->setEnabled( false ); | 465 | m_terminate->setEnabled( false ); |
459 | m_transfer->setEnabled( false ); | 466 | m_transfer->setEnabled( false ); |
460 | m_recordScript->setEnabled( false ); | 467 | m_recordScript->setEnabled( false ); |
461 | m_saveScript->setEnabled( false ); | 468 | m_saveScript->setEnabled( false ); |
462 | m_scripts->setItemEnabled(m_runScript_id, false); | 469 | m_scripts->setItemEnabled(m_runScript_id, false); |
463 | m_fullscreen->setEnabled( false ); | 470 | m_fullscreen->setEnabled( false ); |
464 | m_wrap->setEnabled( false ); | 471 | m_wrap->setEnabled( false ); |
465 | m_closewindow->setEnabled( false ); | 472 | m_closewindow->setEnabled( false ); |
466 | } | 473 | } |
467 | 474 | ||
468 | m_kb->loadDefaults(); | 475 | m_kb->loadDefaults(); |
469 | } | 476 | } |
470 | 477 | ||
471 | /* | 478 | /* |
472 | * We will get the name | 479 | * We will get the name |
473 | * Then the profile | 480 | * Then the profile |
474 | * and then we will make a profile | 481 | * and then we will make a profile |
475 | */ | 482 | */ |
476 | void MainWindow::slotProfile( int id) { | 483 | void MainWindow::slotProfile( int id) { |
477 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 484 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
478 | create( prof ); | 485 | create( prof ); |
479 | } | 486 | } |
480 | 487 | ||
481 | 488 | ||
482 | 489 | ||
483 | void MainWindow::create( const Profile& prof ) { | 490 | void MainWindow::create( const Profile& prof ) { |
484 | if(m_curSession) | 491 | if(m_curSession) |
485 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); | 492 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); |
486 | 493 | ||
487 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 494 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
488 | 495 | ||
489 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) | 496 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) |
490 | { | 497 | { |
491 | QMessageBox::warning(this, | 498 | QMessageBox::warning(this, |
492 | QObject::tr("Session failed"), | 499 | QObject::tr("Session failed"), |
493 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); | 500 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); |
494 | //if(ses) delete ses; | 501 | //if(ses) delete ses; |
495 | return; | 502 | return; |
496 | } | 503 | } |
497 | 504 | ||
498 | m_sessions.append( ses ); | 505 | m_sessions.append( ses ); |
499 | tabWidget()->add( ses ); | 506 | tabWidget()->add( ses ); |
500 | tabWidget()->repaint(); | 507 | tabWidget()->repaint(); |
501 | m_curSession = ses; | 508 | m_curSession = ses; |
502 | 509 | ||
503 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it | 510 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it |
504 | m_connect->setEnabled( true ); | 511 | m_connect->setEnabled( true ); |
505 | m_disconnect->setEnabled( false ); | 512 | m_disconnect->setEnabled( false ); |
506 | m_terminate->setEnabled( true ); | 513 | m_terminate->setEnabled( true ); |
507 | m_fullscreen->setEnabled( true ); | 514 | m_fullscreen->setEnabled( true ); |
508 | m_wrap->setEnabled( true ); | 515 | m_wrap->setEnabled( true ); |
509 | m_closewindow->setEnabled( true ); | 516 | m_closewindow->setEnabled( true ); |
510 | m_transfer->setEnabled( false ); | 517 | m_transfer->setEnabled( false ); |
511 | m_recordScript->setEnabled( false ); | 518 | m_recordScript->setEnabled( false ); |
512 | m_saveScript->setEnabled( false ); | 519 | m_saveScript->setEnabled( false ); |
513 | m_scripts->setItemEnabled(m_runScript_id, false); | 520 | m_scripts->setItemEnabled(m_runScript_id, false); |
514 | 521 | ||