Diffstat (limited to 'noncore/apps/opie-console/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index e2f4d12..02a3fa9 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -68,48 +68,58 @@ void MainWindow::initUI() { | |||
68 | /* | 68 | /* |
69 | * the settings action | 69 | * the settings action |
70 | */ | 70 | */ |
71 | m_setProfiles = new QAction(tr("Configure Profiles"), | 71 | m_setProfiles = new QAction(tr("Configure Profiles"), |
72 | Resource::loadPixmap( "SettingsIcon" ), | 72 | Resource::loadPixmap( "SettingsIcon" ), |
73 | QString::null, 0, this, 0); | 73 | QString::null, 0, this, 0); |
74 | // m_setProfiles->addTo( m_settings ); | 74 | // m_setProfiles->addTo( m_settings ); |
75 | m_setProfiles->addTo( m_icons ); | 75 | m_setProfiles->addTo( m_icons ); |
76 | m_setProfiles->addTo( m_console ); | 76 | m_setProfiles->addTo( m_console ); |
77 | connect( m_setProfiles, SIGNAL(activated() ), | 77 | connect( m_setProfiles, SIGNAL(activated() ), |
78 | this, SLOT(slotConfigure() ) ); | 78 | this, SLOT(slotConfigure() ) ); |
79 | 79 | ||
80 | m_console->insertSeparator(); | 80 | m_console->insertSeparator(); |
81 | /* | 81 | /* |
82 | * new Action for new sessions | 82 | * new Action for new sessions |
83 | */ | 83 | */ |
84 | QAction* a = new QAction(tr("New Connection"), | 84 | QAction* a = new QAction(tr("New Connection"), |
85 | Resource::loadPixmap( "new" ), | 85 | Resource::loadPixmap( "new" ), |
86 | QString::null, 0, this, 0); | 86 | QString::null, 0, this, 0); |
87 | a->addTo( m_console ); | 87 | a->addTo( m_console ); |
88 | a->addTo( m_icons ); | 88 | a->addTo( m_icons ); |
89 | connect(a, SIGNAL(activated() ), | 89 | connect(a, SIGNAL(activated() ), |
90 | this, SLOT(slotNew() ) ); | 90 | this, SLOT(slotNew() ) ); |
91 | 91 | ||
92 | m_console->insertSeparator(); | ||
93 | /* save icon is not available */ | ||
94 | a = new QAction(tr("Save Connection"), | ||
95 | Resource::loadPixmap("save"), QString::null, | ||
96 | 0, this, 0 ); | ||
97 | a->addTo( m_console ); | ||
98 | connect(a, SIGNAL(activated() ), | ||
99 | this, SLOT(slotSaveSession() ) ); | ||
100 | m_console->insertSeparator(); | ||
101 | |||
92 | /* | 102 | /* |
93 | * connect action | 103 | * connect action |
94 | */ | 104 | */ |
95 | m_connect = new QAction(); | 105 | m_connect = new QAction(); |
96 | m_connect->setText( tr("Connect") ); | 106 | m_connect->setText( tr("Connect") ); |
97 | m_connect->addTo( m_console ); | 107 | m_connect->addTo( m_console ); |
98 | connect(m_connect, SIGNAL(activated() ), | 108 | connect(m_connect, SIGNAL(activated() ), |
99 | this, SLOT(slotConnect() ) ); | 109 | this, SLOT(slotConnect() ) ); |
100 | 110 | ||
101 | /* | 111 | /* |
102 | * disconnect action | 112 | * disconnect action |
103 | */ | 113 | */ |
104 | m_disconnect = new QAction(); | 114 | m_disconnect = new QAction(); |
105 | m_disconnect->setText( tr("Disconnect") ); | 115 | m_disconnect->setText( tr("Disconnect") ); |
106 | m_disconnect->addTo( m_console ); | 116 | m_disconnect->addTo( m_console ); |
107 | connect(m_disconnect, SIGNAL(activated() ), | 117 | connect(m_disconnect, SIGNAL(activated() ), |
108 | this, SLOT(slotDisconnect() ) ); | 118 | this, SLOT(slotDisconnect() ) ); |
109 | 119 | ||
110 | m_console->insertSeparator(); | 120 | m_console->insertSeparator(); |
111 | 121 | ||
112 | m_transfer = new QAction(); | 122 | m_transfer = new QAction(); |
113 | m_transfer->setText( tr("Transfer file...") ); | 123 | m_transfer->setText( tr("Transfer file...") ); |
114 | m_transfer->addTo( m_console ); | 124 | m_transfer->addTo( m_console ); |
115 | connect(m_transfer, SIGNAL(activated() ), | 125 | connect(m_transfer, SIGNAL(activated() ), |
@@ -201,48 +211,62 @@ void MainWindow::initUI() { | |||
201 | 211 | ||
202 | /* the settings menu */ | 212 | /* the settings menu */ |
203 | // m_bar->insertItem( tr("Settings"), m_settings ); | 213 | // m_bar->insertItem( tr("Settings"), m_settings ); |
204 | 214 | ||
205 | /* and the keyboard */ | 215 | /* and the keyboard */ |
206 | m_keyBar = new QToolBar(this); | 216 | m_keyBar = new QToolBar(this); |
207 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | 217 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); |
208 | m_keyBar->setHorizontalStretchable( TRUE ); | 218 | m_keyBar->setHorizontalStretchable( TRUE ); |
209 | m_keyBar->hide(); | 219 | m_keyBar->hide(); |
210 | 220 | ||
211 | m_kb = new FunctionKeyboard(m_keyBar); | 221 | m_kb = new FunctionKeyboard(m_keyBar); |
212 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), | 222 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), |
213 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); | 223 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); |
214 | 224 | ||
215 | m_buttonBar = new QToolBar( this ); | 225 | m_buttonBar = new QToolBar( this ); |
216 | addToolBar( m_buttonBar, "Buttons", QMainWindow::Top, TRUE ); | 226 | addToolBar( m_buttonBar, "Buttons", QMainWindow::Top, TRUE ); |
217 | m_buttonBar->setHorizontalStretchable( TRUE ); | 227 | m_buttonBar->setHorizontalStretchable( TRUE ); |
218 | m_buttonBar->hide(); | 228 | m_buttonBar->hide(); |
219 | 229 | ||
220 | /* | 230 | /* |
221 | m_qb = new QuickButton( m_buttonBar ); | 231 | m_qb = new QuickButton( m_buttonBar ); |
222 | connect( m_qb, SIGNAL( keyPressed( ushort, ushort, bool, bool, bool) ), | 232 | connect( m_qb, SIGNAL( keyPressed( ushort, ushort, bool, bool, bool) ), |
223 | this, SLOT( slotKeyReceived( ushort, ushort, bool, bool, bool) ) ); | 233 | this, SLOT( slotKeyReceived( ushort, ushort, bool, bool, bool) ) ); |
224 | */ | 234 | */ |
235 | /* now add the copy and paste actions */ | ||
236 | a = new QAction(tr("Copy"), | ||
237 | Resource::loadPixmap("copy"), QString::null, | ||
238 | 0, this, 0 ); | ||
239 | //a->addTo( m_icons ); | ||
240 | connect( a, SIGNAL(activated() ), | ||
241 | this, SLOT(slotCopy() ) ); | ||
242 | |||
243 | a = new QAction(tr("Paste"), | ||
244 | Resource::loadPixmap("paste"), QString::null, | ||
245 | 0, this, 0 ); | ||
246 | a->addTo( m_icons ); | ||
247 | connect( a, SIGNAL(activated() ), | ||
248 | this, SLOT(slotPaste() ) ); | ||
225 | 249 | ||
226 | 250 | ||
227 | m_connect->setEnabled( false ); | 251 | m_connect->setEnabled( false ); |
228 | m_disconnect->setEnabled( false ); | 252 | m_disconnect->setEnabled( false ); |
229 | m_terminate->setEnabled( false ); | 253 | m_terminate->setEnabled( false ); |
230 | m_transfer->setEnabled( false ); | 254 | m_transfer->setEnabled( false ); |
231 | m_recordScript->setEnabled( false ); | 255 | m_recordScript->setEnabled( false ); |
232 | m_saveScript->setEnabled( false ); | 256 | m_saveScript->setEnabled( false ); |
233 | m_runScript->setEnabled( false ); | 257 | m_runScript->setEnabled( false ); |
234 | m_fullscreen->setEnabled( false ); | 258 | m_fullscreen->setEnabled( false ); |
235 | m_closewindow->setEnabled( false ); | 259 | m_closewindow->setEnabled( false ); |
236 | 260 | ||
237 | /* | 261 | /* |
238 | * connect to the menu activation | 262 | * connect to the menu activation |
239 | */ | 263 | */ |
240 | connect( m_sessionsPop, SIGNAL(activated( int ) ), | 264 | connect( m_sessionsPop, SIGNAL(activated( int ) ), |
241 | this, SLOT(slotProfile( int ) ) ); | 265 | this, SLOT(slotProfile( int ) ) ); |
242 | 266 | ||
243 | m_consoleWindow = new TabWidget( this, "blah"); | 267 | m_consoleWindow = new TabWidget( this, "blah"); |
244 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), | 268 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), |
245 | this, SLOT(slotSessionChanged(Session*) ) ); | 269 | this, SLOT(slotSessionChanged(Session*) ) ); |
246 | setCentralWidget( m_consoleWindow ); | 270 | setCentralWidget( m_consoleWindow ); |
247 | 271 | ||
248 | } | 272 | } |
@@ -518,24 +542,47 @@ void MainWindow::slotFullscreen() { | |||
518 | 542 | ||
519 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 543 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
520 | } | 544 | } |
521 | 545 | ||
522 | m_isFullscreen = !m_isFullscreen; | 546 | m_isFullscreen = !m_isFullscreen; |
523 | } | 547 | } |
524 | 548 | ||
525 | 549 | ||
526 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { | 550 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { |
527 | 551 | ||
528 | if ( m_curSession ) { | 552 | if ( m_curSession ) { |
529 | 553 | ||
530 | QEvent::Type state; | 554 | QEvent::Type state; |
531 | 555 | ||
532 | if (pressed) state = QEvent::KeyPress; | 556 | if (pressed) state = QEvent::KeyPress; |
533 | else state = QEvent::KeyRelease; | 557 | else state = QEvent::KeyRelease; |
534 | 558 | ||
535 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); | 559 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); |
536 | 560 | ||
537 | // where should i send this event? doesnt work sending it here | 561 | // where should i send this event? doesnt work sending it here |
538 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); | 562 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); |
539 | ke.ignore(); | 563 | ke.ignore(); |
540 | } | 564 | } |
541 | } | 565 | } |
566 | void MainWindow::slotCopy() { | ||
567 | if (!currentSession() ) return; | ||
568 | currentSession()->emulationHandler()->copy(); | ||
569 | } | ||
570 | void MainWindow::slotPaste() { | ||
571 | if (!currentSession() ) return; | ||
572 | currentSession()->emulationHandler()->paste(); | ||
573 | } | ||
574 | |||
575 | /* | ||
576 | * Save the session | ||
577 | */ | ||
578 | |||
579 | void MainWindow::slotSaveSession() { | ||
580 | if (!currentSession() ) { | ||
581 | QMessageBox::information(this, tr("Save Connection"), | ||
582 | tr("<qt>There is no Connection.</qt>"), 1 ); | ||
583 | return; | ||
584 | } | ||
585 | manager()->add( currentSession()->profile() ); | ||
586 | manager()->save(); | ||
587 | populateProfiles(); | ||
588 | } | ||