summaryrefslogtreecommitdiff
authorharlekin <harlekin>2005-01-11 16:03:50 (UTC)
committer harlekin <harlekin>2005-01-11 16:03:50 (UTC)
commit1833a9079cd7801f333ac3885b447520e44f937f (patch) (unidiff)
tree4ba1b030a3747b1f22d08a9f0ea55bfb59940761
parent4c4cdd76caea5a8be4a971892375c7c6b4f4a8b9 (diff)
downloadopie-1833a9079cd7801f333ac3885b447520e44f937f.zip
opie-1833a9079cd7801f333ac3885b447520e44f937f.tar.gz
opie-1833a9079cd7801f333ac3885b447520e44f937f.tar.bz2
possibility to set a default path for the save log dialog and also set the initial path into the titelbar
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 9b615f1..21de5c0 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,783 +1,784 @@
1#include "TEmulation.h" 1#include "TEmulation.h"
2#include "profileeditordialog.h" 2#include "profileeditordialog.h"
3#include "configdialog.h" 3#include "configdialog.h"
4#include "default.h" 4#include "default.h"
5#include "profilemanager.h" 5#include "profilemanager.h"
6#include "mainwindow.h" 6#include "mainwindow.h"
7#include "tabwidget.h" 7#include "tabwidget.h"
8#include "transferdialog.h" 8#include "transferdialog.h"
9#include "function_keyboard.h" 9#include "function_keyboard.h"
10#include "emulation_handler.h" 10#include "emulation_handler.h"
11#include "script.h" 11#include "script.h"
12#include "fixit.h" 12#include "fixit.h"
13 13
14/* OPIE */ 14/* OPIE */
15#include <opie2/ofiledialog.h> 15#include <opie2/ofiledialog.h>
16#include <qpe/filemanager.h> 16#include <qpe/filemanager.h>
17using namespace Opie::Ui; 17using namespace Opie::Ui;
18 18
19/* QT */ 19/* QT */
20#include <qaction.h> 20#include <qaction.h>
21#include <qmenubar.h> 21#include <qmenubar.h>
22#include <qtoolbar.h> 22#include <qtoolbar.h>
23#include <qmessagebox.h> 23#include <qmessagebox.h>
24#include <qwhatsthis.h> 24#include <qwhatsthis.h>
25#include <qfileinfo.h> 25#include <qfileinfo.h>
26 26
27/* STD */ 27/* STD */
28#include <assert.h> 28#include <assert.h>
29 29
30#ifdef EAST
31#include <opie2/oconfig.h> 30#include <opie2/oconfig.h>
32#endif
33 31
34MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { 32MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) {
35 33
36#ifdef FSCKED_DISTRI 34#ifdef FSCKED_DISTRI
37 FixIt fix; 35 FixIt fix;
38 fix.fixIt(); 36 fix.fixIt();
39#endif 37#endif
40 38
41 setCaption(QObject::tr("Opie Console") ); 39 setCaption(QObject::tr("Opie Console") );
42 KeyTrans::loadAll(); 40 KeyTrans::loadAll();
43 for (int i = 0; i < KeyTrans::count(); i++ ) { 41 for (int i = 0; i < KeyTrans::count(); i++ ) {
44 KeyTrans* s = KeyTrans::find(i ); 42 KeyTrans* s = KeyTrans::find(i );
45 assert( s ); 43 assert( s );
46 } 44 }
47 m_factory = new MetaFactory(); 45 m_factory = new MetaFactory();
48 Default def(m_factory); 46 Default def(m_factory);
49 m_sessions.setAutoDelete( TRUE ); 47 m_sessions.setAutoDelete( TRUE );
50 m_curSession = 0; 48 m_curSession = 0;
51 m_manager = new ProfileManager( m_factory ); 49 m_manager = new ProfileManager( m_factory );
52 m_manager->load(); 50 m_manager->load();
53 m_scriptsData.setAutoDelete(TRUE); 51 m_scriptsData.setAutoDelete(TRUE);
54 52
55 initUI(); 53 initUI();
56 populateProfiles(); 54 populateProfiles();
57 populateScripts(); 55 populateScripts();
58} 56}
59 57
60void MainWindow::initUI() { 58void MainWindow::initUI() {
61 59
62 setToolBarsMovable( FALSE ); 60 setToolBarsMovable( FALSE );
63 61
64 /* tool bar for the menu */ 62 /* tool bar for the menu */
65 m_tool = new QToolBar( this ); 63 m_tool = new QToolBar( this );
66 m_tool->setHorizontalStretchable( TRUE ); 64 m_tool->setHorizontalStretchable( TRUE );
67 65
68 m_bar = new QMenuBar( m_tool ); 66 m_bar = new QMenuBar( m_tool );
69 m_console = new QPopupMenu( this ); 67 m_console = new QPopupMenu( this );
70 m_scripts = new QPopupMenu( this ); 68 m_scripts = new QPopupMenu( this );
71 m_sessionsPop= new QPopupMenu( this ); 69 m_sessionsPop= new QPopupMenu( this );
72 m_scriptsPop = new QPopupMenu( this ); 70 m_scriptsPop = new QPopupMenu( this );
73 71
74 /* add a toolbar for icons */ 72 /* add a toolbar for icons */
75 m_icons = new QToolBar(this); 73 m_icons = new QToolBar(this);
76 74
77 /* 75 /*
78 * the settings action 76 * the settings action
79 */ 77 */
80 m_setProfiles = new QAction(tr("Configure Profiles"), 78 m_setProfiles = new QAction(tr("Configure Profiles"),
81 Resource::loadPixmap( "SettingsIcon" ), 79 Resource::loadPixmap( "SettingsIcon" ),
82 QString::null, 0, this, 0); 80 QString::null, 0, this, 0);
83 m_setProfiles->addTo( m_console ); 81 m_setProfiles->addTo( m_console );
84 connect( m_setProfiles, SIGNAL(activated() ), 82 connect( m_setProfiles, SIGNAL(activated() ),
85 this, SLOT(slotConfigure() ) ); 83 this, SLOT(slotConfigure() ) );
86 84
87 m_console->insertSeparator(); 85 m_console->insertSeparator();
88 /* 86 /*
89 * new Action for new sessions 87 * new Action for new sessions
90 */ 88 */
91 QAction* newCon = new QAction(tr("New Profile"), 89 QAction* newCon = new QAction(tr("New Profile"),
92 Resource::loadPixmap( "new" ), 90 Resource::loadPixmap( "new" ),
93 QString::null, 0, this, 0); 91 QString::null, 0, this, 0);
94 newCon->addTo( m_console ); 92 newCon->addTo( m_console );
95 connect( newCon, SIGNAL(activated() ), 93 connect( newCon, SIGNAL(activated() ),
96 this, SLOT(slotNew() ) ); 94 this, SLOT(slotNew() ) );
97 95
98 m_console->insertSeparator(); 96 m_console->insertSeparator();
99 97
100 QAction *saveCon = new QAction( tr("Save Profile" ), 98 QAction *saveCon = new QAction( tr("Save Profile" ),
101 Resource::loadPixmap( "save" ), QString::null, 99 Resource::loadPixmap( "save" ), QString::null,
102 0, this, 0 ); 100 0, this, 0 );
103 saveCon->addTo( m_console ); 101 saveCon->addTo( m_console );
104 connect( saveCon, SIGNAL(activated() ), 102 connect( saveCon, SIGNAL(activated() ),
105 this, SLOT(slotSaveSession() ) ); 103 this, SLOT(slotSaveSession() ) );
106 m_console->insertSeparator(); 104 m_console->insertSeparator();
107 105
108 /* 106 /*
109 * connect action 107 * connect action
110 */ 108 */
111 m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), 109 m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"),
112 QString::null, 0, this, 0 ); 110 QString::null, 0, this, 0 );
113 m_connect->addTo( m_console ); 111 m_connect->addTo( m_console );
114 connect(m_connect, SIGNAL(activated() ), 112 connect(m_connect, SIGNAL(activated() ),
115 this, SLOT(slotConnect() ) ); 113 this, SLOT(slotConnect() ) );
116 114
117 /* 115 /*
118 * disconnect action 116 * disconnect action
119 */ 117 */
120 m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), 118 m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"),
121 QString::null, 0, this, 0 ); 119 QString::null, 0, this, 0 );
122 m_disconnect->addTo( m_console ); 120 m_disconnect->addTo( m_console );
123 connect(m_disconnect, SIGNAL(activated() ), 121 connect(m_disconnect, SIGNAL(activated() ),
124 this, SLOT(slotDisconnect() ) ); 122 this, SLOT(slotDisconnect() ) );
125 123
126 m_console->insertSeparator(); 124 m_console->insertSeparator();
127 125
128#ifndef EAST 126#ifndef EAST
129 m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 ); 127 m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 );
130 m_quickLaunch->addTo( m_icons ); 128 m_quickLaunch->addTo( m_icons );
131 connect( m_quickLaunch, SIGNAL( activated() ), 129 connect( m_quickLaunch, SIGNAL( activated() ),
132 this, SLOT( slotQuickLaunch() ) ); 130 this, SLOT( slotQuickLaunch() ) );
133#endif 131#endif
134 132
135 QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) ); 133 QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) );
136 134
137 m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, 135 m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null,
138 0, this, 0 ); 136 0, this, 0 );
139 m_transfer->addTo( m_console ); 137 m_transfer->addTo( m_console );
140 connect(m_transfer, SIGNAL(activated() ), 138 connect(m_transfer, SIGNAL(activated() ),
141 this, SLOT(slotTransfer() ) ); 139 this, SLOT(slotTransfer() ) );
142 140
143 141
144 142
145 /* 143 /*
146 * immediate change of line wrap policy 144 * immediate change of line wrap policy
147 */ 145 */
148 m_isWrapped = true; 146 m_isWrapped = true;
149 m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0, true ); 147 m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0, true );
150 m_wrap->addTo( m_console ); 148 m_wrap->addTo( m_console );
151 m_wrap->setOn( true ); 149 m_wrap->setOn( true );
152 connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); 150 connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) );
153 151
154 /* 152 /*
155 * fullscreen 153 * fullscreen
156 */ 154 */
157 m_isFullscreen = false; 155 m_isFullscreen = false;
158 156
159 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) 157 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" )
160 , QString::null, 0, this, 0 ); 158 , QString::null, 0, this, 0 );
161 m_fullscreen->addTo( m_console ); 159 m_fullscreen->addTo( m_console );
162 connect( m_fullscreen, SIGNAL( activated() ), 160 connect( m_fullscreen, SIGNAL( activated() ),
163 this, SLOT( slotFullscreen() ) ); 161 this, SLOT( slotFullscreen() ) );
164 162
165 m_console->insertSeparator(); 163 m_console->insertSeparator();
166 164
167 m_recordLog = new QAction(); 165 m_recordLog = new QAction();
168 m_recordLog->setText( tr("Start log") ); 166 m_recordLog->setText( tr("Start log") );
169 m_recordLog->addTo( m_console ); 167 m_recordLog->addTo( m_console );
170 connect(m_recordLog, SIGNAL(activated() ), 168 connect(m_recordLog, SIGNAL(activated() ),
171 this, SLOT( slotSaveLog() ) ); 169 this, SLOT( slotSaveLog() ) );
172 m_recordingLog = false; 170 m_recordingLog = false;
173 171
174 QAction *a = new QAction(); 172 QAction *a = new QAction();
175 a->setText( tr("Save history") ); 173 a->setText( tr("Save history") );
176 a->addTo( m_console ); 174 a->addTo( m_console );
177 connect(a, SIGNAL(activated() ), 175 connect(a, SIGNAL(activated() ),
178 this, SLOT(slotSaveHistory() ) ); 176 this, SLOT(slotSaveHistory() ) );
179 /* 177 /*
180 * terminate action 178 * terminate action
181 */ 179 */
182 m_terminate = new QAction(); 180 m_terminate = new QAction();
183 m_terminate->setText( tr("Terminate") ); 181 m_terminate->setText( tr("Terminate") );
184 m_terminate->addTo( m_console ); 182 m_terminate->addTo( m_console );
185 connect(m_terminate, SIGNAL(activated() ), 183 connect(m_terminate, SIGNAL(activated() ),
186 this, SLOT(slotTerminate() ) ); 184 this, SLOT(slotTerminate() ) );
187 185
188 m_closewindow = new QAction(); 186 m_closewindow = new QAction();
189 m_closewindow->setText( tr("Close Window") ); 187 m_closewindow->setText( tr("Close Window") );
190 m_closewindow->addTo( m_console ); 188 m_closewindow->addTo( m_console );
191 connect( m_closewindow, SIGNAL(activated() ), 189 connect( m_closewindow, SIGNAL(activated() ),
192 this, SLOT(slotClose() ) ); 190 this, SLOT(slotClose() ) );
193 191
194 192
195 /* 193 /*
196 * script actions 194 * script actions
197 */ 195 */
198 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); 196 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0);
199 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); 197 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int)));
200 198
201 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); 199 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
202 m_recordScript->addTo(m_scripts); 200 m_recordScript->addTo(m_scripts);
203 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); 201 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript()));
204 202
205 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); 203 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0);
206 m_saveScript->addTo(m_scripts); 204 m_saveScript->addTo(m_scripts);
207 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); 205 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript()));
208 206
209 207
210 208
211 209
212 /* 210 /*
213 * action that open/closes the keyboard 211 * action that open/closes the keyboard
214 */ 212 */
215 m_openKeys = new QAction (tr("Open Keyboard..."), 213 m_openKeys = new QAction (tr("Open Keyboard..."),
216 Resource::loadPixmap( "console/keys/keyboard_icon" ), 214 Resource::loadPixmap( "console/keys/keyboard_icon" ),
217 QString::null, 0, this, 0); 215 QString::null, 0, this, 0);
218 m_openKeys->setToggleAction(true); 216 m_openKeys->setToggleAction(true);
219 connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); 217 connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool)));
220 218
221 /* insert the submenu */ 219 /* insert the submenu */
222 m_console->insertItem(tr("New from Profile"), m_sessionsPop, 220 m_console->insertItem(tr("New from Profile"), m_sessionsPop,
223 -1, 0); 221 -1, 0);
224 222
225 /* insert the connection menu */ 223 /* insert the connection menu */
226 m_bar->insertItem( tr("Connection"), m_console ); 224 m_bar->insertItem( tr("Connection"), m_console );
227 225
228 /* the scripts menu */ 226 /* the scripts menu */
229#ifdef EAST 227#ifdef EAST
230 Opie::Core::OConfig cfg("opie-console"); 228 Opie::Core::OConfig cfg("opie-console");
231 cfg.setGroup("10east"); 229 cfg.setGroup("10east");
232 if( !cfg.readEntry("scripthide",0) ) { 230 if( !cfg.readEntry("scripthide",0) ) {
233 m_bar->insertItem( tr("Scripts"), m_scripts ); 231 m_bar->insertItem( tr("Scripts"), m_scripts );
234 } 232 }
235#endif 233#endif
236 234
237 /* and the keyboard */ 235 /* and the keyboard */
238 m_keyBar = new QToolBar(this); 236 m_keyBar = new QToolBar(this);
239 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); 237 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE );
240 m_keyBar->setHorizontalStretchable( TRUE ); 238 m_keyBar->setHorizontalStretchable( TRUE );
241 m_keyBar->hide(); 239 m_keyBar->hide();
242 240
243 m_kb = new FunctionKeyboard(m_keyBar); 241 m_kb = new FunctionKeyboard(m_keyBar);
244 connect(m_kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)), 242 connect(m_kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)),
245 this, SLOT(slotKeyReceived(FKey,ushort,ushort,bool))); 243 this, SLOT(slotKeyReceived(FKey,ushort,ushort,bool)));
246 244
247 245
248 a = new QAction(tr("Copy"), 246 a = new QAction(tr("Copy"),
249 Resource::loadPixmap("copy"), QString::null, 247 Resource::loadPixmap("copy"), QString::null,
250 0, this, 0 ); 248 0, this, 0 );
251 //a->addTo( m_icons ); 249 //a->addTo( m_icons );
252 connect( a, SIGNAL(activated() ), 250 connect( a, SIGNAL(activated() ),
253 this, SLOT(slotCopy() ) ); 251 this, SLOT(slotCopy() ) );
254 252
255 QAction *paste = new QAction(tr("Paste"), 253 QAction *paste = new QAction(tr("Paste"),
256 Resource::loadPixmap("paste"), QString::null, 254 Resource::loadPixmap("paste"), QString::null,
257 0, this, 0 ); 255 0, this, 0 );
258 connect( paste, SIGNAL(activated() ), 256 connect( paste, SIGNAL(activated() ),
259 this, SLOT(slotPaste() ) ); 257 this, SLOT(slotPaste() ) );
260 258
261 259
262 newCon->addTo( m_icons ); 260 newCon->addTo( m_icons );
263 //m_setProfiles->addTo( m_icons ); 261 //m_setProfiles->addTo( m_icons );
264 paste->addTo( m_icons ); 262 paste->addTo( m_icons );
265 m_openKeys->addTo(m_icons); 263 m_openKeys->addTo(m_icons);
266 m_fullscreen->addTo( m_icons ); 264 m_fullscreen->addTo( m_icons );
267 265
268 m_connect->setEnabled( false ); 266 m_connect->setEnabled( false );
269 m_disconnect->setEnabled( false ); 267 m_disconnect->setEnabled( false );
270 m_terminate->setEnabled( false ); 268 m_terminate->setEnabled( false );
271 m_transfer->setEnabled( false ); 269 m_transfer->setEnabled( false );
272 m_scripts->setItemEnabled(m_runScript_id, false); 270 m_scripts->setItemEnabled(m_runScript_id, false);
273 m_recordScript->setEnabled( false ); 271 m_recordScript->setEnabled( false );
274 m_saveScript->setEnabled( false ); 272 m_saveScript->setEnabled( false );
275 m_fullscreen->setEnabled( false ); 273 m_fullscreen->setEnabled( false );
276 m_closewindow->setEnabled( false ); 274 m_closewindow->setEnabled( false );
277 m_wrap->setEnabled( false ); 275 m_wrap->setEnabled( false );
278 276
279 /* 277 /*
280 * connect to the menu activation 278 * connect to the menu activation
281 */ 279 */
282 connect( m_sessionsPop, SIGNAL(activated(int) ), 280 connect( m_sessionsPop, SIGNAL(activated(int) ),
283 this, SLOT(slotProfile(int) ) ); 281 this, SLOT(slotProfile(int) ) );
284 282
285 m_consoleWindow = new TabWidget( this, "blah"); 283 m_consoleWindow = new TabWidget( this, "blah");
286 connect(m_consoleWindow, SIGNAL(activated(Session*) ), 284 connect(m_consoleWindow, SIGNAL(activated(Session*) ),
287 this, SLOT(slotSessionChanged(Session*) ) ); 285 this, SLOT(slotSessionChanged(Session*) ) );
288 setCentralWidget( m_consoleWindow ); 286 setCentralWidget( m_consoleWindow );
289 287
290 slotQuickLaunch(); 288 slotQuickLaunch();
291} 289}
292 290
293ProfileManager* MainWindow::manager() { 291ProfileManager* MainWindow::manager() {
294 return m_manager; 292 return m_manager;
295} 293}
296TabWidget* MainWindow::tabWidget() { 294TabWidget* MainWindow::tabWidget() {
297 return m_consoleWindow; 295 return m_consoleWindow;
298} 296}
299void MainWindow::populateProfiles() { 297void MainWindow::populateProfiles() {
300 m_sessionsPop->clear(); 298 m_sessionsPop->clear();
301 Profile::ValueList list = manager()->all(); 299 Profile::ValueList list = manager()->all();
302 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { 300 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) {
303 m_sessionsPop->insertItem( (*it).name() ); 301 m_sessionsPop->insertItem( (*it).name() );
304 } 302 }
305 303
306} 304}
307 305
308void MainWindow::populateScripts() { 306void MainWindow::populateScripts() {
309 m_scriptsPop->clear(); 307 m_scriptsPop->clear();
310 m_scriptsData.clear(); 308 m_scriptsData.clear();
311 DocLnkSet files(QPEApplication::documentDir(), "text/plain"); 309 DocLnkSet files(QPEApplication::documentDir(), "text/plain");
312 QListIterator<DocLnk> dit(files.children()); 310 QListIterator<DocLnk> dit(files.children());
313 for (; dit.current(); ++dit) { 311 for (; dit.current(); ++dit) {
314 if (*dit && (*dit)->name().length()>0) { 312 if (*dit && (*dit)->name().length()>0) {
315 QFileInfo info((*dit)->file()); 313 QFileInfo info((*dit)->file());
316 if (info.extension(false) == "script") { 314 if (info.extension(false) == "script") {
317 m_scriptsData.append(new DocLnk(**dit)); 315 m_scriptsData.append(new DocLnk(**dit));
318 m_scriptsPop->insertItem((*dit)->name()); 316 m_scriptsPop->insertItem((*dit)->name());
319 } 317 }
320 } 318 }
321 } 319 }
322 320
323} 321}
324 322
325MainWindow::~MainWindow() { 323MainWindow::~MainWindow() {
326 delete m_factory; 324 delete m_factory;
327 manager()->save(); 325 manager()->save();
328#ifdef FSCKED_DISTRI 326#ifdef FSCKED_DISTRI
329 FixIt fix; 327 FixIt fix;
330 fix.breakIt(); 328 fix.breakIt();
331#endif 329#endif
332} 330}
333 331
334MetaFactory* MainWindow::factory() { 332MetaFactory* MainWindow::factory() {
335 return m_factory; 333 return m_factory;
336} 334}
337 335
338Session* MainWindow::currentSession() { 336Session* MainWindow::currentSession() {
339 return m_curSession; 337 return m_curSession;
340} 338}
341 339
342QList<Session> MainWindow::sessions() { 340QList<Session> MainWindow::sessions() {
343 return m_sessions; 341 return m_sessions;
344} 342}
345 343
346void MainWindow::slotNew() { 344void MainWindow::slotNew() {
347 ProfileEditorDialog dlg(factory() ); 345 ProfileEditorDialog dlg(factory() );
348 dlg.setCaption( tr("New Connection") ); 346 dlg.setCaption( tr("New Connection") );
349 int ret = QPEApplication::execDialog( &dlg ); 347 int ret = QPEApplication::execDialog( &dlg );
350 348
351 if ( ret == QDialog::Accepted ) { 349 if ( ret == QDialog::Accepted ) {
352 create( dlg.profile() ); 350 create( dlg.profile() );
353 } 351 }
354} 352}
355 353
356void MainWindow::slotRecordScript() { 354void MainWindow::slotRecordScript() {
357 if (currentSession()) { 355 if (currentSession()) {
358 currentSession()->emulationHandler()->startRecording(); 356 currentSession()->emulationHandler()->startRecording();
359 m_saveScript->setEnabled(true); 357 m_saveScript->setEnabled(true);
360 m_recordScript->setEnabled(false); 358 m_recordScript->setEnabled(false);
361 } 359 }
362} 360}
363 361
364void MainWindow::slotSaveScript() { 362void MainWindow::slotSaveScript() {
365 if (currentSession() && currentSession()->emulationHandler()->isRecording()) { 363 if (currentSession() && currentSession()->emulationHandler()->isRecording()) {
366 QMap<QString, QStringList> map; 364 QMap<QString, QStringList> map;
367 QStringList text; 365 QStringList text;
368 text << "text/plain"; 366 text << "text/plain";
369 map.insert(tr("Script"), text ); 367 map.insert(tr("Script"), text );
370 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); 368 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
371 if (!filename.isEmpty()) { 369 if (!filename.isEmpty()) {
372 QFileInfo info(filename); 370 QFileInfo info(filename);
373 if (info.extension(FALSE) != "script") 371 if (info.extension(FALSE) != "script")
374 filename += ".script"; 372 filename += ".script";
375 DocLnk nf; 373 DocLnk nf;
376 nf.setType("text/plain"); 374 nf.setType("text/plain");
377 nf.setFile(filename); 375 nf.setFile(filename);
378 nf.setName(info.fileName()); 376 nf.setName(info.fileName());
379 FileManager fm; 377 FileManager fm;
380 fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); 378 fm.saveFile(nf, currentSession()->emulationHandler()->script()->script());
381 currentSession()->emulationHandler()->clearScript(); 379 currentSession()->emulationHandler()->clearScript();
382 m_saveScript->setEnabled(false); 380 m_saveScript->setEnabled(false);
383 m_recordScript->setEnabled(true); 381 m_recordScript->setEnabled(true);
384 populateScripts(); 382 populateScripts();
385 } 383 }
386 } 384 }
387} 385}
388 386
389void MainWindow::slotRunScript(int id) { 387void MainWindow::slotRunScript(int id) {
390 if (currentSession()) { 388 if (currentSession()) {
391 int index = m_scriptsPop->indexOf(id); 389 int index = m_scriptsPop->indexOf(id);
392 DocLnk *lnk = m_scriptsData.at(index); 390 DocLnk *lnk = m_scriptsData.at(index);
393 QString filePath = lnk->file(); 391 QString filePath = lnk->file();
394 Script script(filePath); 392 Script script(filePath);
395 currentSession()->emulationHandler()->runScript(&script); 393 currentSession()->emulationHandler()->runScript(&script);
396 } 394 }
397} 395}
398 396
399void MainWindow::slotConnect() { 397void MainWindow::slotConnect() {
400 if ( currentSession() ) { 398 if ( currentSession() ) {
401 bool ret = currentSession()->layer()->open(); 399 bool ret = currentSession()->layer()->open();
402 if(!ret) QMessageBox::warning(currentSession()->widgetStack(), 400 if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
403 QObject::tr("Failed"), 401 QObject::tr("Failed"),
404 QObject::tr("Connecting failed for this session.")); 402 QObject::tr("Connecting failed for this session."));
405 else { 403 else {
406 m_connect->setEnabled( false ); 404 m_connect->setEnabled( false );
407 m_disconnect->setEnabled( true ); 405 m_disconnect->setEnabled( true );
408 406
409 // if it does not support file transfer, disable the menu entry 407 // if it does not support file transfer, disable the menu entry
410 if ( ( m_curSession->layer() )->supports()[1] == 0 ) { 408 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
411 m_transfer->setEnabled( false ); 409 m_transfer->setEnabled( false );
412 } else { 410 } else {
413 m_transfer->setEnabled( true ); 411 m_transfer->setEnabled( true );
414 } 412 }
415 413
416 m_recordScript->setEnabled( true ); 414 m_recordScript->setEnabled( true );
417 m_scripts->setItemEnabled(m_runScript_id, true); 415 m_scripts->setItemEnabled(m_runScript_id, true);
418 } 416 }
419 } 417 }
420} 418}
421 419
422void MainWindow::slotDisconnect() { 420void MainWindow::slotDisconnect() {
423 if ( currentSession() ) { 421 if ( currentSession() ) {
424 currentSession()->layer()->close(); 422 currentSession()->layer()->close();
425 m_connect->setEnabled( true ); 423 m_connect->setEnabled( true );
426 m_disconnect->setEnabled( false ); 424 m_disconnect->setEnabled( false );
427 m_transfer->setEnabled( false ); 425 m_transfer->setEnabled( false );
428 m_recordScript->setEnabled( false); 426 m_recordScript->setEnabled( false);
429 m_saveScript->setEnabled( false ); 427 m_saveScript->setEnabled( false );
430 m_scripts->setItemEnabled(m_runScript_id, false); 428 m_scripts->setItemEnabled(m_runScript_id, false);
431 } 429 }
432} 430}
433 431
434void MainWindow::slotTerminate() { 432void MainWindow::slotTerminate() {
435 if ( currentSession() ) 433 if ( currentSession() )
436 currentSession()->layer()->close(); 434 currentSession()->layer()->close();
437 435
438 slotClose(); 436 slotClose();
439 /* FIXME move to the next session */ 437 /* FIXME move to the next session */
440} 438}
441 439
442 440
443 441
444void MainWindow::slotQuickLaunch() { 442void MainWindow::slotQuickLaunch() {
445 443
446 Profile prof = manager()->profile( "default" ); 444 Profile prof = manager()->profile( "default" );
447 if ( prof.name() == "default" ) { 445 if ( prof.name() == "default" ) {
448 create( prof ); 446 create( prof );
449 } else { 447 } else {
450 #ifndef EAST 448 #ifndef EAST
451 Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 ); 449 Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 );
452 newProf.setAutoConnect( true ); 450 newProf.setAutoConnect( true );
453 create( newProf ); 451 create( newProf );
454 slotSaveSession(); 452 slotSaveSession();
455 #endif 453 #endif
456 } 454 }
457} 455}
458 456
459void MainWindow::slotConfigure() { 457void MainWindow::slotConfigure() {
460 ConfigDialog conf( manager()->all(), factory() ); 458 ConfigDialog conf( manager()->all(), factory() );
461 459
462 int ret = QPEApplication::execDialog( &conf ); 460 int ret = QPEApplication::execDialog( &conf );
463 461
464 if ( QDialog::Accepted == ret ) { 462 if ( QDialog::Accepted == ret ) {
465 manager()->setProfiles( conf.list() ); 463 manager()->setProfiles( conf.list() );
466 manager()->save(); 464 manager()->save();
467 populateProfiles(); 465 populateProfiles();
468 } 466 }
469} 467}
470/* 468/*
471 * we will remove 469 * we will remove
472 * this window from the tabwidget 470 * this window from the tabwidget
473 * remove it from the list 471 * remove it from the list
474 * delete it 472 * delete it
475 * and set the currentSession() 473 * and set the currentSession()
476 */ 474 */
477void MainWindow::slotClose() { 475void MainWindow::slotClose() {
478 if (!currentSession() ) 476 if (!currentSession() )
479 return; 477 return;
480 478
481 Session* ses = currentSession(); 479 Session* ses = currentSession();
482 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ 480 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */
483 m_curSession = NULL; 481 m_curSession = NULL;
484 tabWidget()->remove( /*currentSession()*/ses ); 482 tabWidget()->remove( /*currentSession()*/ses );
485 /*it's autodelete */ 483 /*it's autodelete */
486 m_sessions.remove( ses ); 484 m_sessions.remove( ses );
487 485
488 if (!currentSession() ) { 486 if (!currentSession() ) {
489 m_connect->setEnabled( false ); 487 m_connect->setEnabled( false );
490 m_disconnect->setEnabled( false ); 488 m_disconnect->setEnabled( false );
491 m_terminate->setEnabled( false ); 489 m_terminate->setEnabled( false );
492 m_transfer->setEnabled( false ); 490 m_transfer->setEnabled( false );
493 m_recordScript->setEnabled( false ); 491 m_recordScript->setEnabled( false );
494 m_saveScript->setEnabled( false ); 492 m_saveScript->setEnabled( false );
495 m_scripts->setItemEnabled(m_runScript_id, false); 493 m_scripts->setItemEnabled(m_runScript_id, false);
496 m_fullscreen->setEnabled( false ); 494 m_fullscreen->setEnabled( false );
497 m_wrap->setEnabled( false ); 495 m_wrap->setEnabled( false );
498 m_closewindow->setEnabled( false ); 496 m_closewindow->setEnabled( false );
499 } 497 }
500 498
501 m_kb->loadDefaults(); 499 m_kb->loadDefaults();
502} 500}
503 501
504/* 502/*
505 * We will get the name 503 * We will get the name
506 * Then the profile 504 * Then the profile
507 * and then we will make a profile 505 * and then we will make a profile
508 */ 506 */
509void MainWindow::slotProfile( int id) { 507void MainWindow::slotProfile( int id) {
510 Profile prof = manager()->profile( m_sessionsPop->text( id) ); 508 Profile prof = manager()->profile( m_sessionsPop->text( id) );
511 create( prof ); 509 create( prof );
512} 510}
513 511
514 512
515 513
516void MainWindow::create( const Profile& prof ) { 514void MainWindow::create( const Profile& prof ) {
517 if(m_curSession) 515 if(m_curSession)
518 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); 516 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
519 517
520 Session *ses = manager()->fromProfile( prof, tabWidget() ); 518 Session *ses = manager()->fromProfile( prof, tabWidget() );
521 519
522 if((!ses) || (!ses->layer()) || (!ses->widgetStack())) 520 if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
523 { 521 {
524 QMessageBox::warning(this, 522 QMessageBox::warning(this,
525 QObject::tr("Session failed"), 523 QObject::tr("Session failed"),
526 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); 524 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>"));
527 //if(ses) delete ses; 525 //if(ses) delete ses;
528 return; 526 return;
529 } 527 }
530 528
531 m_sessions.append( ses ); 529 m_sessions.append( ses );
532 tabWidget()->add( ses ); 530 tabWidget()->add( ses );
533 tabWidget()->repaint(); 531 tabWidget()->repaint();
534 m_curSession = ses; 532 m_curSession = ses;
535 533
536 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it 534 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it
537 m_connect->setEnabled( true ); 535 m_connect->setEnabled( true );
538 m_disconnect->setEnabled( false ); 536 m_disconnect->setEnabled( false );
539 m_terminate->setEnabled( true ); 537 m_terminate->setEnabled( true );
540 m_fullscreen->setEnabled( true ); 538 m_fullscreen->setEnabled( true );
541 m_wrap->setEnabled( true ); 539 m_wrap->setEnabled( true );
542 m_closewindow->setEnabled( true ); 540 m_closewindow->setEnabled( true );
543 m_transfer->setEnabled( false ); 541 m_transfer->setEnabled( false );
544 m_recordScript->setEnabled( false ); 542 m_recordScript->setEnabled( false );
545 m_saveScript->setEnabled( false ); 543 m_saveScript->setEnabled( false );
546 m_scripts->setItemEnabled(m_runScript_id, false); 544 m_scripts->setItemEnabled(m_runScript_id, false);
547 545
548 // is io_layer wants direct connection, then autoconnect 546 // is io_layer wants direct connection, then autoconnect
549 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { 547 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) {
550 if (prof.autoConnect()) { 548 if (prof.autoConnect()) {
551 slotConnect(); 549 slotConnect();
552 } 550 }
553 551
554 QWidget *w = currentSession()->widget(); 552 QWidget *w = currentSession()->widget();
555 if(w) w->setFocus(); 553 if(w) w->setFocus();
556 554
557 if(currentSession()->profile().readNumEntry("Wrap", 80)){ 555 if(currentSession()->profile().readNumEntry("Wrap", 80)){
558 m_isWrapped = true; 556 m_isWrapped = true;
559 } else { 557 } else {
560 m_isWrapped = false; 558 m_isWrapped = false;
561 } 559 }
562 560
563 m_kb->load(currentSession()->profile()); 561 m_kb->load(currentSession()->profile());
564} 562}
565 563
566void MainWindow::slotTransfer() 564void MainWindow::slotTransfer()
567{ 565{
568 if ( currentSession() ) { 566 if ( currentSession() ) {
569 Session *mysession = currentSession(); 567 Session *mysession = currentSession();
570 TransferDialog dlg(/*mysession->widgetStack()*/this, this); 568 TransferDialog dlg(/*mysession->widgetStack()*/this, this);
571 mysession->setTransferDialog(&dlg); 569 mysession->setTransferDialog(&dlg);
572 //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); 570 //dlg.reparent(mysession->widgetStack(), QPoint(0, 0));
573 //dlg.showMaximized(); 571 //dlg.showMaximized();
574 currentSession()->widgetStack()->addWidget(&dlg, -1); 572 currentSession()->widgetStack()->addWidget(&dlg, -1);
575 dlg.show(); 573 dlg.show();
576 //dlg.exec(); 574 //dlg.exec();
577 while(dlg.isRunning()) qApp->processEvents(); 575 while(dlg.isRunning()) qApp->processEvents();
578 mysession->setTransferDialog(0l); 576 mysession->setTransferDialog(0l);
579 } 577 }
580} 578}
581 579
582 580
583void MainWindow::slotOpenKeb(bool state) { 581void MainWindow::slotOpenKeb(bool state) {
584 582
585 if (state) m_keyBar->show(); 583 if (state) m_keyBar->show();
586 else m_keyBar->hide(); 584 else m_keyBar->hide();
587 585
588} 586}
589 587
590 588
591void MainWindow::slotOpenButtons( bool state ) { 589void MainWindow::slotOpenButtons( bool state ) {
592 590
593 if ( state ) { 591 if ( state ) {
594 m_buttonBar->show(); 592 m_buttonBar->show();
595 } else { 593 } else {
596 m_buttonBar->hide(); 594 m_buttonBar->hide();
597 } 595 }
598} 596}
599 597
600 598
601 599
602void MainWindow::slotSessionChanged( Session* ses ) { 600void MainWindow::slotSessionChanged( Session* ses ) {
603 if(m_curSession) 601 if(m_curSession)
604 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); 602 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
605 if(ses) 603 if(ses)
606 if(ses->transferDialog()) ses->transferDialog()->show(); 604 if(ses->transferDialog()) ses->transferDialog()->show();
607 605
608 if ( ses ) { 606 if ( ses ) {
609 m_curSession = ses; 607 m_curSession = ses;
610 if ( m_curSession->layer()->isConnected() ) { 608 if ( m_curSession->layer()->isConnected() ) {
611 m_connect->setEnabled( false ); 609 m_connect->setEnabled( false );
612 m_disconnect->setEnabled( true ); 610 m_disconnect->setEnabled( true );
613 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); 611 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording());
614 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); 612 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording());
615 m_scripts->setItemEnabled(m_runScript_id, true); 613 m_scripts->setItemEnabled(m_runScript_id, true);
616 } else { 614 } else {
617 m_connect->setEnabled( true ); 615 m_connect->setEnabled( true );
618 m_disconnect->setEnabled( false ); 616 m_disconnect->setEnabled( false );
619 m_recordScript->setEnabled( false ); 617 m_recordScript->setEnabled( false );
620 m_saveScript->setEnabled( false ); 618 m_saveScript->setEnabled( false );
621 m_scripts->setItemEnabled(m_runScript_id, false); 619 m_scripts->setItemEnabled(m_runScript_id, false);
622 } 620 }
623 621
624 if ( ( currentSession()->emulationHandler()->isLogging() ) ) { 622 if ( ( currentSession()->emulationHandler()->isLogging() ) ) {
625 m_recordLog->setText( tr("Stop log") ); 623 m_recordLog->setText( tr("Stop log") );
626 } else { 624 } else {
627 m_recordLog->setText( tr("Start log") ); 625 m_recordLog->setText( tr("Start log") );
628 } 626 }
629 627
630 if ( ( m_curSession->layer() )->supports()[1] == 0 ) { 628 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
631 m_transfer->setEnabled( false ); 629 m_transfer->setEnabled( false );
632 } else { 630 } else {
633 m_transfer->setEnabled( true ); 631 m_transfer->setEnabled( true );
634 } 632 }
635 633
636 QWidget *w = m_curSession->widget(); 634 QWidget *w = m_curSession->widget();
637 if(w) w->setFocus(); 635 if(w) w->setFocus();
638 636
639 if(currentSession()->profile().readNumEntry("Wrap", 80)){ 637 if(currentSession()->profile().readNumEntry("Wrap", 80)){
640 m_isWrapped = true; 638 m_isWrapped = true;
641 } else { 639 } else {
642 m_isWrapped = false; 640 m_isWrapped = false;
643 } 641 }
644 642
645 m_kb->load(currentSession()->profile()); 643 m_kb->load(currentSession()->profile());
646 } 644 }
647} 645}
648 646
649void MainWindow::slotWrap() 647void MainWindow::slotWrap()
650{ 648{
651 if(m_curSession) 649 if(m_curSession)
652 { 650 {
653 EmulationHandler *e = m_curSession->emulationHandler(); 651 EmulationHandler *e = m_curSession->emulationHandler();
654 if(e) 652 if(e)
655 { 653 {
656 e->setWrap( m_isWrapped ? 80:0 ); 654 e->setWrap( m_isWrapped ? 80:0 );
657 m_isWrapped = !m_isWrapped; 655 m_isWrapped = !m_isWrapped;
658 } 656 }
659 } 657 }
660} 658}
661 659
662void MainWindow::slotFullscreen() { 660void MainWindow::slotFullscreen() {
663 661
664 662
665 663
666 if ( m_isFullscreen ) { 664 if ( m_isFullscreen ) {
667 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); 665 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true );
668 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); 666 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() );
669 ( m_curSession->emulationHandler() )->cornerButton()->hide(); 667 ( m_curSession->emulationHandler() )->cornerButton()->hide();
670 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 668 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
671 669
672 } else { 670 } else {
673 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); 671 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget();
674 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); 672 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame );
675 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop 673 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop
676 , QPoint(0,0), false ); 674 , QPoint(0,0), false );
677 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); 675 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() );
678 ( m_curSession->widgetStack() )->setFocus(); 676 ( m_curSession->widgetStack() )->setFocus();
679 ( m_curSession->widgetStack() )->show(); 677 ( m_curSession->widgetStack() )->show();
680 678
681 ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); 679 ( ( m_curSession->emulationHandler() )->cornerButton() )->show();
682 680
683 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 681 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
684 } 682 }
685 683
686 m_isFullscreen = !m_isFullscreen; 684 m_isFullscreen = !m_isFullscreen;
687} 685}
688 686
689 687
690void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { 688void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) {
691 689
692 if ( m_curSession ) { 690 if ( m_curSession ) {
693 691
694 QEvent::Type state; 692 QEvent::Type state;
695 693
696 if (pressed) state = QEvent::KeyPress; 694 if (pressed) state = QEvent::KeyPress;
697 else state = QEvent::KeyRelease; 695 else state = QEvent::KeyRelease;
698 696
699 QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); 697 QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode)));
700 698
701 // is this the best way to do this? cant figure out any other way to work 699 // is this the best way to do this? cant figure out any other way to work
702 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); 700 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke);
703 ke.ignore(); 701 ke.ignore();
704 } 702 }
705} 703}
706void MainWindow::slotCopy() { 704void MainWindow::slotCopy() {
707 if (!currentSession() ) return; 705 if (!currentSession() ) return;
708 currentSession()->emulationHandler()->copy(); 706 currentSession()->emulationHandler()->copy();
709} 707}
710void MainWindow::slotPaste() { 708void MainWindow::slotPaste() {
711 if (!currentSession() ) return; 709 if (!currentSession() ) return;
712 currentSession()->emulationHandler()->paste(); 710 currentSession()->emulationHandler()->paste();
713} 711}
714 712
715/* 713/*
716 * Save the session 714 * Save the session
717 */ 715 */
718 716
719void MainWindow::slotSaveSession() { 717void MainWindow::slotSaveSession() {
720 if (!currentSession() ) { 718 if (!currentSession() ) {
721 QMessageBox::information(this, tr("Save Connection"), 719 QMessageBox::information(this, tr("Save Connection"),
722 tr("<qt>There is no Connection.</qt>"), 1 ); 720 tr("<qt>There is no Connection.</qt>"), 1 );
723 return; 721 return;
724 } 722 }
725 manager()->add( currentSession()->profile() ); 723 manager()->add( currentSession()->profile() );
726 manager()->save(); 724 manager()->save();
727 populateProfiles(); 725 populateProfiles();
728} 726}
729 727
730 728
731 729
732void MainWindow::slotSaveLog() { 730void MainWindow::slotSaveLog() {
733 731
734 if( currentSession()->emulationHandler()->isLogging() ) { 732 if( currentSession()->emulationHandler()->isLogging() ) {
735 DocLnk nf; 733 DocLnk nf;
736 QString m_logName = currentSession()->emulationHandler()->logFileName(); 734 QString m_logName = currentSession()->emulationHandler()->logFileName();
737 QFileInfo info(m_logName); 735 QFileInfo info(m_logName);
738 nf.setType("text/plain"); 736 nf.setType("text/plain");
739 nf.setFile(m_logName); 737 nf.setFile(m_logName);
740 nf.setName(info.fileName()); 738 nf.setName(info.fileName());
741 nf.writeLink(); 739 nf.writeLink();
742 m_recordLog->setText( tr("Start log") ); 740 m_recordLog->setText( tr("Start log") );
743 m_recordingLog = false; 741 m_recordingLog = false;
744 currentSession()->emulationHandler()->clearLog(); 742 currentSession()->emulationHandler()->clearLog();
745 } else { 743 } else {
746 QMap<QString, QStringList> map; 744 QMap<QString, QStringList> map;
747 QStringList text; 745 QStringList text;
748 text << "text/plain"; 746 text << "text/plain";
749 map.insert(tr("Log"), text ); 747 map.insert(tr("Log"), text );
750 QString m_logName = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); 748 Opie::Core::OConfig cfg("opie-console");
749 cfg.setGroup("defaults");
750 QString startDir = cfg.readEntry("defaultlogdir", QPEApplication::documentDir() );
751 QString m_logName = OFileDialog::getSaveFileName(2, startDir, QString::null, map, 0, startDir);
751 if (m_logName.isEmpty() ) return; 752 if (m_logName.isEmpty() ) return;
752 753
753 m_recordLog->setText( tr("Stop log") ); 754 m_recordLog->setText( tr("Stop log") );
754 m_recordingLog = true; 755 m_recordingLog = true;
755 currentSession()->emulationHandler()->startLogging(m_logName); 756 currentSession()->emulationHandler()->startLogging(m_logName);
756 } 757 }
757} 758}
758 759
759void MainWindow::slotSaveHistory() { 760void MainWindow::slotSaveHistory() {
760 QMap<QString, QStringList> map; 761 QMap<QString, QStringList> map;
761 QStringList text; 762 QStringList text;
762 text << "text/plain"; 763 text << "text/plain";
763 map.insert(tr("History"), text ); 764 map.insert(tr("History"), text );
764 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); 765 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
765 if (filename.isEmpty() ) return; 766 if (filename.isEmpty() ) return;
766 767
767 QFileInfo info(filename); 768 QFileInfo info(filename);
768 769
769 DocLnk nf; 770 DocLnk nf;
770 nf.setType("text/plain"); 771 nf.setType("text/plain");
771 nf.setFile(filename); 772 nf.setFile(filename);
772 nf.setName(info.fileName()); 773 nf.setName(info.fileName());
773 774
774 775
775 QFile file(filename); 776 QFile file(filename);
776 file.open(IO_WriteOnly ); 777 file.open(IO_WriteOnly );
777 QTextStream str(&file ); 778 QTextStream str(&file );
778 if ( currentSession() ) 779 if ( currentSession() )
779 currentSession()->emulationHandler()->emulation()->streamHistory(&str); 780 currentSession()->emulationHandler()->emulation()->streamHistory(&str);
780 781
781 file.close(); 782 file.close();
782 nf.writeLink(); 783 nf.writeLink();
783} 784}