summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-10-24 19:16:28 (UTC)
committer harlekin <harlekin>2002-10-24 19:16:28 (UTC)
commit2f2f9dc5f45fe7cf194a057e104c2d54394e4cef (patch) (unidiff)
treebf9a38b4e3d09e2e145b79ecf1e5be78263c530d
parent94573faf2e89723a49bbaf3630f1d19f80ba6b27 (diff)
downloadopie-2f2f9dc5f45fe7cf194a057e104c2d54394e4cef.zip
opie-2f2f9dc5f45fe7cf194a057e104c2d54394e4cef.tar.gz
opie-2f2f9dc5f45fe7cf194a057e104c2d54394e4cef.tar.bz2
cleanup and icon rearrangement
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp47
-rw-r--r--noncore/apps/opie-console/mainwindow.h1
2 files changed, 17 insertions, 31 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 745efaf..44ef458 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,419 +1,406 @@
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 29
30 30
31 31
32MainWindow::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) {
33 KeyTrans::loadAll(); 33 KeyTrans::loadAll();
34 for (int i = 0; i < KeyTrans::count(); i++ ) { 34 for (int i = 0; i < KeyTrans::count(); i++ ) {
35 KeyTrans* s = KeyTrans::find(i ); 35 KeyTrans* s = KeyTrans::find(i );
36 assert( s ); 36 assert( s );
37 } 37 }
38 m_factory = new MetaFactory(); 38 m_factory = new MetaFactory();
39 Default def(m_factory); 39 Default def(m_factory);
40 m_sessions.setAutoDelete( TRUE ); 40 m_sessions.setAutoDelete( TRUE );
41 m_curSession = 0; 41 m_curSession = 0;
42 m_manager = new ProfileManager( m_factory ); 42 m_manager = new ProfileManager( m_factory );
43 m_manager->load(); 43 m_manager->load();
44 44
45 initUI(); 45 initUI();
46 populateProfiles(); 46 populateProfiles();
47} 47}
48void MainWindow::initUI() { 48void MainWindow::initUI() {
49 setToolBarsMovable( FALSE ); 49 setToolBarsMovable( FALSE );
50 50
51 /* tool bar for the menu */ 51 /* tool bar for the menu */
52 m_tool = new QToolBar( this ); 52 m_tool = new QToolBar( this );
53 m_tool->setHorizontalStretchable( TRUE ); 53 m_tool->setHorizontalStretchable( TRUE );
54 54
55 m_bar = new QMenuBar( m_tool ); 55 m_bar = new QMenuBar( m_tool );
56 m_console = new QPopupMenu( this ); 56 m_console = new QPopupMenu( this );
57 m_scripts = new QPopupMenu( this ); 57 m_scripts = new QPopupMenu( this );
58 m_sessionsPop= new QPopupMenu( this ); 58 m_sessionsPop= new QPopupMenu( this );
59 //m_settings = new QPopupMenu( this );
60 59
61 /* add a toolbar for icons */ 60 /* add a toolbar for icons */
62 m_icons = new QToolBar(this); 61 m_icons = new QToolBar(this);
63 62
64
65
66
67 /* 63 /*
68 * the settings action 64 * the settings action
69 */ 65 */
70 m_setProfiles = new QAction(tr("Configure Profiles"), 66 m_setProfiles = new QAction(tr("Configure Profiles"),
71 Resource::loadPixmap( "SettingsIcon" ), 67 Resource::loadPixmap( "SettingsIcon" ),
72 QString::null, 0, this, 0); 68 QString::null, 0, this, 0);
73 // m_setProfiles->addTo( m_settings );
74 m_setProfiles->addTo( m_icons );
75 m_setProfiles->addTo( m_console ); 69 m_setProfiles->addTo( m_console );
76 connect( m_setProfiles, SIGNAL(activated() ), 70 connect( m_setProfiles, SIGNAL(activated() ),
77 this, SLOT(slotConfigure() ) ); 71 this, SLOT(slotConfigure() ) );
78 72
79 m_console->insertSeparator(); 73 m_console->insertSeparator();
80 /* 74 /*
81 * new Action for new sessions 75 * new Action for new sessions
82 */ 76 */
83 QAction* a = new QAction(tr("New Connection"), 77 QAction* newCon = new QAction(tr("New Connection"),
84 Resource::loadPixmap( "new" ), 78 Resource::loadPixmap( "new" ),
85 QString::null, 0, this, 0); 79 QString::null, 0, this, 0);
86 a->addTo( m_console ); 80 newCon->addTo( m_console );
87 a->addTo( m_icons ); 81 connect( newCon, SIGNAL(activated() ),
88 connect(a, SIGNAL(activated() ),
89 this, SLOT(slotNew() ) ); 82 this, SLOT(slotNew() ) );
90 83
91 m_console->insertSeparator(); 84 m_console->insertSeparator();
92 /* save icon is not available */ 85 /* save icon is not available */
93 a = new QAction(tr("Save Connection"), 86
87 QAction *saveCon = new QAction(tr("Save Connection"),
94 Resource::loadPixmap("save"), QString::null, 88 Resource::loadPixmap("save"), QString::null,
95 0, this, 0 ); 89 0, this, 0 );
96 a->addTo( m_console ); 90 saveCon->addTo( m_console );
97 connect(a, SIGNAL(activated() ), 91 connect( saveCon, SIGNAL(activated() ),
98 this, SLOT(slotSaveSession() ) ); 92 this, SLOT(slotSaveSession() ) );
99 m_console->insertSeparator(); 93 m_console->insertSeparator();
100 94
101 /* 95 /*
102 * connect action 96 * connect action
103 */ 97 */
104 m_connect = new QAction(); 98 m_connect = new QAction();
105 m_connect->setText( tr("Connect") ); 99 m_connect->setText( tr("Connect") );
106 m_connect->addTo( m_console ); 100 m_connect->addTo( m_console );
107 connect(m_connect, SIGNAL(activated() ), 101 connect(m_connect, SIGNAL(activated() ),
108 this, SLOT(slotConnect() ) ); 102 this, SLOT(slotConnect() ) );
109 103
110 /* 104 /*
111 * disconnect action 105 * disconnect action
112 */ 106 */
113 m_disconnect = new QAction(); 107 m_disconnect = new QAction();
114 m_disconnect->setText( tr("Disconnect") ); 108 m_disconnect->setText( tr("Disconnect") );
115 m_disconnect->addTo( m_console ); 109 m_disconnect->addTo( m_console );
116 connect(m_disconnect, SIGNAL(activated() ), 110 connect(m_disconnect, SIGNAL(activated() ),
117 this, SLOT(slotDisconnect() ) ); 111 this, SLOT(slotDisconnect() ) );
118 112
119 m_console->insertSeparator(); 113 m_console->insertSeparator();
120 114
121 m_transfer = new QAction(); 115 m_transfer = new QAction();
122 m_transfer->setText( tr("Transfer file...") ); 116 m_transfer->setText( tr("Transfer file...") );
123 m_transfer->addTo( m_console ); 117 m_transfer->addTo( m_console );
124 connect(m_transfer, SIGNAL(activated() ), 118 connect(m_transfer, SIGNAL(activated() ),
125 this, SLOT(slotTransfer() ) ); 119 this, SLOT(slotTransfer() ) );
126 120
127 121
128 /* 122 /*
129 * fullscreen 123 * fullscreen
130 */ 124 */
131 m_isFullscreen = false; 125 m_isFullscreen = false;
132 126
133 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) 127 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" )
134 , QString::null, 0, this, 0); 128 , QString::null, 0, this, 0);
135 m_fullscreen->addTo( m_console ); 129 m_fullscreen->addTo( m_console );
136 m_fullscreen->addTo( m_icons );
137 connect( m_fullscreen, SIGNAL( activated() ), 130 connect( m_fullscreen, SIGNAL( activated() ),
138 this, SLOT( slotFullscreen() ) ); 131 this, SLOT( slotFullscreen() ) );
139 132
140 m_console->insertSeparator(); 133 m_console->insertSeparator();
141 /* 134 /*
142 * terminate action 135 * terminate action
143 */ 136 */
144 m_terminate = new QAction(); 137 m_terminate = new QAction();
145 m_terminate->setText( tr("Terminate") ); 138 m_terminate->setText( tr("Terminate") );
146 m_terminate->addTo( m_console ); 139 m_terminate->addTo( m_console );
147 connect(m_terminate, SIGNAL(activated() ), 140 connect(m_terminate, SIGNAL(activated() ),
148 this, SLOT(slotTerminate() ) ); 141 this, SLOT(slotTerminate() ) );
149 142
150 m_closewindow = new QAction(); 143 m_closewindow = new QAction();
151 m_closewindow->setText( tr("Close Window") ); 144 m_closewindow->setText( tr("Close Window") );
152 m_closewindow->addTo( m_console ); 145 m_closewindow->addTo( m_console );
153 connect( m_closewindow, SIGNAL(activated() ), 146 connect( m_closewindow, SIGNAL(activated() ),
154 this, SLOT(slotClose() ) ); 147 this, SLOT(slotClose() ) );
155 148
156 149
157 /* 150 /*
158 * script actions 151 * script actions
159 */ 152 */
160 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); 153 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
161 m_recordScript->addTo(m_scripts); 154 m_recordScript->addTo(m_scripts);
162 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); 155 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript()));
163 156
164 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); 157 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0);
165 m_saveScript->addTo(m_scripts); 158 m_saveScript->addTo(m_scripts);
166 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); 159 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript()));
167 160
168 m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); 161 m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0);
169 m_runScript->addTo(m_scripts); 162 m_runScript->addTo(m_scripts);
170 connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); 163 connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript()));
171 164
172 /* 165 /*
173 * action that open/closes the keyboard 166 * action that open/closes the keyboard
174 */ 167 */
175 m_openKeys = new QAction (tr("Open Keyboard..."), 168 m_openKeys = new QAction (tr("Open Keyboard..."),
176 Resource::loadPixmap( "console/keys/keyboard_icon" ), 169 Resource::loadPixmap( "console/keys/keyboard_icon" ),
177 QString::null, 0, this, 0); 170 QString::null, 0, this, 0);
178
179 m_openKeys->setToggleAction(true); 171 m_openKeys->setToggleAction(true);
180 172 connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool)));
181 connect (m_openKeys, SIGNAL(toggled(bool)),
182 this, SLOT(slotOpenKeb(bool)));
183 m_openKeys->addTo(m_icons);
184 173
185 /* insert the submenu */ 174 /* insert the submenu */
186 m_console->insertItem(tr("New from Profile"), m_sessionsPop, 175 m_console->insertItem(tr("New from Profile"), m_sessionsPop,
187 -1, 0); 176 -1, 0);
188 177
189 /* insert the connection menu */ 178 /* insert the connection menu */
190 m_bar->insertItem( tr("Connection"), m_console ); 179 m_bar->insertItem( tr("Connection"), m_console );
191 180
192 /* the scripts menu */ 181 /* the scripts menu */
193 m_bar->insertItem( tr("Scripts"), m_scripts ); 182 m_bar->insertItem( tr("Scripts"), m_scripts );
194 183
195 /* the settings menu */
196 // m_bar->insertItem( tr("Settings"), m_settings );
197
198 /* and the keyboard */ 184 /* and the keyboard */
199 m_keyBar = new QToolBar(this); 185 m_keyBar = new QToolBar(this);
200 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); 186 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE );
201 m_keyBar->setHorizontalStretchable( TRUE ); 187 m_keyBar->setHorizontalStretchable( TRUE );
202 m_keyBar->hide(); 188 m_keyBar->hide();
203 189
204 m_kb = new FunctionKeyboard(m_keyBar); 190 m_kb = new FunctionKeyboard(m_keyBar);
205 connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), 191 connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)),
206 this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); 192 this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool)));
207 193
208 m_buttonBar = new QToolBar( this );
209 addToolBar( m_buttonBar, "Buttons", QMainWindow::Top, TRUE );
210 m_buttonBar->setHorizontalStretchable( TRUE );
211 m_buttonBar->hide();
212 194
213 a = new QAction(tr("Copy"), 195 QAction *a = new QAction(tr("Copy"),
214 Resource::loadPixmap("copy"), QString::null, 196 Resource::loadPixmap("copy"), QString::null,
215 0, this, 0 ); 197 0, this, 0 );
216 //a->addTo( m_icons ); 198 //a->addTo( m_icons );
217 connect( a, SIGNAL(activated() ), 199 connect( a, SIGNAL(activated() ),
218 this, SLOT(slotCopy() ) ); 200 this, SLOT(slotCopy() ) );
219 201
220 a = new QAction(tr("Paste"), 202 QAction *paste = new QAction(tr("Paste"),
221 Resource::loadPixmap("paste"), QString::null, 203 Resource::loadPixmap("paste"), QString::null,
222 0, this, 0 ); 204 0, this, 0 );
223 a->addTo( m_icons ); 205 connect( paste, SIGNAL(activated() ),
224 connect( a, SIGNAL(activated() ),
225 this, SLOT(slotPaste() ) ); 206 this, SLOT(slotPaste() ) );
226 207
227 208
209 newCon->addTo( m_icons );
210 m_setProfiles->addTo( m_icons );
211 paste->addTo( m_icons );
212 m_openKeys->addTo(m_icons);
213 m_fullscreen->addTo( m_icons );
214
228 m_connect->setEnabled( false ); 215 m_connect->setEnabled( false );
229 m_disconnect->setEnabled( false ); 216 m_disconnect->setEnabled( false );
230 m_terminate->setEnabled( false ); 217 m_terminate->setEnabled( false );
231 m_transfer->setEnabled( false ); 218 m_transfer->setEnabled( false );
232 m_recordScript->setEnabled( false ); 219 m_recordScript->setEnabled( false );
233 m_saveScript->setEnabled( false ); 220 m_saveScript->setEnabled( false );
234 m_runScript->setEnabled( false ); 221 m_runScript->setEnabled( false );
235 m_fullscreen->setEnabled( false ); 222 m_fullscreen->setEnabled( false );
236 m_closewindow->setEnabled( false ); 223 m_closewindow->setEnabled( false );
237 224
238 /* 225 /*
239 * connect to the menu activation 226 * connect to the menu activation
240 */ 227 */
241 connect( m_sessionsPop, SIGNAL(activated( int ) ), 228 connect( m_sessionsPop, SIGNAL(activated( int ) ),
242 this, SLOT(slotProfile( int ) ) ); 229 this, SLOT(slotProfile( int ) ) );
243 230
244 m_consoleWindow = new TabWidget( this, "blah"); 231 m_consoleWindow = new TabWidget( this, "blah");
245 connect(m_consoleWindow, SIGNAL(activated(Session*) ), 232 connect(m_consoleWindow, SIGNAL(activated(Session*) ),
246 this, SLOT(slotSessionChanged(Session*) ) ); 233 this, SLOT(slotSessionChanged(Session*) ) );
247 setCentralWidget( m_consoleWindow ); 234 setCentralWidget( m_consoleWindow );
248 235
249} 236}
250 237
251ProfileManager* MainWindow::manager() { 238ProfileManager* MainWindow::manager() {
252 return m_manager; 239 return m_manager;
253} 240}
254TabWidget* MainWindow::tabWidget() { 241TabWidget* MainWindow::tabWidget() {
255 return m_consoleWindow; 242 return m_consoleWindow;
256} 243}
257void MainWindow::populateProfiles() { 244void MainWindow::populateProfiles() {
258 m_sessionsPop->clear(); 245 m_sessionsPop->clear();
259 Profile::ValueList list = manager()->all(); 246 Profile::ValueList list = manager()->all();
260 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { 247 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) {
261 m_sessionsPop->insertItem( (*it).name() ); 248 m_sessionsPop->insertItem( (*it).name() );
262 } 249 }
263 250
264} 251}
265MainWindow::~MainWindow() { 252MainWindow::~MainWindow() {
266 delete m_factory; 253 delete m_factory;
267 manager()->save(); 254 manager()->save();
268} 255}
269 256
270MetaFactory* MainWindow::factory() { 257MetaFactory* MainWindow::factory() {
271 return m_factory; 258 return m_factory;
272} 259}
273 260
274Session* MainWindow::currentSession() { 261Session* MainWindow::currentSession() {
275 return m_curSession; 262 return m_curSession;
276} 263}
277 264
278QList<Session> MainWindow::sessions() { 265QList<Session> MainWindow::sessions() {
279 return m_sessions; 266 return m_sessions;
280} 267}
281 268
282void MainWindow::slotNew() { 269void MainWindow::slotNew() {
283 ProfileEditorDialog dlg(factory() ); 270 ProfileEditorDialog dlg(factory() );
284 dlg.showMaximized(); 271 dlg.showMaximized();
285 int ret = dlg.exec(); 272 int ret = dlg.exec();
286 273
287 if ( ret == QDialog::Accepted ) { 274 if ( ret == QDialog::Accepted ) {
288 create( dlg.profile() ); 275 create( dlg.profile() );
289 } 276 }
290} 277}
291 278
292void MainWindow::slotRecordScript() { 279void MainWindow::slotRecordScript() {
293 if (currentSession()) { 280 if (currentSession()) {
294 currentSession()->emulationHandler()->startRecording(); 281 currentSession()->emulationHandler()->startRecording();
295 } 282 }
296} 283}
297 284
298void MainWindow::slotSaveScript() { 285void MainWindow::slotSaveScript() {
299 if (currentSession() && currentSession()->emulationHandler()->isRecording()) { 286 if (currentSession() && currentSession()->emulationHandler()->isRecording()) {
300 MimeTypes types; 287 MimeTypes types;
301 QStringList script; 288 QStringList script;
302 script << "text/plain"; 289 script << "text/plain";
303 script << "text/all"; 290 script << "text/all";
304 script << "application/octet-stream"; 291 script << "application/octet-stream";
305 types.insert("Script", script); 292 types.insert("Script", script);
306 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); 293 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types);
307 if (!filename.isEmpty()) { 294 if (!filename.isEmpty()) {
308 currentSession()->emulationHandler()->script()->saveTo(filename); 295 currentSession()->emulationHandler()->script()->saveTo(filename);
309 currentSession()->emulationHandler()->clearScript(); 296 currentSession()->emulationHandler()->clearScript();
310 } 297 }
311 } 298 }
312} 299}
313 300
314void MainWindow::slotRunScript() { 301void MainWindow::slotRunScript() {
315 if (currentSession()) { 302 if (currentSession()) {
316 MimeTypes types; 303 MimeTypes types;
317 QStringList script; 304 QStringList script;
318 script << "text/plain"; 305 script << "text/plain";
319 script << "text/all"; 306 script << "text/all";
320 script << "application/octet-stream"; 307 script << "application/octet-stream";
321 types.insert("Script", script); 308 types.insert("Script", script);
322 QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); 309 QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types);
323 if (!filename.isEmpty()) { 310 if (!filename.isEmpty()) {
324 Script script(DocLnk(filename).file()); 311 Script script(DocLnk(filename).file());
325 currentSession()->emulationHandler()->runScript(&script); 312 currentSession()->emulationHandler()->runScript(&script);
326 } 313 }
327 } 314 }
328} 315}
329 316
330void MainWindow::slotConnect() { 317void MainWindow::slotConnect() {
331 if ( currentSession() ) { 318 if ( currentSession() ) {
332 bool ret = currentSession()->layer()->open(); 319 bool ret = currentSession()->layer()->open();
333 if(!ret) QMessageBox::warning(currentSession()->widgetStack(), 320 if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
334 QObject::tr("Failed"), 321 QObject::tr("Failed"),
335 QObject::tr("Connecting failed for this session.")); 322 QObject::tr("Connecting failed for this session."));
336 else { 323 else {
337 m_connect->setEnabled( false ); 324 m_connect->setEnabled( false );
338 m_disconnect->setEnabled( true ); 325 m_disconnect->setEnabled( true );
339 m_transfer->setEnabled( true ); 326 m_transfer->setEnabled( true );
340 m_recordScript->setEnabled( true ); 327 m_recordScript->setEnabled( true );
341 m_saveScript->setEnabled( true ); 328 m_saveScript->setEnabled( true );
342 m_runScript->setEnabled( true ); 329 m_runScript->setEnabled( true );
343 } 330 }
344 } 331 }
345} 332}
346 333
347void MainWindow::slotDisconnect() { 334void MainWindow::slotDisconnect() {
348 if ( currentSession() ) { 335 if ( currentSession() ) {
349 currentSession()->layer()->close(); 336 currentSession()->layer()->close();
350 m_connect->setEnabled( true ); 337 m_connect->setEnabled( true );
351 m_disconnect->setEnabled( false ); 338 m_disconnect->setEnabled( false );
352 m_transfer->setEnabled( false ); 339 m_transfer->setEnabled( false );
353 m_recordScript->setEnabled( false); 340 m_recordScript->setEnabled( false);
354 m_saveScript->setEnabled( false ); 341 m_saveScript->setEnabled( false );
355 m_runScript->setEnabled( false ); 342 m_runScript->setEnabled( false );
356 } 343 }
357} 344}
358 345
359void MainWindow::slotTerminate() { 346void MainWindow::slotTerminate() {
360 if ( currentSession() ) 347 if ( currentSession() )
361 currentSession()->layer()->close(); 348 currentSession()->layer()->close();
362 349
363 slotClose(); 350 slotClose();
364 /* FIXME move to the next session */ 351 /* FIXME move to the next session */
365} 352}
366 353
367void MainWindow::slotConfigure() { 354void MainWindow::slotConfigure() {
368 ConfigDialog conf( manager()->all(), factory() ); 355 ConfigDialog conf( manager()->all(), factory() );
369 conf.showMaximized(); 356 conf.showMaximized();
370 357
371 int ret = conf.exec(); 358 int ret = conf.exec();
372 359
373 if ( QDialog::Accepted == ret ) { 360 if ( QDialog::Accepted == ret ) {
374 manager()->setProfiles( conf.list() ); 361 manager()->setProfiles( conf.list() );
375 manager()->save(); 362 manager()->save();
376 populateProfiles(); 363 populateProfiles();
377 } 364 }
378} 365}
379/* 366/*
380 * we will remove 367 * we will remove
381 * this window from the tabwidget 368 * this window from the tabwidget
382 * remove it from the list 369 * remove it from the list
383 * delete it 370 * delete it
384 * and set the currentSession() 371 * and set the currentSession()
385 */ 372 */
386void MainWindow::slotClose() { 373void MainWindow::slotClose() {
387 if (!currentSession() ) 374 if (!currentSession() )
388 return; 375 return;
389 376
390 Session* ses = currentSession(); 377 Session* ses = currentSession();
391 qWarning("removing! currentSession %s", currentSession()->name().latin1() ); 378 qWarning("removing! currentSession %s", currentSession()->name().latin1() );
392 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ 379 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */
393 m_curSession = NULL; 380 m_curSession = NULL;
394 tabWidget()->remove( /*currentSession()*/ses ); 381 tabWidget()->remove( /*currentSession()*/ses );
395 /*it's autodelete */ 382 /*it's autodelete */
396 m_sessions.remove( ses ); 383 m_sessions.remove( ses );
397 qWarning("after remove!!"); 384 qWarning("after remove!!");
398 385
399 if (!currentSession() ) { 386 if (!currentSession() ) {
400 m_connect->setEnabled( false ); 387 m_connect->setEnabled( false );
401 m_disconnect->setEnabled( false ); 388 m_disconnect->setEnabled( false );
402 m_terminate->setEnabled( false ); 389 m_terminate->setEnabled( false );
403 m_transfer->setEnabled( false ); 390 m_transfer->setEnabled( false );
404 m_recordScript->setEnabled( false ); 391 m_recordScript->setEnabled( false );
405 m_saveScript->setEnabled( false ); 392 m_saveScript->setEnabled( false );
406 m_runScript->setEnabled( false ); 393 m_runScript->setEnabled( false );
407 m_fullscreen->setEnabled( false ); 394 m_fullscreen->setEnabled( false );
408 m_closewindow->setEnabled( false ); 395 m_closewindow->setEnabled( false );
409 } 396 }
410 397
411 m_kb->loadDefaults(); 398 m_kb->loadDefaults();
412} 399}
413 400
414/* 401/*
415 * We will get the name 402 * We will get the name
416 * Then the profile 403 * Then the profile
417 * and then we will make a profile 404 * and then we will make a profile
418 */ 405 */
419void MainWindow::slotProfile( int id) { 406void MainWindow::slotProfile( int id) {
diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h
index 7cc2aa5..19d3a3d 100644
--- a/noncore/apps/opie-console/mainwindow.h
+++ b/noncore/apps/opie-console/mainwindow.h
@@ -1,130 +1,129 @@
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;
24 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;
108 QPopupMenu* m_sessionsPop; 107 QPopupMenu* m_sessionsPop;
109 QPopupMenu* m_scripts; 108 QPopupMenu* m_scripts;
110 QAction* m_connect; 109 QAction* m_connect;
111 QAction* m_disconnect; 110 QAction* m_disconnect;
112 QAction* m_terminate; 111 QAction* m_terminate;
113 QAction* m_transfer; 112 QAction* m_transfer;
114 QAction* m_setProfiles; 113 QAction* m_setProfiles;
115 QAction* m_openKeys; 114 QAction* m_openKeys;
116 QAction* m_openButtons; 115 QAction* m_openButtons;
117 QAction* m_recordScript; 116 QAction* m_recordScript;
118 QAction* m_saveScript; 117 QAction* m_saveScript;
119 QAction* m_runScript; 118 QAction* m_runScript;
120 QAction* m_fullscreen; 119 QAction* m_fullscreen;
121 QAction* m_closewindow; 120 QAction* m_closewindow;
122 121
123 FunctionKeyboard *m_kb; 122 FunctionKeyboard *m_kb;
124 bool m_isFullscreen; 123 bool m_isFullscreen;
125 124
126 QWidget* savedParentFullscreen; 125 QWidget* savedParentFullscreen;
127}; 126};
128 127
129 128
130#endif 129#endif