summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index a0622d4..291912c 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,609 +1,621 @@
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/odebug.h> 15#include <opie2/odebug.h>
16#include <opie2/ofiledialog.h> 16#include <opie2/ofiledialog.h>
17#include <qpe/filemanager.h> 17#include <qpe/filemanager.h>
18using namespace Opie::Core; 18using namespace Opie::Core;
19using namespace Opie::Ui; 19using namespace Opie::Ui;
20 20
21/* QT */ 21/* QT */
22#include <qaction.h> 22#include <qaction.h>
23#include <qmenubar.h> 23#include <qmenubar.h>
24#include <qtoolbar.h> 24#include <qtoolbar.h>
25#include <qmessagebox.h> 25#include <qmessagebox.h>
26#include <qwhatsthis.h> 26#include <qwhatsthis.h>
27#include <qfileinfo.h> 27#include <qfileinfo.h>
28 28
29/* STD */ 29/* STD */
30#include <assert.h> 30#include <assert.h>
31 31
32#ifdef EAST
33#include <opie2/oconfig.h>
34#endif
35
32MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { 36MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) {
33 37
34#ifdef FSCKED_DISTRI 38#ifdef FSCKED_DISTRI
35 FixIt fix; 39 FixIt fix;
36 fix.fixIt(); 40 fix.fixIt();
37#endif 41#endif
38 42
39 setCaption(QObject::tr("Opie Console") ); 43 setCaption(QObject::tr("Opie Console") );
40 KeyTrans::loadAll(); 44 KeyTrans::loadAll();
41 for (int i = 0; i < KeyTrans::count(); i++ ) { 45 for (int i = 0; i < KeyTrans::count(); i++ ) {
42 KeyTrans* s = KeyTrans::find(i ); 46 KeyTrans* s = KeyTrans::find(i );
43 assert( s ); 47 assert( s );
44 } 48 }
45 m_factory = new MetaFactory(); 49 m_factory = new MetaFactory();
46 Default def(m_factory); 50 Default def(m_factory);
47 m_sessions.setAutoDelete( TRUE ); 51 m_sessions.setAutoDelete( TRUE );
48 m_curSession = 0; 52 m_curSession = 0;
49 m_manager = new ProfileManager( m_factory ); 53 m_manager = new ProfileManager( m_factory );
50 m_manager->load(); 54 m_manager->load();
51 m_scriptsData.setAutoDelete(TRUE); 55 m_scriptsData.setAutoDelete(TRUE);
52 56
53 initUI(); 57 initUI();
54 populateProfiles(); 58 populateProfiles();
55 populateScripts(); 59 populateScripts();
56} 60}
57 61
58void MainWindow::initUI() { 62void MainWindow::initUI() {
59 63
60 setToolBarsMovable( FALSE ); 64 setToolBarsMovable( FALSE );
61 65
62 /* tool bar for the menu */ 66 /* tool bar for the menu */
63 m_tool = new QToolBar( this ); 67 m_tool = new QToolBar( this );
64 m_tool->setHorizontalStretchable( TRUE ); 68 m_tool->setHorizontalStretchable( TRUE );
65 69
66 m_bar = new QMenuBar( m_tool ); 70 m_bar = new QMenuBar( m_tool );
67 m_console = new QPopupMenu( this ); 71 m_console = new QPopupMenu( this );
68 m_scripts = new QPopupMenu( this ); 72 m_scripts = new QPopupMenu( this );
69 m_sessionsPop= new QPopupMenu( this ); 73 m_sessionsPop= new QPopupMenu( this );
70 m_scriptsPop = new QPopupMenu( this ); 74 m_scriptsPop = new QPopupMenu( this );
71 75
72 /* add a toolbar for icons */ 76 /* add a toolbar for icons */
73 m_icons = new QToolBar(this); 77 m_icons = new QToolBar(this);
74 78
75 /* 79 /*
76 * the settings action 80 * the settings action
77 */ 81 */
78 m_setProfiles = new QAction(tr("Configure Profiles"), 82 m_setProfiles = new QAction(tr("Configure Profiles"),
79 Resource::loadPixmap( "SettingsIcon" ), 83 Resource::loadPixmap( "SettingsIcon" ),
80 QString::null, 0, this, 0); 84 QString::null, 0, this, 0);
81 m_setProfiles->addTo( m_console ); 85 m_setProfiles->addTo( m_console );
82 connect( m_setProfiles, SIGNAL(activated() ), 86 connect( m_setProfiles, SIGNAL(activated() ),
83 this, SLOT(slotConfigure() ) ); 87 this, SLOT(slotConfigure() ) );
84 88
85 m_console->insertSeparator(); 89 m_console->insertSeparator();
86 /* 90 /*
87 * new Action for new sessions 91 * new Action for new sessions
88 */ 92 */
89 QAction* newCon = new QAction(tr("New Profile"), 93 QAction* newCon = new QAction(tr("New Profile"),
90 Resource::loadPixmap( "new" ), 94 Resource::loadPixmap( "new" ),
91 QString::null, 0, this, 0); 95 QString::null, 0, this, 0);
92 newCon->addTo( m_console ); 96 newCon->addTo( m_console );
93 connect( newCon, SIGNAL(activated() ), 97 connect( newCon, SIGNAL(activated() ),
94 this, SLOT(slotNew() ) ); 98 this, SLOT(slotNew() ) );
95 99
96 m_console->insertSeparator(); 100 m_console->insertSeparator();
97 101
98 QAction *saveCon = new QAction( tr("Save Profile" ), 102 QAction *saveCon = new QAction( tr("Save Profile" ),
99 Resource::loadPixmap( "save" ), QString::null, 103 Resource::loadPixmap( "save" ), QString::null,
100 0, this, 0 ); 104 0, this, 0 );
101 saveCon->addTo( m_console ); 105 saveCon->addTo( m_console );
102 connect( saveCon, SIGNAL(activated() ), 106 connect( saveCon, SIGNAL(activated() ),
103 this, SLOT(slotSaveSession() ) ); 107 this, SLOT(slotSaveSession() ) );
104 m_console->insertSeparator(); 108 m_console->insertSeparator();
105 109
106 /* 110 /*
107 * connect action 111 * connect action
108 */ 112 */
109 m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), 113 m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"),
110 QString::null, 0, this, 0 ); 114 QString::null, 0, this, 0 );
111 m_connect->addTo( m_console ); 115 m_connect->addTo( m_console );
112 connect(m_connect, SIGNAL(activated() ), 116 connect(m_connect, SIGNAL(activated() ),
113 this, SLOT(slotConnect() ) ); 117 this, SLOT(slotConnect() ) );
114 118
115 /* 119 /*
116 * disconnect action 120 * disconnect action
117 */ 121 */
118 m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), 122 m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"),
119 QString::null, 0, this, 0 ); 123 QString::null, 0, this, 0 );
120 m_disconnect->addTo( m_console ); 124 m_disconnect->addTo( m_console );
121 connect(m_disconnect, SIGNAL(activated() ), 125 connect(m_disconnect, SIGNAL(activated() ),
122 this, SLOT(slotDisconnect() ) ); 126 this, SLOT(slotDisconnect() ) );
123 127
124 m_console->insertSeparator(); 128 m_console->insertSeparator();
125 129
126#ifndef EAST 130#ifndef EAST
127 m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 ); 131 m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 );
128 m_quickLaunch->addTo( m_icons ); 132 m_quickLaunch->addTo( m_icons );
129 connect( m_quickLaunch, SIGNAL( activated() ), 133 connect( m_quickLaunch, SIGNAL( activated() ),
130 this, SLOT( slotQuickLaunch() ) ); 134 this, SLOT( slotQuickLaunch() ) );
131#endif 135#endif
132 136
133 QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) ); 137 QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) );
134 138
135 m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, 139 m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null,
136 0, this, 0 ); 140 0, this, 0 );
137 m_transfer->addTo( m_console ); 141 m_transfer->addTo( m_console );
138 connect(m_transfer, SIGNAL(activated() ), 142 connect(m_transfer, SIGNAL(activated() ),
139 this, SLOT(slotTransfer() ) ); 143 this, SLOT(slotTransfer() ) );
140 144
141 145
142 146
143 /* 147 /*
144 * immediate change of line wrap policy 148 * immediate change of line wrap policy
145 */ 149 */
146 m_isWrapped = true; 150 m_isWrapped = true;
147 m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0, true ); 151 m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0, true );
148 m_wrap->addTo( m_console ); 152 m_wrap->addTo( m_console );
149 m_wrap->setOn( true ); 153 m_wrap->setOn( true );
150 connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); 154 connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) );
151 155
152 /* 156 /*
153 * fullscreen 157 * fullscreen
154 */ 158 */
155 m_isFullscreen = false; 159 m_isFullscreen = false;
156 160
157 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) 161 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" )
158 , QString::null, 0, this, 0 ); 162 , QString::null, 0, this, 0 );
159 m_fullscreen->addTo( m_console ); 163 m_fullscreen->addTo( m_console );
160 connect( m_fullscreen, SIGNAL( activated() ), 164 connect( m_fullscreen, SIGNAL( activated() ),
161 this, SLOT( slotFullscreen() ) ); 165 this, SLOT( slotFullscreen() ) );
162 166
163 m_console->insertSeparator(); 167 m_console->insertSeparator();
164 168
165 m_recordLog = new QAction(); 169 m_recordLog = new QAction();
166 m_recordLog->setText( tr("Start log") ); 170 m_recordLog->setText( tr("Start log") );
167 m_recordLog->addTo( m_console ); 171 m_recordLog->addTo( m_console );
168 connect(m_recordLog, SIGNAL(activated() ), 172 connect(m_recordLog, SIGNAL(activated() ),
169 this, SLOT( slotSaveLog() ) ); 173 this, SLOT( slotSaveLog() ) );
170 m_recordingLog = false; 174 m_recordingLog = false;
171 175
172 QAction *a = new QAction(); 176 QAction *a = new QAction();
173 a->setText( tr("Save history") ); 177 a->setText( tr("Save history") );
174 a->addTo( m_console ); 178 a->addTo( m_console );
175 connect(a, SIGNAL(activated() ), 179 connect(a, SIGNAL(activated() ),
176 this, SLOT(slotSaveHistory() ) ); 180 this, SLOT(slotSaveHistory() ) );
177 /* 181 /*
178 * terminate action 182 * terminate action
179 */ 183 */
180 m_terminate = new QAction(); 184 m_terminate = new QAction();
181 m_terminate->setText( tr("Terminate") ); 185 m_terminate->setText( tr("Terminate") );
182 m_terminate->addTo( m_console ); 186 m_terminate->addTo( m_console );
183 connect(m_terminate, SIGNAL(activated() ), 187 connect(m_terminate, SIGNAL(activated() ),
184 this, SLOT(slotTerminate() ) ); 188 this, SLOT(slotTerminate() ) );
185 189
186 m_closewindow = new QAction(); 190 m_closewindow = new QAction();
187 m_closewindow->setText( tr("Close Window") ); 191 m_closewindow->setText( tr("Close Window") );
188 m_closewindow->addTo( m_console ); 192 m_closewindow->addTo( m_console );
189 connect( m_closewindow, SIGNAL(activated() ), 193 connect( m_closewindow, SIGNAL(activated() ),
190 this, SLOT(slotClose() ) ); 194 this, SLOT(slotClose() ) );
191 195
192 196
193 /* 197 /*
194 * script actions 198 * script actions
195 */ 199 */
196 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); 200 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0);
197 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); 201 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int)));
198 202
199 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); 203 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
200 m_recordScript->addTo(m_scripts); 204 m_recordScript->addTo(m_scripts);
201 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); 205 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript()));
202 206
203 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); 207 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0);
204 m_saveScript->addTo(m_scripts); 208 m_saveScript->addTo(m_scripts);
205 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); 209 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript()));
206 210
207 211
212
213
208 /* 214 /*
209 * action that open/closes the keyboard 215 * action that open/closes the keyboard
210 */ 216 */
211 m_openKeys = new QAction (tr("Open Keyboard..."), 217 m_openKeys = new QAction (tr("Open Keyboard..."),
212 Resource::loadPixmap( "console/keys/keyboard_icon" ), 218 Resource::loadPixmap( "console/keys/keyboard_icon" ),
213 QString::null, 0, this, 0); 219 QString::null, 0, this, 0);
214 m_openKeys->setToggleAction(true); 220 m_openKeys->setToggleAction(true);
215 connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); 221 connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool)));
216 222
217 /* insert the submenu */ 223 /* insert the submenu */
218 m_console->insertItem(tr("New from Profile"), m_sessionsPop, 224 m_console->insertItem(tr("New from Profile"), m_sessionsPop,
219 -1, 0); 225 -1, 0);
220 226
221 /* insert the connection menu */ 227 /* insert the connection menu */
222 m_bar->insertItem( tr("Connection"), m_console ); 228 m_bar->insertItem( tr("Connection"), m_console );
223 229
224 /* the scripts menu */ 230 /* the scripts menu */
225 m_bar->insertItem( tr("Scripts"), m_scripts ); 231 #ifdef EAST
232 OConfig cfg("opie-console");
233 cfg.setGroup("10east");
234 if( !cfg.readEntry("scripthide",0) ) {
235 m_bar->insertItem( tr("Scripts"), m_scripts );
236 }
237 #endif
226 238
227 /* and the keyboard */ 239 /* and the keyboard */
228 m_keyBar = new QToolBar(this); 240 m_keyBar = new QToolBar(this);
229 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); 241 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE );
230 m_keyBar->setHorizontalStretchable( TRUE ); 242 m_keyBar->setHorizontalStretchable( TRUE );
231 m_keyBar->hide(); 243 m_keyBar->hide();
232 244
233 m_kb = new FunctionKeyboard(m_keyBar); 245 m_kb = new FunctionKeyboard(m_keyBar);
234 connect(m_kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)), 246 connect(m_kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)),
235 this, SLOT(slotKeyReceived(FKey,ushort,ushort,bool))); 247 this, SLOT(slotKeyReceived(FKey,ushort,ushort,bool)));
236 248
237 249
238 a = new QAction(tr("Copy"), 250 a = new QAction(tr("Copy"),
239 Resource::loadPixmap("copy"), QString::null, 251 Resource::loadPixmap("copy"), QString::null,
240 0, this, 0 ); 252 0, this, 0 );
241 //a->addTo( m_icons ); 253 //a->addTo( m_icons );
242 connect( a, SIGNAL(activated() ), 254 connect( a, SIGNAL(activated() ),
243 this, SLOT(slotCopy() ) ); 255 this, SLOT(slotCopy() ) );
244 256
245 QAction *paste = new QAction(tr("Paste"), 257 QAction *paste = new QAction(tr("Paste"),
246 Resource::loadPixmap("paste"), QString::null, 258 Resource::loadPixmap("paste"), QString::null,
247 0, this, 0 ); 259 0, this, 0 );
248 connect( paste, SIGNAL(activated() ), 260 connect( paste, SIGNAL(activated() ),
249 this, SLOT(slotPaste() ) ); 261 this, SLOT(slotPaste() ) );
250 262
251 263
252 newCon->addTo( m_icons ); 264 newCon->addTo( m_icons );
253 //m_setProfiles->addTo( m_icons ); 265 //m_setProfiles->addTo( m_icons );
254 paste->addTo( m_icons ); 266 paste->addTo( m_icons );
255 m_openKeys->addTo(m_icons); 267 m_openKeys->addTo(m_icons);
256 m_fullscreen->addTo( m_icons ); 268 m_fullscreen->addTo( m_icons );
257 269
258 m_connect->setEnabled( false ); 270 m_connect->setEnabled( false );
259 m_disconnect->setEnabled( false ); 271 m_disconnect->setEnabled( false );
260 m_terminate->setEnabled( false ); 272 m_terminate->setEnabled( false );
261 m_transfer->setEnabled( false ); 273 m_transfer->setEnabled( false );
262 m_scripts->setItemEnabled(m_runScript_id, false); 274 m_scripts->setItemEnabled(m_runScript_id, false);
263 m_recordScript->setEnabled( false ); 275 m_recordScript->setEnabled( false );
264 m_saveScript->setEnabled( false ); 276 m_saveScript->setEnabled( false );
265 m_fullscreen->setEnabled( false ); 277 m_fullscreen->setEnabled( false );
266 m_closewindow->setEnabled( false ); 278 m_closewindow->setEnabled( false );
267 m_wrap->setEnabled( false ); 279 m_wrap->setEnabled( false );
268 280
269 /* 281 /*
270 * connect to the menu activation 282 * connect to the menu activation
271 */ 283 */
272 connect( m_sessionsPop, SIGNAL(activated(int) ), 284 connect( m_sessionsPop, SIGNAL(activated(int) ),
273 this, SLOT(slotProfile(int) ) ); 285 this, SLOT(slotProfile(int) ) );
274 286
275 m_consoleWindow = new TabWidget( this, "blah"); 287 m_consoleWindow = new TabWidget( this, "blah");
276 connect(m_consoleWindow, SIGNAL(activated(Session*) ), 288 connect(m_consoleWindow, SIGNAL(activated(Session*) ),
277 this, SLOT(slotSessionChanged(Session*) ) ); 289 this, SLOT(slotSessionChanged(Session*) ) );
278 setCentralWidget( m_consoleWindow ); 290 setCentralWidget( m_consoleWindow );
279 291
280 slotQuickLaunch(); 292 slotQuickLaunch();
281} 293}
282 294
283ProfileManager* MainWindow::manager() { 295ProfileManager* MainWindow::manager() {
284 return m_manager; 296 return m_manager;
285} 297}
286TabWidget* MainWindow::tabWidget() { 298TabWidget* MainWindow::tabWidget() {
287 return m_consoleWindow; 299 return m_consoleWindow;
288} 300}
289void MainWindow::populateProfiles() { 301void MainWindow::populateProfiles() {
290 m_sessionsPop->clear(); 302 m_sessionsPop->clear();
291 Profile::ValueList list = manager()->all(); 303 Profile::ValueList list = manager()->all();
292 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { 304 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) {
293 m_sessionsPop->insertItem( (*it).name() ); 305 m_sessionsPop->insertItem( (*it).name() );
294 } 306 }
295 307
296} 308}
297 309
298void MainWindow::populateScripts() { 310void MainWindow::populateScripts() {
299 m_scriptsPop->clear(); 311 m_scriptsPop->clear();
300 m_scriptsData.clear(); 312 m_scriptsData.clear();
301 DocLnkSet files(QPEApplication::documentDir(), "text/plain"); 313 DocLnkSet files(QPEApplication::documentDir(), "text/plain");
302 QListIterator<DocLnk> dit(files.children()); 314 QListIterator<DocLnk> dit(files.children());
303 for (; dit.current(); ++dit) { 315 for (; dit.current(); ++dit) {
304 if (*dit && (*dit)->name().length()>0) { 316 if (*dit && (*dit)->name().length()>0) {
305 QFileInfo info((*dit)->file()); 317 QFileInfo info((*dit)->file());
306 if (info.extension(false) == "script") { 318 if (info.extension(false) == "script") {
307 m_scriptsData.append(new DocLnk(**dit)); 319 m_scriptsData.append(new DocLnk(**dit));
308 m_scriptsPop->insertItem((*dit)->name()); 320 m_scriptsPop->insertItem((*dit)->name());
309 } 321 }
310 } 322 }
311 } 323 }
312 324
313} 325}
314 326
315MainWindow::~MainWindow() { 327MainWindow::~MainWindow() {
316 delete m_factory; 328 delete m_factory;
317 manager()->save(); 329 manager()->save();
318#ifdef FSCKED_DISTRI 330#ifdef FSCKED_DISTRI
319 FixIt fix; 331 FixIt fix;
320 fix.breakIt(); 332 fix.breakIt();
321#endif 333#endif
322} 334}
323 335
324MetaFactory* MainWindow::factory() { 336MetaFactory* MainWindow::factory() {
325 return m_factory; 337 return m_factory;
326} 338}
327 339
328Session* MainWindow::currentSession() { 340Session* MainWindow::currentSession() {
329 return m_curSession; 341 return m_curSession;
330} 342}
331 343
332QList<Session> MainWindow::sessions() { 344QList<Session> MainWindow::sessions() {
333 return m_sessions; 345 return m_sessions;
334} 346}
335 347
336void MainWindow::slotNew() { 348void MainWindow::slotNew() {
337 ProfileEditorDialog dlg(factory() ); 349 ProfileEditorDialog dlg(factory() );
338 dlg.setCaption( tr("New Connection") ); 350 dlg.setCaption( tr("New Connection") );
339 int ret = QPEApplication::execDialog( &dlg ); 351 int ret = QPEApplication::execDialog( &dlg );
340 352
341 if ( ret == QDialog::Accepted ) { 353 if ( ret == QDialog::Accepted ) {
342 create( dlg.profile() ); 354 create( dlg.profile() );
343 } 355 }
344} 356}
345 357
346void MainWindow::slotRecordScript() { 358void MainWindow::slotRecordScript() {
347 if (currentSession()) { 359 if (currentSession()) {
348 currentSession()->emulationHandler()->startRecording(); 360 currentSession()->emulationHandler()->startRecording();
349 m_saveScript->setEnabled(true); 361 m_saveScript->setEnabled(true);
350 m_recordScript->setEnabled(false); 362 m_recordScript->setEnabled(false);
351 } 363 }
352} 364}
353 365
354void MainWindow::slotSaveScript() { 366void MainWindow::slotSaveScript() {
355 if (currentSession() && currentSession()->emulationHandler()->isRecording()) { 367 if (currentSession() && currentSession()->emulationHandler()->isRecording()) {
356 QMap<QString, QStringList> map; 368 QMap<QString, QStringList> map;
357 QStringList text; 369 QStringList text;
358 text << "text/plain"; 370 text << "text/plain";
359 map.insert(tr("Script"), text ); 371 map.insert(tr("Script"), text );
360 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); 372 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
361 if (!filename.isEmpty()) { 373 if (!filename.isEmpty()) {
362 QFileInfo info(filename); 374 QFileInfo info(filename);
363 if (info.extension(FALSE) != "script") 375 if (info.extension(FALSE) != "script")
364 filename += ".script"; 376 filename += ".script";
365 DocLnk nf; 377 DocLnk nf;
366 nf.setType("text/plain"); 378 nf.setType("text/plain");
367 nf.setFile(filename); 379 nf.setFile(filename);
368 nf.setName(info.fileName()); 380 nf.setName(info.fileName());
369 FileManager fm; 381 FileManager fm;
370 fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); 382 fm.saveFile(nf, currentSession()->emulationHandler()->script()->script());
371 currentSession()->emulationHandler()->clearScript(); 383 currentSession()->emulationHandler()->clearScript();
372 m_saveScript->setEnabled(false); 384 m_saveScript->setEnabled(false);
373 m_recordScript->setEnabled(true); 385 m_recordScript->setEnabled(true);
374 populateScripts(); 386 populateScripts();
375 } 387 }
376 } 388 }
377} 389}
378 390
379void MainWindow::slotRunScript(int id) { 391void MainWindow::slotRunScript(int id) {
380 if (currentSession()) { 392 if (currentSession()) {
381 int index = m_scriptsPop->indexOf(id); 393 int index = m_scriptsPop->indexOf(id);
382 DocLnk *lnk = m_scriptsData.at(index); 394 DocLnk *lnk = m_scriptsData.at(index);
383 QString filePath = lnk->file(); 395 QString filePath = lnk->file();
384 Script script(filePath); 396 Script script(filePath);
385 currentSession()->emulationHandler()->runScript(&script); 397 currentSession()->emulationHandler()->runScript(&script);
386 } 398 }
387} 399}
388 400
389void MainWindow::slotConnect() { 401void MainWindow::slotConnect() {
390 if ( currentSession() ) { 402 if ( currentSession() ) {
391 bool ret = currentSession()->layer()->open(); 403 bool ret = currentSession()->layer()->open();
392 if(!ret) QMessageBox::warning(currentSession()->widgetStack(), 404 if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
393 QObject::tr("Failed"), 405 QObject::tr("Failed"),
394 QObject::tr("Connecting failed for this session.")); 406 QObject::tr("Connecting failed for this session."));
395 else { 407 else {
396 m_connect->setEnabled( false ); 408 m_connect->setEnabled( false );
397 m_disconnect->setEnabled( true ); 409 m_disconnect->setEnabled( true );
398 410
399 // if it does not support file transfer, disable the menu entry 411 // if it does not support file transfer, disable the menu entry
400 if ( ( m_curSession->layer() )->supports()[1] == 0 ) { 412 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
401 m_transfer->setEnabled( false ); 413 m_transfer->setEnabled( false );
402 } else { 414 } else {
403 m_transfer->setEnabled( true ); 415 m_transfer->setEnabled( true );
404 } 416 }
405 417
406 m_recordScript->setEnabled( true ); 418 m_recordScript->setEnabled( true );
407 m_scripts->setItemEnabled(m_runScript_id, true); 419 m_scripts->setItemEnabled(m_runScript_id, true);
408 } 420 }
409 } 421 }
410} 422}
411 423
412void MainWindow::slotDisconnect() { 424void MainWindow::slotDisconnect() {
413 if ( currentSession() ) { 425 if ( currentSession() ) {
414 currentSession()->layer()->close(); 426 currentSession()->layer()->close();
415 m_connect->setEnabled( true ); 427 m_connect->setEnabled( true );
416 m_disconnect->setEnabled( false ); 428 m_disconnect->setEnabled( false );
417 m_transfer->setEnabled( false ); 429 m_transfer->setEnabled( false );
418 m_recordScript->setEnabled( false); 430 m_recordScript->setEnabled( false);
419 m_saveScript->setEnabled( false ); 431 m_saveScript->setEnabled( false );
420 m_scripts->setItemEnabled(m_runScript_id, false); 432 m_scripts->setItemEnabled(m_runScript_id, false);
421 } 433 }
422} 434}
423 435
424void MainWindow::slotTerminate() { 436void MainWindow::slotTerminate() {
425 if ( currentSession() ) 437 if ( currentSession() )
426 currentSession()->layer()->close(); 438 currentSession()->layer()->close();
427 439
428 slotClose(); 440 slotClose();
429 /* FIXME move to the next session */ 441 /* FIXME move to the next session */
430} 442}
431 443
432 444
433 445
434void MainWindow::slotQuickLaunch() { 446void MainWindow::slotQuickLaunch() {
435 447
436 Profile prof = manager()->profile( "default" ); 448 Profile prof = manager()->profile( "default" );
437 if ( prof.name() == "default" ) { 449 if ( prof.name() == "default" ) {
438 create( prof ); 450 create( prof );
439 } else { 451 } else {
440 #ifndef EAST 452 #ifndef EAST
441 Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 ); 453 Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 );
442 newProf.setAutoConnect( true ); 454 newProf.setAutoConnect( true );
443 create( newProf ); 455 create( newProf );
444 slotSaveSession(); 456 slotSaveSession();
445 #endif 457 #endif
446 } 458 }
447} 459}
448 460
449void MainWindow::slotConfigure() { 461void MainWindow::slotConfigure() {
450 ConfigDialog conf( manager()->all(), factory() ); 462 ConfigDialog conf( manager()->all(), factory() );
451 463
452 int ret = QPEApplication::execDialog( &conf ); 464 int ret = QPEApplication::execDialog( &conf );
453 465
454 if ( QDialog::Accepted == ret ) { 466 if ( QDialog::Accepted == ret ) {
455 manager()->setProfiles( conf.list() ); 467 manager()->setProfiles( conf.list() );
456 manager()->save(); 468 manager()->save();
457 populateProfiles(); 469 populateProfiles();
458 } 470 }
459} 471}
460/* 472/*
461 * we will remove 473 * we will remove
462 * this window from the tabwidget 474 * this window from the tabwidget
463 * remove it from the list 475 * remove it from the list
464 * delete it 476 * delete it
465 * and set the currentSession() 477 * and set the currentSession()
466 */ 478 */
467void MainWindow::slotClose() { 479void MainWindow::slotClose() {
468 if (!currentSession() ) 480 if (!currentSession() )
469 return; 481 return;
470 482
471 Session* ses = currentSession(); 483 Session* ses = currentSession();
472 owarn << "removing! currentSession " << currentSession()->name().latin1() << "" << oendl; 484 owarn << "removing! currentSession " << currentSession()->name().latin1() << "" << oendl;
473 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ 485 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */
474 m_curSession = NULL; 486 m_curSession = NULL;
475 tabWidget()->remove( /*currentSession()*/ses ); 487 tabWidget()->remove( /*currentSession()*/ses );
476 /*it's autodelete */ 488 /*it's autodelete */
477 m_sessions.remove( ses ); 489 m_sessions.remove( ses );
478 owarn << "after remove!!" << oendl; 490 owarn << "after remove!!" << oendl;
479 491
480 if (!currentSession() ) { 492 if (!currentSession() ) {
481 m_connect->setEnabled( false ); 493 m_connect->setEnabled( false );
482 m_disconnect->setEnabled( false ); 494 m_disconnect->setEnabled( false );
483 m_terminate->setEnabled( false ); 495 m_terminate->setEnabled( false );
484 m_transfer->setEnabled( false ); 496 m_transfer->setEnabled( false );
485 m_recordScript->setEnabled( false ); 497 m_recordScript->setEnabled( false );
486 m_saveScript->setEnabled( false ); 498 m_saveScript->setEnabled( false );
487 m_scripts->setItemEnabled(m_runScript_id, false); 499 m_scripts->setItemEnabled(m_runScript_id, false);
488 m_fullscreen->setEnabled( false ); 500 m_fullscreen->setEnabled( false );
489 m_wrap->setEnabled( false ); 501 m_wrap->setEnabled( false );
490 m_closewindow->setEnabled( false ); 502 m_closewindow->setEnabled( false );
491 } 503 }
492 504
493 m_kb->loadDefaults(); 505 m_kb->loadDefaults();
494} 506}
495 507
496/* 508/*
497 * We will get the name 509 * We will get the name
498 * Then the profile 510 * Then the profile
499 * and then we will make a profile 511 * and then we will make a profile
500 */ 512 */
501void MainWindow::slotProfile( int id) { 513void MainWindow::slotProfile( int id) {
502 Profile prof = manager()->profile( m_sessionsPop->text( id) ); 514 Profile prof = manager()->profile( m_sessionsPop->text( id) );
503 create( prof ); 515 create( prof );
504} 516}
505 517
506 518
507 519
508void MainWindow::create( const Profile& prof ) { 520void MainWindow::create( const Profile& prof ) {
509 if(m_curSession) 521 if(m_curSession)
510 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); 522 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
511 523
512 Session *ses = manager()->fromProfile( prof, tabWidget() ); 524 Session *ses = manager()->fromProfile( prof, tabWidget() );
513 525
514 if((!ses) || (!ses->layer()) || (!ses->widgetStack())) 526 if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
515 { 527 {
516 QMessageBox::warning(this, 528 QMessageBox::warning(this,
517 QObject::tr("Session failed"), 529 QObject::tr("Session failed"),
518 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); 530 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>"));
519 //if(ses) delete ses; 531 //if(ses) delete ses;
520 return; 532 return;
521 } 533 }
522 534
523 m_sessions.append( ses ); 535 m_sessions.append( ses );
524 tabWidget()->add( ses ); 536 tabWidget()->add( ses );
525 tabWidget()->repaint(); 537 tabWidget()->repaint();
526 m_curSession = ses; 538 m_curSession = ses;
527 539
528 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it 540 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it
529 m_connect->setEnabled( true ); 541 m_connect->setEnabled( true );
530 m_disconnect->setEnabled( false ); 542 m_disconnect->setEnabled( false );
531 m_terminate->setEnabled( true ); 543 m_terminate->setEnabled( true );
532 m_fullscreen->setEnabled( true ); 544 m_fullscreen->setEnabled( true );
533 m_wrap->setEnabled( true ); 545 m_wrap->setEnabled( true );
534 m_closewindow->setEnabled( true ); 546 m_closewindow->setEnabled( true );
535 m_transfer->setEnabled( false ); 547 m_transfer->setEnabled( false );
536 m_recordScript->setEnabled( false ); 548 m_recordScript->setEnabled( false );
537 m_saveScript->setEnabled( false ); 549 m_saveScript->setEnabled( false );
538 m_scripts->setItemEnabled(m_runScript_id, false); 550 m_scripts->setItemEnabled(m_runScript_id, false);
539 551
540 // is io_layer wants direct connection, then autoconnect 552 // is io_layer wants direct connection, then autoconnect
541 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { 553 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) {
542 if (prof.autoConnect()) { 554 if (prof.autoConnect()) {
543 slotConnect(); 555 slotConnect();
544 } 556 }
545 557
546 QWidget *w = currentSession()->widget(); 558 QWidget *w = currentSession()->widget();
547 if(w) w->setFocus(); 559 if(w) w->setFocus();
548 560
549 if(currentSession()->profile().readNumEntry("Wrap", 80)){ 561 if(currentSession()->profile().readNumEntry("Wrap", 80)){
550 m_isWrapped = true; 562 m_isWrapped = true;
551 } else { 563 } else {
552 m_isWrapped = false; 564 m_isWrapped = false;
553 } 565 }
554 566
555 m_kb->load(currentSession()->profile()); 567 m_kb->load(currentSession()->profile());
556} 568}
557 569
558void MainWindow::slotTransfer() 570void MainWindow::slotTransfer()
559{ 571{
560 if ( currentSession() ) { 572 if ( currentSession() ) {
561 Session *mysession = currentSession(); 573 Session *mysession = currentSession();
562 TransferDialog dlg(/*mysession->widgetStack()*/this, this); 574 TransferDialog dlg(/*mysession->widgetStack()*/this, this);
563 mysession->setTransferDialog(&dlg); 575 mysession->setTransferDialog(&dlg);
564 //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); 576 //dlg.reparent(mysession->widgetStack(), QPoint(0, 0));
565 //dlg.showMaximized(); 577 //dlg.showMaximized();
566 currentSession()->widgetStack()->addWidget(&dlg, -1); 578 currentSession()->widgetStack()->addWidget(&dlg, -1);
567 dlg.show(); 579 dlg.show();
568 //dlg.exec(); 580 //dlg.exec();
569 while(dlg.isRunning()) qApp->processEvents(); 581 while(dlg.isRunning()) qApp->processEvents();
570 mysession->setTransferDialog(0l); 582 mysession->setTransferDialog(0l);
571 } 583 }
572} 584}
573 585
574 586
575void MainWindow::slotOpenKeb(bool state) { 587void MainWindow::slotOpenKeb(bool state) {
576 588
577 if (state) m_keyBar->show(); 589 if (state) m_keyBar->show();
578 else m_keyBar->hide(); 590 else m_keyBar->hide();
579 591
580} 592}
581 593
582 594
583void MainWindow::slotOpenButtons( bool state ) { 595void MainWindow::slotOpenButtons( bool state ) {
584 596
585 if ( state ) { 597 if ( state ) {
586 m_buttonBar->show(); 598 m_buttonBar->show();
587 } else { 599 } else {
588 m_buttonBar->hide(); 600 m_buttonBar->hide();
589 } 601 }
590} 602}
591 603
592 604
593 605
594void MainWindow::slotSessionChanged( Session* ses ) { 606void MainWindow::slotSessionChanged( Session* ses ) {
595 owarn << "changed!" << oendl; 607 owarn << "changed!" << oendl;
596 608
597 if(m_curSession) 609 if(m_curSession)
598 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); 610 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
599 if(ses) 611 if(ses)
600 if(ses->transferDialog()) ses->transferDialog()->show(); 612 if(ses->transferDialog()) ses->transferDialog()->show();
601 613
602 if ( ses ) { 614 if ( ses ) {
603 m_curSession = ses; 615 m_curSession = ses;
604 odebug << QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) << oendl; 616 odebug << QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) << oendl;
605 if ( m_curSession->layer()->isConnected() ) { 617 if ( m_curSession->layer()->isConnected() ) {
606 m_connect->setEnabled( false ); 618 m_connect->setEnabled( false );
607 m_disconnect->setEnabled( true ); 619 m_disconnect->setEnabled( true );
608 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); 620 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording());
609 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); 621 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording());