Diffstat (limited to 'noncore/apps/opie-console/mainwindow.cpp') (more/less context) (ignore 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,67 +1,69 @@ | |||
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", |
44 | "* c #848484", | 46 | "* c #848484", |
45 | "= c #666666", | 47 | "= c #666666", |
46 | "- c #D8D8D8", | 48 | "- c #D8D8D8", |
47 | "; c #FFFFFF", | 49 | "; c #FFFFFF", |
48 | "> c #DBDBDB", | 50 | "> c #DBDBDB", |
49 | ", c #636363", | 51 | ", c #636363", |
50 | "' c #989898", | 52 | "' c #989898", |
51 | ") c #2D2D2D", | 53 | ") c #2D2D2D", |
52 | "! c #909090", | 54 | "! c #909090", |
53 | "~ c #AEAEAE", | 55 | "~ c #AEAEAE", |
54 | "{ c #EAEAEA", | 56 | "{ c #EAEAEA", |
55 | "] c #575757", | 57 | "] c #575757", |
56 | "^ c #585858", | 58 | "^ c #585858", |
57 | "/ c #8A8A8A", | 59 | "/ c #8A8A8A", |
58 | "( c #828282", | 60 | "( c #828282", |
59 | "_ c #6F6F6F", | 61 | "_ c #6F6F6F", |
60 | ": c #C9C9C9", | 62 | ": c #C9C9C9", |
61 | "< c #050505", | 63 | "< c #050505", |
62 | "[ c #292929", | 64 | "[ c #292929", |
63 | "} c #777777", | 65 | "} c #777777", |
64 | "| c #616161", | 66 | "| c #616161", |
65 | "1 c #3A3A3A", | 67 | "1 c #3A3A3A", |
66 | "2 c #BEBEBE", | 68 | "2 c #BEBEBE", |
67 | "3 c #2C2C2C", | 69 | "3 c #2C2C2C", |
@@ -196,158 +198,164 @@ void MainWindow::initUI() { | |||
196 | m_console->insertSeparator(); | 198 | m_console->insertSeparator(); |
197 | 199 | ||
198 | /* | 200 | /* |
199 | * connect action | 201 | * connect action |
200 | */ | 202 | */ |
201 | m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), | 203 | m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), |
202 | QString::null, 0, this, 0 ); | 204 | QString::null, 0, this, 0 ); |
203 | m_connect->addTo( m_console ); | 205 | m_connect->addTo( m_console ); |
204 | connect(m_connect, SIGNAL(activated() ), | 206 | connect(m_connect, SIGNAL(activated() ), |
205 | this, SLOT(slotConnect() ) ); | 207 | this, SLOT(slotConnect() ) ); |
206 | 208 | ||
207 | /* | 209 | /* |
208 | * disconnect action | 210 | * disconnect action |
209 | */ | 211 | */ |
210 | m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), | 212 | m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), |
211 | QString::null, 0, this, 0 ); | 213 | QString::null, 0, this, 0 ); |
212 | m_disconnect->addTo( m_console ); | 214 | m_disconnect->addTo( m_console ); |
213 | connect(m_disconnect, SIGNAL(activated() ), | 215 | connect(m_disconnect, SIGNAL(activated() ), |
214 | this, SLOT(slotDisconnect() ) ); | 216 | this, SLOT(slotDisconnect() ) ); |
215 | 217 | ||
216 | m_console->insertSeparator(); | 218 | m_console->insertSeparator(); |
217 | 219 | ||
218 | m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, | 220 | m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, |
219 | 0, this, 0 ); | 221 | 0, this, 0 ); |
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); |
268 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); | 276 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); |
269 | 277 | ||
270 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); | 278 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); |
271 | m_saveScript->addTo(m_scripts); | 279 | m_saveScript->addTo(m_scripts); |
272 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); | 280 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); |
273 | 281 | ||
274 | 282 | ||
275 | /* | 283 | /* |
276 | * action that open/closes the keyboard | 284 | * action that open/closes the keyboard |
277 | */ | 285 | */ |
278 | m_openKeys = new QAction (tr("Open Keyboard..."), | 286 | m_openKeys = new QAction (tr("Open Keyboard..."), |
279 | Resource::loadPixmap( "console/keys/keyboard_icon" ), | 287 | Resource::loadPixmap( "console/keys/keyboard_icon" ), |
280 | QString::null, 0, this, 0); | 288 | QString::null, 0, this, 0); |
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); |
330 | m_recordScript->setEnabled( false ); | 338 | m_recordScript->setEnabled( false ); |
331 | m_saveScript->setEnabled( false ); | 339 | m_saveScript->setEnabled( false ); |
332 | m_fullscreen->setEnabled( false ); | 340 | m_fullscreen->setEnabled( false ); |
333 | m_closewindow->setEnabled( false ); | 341 | m_closewindow->setEnabled( false ); |
334 | m_wrap->setEnabled( false ); | 342 | m_wrap->setEnabled( false ); |
335 | 343 | ||
336 | /* | 344 | /* |
337 | * connect to the menu activation | 345 | * connect to the menu activation |
338 | */ | 346 | */ |
339 | connect( m_sessionsPop, SIGNAL(activated( int ) ), | 347 | connect( m_sessionsPop, SIGNAL(activated( int ) ), |
340 | this, SLOT(slotProfile( int ) ) ); | 348 | this, SLOT(slotProfile( int ) ) ); |
341 | 349 | ||
342 | m_consoleWindow = new TabWidget( this, "blah"); | 350 | m_consoleWindow = new TabWidget( this, "blah"); |
343 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), | 351 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), |
344 | this, SLOT(slotSessionChanged(Session*) ) ); | 352 | this, SLOT(slotSessionChanged(Session*) ) ); |
345 | setCentralWidget( m_consoleWindow ); | 353 | setCentralWidget( m_consoleWindow ); |
346 | 354 | ||
347 | } | 355 | } |
348 | 356 | ||
349 | ProfileManager* MainWindow::manager() { | 357 | ProfileManager* MainWindow::manager() { |
350 | return m_manager; | 358 | return m_manager; |
351 | } | 359 | } |
352 | TabWidget* MainWindow::tabWidget() { | 360 | TabWidget* MainWindow::tabWidget() { |
353 | return m_consoleWindow; | 361 | return m_consoleWindow; |
@@ -723,48 +731,73 @@ void MainWindow::slotFullscreen() { | |||
723 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); | 731 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); |
724 | 732 | ||
725 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 733 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
726 | } | 734 | } |
727 | 735 | ||
728 | m_isFullscreen = !m_isFullscreen; | 736 | m_isFullscreen = !m_isFullscreen; |
729 | } | 737 | } |
730 | 738 | ||
731 | 739 | ||
732 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { | 740 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { |
733 | 741 | ||
734 | if ( m_curSession ) { | 742 | if ( m_curSession ) { |
735 | 743 | ||
736 | QEvent::Type state; | 744 | QEvent::Type state; |
737 | 745 | ||
738 | if (pressed) state = QEvent::KeyPress; | 746 | if (pressed) state = QEvent::KeyPress; |
739 | else state = QEvent::KeyRelease; | 747 | else state = QEvent::KeyRelease; |
740 | 748 | ||
741 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); | 749 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); |
742 | 750 | ||
743 | // is this the best way to do this? cant figure out any other way to work | 751 | // is this the best way to do this? cant figure out any other way to work |
744 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); | 752 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); |
745 | ke.ignore(); | 753 | ke.ignore(); |
746 | } | 754 | } |
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 | } | ||