VirtualBox

Changeset 14014 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Nov 10, 2008 1:48:45 PM (16 years ago)
Author:
vboxsync
Message:

Fe/Qt4: Systray: Stabilized action handling.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxSelectorWnd.cpp

    r14005 r14014  
    14171417
    14181418        KMachineState state = item->state();
    1419         bool running = item->sessionState() != KSessionState_Closed;
     1419        bool running = item->running();
    14201420        bool modifyEnabled = !running && state != KMachineState_Saved;
    14211421
     
    14501450            vmTabWidget->setTabEnabled (vmTabWidget->indexOf (vmDescriptionPage), true);
    14511451        }
    1452 
    1453         /* enable/disable modify actions */
    1454         vmConfigAction->setEnabled (modifyEnabled);
    1455         vmDeleteAction->setEnabled (modifyEnabled);
    1456         vmDiscardAction->setEnabled (state == KMachineState_Saved && !running);
    1457         vmPauseAction->setEnabled (state == KMachineState_Running ||
    1458                                    state == KMachineState_Paused);
    1459 
    1460         /* change the Start button text accordingly */
    1461         if (state >= KMachineState_Running)
    1462         {
    1463             vmStartAction->setText (tr ("S&how"));
    1464             vmStartAction->setStatusTip (
    1465                 tr ("Switch to the window of the selected virtual machine"));
    1466 
    1467             vmStartAction->setEnabled (item->canSwitchTo());
    1468         }
    1469         else
    1470         {
    1471             vmStartAction->setText (tr ("S&tart"));
    1472             vmStartAction->setStatusTip (
    1473                 tr ("Start the selected virtual machine"));
    1474 
    1475             vmStartAction->setEnabled (!running);
    1476         }
    1477 
    1478         /* change the Pause/Resume button text accordingly */
    1479         if (state == KMachineState_Paused)
    1480         {
    1481             vmPauseAction->setText (tr ("R&esume"));
    1482             vmPauseAction->setShortcut (QKeySequence ("Ctrl+P"));
    1483             vmPauseAction->setStatusTip (
    1484                 tr ("Resume the execution of the virtual machine"));
    1485             vmPauseAction->blockSignals (true);
    1486             vmPauseAction->setChecked (true);
    1487             vmPauseAction->blockSignals (false);
    1488         }
    1489         else
    1490         {
    1491             vmPauseAction->setText (tr ("&Pause"));
    1492             vmPauseAction->setShortcut (QKeySequence ("Ctrl+P"));
    1493             vmPauseAction->setStatusTip (
    1494                 tr ("Suspend the execution of the virtual machine"));
    1495             vmPauseAction->blockSignals (true);
    1496             vmPauseAction->setChecked (false);
    1497             vmPauseAction->blockSignals (false);
    1498         }
    1499 
    1500         /* disable Refresh for accessible machines */
    1501         vmRefreshAction->setEnabled (false);
    1502 
    1503         /* enable the show log item for the selected vm */
    1504         vmShowLogsAction->setEnabled (true);
    15051452    }
    15061453    else
     
    15151462            vmDetailsView->setErrorText (
    15161463                VBoxProblemReporter::formatErrorInfo (item->accessError()));
    1517             vmRefreshAction->setEnabled (true);
    15181464        }
    15191465        else
     
    15481494        vmTabWidget->setTabText (vmTabWidget->indexOf (vmDescriptionPage), tr ("D&escription"));
    15491495        vmTabWidget->setTabEnabled (vmTabWidget->indexOf (vmDescriptionPage), false);
    1550 
    1551         /* disable modify actions */
    1552         vmConfigAction->setEnabled (false);
    1553         vmDeleteAction->setEnabled (item != NULL);
    1554         vmDiscardAction->setEnabled (false);
    1555         vmPauseAction->setEnabled (false);
    1556 
    1557         /* change the Start button text accordingly */
    1558         vmStartAction->setText (tr ("S&tart"));
    1559         vmStartAction->setStatusTip (
    1560             tr ("Start the selected virtual machine"));
    1561         vmStartAction->setEnabled (false);
    1562 
    1563         /* disable the show log item for the selected vm */
    1564         vmShowLogsAction->setEnabled (false);
     1496    }
     1497
     1498    if (item)
     1499    {
     1500        item->updateActions();
     1501
     1502        /* enable/disable modify actions */
     1503        vmConfigAction->setEnabled (item->vmActionConfig()->isEnabled());
     1504        vmDeleteAction->setEnabled (item->vmActionDelete()->isEnabled());
     1505        vmDiscardAction->setEnabled (item->vmActionDiscard()->isEnabled());
     1506
     1507        vmStartAction->setEnabled (item->vmActionStart()->isEnabled());
     1508        vmStartAction->setText (item->vmActionStart()->text());
     1509        vmStartAction->setStatusTip (item->vmActionStart()->statusTip());
     1510
     1511        vmPauseAction->setEnabled (item->vmActionPause()->isEnabled());
     1512        vmPauseAction->setText (item->vmActionPause()->text());
     1513        vmPauseAction->setStatusTip (item->vmActionPause()->statusTip());
     1514        vmPauseAction->blockSignals (true);
     1515        vmPauseAction->setChecked (item->vmActionPause()->isChecked());
     1516        vmPauseAction->blockSignals (false);
     1517
     1518        vmRefreshAction->setEnabled (item->vmActionRefresh()->isEnabled());
     1519
     1520        vmShowLogsAction->setEnabled (item->vmActionShowLogs()->isEnabled());
    15651521    }
    15661522}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette