Diffstat (limited to 'noncore/apps/opie-console/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index d221715..01468ca 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -1,43 +1,45 @@ | |||
1 | #include <assert.h> | 1 | #include <assert.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qmenubar.h> | 4 | #include <qmenubar.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | #include <qpopupmenu.h> | 6 | #include <qpopupmenu.h> |
7 | #include <qtoolbar.h> | 7 | #include <qtoolbar.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qpushbutton.h> | 9 | #include <qpushbutton.h> |
10 | #include <qwhatsthis.h> | 10 | #include <qwhatsthis.h> |
11 | #include <qfileinfo.h> | 11 | #include <qfileinfo.h> |
12 | #include <qtextstream.h> | ||
12 | 13 | ||
13 | #include <qpe/resource.h> | 14 | #include <qpe/resource.h> |
14 | #include <qpe/qpeapplication.h> | 15 | #include <qpe/qpeapplication.h> |
15 | #include <qpe/filemanager.h> | 16 | #include <qpe/filemanager.h> |
16 | #include <qpe/mimetype.h> | 17 | #include <qpe/mimetype.h> |
17 | 18 | ||
18 | #include <opie/ofiledialog.h> | 19 | #include <opie/ofiledialog.h> |
19 | 20 | ||
21 | #include "TEmulation.h" | ||
20 | #include "keytrans.h" | 22 | #include "keytrans.h" |
21 | #include "profileeditordialog.h" | 23 | #include "profileeditordialog.h" |
22 | #include "configdialog.h" | 24 | #include "configdialog.h" |
23 | #include "default.h" | 25 | #include "default.h" |
24 | #include "metafactory.h" | 26 | #include "metafactory.h" |
25 | #include "profile.h" | 27 | #include "profile.h" |
26 | #include "profilemanager.h" | 28 | #include "profilemanager.h" |
27 | #include "mainwindow.h" | 29 | #include "mainwindow.h" |
28 | #include "tabwidget.h" | 30 | #include "tabwidget.h" |
29 | #include "transferdialog.h" | 31 | #include "transferdialog.h" |
30 | #include "function_keyboard.h" | 32 | #include "function_keyboard.h" |
31 | #include "emulation_handler.h" | 33 | #include "emulation_handler.h" |
32 | #include "script.h" | 34 | #include "script.h" |
33 | 35 | ||
34 | static char * filesave_xpm[] = { | 36 | static char * filesave_xpm[] = { |
35 | "16 16 78 1", | 37 | "16 16 78 1", |
36 | " c None", | 38 | " c None", |
37 | ". c #343434", | 39 | ". c #343434", |
38 | "+ c #A0A0A0", | 40 | "+ c #A0A0A0", |
39 | "@ c #565656", | 41 | "@ c #565656", |
40 | "# c #9E9E9E", | 42 | "# c #9E9E9E", |
41 | "$ c #525252", | 43 | "$ c #525252", |
42 | "% c #929292", | 44 | "% c #929292", |
43 | "& c #676767", | 45 | "& c #676767", |
@@ -220,48 +222,54 @@ void MainWindow::initUI() { | |||
220 | m_transfer->addTo( m_console ); | 222 | m_transfer->addTo( m_console ); |
221 | connect(m_transfer, SIGNAL(activated() ), | 223 | connect(m_transfer, SIGNAL(activated() ), |
222 | this, SLOT(slotTransfer() ) ); | 224 | this, SLOT(slotTransfer() ) ); |
223 | 225 | ||
224 | /* | 226 | /* |
225 | * immediate change of line wrap policy | 227 | * immediate change of line wrap policy |
226 | */ | 228 | */ |
227 | m_isWrapped = false; | 229 | m_isWrapped = false; |
228 | m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 ); | 230 | m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 ); |
229 | m_wrap->addTo( m_console ); | 231 | m_wrap->addTo( m_console ); |
230 | connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); | 232 | connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); |
231 | 233 | ||
232 | /* | 234 | /* |
233 | * fullscreen | 235 | * fullscreen |
234 | */ | 236 | */ |
235 | m_isFullscreen = false; | 237 | m_isFullscreen = false; |
236 | 238 | ||
237 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) | 239 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) |
238 | , QString::null, 0, this, 0); | 240 | , QString::null, 0, this, 0); |
239 | m_fullscreen->addTo( m_console ); | 241 | m_fullscreen->addTo( m_console ); |
240 | connect( m_fullscreen, SIGNAL( activated() ), | 242 | connect( m_fullscreen, SIGNAL( activated() ), |
241 | this, SLOT( slotFullscreen() ) ); | 243 | this, SLOT( slotFullscreen() ) ); |
242 | 244 | ||
243 | m_console->insertSeparator(); | 245 | m_console->insertSeparator(); |
246 | |||
247 | QAction *a = new QAction(); | ||
248 | a->setText( tr("Save history") ); | ||
249 | a->addTo( m_console ); | ||
250 | connect(a, SIGNAL(activated() ), | ||
251 | this, SLOT(slotSaveHistory() ) ); | ||
244 | /* | 252 | /* |
245 | * terminate action | 253 | * terminate action |
246 | */ | 254 | */ |
247 | m_terminate = new QAction(); | 255 | m_terminate = new QAction(); |
248 | m_terminate->setText( tr("Terminate") ); | 256 | m_terminate->setText( tr("Terminate") ); |
249 | m_terminate->addTo( m_console ); | 257 | m_terminate->addTo( m_console ); |
250 | connect(m_terminate, SIGNAL(activated() ), | 258 | connect(m_terminate, SIGNAL(activated() ), |
251 | this, SLOT(slotTerminate() ) ); | 259 | this, SLOT(slotTerminate() ) ); |
252 | 260 | ||
253 | m_closewindow = new QAction(); | 261 | m_closewindow = new QAction(); |
254 | m_closewindow->setText( tr("Close Window") ); | 262 | m_closewindow->setText( tr("Close Window") ); |
255 | m_closewindow->addTo( m_console ); | 263 | m_closewindow->addTo( m_console ); |
256 | connect( m_closewindow, SIGNAL(activated() ), | 264 | connect( m_closewindow, SIGNAL(activated() ), |
257 | this, SLOT(slotClose() ) ); | 265 | this, SLOT(slotClose() ) ); |
258 | 266 | ||
259 | 267 | ||
260 | /* | 268 | /* |
261 | * script actions | 269 | * script actions |
262 | */ | 270 | */ |
263 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); | 271 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); |
264 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); | 272 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); |
265 | 273 | ||
266 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); | 274 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); |
267 | m_recordScript->addTo(m_scripts); | 275 | m_recordScript->addTo(m_scripts); |
@@ -281,49 +289,49 @@ void MainWindow::initUI() { | |||
281 | m_openKeys->setToggleAction(true); | 289 | m_openKeys->setToggleAction(true); |
282 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); | 290 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); |
283 | 291 | ||
284 | /* insert the submenu */ | 292 | /* insert the submenu */ |
285 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 293 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
286 | -1, 0); | 294 | -1, 0); |
287 | 295 | ||
288 | /* insert the connection menu */ | 296 | /* insert the connection menu */ |
289 | m_bar->insertItem( tr("Connection"), m_console ); | 297 | m_bar->insertItem( tr("Connection"), m_console ); |
290 | 298 | ||
291 | /* the scripts menu */ | 299 | /* the scripts menu */ |
292 | m_bar->insertItem( tr("Scripts"), m_scripts ); | 300 | m_bar->insertItem( tr("Scripts"), m_scripts ); |
293 | 301 | ||
294 | /* and the keyboard */ | 302 | /* and the keyboard */ |
295 | m_keyBar = new QToolBar(this); | 303 | m_keyBar = new QToolBar(this); |
296 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | 304 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); |
297 | m_keyBar->setHorizontalStretchable( TRUE ); | 305 | m_keyBar->setHorizontalStretchable( TRUE ); |
298 | m_keyBar->hide(); | 306 | m_keyBar->hide(); |
299 | 307 | ||
300 | m_kb = new FunctionKeyboard(m_keyBar); | 308 | m_kb = new FunctionKeyboard(m_keyBar); |
301 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), | 309 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), |
302 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); | 310 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); |
303 | 311 | ||
304 | 312 | ||
305 | QAction *a = new QAction(tr("Copy"), | 313 | a = new QAction(tr("Copy"), |
306 | Resource::loadPixmap("copy"), QString::null, | 314 | Resource::loadPixmap("copy"), QString::null, |
307 | 0, this, 0 ); | 315 | 0, this, 0 ); |
308 | //a->addTo( m_icons ); | 316 | //a->addTo( m_icons ); |
309 | connect( a, SIGNAL(activated() ), | 317 | connect( a, SIGNAL(activated() ), |
310 | this, SLOT(slotCopy() ) ); | 318 | this, SLOT(slotCopy() ) ); |
311 | 319 | ||
312 | QAction *paste = new QAction(tr("Paste"), | 320 | QAction *paste = new QAction(tr("Paste"), |
313 | Resource::loadPixmap("paste"), QString::null, | 321 | Resource::loadPixmap("paste"), QString::null, |
314 | 0, this, 0 ); | 322 | 0, this, 0 ); |
315 | connect( paste, SIGNAL(activated() ), | 323 | connect( paste, SIGNAL(activated() ), |
316 | this, SLOT(slotPaste() ) ); | 324 | this, SLOT(slotPaste() ) ); |
317 | 325 | ||
318 | 326 | ||
319 | newCon->addTo( m_icons ); | 327 | newCon->addTo( m_icons ); |
320 | m_setProfiles->addTo( m_icons ); | 328 | m_setProfiles->addTo( m_icons ); |
321 | paste->addTo( m_icons ); | 329 | paste->addTo( m_icons ); |
322 | m_openKeys->addTo(m_icons); | 330 | m_openKeys->addTo(m_icons); |
323 | m_fullscreen->addTo( m_icons ); | 331 | m_fullscreen->addTo( m_icons ); |
324 | 332 | ||
325 | m_connect->setEnabled( false ); | 333 | m_connect->setEnabled( false ); |
326 | m_disconnect->setEnabled( false ); | 334 | m_disconnect->setEnabled( false ); |
327 | m_terminate->setEnabled( false ); | 335 | m_terminate->setEnabled( false ); |
328 | m_transfer->setEnabled( false ); | 336 | m_transfer->setEnabled( false ); |
329 | m_scripts->setItemEnabled(m_runScript_id, false); | 337 | m_scripts->setItemEnabled(m_runScript_id, false); |
@@ -747,24 +755,49 @@ void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { | |||
747 | } | 755 | } |
748 | void MainWindow::slotCopy() { | 756 | void MainWindow::slotCopy() { |
749 | if (!currentSession() ) return; | 757 | if (!currentSession() ) return; |
750 | currentSession()->emulationHandler()->copy(); | 758 | currentSession()->emulationHandler()->copy(); |
751 | } | 759 | } |
752 | void MainWindow::slotPaste() { | 760 | void MainWindow::slotPaste() { |
753 | if (!currentSession() ) return; | 761 | if (!currentSession() ) return; |
754 | currentSession()->emulationHandler()->paste(); | 762 | currentSession()->emulationHandler()->paste(); |
755 | } | 763 | } |
756 | 764 | ||
757 | /* | 765 | /* |
758 | * Save the session | 766 | * Save the session |
759 | */ | 767 | */ |
760 | 768 | ||
761 | void MainWindow::slotSaveSession() { | 769 | void MainWindow::slotSaveSession() { |
762 | if (!currentSession() ) { | 770 | if (!currentSession() ) { |
763 | QMessageBox::information(this, tr("Save Connection"), | 771 | QMessageBox::information(this, tr("Save Connection"), |
764 | tr("<qt>There is no Connection.</qt>"), 1 ); | 772 | tr("<qt>There is no Connection.</qt>"), 1 ); |
765 | return; | 773 | return; |
766 | } | 774 | } |
767 | manager()->add( currentSession()->profile() ); | 775 | manager()->add( currentSession()->profile() ); |
768 | manager()->save(); | 776 | manager()->save(); |
769 | populateProfiles(); | 777 | populateProfiles(); |
770 | } | 778 | } |
779 | void MainWindow::slotSaveHistory() { | ||
780 | QMap<QString, QStringList> map; | ||
781 | QStringList text; | ||
782 | text << "text/plain"; | ||
783 | map.insert(tr("History"), text ); | ||
784 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | ||
785 | if (filename.isEmpty() ) return; | ||
786 | |||
787 | QFileInfo info(filename); | ||
788 | |||
789 | DocLnk nf; | ||
790 | nf.setType("text/plain"); | ||
791 | nf.setFile(filename); | ||
792 | nf.setName(info.fileName()); | ||
793 | |||
794 | |||
795 | QFile file(filename); | ||
796 | file.open(IO_WriteOnly ); | ||
797 | QTextStream str(&file ); | ||
798 | if ( currentSession() ) | ||
799 | currentSession()->emulationHandler()->emulation()->streamHistory(&str); | ||
800 | |||
801 | file.close(); | ||
802 | nf.writeLink(); | ||
803 | } | ||