summaryrefslogtreecommitdiff
authorjosef <josef>2002-10-20 16:39:25 (UTC)
committer josef <josef>2002-10-20 16:39:25 (UTC)
commit1f106a8b44ae659f30361588f53354e8f1985974 (patch) (unidiff)
tree7d5fc441c776ec8ad5313350ea78c3289cca2bc2
parentd3936c24518e9fea48a060eaef02e64a89646657 (diff)
downloadopie-1f106a8b44ae659f30361588f53354e8f1985974.zip
opie-1f106a8b44ae659f30361588f53354e8f1985974.tar.gz
opie-1f106a8b44ae659f30361588f53354e8f1985974.tar.bz2
- fix focus handling:
If a new session is created, it gets the focus. Likewise, if we switch the session. Before the patch, one had to click inside the term window to be able to type.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 49f9653..afac542 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -54,480 +54,486 @@ void MainWindow::initUI() {
54 m_tool->setHorizontalStretchable( TRUE ); 54 m_tool->setHorizontalStretchable( TRUE );
55 55
56 m_bar = new QMenuBar( m_tool ); 56 m_bar = new QMenuBar( m_tool );
57 m_console = new QPopupMenu( this ); 57 m_console = new QPopupMenu( this );
58 m_scripts = new QPopupMenu( this ); 58 m_scripts = new QPopupMenu( this );
59 m_sessionsPop= new QPopupMenu( this ); 59 m_sessionsPop= new QPopupMenu( this );
60 //m_settings = new QPopupMenu( this ); 60 //m_settings = new QPopupMenu( this );
61 61
62 /* add a toolbar for icons */ 62 /* add a toolbar for icons */
63 m_icons = new QToolBar(this); 63 m_icons = new QToolBar(this);
64 64
65 65
66 66
67 67
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 /* 92 /*
93 * connect action 93 * connect action
94 */ 94 */
95 m_connect = new QAction(); 95 m_connect = new QAction();
96 m_connect->setText( tr("Connect") ); 96 m_connect->setText( tr("Connect") );
97 m_connect->addTo( m_console ); 97 m_connect->addTo( m_console );
98 connect(m_connect, SIGNAL(activated() ), 98 connect(m_connect, SIGNAL(activated() ),
99 this, SLOT(slotConnect() ) ); 99 this, SLOT(slotConnect() ) );
100 100
101 /* 101 /*
102 * disconnect action 102 * disconnect action
103 */ 103 */
104 m_disconnect = new QAction(); 104 m_disconnect = new QAction();
105 m_disconnect->setText( tr("Disconnect") ); 105 m_disconnect->setText( tr("Disconnect") );
106 m_disconnect->addTo( m_console ); 106 m_disconnect->addTo( m_console );
107 connect(m_disconnect, SIGNAL(activated() ), 107 connect(m_disconnect, SIGNAL(activated() ),
108 this, SLOT(slotDisconnect() ) ); 108 this, SLOT(slotDisconnect() ) );
109 109
110 m_console->insertSeparator(); 110 m_console->insertSeparator();
111 111
112 m_transfer = new QAction(); 112 m_transfer = new QAction();
113 m_transfer->setText( tr("Transfer file...") ); 113 m_transfer->setText( tr("Transfer file...") );
114 m_transfer->addTo( m_console ); 114 m_transfer->addTo( m_console );
115 connect(m_transfer, SIGNAL(activated() ), 115 connect(m_transfer, SIGNAL(activated() ),
116 this, SLOT(slotTransfer() ) ); 116 this, SLOT(slotTransfer() ) );
117 117
118 118
119 /* 119 /*
120 * fullscreen 120 * fullscreen
121 */ 121 */
122 m_isFullscreen = false; 122 m_isFullscreen = false;
123 123
124 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) 124 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" )
125 , QString::null, 0, this, 0); 125 , QString::null, 0, this, 0);
126 m_fullscreen->addTo( m_console ); 126 m_fullscreen->addTo( m_console );
127 m_fullscreen->addTo( m_icons ); 127 m_fullscreen->addTo( m_icons );
128 connect( m_fullscreen, SIGNAL( activated() ), 128 connect( m_fullscreen, SIGNAL( activated() ),
129 this, SLOT( slotFullscreen() ) ); 129 this, SLOT( slotFullscreen() ) );
130 130
131 m_console->insertSeparator(); 131 m_console->insertSeparator();
132 /* 132 /*
133 * terminate action 133 * terminate action
134 */ 134 */
135 m_terminate = new QAction(); 135 m_terminate = new QAction();
136 m_terminate->setText( tr("Terminate") ); 136 m_terminate->setText( tr("Terminate") );
137 m_terminate->addTo( m_console ); 137 m_terminate->addTo( m_console );
138 connect(m_terminate, SIGNAL(activated() ), 138 connect(m_terminate, SIGNAL(activated() ),
139 this, SLOT(slotTerminate() ) ); 139 this, SLOT(slotTerminate() ) );
140 140
141 m_closewindow = new QAction(); 141 m_closewindow = new QAction();
142 m_closewindow->setText( tr("Close Window") ); 142 m_closewindow->setText( tr("Close Window") );
143 m_closewindow->addTo( m_console ); 143 m_closewindow->addTo( m_console );
144 connect( m_closewindow, SIGNAL(activated() ), 144 connect( m_closewindow, SIGNAL(activated() ),
145 this, SLOT(slotClose() ) ); 145 this, SLOT(slotClose() ) );
146 146
147 147
148 /* 148 /*
149 * script actions 149 * script actions
150 */ 150 */
151 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); 151 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
152 m_recordScript->addTo(m_scripts); 152 m_recordScript->addTo(m_scripts);
153 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); 153 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript()));
154 154
155 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); 155 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0);
156 m_saveScript->addTo(m_scripts); 156 m_saveScript->addTo(m_scripts);
157 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); 157 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript()));
158 158
159 m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); 159 m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0);
160 m_runScript->addTo(m_scripts); 160 m_runScript->addTo(m_scripts);
161 connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); 161 connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript()));
162 162
163 /* 163 /*
164 * action that open/closes the keyboard 164 * action that open/closes the keyboard
165 */ 165 */
166 m_openKeys = new QAction (tr("Open Keyboard..."), 166 m_openKeys = new QAction (tr("Open Keyboard..."),
167 Resource::loadPixmap( "console/keyboard_icon.png" ), 167 Resource::loadPixmap( "console/keyboard_icon.png" ),
168 QString::null, 0, this, 0); 168 QString::null, 0, this, 0);
169 169
170 m_openKeys->setToggleAction(true); 170 m_openKeys->setToggleAction(true);
171 171
172 connect (m_openKeys, SIGNAL(toggled(bool)), 172 connect (m_openKeys, SIGNAL(toggled(bool)),
173 this, SLOT(slotOpenKeb(bool))); 173 this, SLOT(slotOpenKeb(bool)));
174 m_openKeys->addTo(m_icons); 174 m_openKeys->addTo(m_icons);
175 175
176 176
177 /* 177 /*
178 * action that open/closes the keyboard 178 * action that open/closes the keyboard
179 */ 179 */
180 m_openButtons = new QAction ( tr( "Open Buttons..." ), 180 m_openButtons = new QAction ( tr( "Open Buttons..." ),
181 Resource::loadPixmap( "down" ), 181 Resource::loadPixmap( "down" ),
182 QString::null, 0, this, 0 ); 182 QString::null, 0, this, 0 );
183 183
184 m_openButtons->setToggleAction( true ); 184 m_openButtons->setToggleAction( true );
185 185
186 connect ( m_openButtons, SIGNAL( toggled( bool ) ), 186 connect ( m_openButtons, SIGNAL( toggled( bool ) ),
187 this, SLOT( slotOpenButtons( bool ) ) ); 187 this, SLOT( slotOpenButtons( bool ) ) );
188 m_openButtons->addTo( m_icons ); 188 m_openButtons->addTo( m_icons );
189 189
190 190
191 /* insert the submenu */ 191 /* insert the submenu */
192 m_console->insertItem(tr("New from Profile"), m_sessionsPop, 192 m_console->insertItem(tr("New from Profile"), m_sessionsPop,
193 -1, 0); 193 -1, 0);
194 194
195 /* insert the connection menu */ 195 /* insert the connection menu */
196 m_bar->insertItem( tr("Connection"), m_console ); 196 m_bar->insertItem( tr("Connection"), m_console );
197 197
198 /* the scripts menu */ 198 /* the scripts menu */
199 m_bar->insertItem( tr("Scripts"), m_scripts ); 199 m_bar->insertItem( tr("Scripts"), m_scripts );
200 200
201 /* the settings menu */ 201 /* the settings menu */
202 // m_bar->insertItem( tr("Settings"), m_settings ); 202 // m_bar->insertItem( tr("Settings"), m_settings );
203 203
204 /* and the keyboard */ 204 /* and the keyboard */
205 m_keyBar = new QToolBar(this); 205 m_keyBar = new QToolBar(this);
206 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); 206 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE );
207 m_keyBar->setHorizontalStretchable( TRUE ); 207 m_keyBar->setHorizontalStretchable( TRUE );
208 m_keyBar->hide(); 208 m_keyBar->hide();
209 209
210 m_kb = new FunctionKeyboard(m_keyBar); 210 m_kb = new FunctionKeyboard(m_keyBar);
211 connect(m_kb, SIGNAL(keyPressed(ushort, ushort, bool, bool, bool)), 211 connect(m_kb, SIGNAL(keyPressed(ushort, ushort, bool, bool, bool)),
212 this, SLOT(slotKeyReceived(ushort, ushort, bool, bool, bool))); 212 this, SLOT(slotKeyReceived(ushort, ushort, bool, bool, bool)));
213 213
214 m_buttonBar = new QToolBar( this ); 214 m_buttonBar = new QToolBar( this );
215 addToolBar( m_buttonBar, "Buttons", QMainWindow::Top, TRUE ); 215 addToolBar( m_buttonBar, "Buttons", QMainWindow::Top, TRUE );
216 m_buttonBar->setHorizontalStretchable( TRUE ); 216 m_buttonBar->setHorizontalStretchable( TRUE );
217 m_buttonBar->hide(); 217 m_buttonBar->hide();
218 218
219 m_qb = new QuickButton( m_buttonBar ); 219 m_qb = new QuickButton( m_buttonBar );
220 connect( m_qb, SIGNAL( keyPressed( ushort, ushort, bool, bool, bool) ), 220 connect( m_qb, SIGNAL( keyPressed( ushort, ushort, bool, bool, bool) ),
221 this, SLOT( slotKeyReceived( ushort, ushort, bool, bool, bool) ) ); 221 this, SLOT( slotKeyReceived( ushort, ushort, bool, bool, bool) ) );
222 222
223 223
224 m_connect->setEnabled( false ); 224 m_connect->setEnabled( false );
225 m_disconnect->setEnabled( false ); 225 m_disconnect->setEnabled( false );
226 m_terminate->setEnabled( false ); 226 m_terminate->setEnabled( false );
227 m_transfer->setEnabled( false ); 227 m_transfer->setEnabled( false );
228 m_recordScript->setEnabled( false ); 228 m_recordScript->setEnabled( false );
229 m_saveScript->setEnabled( false ); 229 m_saveScript->setEnabled( false );
230 m_runScript->setEnabled( false ); 230 m_runScript->setEnabled( false );
231 m_fullscreen->setEnabled( false ); 231 m_fullscreen->setEnabled( false );
232 m_closewindow->setEnabled( false ); 232 m_closewindow->setEnabled( false );
233 233
234 /* 234 /*
235 * connect to the menu activation 235 * connect to the menu activation
236 */ 236 */
237 connect( m_sessionsPop, SIGNAL(activated( int ) ), 237 connect( m_sessionsPop, SIGNAL(activated( int ) ),
238 this, SLOT(slotProfile( int ) ) ); 238 this, SLOT(slotProfile( int ) ) );
239 239
240 m_consoleWindow = new TabWidget( this, "blah"); 240 m_consoleWindow = new TabWidget( this, "blah");
241 connect(m_consoleWindow, SIGNAL(activated(Session*) ), 241 connect(m_consoleWindow, SIGNAL(activated(Session*) ),
242 this, SLOT(slotSessionChanged(Session*) ) ); 242 this, SLOT(slotSessionChanged(Session*) ) );
243 setCentralWidget( m_consoleWindow ); 243 setCentralWidget( m_consoleWindow );
244 244
245} 245}
246 246
247ProfileManager* MainWindow::manager() { 247ProfileManager* MainWindow::manager() {
248 return m_manager; 248 return m_manager;
249} 249}
250TabWidget* MainWindow::tabWidget() { 250TabWidget* MainWindow::tabWidget() {
251 return m_consoleWindow; 251 return m_consoleWindow;
252} 252}
253void MainWindow::populateProfiles() { 253void MainWindow::populateProfiles() {
254 m_sessionsPop->clear(); 254 m_sessionsPop->clear();
255 Profile::ValueList list = manager()->all(); 255 Profile::ValueList list = manager()->all();
256 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { 256 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) {
257 m_sessionsPop->insertItem( (*it).name() ); 257 m_sessionsPop->insertItem( (*it).name() );
258 } 258 }
259 259
260} 260}
261MainWindow::~MainWindow() { 261MainWindow::~MainWindow() {
262 delete m_factory; 262 delete m_factory;
263 manager()->save(); 263 manager()->save();
264} 264}
265 265
266MetaFactory* MainWindow::factory() { 266MetaFactory* MainWindow::factory() {
267 return m_factory; 267 return m_factory;
268} 268}
269 269
270Session* MainWindow::currentSession() { 270Session* MainWindow::currentSession() {
271 return m_curSession; 271 return m_curSession;
272} 272}
273 273
274QList<Session> MainWindow::sessions() { 274QList<Session> MainWindow::sessions() {
275 return m_sessions; 275 return m_sessions;
276} 276}
277 277
278void MainWindow::slotNew() { 278void MainWindow::slotNew() {
279 ProfileEditorDialog dlg(factory() ); 279 ProfileEditorDialog dlg(factory() );
280 dlg.showMaximized(); 280 dlg.showMaximized();
281 int ret = dlg.exec(); 281 int ret = dlg.exec();
282 282
283 if ( ret == QDialog::Accepted ) { 283 if ( ret == QDialog::Accepted ) {
284 create( dlg.profile() ); 284 create( dlg.profile() );
285 } 285 }
286} 286}
287 287
288void MainWindow::slotRecordScript() { 288void MainWindow::slotRecordScript() {
289 if (currentSession()) { 289 if (currentSession()) {
290 currentSession()->emulationHandler()->startRecording(); 290 currentSession()->emulationHandler()->startRecording();
291 } 291 }
292} 292}
293 293
294void MainWindow::slotSaveScript() { 294void MainWindow::slotSaveScript() {
295 if (currentSession() && currentSession()->emulationHandler()->isRecording()) { 295 if (currentSession() && currentSession()->emulationHandler()->isRecording()) {
296 MimeTypes types; 296 MimeTypes types;
297 QStringList script; 297 QStringList script;
298 script << "text/plain"; 298 script << "text/plain";
299 types.insert("Script", script); 299 types.insert("Script", script);
300 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); 300 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types);
301 if (!filename.isEmpty()) { 301 if (!filename.isEmpty()) {
302 currentSession()->emulationHandler()->script()->saveTo(filename); 302 currentSession()->emulationHandler()->script()->saveTo(filename);
303 currentSession()->emulationHandler()->clearScript(); 303 currentSession()->emulationHandler()->clearScript();
304 } 304 }
305 } 305 }
306} 306}
307 307
308void MainWindow::slotRunScript() { 308void MainWindow::slotRunScript() {
309 if (currentSession()) { 309 if (currentSession()) {
310 MimeTypes types; 310 MimeTypes types;
311 QStringList script; 311 QStringList script;
312 script << "text/plain"; 312 script << "text/plain";
313 types.insert("Script", script); 313 types.insert("Script", script);
314 QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); 314 QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types);
315 if (!filename.isEmpty()) { 315 if (!filename.isEmpty()) {
316 Script script(DocLnk(filename).file()); 316 Script script(DocLnk(filename).file());
317 currentSession()->emulationHandler()->runScript(&script); 317 currentSession()->emulationHandler()->runScript(&script);
318 } 318 }
319 } 319 }
320} 320}
321 321
322void MainWindow::slotConnect() { 322void MainWindow::slotConnect() {
323 if ( currentSession() ) { 323 if ( currentSession() ) {
324 bool ret = currentSession()->layer()->open(); 324 bool ret = currentSession()->layer()->open();
325 if(!ret) QMessageBox::warning(currentSession()->widgetStack(), 325 if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
326 QObject::tr("Failed"), 326 QObject::tr("Failed"),
327 QObject::tr("Connecting failed for this session.")); 327 QObject::tr("Connecting failed for this session."));
328 else { 328 else {
329 m_connect->setEnabled( false ); 329 m_connect->setEnabled( false );
330 m_disconnect->setEnabled( true ); 330 m_disconnect->setEnabled( true );
331 } 331 }
332 } 332 }
333} 333}
334 334
335void MainWindow::slotDisconnect() { 335void MainWindow::slotDisconnect() {
336 if ( currentSession() ) { 336 if ( currentSession() ) {
337 currentSession()->layer()->close(); 337 currentSession()->layer()->close();
338 m_connect->setEnabled( true ); 338 m_connect->setEnabled( true );
339 m_disconnect->setEnabled( false ); 339 m_disconnect->setEnabled( false );
340 } 340 }
341} 341}
342 342
343void MainWindow::slotTerminate() { 343void MainWindow::slotTerminate() {
344 if ( currentSession() ) 344 if ( currentSession() )
345 currentSession()->layer()->close(); 345 currentSession()->layer()->close();
346 346
347 slotClose(); 347 slotClose();
348 /* FIXME move to the next session */ 348 /* FIXME move to the next session */
349} 349}
350 350
351void MainWindow::slotConfigure() { 351void MainWindow::slotConfigure() {
352 ConfigDialog conf( manager()->all(), factory() ); 352 ConfigDialog conf( manager()->all(), factory() );
353 conf.showMaximized(); 353 conf.showMaximized();
354 354
355 int ret = conf.exec(); 355 int ret = conf.exec();
356 356
357 if ( QDialog::Accepted == ret ) { 357 if ( QDialog::Accepted == ret ) {
358 manager()->setProfiles( conf.list() ); 358 manager()->setProfiles( conf.list() );
359 manager()->save(); 359 manager()->save();
360 populateProfiles(); 360 populateProfiles();
361 } 361 }
362} 362}
363/* 363/*
364 * we will remove 364 * we will remove
365 * this window from the tabwidget 365 * this window from the tabwidget
366 * remove it from the list 366 * remove it from the list
367 * delete it 367 * delete it
368 * and set the currentSession() 368 * and set the currentSession()
369 */ 369 */
370void MainWindow::slotClose() { 370void MainWindow::slotClose() {
371 if (!currentSession() ) 371 if (!currentSession() )
372 return; 372 return;
373 373
374 Session* ses = currentSession(); 374 Session* ses = currentSession();
375 qWarning("removing! currentSession %s", currentSession()->name().latin1() ); 375 qWarning("removing! currentSession %s", currentSession()->name().latin1() );
376 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ 376 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */
377 m_curSession = NULL; 377 m_curSession = NULL;
378 tabWidget()->remove( /*currentSession()*/ses ); 378 tabWidget()->remove( /*currentSession()*/ses );
379 /*it's autodelete */ 379 /*it's autodelete */
380 m_sessions.remove( ses ); 380 m_sessions.remove( ses );
381 qWarning("after remove!!"); 381 qWarning("after remove!!");
382 382
383 if (!currentSession() ) { 383 if (!currentSession() ) {
384 m_connect->setEnabled( false ); 384 m_connect->setEnabled( false );
385 m_disconnect->setEnabled( false ); 385 m_disconnect->setEnabled( false );
386 m_terminate->setEnabled( false ); 386 m_terminate->setEnabled( false );
387 m_transfer->setEnabled( false ); 387 m_transfer->setEnabled( false );
388 m_recordScript->setEnabled( false ); 388 m_recordScript->setEnabled( false );
389 m_saveScript->setEnabled( false ); 389 m_saveScript->setEnabled( false );
390 m_runScript->setEnabled( false ); 390 m_runScript->setEnabled( false );
391 m_fullscreen->setEnabled( false ); 391 m_fullscreen->setEnabled( false );
392 m_closewindow->setEnabled( false ); 392 m_closewindow->setEnabled( false );
393 } 393 }
394} 394}
395 395
396/* 396/*
397 * We will get the name 397 * We will get the name
398 * Then the profile 398 * Then the profile
399 * and then we will make a profile 399 * and then we will make a profile
400 */ 400 */
401void MainWindow::slotProfile( int id) { 401void MainWindow::slotProfile( int id) {
402 Profile prof = manager()->profile( m_sessionsPop->text( id) ); 402 Profile prof = manager()->profile( m_sessionsPop->text( id) );
403 create( prof ); 403 create( prof );
404} 404}
405void MainWindow::create( const Profile& prof ) { 405void MainWindow::create( const Profile& prof ) {
406 Session *ses = manager()->fromProfile( prof, tabWidget() ); 406 Session *ses = manager()->fromProfile( prof, tabWidget() );
407 407
408 if((!ses) || (!ses->layer()) || (!ses->widgetStack())) 408 if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
409 { 409 {
410 QMessageBox::warning(this, 410 QMessageBox::warning(this,
411 QObject::tr("Session failed"), 411 QObject::tr("Session failed"),
412 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); 412 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>"));
413 //if(ses) delete ses; 413 //if(ses) delete ses;
414 return; 414 return;
415 } 415 }
416 416
417 m_sessions.append( ses ); 417 m_sessions.append( ses );
418 tabWidget()->add( ses ); 418 tabWidget()->add( ses );
419 m_curSession = ses; 419 m_curSession = ses;
420 420
421 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it 421 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it
422 m_connect->setEnabled( true ); 422 m_connect->setEnabled( true );
423 m_disconnect->setEnabled( false ); 423 m_disconnect->setEnabled( false );
424 m_terminate->setEnabled( true ); 424 m_terminate->setEnabled( true );
425 m_transfer->setEnabled( true ); 425 m_transfer->setEnabled( true );
426 m_recordScript->setEnabled( true ); 426 m_recordScript->setEnabled( true );
427 m_saveScript->setEnabled( true ); 427 m_saveScript->setEnabled( true );
428 m_runScript->setEnabled( true ); 428 m_runScript->setEnabled( true );
429 m_fullscreen->setEnabled( true ); 429 m_fullscreen->setEnabled( true );
430 m_closewindow->setEnabled( true ); 430 m_closewindow->setEnabled( true );
431 431
432 432
433 // is io_layer wants direct connection, then autoconnect 433 // is io_layer wants direct connection, then autoconnect
434 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { 434 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) {
435 if (prof.autoConnect()) { 435 if (prof.autoConnect()) {
436 slotConnect(); 436 slotConnect();
437 } 437 }
438
439 QWidget *w = currentSession()->widget();
440 if(w) w->setFocus();
438} 441}
439 442
440void MainWindow::slotTransfer() 443void MainWindow::slotTransfer()
441{ 444{
442 if ( currentSession() ) { 445 if ( currentSession() ) {
443 TransferDialog dlg(currentSession()->widgetStack(), this); 446 TransferDialog dlg(currentSession()->widgetStack(), this);
444 dlg.showMaximized(); 447 dlg.showMaximized();
445 //currentSession()->widgetStack()->add(dlg); 448 //currentSession()->widgetStack()->add(dlg);
446 dlg.exec(); 449 dlg.exec();
447 } 450 }
448} 451}
449 452
450 453
451void MainWindow::slotOpenKeb(bool state) { 454void MainWindow::slotOpenKeb(bool state) {
452 455
453 if (state) m_keyBar->show(); 456 if (state) m_keyBar->show();
454 else m_keyBar->hide(); 457 else m_keyBar->hide();
455 458
456} 459}
457 460
458 461
459void MainWindow::slotOpenButtons( bool state ) { 462void MainWindow::slotOpenButtons( bool state ) {
460 463
461 if ( state ) { 464 if ( state ) {
462 m_buttonBar->show(); 465 m_buttonBar->show();
463 } else { 466 } else {
464 m_buttonBar->hide(); 467 m_buttonBar->hide();
465 } 468 }
466} 469}
467 470
468 471
469 472
470void MainWindow::slotSessionChanged( Session* ses ) { 473void MainWindow::slotSessionChanged( Session* ses ) {
471 qWarning("changed!"); 474 qWarning("changed!");
472 if ( ses ) { 475 if ( ses ) {
473 m_curSession = ses; 476 m_curSession = ses;
474 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); 477 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) );
475 if ( m_curSession->layer()->isConnected() ) { 478 if ( m_curSession->layer()->isConnected() ) {
476 m_connect->setEnabled( false ); 479 m_connect->setEnabled( false );
477 m_disconnect->setEnabled( true ); 480 m_disconnect->setEnabled( true );
478 } else { 481 } else {
479 m_connect->setEnabled( true ); 482 m_connect->setEnabled( true );
480 m_disconnect->setEnabled( false ); 483 m_disconnect->setEnabled( false );
481 } 484 }
485
486 QWidget *w = m_curSession->widget();
487 if(w) w->setFocus();
482 } 488 }
483} 489}
484 490
485void MainWindow::slotFullscreen() { 491void MainWindow::slotFullscreen() {
486 492
487 493
488 494
489 if ( m_isFullscreen ) { 495 if ( m_isFullscreen ) {
490 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), false ); 496 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), false );
491 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 497 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken );
492 498
493 setCentralWidget( m_consoleWindow ); 499 setCentralWidget( m_consoleWindow );
494 ( m_curSession->widgetStack() )->show(); 500 ( m_curSession->widgetStack() )->show();
495 ( m_curSession->emulationHandler() )->cornerButton()->hide(); 501 ( m_curSession->emulationHandler() )->cornerButton()->hide();
496 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 502 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
497 503
498 } else { 504 } else {
499 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); 505 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget();
500 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); 506 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame );
501 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop 507 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop
502 , QPoint(0,0), false ); 508 , QPoint(0,0), false );
503 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); 509 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() );
504 ( m_curSession->widgetStack() )->setFocus(); 510 ( m_curSession->widgetStack() )->setFocus();
505 ( m_curSession->widgetStack() )->show(); 511 ( m_curSession->widgetStack() )->show();
506 512
507 ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); 513 ( ( m_curSession->emulationHandler() )->cornerButton() )->show();
508 514
509 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 515 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
510 } 516 }
511 517
512 m_isFullscreen = !m_isFullscreen; 518 m_isFullscreen = !m_isFullscreen;
513} 519}
514 520
515 521
516void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool pressed, bool) { 522void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool pressed, bool) {
517 523
518 //qWarning("unicode: %x, qkey: %x, %s", u, q, pressed ? "pressed" : "released"); 524 //qWarning("unicode: %x, qkey: %x, %s", u, q, pressed ? "pressed" : "released");
519 525
520 if ( m_curSession ) { 526 if ( m_curSession ) {
521 527
522 QEvent::Type state; 528 QEvent::Type state;
523 529
524 if (pressed) state = QEvent::KeyPress; 530 if (pressed) state = QEvent::KeyPress;
525 else state = QEvent::KeyRelease; 531 else state = QEvent::KeyRelease;
526 532
527 QKeyEvent ke(state, q, u, 0, QString(QChar(u))); 533 QKeyEvent ke(state, q, u, 0, QString(QChar(u)));
528 534
529 // where should i send this event? doesnt work sending it here 535 // where should i send this event? doesnt work sending it here
530 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); 536 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke);
531 ke.ignore(); 537 ke.ignore();
532 } 538 }
533} 539}