summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-10-24 12:22:18 (UTC)
committer harlekin <harlekin>2002-10-24 12:22:18 (UTC)
commit23b602802d2c02b20a8c6a9bf8c3785b9ca97b43 (patch) (unidiff)
tree9af1c9f623316eb888ae525efaeb3a99169ce82d
parentacf708cee945b8b843b0132672d79f5c4571c22b (diff)
downloadopie-23b602802d2c02b20a8c6a9bf8c3785b9ca97b43.zip
opie-23b602802d2c02b20a8c6a9bf8c3785b9ca97b43.tar.gz
opie-23b602802d2c02b20a8c6a9bf8c3785b9ca97b43.tar.bz2
taken most quickbutton stuff out now and also set the nicer icon again for keys
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp10
-rw-r--r--noncore/apps/opie-console/mainwindow.h3
2 files changed, 3 insertions, 10 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 02a3fa9..ddaaf1b 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,331 +1,324 @@
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"
30 29
31 30
32 31
33MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { 32MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) {
34 KeyTrans::loadAll(); 33 KeyTrans::loadAll();
35 for (int i = 0; i < KeyTrans::count(); i++ ) { 34 for (int i = 0; i < KeyTrans::count(); i++ ) {
36 KeyTrans* s = KeyTrans::find(i ); 35 KeyTrans* s = KeyTrans::find(i );
37 assert( s ); 36 assert( s );
38 } 37 }
39 m_factory = new MetaFactory(); 38 m_factory = new MetaFactory();
40 Default def(m_factory); 39 Default def(m_factory);
41 m_sessions.setAutoDelete( TRUE ); 40 m_sessions.setAutoDelete( TRUE );
42 m_curSession = 0; 41 m_curSession = 0;
43 m_manager = new ProfileManager( m_factory ); 42 m_manager = new ProfileManager( m_factory );
44 m_manager->load(); 43 m_manager->load();
45 44
46 initUI(); 45 initUI();
47 populateProfiles(); 46 populateProfiles();
48} 47}
49void MainWindow::initUI() { 48void MainWindow::initUI() {
50 setToolBarsMovable( FALSE ); 49 setToolBarsMovable( FALSE );
51 50
52 /* tool bar for the menu */ 51 /* tool bar for the menu */
53 m_tool = new QToolBar( this ); 52 m_tool = new QToolBar( this );
54 m_tool->setHorizontalStretchable( TRUE ); 53 m_tool->setHorizontalStretchable( TRUE );
55 54
56 m_bar = new QMenuBar( m_tool ); 55 m_bar = new QMenuBar( m_tool );
57 m_console = new QPopupMenu( this ); 56 m_console = new QPopupMenu( this );
58 m_scripts = new QPopupMenu( this ); 57 m_scripts = new QPopupMenu( this );
59 m_sessionsPop= new QPopupMenu( this ); 58 m_sessionsPop= new QPopupMenu( this );
60 //m_settings = new QPopupMenu( this ); 59 //m_settings = new QPopupMenu( this );
61 60
62 /* add a toolbar for icons */ 61 /* add a toolbar for icons */
63 m_icons = new QToolBar(this); 62 m_icons = new QToolBar(this);
64 63
65 64
66 65
67 66
68 /* 67 /*
69 * the settings action 68 * the settings action
70 */ 69 */
71 m_setProfiles = new QAction(tr("Configure Profiles"), 70 m_setProfiles = new QAction(tr("Configure Profiles"),
72 Resource::loadPixmap( "SettingsIcon" ), 71 Resource::loadPixmap( "SettingsIcon" ),
73 QString::null, 0, this, 0); 72 QString::null, 0, this, 0);
74 // m_setProfiles->addTo( m_settings ); 73 // m_setProfiles->addTo( m_settings );
75 m_setProfiles->addTo( m_icons ); 74 m_setProfiles->addTo( m_icons );
76 m_setProfiles->addTo( m_console ); 75 m_setProfiles->addTo( m_console );
77 connect( m_setProfiles, SIGNAL(activated() ), 76 connect( m_setProfiles, SIGNAL(activated() ),
78 this, SLOT(slotConfigure() ) ); 77 this, SLOT(slotConfigure() ) );
79 78
80 m_console->insertSeparator(); 79 m_console->insertSeparator();
81 /* 80 /*
82 * new Action for new sessions 81 * new Action for new sessions
83 */ 82 */
84 QAction* a = new QAction(tr("New Connection"), 83 QAction* a = new QAction(tr("New Connection"),
85 Resource::loadPixmap( "new" ), 84 Resource::loadPixmap( "new" ),
86 QString::null, 0, this, 0); 85 QString::null, 0, this, 0);
87 a->addTo( m_console ); 86 a->addTo( m_console );
88 a->addTo( m_icons ); 87 a->addTo( m_icons );
89 connect(a, SIGNAL(activated() ), 88 connect(a, SIGNAL(activated() ),
90 this, SLOT(slotNew() ) ); 89 this, SLOT(slotNew() ) );
91 90
92 m_console->insertSeparator(); 91 m_console->insertSeparator();
93 /* save icon is not available */ 92 /* save icon is not available */
94 a = new QAction(tr("Save Connection"), 93 a = new QAction(tr("Save Connection"),
95 Resource::loadPixmap("save"), QString::null, 94 Resource::loadPixmap("save"), QString::null,
96 0, this, 0 ); 95 0, this, 0 );
97 a->addTo( m_console ); 96 a->addTo( m_console );
98 connect(a, SIGNAL(activated() ), 97 connect(a, SIGNAL(activated() ),
99 this, SLOT(slotSaveSession() ) ); 98 this, SLOT(slotSaveSession() ) );
100 m_console->insertSeparator(); 99 m_console->insertSeparator();
101 100
102 /* 101 /*
103 * connect action 102 * connect action
104 */ 103 */
105 m_connect = new QAction(); 104 m_connect = new QAction();
106 m_connect->setText( tr("Connect") ); 105 m_connect->setText( tr("Connect") );
107 m_connect->addTo( m_console ); 106 m_connect->addTo( m_console );
108 connect(m_connect, SIGNAL(activated() ), 107 connect(m_connect, SIGNAL(activated() ),
109 this, SLOT(slotConnect() ) ); 108 this, SLOT(slotConnect() ) );
110 109
111 /* 110 /*
112 * disconnect action 111 * disconnect action
113 */ 112 */
114 m_disconnect = new QAction(); 113 m_disconnect = new QAction();
115 m_disconnect->setText( tr("Disconnect") ); 114 m_disconnect->setText( tr("Disconnect") );
116 m_disconnect->addTo( m_console ); 115 m_disconnect->addTo( m_console );
117 connect(m_disconnect, SIGNAL(activated() ), 116 connect(m_disconnect, SIGNAL(activated() ),
118 this, SLOT(slotDisconnect() ) ); 117 this, SLOT(slotDisconnect() ) );
119 118
120 m_console->insertSeparator(); 119 m_console->insertSeparator();
121 120
122 m_transfer = new QAction(); 121 m_transfer = new QAction();
123 m_transfer->setText( tr("Transfer file...") ); 122 m_transfer->setText( tr("Transfer file...") );
124 m_transfer->addTo( m_console ); 123 m_transfer->addTo( m_console );
125 connect(m_transfer, SIGNAL(activated() ), 124 connect(m_transfer, SIGNAL(activated() ),
126 this, SLOT(slotTransfer() ) ); 125 this, SLOT(slotTransfer() ) );
127 126
128 127
129 /* 128 /*
130 * fullscreen 129 * fullscreen
131 */ 130 */
132 m_isFullscreen = false; 131 m_isFullscreen = false;
133 132
134 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) 133 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" )
135 , QString::null, 0, this, 0); 134 , QString::null, 0, this, 0);
136 m_fullscreen->addTo( m_console ); 135 m_fullscreen->addTo( m_console );
137 m_fullscreen->addTo( m_icons ); 136 m_fullscreen->addTo( m_icons );
138 connect( m_fullscreen, SIGNAL( activated() ), 137 connect( m_fullscreen, SIGNAL( activated() ),
139 this, SLOT( slotFullscreen() ) ); 138 this, SLOT( slotFullscreen() ) );
140 139
141 m_console->insertSeparator(); 140 m_console->insertSeparator();
142 /* 141 /*
143 * terminate action 142 * terminate action
144 */ 143 */
145 m_terminate = new QAction(); 144 m_terminate = new QAction();
146 m_terminate->setText( tr("Terminate") ); 145 m_terminate->setText( tr("Terminate") );
147 m_terminate->addTo( m_console ); 146 m_terminate->addTo( m_console );
148 connect(m_terminate, SIGNAL(activated() ), 147 connect(m_terminate, SIGNAL(activated() ),
149 this, SLOT(slotTerminate() ) ); 148 this, SLOT(slotTerminate() ) );
150 149
151 m_closewindow = new QAction(); 150 m_closewindow = new QAction();
152 m_closewindow->setText( tr("Close Window") ); 151 m_closewindow->setText( tr("Close Window") );
153 m_closewindow->addTo( m_console ); 152 m_closewindow->addTo( m_console );
154 connect( m_closewindow, SIGNAL(activated() ), 153 connect( m_closewindow, SIGNAL(activated() ),
155 this, SLOT(slotClose() ) ); 154 this, SLOT(slotClose() ) );
156 155
157 156
158 /* 157 /*
159 * script actions 158 * script actions
160 */ 159 */
161 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); 160 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
162 m_recordScript->addTo(m_scripts); 161 m_recordScript->addTo(m_scripts);
163 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); 162 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript()));
164 163
165 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); 164 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0);
166 m_saveScript->addTo(m_scripts); 165 m_saveScript->addTo(m_scripts);
167 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); 166 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript()));
168 167
169 m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); 168 m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0);
170 m_runScript->addTo(m_scripts); 169 m_runScript->addTo(m_scripts);
171 connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); 170 connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript()));
172 171
173 /* 172 /*
174 * action that open/closes the keyboard 173 * action that open/closes the keyboard
175 */ 174 */
176 m_openKeys = new QAction (tr("Open Keyboard..."), 175 m_openKeys = new QAction (tr("Open Keyboard..."),
177 Resource::loadPixmap( "down" ), 176 Resource::loadPixmap( "console/keys/keyboard_icon" ),
178 QString::null, 0, this, 0); 177 QString::null, 0, this, 0);
179 178
180 m_openKeys->setToggleAction(true); 179 m_openKeys->setToggleAction(true);
181 180
182 connect (m_openKeys, SIGNAL(toggled(bool)), 181 connect (m_openKeys, SIGNAL(toggled(bool)),
183 this, SLOT(slotOpenKeb(bool))); 182 this, SLOT(slotOpenKeb(bool)));
184 m_openKeys->addTo(m_icons); 183 m_openKeys->addTo(m_icons);
185 184
186 185
187 /* 186 /*
188 * action that open/closes the keyboard 187 * action that open/closes the keyboard
189 188
190 m_openButtons = new QAction ( tr( "Open Buttons..." ), 189 m_openButtons = new QAction ( tr( "Open Buttons..." ),
191 Resource::loadPixmap( "" ), 190 Resource::loadPixmap( "" ),
192 QString::null, 0, this, 0 ); 191 QString::null, 0, this, 0 );
193 192
194 m_openButtons->setToggleAction( true ); 193 m_openButtons->setToggleAction( true );
195 194
196 connect ( m_openButtons, SIGNAL( toggled( bool ) ), 195 connect ( m_openButtons, SIGNAL( toggled( bool ) ),
197 this, SLOT( slotOpenButtons( bool ) ) ); 196 this, SLOT( slotOpenButtons( bool ) ) );
198 m_openButtons->addTo( m_icons ); 197 m_openButtons->addTo( m_icons );
199 198
200 */ 199 */
201 200
202 /* insert the submenu */ 201 /* insert the submenu */
203 m_console->insertItem(tr("New from Profile"), m_sessionsPop, 202 m_console->insertItem(tr("New from Profile"), m_sessionsPop,
204 -1, 0); 203 -1, 0);
205 204
206 /* insert the connection menu */ 205 /* insert the connection menu */
207 m_bar->insertItem( tr("Connection"), m_console ); 206 m_bar->insertItem( tr("Connection"), m_console );
208 207
209 /* the scripts menu */ 208 /* the scripts menu */
210 m_bar->insertItem( tr("Scripts"), m_scripts ); 209 m_bar->insertItem( tr("Scripts"), m_scripts );
211 210
212 /* the settings menu */ 211 /* the settings menu */
213 // m_bar->insertItem( tr("Settings"), m_settings ); 212 // m_bar->insertItem( tr("Settings"), m_settings );
214 213
215 /* and the keyboard */ 214 /* and the keyboard */
216 m_keyBar = new QToolBar(this); 215 m_keyBar = new QToolBar(this);
217 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); 216 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE );
218 m_keyBar->setHorizontalStretchable( TRUE ); 217 m_keyBar->setHorizontalStretchable( TRUE );
219 m_keyBar->hide(); 218 m_keyBar->hide();
220 219
221 m_kb = new FunctionKeyboard(m_keyBar); 220 m_kb = new FunctionKeyboard(m_keyBar);
222 connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), 221 connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)),
223 this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); 222 this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool)));
224 223
225 m_buttonBar = new QToolBar( this ); 224 m_buttonBar = new QToolBar( this );
226 addToolBar( m_buttonBar, "Buttons", QMainWindow::Top, TRUE ); 225 addToolBar( m_buttonBar, "Buttons", QMainWindow::Top, TRUE );
227 m_buttonBar->setHorizontalStretchable( TRUE ); 226 m_buttonBar->setHorizontalStretchable( TRUE );
228 m_buttonBar->hide(); 227 m_buttonBar->hide();
229 228
230 /*
231 m_qb = new QuickButton( m_buttonBar );
232 connect( m_qb, SIGNAL( keyPressed( ushort, ushort, bool, bool, bool) ),
233 this, SLOT( slotKeyReceived( ushort, ushort, bool, bool, bool) ) );
234 */
235 /* now add the copy and paste actions */
236 a = new QAction(tr("Copy"), 229 a = new QAction(tr("Copy"),
237 Resource::loadPixmap("copy"), QString::null, 230 Resource::loadPixmap("copy"), QString::null,
238 0, this, 0 ); 231 0, this, 0 );
239 //a->addTo( m_icons ); 232 //a->addTo( m_icons );
240 connect( a, SIGNAL(activated() ), 233 connect( a, SIGNAL(activated() ),
241 this, SLOT(slotCopy() ) ); 234 this, SLOT(slotCopy() ) );
242 235
243 a = new QAction(tr("Paste"), 236 a = new QAction(tr("Paste"),
244 Resource::loadPixmap("paste"), QString::null, 237 Resource::loadPixmap("paste"), QString::null,
245 0, this, 0 ); 238 0, this, 0 );
246 a->addTo( m_icons ); 239 a->addTo( m_icons );
247 connect( a, SIGNAL(activated() ), 240 connect( a, SIGNAL(activated() ),
248 this, SLOT(slotPaste() ) ); 241 this, SLOT(slotPaste() ) );
249 242
250 243
251 m_connect->setEnabled( false ); 244 m_connect->setEnabled( false );
252 m_disconnect->setEnabled( false ); 245 m_disconnect->setEnabled( false );
253 m_terminate->setEnabled( false ); 246 m_terminate->setEnabled( false );
254 m_transfer->setEnabled( false ); 247 m_transfer->setEnabled( false );
255 m_recordScript->setEnabled( false ); 248 m_recordScript->setEnabled( false );
256 m_saveScript->setEnabled( false ); 249 m_saveScript->setEnabled( false );
257 m_runScript->setEnabled( false ); 250 m_runScript->setEnabled( false );
258 m_fullscreen->setEnabled( false ); 251 m_fullscreen->setEnabled( false );
259 m_closewindow->setEnabled( false ); 252 m_closewindow->setEnabled( false );
260 253
261 /* 254 /*
262 * connect to the menu activation 255 * connect to the menu activation
263 */ 256 */
264 connect( m_sessionsPop, SIGNAL(activated( int ) ), 257 connect( m_sessionsPop, SIGNAL(activated( int ) ),
265 this, SLOT(slotProfile( int ) ) ); 258 this, SLOT(slotProfile( int ) ) );
266 259
267 m_consoleWindow = new TabWidget( this, "blah"); 260 m_consoleWindow = new TabWidget( this, "blah");
268 connect(m_consoleWindow, SIGNAL(activated(Session*) ), 261 connect(m_consoleWindow, SIGNAL(activated(Session*) ),
269 this, SLOT(slotSessionChanged(Session*) ) ); 262 this, SLOT(slotSessionChanged(Session*) ) );
270 setCentralWidget( m_consoleWindow ); 263 setCentralWidget( m_consoleWindow );
271 264
272} 265}
273 266
274ProfileManager* MainWindow::manager() { 267ProfileManager* MainWindow::manager() {
275 return m_manager; 268 return m_manager;
276} 269}
277TabWidget* MainWindow::tabWidget() { 270TabWidget* MainWindow::tabWidget() {
278 return m_consoleWindow; 271 return m_consoleWindow;
279} 272}
280void MainWindow::populateProfiles() { 273void MainWindow::populateProfiles() {
281 m_sessionsPop->clear(); 274 m_sessionsPop->clear();
282 Profile::ValueList list = manager()->all(); 275 Profile::ValueList list = manager()->all();
283 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { 276 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) {
284 m_sessionsPop->insertItem( (*it).name() ); 277 m_sessionsPop->insertItem( (*it).name() );
285 } 278 }
286 279
287} 280}
288MainWindow::~MainWindow() { 281MainWindow::~MainWindow() {
289 delete m_factory; 282 delete m_factory;
290 manager()->save(); 283 manager()->save();
291} 284}
292 285
293MetaFactory* MainWindow::factory() { 286MetaFactory* MainWindow::factory() {
294 return m_factory; 287 return m_factory;
295} 288}
296 289
297Session* MainWindow::currentSession() { 290Session* MainWindow::currentSession() {
298 return m_curSession; 291 return m_curSession;
299} 292}
300 293
301QList<Session> MainWindow::sessions() { 294QList<Session> MainWindow::sessions() {
302 return m_sessions; 295 return m_sessions;
303} 296}
304 297
305void MainWindow::slotNew() { 298void MainWindow::slotNew() {
306 ProfileEditorDialog dlg(factory() ); 299 ProfileEditorDialog dlg(factory() );
307 dlg.showMaximized(); 300 dlg.showMaximized();
308 int ret = dlg.exec(); 301 int ret = dlg.exec();
309 302
310 if ( ret == QDialog::Accepted ) { 303 if ( ret == QDialog::Accepted ) {
311 create( dlg.profile() ); 304 create( dlg.profile() );
312 } 305 }
313} 306}
314 307
315void MainWindow::slotRecordScript() { 308void MainWindow::slotRecordScript() {
316 if (currentSession()) { 309 if (currentSession()) {
317 currentSession()->emulationHandler()->startRecording(); 310 currentSession()->emulationHandler()->startRecording();
318 } 311 }
319} 312}
320 313
321void MainWindow::slotSaveScript() { 314void MainWindow::slotSaveScript() {
322 if (currentSession() && currentSession()->emulationHandler()->isRecording()) { 315 if (currentSession() && currentSession()->emulationHandler()->isRecording()) {
323 MimeTypes types; 316 MimeTypes types;
324 QStringList script; 317 QStringList script;
325 script << "text/plain"; 318 script << "text/plain";
326 script << "text/all"; 319 script << "text/all";
327 script << "application/octet-stream"; 320 script << "application/octet-stream";
328 types.insert("Script", script); 321 types.insert("Script", script);
329 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); 322 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types);
330 if (!filename.isEmpty()) { 323 if (!filename.isEmpty()) {
331 currentSession()->emulationHandler()->script()->saveTo(filename); 324 currentSession()->emulationHandler()->script()->saveTo(filename);
@@ -354,192 +347,193 @@ void MainWindow::slotConnect() {
354 if ( currentSession() ) { 347 if ( currentSession() ) {
355 bool ret = currentSession()->layer()->open(); 348 bool ret = currentSession()->layer()->open();
356 if(!ret) QMessageBox::warning(currentSession()->widgetStack(), 349 if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
357 QObject::tr("Failed"), 350 QObject::tr("Failed"),
358 QObject::tr("Connecting failed for this session.")); 351 QObject::tr("Connecting failed for this session."));
359 else { 352 else {
360 m_connect->setEnabled( false ); 353 m_connect->setEnabled( false );
361 m_disconnect->setEnabled( true ); 354 m_disconnect->setEnabled( true );
362 } 355 }
363 } 356 }
364} 357}
365 358
366void MainWindow::slotDisconnect() { 359void MainWindow::slotDisconnect() {
367 if ( currentSession() ) { 360 if ( currentSession() ) {
368 currentSession()->layer()->close(); 361 currentSession()->layer()->close();
369 m_connect->setEnabled( true ); 362 m_connect->setEnabled( true );
370 m_disconnect->setEnabled( false ); 363 m_disconnect->setEnabled( false );
371 } 364 }
372} 365}
373 366
374void MainWindow::slotTerminate() { 367void MainWindow::slotTerminate() {
375 if ( currentSession() ) 368 if ( currentSession() )
376 currentSession()->layer()->close(); 369 currentSession()->layer()->close();
377 370
378 slotClose(); 371 slotClose();
379 /* FIXME move to the next session */ 372 /* FIXME move to the next session */
380} 373}
381 374
382void MainWindow::slotConfigure() { 375void MainWindow::slotConfigure() {
383 ConfigDialog conf( manager()->all(), factory() ); 376 ConfigDialog conf( manager()->all(), factory() );
384 conf.showMaximized(); 377 conf.showMaximized();
385 378
386 int ret = conf.exec(); 379 int ret = conf.exec();
387 380
388 if ( QDialog::Accepted == ret ) { 381 if ( QDialog::Accepted == ret ) {
389 manager()->setProfiles( conf.list() ); 382 manager()->setProfiles( conf.list() );
390 manager()->save(); 383 manager()->save();
391 populateProfiles(); 384 populateProfiles();
392 } 385 }
393} 386}
394/* 387/*
395 * we will remove 388 * we will remove
396 * this window from the tabwidget 389 * this window from the tabwidget
397 * remove it from the list 390 * remove it from the list
398 * delete it 391 * delete it
399 * and set the currentSession() 392 * and set the currentSession()
400 */ 393 */
401void MainWindow::slotClose() { 394void MainWindow::slotClose() {
402 if (!currentSession() ) 395 if (!currentSession() )
403 return; 396 return;
404 397
405 Session* ses = currentSession(); 398 Session* ses = currentSession();
406 qWarning("removing! currentSession %s", currentSession()->name().latin1() ); 399 qWarning("removing! currentSession %s", currentSession()->name().latin1() );
407 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ 400 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */
408 m_curSession = NULL; 401 m_curSession = NULL;
409 tabWidget()->remove( /*currentSession()*/ses ); 402 tabWidget()->remove( /*currentSession()*/ses );
410 /*it's autodelete */ 403 /*it's autodelete */
411 m_sessions.remove( ses ); 404 m_sessions.remove( ses );
412 qWarning("after remove!!"); 405 qWarning("after remove!!");
413 406
414 if (!currentSession() ) { 407 if (!currentSession() ) {
415 m_connect->setEnabled( false ); 408 m_connect->setEnabled( false );
416 m_disconnect->setEnabled( false ); 409 m_disconnect->setEnabled( false );
417 m_terminate->setEnabled( false ); 410 m_terminate->setEnabled( false );
418 m_transfer->setEnabled( false ); 411 m_transfer->setEnabled( false );
419 m_recordScript->setEnabled( false ); 412 m_recordScript->setEnabled( false );
420 m_saveScript->setEnabled( false ); 413 m_saveScript->setEnabled( false );
421 m_runScript->setEnabled( false ); 414 m_runScript->setEnabled( false );
422 m_fullscreen->setEnabled( false ); 415 m_fullscreen->setEnabled( false );
423 m_closewindow->setEnabled( false ); 416 m_closewindow->setEnabled( false );
424 } 417 }
425} 418}
426 419
427/* 420/*
428 * We will get the name 421 * We will get the name
429 * Then the profile 422 * Then the profile
430 * and then we will make a profile 423 * and then we will make a profile
431 */ 424 */
432void MainWindow::slotProfile( int id) { 425void MainWindow::slotProfile( int id) {
433 Profile prof = manager()->profile( m_sessionsPop->text( id) ); 426 Profile prof = manager()->profile( m_sessionsPop->text( id) );
434 create( prof ); 427 create( prof );
435} 428}
436void MainWindow::create( const Profile& prof ) { 429void MainWindow::create( const Profile& prof ) {
437 Session *ses = manager()->fromProfile( prof, tabWidget() ); 430 Session *ses = manager()->fromProfile( prof, tabWidget() );
438 431
439 if((!ses) || (!ses->layer()) || (!ses->widgetStack())) 432 if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
440 { 433 {
441 QMessageBox::warning(this, 434 QMessageBox::warning(this,
442 QObject::tr("Session failed"), 435 QObject::tr("Session failed"),
443 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); 436 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>"));
444 //if(ses) delete ses; 437 //if(ses) delete ses;
445 return; 438 return;
446 } 439 }
447 440
448 m_sessions.append( ses ); 441 m_sessions.append( ses );
449 tabWidget()->add( ses ); 442 tabWidget()->add( ses );
443 tabWidget()->repaint();
450 m_curSession = ses; 444 m_curSession = ses;
451 445
452 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it 446 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it
453 m_connect->setEnabled( true ); 447 m_connect->setEnabled( true );
454 m_disconnect->setEnabled( false ); 448 m_disconnect->setEnabled( false );
455 m_terminate->setEnabled( true ); 449 m_terminate->setEnabled( true );
456 m_transfer->setEnabled( true ); 450 m_transfer->setEnabled( true );
457 m_recordScript->setEnabled( true ); 451 m_recordScript->setEnabled( true );
458 m_saveScript->setEnabled( true ); 452 m_saveScript->setEnabled( true );
459 m_runScript->setEnabled( true ); 453 m_runScript->setEnabled( true );
460 m_fullscreen->setEnabled( true ); 454 m_fullscreen->setEnabled( true );
461 m_closewindow->setEnabled( true ); 455 m_closewindow->setEnabled( true );
462 456
463 457
464 // is io_layer wants direct connection, then autoconnect 458 // is io_layer wants direct connection, then autoconnect
465 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { 459 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) {
466 if (prof.autoConnect()) { 460 if (prof.autoConnect()) {
467 slotConnect(); 461 slotConnect();
468 } 462 }
469 463
470 QWidget *w = currentSession()->widget(); 464 QWidget *w = currentSession()->widget();
471 if(w) w->setFocus(); 465 if(w) w->setFocus();
472} 466}
473 467
474void MainWindow::slotTransfer() 468void MainWindow::slotTransfer()
475{ 469{
476 if ( currentSession() ) { 470 if ( currentSession() ) {
477 TransferDialog dlg(currentSession()->widgetStack(), this); 471 TransferDialog dlg(currentSession()->widgetStack(), this);
478 dlg.showMaximized(); 472 dlg.showMaximized();
479 //currentSession()->widgetStack()->add(dlg); 473 //currentSession()->widgetStack()->add(dlg);
480 dlg.exec(); 474 dlg.exec();
481 } 475 }
482} 476}
483 477
484 478
485void MainWindow::slotOpenKeb(bool state) { 479void MainWindow::slotOpenKeb(bool state) {
486 480
487 if (state) m_keyBar->show(); 481 if (state) m_keyBar->show();
488 else m_keyBar->hide(); 482 else m_keyBar->hide();
489 483
490} 484}
491 485
492 486
493void MainWindow::slotOpenButtons( bool state ) { 487void MainWindow::slotOpenButtons( bool state ) {
494 488
495 if ( state ) { 489 if ( state ) {
496 m_buttonBar->show(); 490 m_buttonBar->show();
497 } else { 491 } else {
498 m_buttonBar->hide(); 492 m_buttonBar->hide();
499 } 493 }
500} 494}
501 495
502 496
503 497
504void MainWindow::slotSessionChanged( Session* ses ) { 498void MainWindow::slotSessionChanged( Session* ses ) {
505 qWarning("changed!"); 499 qWarning("changed!");
506 if ( ses ) { 500 if ( ses ) {
507 m_curSession = ses; 501 m_curSession = ses;
508 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); 502 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) );
509 if ( m_curSession->layer()->isConnected() ) { 503 if ( m_curSession->layer()->isConnected() ) {
510 m_connect->setEnabled( false ); 504 m_connect->setEnabled( false );
511 m_disconnect->setEnabled( true ); 505 m_disconnect->setEnabled( true );
512 } else { 506 } else {
513 m_connect->setEnabled( true ); 507 m_connect->setEnabled( true );
514 m_disconnect->setEnabled( false ); 508 m_disconnect->setEnabled( false );
515 } 509 }
516 510
517 QWidget *w = m_curSession->widget(); 511 QWidget *w = m_curSession->widget();
518 if(w) w->setFocus(); 512 if(w) w->setFocus();
519 } 513 }
520} 514}
521 515
522void MainWindow::slotFullscreen() { 516void MainWindow::slotFullscreen() {
523 517
524 518
525 519
526 if ( m_isFullscreen ) { 520 if ( m_isFullscreen ) {
527 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); 521 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true );
528 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); 522 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() );
529 ( m_curSession->emulationHandler() )->cornerButton()->hide(); 523 ( m_curSession->emulationHandler() )->cornerButton()->hide();
530 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 524 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
531 525
532 } else { 526 } else {
533 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); 527 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget();
534 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); 528 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame );
535 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop 529 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop
536 , QPoint(0,0), false ); 530 , QPoint(0,0), false );
537 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); 531 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() );
538 ( m_curSession->widgetStack() )->setFocus(); 532 ( m_curSession->widgetStack() )->setFocus();
539 ( m_curSession->widgetStack() )->show(); 533 ( m_curSession->widgetStack() )->show();
540 534
541 ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); 535 ( ( m_curSession->emulationHandler() )->cornerButton() )->show();
542 536
543 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 537 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
544 } 538 }
545 539
diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h
index 16b6252..7cc2aa5 100644
--- a/noncore/apps/opie-console/mainwindow.h
+++ b/noncore/apps/opie-console/mainwindow.h
@@ -1,131 +1,130 @@
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 FKey; 23class FKey;
24class QuickButton; 24
25 25
26class MainWindow : public QMainWindow { 26class MainWindow : public QMainWindow {
27 Q_OBJECT 27 Q_OBJECT
28public: 28public:
29 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); 29 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 );
30 ~MainWindow(); 30 ~MainWindow();
31 31
32 /** 32 /**
33 * our factory to generate IOLayer and so on 33 * our factory to generate IOLayer and so on
34 * 34 *
35 */ 35 */
36 MetaFactory* factory(); 36 MetaFactory* factory();
37 37
38 /** 38 /**
39 * A session contains a QWidget*, 39 * A session contains a QWidget*,
40 * an IOLayer* and some infos for us 40 * an IOLayer* and some infos for us
41 */ 41 */
42 Session* currentSession(); 42 Session* currentSession();
43 43
44 /** 44 /**
45 * the session list 45 * the session list
46 */ 46 */
47 QList<Session> sessions(); 47 QList<Session> sessions();
48 48
49 /** 49 /**
50 * 50 *
51 */ 51 */
52 ProfileManager* manager(); 52 ProfileManager* manager();
53 TabWidget* tabWidget(); 53 TabWidget* tabWidget();
54 54
55private slots: 55private slots:
56 void slotNew(); 56 void slotNew();
57 void slotConnect(); 57 void slotConnect();
58 void slotDisconnect(); 58 void slotDisconnect();
59 void slotTerminate(); 59 void slotTerminate();
60 void slotConfigure(); 60 void slotConfigure();
61 void slotClose(); 61 void slotClose();
62 void slotProfile(int); 62 void slotProfile(int);
63 void slotTransfer(); 63 void slotTransfer();
64 void slotOpenKeb(bool); 64 void slotOpenKeb(bool);
65 void slotOpenButtons(bool); 65 void slotOpenButtons(bool);
66 void slotRecordScript(); 66 void slotRecordScript();
67 void slotSaveScript(); 67 void slotSaveScript();
68 void slotRunScript(); 68 void slotRunScript();
69 void slotFullscreen(); 69 void slotFullscreen();
70 void slotSessionChanged( Session* ); 70 void slotSessionChanged( Session* );
71 void slotKeyReceived(FKey, ushort, ushort, bool); 71 void slotKeyReceived(FKey, ushort, ushort, bool);
72 72
73 /* what could these both slot do? */ 73 /* what could these both slot do? */
74 void slotCopy(); 74 void slotCopy();
75 void slotPaste(); 75 void slotPaste();
76 76
77 /* save the currentSession() to Profiles */ 77 /* save the currentSession() to Profiles */
78 void slotSaveSession(); 78 void slotSaveSession();
79 79
80private: 80private:
81 void initUI(); 81 void initUI();
82 void populateProfiles(); 82 void populateProfiles();
83 void create( const Profile& ); 83 void create( const Profile& );
84 /** 84 /**
85 * the current session 85 * the current session
86 */ 86 */
87 Session* m_curSession; 87 Session* m_curSession;
88 88
89 /** 89 /**
90 * the session list 90 * the session list
91 */ 91 */
92 QList<Session> m_sessions; 92 QList<Session> m_sessions;
93 93
94 /** 94 /**
95 * the metafactory 95 * the metafactory
96 */ 96 */
97 MetaFactory* m_factory; 97 MetaFactory* m_factory;
98 ProfileManager* m_manager; 98 ProfileManager* m_manager;
99 99
100 TabWidget* m_consoleWindow; 100 TabWidget* m_consoleWindow;
101 QToolBar* m_tool; 101 QToolBar* m_tool;
102 QToolBar* m_icons; 102 QToolBar* m_icons;
103 QToolBar* m_keyBar; 103 QToolBar* m_keyBar;
104 QToolBar* m_buttonBar; 104 QToolBar* m_buttonBar;
105 QMenuBar* m_bar; 105 QMenuBar* m_bar;
106 QPopupMenu* m_console; 106 QPopupMenu* m_console;
107 QPopupMenu* m_settings; 107 QPopupMenu* m_settings;
108 QPopupMenu* m_sessionsPop; 108 QPopupMenu* m_sessionsPop;
109 QPopupMenu* m_scripts; 109 QPopupMenu* m_scripts;
110 QAction* m_connect; 110 QAction* m_connect;
111 QAction* m_disconnect; 111 QAction* m_disconnect;
112 QAction* m_terminate; 112 QAction* m_terminate;
113 QAction* m_transfer; 113 QAction* m_transfer;
114 QAction* m_setProfiles; 114 QAction* m_setProfiles;
115 QAction* m_openKeys; 115 QAction* m_openKeys;
116 QAction* m_openButtons; 116 QAction* m_openButtons;
117 QAction* m_recordScript; 117 QAction* m_recordScript;
118 QAction* m_saveScript; 118 QAction* m_saveScript;
119 QAction* m_runScript; 119 QAction* m_runScript;
120 QAction* m_fullscreen; 120 QAction* m_fullscreen;
121 QAction* m_closewindow; 121 QAction* m_closewindow;
122 122
123 FunctionKeyboard *m_kb; 123 FunctionKeyboard *m_kb;
124 QuickButton *m_qb;
125 bool m_isFullscreen; 124 bool m_isFullscreen;
126 125
127 QWidget* savedParentFullscreen; 126 QWidget* savedParentFullscreen;
128}; 127};
129 128
130 129
131#endif 130#endif