summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 27407d9..cf1fbc3 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,533 +1,533 @@
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 11
12#include <qpe/resource.h> 12#include <qpe/resource.h>
13 13
14#include <opie/ofiledialog.h> 14#include <opie/ofiledialog.h>
15 15
16#include "keytrans.h" 16#include "keytrans.h"
17#include "profileeditordialog.h" 17#include "profileeditordialog.h"
18#include "configdialog.h" 18#include "configdialog.h"
19#include "default.h" 19#include "default.h"
20#include "metafactory.h" 20#include "metafactory.h"
21#include "profile.h" 21#include "profile.h"
22#include "profilemanager.h" 22#include "profilemanager.h"
23#include "mainwindow.h" 23#include "mainwindow.h"
24#include "tabwidget.h" 24#include "tabwidget.h"
25#include "transferdialog.h" 25#include "transferdialog.h"
26#include "function_keyboard.h" 26#include "function_keyboard.h"
27#include "emulation_handler.h" 27#include "emulation_handler.h"
28#include "script.h" 28#include "script.h"
29#include "quick_button.h" 29#include "quick_button.h"
30 30
31 31
32 32
33MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { 33MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) {
34 KeyTrans::loadAll(); 34 KeyTrans::loadAll();
35 for (int i = 0; i < KeyTrans::count(); i++ ) { 35 for (int i = 0; i < KeyTrans::count(); i++ ) {
36 KeyTrans* s = KeyTrans::find(i ); 36 KeyTrans* s = KeyTrans::find(i );
37 assert( s ); 37 assert( s );
38 } 38 }
39 m_factory = new MetaFactory(); 39 m_factory = new MetaFactory();
40 Default def(m_factory); 40 Default def(m_factory);
41 m_sessions.setAutoDelete( TRUE ); 41 m_sessions.setAutoDelete( TRUE );
42 m_curSession = 0; 42 m_curSession = 0;
43 m_manager = new ProfileManager( m_factory ); 43 m_manager = new ProfileManager( m_factory );
44 m_manager->load(); 44 m_manager->load();
45 45
46 initUI(); 46 initUI();
47 populateProfiles(); 47 populateProfiles();
48} 48}
49void MainWindow::initUI() { 49void MainWindow::initUI() {
50 setToolBarsMovable( FALSE ); 50 setToolBarsMovable( FALSE );
51 51
52 /* tool bar for the menu */ 52 /* tool bar for the menu */
53 m_tool = new QToolBar( this ); 53 m_tool = new QToolBar( this );
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 80
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_transfer = new QAction(); 110 m_transfer = new QAction();
111 m_transfer->setText( tr("Transfer file...") ); 111 m_transfer->setText( tr("Transfer file...") );
112 m_transfer->addTo( m_console ); 112 m_transfer->addTo( m_console );
113 connect(m_transfer, SIGNAL(activated() ), 113 connect(m_transfer, SIGNAL(activated() ),
114 this, SLOT(slotTransfer() ) ); 114 this, SLOT(slotTransfer() ) );
115 115
116 116
117 /* 117 /*
118 * fullscreen 118 * fullscreen
119 */ 119 */
120 m_isFullscreen = false; 120 m_isFullscreen = false;
121 121
122 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) 122 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" )
123 , QString::null, 0, this, 0); 123 , QString::null, 0, this, 0);
124 m_fullscreen->addTo( m_console ); 124 m_fullscreen->addTo( m_console );
125 m_fullscreen->addTo( m_icons ); 125 m_fullscreen->addTo( m_icons );
126 connect( m_fullscreen, SIGNAL( activated() ), 126 connect( m_fullscreen, SIGNAL( activated() ),
127 this, SLOT( slotFullscreen() ) ); 127 this, SLOT( slotFullscreen() ) );
128 128
129 /* 129 /*
130 * terminate action 130 * terminate action
131 */ 131 */
132 m_terminate = new QAction(); 132 m_terminate = new QAction();
133 m_terminate->setText( tr("Terminate") ); 133 m_terminate->setText( tr("Terminate") );
134 m_terminate->addTo( m_console ); 134 m_terminate->addTo( m_console );
135 connect(m_terminate, SIGNAL(activated() ), 135 connect(m_terminate, SIGNAL(activated() ),
136 this, SLOT(slotTerminate() ) ); 136 this, SLOT(slotTerminate() ) );
137 137
138 m_closewindow = new QAction(); 138 m_closewindow = new QAction();
139 m_closewindow->setText( tr("Close Window") ); 139 m_closewindow->setText( tr("Close Window") );
140 m_closewindow->addTo( m_console ); 140 m_closewindow->addTo( m_console );
141 connect( m_closewindow, SIGNAL(activated() ), 141 connect( m_closewindow, SIGNAL(activated() ),
142 this, SLOT(slotClose() ) ); 142 this, SLOT(slotClose() ) );
143 143
144 144
145 /* 145 /*
146 * script actions 146 * script actions
147 */ 147 */
148 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); 148 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
149 m_recordScript->addTo(m_scripts); 149 m_recordScript->addTo(m_scripts);
150 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); 150 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript()));
151 151
152 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); 152 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0);
153 m_saveScript->addTo(m_scripts); 153 m_saveScript->addTo(m_scripts);
154 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); 154 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript()));
155 155
156 m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); 156 m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0);
157 m_runScript->addTo(m_scripts); 157 m_runScript->addTo(m_scripts);
158 connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); 158 connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript()));
159 159
160 /* 160 /*
161 * action that open/closes the keyboard 161 * action that open/closes the keyboard
162 */ 162 */
163 m_openKeys = new QAction (tr("Open Keyboard..."), 163 m_openKeys = new QAction (tr("Open Keyboard..."),
164 Resource::loadPixmap( "down" ), 164 Resource::loadPixmap( "down" ),
165 QString::null, 0, this, 0); 165 QString::null, 0, this, 0);
166 166
167 m_openKeys->setToggleAction(true); 167 m_openKeys->setToggleAction(true);
168 168
169 connect (m_openKeys, SIGNAL(toggled(bool)), 169 connect (m_openKeys, SIGNAL(toggled(bool)),
170 this, SLOT(slotOpenKeb(bool))); 170 this, SLOT(slotOpenKeb(bool)));
171 m_openKeys->addTo(m_icons); 171 m_openKeys->addTo(m_icons);
172 172
173 173
174 /* 174 /*
175 * action that open/closes the keyboard 175 * action that open/closes the keyboard
176 */ 176 */
177 m_openButtons = new QAction ( tr( "Open Buttons..." ), 177 m_openButtons = new QAction ( tr( "Open Buttons..." ),
178 Resource::loadPixmap( "down" ), 178 Resource::loadPixmap( "down" ),
179 QString::null, 0, this, 0 ); 179 QString::null, 0, this, 0 );
180 180
181 m_openButtons->setToggleAction( true ); 181 m_openButtons->setToggleAction( true );
182 182
183 connect ( m_openButtons, SIGNAL( toggled( bool ) ), 183 connect ( m_openButtons, SIGNAL( toggled( bool ) ),
184 this, SLOT( slotOpenButtons( bool ) ) ); 184 this, SLOT( slotOpenButtons( bool ) ) );
185 m_openButtons->addTo( m_icons ); 185 m_openButtons->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)), 208 connect(m_kb, SIGNAL(keyPressed(ushort, ushort, bool, bool, bool)),
209 this, SLOT(slotKeyReceived(ushort, ushort, bool, bool, bool))); 209 this, SLOT(slotKeyReceived(ushort, ushort, bool, bool, bool)));
210 210
211 m_buttonBar = new QToolBar( this ); 211 m_buttonBar = new QToolBar( this );
212 addToolBar( m_buttonBar, "Buttons", QMainWindow::Top, TRUE ); 212 addToolBar( m_buttonBar, "Buttons", QMainWindow::Top, TRUE );
213 m_buttonBar->setHorizontalStretchable( TRUE ); 213 m_buttonBar->setHorizontalStretchable( TRUE );
214 m_buttonBar->hide(); 214 m_buttonBar->hide();
215 215
216 m_qb = new QuickButton( m_buttonBar ); 216 m_qb = new QuickButton( m_buttonBar );
217 connect( m_qb, SIGNAL( keyPressed( ushort, ushort, bool, bool, bool) ), 217 connect( m_qb, SIGNAL( keyPressed( ushort, ushort, bool, bool, bool) ),
218 this, SLOT( slotKeyReceived( ushort, ushort, bool, bool, bool) ) ); 218 this, SLOT( slotKeyReceived( ushort, ushort, bool, bool, bool) ) );
219 219
220 220
221 m_connect->setEnabled( false ); 221 m_connect->setEnabled( false );
222 m_disconnect->setEnabled( false ); 222 m_disconnect->setEnabled( false );
223 m_terminate->setEnabled( false ); 223 m_terminate->setEnabled( false );
224 m_transfer->setEnabled( false ); 224 m_transfer->setEnabled( false );
225 m_recordScript->setEnabled( false ); 225 m_recordScript->setEnabled( false );
226 m_saveScript->setEnabled( false ); 226 m_saveScript->setEnabled( false );
227 m_runScript->setEnabled( false ); 227 m_runScript->setEnabled( false );
228 m_fullscreen->setEnabled( false ); 228 m_fullscreen->setEnabled( false );
229 m_closewindow->setEnabled( false ); 229 m_closewindow->setEnabled( false );
230 230
231 /* 231 /*
232 * connect to the menu activation 232 * connect to the menu activation
233 */ 233 */
234 connect( m_sessionsPop, SIGNAL(activated( int ) ), 234 connect( m_sessionsPop, SIGNAL(activated( int ) ),
235 this, SLOT(slotProfile( int ) ) ); 235 this, SLOT(slotProfile( int ) ) );
236 236
237 m_consoleWindow = new TabWidget( this, "blah"); 237 m_consoleWindow = new TabWidget( this, "blah");
238 connect(m_consoleWindow, SIGNAL(activated(Session*) ), 238 connect(m_consoleWindow, SIGNAL(activated(Session*) ),
239 this, SLOT(slotSessionChanged(Session*) ) ); 239 this, SLOT(slotSessionChanged(Session*) ) );
240 setCentralWidget( m_consoleWindow ); 240 setCentralWidget( m_consoleWindow );
241 241
242} 242}
243 243
244ProfileManager* MainWindow::manager() { 244ProfileManager* MainWindow::manager() {
245 return m_manager; 245 return m_manager;
246} 246}
247TabWidget* MainWindow::tabWidget() { 247TabWidget* MainWindow::tabWidget() {
248 return m_consoleWindow; 248 return m_consoleWindow;
249} 249}
250void MainWindow::populateProfiles() { 250void MainWindow::populateProfiles() {
251 m_sessionsPop->clear(); 251 m_sessionsPop->clear();
252 Profile::ValueList list = manager()->all(); 252 Profile::ValueList list = manager()->all();
253 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { 253 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) {
254 m_sessionsPop->insertItem( (*it).name() ); 254 m_sessionsPop->insertItem( (*it).name() );
255 } 255 }
256 256
257} 257}
258MainWindow::~MainWindow() { 258MainWindow::~MainWindow() {
259 delete m_factory; 259 delete m_factory;
260 manager()->save(); 260 manager()->save();
261} 261}
262 262
263MetaFactory* MainWindow::factory() { 263MetaFactory* MainWindow::factory() {
264 return m_factory; 264 return m_factory;
265} 265}
266 266
267Session* MainWindow::currentSession() { 267Session* MainWindow::currentSession() {
268 return m_curSession; 268 return m_curSession;
269} 269}
270 270
271QList<Session> MainWindow::sessions() { 271QList<Session> MainWindow::sessions() {
272 return m_sessions; 272 return m_sessions;
273} 273}
274 274
275void MainWindow::slotNew() { 275void MainWindow::slotNew() {
276 ProfileEditorDialog dlg(factory() ); 276 ProfileEditorDialog dlg(factory() );
277 dlg.showMaximized(); 277 dlg.showMaximized();
278 int ret = dlg.exec(); 278 int ret = dlg.exec();
279 279
280 if ( ret == QDialog::Accepted ) { 280 if ( ret == QDialog::Accepted ) {
281 create( dlg.profile() ); 281 create( dlg.profile() );
282 } 282 }
283} 283}
284 284
285void MainWindow::slotRecordScript() { 285void MainWindow::slotRecordScript() {
286/* if (currentSession()) { 286/* if (currentSession()) {
287 currentSession()->emulationLayer()->startRecording(); 287 currentSession()->emulationLayer()->startRecording();
288 } 288 }
289 */ 289 */
290} 290}
291 291
292void MainWindow::slotSaveScript() { 292void MainWindow::slotSaveScript() {
293/* if (currentSession() && currentSession()->emulationLayer()->isRecording()) { 293/* if (currentSession() && currentSession()->emulationLayer()->isRecording()) {
294 MimeTypes types; 294 MimeTypes types;
295 QStringList script; 295 QStringList script;
296 script << "text/plain"; 296 script << "text/plain";
297 types.insert("Script", script); 297 types.insert("Script", script);
298 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); 298 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types);
299 if (!filename.isEmpty()) { 299 if (!filename.isEmpty()) {
300 currentSession()->emulationLayer()->script()->saveTo(filename); 300 currentSession()->emulationLayer()->script()->saveTo(filename);
301 currentSession()->emulationLayer()->clearScript(); 301 currentSession()->emulationLayer()->clearScript();
302 } 302 }
303 } 303 }
304 */ 304 */
305} 305}
306 306
307void MainWindow::slotRunScript() { 307void MainWindow::slotRunScript() {
308/* 308/*
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()->emulationLayer()->runScript(&script); 317 currentSession()->emulationLayer()->runScript(&script);
318 } 318 }
319 } 319 }
320 */ 320 */
321} 321}
322 322
323void MainWindow::slotConnect() { 323void MainWindow::slotConnect() {
324 if ( currentSession() ) { 324 if ( currentSession() ) {
325 bool ret = currentSession()->layer()->open(); 325 bool ret = currentSession()->layer()->open();
326 if(!ret) QMessageBox::warning(currentSession()->widgetStack(), 326 if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
327 QObject::tr("Failed"), 327 QObject::tr("Failed"),
328 QObject::tr("Connecting failed for this session.")); 328 QObject::tr("Connecting failed for this session."));
329 else { 329 else {
330 m_connect->setEnabled( false ); 330 m_connect->setEnabled( false );
331 m_disconnect->setEnabled( true ); 331 m_disconnect->setEnabled( true );
332 } 332 }
333 } 333 }
334} 334}
335 335
336void MainWindow::slotDisconnect() { 336void MainWindow::slotDisconnect() {
337 if ( currentSession() ) { 337 if ( currentSession() ) {
338 currentSession()->layer()->close(); 338 currentSession()->layer()->close();
339 m_connect->setEnabled( true ); 339 m_connect->setEnabled( true );
340 m_disconnect->setEnabled( false ); 340 m_disconnect->setEnabled( false );
341 } 341 }
342} 342}
343 343
344void MainWindow::slotTerminate() { 344void MainWindow::slotTerminate() {
345 if ( currentSession() ) 345 if ( currentSession() )
346 currentSession()->layer()->close(); 346 currentSession()->layer()->close();
347 347
348 slotClose(); 348 slotClose();
349 /* FIXME move to the next session */ 349 /* FIXME move to the next session */
350} 350}
351 351
352void MainWindow::slotConfigure() { 352void MainWindow::slotConfigure() {
353 ConfigDialog conf( manager()->all(), factory() ); 353 ConfigDialog conf( manager()->all(), factory() );
354 conf.showMaximized(); 354 conf.showMaximized();
355 355
356 int ret = conf.exec(); 356 int ret = conf.exec();
357 357
358 if ( QDialog::Accepted == ret ) { 358 if ( QDialog::Accepted == ret ) {
359 manager()->setProfiles( conf.list() ); 359 manager()->setProfiles( conf.list() );
360 manager()->save(); 360 manager()->save();
361 populateProfiles(); 361 populateProfiles();
362 } 362 }
363} 363}
364/* 364/*
365 * we will remove 365 * we will remove
366 * this window from the tabwidget 366 * this window from the tabwidget
367 * remove it from the list 367 * remove it from the list
368 * delete it 368 * delete it
369 * and set the currentSession() 369 * and set the currentSession()
370 */ 370 */
371void MainWindow::slotClose() { 371void MainWindow::slotClose() {
372 if (!currentSession() ) 372 if (!currentSession() )
373 return; 373 return;
374 374
375 Session* ses = currentSession(); 375 Session* ses = currentSession();
376 qWarning("removing! currentSession %s", currentSession()->name().latin1() ); 376 qWarning("removing! currentSession %s", currentSession()->name().latin1() );
377 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ 377 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */
378 m_curSession = NULL; 378 m_curSession = NULL;
379 tabWidget()->remove( /*currentSession()*/ses ); 379 tabWidget()->remove( /*currentSession()*/ses );
380 /*it's autodelete */ 380 /*it's autodelete */
381 m_sessions.remove( ses ); 381 m_sessions.remove( ses );
382 qWarning("after remove!!"); 382 qWarning("after remove!!");
383 383
384 if (!currentSession() ) { 384 if (!currentSession() ) {
385 m_connect->setEnabled( false ); 385 m_connect->setEnabled( false );
386 m_disconnect->setEnabled( false ); 386 m_disconnect->setEnabled( false );
387 m_terminate->setEnabled( false ); 387 m_terminate->setEnabled( false );
388 m_transfer->setEnabled( false ); 388 m_transfer->setEnabled( false );
389 m_recordScript->setEnabled( false ); 389 m_recordScript->setEnabled( false );
390 m_saveScript->setEnabled( false ); 390 m_saveScript->setEnabled( false );
391 m_runScript->setEnabled( false ); 391 m_runScript->setEnabled( false );
392 m_fullscreen->setEnabled( false ); 392 m_fullscreen->setEnabled( false );
393 m_closewindow->setEnabled( false ); 393 m_closewindow->setEnabled( false );
394 } 394 }
395} 395}
396 396
397/* 397/*
398 * We will get the name 398 * We will get the name
399 * Then the profile 399 * Then the profile
400 * and then we will make a profile 400 * and then we will make a profile
401 */ 401 */
402void MainWindow::slotProfile( int id) { 402void MainWindow::slotProfile( int id) {
403 Profile prof = manager()->profile( m_sessionsPop->text( id) ); 403 Profile prof = manager()->profile( m_sessionsPop->text( id) );
404 create( prof ); 404 create( prof );
405} 405}
406void MainWindow::create( const Profile& prof ) { 406void MainWindow::create( const Profile& prof ) {
407 Session *ses = manager()->fromProfile( prof, tabWidget() ); 407 Session *ses = manager()->fromProfile( prof, tabWidget() );
408 408
409 if((!ses) || (!ses->layer()) || (!ses->widgetStack())) 409 if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
410 { 410 {
411 QMessageBox::warning(this, 411 QMessageBox::warning(this,
412 QObject::tr("Session failed"), 412 QObject::tr("Session failed"),
413 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); 413 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>"));
414 //if(ses) delete ses; 414 //if(ses) delete ses;
415 return; 415 return;
416 } 416 }
417 417
418 m_sessions.append( ses ); 418 m_sessions.append( ses );
419 tabWidget()->add( ses ); 419 tabWidget()->add( ses );
420 m_curSession = ses; 420 m_curSession = ses;
421 421
422 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it 422 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it
423 m_connect->setEnabled( true ); 423 m_connect->setEnabled( true );
424 m_disconnect->setEnabled( false ); 424 m_disconnect->setEnabled( false );
425 m_terminate->setEnabled( true ); 425 m_terminate->setEnabled( true );
426 m_transfer->setEnabled( true ); 426 m_transfer->setEnabled( true );
427 m_recordScript->setEnabled( true ); 427 m_recordScript->setEnabled( true );
428 m_saveScript->setEnabled( true ); 428 m_saveScript->setEnabled( true );
429 m_runScript->setEnabled( true ); 429 m_runScript->setEnabled( true );
430 m_fullscreen->setEnabled( true ); 430 m_fullscreen->setEnabled( true );
431 m_closewindow->setEnabled( true ); 431 m_closewindow->setEnabled( true );
432 432
433 433
434 // is io_layer wants direct connection, then autoconnect 434 // is io_layer wants direct connection, then autoconnect
435 if ( ( m_curSession->layer() )->supports()[0] = 1 ) { 435 if ( ( m_curSession->layer() )->supports()[0] == 1 ) {
436 slotConnect(); 436 slotConnect();
437 } 437 }
438} 438}
439 439
440void MainWindow::slotTransfer() 440void MainWindow::slotTransfer()
441{ 441{
442 if ( currentSession() ) { 442 if ( currentSession() ) {
443 TransferDialog dlg(currentSession()->widgetStack(), this); 443 TransferDialog dlg(currentSession()->widgetStack(), this);
444 dlg.showMaximized(); 444 dlg.showMaximized();
445 //currentSession()->widgetStack()->add(dlg); 445 //currentSession()->widgetStack()->add(dlg);
446 dlg.exec(); 446 dlg.exec();
447 } 447 }
448} 448}
449 449
450 450
451void MainWindow::slotOpenKeb(bool state) { 451void MainWindow::slotOpenKeb(bool state) {
452 452
453 if (state) m_keyBar->show(); 453 if (state) m_keyBar->show();
454 else m_keyBar->hide(); 454 else m_keyBar->hide();
455 455
456} 456}
457 457
458 458
459void MainWindow::slotOpenButtons( bool state ) { 459void MainWindow::slotOpenButtons( bool state ) {
460 460
461 if ( state ) { 461 if ( state ) {
462 m_buttonBar->show(); 462 m_buttonBar->show();
463 } else { 463 } else {
464 m_buttonBar->hide(); 464 m_buttonBar->hide();
465 } 465 }
466} 466}
467 467
468 468
469 469
470void MainWindow::slotSessionChanged( Session* ses ) { 470void MainWindow::slotSessionChanged( Session* ses ) {
471 qWarning("changed!"); 471 qWarning("changed!");
472 if ( ses ) { 472 if ( ses ) {
473 m_curSession = ses; 473 m_curSession = ses;
474 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); 474 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) );
475 if ( m_curSession->layer()->isConnected() ) { 475 if ( m_curSession->layer()->isConnected() ) {
476 m_connect->setEnabled( false ); 476 m_connect->setEnabled( false );
477 m_disconnect->setEnabled( true ); 477 m_disconnect->setEnabled( true );
478 } else { 478 } else {
479 m_connect->setEnabled( true ); 479 m_connect->setEnabled( true );
480 m_disconnect->setEnabled( false ); 480 m_disconnect->setEnabled( false );
481 } 481 }
482 } 482 }
483} 483}
484 484
485void MainWindow::slotFullscreen() { 485void MainWindow::slotFullscreen() {
486 486
487 487
488 488
489 if ( m_isFullscreen ) { 489 if ( m_isFullscreen ) {
490 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), false ); 490 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), false );
491 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 491 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken );
492 492
493 setCentralWidget( m_consoleWindow ); 493 setCentralWidget( m_consoleWindow );
494 ( m_curSession->widgetStack() )->show(); 494 ( m_curSession->widgetStack() )->show();
495 ( m_curSession->emulationHandler() )->cornerButton()->hide(); 495 ( m_curSession->emulationHandler() )->cornerButton()->hide();
496 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 496 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
497 497
498 } else { 498 } else {
499 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); 499 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget();
500 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); 500 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame );
501 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop 501 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop
502 , QPoint(0,0), false ); 502 , QPoint(0,0), false );
503 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); 503 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() );
504 ( m_curSession->widgetStack() )->setFocus(); 504 ( m_curSession->widgetStack() )->setFocus();
505 ( m_curSession->widgetStack() )->show(); 505 ( m_curSession->widgetStack() )->show();
506 506
507 ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); 507 ( ( m_curSession->emulationHandler() )->cornerButton() )->show();
508 508
509 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 509 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
510 } 510 }
511 511
512 m_isFullscreen = !m_isFullscreen; 512 m_isFullscreen = !m_isFullscreen;
513} 513}
514 514
515 515
516void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool pressed, bool) { 516void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool pressed, bool) {
517 517
518 qWarning("unicode: %x, qkey: %x, %s", u, q, pressed ? "pressed" : "released"); 518 //qWarning("unicode: %x, qkey: %x, %s", u, q, pressed ? "pressed" : "released");
519 519
520 if ( m_curSession ) { 520 if ( m_curSession ) {
521 521
522 QEvent::Type state; 522 QEvent::Type state;
523 523
524 if (pressed) state = QEvent::KeyPress; 524 if (pressed) state = QEvent::KeyPress;
525 else state = QEvent::KeyRelease; 525 else state = QEvent::KeyRelease;
526 526
527 QKeyEvent ke(state, q, u, 0, QString(QChar(u))); 527 QKeyEvent ke(state, q, u, 0, QString(QChar(u)));
528 528
529 // where should i send this event? doesnt work sending it here 529 // where should i send this event? doesnt work sending it here
530 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); 530 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke);
531 ke.ignore(); 531 ke.ignore();
532 } 532 }
533} 533}