Diffstat (limited to 'noncore/apps/opie-console/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 85 |
1 files changed, 53 insertions, 32 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 44ef458..2e00a07 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -1,24 +1,27 @@ | |||
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 | #include <qpe/qpeapplication.h> | ||
14 | #include <qpe/filemanager.h> | ||
15 | #include <qpe/mimetype.h> | ||
13 | 16 | ||
14 | #include <opie/ofiledialog.h> | 17 | #include <opie/ofiledialog.h> |
15 | 18 | ||
16 | #include "keytrans.h" | 19 | #include "keytrans.h" |
17 | #include "profileeditordialog.h" | 20 | #include "profileeditordialog.h" |
18 | #include "configdialog.h" | 21 | #include "configdialog.h" |
19 | #include "default.h" | 22 | #include "default.h" |
20 | #include "metafactory.h" | 23 | #include "metafactory.h" |
21 | #include "profile.h" | 24 | #include "profile.h" |
22 | #include "profilemanager.h" | 25 | #include "profilemanager.h" |
23 | #include "mainwindow.h" | 26 | #include "mainwindow.h" |
24 | #include "tabwidget.h" | 27 | #include "tabwidget.h" |
@@ -35,36 +38,38 @@ MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow( | |||
35 | KeyTrans* s = KeyTrans::find(i ); | 38 | KeyTrans* s = KeyTrans::find(i ); |
36 | assert( s ); | 39 | assert( s ); |
37 | } | 40 | } |
38 | m_factory = new MetaFactory(); | 41 | m_factory = new MetaFactory(); |
39 | Default def(m_factory); | 42 | Default def(m_factory); |
40 | m_sessions.setAutoDelete( TRUE ); | 43 | m_sessions.setAutoDelete( TRUE ); |
41 | m_curSession = 0; | 44 | m_curSession = 0; |
42 | m_manager = new ProfileManager( m_factory ); | 45 | m_manager = new ProfileManager( m_factory ); |
43 | m_manager->load(); | 46 | m_manager->load(); |
44 | 47 | ||
45 | initUI(); | 48 | initUI(); |
46 | populateProfiles(); | 49 | populateProfiles(); |
50 | populateScripts(); | ||
47 | } | 51 | } |
48 | void MainWindow::initUI() { | 52 | void MainWindow::initUI() { |
49 | setToolBarsMovable( FALSE ); | 53 | setToolBarsMovable( FALSE ); |
50 | 54 | ||
51 | /* tool bar for the menu */ | 55 | /* tool bar for the menu */ |
52 | m_tool = new QToolBar( this ); | 56 | m_tool = new QToolBar( this ); |
53 | m_tool->setHorizontalStretchable( TRUE ); | 57 | m_tool->setHorizontalStretchable( TRUE ); |
54 | 58 | ||
55 | m_bar = new QMenuBar( m_tool ); | 59 | m_bar = new QMenuBar( m_tool ); |
56 | m_console = new QPopupMenu( this ); | 60 | m_console = new QPopupMenu( this ); |
57 | m_scripts = new QPopupMenu( this ); | 61 | m_scripts = new QPopupMenu( this ); |
58 | m_sessionsPop= new QPopupMenu( this ); | 62 | m_sessionsPop= new QPopupMenu( this ); |
63 | m_scriptsPop = new QPopupMenu( this ); | ||
59 | 64 | ||
60 | /* add a toolbar for icons */ | 65 | /* add a toolbar for icons */ |
61 | m_icons = new QToolBar(this); | 66 | m_icons = new QToolBar(this); |
62 | 67 | ||
63 | /* | 68 | /* |
64 | * the settings action | 69 | * the settings action |
65 | */ | 70 | */ |
66 | m_setProfiles = new QAction(tr("Configure Profiles"), | 71 | m_setProfiles = new QAction(tr("Configure Profiles"), |
67 | Resource::loadPixmap( "SettingsIcon" ), | 72 | Resource::loadPixmap( "SettingsIcon" ), |
68 | QString::null, 0, this, 0); | 73 | QString::null, 0, this, 0); |
69 | m_setProfiles->addTo( m_console ); | 74 | m_setProfiles->addTo( m_console ); |
70 | connect( m_setProfiles, SIGNAL(activated() ), | 75 | connect( m_setProfiles, SIGNAL(activated() ), |
@@ -141,35 +146,35 @@ void MainWindow::initUI() { | |||
141 | this, SLOT(slotTerminate() ) ); | 146 | this, SLOT(slotTerminate() ) ); |
142 | 147 | ||
143 | m_closewindow = new QAction(); | 148 | m_closewindow = new QAction(); |
144 | m_closewindow->setText( tr("Close Window") ); | 149 | m_closewindow->setText( tr("Close Window") ); |
145 | m_closewindow->addTo( m_console ); | 150 | m_closewindow->addTo( m_console ); |
146 | connect( m_closewindow, SIGNAL(activated() ), | 151 | connect( m_closewindow, SIGNAL(activated() ), |
147 | this, SLOT(slotClose() ) ); | 152 | this, SLOT(slotClose() ) ); |
148 | 153 | ||
149 | 154 | ||
150 | /* | 155 | /* |
151 | * script actions | 156 | * script actions |
152 | */ | 157 | */ |
158 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); | ||
159 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); | ||
160 | |||
153 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); | 161 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); |
154 | m_recordScript->addTo(m_scripts); | 162 | m_recordScript->addTo(m_scripts); |
155 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); | 163 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); |
156 | 164 | ||
157 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); | 165 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); |
158 | m_saveScript->addTo(m_scripts); | 166 | m_saveScript->addTo(m_scripts); |
159 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); | 167 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); |
160 | 168 | ||
161 | m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); | ||
162 | m_runScript->addTo(m_scripts); | ||
163 | connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); | ||
164 | 169 | ||
165 | /* | 170 | /* |
166 | * action that open/closes the keyboard | 171 | * action that open/closes the keyboard |
167 | */ | 172 | */ |
168 | m_openKeys = new QAction (tr("Open Keyboard..."), | 173 | m_openKeys = new QAction (tr("Open Keyboard..."), |
169 | Resource::loadPixmap( "console/keys/keyboard_icon" ), | 174 | Resource::loadPixmap( "console/keys/keyboard_icon" ), |
170 | QString::null, 0, this, 0); | 175 | QString::null, 0, this, 0); |
171 | m_openKeys->setToggleAction(true); | 176 | m_openKeys->setToggleAction(true); |
172 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); | 177 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); |
173 | 178 | ||
174 | /* insert the submenu */ | 179 | /* insert the submenu */ |
175 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 180 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
@@ -207,27 +212,27 @@ void MainWindow::initUI() { | |||
207 | 212 | ||
208 | 213 | ||
209 | newCon->addTo( m_icons ); | 214 | newCon->addTo( m_icons ); |
210 | m_setProfiles->addTo( m_icons ); | 215 | m_setProfiles->addTo( m_icons ); |
211 | paste->addTo( m_icons ); | 216 | paste->addTo( m_icons ); |
212 | m_openKeys->addTo(m_icons); | 217 | m_openKeys->addTo(m_icons); |
213 | m_fullscreen->addTo( m_icons ); | 218 | m_fullscreen->addTo( m_icons ); |
214 | 219 | ||
215 | m_connect->setEnabled( false ); | 220 | m_connect->setEnabled( false ); |
216 | m_disconnect->setEnabled( false ); | 221 | m_disconnect->setEnabled( false ); |
217 | m_terminate->setEnabled( false ); | 222 | m_terminate->setEnabled( false ); |
218 | m_transfer->setEnabled( false ); | 223 | m_transfer->setEnabled( false ); |
224 | m_scripts->setItemEnabled(m_runScript_id, false); | ||
219 | m_recordScript->setEnabled( false ); | 225 | m_recordScript->setEnabled( false ); |
220 | m_saveScript->setEnabled( false ); | 226 | m_saveScript->setEnabled( false ); |
221 | m_runScript->setEnabled( false ); | ||
222 | m_fullscreen->setEnabled( false ); | 227 | m_fullscreen->setEnabled( false ); |
223 | m_closewindow->setEnabled( false ); | 228 | m_closewindow->setEnabled( false ); |
224 | 229 | ||
225 | /* | 230 | /* |
226 | * connect to the menu activation | 231 | * connect to the menu activation |
227 | */ | 232 | */ |
228 | connect( m_sessionsPop, SIGNAL(activated( int ) ), | 233 | connect( m_sessionsPop, SIGNAL(activated( int ) ), |
229 | this, SLOT(slotProfile( int ) ) ); | 234 | this, SLOT(slotProfile( int ) ) ); |
230 | 235 | ||
231 | m_consoleWindow = new TabWidget( this, "blah"); | 236 | m_consoleWindow = new TabWidget( this, "blah"); |
232 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), | 237 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), |
233 | this, SLOT(slotSessionChanged(Session*) ) ); | 238 | this, SLOT(slotSessionChanged(Session*) ) ); |
@@ -240,24 +245,39 @@ ProfileManager* MainWindow::manager() { | |||
240 | } | 245 | } |
241 | TabWidget* MainWindow::tabWidget() { | 246 | TabWidget* MainWindow::tabWidget() { |
242 | return m_consoleWindow; | 247 | return m_consoleWindow; |
243 | } | 248 | } |
244 | void MainWindow::populateProfiles() { | 249 | void MainWindow::populateProfiles() { |
245 | m_sessionsPop->clear(); | 250 | m_sessionsPop->clear(); |
246 | Profile::ValueList list = manager()->all(); | 251 | Profile::ValueList list = manager()->all(); |
247 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 252 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
248 | m_sessionsPop->insertItem( (*it).name() ); | 253 | m_sessionsPop->insertItem( (*it).name() ); |
249 | } | 254 | } |
250 | 255 | ||
251 | } | 256 | } |
257 | |||
258 | void MainWindow::populateScripts() { | ||
259 | m_scriptsPop->clear(); | ||
260 | m_scriptsData.clear(); | ||
261 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); | ||
262 | QListIterator<DocLnk> dit(files.children()); | ||
263 | for (; dit.current(); ++dit) { | ||
264 | if (*dit && (*dit)->name().length()>0) { | ||
265 | m_scriptsData.append((*dit)); | ||
266 | m_scriptsPop->insertItem((*dit)->name()); | ||
267 | } | ||
268 | } | ||
269 | |||
270 | } | ||
271 | |||
252 | MainWindow::~MainWindow() { | 272 | MainWindow::~MainWindow() { |
253 | delete m_factory; | 273 | delete m_factory; |
254 | manager()->save(); | 274 | manager()->save(); |
255 | } | 275 | } |
256 | 276 | ||
257 | MetaFactory* MainWindow::factory() { | 277 | MetaFactory* MainWindow::factory() { |
258 | return m_factory; | 278 | return m_factory; |
259 | } | 279 | } |
260 | 280 | ||
261 | Session* MainWindow::currentSession() { | 281 | Session* MainWindow::currentSession() { |
262 | return m_curSession; | 282 | return m_curSession; |
263 | } | 283 | } |
@@ -270,85 +290,86 @@ void MainWindow::slotNew() { | |||
270 | ProfileEditorDialog dlg(factory() ); | 290 | ProfileEditorDialog dlg(factory() ); |
271 | dlg.showMaximized(); | 291 | dlg.showMaximized(); |
272 | int ret = dlg.exec(); | 292 | int ret = dlg.exec(); |
273 | 293 | ||
274 | if ( ret == QDialog::Accepted ) { | 294 | if ( ret == QDialog::Accepted ) { |
275 | create( dlg.profile() ); | 295 | create( dlg.profile() ); |
276 | } | 296 | } |
277 | } | 297 | } |
278 | 298 | ||
279 | void MainWindow::slotRecordScript() { | 299 | void MainWindow::slotRecordScript() { |
280 | if (currentSession()) { | 300 | if (currentSession()) { |
281 | currentSession()->emulationHandler()->startRecording(); | 301 | currentSession()->emulationHandler()->startRecording(); |
302 | m_saveScript->setEnabled(true); | ||
303 | m_recordScript->setEnabled(false); | ||
282 | } | 304 | } |
283 | } | 305 | } |
284 | 306 | ||
285 | void MainWindow::slotSaveScript() { | 307 | void MainWindow::slotSaveScript() { |
286 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { | 308 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { |
287 | MimeTypes types; | 309 | QMap<QString, QStringList> map; |
288 | QStringList script; | 310 | QStringList text; |
289 | script << "text/plain"; | 311 | text << "text/plain"; |
290 | script << "text/all"; | 312 | map.insert(tr("Script"), text ); |
291 | script << "application/octet-stream"; | 313 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
292 | types.insert("Script", script); | ||
293 | QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); | ||
294 | if (!filename.isEmpty()) { | 314 | if (!filename.isEmpty()) { |
295 | currentSession()->emulationHandler()->script()->saveTo(filename); | 315 | DocLnk nf; |
316 | nf.setType("text/plain"); | ||
317 | nf.setFile(filename); | ||
318 | nf.setName(filename); | ||
319 | FileManager fm; | ||
320 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); | ||
296 | currentSession()->emulationHandler()->clearScript(); | 321 | currentSession()->emulationHandler()->clearScript(); |
322 | m_saveScript->setEnabled(false); | ||
323 | m_recordScript->setEnabled(true); | ||
324 | populateScripts(); | ||
297 | } | 325 | } |
298 | } | 326 | } |
299 | } | 327 | } |
300 | 328 | ||
301 | void MainWindow::slotRunScript() { | 329 | void MainWindow::slotRunScript(int id) { |
302 | if (currentSession()) { | 330 | if (currentSession()) { |
303 | MimeTypes types; | 331 | DocLnk *lnk = m_scriptsData.at(m_scriptsPop->indexOf(id)); |
304 | QStringList script; | 332 | QString filePath = lnk->file(); |
305 | script << "text/plain"; | 333 | printf("path is : %s\n", filePath.latin1()); |
306 | script << "text/all"; | 334 | Script script(filePath); |
307 | script << "application/octet-stream"; | ||
308 | types.insert("Script", script); | ||
309 | QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); | ||
310 | if (!filename.isEmpty()) { | ||
311 | Script script(DocLnk(filename).file()); | ||
312 | currentSession()->emulationHandler()->runScript(&script); | 335 | currentSession()->emulationHandler()->runScript(&script); |
313 | } | 336 | } |
314 | } | 337 | } |
315 | } | ||
316 | 338 | ||
317 | void MainWindow::slotConnect() { | 339 | void MainWindow::slotConnect() { |
318 | if ( currentSession() ) { | 340 | if ( currentSession() ) { |
319 | bool ret = currentSession()->layer()->open(); | 341 | bool ret = currentSession()->layer()->open(); |
320 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), | 342 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), |
321 | QObject::tr("Failed"), | 343 | QObject::tr("Failed"), |
322 | QObject::tr("Connecting failed for this session.")); | 344 | QObject::tr("Connecting failed for this session.")); |
323 | else { | 345 | else { |
324 | m_connect->setEnabled( false ); | 346 | m_connect->setEnabled( false ); |
325 | m_disconnect->setEnabled( true ); | 347 | m_disconnect->setEnabled( true ); |
326 | m_transfer->setEnabled( true ); | 348 | m_transfer->setEnabled( true ); |
327 | m_recordScript->setEnabled( true ); | 349 | m_recordScript->setEnabled( true ); |
328 | m_saveScript->setEnabled( true ); | 350 | m_scripts->setItemEnabled(m_runScript_id, true); |
329 | m_runScript->setEnabled( true ); | ||
330 | } | 351 | } |
331 | } | 352 | } |
332 | } | 353 | } |
333 | 354 | ||
334 | void MainWindow::slotDisconnect() { | 355 | void MainWindow::slotDisconnect() { |
335 | if ( currentSession() ) { | 356 | if ( currentSession() ) { |
336 | currentSession()->layer()->close(); | 357 | currentSession()->layer()->close(); |
337 | m_connect->setEnabled( true ); | 358 | m_connect->setEnabled( true ); |
338 | m_disconnect->setEnabled( false ); | 359 | m_disconnect->setEnabled( false ); |
339 | m_transfer->setEnabled( false ); | 360 | m_transfer->setEnabled( false ); |
340 | m_recordScript->setEnabled( false); | 361 | m_recordScript->setEnabled( false); |
341 | m_saveScript->setEnabled( false ); | 362 | m_saveScript->setEnabled( false ); |
342 | m_runScript->setEnabled( false ); | 363 | m_scripts->setItemEnabled(m_runScript_id, false); |
343 | } | 364 | } |
344 | } | 365 | } |
345 | 366 | ||
346 | void MainWindow::slotTerminate() { | 367 | void MainWindow::slotTerminate() { |
347 | if ( currentSession() ) | 368 | if ( currentSession() ) |
348 | currentSession()->layer()->close(); | 369 | currentSession()->layer()->close(); |
349 | 370 | ||
350 | slotClose(); | 371 | slotClose(); |
351 | /* FIXME move to the next session */ | 372 | /* FIXME move to the next session */ |
352 | } | 373 | } |
353 | 374 | ||
354 | void MainWindow::slotConfigure() { | 375 | void MainWindow::slotConfigure() { |
@@ -381,25 +402,25 @@ void MainWindow::slotClose() { | |||
381 | tabWidget()->remove( /*currentSession()*/ses ); | 402 | tabWidget()->remove( /*currentSession()*/ses ); |
382 | /*it's autodelete */ | 403 | /*it's autodelete */ |
383 | m_sessions.remove( ses ); | 404 | m_sessions.remove( ses ); |
384 | qWarning("after remove!!"); | 405 | qWarning("after remove!!"); |
385 | 406 | ||
386 | if (!currentSession() ) { | 407 | if (!currentSession() ) { |
387 | m_connect->setEnabled( false ); | 408 | m_connect->setEnabled( false ); |
388 | m_disconnect->setEnabled( false ); | 409 | m_disconnect->setEnabled( false ); |
389 | m_terminate->setEnabled( false ); | 410 | m_terminate->setEnabled( false ); |
390 | m_transfer->setEnabled( false ); | 411 | m_transfer->setEnabled( false ); |
391 | m_recordScript->setEnabled( false ); | 412 | m_recordScript->setEnabled( false ); |
392 | m_saveScript->setEnabled( false ); | 413 | m_saveScript->setEnabled( false ); |
393 | m_runScript->setEnabled( false ); | 414 | m_scripts->setItemEnabled(m_runScript_id, false); |
394 | m_fullscreen->setEnabled( false ); | 415 | m_fullscreen->setEnabled( false ); |
395 | m_closewindow->setEnabled( false ); | 416 | m_closewindow->setEnabled( false ); |
396 | } | 417 | } |
397 | 418 | ||
398 | m_kb->loadDefaults(); | 419 | m_kb->loadDefaults(); |
399 | } | 420 | } |
400 | 421 | ||
401 | /* | 422 | /* |
402 | * We will get the name | 423 | * We will get the name |
403 | * Then the profile | 424 | * Then the profile |
404 | * and then we will make a profile | 425 | * and then we will make a profile |
405 | */ | 426 | */ |
@@ -424,25 +445,25 @@ void MainWindow::create( const Profile& prof ) { | |||
424 | tabWidget()->repaint(); | 445 | tabWidget()->repaint(); |
425 | m_curSession = ses; | 446 | m_curSession = ses; |
426 | 447 | ||
427 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it | 448 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it |
428 | m_connect->setEnabled( true ); | 449 | m_connect->setEnabled( true ); |
429 | m_disconnect->setEnabled( false ); | 450 | m_disconnect->setEnabled( false ); |
430 | m_terminate->setEnabled( true ); | 451 | m_terminate->setEnabled( true ); |
431 | m_fullscreen->setEnabled( true ); | 452 | m_fullscreen->setEnabled( true ); |
432 | m_closewindow->setEnabled( true ); | 453 | m_closewindow->setEnabled( true ); |
433 | m_transfer->setEnabled( false ); | 454 | m_transfer->setEnabled( false ); |
434 | m_recordScript->setEnabled( false ); | 455 | m_recordScript->setEnabled( false ); |
435 | m_saveScript->setEnabled( false ); | 456 | m_saveScript->setEnabled( false ); |
436 | m_runScript->setEnabled( false ); | 457 | m_scripts->setItemEnabled(m_runScript_id, false); |
437 | 458 | ||
438 | // is io_layer wants direct connection, then autoconnect | 459 | // is io_layer wants direct connection, then autoconnect |
439 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { | 460 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { |
440 | if (prof.autoConnect()) { | 461 | if (prof.autoConnect()) { |
441 | slotConnect(); | 462 | slotConnect(); |
442 | } | 463 | } |
443 | 464 | ||
444 | 465 | ||
445 | 466 | ||
446 | QWidget *w = currentSession()->widget(); | 467 | QWidget *w = currentSession()->widget(); |
447 | if(w) w->setFocus(); | 468 | if(w) w->setFocus(); |
448 | 469 | ||
@@ -478,33 +499,33 @@ void MainWindow::slotOpenButtons( bool state ) { | |||
478 | } | 499 | } |
479 | 500 | ||
480 | 501 | ||
481 | 502 | ||
482 | void MainWindow::slotSessionChanged( Session* ses ) { | 503 | void MainWindow::slotSessionChanged( Session* ses ) { |
483 | qWarning("changed!"); | 504 | qWarning("changed!"); |
484 | if ( ses ) { | 505 | if ( ses ) { |
485 | m_curSession = ses; | 506 | m_curSession = ses; |
486 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); | 507 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); |
487 | if ( m_curSession->layer()->isConnected() ) { | 508 | if ( m_curSession->layer()->isConnected() ) { |
488 | m_connect->setEnabled( false ); | 509 | m_connect->setEnabled( false ); |
489 | m_disconnect->setEnabled( true ); | 510 | m_disconnect->setEnabled( true ); |
490 | m_recordScript->setEnabled( true ); | 511 | m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); |
491 | m_saveScript->setEnabled( true ); | 512 | m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); |
492 | m_runScript->setEnabled( true ); | 513 | m_scripts->setItemEnabled(m_runScript_id, true); |
493 | } else { | 514 | } else { |
494 | m_connect->setEnabled( true ); | 515 | m_connect->setEnabled( true ); |
495 | m_disconnect->setEnabled( false ); | 516 | m_disconnect->setEnabled( false ); |
496 | m_recordScript->setEnabled( false ); | 517 | m_recordScript->setEnabled( false ); |
497 | m_saveScript->setEnabled( false ); | 518 | m_saveScript->setEnabled( false ); |
498 | m_runScript->setEnabled( false ); | 519 | m_scripts->setItemEnabled(m_runScript_id, false); |
499 | } | 520 | } |
500 | 521 | ||
501 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { | 522 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { |
502 | m_transfer->setEnabled( false ); | 523 | m_transfer->setEnabled( false ); |
503 | } else { | 524 | } else { |
504 | m_transfer->setEnabled( true ); | 525 | m_transfer->setEnabled( true ); |
505 | } | 526 | } |
506 | 527 | ||
507 | 528 | ||
508 | 529 | ||
509 | 530 | ||
510 | 531 | ||