summaryrefslogtreecommitdiff
authorhash <hash>2002-10-15 16:25:43 (UTC)
committer hash <hash>2002-10-15 16:25:43 (UTC)
commitd0cd09e4a68ca8dc3acf50c13a0acce39cd36b55 (patch) (unidiff)
tree7562d562c6463a9f28587af3c1138e1f780dfb3d
parent09ba4d2c79a41b185902519639032a49c85deadb (diff)
downloadopie-d0cd09e4a68ca8dc3acf50c13a0acce39cd36b55.zip
opie-d0cd09e4a68ca8dc3acf50c13a0acce39cd36b55.tar.gz
opie-d0cd09e4a68ca8dc3acf50c13a0acce39cd36b55.tar.bz2
added a keyReceive slot so sending key events to the TE widget _might_ be possible (havent figure that out yet...)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp16
-rw-r--r--noncore/apps/opie-console/mainwindow.h2
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
@@ -1,478 +1,494 @@
1#include <assert.h> 1#include <assert.h>
2 2
3 3
4 4
5#include <qaction.h> 5#include <qaction.h>
6#include <qmenubar.h> 6#include <qmenubar.h>
7#include <qlabel.h> 7#include <qlabel.h>
8#include <qpopupmenu.h> 8#include <qpopupmenu.h>
9#include <qtoolbar.h> 9#include <qtoolbar.h>
10#include <qmessagebox.h> 10#include <qmessagebox.h>
11#include <qpushbutton.h> 11#include <qpushbutton.h>
12 12
13#include <qpe/resource.h> 13#include <qpe/resource.h>
14#include <opie/ofiledialog.h> 14#include <opie/ofiledialog.h>
15 15
16 16
17#include "keytrans.h" 17#include "keytrans.h"
18#include "profileeditordialog.h" 18#include "profileeditordialog.h"
19#include "configdialog.h" 19#include "configdialog.h"
20#include "default.h" 20#include "default.h"
21#include "metafactory.h" 21#include "metafactory.h"
22#include "profile.h" 22#include "profile.h"
23#include "profilemanager.h" 23#include "profilemanager.h"
24#include "mainwindow.h" 24#include "mainwindow.h"
25#include "tabwidget.h" 25#include "tabwidget.h"
26#include "transferdialog.h" 26#include "transferdialog.h"
27#include "function_keyboard.h" 27#include "function_keyboard.h"
28#include "script.h" 28#include "script.h"
29 29
30 30
31 31
32static char * menu_xpm[] = { 32static char * menu_xpm[] = {
33"12 12 5 1", 33"12 12 5 1",
34 " c None", 34 " c None",
35 ".c #000000", 35 ".c #000000",
36 "+c #FFFDAD", 36 "+c #FFFDAD",
37 "@c #FFFF00", 37 "@c #FFFF00",
38 "#c #E5E100", 38 "#c #E5E100",
39" ", 39" ",
40" ", 40" ",
41" ......... ", 41" ......... ",
42" .+++++++. ", 42" .+++++++. ",
43" .+@@@@#. ", 43" .+@@@@#. ",
44" .+@@@#. ", 44" .+@@@#. ",
45" .+@@#. ", 45" .+@@#. ",
46" .+@#. ", 46" .+@#. ",
47" .+#. ", 47" .+#. ",
48" .+. ", 48" .+. ",
49" .. ", 49" .. ",
50" "}; 50" "};
51 51
52 52
53MainWindow::MainWindow() { 53MainWindow::MainWindow() {
54 KeyTrans::loadAll(); 54 KeyTrans::loadAll();
55 for (int i = 0; i < KeyTrans::count(); i++ ) { 55 for (int i = 0; i < KeyTrans::count(); i++ ) {
56 KeyTrans* s = KeyTrans::find(i ); 56 KeyTrans* s = KeyTrans::find(i );
57 assert( s ); 57 assert( s );
58 } 58 }
59 m_factory = new MetaFactory(); 59 m_factory = new MetaFactory();
60 Default def(m_factory); 60 Default def(m_factory);
61 m_sessions.setAutoDelete( TRUE ); 61 m_sessions.setAutoDelete( TRUE );
62 m_curSession = 0; 62 m_curSession = 0;
63 m_manager = new ProfileManager( m_factory ); 63 m_manager = new ProfileManager( m_factory );
64 m_manager->load(); 64 m_manager->load();
65 65
66 initUI(); 66 initUI();
67 populateProfiles(); 67 populateProfiles();
68} 68}
69void MainWindow::initUI() { 69void MainWindow::initUI() {
70 setToolBarsMovable( FALSE ); 70 setToolBarsMovable( FALSE );
71 71
72 /* tool bar for the menu */ 72 /* tool bar for the menu */
73 m_tool = new QToolBar( this ); 73 m_tool = new QToolBar( this );
74 m_tool->setHorizontalStretchable( TRUE ); 74 m_tool->setHorizontalStretchable( TRUE );
75 75
76 m_bar = new QMenuBar( m_tool ); 76 m_bar = new QMenuBar( m_tool );
77 m_console = new QPopupMenu( this ); 77 m_console = new QPopupMenu( this );
78 m_scripts = new QPopupMenu( this ); 78 m_scripts = new QPopupMenu( this );
79 m_sessionsPop= new QPopupMenu( this ); 79 m_sessionsPop= new QPopupMenu( this );
80 m_settings = new QPopupMenu( this ); 80 m_settings = new QPopupMenu( this );
81 81
82 /* add a toolbar for icons */ 82 /* add a toolbar for icons */
83 m_icons = new QToolBar(this); 83 m_icons = new QToolBar(this);
84 84
85 /* 85 /*
86 * new Action for new sessions 86 * new Action for new sessions
87 */ 87 */
88 QAction* a = new QAction(tr("New Connection"), 88 QAction* a = new QAction(tr("New Connection"),
89 Resource::loadPixmap( "new" ), 89 Resource::loadPixmap( "new" ),
90 QString::null, 0, this, 0); 90 QString::null, 0, this, 0);
91 a->addTo( m_console ); 91 a->addTo( m_console );
92 a->addTo( m_icons ); 92 a->addTo( m_icons );
93 connect(a, SIGNAL(activated() ), 93 connect(a, SIGNAL(activated() ),
94 this, SLOT(slotNew() ) ); 94 this, SLOT(slotNew() ) );
95 95
96 /* 96 /*
97 * connect action 97 * connect action
98 */ 98 */
99 m_connect = new QAction(); 99 m_connect = new QAction();
100 m_connect->setText( tr("Connect") ); 100 m_connect->setText( tr("Connect") );
101 m_connect->addTo( m_console ); 101 m_connect->addTo( m_console );
102 connect(m_connect, SIGNAL(activated() ), 102 connect(m_connect, SIGNAL(activated() ),
103 this, SLOT(slotConnect() ) ); 103 this, SLOT(slotConnect() ) );
104 104
105 /* 105 /*
106 * disconnect action 106 * disconnect action
107 */ 107 */
108 m_disconnect = new QAction(); 108 m_disconnect = new QAction();
109 m_disconnect->setText( tr("Disconnect") ); 109 m_disconnect->setText( tr("Disconnect") );
110 m_disconnect->addTo( m_console ); 110 m_disconnect->addTo( m_console );
111 connect(m_disconnect, SIGNAL(activated() ), 111 connect(m_disconnect, SIGNAL(activated() ),
112 this, SLOT(slotDisconnect() ) ); 112 this, SLOT(slotDisconnect() ) );
113 113
114 m_transfer = new QAction(); 114 m_transfer = new QAction();
115 m_transfer->setText( tr("Transfer file...") ); 115 m_transfer->setText( tr("Transfer file...") );
116 m_transfer->addTo( m_console ); 116 m_transfer->addTo( m_console );
117 connect(m_transfer, SIGNAL(activated() ), 117 connect(m_transfer, SIGNAL(activated() ),
118 this, SLOT(slotTransfer() ) ); 118 this, SLOT(slotTransfer() ) );
119 119
120 120
121 /* 121 /*
122 * fullscreen 122 * fullscreen
123 */ 123 */
124 m_isFullscreen = false; 124 m_isFullscreen = false;
125 125
126 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) 126 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" )
127 , QString::null, 0, this, 0); 127 , QString::null, 0, this, 0);
128 m_fullscreen->addTo( m_console ); 128 m_fullscreen->addTo( m_console );
129 m_fullscreen->addTo( m_icons ); 129 m_fullscreen->addTo( m_icons );
130 connect( m_fullscreen, SIGNAL( activated() ), 130 connect( m_fullscreen, SIGNAL( activated() ),
131 this, SLOT( slotFullscreen() ) ); 131 this, SLOT( slotFullscreen() ) );
132 132
133 /* 133 /*
134 * terminate action 134 * terminate action
135 */ 135 */
136 m_terminate = new QAction(); 136 m_terminate = new QAction();
137 m_terminate->setText( tr("Terminate") ); 137 m_terminate->setText( tr("Terminate") );
138 m_terminate->addTo( m_console ); 138 m_terminate->addTo( m_console );
139 connect(m_terminate, SIGNAL(activated() ), 139 connect(m_terminate, SIGNAL(activated() ),
140 this, SLOT(slotTerminate() ) ); 140 this, SLOT(slotTerminate() ) );
141 141
142 m_closewindow = new QAction(); 142 m_closewindow = new QAction();
143 m_closewindow->setText( tr("Close Window") ); 143 m_closewindow->setText( tr("Close Window") );
144 m_closewindow->addTo( m_console ); 144 m_closewindow->addTo( m_console );
145 connect( m_closewindow, SIGNAL(activated() ), 145 connect( m_closewindow, SIGNAL(activated() ),
146 this, SLOT(slotClose() ) ); 146 this, SLOT(slotClose() ) );
147 147
148 /* 148 /*
149 * the settings action 149 * the settings action
150 */ 150 */
151 m_setProfiles = new QAction(tr("Configure Profiles"), 151 m_setProfiles = new QAction(tr("Configure Profiles"),
152 Resource::loadPixmap( "SettingsIcon" ), 152 Resource::loadPixmap( "SettingsIcon" ),
153 QString::null, 0, this, 0); 153 QString::null, 0, this, 0);
154 m_setProfiles->addTo( m_settings ); 154 m_setProfiles->addTo( m_settings );
155 m_setProfiles->addTo( m_icons ); 155 m_setProfiles->addTo( m_icons );
156 connect( m_setProfiles, SIGNAL(activated() ), 156 connect( m_setProfiles, SIGNAL(activated() ),
157 this, SLOT(slotConfigure() ) ); 157 this, SLOT(slotConfigure() ) );
158 158
159 /* 159 /*
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
234ProfileManager* MainWindow::manager() { 236ProfileManager* MainWindow::manager() {
235 return m_manager; 237 return m_manager;
236} 238}
237TabWidget* MainWindow::tabWidget() { 239TabWidget* MainWindow::tabWidget() {
238 return m_consoleWindow; 240 return m_consoleWindow;
239} 241}
240void MainWindow::populateProfiles() { 242void 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}
248MainWindow::~MainWindow() { 250MainWindow::~MainWindow() {
249 delete m_factory; 251 delete m_factory;
250 manager()->save(); 252 manager()->save();
251} 253}
252 254
253MetaFactory* MainWindow::factory() { 255MetaFactory* MainWindow::factory() {
254 return m_factory; 256 return m_factory;
255} 257}
256 258
257Session* MainWindow::currentSession() { 259Session* MainWindow::currentSession() {
258 return m_curSession; 260 return m_curSession;
259} 261}
260 262
261QList<Session> MainWindow::sessions() { 263QList<Session> MainWindow::sessions() {
262 return m_sessions; 264 return m_sessions;
263} 265}
264 266
265void MainWindow::slotNew() { 267void MainWindow::slotNew() {
266 ProfileEditorDialog dlg(factory() ); 268 ProfileEditorDialog dlg(factory() );
267 dlg.showMaximized(); 269 dlg.showMaximized();
268 int ret = dlg.exec(); 270 int ret = dlg.exec();
269 271
270 if ( ret == QDialog::Accepted ) { 272 if ( ret == QDialog::Accepted ) {
271 create( dlg.profile() ); 273 create( dlg.profile() );
272 } 274 }
273} 275}
274 276
275void MainWindow::slotRecordScript() { 277void MainWindow::slotRecordScript() {
276/* if (currentSession()) { 278/* if (currentSession()) {
277 currentSession()->emulationLayer()->startRecording(); 279 currentSession()->emulationLayer()->startRecording();
278 } 280 }
279 */ 281 */
280} 282}
281 283
282void MainWindow::slotSaveScript() { 284void MainWindow::slotSaveScript() {
283/* if (currentSession() && currentSession()->emulationLayer()->isRecording()) { 285/* if (currentSession() && currentSession()->emulationLayer()->isRecording()) {
284 MimeTypes types; 286 MimeTypes types;
285 QStringList script; 287 QStringList script;
286 script << "text/plain"; 288 script << "text/plain";
287 types.insert("Script", script); 289 types.insert("Script", script);
288 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); 290 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types);
289 if (!filename.isEmpty()) { 291 if (!filename.isEmpty()) {
290 currentSession()->emulationLayer()->script()->saveTo(filename); 292 currentSession()->emulationLayer()->script()->saveTo(filename);
291 currentSession()->emulationLayer()->clearScript(); 293 currentSession()->emulationLayer()->clearScript();
292 } 294 }
293 } 295 }
294 */ 296 */
295} 297}
296 298
297void MainWindow::slotRunScript() { 299void MainWindow::slotRunScript() {
298/* 300/*
299 if (currentSession()) { 301 if (currentSession()) {
300 MimeTypes types; 302 MimeTypes types;
301 QStringList script; 303 QStringList script;
302 script << "text/plain"; 304 script << "text/plain";
303 types.insert("Script", script); 305 types.insert("Script", script);
304 QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); 306 QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types);
305 if (!filename.isEmpty()) { 307 if (!filename.isEmpty()) {
306 Script script(DocLnk(filename).file()); 308 Script script(DocLnk(filename).file());
307 currentSession()->emulationLayer()->runScript(&script); 309 currentSession()->emulationLayer()->runScript(&script);
308 } 310 }
309 } 311 }
310 */ 312 */
311} 313}
312 314
313void MainWindow::slotConnect() { 315void MainWindow::slotConnect() {
314 if ( currentSession() ) { 316 if ( currentSession() ) {
315 bool ret = currentSession()->layer()->open(); 317 bool ret = currentSession()->layer()->open();
316 if(!ret) QMessageBox::warning(currentSession()->widgetStack(), 318 if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
317 QObject::tr("Failed"), 319 QObject::tr("Failed"),
318 QObject::tr("Connecting failed for this session.")); 320 QObject::tr("Connecting failed for this session."));
319 m_connect->setEnabled( false ); 321 m_connect->setEnabled( false );
320 m_disconnect->setEnabled( true ); 322 m_disconnect->setEnabled( true );
321 } 323 }
322} 324}
323 325
324void MainWindow::slotDisconnect() { 326void MainWindow::slotDisconnect() {
325 if ( currentSession() ) { 327 if ( currentSession() ) {
326 currentSession()->layer()->close(); 328 currentSession()->layer()->close();
327 m_connect->setEnabled( true ); 329 m_connect->setEnabled( true );
328 m_disconnect->setEnabled( false ); 330 m_disconnect->setEnabled( false );
329 } 331 }
330} 332}
331 333
332void MainWindow::slotTerminate() { 334void MainWindow::slotTerminate() {
333 if ( currentSession() ) 335 if ( currentSession() )
334 currentSession()->layer()->close(); 336 currentSession()->layer()->close();
335 337
336 slotClose(); 338 slotClose();
337 /* FIXME move to the next session */ 339 /* FIXME move to the next session */
338} 340}
339 341
340void MainWindow::slotConfigure() { 342void MainWindow::slotConfigure() {
341 ConfigDialog conf( manager()->all(), factory() ); 343 ConfigDialog conf( manager()->all(), factory() );
342 conf.showMaximized(); 344 conf.showMaximized();
343 345
344 int ret = conf.exec(); 346 int ret = conf.exec();
345 347
346 if ( QDialog::Accepted == ret ) { 348 if ( QDialog::Accepted == ret ) {
347 manager()->setProfiles( conf.list() ); 349 manager()->setProfiles( conf.list() );
348 manager()->save(); 350 manager()->save();
349 populateProfiles(); 351 populateProfiles();
350 } 352 }
351} 353}
352/* 354/*
353 * we will remove 355 * we will remove
354 * this window from the tabwidget 356 * this window from the tabwidget
355 * remove it from the list 357 * remove it from the list
356 * delete it 358 * delete it
357 * and set the currentSession() 359 * and set the currentSession()
358 */ 360 */
359void MainWindow::slotClose() { 361void MainWindow::slotClose() {
360 if (!currentSession() ) 362 if (!currentSession() )
361 return; 363 return;
362 364
363 Session* ses = currentSession(); 365 Session* ses = currentSession();
364 qWarning("removing! currentSession %s", currentSession()->name().latin1() ); 366 qWarning("removing! currentSession %s", currentSession()->name().latin1() );
365 tabWidget()->remove( currentSession() ); 367 tabWidget()->remove( currentSession() );
366 /*it's autodelete */ 368 /*it's autodelete */
367 m_sessions.remove( ses ); 369 m_sessions.remove( ses );
368 qWarning("after remove!!"); 370 qWarning("after remove!!");
369 371
370 if (!currentSession() ) { 372 if (!currentSession() ) {
371 m_connect->setEnabled( false ); 373 m_connect->setEnabled( false );
372 m_disconnect->setEnabled( false ); 374 m_disconnect->setEnabled( false );
373 m_terminate->setEnabled( false ); 375 m_terminate->setEnabled( false );
374 m_transfer->setEnabled( false ); 376 m_transfer->setEnabled( false );
375 m_recordScript->setEnabled( false ); 377 m_recordScript->setEnabled( false );
376 m_saveScript->setEnabled( false ); 378 m_saveScript->setEnabled( false );
377 m_runScript->setEnabled( false ); 379 m_runScript->setEnabled( false );
378 m_fullscreen->setEnabled( false ); 380 m_fullscreen->setEnabled( false );
379 m_closewindow->setEnabled( false ); 381 m_closewindow->setEnabled( false );
380 } 382 }
381} 383}
382 384
383/* 385/*
384 * We will get the name 386 * We will get the name
385 * Then the profile 387 * Then the profile
386 * and then we will make a profile 388 * and then we will make a profile
387 */ 389 */
388void MainWindow::slotProfile( int id) { 390void MainWindow::slotProfile( int id) {
389 Profile prof = manager()->profile( m_sessionsPop->text( id) ); 391 Profile prof = manager()->profile( m_sessionsPop->text( id) );
390 create( prof ); 392 create( prof );
391} 393}
392void MainWindow::create( const Profile& prof ) { 394void MainWindow::create( const Profile& prof ) {
393 Session *ses = manager()->fromProfile( prof, tabWidget() ); 395 Session *ses = manager()->fromProfile( prof, tabWidget() );
394 396
395 if((!ses) || (!ses->layer()) || (!ses->widgetStack())) 397 if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
396 { 398 {
397 QMessageBox::warning(this, 399 QMessageBox::warning(this,
398 QObject::tr("Session failed"), 400 QObject::tr("Session failed"),
399 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); 401 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>"));
400 //if(ses) delete ses; 402 //if(ses) delete ses;
401 return; 403 return;
402 } 404 }
403 405
404 m_sessions.append( ses ); 406 m_sessions.append( ses );
405 tabWidget()->add( ses ); 407 tabWidget()->add( ses );
406 m_curSession = ses; 408 m_curSession = ses;
407 409
408 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it 410 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it
409 m_connect->setEnabled( true ); 411 m_connect->setEnabled( true );
410 m_disconnect->setEnabled( false ); 412 m_disconnect->setEnabled( false );
411 m_terminate->setEnabled( true ); 413 m_terminate->setEnabled( true );
412 m_transfer->setEnabled( true ); 414 m_transfer->setEnabled( true );
413 m_recordScript->setEnabled( true ); 415 m_recordScript->setEnabled( true );
414 m_saveScript->setEnabled( true ); 416 m_saveScript->setEnabled( true );
415 m_runScript->setEnabled( true ); 417 m_runScript->setEnabled( true );
416 m_fullscreen->setEnabled( true ); 418 m_fullscreen->setEnabled( true );
417 m_closewindow->setEnabled( true ); 419 m_closewindow->setEnabled( true );
418} 420}
419 421
420void MainWindow::slotTransfer() 422void MainWindow::slotTransfer()
421{ 423{
422 if ( currentSession() ) { 424 if ( currentSession() ) {
423 TransferDialog dlg(this); 425 TransferDialog dlg(this);
424 dlg.showMaximized(); 426 dlg.showMaximized();
425 dlg.exec(); 427 dlg.exec();
426 } 428 }
427} 429}
428 430
429 431
430void MainWindow::slotOpenKeb(bool state) { 432void 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}
436void MainWindow::slotSessionChanged( Session* ses ) { 438void 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
451void MainWindow::slotFullscreen() { 453void 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
483void 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
@@ -1,113 +1,115 @@
1#ifndef OPIE_MAIN_WINDOW_H 1#ifndef OPIE_MAIN_WINDOW_H
2#define OPIE_MAIN_WINDOW_H 2#define OPIE_MAIN_WINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qlist.h> 5#include <qlist.h>
6 6
7#include "session.h" 7#include "session.h"
8 8
9/** 9/**
10 * this is the MainWindow of the new opie console 10 * this is the MainWindow of the new opie console
11 * it's also the dispatcher between the different 11 * it's also the dispatcher between the different
12 * actions supported by the gui 12 * actions supported by the gui
13 */ 13 */
14class QToolBar; 14class QToolBar;
15class QToolButton; 15class QToolButton;
16class QMenuBar; 16class QMenuBar;
17class QAction; 17class QAction;
18class MetaFactory; 18class MetaFactory;
19class TabWidget; 19class TabWidget;
20class ProfileManager; 20class ProfileManager;
21class Profile; 21class Profile;
22class FunctionKeyboard; 22class FunctionKeyboard;
23class MainWindow : public QMainWindow { 23class MainWindow : public QMainWindow {
24 Q_OBJECT 24 Q_OBJECT
25public: 25public:
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
52private slots: 52private 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
67private: 69private:
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