Diffstat (limited to 'noncore/apps/opie-console/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 197f799..06a8f7d 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -3,48 +3,49 @@ | |||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qmenubar.h> | 4 | #include <qmenubar.h> |
5 | #include <qtoolbar.h> | 5 | #include <qtoolbar.h> |
6 | #include <qmessagebox.h> | 6 | #include <qmessagebox.h> |
7 | #include <qwhatsthis.h> | 7 | #include <qwhatsthis.h> |
8 | #include <qfileinfo.h> | 8 | #include <qfileinfo.h> |
9 | 9 | ||
10 | #include <qpe/filemanager.h> | 10 | #include <qpe/filemanager.h> |
11 | 11 | ||
12 | #include <opie2/ofiledialog.h> | 12 | #include <opie2/ofiledialog.h> |
13 | 13 | ||
14 | #include "TEmulation.h" | 14 | #include "TEmulation.h" |
15 | #include "profileeditordialog.h" | 15 | #include "profileeditordialog.h" |
16 | #include "configdialog.h" | 16 | #include "configdialog.h" |
17 | #include "default.h" | 17 | #include "default.h" |
18 | #include "profilemanager.h" | 18 | #include "profilemanager.h" |
19 | #include "mainwindow.h" | 19 | #include "mainwindow.h" |
20 | #include "tabwidget.h" | 20 | #include "tabwidget.h" |
21 | #include "transferdialog.h" | 21 | #include "transferdialog.h" |
22 | #include "function_keyboard.h" | 22 | #include "function_keyboard.h" |
23 | #include "emulation_handler.h" | 23 | #include "emulation_handler.h" |
24 | #include "script.h" | 24 | #include "script.h" |
25 | 25 | ||
26 | 26 | ||
27 | using namespace Opie::Ui; | ||
27 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { | 28 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { |
28 | KeyTrans::loadAll(); | 29 | KeyTrans::loadAll(); |
29 | for (int i = 0; i < KeyTrans::count(); i++ ) { | 30 | for (int i = 0; i < KeyTrans::count(); i++ ) { |
30 | KeyTrans* s = KeyTrans::find(i ); | 31 | KeyTrans* s = KeyTrans::find(i ); |
31 | assert( s ); | 32 | assert( s ); |
32 | } | 33 | } |
33 | m_factory = new MetaFactory(); | 34 | m_factory = new MetaFactory(); |
34 | Default def(m_factory); | 35 | Default def(m_factory); |
35 | m_sessions.setAutoDelete( TRUE ); | 36 | m_sessions.setAutoDelete( TRUE ); |
36 | m_curSession = 0; | 37 | m_curSession = 0; |
37 | m_manager = new ProfileManager( m_factory ); | 38 | m_manager = new ProfileManager( m_factory ); |
38 | m_manager->load(); | 39 | m_manager->load(); |
39 | m_scriptsData.setAutoDelete(TRUE); | 40 | m_scriptsData.setAutoDelete(TRUE); |
40 | 41 | ||
41 | initUI(); | 42 | initUI(); |
42 | populateProfiles(); | 43 | populateProfiles(); |
43 | populateScripts(); | 44 | populateScripts(); |
44 | } | 45 | } |
45 | 46 | ||
46 | void MainWindow::initUI() { | 47 | void MainWindow::initUI() { |
47 | 48 | ||
48 | setToolBarsMovable( FALSE ); | 49 | setToolBarsMovable( FALSE ); |
49 | 50 | ||
50 | /* tool bar for the menu */ | 51 | /* tool bar for the menu */ |
@@ -311,49 +312,49 @@ QList<Session> MainWindow::sessions() { | |||
311 | void MainWindow::slotNew() { | 312 | void MainWindow::slotNew() { |
312 | ProfileEditorDialog dlg(factory() ); | 313 | ProfileEditorDialog dlg(factory() ); |
313 | dlg.setCaption( tr("New Connection") ); | 314 | dlg.setCaption( tr("New Connection") ); |
314 | int ret = QPEApplication::execDialog( &dlg ); | 315 | int ret = QPEApplication::execDialog( &dlg ); |
315 | 316 | ||
316 | if ( ret == QDialog::Accepted ) { | 317 | if ( ret == QDialog::Accepted ) { |
317 | create( dlg.profile() ); | 318 | create( dlg.profile() ); |
318 | } | 319 | } |
319 | } | 320 | } |
320 | 321 | ||
321 | void MainWindow::slotRecordScript() { | 322 | void MainWindow::slotRecordScript() { |
322 | if (currentSession()) { | 323 | if (currentSession()) { |
323 | currentSession()->emulationHandler()->startRecording(); | 324 | currentSession()->emulationHandler()->startRecording(); |
324 | m_saveScript->setEnabled(true); | 325 | m_saveScript->setEnabled(true); |
325 | m_recordScript->setEnabled(false); | 326 | m_recordScript->setEnabled(false); |
326 | } | 327 | } |
327 | } | 328 | } |
328 | 329 | ||
329 | void MainWindow::slotSaveScript() { | 330 | void MainWindow::slotSaveScript() { |
330 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { | 331 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { |
331 | QMap<QString, QStringList> map; | 332 | QMap<QString, QStringList> map; |
332 | QStringList text; | 333 | QStringList text; |
333 | text << "text/plain"; | 334 | text << "text/plain"; |
334 | map.insert(tr("Script"), text ); | 335 | map.insert(tr("Script"), text ); |
335 | QString filename = Opie::OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | 336 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
336 | if (!filename.isEmpty()) { | 337 | if (!filename.isEmpty()) { |
337 | QFileInfo info(filename); | 338 | QFileInfo info(filename); |
338 | if (info.extension(FALSE) != "script") | 339 | if (info.extension(FALSE) != "script") |
339 | filename += ".script"; | 340 | filename += ".script"; |
340 | DocLnk nf; | 341 | DocLnk nf; |
341 | nf.setType("text/plain"); | 342 | nf.setType("text/plain"); |
342 | nf.setFile(filename); | 343 | nf.setFile(filename); |
343 | nf.setName(info.fileName()); | 344 | nf.setName(info.fileName()); |
344 | FileManager fm; | 345 | FileManager fm; |
345 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); | 346 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); |
346 | currentSession()->emulationHandler()->clearScript(); | 347 | currentSession()->emulationHandler()->clearScript(); |
347 | m_saveScript->setEnabled(false); | 348 | m_saveScript->setEnabled(false); |
348 | m_recordScript->setEnabled(true); | 349 | m_recordScript->setEnabled(true); |
349 | populateScripts(); | 350 | populateScripts(); |
350 | } | 351 | } |
351 | } | 352 | } |
352 | } | 353 | } |
353 | 354 | ||
354 | void MainWindow::slotRunScript(int id) { | 355 | void MainWindow::slotRunScript(int id) { |
355 | if (currentSession()) { | 356 | if (currentSession()) { |
356 | int index = m_scriptsPop->indexOf(id); | 357 | int index = m_scriptsPop->indexOf(id); |
357 | DocLnk *lnk = m_scriptsData.at(index); | 358 | DocLnk *lnk = m_scriptsData.at(index); |
358 | QString filePath = lnk->file(); | 359 | QString filePath = lnk->file(); |
359 | Script script(filePath); | 360 | Script script(filePath); |
@@ -684,44 +685,44 @@ void MainWindow::slotCopy() { | |||
684 | void MainWindow::slotPaste() { | 685 | void MainWindow::slotPaste() { |
685 | if (!currentSession() ) return; | 686 | if (!currentSession() ) return; |
686 | currentSession()->emulationHandler()->paste(); | 687 | currentSession()->emulationHandler()->paste(); |
687 | } | 688 | } |
688 | 689 | ||
689 | /* | 690 | /* |
690 | * Save the session | 691 | * Save the session |
691 | */ | 692 | */ |
692 | 693 | ||
693 | void MainWindow::slotSaveSession() { | 694 | void MainWindow::slotSaveSession() { |
694 | if (!currentSession() ) { | 695 | if (!currentSession() ) { |
695 | QMessageBox::information(this, tr("Save Connection"), | 696 | QMessageBox::information(this, tr("Save Connection"), |
696 | tr("<qt>There is no Connection.</qt>"), 1 ); | 697 | tr("<qt>There is no Connection.</qt>"), 1 ); |
697 | return; | 698 | return; |
698 | } | 699 | } |
699 | manager()->add( currentSession()->profile() ); | 700 | manager()->add( currentSession()->profile() ); |
700 | manager()->save(); | 701 | manager()->save(); |
701 | populateProfiles(); | 702 | populateProfiles(); |
702 | } | 703 | } |
703 | void MainWindow::slotSaveHistory() { | 704 | void MainWindow::slotSaveHistory() { |
704 | QMap<QString, QStringList> map; | 705 | QMap<QString, QStringList> map; |
705 | QStringList text; | 706 | QStringList text; |
706 | text << "text/plain"; | 707 | text << "text/plain"; |
707 | map.insert(tr("History"), text ); | 708 | map.insert(tr("History"), text ); |
708 | QString filename = Opie::OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | 709 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
709 | if (filename.isEmpty() ) return; | 710 | if (filename.isEmpty() ) return; |
710 | 711 | ||
711 | QFileInfo info(filename); | 712 | QFileInfo info(filename); |
712 | 713 | ||
713 | DocLnk nf; | 714 | DocLnk nf; |
714 | nf.setType("text/plain"); | 715 | nf.setType("text/plain"); |
715 | nf.setFile(filename); | 716 | nf.setFile(filename); |
716 | nf.setName(info.fileName()); | 717 | nf.setName(info.fileName()); |
717 | 718 | ||
718 | 719 | ||
719 | QFile file(filename); | 720 | QFile file(filename); |
720 | file.open(IO_WriteOnly ); | 721 | file.open(IO_WriteOnly ); |
721 | QTextStream str(&file ); | 722 | QTextStream str(&file ); |
722 | if ( currentSession() ) | 723 | if ( currentSession() ) |
723 | currentSession()->emulationHandler()->emulation()->streamHistory(&str); | 724 | currentSession()->emulationHandler()->emulation()->streamHistory(&str); |
724 | 725 | ||
725 | file.close(); | 726 | file.close(); |
726 | nf.writeLink(); | 727 | nf.writeLink(); |
727 | } | 728 | } |