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