-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 16 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.h | 2 |
2 files changed, 18 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 29dbcf3..d3b6c8a 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -160,96 +160,98 @@ void MainWindow::initUI() { | |||
160 | * script actions | 160 | * script actions |
161 | */ | 161 | */ |
162 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); | 162 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); |
163 | m_recordScript->addTo(m_scripts); | 163 | m_recordScript->addTo(m_scripts); |
164 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); | 164 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); |
165 | 165 | ||
166 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); | 166 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); |
167 | m_saveScript->addTo(m_scripts); | 167 | m_saveScript->addTo(m_scripts); |
168 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); | 168 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); |
169 | 169 | ||
170 | m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); | 170 | m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); |
171 | m_runScript->addTo(m_scripts); | 171 | m_runScript->addTo(m_scripts); |
172 | connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); | 172 | connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); |
173 | 173 | ||
174 | /* | 174 | /* |
175 | * action that open/closes the keyboard | 175 | * action that open/closes the keyboard |
176 | */ | 176 | */ |
177 | m_openKeys = new QAction (tr("Open Keyboard..."), | 177 | m_openKeys = new QAction (tr("Open Keyboard..."), |
178 | Resource::loadPixmap( "down" ), | 178 | Resource::loadPixmap( "down" ), |
179 | QString::null, 0, this, 0); | 179 | QString::null, 0, this, 0); |
180 | 180 | ||
181 | m_openKeys->setToggleAction(true); | 181 | m_openKeys->setToggleAction(true); |
182 | 182 | ||
183 | connect (m_openKeys, SIGNAL(toggled(bool)), | 183 | connect (m_openKeys, SIGNAL(toggled(bool)), |
184 | this, SLOT(slotOpenKeb(bool))); | 184 | this, SLOT(slotOpenKeb(bool))); |
185 | m_openKeys->addTo(m_icons); | 185 | m_openKeys->addTo(m_icons); |
186 | 186 | ||
187 | 187 | ||
188 | /* insert the submenu */ | 188 | /* insert the submenu */ |
189 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 189 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
190 | -1, 0); | 190 | -1, 0); |
191 | 191 | ||
192 | /* insert the connection menu */ | 192 | /* insert the connection menu */ |
193 | m_bar->insertItem( tr("Connection"), m_console ); | 193 | m_bar->insertItem( tr("Connection"), m_console ); |
194 | 194 | ||
195 | /* the scripts menu */ | 195 | /* the scripts menu */ |
196 | m_bar->insertItem( tr("Scripts"), m_scripts ); | 196 | m_bar->insertItem( tr("Scripts"), m_scripts ); |
197 | 197 | ||
198 | /* the settings menu */ | 198 | /* the settings menu */ |
199 | m_bar->insertItem( tr("Settings"), m_settings ); | 199 | m_bar->insertItem( tr("Settings"), m_settings ); |
200 | 200 | ||
201 | /* and the keyboard */ | 201 | /* and the keyboard */ |
202 | m_keyBar = new QToolBar(this); | 202 | m_keyBar = new QToolBar(this); |
203 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | 203 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); |
204 | m_keyBar->setHorizontalStretchable( TRUE ); | 204 | m_keyBar->setHorizontalStretchable( TRUE ); |
205 | m_keyBar->hide(); | 205 | m_keyBar->hide(); |
206 | 206 | ||
207 | m_kb = new FunctionKeyboard(m_keyBar); | 207 | m_kb = new FunctionKeyboard(m_keyBar); |
208 | connect(m_kb, SIGNAL(keyPressed(ushort, ushort, bool, bool, bool)), | ||
209 | this, SLOT(slotKeyReceived(ushort, ushort, bool, bool, bool))); | ||
208 | 210 | ||
209 | 211 | ||
210 | 212 | ||
211 | m_connect->setEnabled( false ); | 213 | m_connect->setEnabled( false ); |
212 | m_disconnect->setEnabled( false ); | 214 | m_disconnect->setEnabled( false ); |
213 | m_terminate->setEnabled( false ); | 215 | m_terminate->setEnabled( false ); |
214 | m_transfer->setEnabled( false ); | 216 | m_transfer->setEnabled( false ); |
215 | m_recordScript->setEnabled( false ); | 217 | m_recordScript->setEnabled( false ); |
216 | m_saveScript->setEnabled( false ); | 218 | m_saveScript->setEnabled( false ); |
217 | m_runScript->setEnabled( false ); | 219 | m_runScript->setEnabled( false ); |
218 | m_fullscreen->setEnabled( false ); | 220 | m_fullscreen->setEnabled( false ); |
219 | m_closewindow->setEnabled( false ); | 221 | m_closewindow->setEnabled( false ); |
220 | 222 | ||
221 | /* | 223 | /* |
222 | * connect to the menu activation | 224 | * connect to the menu activation |
223 | */ | 225 | */ |
224 | connect( m_sessionsPop, SIGNAL(activated( int ) ), | 226 | connect( m_sessionsPop, SIGNAL(activated( int ) ), |
225 | this, SLOT(slotProfile( int ) ) ); | 227 | this, SLOT(slotProfile( int ) ) ); |
226 | 228 | ||
227 | m_consoleWindow = new TabWidget( this, "blah"); | 229 | m_consoleWindow = new TabWidget( this, "blah"); |
228 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), | 230 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), |
229 | this, SLOT(slotSessionChanged(Session*) ) ); | 231 | this, SLOT(slotSessionChanged(Session*) ) ); |
230 | setCentralWidget( m_consoleWindow ); | 232 | setCentralWidget( m_consoleWindow ); |
231 | 233 | ||
232 | } | 234 | } |
233 | 235 | ||
234 | ProfileManager* MainWindow::manager() { | 236 | ProfileManager* MainWindow::manager() { |
235 | return m_manager; | 237 | return m_manager; |
236 | } | 238 | } |
237 | TabWidget* MainWindow::tabWidget() { | 239 | TabWidget* MainWindow::tabWidget() { |
238 | return m_consoleWindow; | 240 | return m_consoleWindow; |
239 | } | 241 | } |
240 | void MainWindow::populateProfiles() { | 242 | void MainWindow::populateProfiles() { |
241 | m_sessionsPop->clear(); | 243 | m_sessionsPop->clear(); |
242 | Profile::ValueList list = manager()->all(); | 244 | Profile::ValueList list = manager()->all(); |
243 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 245 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
244 | m_sessionsPop->insertItem( (*it).name() ); | 246 | m_sessionsPop->insertItem( (*it).name() ); |
245 | } | 247 | } |
246 | 248 | ||
247 | } | 249 | } |
248 | MainWindow::~MainWindow() { | 250 | MainWindow::~MainWindow() { |
249 | delete m_factory; | 251 | delete m_factory; |
250 | manager()->save(); | 252 | manager()->save(); |
251 | } | 253 | } |
252 | 254 | ||
253 | MetaFactory* MainWindow::factory() { | 255 | MetaFactory* MainWindow::factory() { |
254 | return m_factory; | 256 | return m_factory; |
255 | } | 257 | } |
@@ -431,48 +433,62 @@ void MainWindow::slotOpenKeb(bool state) { | |||
431 | 433 | ||
432 | if (state) m_keyBar->show(); | 434 | if (state) m_keyBar->show(); |
433 | else m_keyBar->hide(); | 435 | else m_keyBar->hide(); |
434 | 436 | ||
435 | } | 437 | } |
436 | void MainWindow::slotSessionChanged( Session* ses ) { | 438 | void MainWindow::slotSessionChanged( Session* ses ) { |
437 | qWarning("changed!"); | 439 | qWarning("changed!"); |
438 | if ( ses ) { | 440 | if ( ses ) { |
439 | m_curSession = ses; | 441 | m_curSession = ses; |
440 | 442 | ||
441 | if ( m_curSession->isConnected() ) { | 443 | if ( m_curSession->isConnected() ) { |
442 | m_connect->setEnabled( false ); | 444 | m_connect->setEnabled( false ); |
443 | m_disconnect->setEnabled( true ); | 445 | m_disconnect->setEnabled( true ); |
444 | } else { | 446 | } else { |
445 | m_connect->setEnabled( true ); | 447 | m_connect->setEnabled( true ); |
446 | m_disconnect->setEnabled( false ); | 448 | m_disconnect->setEnabled( false ); |
447 | } | 449 | } |
448 | } | 450 | } |
449 | } | 451 | } |
450 | 452 | ||
451 | void MainWindow::slotFullscreen() { | 453 | void MainWindow::slotFullscreen() { |
452 | 454 | ||
453 | if ( m_isFullscreen ) { | 455 | if ( m_isFullscreen ) { |
454 | ( m_curSession->widgetStack() )->reparent( m_consoleWindow, 0, QPoint(0,0), false ); | 456 | ( m_curSession->widgetStack() )->reparent( m_consoleWindow, 0, QPoint(0,0), false ); |
455 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 457 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
456 | setCentralWidget( m_consoleWindow ); | 458 | setCentralWidget( m_consoleWindow ); |
457 | ( m_curSession->widgetStack() )->show(); | 459 | ( m_curSession->widgetStack() )->show(); |
458 | m_fullscreen->setText( tr("Full screen") ); | 460 | m_fullscreen->setText( tr("Full screen") ); |
459 | 461 | ||
460 | } else { | 462 | } else { |
461 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); | 463 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); |
462 | ( m_curSession->widgetStack() )->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop, | 464 | ( m_curSession->widgetStack() )->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop, |
463 | QPoint(0,0), false); | 465 | QPoint(0,0), false); |
464 | ( m_curSession->widgetStack() )->resize(qApp->desktop()->width(), qApp->desktop()->height()); | 466 | ( m_curSession->widgetStack() )->resize(qApp->desktop()->width(), qApp->desktop()->height()); |
465 | ( m_curSession->widgetStack() )->setFocus(); | 467 | ( m_curSession->widgetStack() )->setFocus(); |
466 | ( m_curSession->widgetStack() )->show(); | 468 | ( m_curSession->widgetStack() )->show(); |
467 | 469 | ||
468 | //QPushButton *cornerButton = new QPushButton( ); | 470 | //QPushButton *cornerButton = new QPushButton( ); |
469 | //cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) ); | 471 | //cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) ); |
470 | //connect( cornerButton, SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 472 | //connect( cornerButton, SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
471 | // need teh scrollbar | 473 | // need teh scrollbar |
472 | // ( m_curSession->widgetStack() )->setCornerWidget( cornerButton ); | 474 | // ( m_curSession->widgetStack() )->setCornerWidget( cornerButton ); |
473 | m_fullscreen->setText( tr("Stop full screen") ); | 475 | m_fullscreen->setText( tr("Stop full screen") ); |
474 | } | 476 | } |
475 | 477 | ||
476 | m_isFullscreen = !m_isFullscreen; | 478 | m_isFullscreen = !m_isFullscreen; |
477 | 479 | ||
478 | } | 480 | } |
481 | |||
482 | |||
483 | void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool, bool) { | ||
484 | |||
485 | qWarning("received key event! relay to TE widget"); | ||
486 | |||
487 | if ( m_curSession ) { | ||
488 | QKeyEvent ke(QEvent::KeyPress, q, u, 0); | ||
489 | |||
490 | ke.ignore(); | ||
491 | // where should i send this event? doesnt work sending it here | ||
492 | QApplication::sendEvent((QObject *)m_curSession->widgetStack(), &ke); | ||
493 | } | ||
494 | } | ||
diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h index e63078a..91ca147 100644 --- a/noncore/apps/opie-console/mainwindow.h +++ b/noncore/apps/opie-console/mainwindow.h | |||
@@ -19,95 +19,97 @@ class MetaFactory; | |||
19 | class TabWidget; | 19 | class TabWidget; |
20 | class ProfileManager; | 20 | class ProfileManager; |
21 | class Profile; | 21 | class Profile; |
22 | class FunctionKeyboard; | 22 | class FunctionKeyboard; |
23 | class MainWindow : public QMainWindow { | 23 | class MainWindow : public QMainWindow { |
24 | Q_OBJECT | 24 | Q_OBJECT |
25 | public: | 25 | public: |
26 | MainWindow(); | 26 | MainWindow(); |
27 | ~MainWindow(); | 27 | ~MainWindow(); |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * our factory to generate IOLayer and so on | 30 | * our factory to generate IOLayer and so on |
31 | * | 31 | * |
32 | */ | 32 | */ |
33 | MetaFactory* factory(); | 33 | MetaFactory* factory(); |
34 | 34 | ||
35 | /** | 35 | /** |
36 | * A session contains a QWidget*, | 36 | * A session contains a QWidget*, |
37 | * an IOLayer* and some infos for us | 37 | * an IOLayer* and some infos for us |
38 | */ | 38 | */ |
39 | Session* currentSession(); | 39 | Session* currentSession(); |
40 | 40 | ||
41 | /** | 41 | /** |
42 | * the session list | 42 | * the session list |
43 | */ | 43 | */ |
44 | QList<Session> sessions(); | 44 | QList<Session> sessions(); |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * | 47 | * |
48 | */ | 48 | */ |
49 | ProfileManager* manager(); | 49 | ProfileManager* manager(); |
50 | TabWidget* tabWidget(); | 50 | TabWidget* tabWidget(); |
51 | 51 | ||
52 | private slots: | 52 | private slots: |
53 | void slotNew(); | 53 | void slotNew(); |
54 | void slotConnect(); | 54 | void slotConnect(); |
55 | void slotDisconnect(); | 55 | void slotDisconnect(); |
56 | void slotTerminate(); | 56 | void slotTerminate(); |
57 | void slotConfigure(); | 57 | void slotConfigure(); |
58 | void slotClose(); | 58 | void slotClose(); |
59 | void slotProfile(int); | 59 | void slotProfile(int); |
60 | void slotTransfer(); | 60 | void slotTransfer(); |
61 | void slotOpenKeb(bool); | 61 | void slotOpenKeb(bool); |
62 | void slotRecordScript(); | 62 | void slotRecordScript(); |
63 | void slotSaveScript(); | 63 | void slotSaveScript(); |
64 | void slotRunScript(); | 64 | void slotRunScript(); |
65 | void slotFullscreen(); | 65 | void slotFullscreen(); |
66 | void slotSessionChanged( Session* ); | 66 | void slotSessionChanged( Session* ); |
67 | void slotKeyReceived(ushort, ushort, bool, bool, bool); | ||
68 | |||
67 | private: | 69 | private: |
68 | void initUI(); | 70 | void initUI(); |
69 | void populateProfiles(); | 71 | void populateProfiles(); |
70 | void create( const Profile& ); | 72 | void create( const Profile& ); |
71 | /** | 73 | /** |
72 | * the current session | 74 | * the current session |
73 | */ | 75 | */ |
74 | Session* m_curSession; | 76 | Session* m_curSession; |
75 | 77 | ||
76 | /** | 78 | /** |
77 | * the session list | 79 | * the session list |
78 | */ | 80 | */ |
79 | QList<Session> m_sessions; | 81 | QList<Session> m_sessions; |
80 | 82 | ||
81 | /** | 83 | /** |
82 | * the metafactory | 84 | * the metafactory |
83 | */ | 85 | */ |
84 | MetaFactory* m_factory; | 86 | MetaFactory* m_factory; |
85 | ProfileManager* m_manager; | 87 | ProfileManager* m_manager; |
86 | 88 | ||
87 | TabWidget* m_consoleWindow; | 89 | TabWidget* m_consoleWindow; |
88 | QToolBar* m_tool; | 90 | QToolBar* m_tool; |
89 | QToolBar* m_icons; | 91 | QToolBar* m_icons; |
90 | QToolBar* m_keyBar; | 92 | QToolBar* m_keyBar; |
91 | QMenuBar* m_bar; | 93 | QMenuBar* m_bar; |
92 | QPopupMenu* m_console; | 94 | QPopupMenu* m_console; |
93 | QPopupMenu* m_settings; | 95 | QPopupMenu* m_settings; |
94 | QPopupMenu* m_sessionsPop; | 96 | QPopupMenu* m_sessionsPop; |
95 | QPopupMenu* m_scripts; | 97 | QPopupMenu* m_scripts; |
96 | QAction* m_connect; | 98 | QAction* m_connect; |
97 | QAction* m_disconnect; | 99 | QAction* m_disconnect; |
98 | QAction* m_terminate; | 100 | QAction* m_terminate; |
99 | QAction* m_transfer; | 101 | QAction* m_transfer; |
100 | QAction* m_setProfiles; | 102 | QAction* m_setProfiles; |
101 | QAction* m_openKeys; | 103 | QAction* m_openKeys; |
102 | QAction* m_recordScript; | 104 | QAction* m_recordScript; |
103 | QAction* m_saveScript; | 105 | QAction* m_saveScript; |
104 | QAction* m_runScript; | 106 | QAction* m_runScript; |
105 | QAction* m_fullscreen; | 107 | QAction* m_fullscreen; |
106 | QAction* m_closewindow; | 108 | QAction* m_closewindow; |
107 | 109 | ||
108 | FunctionKeyboard *m_kb; | 110 | FunctionKeyboard *m_kb; |
109 | bool m_isFullscreen; | 111 | bool m_isFullscreen; |
110 | }; | 112 | }; |
111 | 113 | ||
112 | 114 | ||
113 | #endif | 115 | #endif |