summaryrefslogtreecommitdiff
authorzecke <zecke>2004-05-01 21:10:02 (UTC)
committer zecke <zecke>2004-05-01 21:10:02 (UTC)
commit49227638e76fa71209390a9c42528a02e3803e3d (patch) (unidiff)
tree3fbbf00962bbb2698e63a196a83fb156443bafd3
parent0d4fd8b708eddb609fd3b14ffe7df1cb3a1401f1 (diff)
downloadopie-49227638e76fa71209390a9c42528a02e3803e3d.zip
opie-49227638e76fa71209390a9c42528a02e3803e3d.tar.gz
opie-49227638e76fa71209390a9c42528a02e3803e3d.tar.bz2
Convert to quicklaunch. Integrate the Sharp ROM fixlet in c'tor and d'tor
of the mainwindow
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/fixit.h88
-rw-r--r--noncore/apps/opie-console/main.cpp106
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp19
-rw-r--r--noncore/apps/opie-console/mainwindow.h1
-rw-r--r--noncore/apps/opie-console/opie-console.pro4
5 files changed, 107 insertions, 111 deletions
diff --git a/noncore/apps/opie-console/fixit.h b/noncore/apps/opie-console/fixit.h
new file mode 100644
index 0000000..501914e
--- a/dev/null
+++ b/noncore/apps/opie-console/fixit.h
@@ -0,0 +1,88 @@
1#ifndef FIX_IT_H
2#define FIX_IT_H
3
4
5#include <sys/types.h>
6
7#include <stdio.h>
8#include <stdlib.h>
9#include <signal.h>
10#include <qfile.h>
11
12/*
13 * The Zaurus rom
14 */
15class FixIt {
16public:
17 FixIt();
18 ~FixIt();
19 void fixIt();
20 /* no real interested in implementing it */
21 void breakIt() {
22
23 };
24 char* m_file;
25};
26
27FixIt::FixIt() {
28 /* the new inittab */
29 m_file = "#\n# /etc/inittab"
30"#"
31""
32"# 0 - halt (Do NOT set initdefault to this)"
33"# 1 - Single user mode"
34"# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)"
35"# 3 - Full multiuser mode"
36"# 4 - JavaVM(Intent) developer mode"
37"# 5 - JavaVM(Intent)"
38"# 6 - reboot (Do NOT set initdefault to this)"
39"#"
40"id:5:initdefault:"
41""
42"# Specify things to do when starting"
43"si::sysinit:/etc/rc.d/rc.sysinit"
44""
45"l0:0:wait:/root/etc/rc.d/rc 0"
46"l1:1:wait:/etc/rc.d/rc 1"
47"l2:2:wait:/etc/rc.d/rc 2"
48"l3:3:wait:/etc/rc.d/rc 3"
49"l4:4:wait:/etc/rc.d/rc 4"
50"l5:5:wait:/etc/rc.d/rc 5"
51"l6:6:wait:/root/etc/rc.d/rc 6"
52""
53"# Specify things to do before rebooting"
54"um::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1"
55"sw::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1"
56""
57"# Specify program to run on ttyS0"
58"s0:24:respawn:/sbin/getty 9600 ttyS0"
59"#pd:5:respawn:/etc/sync/serialctl"
60""
61"# Specify program to run on tty1"
62"1:2:respawn:/sbin/getty 9600 tty1"
63"ln:345:respawn:survive -l 6 /sbin/launch"
64"#qt:5:respawn:/sbin/qt"
65""
66"# collie sp."
67"sy::respawn:/sbin/shsync\n";
68
69}
70FixIt::~FixIt() {
71}
72/*
73 * the retail Zaurus is broken in many ways
74 * one is that pppd is listening on our port...
75 * we've to stop it from that and then do kill(SIGHUP,1);
76 */
77void FixIt::fixIt() {
78 ::rename("/etc/inittab", QPEApplication::qpeDir() + "/etc/inittab" );
79 QFile file( "/etc/inittab" );
80 if ( file.open(IO_WriteOnly | IO_Raw ) ) {
81 file.writeBlock(m_file,strlen(m_file) );
82 }
83 file.close();
84 ::kill( SIGHUP, 1 );
85}
86
87
88#endif
diff --git a/noncore/apps/opie-console/main.cpp b/noncore/apps/opie-console/main.cpp
index 92921ab..eafc9b2 100644
--- a/noncore/apps/opie-console/main.cpp
+++ b/noncore/apps/opie-console/main.cpp
@@ -1,110 +1,8 @@
1#include <sys/types.h> 1#include <opie2/oapplicationfactory.h>
2
3#include <stdio.h>
4#include <stdlib.h>
5#include <signal.h>
6#include <qfile.h>
7
8#include <qpe/qpeapplication.h>
9 2
10#include "mainwindow.h" 3#include "mainwindow.h"
11 4
12// #define FSCKED_DISTRIBUTION 1
13#ifdef FSCKED_DISTRIBUTION
14/*
15 * The Zaurus rom
16 */
17class FixIt {
18public:
19 FixIt();
20 ~FixIt();
21 void fixIt();
22 /* no real interested in implementing it */
23 void breakIt() {
24
25 };
26 char* m_file;
27};
28
29FixIt::FixIt() {
30 /* the new inittab */
31 m_file = "#\n# /etc/inittab"
32"#"
33""
34"# 0 - halt (Do NOT set initdefault to this)"
35"# 1 - Single user mode"
36"# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)"
37"# 3 - Full multiuser mode"
38"# 4 - JavaVM(Intent) developer mode"
39"# 5 - JavaVM(Intent)"
40"# 6 - reboot (Do NOT set initdefault to this)"
41"#"
42"id:5:initdefault:"
43""
44"# Specify things to do when starting"
45"si::sysinit:/etc/rc.d/rc.sysinit"
46""
47"l0:0:wait:/root/etc/rc.d/rc 0"
48"l1:1:wait:/etc/rc.d/rc 1"
49"l2:2:wait:/etc/rc.d/rc 2"
50"l3:3:wait:/etc/rc.d/rc 3"
51"l4:4:wait:/etc/rc.d/rc 4"
52"l5:5:wait:/etc/rc.d/rc 5"
53"l6:6:wait:/root/etc/rc.d/rc 6"
54""
55"# Specify things to do before rebooting"
56"um::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1"
57"sw::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1"
58""
59"# Specify program to run on ttyS0"
60"s0:24:respawn:/sbin/getty 9600 ttyS0"
61"#pd:5:respawn:/etc/sync/serialctl"
62""
63"# Specify program to run on tty1"
64"1:2:respawn:/sbin/getty 9600 tty1"
65"ln:345:respawn:survive -l 6 /sbin/launch"
66"#qt:5:respawn:/sbin/qt"
67""
68"# collie sp."
69"sy::respawn:/sbin/shsync\n";
70}
71FixIt::~FixIt() {
72}
73/*
74 * the retail Zaurus is broken in many ways
75 * one is that pppd is listening on our port...
76 * we've to stop it from that and then do kill(SIGHUP,1);
77 */
78void FixIt::fixIt() {
79 ::rename("/etc/inittab", QPEApplication::qpeDir() + "/etc/inittab" );
80 QFile file( "/etc/inittab" );
81 if ( file.open(IO_WriteOnly | IO_Raw ) ) {
82 file.writeBlock(m_file,strlen(m_file) );
83 }
84 file.close();
85 ::kill( SIGHUP, 1 );
86}
87#endif
88
89int main(int argc, char **argv) {
90// too bad this gives us trouble the taskbar... argv[0]="embeddedkonsole";
91 QPEApplication app( argc, argv );
92
93#ifdef FSCKED_DISTRIBUTION
94// owarn << "fscked" << oendl;
95 FixIt it;
96 it.fixIt();
97#endif
98 5
99 MainWindow mw; 6OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<MainWindow> );
100 mw.setCaption(QObject::tr("Opie Console") );
101 app.showMainWidget( &mw );
102 7
103 int ap = app.exec();
104 8
105#ifdef FSCKED_DISTRIBUTION
106 /* should add a signal handler too */
107 it.breakIt();
108#endif
109 return ap;
110}
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index b403b4d..b160604 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,731 +1,742 @@
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 13
13/* OPIE */ 14/* OPIE */
14#include <opie2/odebug.h> 15#include <opie2/odebug.h>
15#include <opie2/ofiledialog.h> 16#include <opie2/ofiledialog.h>
16#include <qpe/filemanager.h> 17#include <qpe/filemanager.h>
17using namespace Opie::Core; 18using namespace Opie::Core;
18using namespace Opie::Ui; 19using namespace Opie::Ui;
19 20
20/* QT */ 21/* QT */
21#include <qaction.h> 22#include <qaction.h>
22#include <qmenubar.h> 23#include <qmenubar.h>
23#include <qtoolbar.h> 24#include <qtoolbar.h>
24#include <qmessagebox.h> 25#include <qmessagebox.h>
25#include <qwhatsthis.h> 26#include <qwhatsthis.h>
26#include <qfileinfo.h> 27#include <qfileinfo.h>
27 28
28/* STD */ 29/* STD */
29#include <assert.h> 30#include <assert.h>
30 31
31MainWindow::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) {
33#ifdef FSCKED_DISTRI
34 FixIt fix;
35 fix.fixIt();
36#endif
37
38 setCaption(QObject::tr("Opie Console") );
32 KeyTrans::loadAll(); 39 KeyTrans::loadAll();
33 for (int i = 0; i < KeyTrans::count(); i++ ) { 40 for (int i = 0; i < KeyTrans::count(); i++ ) {
34 KeyTrans* s = KeyTrans::find(i ); 41 KeyTrans* s = KeyTrans::find(i );
35 assert( s ); 42 assert( s );
36 } 43 }
37 m_factory = new MetaFactory(); 44 m_factory = new MetaFactory();
38 Default def(m_factory); 45 Default def(m_factory);
39 m_sessions.setAutoDelete( TRUE ); 46 m_sessions.setAutoDelete( TRUE );
40 m_curSession = 0; 47 m_curSession = 0;
41 m_manager = new ProfileManager( m_factory ); 48 m_manager = new ProfileManager( m_factory );
42 m_manager->load(); 49 m_manager->load();
43 m_scriptsData.setAutoDelete(TRUE); 50 m_scriptsData.setAutoDelete(TRUE);
44 51
45 initUI(); 52 initUI();
46 populateProfiles(); 53 populateProfiles();
47 populateScripts(); 54 populateScripts();
48} 55}
49 56
50void MainWindow::initUI() { 57void MainWindow::initUI() {
51 58
52 setToolBarsMovable( FALSE ); 59 setToolBarsMovable( FALSE );
53 60
54 /* tool bar for the menu */ 61 /* tool bar for the menu */
55 m_tool = new QToolBar( this ); 62 m_tool = new QToolBar( this );
56 m_tool->setHorizontalStretchable( TRUE ); 63 m_tool->setHorizontalStretchable( TRUE );
57 64
58 m_bar = new QMenuBar( m_tool ); 65 m_bar = new QMenuBar( m_tool );
59 m_console = new QPopupMenu( this ); 66 m_console = new QPopupMenu( this );
60 m_scripts = new QPopupMenu( this ); 67 m_scripts = new QPopupMenu( this );
61 m_sessionsPop= new QPopupMenu( this ); 68 m_sessionsPop= new QPopupMenu( this );
62 m_scriptsPop = new QPopupMenu( this ); 69 m_scriptsPop = new QPopupMenu( this );
63 70
64 /* add a toolbar for icons */ 71 /* add a toolbar for icons */
65 m_icons = new QToolBar(this); 72 m_icons = new QToolBar(this);
66 73
67 /* 74 /*
68 * the settings action 75 * the settings action
69 */ 76 */
70 m_setProfiles = new QAction(tr("Configure Profiles"), 77 m_setProfiles = new QAction(tr("Configure Profiles"),
71 Resource::loadPixmap( "SettingsIcon" ), 78 Resource::loadPixmap( "SettingsIcon" ),
72 QString::null, 0, this, 0); 79 QString::null, 0, this, 0);
73 m_setProfiles->addTo( m_console ); 80 m_setProfiles->addTo( m_console );
74 connect( m_setProfiles, SIGNAL(activated() ), 81 connect( m_setProfiles, SIGNAL(activated() ),
75 this, SLOT(slotConfigure() ) ); 82 this, SLOT(slotConfigure() ) );
76 83
77 m_console->insertSeparator(); 84 m_console->insertSeparator();
78 /* 85 /*
79 * new Action for new sessions 86 * new Action for new sessions
80 */ 87 */
81 QAction* newCon = new QAction(tr("New Profile"), 88 QAction* newCon = new QAction(tr("New Profile"),
82 Resource::loadPixmap( "new" ), 89 Resource::loadPixmap( "new" ),
83 QString::null, 0, this, 0); 90 QString::null, 0, this, 0);
84 newCon->addTo( m_console ); 91 newCon->addTo( m_console );
85 connect( newCon, SIGNAL(activated() ), 92 connect( newCon, SIGNAL(activated() ),
86 this, SLOT(slotNew() ) ); 93 this, SLOT(slotNew() ) );
87 94
88 m_console->insertSeparator(); 95 m_console->insertSeparator();
89 96
90 QAction *saveCon = new QAction( tr("Save Profile" ), 97 QAction *saveCon = new QAction( tr("Save Profile" ),
91 Resource::loadPixmap( "save" ), QString::null, 98 Resource::loadPixmap( "save" ), QString::null,
92 0, this, 0 ); 99 0, this, 0 );
93 saveCon->addTo( m_console ); 100 saveCon->addTo( m_console );
94 connect( saveCon, SIGNAL(activated() ), 101 connect( saveCon, SIGNAL(activated() ),
95 this, SLOT(slotSaveSession() ) ); 102 this, SLOT(slotSaveSession() ) );
96 m_console->insertSeparator(); 103 m_console->insertSeparator();
97 104
98 /* 105 /*
99 * connect action 106 * connect action
100 */ 107 */
101 m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), 108 m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"),
102 QString::null, 0, this, 0 ); 109 QString::null, 0, this, 0 );
103 m_connect->addTo( m_console ); 110 m_connect->addTo( m_console );
104 connect(m_connect, SIGNAL(activated() ), 111 connect(m_connect, SIGNAL(activated() ),
105 this, SLOT(slotConnect() ) ); 112 this, SLOT(slotConnect() ) );
106 113
107 /* 114 /*
108 * disconnect action 115 * disconnect action
109 */ 116 */
110 m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), 117 m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"),
111 QString::null, 0, this, 0 ); 118 QString::null, 0, this, 0 );
112 m_disconnect->addTo( m_console ); 119 m_disconnect->addTo( m_console );
113 connect(m_disconnect, SIGNAL(activated() ), 120 connect(m_disconnect, SIGNAL(activated() ),
114 this, SLOT(slotDisconnect() ) ); 121 this, SLOT(slotDisconnect() ) );
115 122
116 m_console->insertSeparator(); 123 m_console->insertSeparator();
117 124
118 125
119 m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 ); 126 m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 );
120 m_quickLaunch->addTo( m_icons ); 127 m_quickLaunch->addTo( m_icons );
121 connect( m_quickLaunch, SIGNAL( activated() ), 128 connect( m_quickLaunch, SIGNAL( activated() ),
122 this, SLOT( slotQuickLaunch() ) ); 129 this, SLOT( slotQuickLaunch() ) );
123 130
124 QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) ); 131 QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) );
125 132
126 m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, 133 m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null,
127 0, this, 0 ); 134 0, this, 0 );
128 m_transfer->addTo( m_console ); 135 m_transfer->addTo( m_console );
129 connect(m_transfer, SIGNAL(activated() ), 136 connect(m_transfer, SIGNAL(activated() ),
130 this, SLOT(slotTransfer() ) ); 137 this, SLOT(slotTransfer() ) );
131 138
132 139
133 140
134 /* 141 /*
135 * immediate change of line wrap policy 142 * immediate change of line wrap policy
136 */ 143 */
137 m_isWrapped = false; 144 m_isWrapped = false;
138 m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 ); 145 m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 );
139 m_wrap->addTo( m_console ); 146 m_wrap->addTo( m_console );
140 connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); 147 connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) );
141 148
142 /* 149 /*
143 * fullscreen 150 * fullscreen
144 */ 151 */
145 m_isFullscreen = false; 152 m_isFullscreen = false;
146 153
147 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) 154 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" )
148 , QString::null, 0, this, 0); 155 , QString::null, 0, this, 0);
149 m_fullscreen->addTo( m_console ); 156 m_fullscreen->addTo( m_console );
150 connect( m_fullscreen, SIGNAL( activated() ), 157 connect( m_fullscreen, SIGNAL( activated() ),
151 this, SLOT( slotFullscreen() ) ); 158 this, SLOT( slotFullscreen() ) );
152 159
153 m_console->insertSeparator(); 160 m_console->insertSeparator();
154 161
155 QAction *a = new QAction(); 162 QAction *a = new QAction();
156 a->setText( tr("Save history") ); 163 a->setText( tr("Save history") );
157 a->addTo( m_console ); 164 a->addTo( m_console );
158 connect(a, SIGNAL(activated() ), 165 connect(a, SIGNAL(activated() ),
159 this, SLOT(slotSaveHistory() ) ); 166 this, SLOT(slotSaveHistory() ) );
160 /* 167 /*
161 * terminate action 168 * terminate action
162 */ 169 */
163 m_terminate = new QAction(); 170 m_terminate = new QAction();
164 m_terminate->setText( tr("Terminate") ); 171 m_terminate->setText( tr("Terminate") );
165 m_terminate->addTo( m_console ); 172 m_terminate->addTo( m_console );
166 connect(m_terminate, SIGNAL(activated() ), 173 connect(m_terminate, SIGNAL(activated() ),
167 this, SLOT(slotTerminate() ) ); 174 this, SLOT(slotTerminate() ) );
168 175
169 m_closewindow = new QAction(); 176 m_closewindow = new QAction();
170 m_closewindow->setText( tr("Close Window") ); 177 m_closewindow->setText( tr("Close Window") );
171 m_closewindow->addTo( m_console ); 178 m_closewindow->addTo( m_console );
172 connect( m_closewindow, SIGNAL(activated() ), 179 connect( m_closewindow, SIGNAL(activated() ),
173 this, SLOT(slotClose() ) ); 180 this, SLOT(slotClose() ) );
174 181
175 182
176 /* 183 /*
177 * script actions 184 * script actions
178 */ 185 */
179 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); 186 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0);
180 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); 187 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int)));
181 188
182 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); 189 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
183 m_recordScript->addTo(m_scripts); 190 m_recordScript->addTo(m_scripts);
184 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); 191 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript()));
185 192
186 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); 193 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0);
187 m_saveScript->addTo(m_scripts); 194 m_saveScript->addTo(m_scripts);
188 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); 195 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript()));
189 196
190 197
191 /* 198 /*
192 * action that open/closes the keyboard 199 * action that open/closes the keyboard
193 */ 200 */
194 m_openKeys = new QAction (tr("Open Keyboard..."), 201 m_openKeys = new QAction (tr("Open Keyboard..."),
195 Resource::loadPixmap( "console/keys/keyboard_icon" ), 202 Resource::loadPixmap( "console/keys/keyboard_icon" ),
196 QString::null, 0, this, 0); 203 QString::null, 0, this, 0);
197 m_openKeys->setToggleAction(true); 204 m_openKeys->setToggleAction(true);
198 connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); 205 connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool)));
199 206
200 /* insert the submenu */ 207 /* insert the submenu */
201 m_console->insertItem(tr("New from Profile"), m_sessionsPop, 208 m_console->insertItem(tr("New from Profile"), m_sessionsPop,
202 -1, 0); 209 -1, 0);
203 210
204 /* insert the connection menu */ 211 /* insert the connection menu */
205 m_bar->insertItem( tr("Connection"), m_console ); 212 m_bar->insertItem( tr("Connection"), m_console );
206 213
207 /* the scripts menu */ 214 /* the scripts menu */
208 m_bar->insertItem( tr("Scripts"), m_scripts ); 215 m_bar->insertItem( tr("Scripts"), m_scripts );
209 216
210 /* and the keyboard */ 217 /* and the keyboard */
211 m_keyBar = new QToolBar(this); 218 m_keyBar = new QToolBar(this);
212 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); 219 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE );
213 m_keyBar->setHorizontalStretchable( TRUE ); 220 m_keyBar->setHorizontalStretchable( TRUE );
214 m_keyBar->hide(); 221 m_keyBar->hide();
215 222
216 m_kb = new FunctionKeyboard(m_keyBar); 223 m_kb = new FunctionKeyboard(m_keyBar);
217 connect(m_kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)), 224 connect(m_kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)),
218 this, SLOT(slotKeyReceived(FKey,ushort,ushort,bool))); 225 this, SLOT(slotKeyReceived(FKey,ushort,ushort,bool)));
219 226
220 227
221 a = new QAction(tr("Copy"), 228 a = new QAction(tr("Copy"),
222 Resource::loadPixmap("copy"), QString::null, 229 Resource::loadPixmap("copy"), QString::null,
223 0, this, 0 ); 230 0, this, 0 );
224 //a->addTo( m_icons ); 231 //a->addTo( m_icons );
225 connect( a, SIGNAL(activated() ), 232 connect( a, SIGNAL(activated() ),
226 this, SLOT(slotCopy() ) ); 233 this, SLOT(slotCopy() ) );
227 234
228 QAction *paste = new QAction(tr("Paste"), 235 QAction *paste = new QAction(tr("Paste"),
229 Resource::loadPixmap("paste"), QString::null, 236 Resource::loadPixmap("paste"), QString::null,
230 0, this, 0 ); 237 0, this, 0 );
231 connect( paste, SIGNAL(activated() ), 238 connect( paste, SIGNAL(activated() ),
232 this, SLOT(slotPaste() ) ); 239 this, SLOT(slotPaste() ) );
233 240
234 241
235 newCon->addTo( m_icons ); 242 newCon->addTo( m_icons );
236 //m_setProfiles->addTo( m_icons ); 243 //m_setProfiles->addTo( m_icons );
237 paste->addTo( m_icons ); 244 paste->addTo( m_icons );
238 m_openKeys->addTo(m_icons); 245 m_openKeys->addTo(m_icons);
239 m_fullscreen->addTo( m_icons ); 246 m_fullscreen->addTo( m_icons );
240 247
241 m_connect->setEnabled( false ); 248 m_connect->setEnabled( false );
242 m_disconnect->setEnabled( false ); 249 m_disconnect->setEnabled( false );
243 m_terminate->setEnabled( false ); 250 m_terminate->setEnabled( false );
244 m_transfer->setEnabled( false ); 251 m_transfer->setEnabled( false );
245 m_scripts->setItemEnabled(m_runScript_id, false); 252 m_scripts->setItemEnabled(m_runScript_id, false);
246 m_recordScript->setEnabled( false ); 253 m_recordScript->setEnabled( false );
247 m_saveScript->setEnabled( false ); 254 m_saveScript->setEnabled( false );
248 m_fullscreen->setEnabled( false ); 255 m_fullscreen->setEnabled( false );
249 m_closewindow->setEnabled( false ); 256 m_closewindow->setEnabled( false );
250 m_wrap->setEnabled( false ); 257 m_wrap->setEnabled( false );
251 258
252 /* 259 /*
253 * connect to the menu activation 260 * connect to the menu activation
254 */ 261 */
255 connect( m_sessionsPop, SIGNAL(activated(int) ), 262 connect( m_sessionsPop, SIGNAL(activated(int) ),
256 this, SLOT(slotProfile(int) ) ); 263 this, SLOT(slotProfile(int) ) );
257 264
258 m_consoleWindow = new TabWidget( this, "blah"); 265 m_consoleWindow = new TabWidget( this, "blah");
259 connect(m_consoleWindow, SIGNAL(activated(Session*) ), 266 connect(m_consoleWindow, SIGNAL(activated(Session*) ),
260 this, SLOT(slotSessionChanged(Session*) ) ); 267 this, SLOT(slotSessionChanged(Session*) ) );
261 setCentralWidget( m_consoleWindow ); 268 setCentralWidget( m_consoleWindow );
262 269
263 slotQuickLaunch(); 270 slotQuickLaunch();
264} 271}
265 272
266ProfileManager* MainWindow::manager() { 273ProfileManager* MainWindow::manager() {
267 return m_manager; 274 return m_manager;
268} 275}
269TabWidget* MainWindow::tabWidget() { 276TabWidget* MainWindow::tabWidget() {
270 return m_consoleWindow; 277 return m_consoleWindow;
271} 278}
272void MainWindow::populateProfiles() { 279void MainWindow::populateProfiles() {
273 m_sessionsPop->clear(); 280 m_sessionsPop->clear();
274 Profile::ValueList list = manager()->all(); 281 Profile::ValueList list = manager()->all();
275 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { 282 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) {
276 m_sessionsPop->insertItem( (*it).name() ); 283 m_sessionsPop->insertItem( (*it).name() );
277 } 284 }
278 285
279} 286}
280 287
281void MainWindow::populateScripts() { 288void MainWindow::populateScripts() {
282 m_scriptsPop->clear(); 289 m_scriptsPop->clear();
283 m_scriptsData.clear(); 290 m_scriptsData.clear();
284 DocLnkSet files(QPEApplication::documentDir(), "text/plain"); 291 DocLnkSet files(QPEApplication::documentDir(), "text/plain");
285 QListIterator<DocLnk> dit(files.children()); 292 QListIterator<DocLnk> dit(files.children());
286 for (; dit.current(); ++dit) { 293 for (; dit.current(); ++dit) {
287 if (*dit && (*dit)->name().length()>0) { 294 if (*dit && (*dit)->name().length()>0) {
288 QFileInfo info((*dit)->file()); 295 QFileInfo info((*dit)->file());
289 if (info.extension(false) == "script") { 296 if (info.extension(false) == "script") {
290 m_scriptsData.append(new DocLnk(**dit)); 297 m_scriptsData.append(new DocLnk(**dit));
291 m_scriptsPop->insertItem((*dit)->name()); 298 m_scriptsPop->insertItem((*dit)->name());
292 } 299 }
293 } 300 }
294 } 301 }
295 302
296} 303}
297 304
298MainWindow::~MainWindow() { 305MainWindow::~MainWindow() {
299 delete m_factory; 306 delete m_factory;
300 manager()->save(); 307 manager()->save();
308#ifdef FSCKED_DISTRI
309 FixIt fix;
310 fix.breakIt();
311#endif
301} 312}
302 313
303MetaFactory* MainWindow::factory() { 314MetaFactory* MainWindow::factory() {
304 return m_factory; 315 return m_factory;
305} 316}
306 317
307Session* MainWindow::currentSession() { 318Session* MainWindow::currentSession() {
308 return m_curSession; 319 return m_curSession;
309} 320}
310 321
311QList<Session> MainWindow::sessions() { 322QList<Session> MainWindow::sessions() {
312 return m_sessions; 323 return m_sessions;
313} 324}
314 325
315void MainWindow::slotNew() { 326void MainWindow::slotNew() {
316 ProfileEditorDialog dlg(factory() ); 327 ProfileEditorDialog dlg(factory() );
317 dlg.setCaption( tr("New Connection") ); 328 dlg.setCaption( tr("New Connection") );
318 int ret = QPEApplication::execDialog( &dlg ); 329 int ret = QPEApplication::execDialog( &dlg );
319 330
320 if ( ret == QDialog::Accepted ) { 331 if ( ret == QDialog::Accepted ) {
321 create( dlg.profile() ); 332 create( dlg.profile() );
322 } 333 }
323} 334}
324 335
325void MainWindow::slotRecordScript() { 336void MainWindow::slotRecordScript() {
326 if (currentSession()) { 337 if (currentSession()) {
327 currentSession()->emulationHandler()->startRecording(); 338 currentSession()->emulationHandler()->startRecording();
328 m_saveScript->setEnabled(true); 339 m_saveScript->setEnabled(true);
329 m_recordScript->setEnabled(false); 340 m_recordScript->setEnabled(false);
330 } 341 }
331} 342}
332 343
333void MainWindow::slotSaveScript() { 344void MainWindow::slotSaveScript() {
334 if (currentSession() && currentSession()->emulationHandler()->isRecording()) { 345 if (currentSession() && currentSession()->emulationHandler()->isRecording()) {
335 QMap<QString, QStringList> map; 346 QMap<QString, QStringList> map;
336 QStringList text; 347 QStringList text;
337 text << "text/plain"; 348 text << "text/plain";
338 map.insert(tr("Script"), text ); 349 map.insert(tr("Script"), text );
339 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); 350 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
340 if (!filename.isEmpty()) { 351 if (!filename.isEmpty()) {
341 QFileInfo info(filename); 352 QFileInfo info(filename);
342 if (info.extension(FALSE) != "script") 353 if (info.extension(FALSE) != "script")
343 filename += ".script"; 354 filename += ".script";
344 DocLnk nf; 355 DocLnk nf;
345 nf.setType("text/plain"); 356 nf.setType("text/plain");
346 nf.setFile(filename); 357 nf.setFile(filename);
347 nf.setName(info.fileName()); 358 nf.setName(info.fileName());
348 FileManager fm; 359 FileManager fm;
349 fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); 360 fm.saveFile(nf, currentSession()->emulationHandler()->script()->script());
350 currentSession()->emulationHandler()->clearScript(); 361 currentSession()->emulationHandler()->clearScript();
351 m_saveScript->setEnabled(false); 362 m_saveScript->setEnabled(false);
352 m_recordScript->setEnabled(true); 363 m_recordScript->setEnabled(true);
353 populateScripts(); 364 populateScripts();
354 } 365 }
355 } 366 }
356} 367}
357 368
358void MainWindow::slotRunScript(int id) { 369void MainWindow::slotRunScript(int id) {
359 if (currentSession()) { 370 if (currentSession()) {
360 int index = m_scriptsPop->indexOf(id); 371 int index = m_scriptsPop->indexOf(id);
361 DocLnk *lnk = m_scriptsData.at(index); 372 DocLnk *lnk = m_scriptsData.at(index);
362 QString filePath = lnk->file(); 373 QString filePath = lnk->file();
363 Script script(filePath); 374 Script script(filePath);
364 currentSession()->emulationHandler()->runScript(&script); 375 currentSession()->emulationHandler()->runScript(&script);
365 } 376 }
366} 377}
367 378
368void MainWindow::slotConnect() { 379void MainWindow::slotConnect() {
369 if ( currentSession() ) { 380 if ( currentSession() ) {
370 bool ret = currentSession()->layer()->open(); 381 bool ret = currentSession()->layer()->open();
371 if(!ret) QMessageBox::warning(currentSession()->widgetStack(), 382 if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
372 QObject::tr("Failed"), 383 QObject::tr("Failed"),
373 QObject::tr("Connecting failed for this session.")); 384 QObject::tr("Connecting failed for this session."));
374 else { 385 else {
375 m_connect->setEnabled( false ); 386 m_connect->setEnabled( false );
376 m_disconnect->setEnabled( true ); 387 m_disconnect->setEnabled( true );
377 388
378 // if it does not support file transfer, disable the menu entry 389 // if it does not support file transfer, disable the menu entry
379 if ( ( m_curSession->layer() )->supports()[1] == 0 ) { 390 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
380 m_transfer->setEnabled( false ); 391 m_transfer->setEnabled( false );
381 } else { 392 } else {
382 m_transfer->setEnabled( true ); 393 m_transfer->setEnabled( true );
383 } 394 }
384 395
385 m_recordScript->setEnabled( true ); 396 m_recordScript->setEnabled( true );
386 m_scripts->setItemEnabled(m_runScript_id, true); 397 m_scripts->setItemEnabled(m_runScript_id, true);
387 } 398 }
388 } 399 }
389} 400}
390 401
391void MainWindow::slotDisconnect() { 402void MainWindow::slotDisconnect() {
392 if ( currentSession() ) { 403 if ( currentSession() ) {
393 currentSession()->layer()->close(); 404 currentSession()->layer()->close();
394 m_connect->setEnabled( true ); 405 m_connect->setEnabled( true );
395 m_disconnect->setEnabled( false ); 406 m_disconnect->setEnabled( false );
396 m_transfer->setEnabled( false ); 407 m_transfer->setEnabled( false );
397 m_recordScript->setEnabled( false); 408 m_recordScript->setEnabled( false);
398 m_saveScript->setEnabled( false ); 409 m_saveScript->setEnabled( false );
399 m_scripts->setItemEnabled(m_runScript_id, false); 410 m_scripts->setItemEnabled(m_runScript_id, false);
400 } 411 }
401} 412}
402 413
403void MainWindow::slotTerminate() { 414void MainWindow::slotTerminate() {
404 if ( currentSession() ) 415 if ( currentSession() )
405 currentSession()->layer()->close(); 416 currentSession()->layer()->close();
406 417
407 slotClose(); 418 slotClose();
408 /* FIXME move to the next session */ 419 /* FIXME move to the next session */
409} 420}
410 421
411 422
412 423
413 424
414 425
415 426
416void MainWindow::slotQuickLaunch() { 427void MainWindow::slotQuickLaunch() {
417 Profile prof = manager()->profile( "default" ); 428 Profile prof = manager()->profile( "default" );
418 if ( prof.name() == "default" ) { 429 if ( prof.name() == "default" ) {
419 create( prof ); 430 create( prof );
420 } else { 431 } else {
421 Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 ); 432 Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 );
422 newProf.setAutoConnect( true ); 433 newProf.setAutoConnect( true );
423 create( newProf ); 434 create( newProf );
424 slotSaveSession(); 435 slotSaveSession();
425 } 436 }
426 437
427} 438}
428 439
429void MainWindow::slotConfigure() { 440void MainWindow::slotConfigure() {
430 ConfigDialog conf( manager()->all(), factory() ); 441 ConfigDialog conf( manager()->all(), factory() );
431 442
432 int ret = QPEApplication::execDialog( &conf ); 443 int ret = QPEApplication::execDialog( &conf );
433 444
434 if ( QDialog::Accepted == ret ) { 445 if ( QDialog::Accepted == ret ) {
435 manager()->setProfiles( conf.list() ); 446 manager()->setProfiles( conf.list() );
436 manager()->save(); 447 manager()->save();
437 populateProfiles(); 448 populateProfiles();
438 } 449 }
439} 450}
440/* 451/*
441 * we will remove 452 * we will remove
442 * this window from the tabwidget 453 * this window from the tabwidget
443 * remove it from the list 454 * remove it from the list
444 * delete it 455 * delete it
445 * and set the currentSession() 456 * and set the currentSession()
446 */ 457 */
447void MainWindow::slotClose() { 458void MainWindow::slotClose() {
448 if (!currentSession() ) 459 if (!currentSession() )
449 return; 460 return;
450 461
451 Session* ses = currentSession(); 462 Session* ses = currentSession();
452 owarn << "removing! currentSession " << currentSession()->name().latin1() << "" << oendl; 463 owarn << "removing! currentSession " << currentSession()->name().latin1() << "" << oendl;
453 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ 464 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */
454 m_curSession = NULL; 465 m_curSession = NULL;
455 tabWidget()->remove( /*currentSession()*/ses ); 466 tabWidget()->remove( /*currentSession()*/ses );
456 /*it's autodelete */ 467 /*it's autodelete */
457 m_sessions.remove( ses ); 468 m_sessions.remove( ses );
458 owarn << "after remove!!" << oendl; 469 owarn << "after remove!!" << oendl;
459 470
460 if (!currentSession() ) { 471 if (!currentSession() ) {
461 m_connect->setEnabled( false ); 472 m_connect->setEnabled( false );
462 m_disconnect->setEnabled( false ); 473 m_disconnect->setEnabled( false );
463 m_terminate->setEnabled( false ); 474 m_terminate->setEnabled( false );
464 m_transfer->setEnabled( false ); 475 m_transfer->setEnabled( false );
465 m_recordScript->setEnabled( false ); 476 m_recordScript->setEnabled( false );
466 m_saveScript->setEnabled( false ); 477 m_saveScript->setEnabled( false );
467 m_scripts->setItemEnabled(m_runScript_id, false); 478 m_scripts->setItemEnabled(m_runScript_id, false);
468 m_fullscreen->setEnabled( false ); 479 m_fullscreen->setEnabled( false );
469 m_wrap->setEnabled( false ); 480 m_wrap->setEnabled( false );
470 m_closewindow->setEnabled( false ); 481 m_closewindow->setEnabled( false );
471 } 482 }
472 483
473 m_kb->loadDefaults(); 484 m_kb->loadDefaults();
474} 485}
475 486
476/* 487/*
477 * We will get the name 488 * We will get the name
478 * Then the profile 489 * Then the profile
479 * and then we will make a profile 490 * and then we will make a profile
480 */ 491 */
481void MainWindow::slotProfile( int id) { 492void MainWindow::slotProfile( int id) {
482 Profile prof = manager()->profile( m_sessionsPop->text( id) ); 493 Profile prof = manager()->profile( m_sessionsPop->text( id) );
483 create( prof ); 494 create( prof );
484} 495}
485 496
486 497
487 498
488void MainWindow::create( const Profile& prof ) { 499void MainWindow::create( const Profile& prof ) {
489 if(m_curSession) 500 if(m_curSession)
490 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); 501 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
491 502
492 Session *ses = manager()->fromProfile( prof, tabWidget() ); 503 Session *ses = manager()->fromProfile( prof, tabWidget() );
493 504
494 if((!ses) || (!ses->layer()) || (!ses->widgetStack())) 505 if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
495 { 506 {
496 QMessageBox::warning(this, 507 QMessageBox::warning(this,
497 QObject::tr("Session failed"), 508 QObject::tr("Session failed"),
498 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); 509 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>"));
499 //if(ses) delete ses; 510 //if(ses) delete ses;
500 return; 511 return;
501 } 512 }
502 513
503 m_sessions.append( ses ); 514 m_sessions.append( ses );
504 tabWidget()->add( ses ); 515 tabWidget()->add( ses );
505 tabWidget()->repaint(); 516 tabWidget()->repaint();
506 m_curSession = ses; 517 m_curSession = ses;
507 518
508 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it 519 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it
509 m_connect->setEnabled( true ); 520 m_connect->setEnabled( true );
510 m_disconnect->setEnabled( false ); 521 m_disconnect->setEnabled( false );
511 m_terminate->setEnabled( true ); 522 m_terminate->setEnabled( true );
512 m_fullscreen->setEnabled( true ); 523 m_fullscreen->setEnabled( true );
513 m_wrap->setEnabled( true ); 524 m_wrap->setEnabled( true );
514 m_closewindow->setEnabled( true ); 525 m_closewindow->setEnabled( true );
515 m_transfer->setEnabled( false ); 526 m_transfer->setEnabled( false );
516 m_recordScript->setEnabled( false ); 527 m_recordScript->setEnabled( false );
517 m_saveScript->setEnabled( false ); 528 m_saveScript->setEnabled( false );
518 m_scripts->setItemEnabled(m_runScript_id, false); 529 m_scripts->setItemEnabled(m_runScript_id, false);
519 530
520 // is io_layer wants direct connection, then autoconnect 531 // is io_layer wants direct connection, then autoconnect
521 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { 532 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) {
522 if (prof.autoConnect()) { 533 if (prof.autoConnect()) {
523 slotConnect(); 534 slotConnect();
524 } 535 }
525 536
526 537
527 QWidget *w = currentSession()->widget(); 538 QWidget *w = currentSession()->widget();
528 if(w) w->setFocus(); 539 if(w) w->setFocus();
529 540
530 if(currentSession()->profile().readNumEntry("Wrap", 80)){ 541 if(currentSession()->profile().readNumEntry("Wrap", 80)){
531 m_isWrapped = true; 542 m_isWrapped = true;
532 } else { 543 } else {
533 m_isWrapped = false; 544 m_isWrapped = false;
534 } 545 }
535 546
536 m_kb->load(currentSession()->profile()); 547 m_kb->load(currentSession()->profile());
537} 548}
538 549
539void MainWindow::slotTransfer() 550void MainWindow::slotTransfer()
540{ 551{
541 if ( currentSession() ) { 552 if ( currentSession() ) {
542 Session *mysession = currentSession(); 553 Session *mysession = currentSession();
543 TransferDialog dlg(/*mysession->widgetStack()*/this, this); 554 TransferDialog dlg(/*mysession->widgetStack()*/this, this);
544 mysession->setTransferDialog(&dlg); 555 mysession->setTransferDialog(&dlg);
545 //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); 556 //dlg.reparent(mysession->widgetStack(), QPoint(0, 0));
546 //dlg.showMaximized(); 557 //dlg.showMaximized();
547 currentSession()->widgetStack()->addWidget(&dlg, -1); 558 currentSession()->widgetStack()->addWidget(&dlg, -1);
548 dlg.show(); 559 dlg.show();
549 //dlg.exec(); 560 //dlg.exec();
550 while(dlg.isRunning()) qApp->processEvents(); 561 while(dlg.isRunning()) qApp->processEvents();
551 mysession->setTransferDialog(0l); 562 mysession->setTransferDialog(0l);
552 } 563 }
553} 564}
554 565
555 566
556void MainWindow::slotOpenKeb(bool state) { 567void MainWindow::slotOpenKeb(bool state) {
557 568
558 if (state) m_keyBar->show(); 569 if (state) m_keyBar->show();
559 else m_keyBar->hide(); 570 else m_keyBar->hide();
560 571
561} 572}
562 573
563 574
564void MainWindow::slotOpenButtons( bool state ) { 575void MainWindow::slotOpenButtons( bool state ) {
565 576
566 if ( state ) { 577 if ( state ) {
567 m_buttonBar->show(); 578 m_buttonBar->show();
568 } else { 579 } else {
569 m_buttonBar->hide(); 580 m_buttonBar->hide();
570 } 581 }
571} 582}
572 583
573 584
574 585
575void MainWindow::slotSessionChanged( Session* ses ) { 586void MainWindow::slotSessionChanged( Session* ses ) {
576 owarn << "changed!" << oendl; 587 owarn << "changed!" << oendl;
577 588
578 if(m_curSession) 589 if(m_curSession)
579 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); 590 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
580 if(ses) 591 if(ses)
581 if(ses->transferDialog()) ses->transferDialog()->show(); 592 if(ses->transferDialog()) ses->transferDialog()->show();
582 593
583 if ( ses ) { 594 if ( ses ) {
584 m_curSession = ses; 595 m_curSession = ses;
585 odebug << QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) << oendl; 596 odebug << QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) << oendl;
586 if ( m_curSession->layer()->isConnected() ) { 597 if ( m_curSession->layer()->isConnected() ) {
587 m_connect->setEnabled( false ); 598 m_connect->setEnabled( false );
588 m_disconnect->setEnabled( true ); 599 m_disconnect->setEnabled( true );
589 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); 600 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording());
590 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); 601 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording());
591 m_scripts->setItemEnabled(m_runScript_id, true); 602 m_scripts->setItemEnabled(m_runScript_id, true);
592 } else { 603 } else {
593 m_connect->setEnabled( true ); 604 m_connect->setEnabled( true );
594 m_disconnect->setEnabled( false ); 605 m_disconnect->setEnabled( false );
595 m_recordScript->setEnabled( false ); 606 m_recordScript->setEnabled( false );
596 m_saveScript->setEnabled( false ); 607 m_saveScript->setEnabled( false );
597 m_scripts->setItemEnabled(m_runScript_id, false); 608 m_scripts->setItemEnabled(m_runScript_id, false);
598 } 609 }
599 610
600 if ( ( m_curSession->layer() )->supports()[1] == 0 ) { 611 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
601 m_transfer->setEnabled( false ); 612 m_transfer->setEnabled( false );
602 } else { 613 } else {
603 m_transfer->setEnabled( true ); 614 m_transfer->setEnabled( true );
604 } 615 }
605 616
606 QWidget *w = m_curSession->widget(); 617 QWidget *w = m_curSession->widget();
607 if(w) w->setFocus(); 618 if(w) w->setFocus();
608 619
609 if(currentSession()->profile().readNumEntry("Wrap", 80)){ 620 if(currentSession()->profile().readNumEntry("Wrap", 80)){
610 m_isWrapped = true; 621 m_isWrapped = true;
611 } else { 622 } else {
612 m_isWrapped = false; 623 m_isWrapped = false;
613 } 624 }
614 625
615 m_kb->load(currentSession()->profile()); 626 m_kb->load(currentSession()->profile());
616 } 627 }
617} 628}
618 629
619void MainWindow::slotWrap() 630void MainWindow::slotWrap()
620{ 631{
621 if(m_curSession) 632 if(m_curSession)
622 { 633 {
623 EmulationHandler *e = m_curSession->emulationHandler(); 634 EmulationHandler *e = m_curSession->emulationHandler();
624 if(e) 635 if(e)
625 { 636 {
626 if(m_isWrapped) 637 if(m_isWrapped)
627 { 638 {
628 e->setWrap(80); 639 e->setWrap(80);
629 m_isWrapped = false; 640 m_isWrapped = false;
630 } 641 }
631 else 642 else
632 { 643 {
633 e->setWrap(0); 644 e->setWrap(0);
634 m_isWrapped = true; 645 m_isWrapped = true;
635 } 646 }
636 } 647 }
637 } 648 }
638} 649}
639 650
640void MainWindow::slotFullscreen() { 651void MainWindow::slotFullscreen() {
641 652
642 653
643 654
644 if ( m_isFullscreen ) { 655 if ( m_isFullscreen ) {
645 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); 656 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true );
646 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); 657 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() );
647 ( m_curSession->emulationHandler() )->cornerButton()->hide(); 658 ( m_curSession->emulationHandler() )->cornerButton()->hide();
648 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 659 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
649 660
650 } else { 661 } else {
651 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); 662 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget();
652 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); 663 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame );
653 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop 664 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop
654 , QPoint(0,0), false ); 665 , QPoint(0,0), false );
655 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); 666 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() );
656 ( m_curSession->widgetStack() )->setFocus(); 667 ( m_curSession->widgetStack() )->setFocus();
657 ( m_curSession->widgetStack() )->show(); 668 ( m_curSession->widgetStack() )->show();
658 669
659 ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); 670 ( ( m_curSession->emulationHandler() )->cornerButton() )->show();
660 671
661 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 672 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
662 } 673 }
663 674
664 m_isFullscreen = !m_isFullscreen; 675 m_isFullscreen = !m_isFullscreen;
665} 676}
666 677
667 678
668void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { 679void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) {
669 680
670 if ( m_curSession ) { 681 if ( m_curSession ) {
671 682
672 QEvent::Type state; 683 QEvent::Type state;
673 684
674 if (pressed) state = QEvent::KeyPress; 685 if (pressed) state = QEvent::KeyPress;
675 else state = QEvent::KeyRelease; 686 else state = QEvent::KeyRelease;
676 687
677 QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); 688 QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode)));
678 689
679 // is this the best way to do this? cant figure out any other way to work 690 // is this the best way to do this? cant figure out any other way to work
680 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); 691 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke);
681 ke.ignore(); 692 ke.ignore();
682 } 693 }
683} 694}
684void MainWindow::slotCopy() { 695void MainWindow::slotCopy() {
685 if (!currentSession() ) return; 696 if (!currentSession() ) return;
686 currentSession()->emulationHandler()->copy(); 697 currentSession()->emulationHandler()->copy();
687} 698}
688void MainWindow::slotPaste() { 699void MainWindow::slotPaste() {
689 if (!currentSession() ) return; 700 if (!currentSession() ) return;
690 currentSession()->emulationHandler()->paste(); 701 currentSession()->emulationHandler()->paste();
691} 702}
692 703
693/* 704/*
694 * Save the session 705 * Save the session
695 */ 706 */
696 707
697void MainWindow::slotSaveSession() { 708void MainWindow::slotSaveSession() {
698 if (!currentSession() ) { 709 if (!currentSession() ) {
699 QMessageBox::information(this, tr("Save Connection"), 710 QMessageBox::information(this, tr("Save Connection"),
700 tr("<qt>There is no Connection.</qt>"), 1 ); 711 tr("<qt>There is no Connection.</qt>"), 1 );
701 return; 712 return;
702 } 713 }
703 manager()->add( currentSession()->profile() ); 714 manager()->add( currentSession()->profile() );
704 manager()->save(); 715 manager()->save();
705 populateProfiles(); 716 populateProfiles();
706} 717}
707void MainWindow::slotSaveHistory() { 718void MainWindow::slotSaveHistory() {
708 QMap<QString, QStringList> map; 719 QMap<QString, QStringList> map;
709 QStringList text; 720 QStringList text;
710 text << "text/plain"; 721 text << "text/plain";
711 map.insert(tr("History"), text ); 722 map.insert(tr("History"), text );
712 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); 723 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
713 if (filename.isEmpty() ) return; 724 if (filename.isEmpty() ) return;
714 725
715 QFileInfo info(filename); 726 QFileInfo info(filename);
716 727
717 DocLnk nf; 728 DocLnk nf;
718 nf.setType("text/plain"); 729 nf.setType("text/plain");
719 nf.setFile(filename); 730 nf.setFile(filename);
720 nf.setName(info.fileName()); 731 nf.setName(info.fileName());
721 732
722 733
723 QFile file(filename); 734 QFile file(filename);
724 file.open(IO_WriteOnly ); 735 file.open(IO_WriteOnly );
725 QTextStream str(&file ); 736 QTextStream str(&file );
726 if ( currentSession() ) 737 if ( currentSession() )
727 currentSession()->emulationHandler()->emulation()->streamHistory(&str); 738 currentSession()->emulationHandler()->emulation()->streamHistory(&str);
728 739
729 file.close(); 740 file.close();
730 nf.writeLink(); 741 nf.writeLink();
731} 742}
diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h
index 86939c1..b1f175a 100644
--- a/noncore/apps/opie-console/mainwindow.h
+++ b/noncore/apps/opie-console/mainwindow.h
@@ -1,138 +1,139 @@
1#ifndef OPIE_MAIN_WINDOW_H 1#ifndef OPIE_MAIN_WINDOW_H
2#define OPIE_MAIN_WINDOW_H 2#define OPIE_MAIN_WINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qlist.h> 5#include <qlist.h>
6 6
7#include "session.h" 7#include "session.h"
8 8
9/** 9/**
10 * this is the MainWindow of the new opie console 10 * this is the MainWindow of the new opie console
11 * it's also the dispatcher between the different 11 * it's also the dispatcher between the different
12 * actions supported by the gui 12 * actions supported by the gui
13 */ 13 */
14class QToolBar; 14class QToolBar;
15class QToolButton; 15class QToolButton;
16class QMenuBar; 16class QMenuBar;
17class QAction; 17class QAction;
18class MetaFactory; 18class MetaFactory;
19class TabWidget; 19class TabWidget;
20class ProfileManager; 20class ProfileManager;
21class Profile; 21class Profile;
22class FunctionKeyboard; 22class FunctionKeyboard;
23class FKey; 23class FKey;
24class DocLnk; 24class DocLnk;
25 25
26class MainWindow : public QMainWindow { 26class MainWindow : public QMainWindow {
27 Q_OBJECT 27 Q_OBJECT
28public: 28public:
29 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); 29 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 );
30 ~MainWindow(); 30 ~MainWindow();
31 static QString appName() {return QString::fromLatin1("console"); }
31 32
32 /** 33 /**
33 * our factory to generate IOLayer and so on 34 * our factory to generate IOLayer and so on
34 * 35 *
35 */ 36 */
36 MetaFactory* factory(); 37 MetaFactory* factory();
37 38
38 /** 39 /**
39 * A session contains a QWidget*, 40 * A session contains a QWidget*,
40 * an IOLayer* and some infos for us 41 * an IOLayer* and some infos for us
41 */ 42 */
42 Session* currentSession(); 43 Session* currentSession();
43 44
44 /** 45 /**
45 * the session list 46 * the session list
46 */ 47 */
47 QList<Session> sessions(); 48 QList<Session> sessions();
48 49
49 /** 50 /**
50 * 51 *
51 */ 52 */
52 ProfileManager* manager(); 53 ProfileManager* manager();
53 TabWidget* tabWidget(); 54 TabWidget* tabWidget();
54 55
55private slots: 56private slots:
56 void slotNew(); 57 void slotNew();
57 void slotConnect(); 58 void slotConnect();
58 void slotDisconnect(); 59 void slotDisconnect();
59 void slotTerminate(); 60 void slotTerminate();
60 void slotConfigure(); 61 void slotConfigure();
61 void slotClose(); 62 void slotClose();
62 void slotProfile(int); 63 void slotProfile(int);
63 void slotTransfer(); 64 void slotTransfer();
64 void slotOpenKeb(bool); 65 void slotOpenKeb(bool);
65 void slotOpenButtons(bool); 66 void slotOpenButtons(bool);
66 void slotRecordScript(); 67 void slotRecordScript();
67 void slotSaveScript(); 68 void slotSaveScript();
68 void slotRunScript(int); 69 void slotRunScript(int);
69 void slotFullscreen(); 70 void slotFullscreen();
70 void slotQuickLaunch(); 71 void slotQuickLaunch();
71 void slotWrap(); 72 void slotWrap();
72 void slotSessionChanged( Session* ); 73 void slotSessionChanged( Session* );
73 void slotKeyReceived(FKey, ushort, ushort, bool); 74 void slotKeyReceived(FKey, ushort, ushort, bool);
74 void slotSaveHistory(); 75 void slotSaveHistory();
75 76
76 /* what could these both slot do? */ 77 /* what could these both slot do? */
77 void slotCopy(); 78 void slotCopy();
78 void slotPaste(); 79 void slotPaste();
79 80
80 /* save the currentSession() to Profiles */ 81 /* save the currentSession() to Profiles */
81 void slotSaveSession(); 82 void slotSaveSession();
82 83
83private: 84private:
84 void initUI(); 85 void initUI();
85 void populateProfiles(); 86 void populateProfiles();
86 void populateScripts(); 87 void populateScripts();
87 void create( const Profile& ); 88 void create( const Profile& );
88 /** 89 /**
89 * the current session 90 * the current session
90 */ 91 */
91 Session* m_curSession; 92 Session* m_curSession;
92 93
93 /** 94 /**
94 * the session list 95 * the session list
95 */ 96 */
96 QList<Session> m_sessions; 97 QList<Session> m_sessions;
97 QList<DocLnk> m_scriptsData; 98 QList<DocLnk> m_scriptsData;
98 99
99 /** 100 /**
100 * the metafactory 101 * the metafactory
101 */ 102 */
102 MetaFactory* m_factory; 103 MetaFactory* m_factory;
103 ProfileManager* m_manager; 104 ProfileManager* m_manager;
104 105
105 TabWidget* m_consoleWindow; 106 TabWidget* m_consoleWindow;
106 QToolBar* m_tool; 107 QToolBar* m_tool;
107 QToolBar* m_icons; 108 QToolBar* m_icons;
108 QToolBar* m_keyBar; 109 QToolBar* m_keyBar;
109 QToolBar* m_buttonBar; 110 QToolBar* m_buttonBar;
110 QMenuBar* m_bar; 111 QMenuBar* m_bar;
111 QPopupMenu* m_console; 112 QPopupMenu* m_console;
112 QPopupMenu* m_sessionsPop; 113 QPopupMenu* m_sessionsPop;
113 QPopupMenu* m_scriptsPop; 114 QPopupMenu* m_scriptsPop;
114 QPopupMenu* m_scripts; 115 QPopupMenu* m_scripts;
115 QAction* m_connect; 116 QAction* m_connect;
116 QAction* m_disconnect; 117 QAction* m_disconnect;
117 QAction* m_quickLaunch; 118 QAction* m_quickLaunch;
118 QAction* m_terminate; 119 QAction* m_terminate;
119 QAction* m_transfer; 120 QAction* m_transfer;
120 QAction* m_setProfiles; 121 QAction* m_setProfiles;
121 QAction* m_openKeys; 122 QAction* m_openKeys;
122 QAction* m_openButtons; 123 QAction* m_openButtons;
123 QAction* m_recordScript; 124 QAction* m_recordScript;
124 QAction* m_saveScript; 125 QAction* m_saveScript;
125 QAction* m_fullscreen; 126 QAction* m_fullscreen;
126 QAction* m_wrap; 127 QAction* m_wrap;
127 QAction* m_closewindow; 128 QAction* m_closewindow;
128 129
129 FunctionKeyboard *m_kb; 130 FunctionKeyboard *m_kb;
130 int m_runScript_id; 131 int m_runScript_id;
131 bool m_isFullscreen; 132 bool m_isFullscreen;
132 bool m_isWrapped; 133 bool m_isWrapped;
133 134
134 QWidget* savedParentFullscreen; 135 QWidget* savedParentFullscreen;
135}; 136};
136 137
137 138
138#endif 139#endif
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro
index 8268b01..baa5a55 100644
--- a/noncore/apps/opie-console/opie-console.pro
+++ b/noncore/apps/opie-console/opie-console.pro
@@ -1,74 +1,72 @@
1TEMPLATE = app 1CONFIG += qt warn_on quick-app
2CONFIG += qt warn_on
3DESTDIR = $(OPIEDIR)/bin
4HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h io_modem.h \ 2HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h io_modem.h \
5 file_layer.h filetransfer.h \ 3 file_layer.h filetransfer.h \
6 metafactory.h \ 4 metafactory.h \
7 session.h \ 5 session.h \
8 mainwindow.h \ 6 mainwindow.h \
9 profile.h \ 7 profile.h \
10 profileconfig.h \ 8 profileconfig.h \
11 profilemanager.h \ 9 profilemanager.h \
12 tabwidget.h \ 10 tabwidget.h \
13 configdialog.h \ 11 configdialog.h \
14 keytrans.h \ 12 keytrans.h \
15 transferdialog.h \ 13 transferdialog.h \
16 profiledialogwidget.h \ 14 profiledialogwidget.h \
17 profileeditordialog.h \ 15 profileeditordialog.h \
18 default.h \ 16 default.h \
19 iolayerbase.h \ 17 iolayerbase.h \
20 serialconfigwidget.h irdaconfigwidget.h \ 18 serialconfigwidget.h irdaconfigwidget.h \
21 btconfigwidget.h modemconfigwidget.h \ 19 btconfigwidget.h modemconfigwidget.h \
22 atconfigdialog.h dialdialog.h \ 20 atconfigdialog.h dialdialog.h \
23 procctl.h \ 21 procctl.h \
24 function_keyboard.h \ 22 function_keyboard.h \
25 receive_layer.h filereceive.h \ 23 receive_layer.h filereceive.h \
26 script.h \ 24 script.h \
27 dialer.h \ 25 dialer.h \
28 terminalwidget.h \ 26 terminalwidget.h \
29 emulation_handler.h TECommon.h \ 27 emulation_handler.h TECommon.h \
30 TEHistory.h TEScreen.h TEWidget.h \ 28 TEHistory.h TEScreen.h TEWidget.h \
31 TEmuVt102.h TEmulation.h MyPty.h \ 29 TEmuVt102.h TEmulation.h MyPty.h \
32 consoleconfigwidget.h 30 consoleconfigwidget.h
33 31
34SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \ 32SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \
35 file_layer.cpp filetransfer.cpp \ 33 file_layer.cpp filetransfer.cpp \
36 main.cpp \ 34 main.cpp \
37 metafactory.cpp \ 35 metafactory.cpp \
38 session.cpp \ 36 session.cpp \
39 mainwindow.cpp \ 37 mainwindow.cpp \
40 profile.cpp \ 38 profile.cpp \
41 profileconfig.cpp \ 39 profileconfig.cpp \
42 profilemanager.cpp \ 40 profilemanager.cpp \
43 tabwidget.cpp \ 41 tabwidget.cpp \
44 configdialog.cpp \ 42 configdialog.cpp \
45 keytrans.cpp \ 43 keytrans.cpp \
46 transferdialog.cpp \ 44 transferdialog.cpp \
47 profiledialogwidget.cpp \ 45 profiledialogwidget.cpp \
48 profileeditordialog.cpp \ 46 profileeditordialog.cpp \
49 iolayerbase.cpp \ 47 iolayerbase.cpp \
50 serialconfigwidget.cpp irdaconfigwidget.cpp \ 48 serialconfigwidget.cpp irdaconfigwidget.cpp \
51 btconfigwidget.cpp modemconfigwidget.cpp \ 49 btconfigwidget.cpp modemconfigwidget.cpp \
52 atconfigdialog.cpp dialdialog.cpp \ 50 atconfigdialog.cpp dialdialog.cpp \
53 default.cpp procctl.cpp \ 51 default.cpp procctl.cpp \
54 function_keyboard.cpp \ 52 function_keyboard.cpp \
55 receive_layer.cpp filereceive.cpp \ 53 receive_layer.cpp filereceive.cpp \
56 script.cpp \ 54 script.cpp \
57 dialer.cpp \ 55 dialer.cpp \
58 terminalwidget.cpp \ 56 terminalwidget.cpp \
59 emulation_handler.cpp TEHistory.cpp \ 57 emulation_handler.cpp TEHistory.cpp \
60 TEScreen.cpp TEWidget.cpp \ 58 TEScreen.cpp TEWidget.cpp \
61 TEmuVt102.cpp TEmulation.cpp MyPty.cpp \ 59 TEmuVt102.cpp TEmulation.cpp MyPty.cpp \
62 consoleconfigwidget.cpp 60 consoleconfigwidget.cpp
63 61
64 62
65INTERFACES = configurebase.ui editbase.ui 63INTERFACES = configurebase.ui editbase.ui
66INCLUDEPATH += $(OPIEDIR)/include 64INCLUDEPATH += $(OPIEDIR)/include
67DEPENDPATH += $(OPIEDIR)/include 65DEPENDPATH += $(OPIEDIR)/include
68LIBS += -lqpe -lopiecore2 -lopieui2 -lutil 66LIBS += -lqpe -lopiecore2 -lopieui2 -lutil
69TARGET = console 67TARGET = console
70 68
71DEFINES += HAVE_OPENPTY 69DEFINES += HAVE_OPENPTY
72 70
73 71
74include ( $(OPIEDIR)/include.pro ) 72include ( $(OPIEDIR)/include.pro )