summaryrefslogtreecommitdiff
authorharlekin <harlekin>2005-01-11 16:03:50 (UTC)
committer harlekin <harlekin>2005-01-11 16:03:50 (UTC)
commit1833a9079cd7801f333ac3885b447520e44f937f (patch) (unidiff)
tree4ba1b030a3747b1f22d08a9f0ea55bfb59940761
parent4c4cdd76caea5a8be4a971892375c7c6b4f4a8b9 (diff)
downloadopie-1833a9079cd7801f333ac3885b447520e44f937f.zip
opie-1833a9079cd7801f333ac3885b447520e44f937f.tar.gz
opie-1833a9079cd7801f333ac3885b447520e44f937f.tar.bz2
possibility to set a default path for the save log dialog and also set the initial path into the titelbar
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 9b615f1..21de5c0 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,96 +1,94 @@
1#include "TEmulation.h" 1#include "TEmulation.h"
2#include "profileeditordialog.h" 2#include "profileeditordialog.h"
3#include "configdialog.h" 3#include "configdialog.h"
4#include "default.h" 4#include "default.h"
5#include "profilemanager.h" 5#include "profilemanager.h"
6#include "mainwindow.h" 6#include "mainwindow.h"
7#include "tabwidget.h" 7#include "tabwidget.h"
8#include "transferdialog.h" 8#include "transferdialog.h"
9#include "function_keyboard.h" 9#include "function_keyboard.h"
10#include "emulation_handler.h" 10#include "emulation_handler.h"
11#include "script.h" 11#include "script.h"
12#include "fixit.h" 12#include "fixit.h"
13 13
14/* OPIE */ 14/* OPIE */
15#include <opie2/ofiledialog.h> 15#include <opie2/ofiledialog.h>
16#include <qpe/filemanager.h> 16#include <qpe/filemanager.h>
17using namespace Opie::Ui; 17using namespace Opie::Ui;
18 18
19/* QT */ 19/* QT */
20#include <qaction.h> 20#include <qaction.h>
21#include <qmenubar.h> 21#include <qmenubar.h>
22#include <qtoolbar.h> 22#include <qtoolbar.h>
23#include <qmessagebox.h> 23#include <qmessagebox.h>
24#include <qwhatsthis.h> 24#include <qwhatsthis.h>
25#include <qfileinfo.h> 25#include <qfileinfo.h>
26 26
27/* STD */ 27/* STD */
28#include <assert.h> 28#include <assert.h>
29 29
30#ifdef EAST
31#include <opie2/oconfig.h> 30#include <opie2/oconfig.h>
32#endif
33 31
34MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { 32MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) {
35 33
36#ifdef FSCKED_DISTRI 34#ifdef FSCKED_DISTRI
37 FixIt fix; 35 FixIt fix;
38 fix.fixIt(); 36 fix.fixIt();
39#endif 37#endif
40 38
41 setCaption(QObject::tr("Opie Console") ); 39 setCaption(QObject::tr("Opie Console") );
42 KeyTrans::loadAll(); 40 KeyTrans::loadAll();
43 for (int i = 0; i < KeyTrans::count(); i++ ) { 41 for (int i = 0; i < KeyTrans::count(); i++ ) {
44 KeyTrans* s = KeyTrans::find(i ); 42 KeyTrans* s = KeyTrans::find(i );
45 assert( s ); 43 assert( s );
46 } 44 }
47 m_factory = new MetaFactory(); 45 m_factory = new MetaFactory();
48 Default def(m_factory); 46 Default def(m_factory);
49 m_sessions.setAutoDelete( TRUE ); 47 m_sessions.setAutoDelete( TRUE );
50 m_curSession = 0; 48 m_curSession = 0;
51 m_manager = new ProfileManager( m_factory ); 49 m_manager = new ProfileManager( m_factory );
52 m_manager->load(); 50 m_manager->load();
53 m_scriptsData.setAutoDelete(TRUE); 51 m_scriptsData.setAutoDelete(TRUE);
54 52
55 initUI(); 53 initUI();
56 populateProfiles(); 54 populateProfiles();
57 populateScripts(); 55 populateScripts();
58} 56}
59 57
60void MainWindow::initUI() { 58void MainWindow::initUI() {
61 59
62 setToolBarsMovable( FALSE ); 60 setToolBarsMovable( FALSE );
63 61
64 /* tool bar for the menu */ 62 /* tool bar for the menu */
65 m_tool = new QToolBar( this ); 63 m_tool = new QToolBar( this );
66 m_tool->setHorizontalStretchable( TRUE ); 64 m_tool->setHorizontalStretchable( TRUE );
67 65
68 m_bar = new QMenuBar( m_tool ); 66 m_bar = new QMenuBar( m_tool );
69 m_console = new QPopupMenu( this ); 67 m_console = new QPopupMenu( this );
70 m_scripts = new QPopupMenu( this ); 68 m_scripts = new QPopupMenu( this );
71 m_sessionsPop= new QPopupMenu( this ); 69 m_sessionsPop= new QPopupMenu( this );
72 m_scriptsPop = new QPopupMenu( this ); 70 m_scriptsPop = new QPopupMenu( this );
73 71
74 /* add a toolbar for icons */ 72 /* add a toolbar for icons */
75 m_icons = new QToolBar(this); 73 m_icons = new QToolBar(this);
76 74
77 /* 75 /*
78 * the settings action 76 * the settings action
79 */ 77 */
80 m_setProfiles = new QAction(tr("Configure Profiles"), 78 m_setProfiles = new QAction(tr("Configure Profiles"),
81 Resource::loadPixmap( "SettingsIcon" ), 79 Resource::loadPixmap( "SettingsIcon" ),
82 QString::null, 0, this, 0); 80 QString::null, 0, this, 0);
83 m_setProfiles->addTo( m_console ); 81 m_setProfiles->addTo( m_console );
84 connect( m_setProfiles, SIGNAL(activated() ), 82 connect( m_setProfiles, SIGNAL(activated() ),
85 this, SLOT(slotConfigure() ) ); 83 this, SLOT(slotConfigure() ) );
86 84
87 m_console->insertSeparator(); 85 m_console->insertSeparator();
88 /* 86 /*
89 * new Action for new sessions 87 * new Action for new sessions
90 */ 88 */
91 QAction* newCon = new QAction(tr("New Profile"), 89 QAction* newCon = new QAction(tr("New Profile"),
92 Resource::loadPixmap( "new" ), 90 Resource::loadPixmap( "new" ),
93 QString::null, 0, this, 0); 91 QString::null, 0, this, 0);
94 newCon->addTo( m_console ); 92 newCon->addTo( m_console );
95 connect( newCon, SIGNAL(activated() ), 93 connect( newCon, SIGNAL(activated() ),
96 this, SLOT(slotNew() ) ); 94 this, SLOT(slotNew() ) );
@@ -686,98 +684,101 @@ void MainWindow::slotFullscreen() {
686 m_isFullscreen = !m_isFullscreen; 684 m_isFullscreen = !m_isFullscreen;
687} 685}
688 686
689 687
690void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { 688void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) {
691 689
692 if ( m_curSession ) { 690 if ( m_curSession ) {
693 691
694 QEvent::Type state; 692 QEvent::Type state;
695 693
696 if (pressed) state = QEvent::KeyPress; 694 if (pressed) state = QEvent::KeyPress;
697 else state = QEvent::KeyRelease; 695 else state = QEvent::KeyRelease;
698 696
699 QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); 697 QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode)));
700 698
701 // is this the best way to do this? cant figure out any other way to work 699 // is this the best way to do this? cant figure out any other way to work
702 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); 700 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke);
703 ke.ignore(); 701 ke.ignore();
704 } 702 }
705} 703}
706void MainWindow::slotCopy() { 704void MainWindow::slotCopy() {
707 if (!currentSession() ) return; 705 if (!currentSession() ) return;
708 currentSession()->emulationHandler()->copy(); 706 currentSession()->emulationHandler()->copy();
709} 707}
710void MainWindow::slotPaste() { 708void MainWindow::slotPaste() {
711 if (!currentSession() ) return; 709 if (!currentSession() ) return;
712 currentSession()->emulationHandler()->paste(); 710 currentSession()->emulationHandler()->paste();
713} 711}
714 712
715/* 713/*
716 * Save the session 714 * Save the session
717 */ 715 */
718 716
719void MainWindow::slotSaveSession() { 717void MainWindow::slotSaveSession() {
720 if (!currentSession() ) { 718 if (!currentSession() ) {
721 QMessageBox::information(this, tr("Save Connection"), 719 QMessageBox::information(this, tr("Save Connection"),
722 tr("<qt>There is no Connection.</qt>"), 1 ); 720 tr("<qt>There is no Connection.</qt>"), 1 );
723 return; 721 return;
724 } 722 }
725 manager()->add( currentSession()->profile() ); 723 manager()->add( currentSession()->profile() );
726 manager()->save(); 724 manager()->save();
727 populateProfiles(); 725 populateProfiles();
728} 726}
729 727
730 728
731 729
732void MainWindow::slotSaveLog() { 730void MainWindow::slotSaveLog() {
733 731
734 if( currentSession()->emulationHandler()->isLogging() ) { 732 if( currentSession()->emulationHandler()->isLogging() ) {
735 DocLnk nf; 733 DocLnk nf;
736 QString m_logName = currentSession()->emulationHandler()->logFileName(); 734 QString m_logName = currentSession()->emulationHandler()->logFileName();
737 QFileInfo info(m_logName); 735 QFileInfo info(m_logName);
738 nf.setType("text/plain"); 736 nf.setType("text/plain");
739 nf.setFile(m_logName); 737 nf.setFile(m_logName);
740 nf.setName(info.fileName()); 738 nf.setName(info.fileName());
741 nf.writeLink(); 739 nf.writeLink();
742 m_recordLog->setText( tr("Start log") ); 740 m_recordLog->setText( tr("Start log") );
743 m_recordingLog = false; 741 m_recordingLog = false;
744 currentSession()->emulationHandler()->clearLog(); 742 currentSession()->emulationHandler()->clearLog();
745 } else { 743 } else {
746 QMap<QString, QStringList> map; 744 QMap<QString, QStringList> map;
747 QStringList text; 745 QStringList text;
748 text << "text/plain"; 746 text << "text/plain";
749 map.insert(tr("Log"), text ); 747 map.insert(tr("Log"), text );
750 QString m_logName = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); 748 Opie::Core::OConfig cfg("opie-console");
749 cfg.setGroup("defaults");
750 QString startDir = cfg.readEntry("defaultlogdir", QPEApplication::documentDir() );
751 QString m_logName = OFileDialog::getSaveFileName(2, startDir, QString::null, map, 0, startDir);
751 if (m_logName.isEmpty() ) return; 752 if (m_logName.isEmpty() ) return;
752 753
753 m_recordLog->setText( tr("Stop log") ); 754 m_recordLog->setText( tr("Stop log") );
754 m_recordingLog = true; 755 m_recordingLog = true;
755 currentSession()->emulationHandler()->startLogging(m_logName); 756 currentSession()->emulationHandler()->startLogging(m_logName);
756 } 757 }
757} 758}
758 759
759void MainWindow::slotSaveHistory() { 760void MainWindow::slotSaveHistory() {
760 QMap<QString, QStringList> map; 761 QMap<QString, QStringList> map;
761 QStringList text; 762 QStringList text;
762 text << "text/plain"; 763 text << "text/plain";
763 map.insert(tr("History"), text ); 764 map.insert(tr("History"), text );
764 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); 765 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
765 if (filename.isEmpty() ) return; 766 if (filename.isEmpty() ) return;
766 767
767 QFileInfo info(filename); 768 QFileInfo info(filename);
768 769
769 DocLnk nf; 770 DocLnk nf;
770 nf.setType("text/plain"); 771 nf.setType("text/plain");
771 nf.setFile(filename); 772 nf.setFile(filename);
772 nf.setName(info.fileName()); 773 nf.setName(info.fileName());
773 774
774 775
775 QFile file(filename); 776 QFile file(filename);
776 file.open(IO_WriteOnly ); 777 file.open(IO_WriteOnly );
777 QTextStream str(&file ); 778 QTextStream str(&file );
778 if ( currentSession() ) 779 if ( currentSession() )
779 currentSession()->emulationHandler()->emulation()->streamHistory(&str); 780 currentSession()->emulationHandler()->emulation()->streamHistory(&str);
780 781
781 file.close(); 782 file.close();
782 nf.writeLink(); 783 nf.writeLink();
783} 784}