VirtualBox

Changeset 53086 in vbox for trunk/src


Ignore:
Timestamp:
Oct 17, 2014 1:56:38 PM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: Runtime UI rework/cleanup for 7115 (part #26): Extend Close VM Dialog with 'leave VM at background' option.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp

    r52937 r53086  
    12621262    switch (machineCloseAction)
    12631263    {
     1264        case MachineCloseAction_Detach:                     strResult = "Detach"; break;
    12641265        case MachineCloseAction_SaveState:                  strResult = "SaveState"; break;
    12651266        case MachineCloseAction_Shutdown:                   strResult = "Shutdown"; break;
     
    12811282     * to search through the keys using 'case-insensitive' rule: */
    12821283    QStringList keys;                    QList<MachineCloseAction> values;
     1284    keys << "Detach";                    values << MachineCloseAction_Detach;
    12831285    keys << "SaveState";                 values << MachineCloseAction_SaveState;
    12841286    keys << "Shutdown";                  values << MachineCloseAction_Shutdown;
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r52937 r53086  
    565565{
    566566    MachineCloseAction_Invalid                    = 0,
    567     MachineCloseAction_SaveState                  = RT_BIT(0),
    568     MachineCloseAction_Shutdown                   = RT_BIT(1),
    569     MachineCloseAction_PowerOff                   = RT_BIT(2),
    570     MachineCloseAction_PowerOff_RestoringSnapshot = RT_BIT(3),
     567    MachineCloseAction_Detach                     = RT_BIT(0),
     568    MachineCloseAction_SaveState                  = RT_BIT(1),
     569    MachineCloseAction_Shutdown                   = RT_BIT(2),
     570    MachineCloseAction_PowerOff                   = RT_BIT(3),
     571    MachineCloseAction_PowerOff_RestoringSnapshot = RT_BIT(4),
    571572    MachineCloseAction_All                        = 0xFF
    572573};
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.cpp

    r52937 r53086  
    21392139    /* Recache close related action restrictions: */
    21402140    MachineCloseAction restrictedCloseActions = gEDataManager->restrictedMachineCloseActions(strMachineID);
    2141     bool fAllCloseActionsRestricted =    (restrictedCloseActions & MachineCloseAction_SaveState)
     2141    bool fAllCloseActionsRestricted =    (!vboxGlobal().isSeparateProcess() || (restrictedCloseActions & MachineCloseAction_Detach))
     2142                                      && (restrictedCloseActions & MachineCloseAction_SaveState)
    21422143                                      && (restrictedCloseActions & MachineCloseAction_Shutdown)
    21432144                                      && (restrictedCloseActions & MachineCloseAction_PowerOff);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r53068 r53086  
    314314        switch (defaultCloseAction)
    315315        {
    316             /* If VM is stuck, and the default close-action is 'save-state' or 'shutdown',
     316            /* If VM is stuck, and the default close-action is 'detach', 'save-state' or 'shutdown',
    317317             * we should ask the user about what to do: */
     318            case MachineCloseAction_Detach:
    318319            case MachineCloseAction_SaveState:
    319320            case MachineCloseAction_Shutdown:
     
    355356                if (!fWasPaused && uisession()->isPaused() &&
    356357                    (closeAction == MachineCloseAction_Invalid ||
     358                     closeAction == MachineCloseAction_Detach ||
    357359                     closeAction == MachineCloseAction_Shutdown))
    358360                {
     
    376378    switch (closeAction)
    377379    {
     380        case MachineCloseAction_Detach:
     381        {
     382            /* Just close Runtime UI: */
     383            uisession()->closeRuntimeUI();
     384            break;
     385        }
    378386        case MachineCloseAction_SaveState:
    379387        {
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r53084 r53086  
    13481348        m_defaultCloseAction = gEDataManager->defaultMachineCloseAction(strMachineID);
    13491349        m_restrictedCloseActions = gEDataManager->restrictedMachineCloseActions(strMachineID);
    1350         m_fAllCloseActionsRestricted =  (m_restrictedCloseActions & MachineCloseAction_SaveState)
     1350        m_fAllCloseActionsRestricted =  (!vboxGlobal().isSeparateProcess() || (m_restrictedCloseActions & MachineCloseAction_Detach))
     1351                                     && (m_restrictedCloseActions & MachineCloseAction_SaveState)
    13511352                                     && (m_restrictedCloseActions & MachineCloseAction_Shutdown)
    13521353                                     && (m_restrictedCloseActions & MachineCloseAction_PowerOff);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.cpp

    r52730 r53086  
    4949                                 bool fIsACPIEnabled, MachineCloseAction restictedCloseActions)
    5050    : QIWithRetranslateUI<QIDialog>(pParent)
     51    , m_pIcon(0), m_pLabel(0)
     52    , m_pDetachIcon(0), m_pDetachRadio(0)
     53    , m_pSaveIcon(0), m_pSaveRadio(0)
     54    , m_pShutdownIcon(0), m_pShutdownRadio(0)
     55    , m_pPowerOffIcon(0), m_pPowerOffRadio(0), m_pDiscardCheckBox(0)
    5156    , m_machine(machine)
    5257    , m_restictedCloseActions(restictedCloseActions)
     
    7479{
    7580    /* Calculate result: */
    76     if (m_pSaveRadio->isChecked())
     81    if (m_pDetachRadio->isChecked())
     82        setResult(MachineCloseAction_Detach);
     83    else if (m_pSaveRadio->isChecked())
    7784        setResult(MachineCloseAction_SaveState);
    7885    else if (m_pShutdownRadio->isChecked())
     
    106113    /* Assign new pixmap: */
    107114    m_pIcon->setPixmap(pixmap);
     115}
     116
     117void UIVMCloseDialog::setDetachButtonEnabled(bool fEnabled)
     118{
     119    m_pDetachIcon->setEnabled(fEnabled);
     120    m_pDetachRadio->setEnabled(fEnabled);
     121}
     122
     123void UIVMCloseDialog::setDetachButtonVisible(bool fVisible)
     124{
     125    m_pDetachIcon->setVisible(fVisible);
     126    m_pDetachRadio->setVisible(fVisible);
    108127}
    109128
     
    181200                QGridLayout *pChoiceLayout = new QGridLayout;
    182201                {
     202                    /* Prepare 'detach' icon: */
     203                    m_pDetachIcon = new QLabel(this);
     204                    {
     205                        /* Configure icon: */
     206                        m_pDetachIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
     207                        m_pDetachIcon->setPixmap(QPixmap(":/vm_create_shortcut_16px.png"));
     208                    }
     209                    /* Prepare 'detach' radio-button: */
     210                    m_pDetachRadio = new QRadioButton(this);
     211                    {
     212                        /* Configure button: */
     213                        m_pDetachRadio->installEventFilter(this);
     214                        connect(m_pDetachRadio, SIGNAL(toggled(bool)), this, SLOT(sltUpdateWidgetAvailability()));
     215                    }
    183216                    /* Prepare 'save' icon: */
    184217                    m_pSaveIcon = new QLabel(this);
     
    232265#endif /* !Q_WS_MAC */
    233266                    pChoiceLayout->setContentsMargins(0, 0, 0, 0);
    234                     pChoiceLayout->addWidget(m_pSaveIcon, 0, 0);
    235                     pChoiceLayout->addWidget(m_pSaveRadio, 0, 1);
    236                     pChoiceLayout->addWidget(m_pShutdownIcon, 1, 0);
    237                     pChoiceLayout->addWidget(m_pShutdownRadio, 1, 1);
    238                     pChoiceLayout->addWidget(m_pPowerOffIcon, 2, 0);
    239                     pChoiceLayout->addWidget(m_pPowerOffRadio, 2, 1);
    240                     pChoiceLayout->addWidget(m_pDiscardCheckBox, 3, 1);
     267                    pChoiceLayout->addWidget(m_pDetachIcon, 0, 0);
     268                    pChoiceLayout->addWidget(m_pDetachRadio, 0, 1);
     269                    pChoiceLayout->addWidget(m_pSaveIcon, 1, 0);
     270                    pChoiceLayout->addWidget(m_pSaveRadio, 1, 1);
     271                    pChoiceLayout->addWidget(m_pShutdownIcon, 2, 0);
     272                    pChoiceLayout->addWidget(m_pShutdownRadio, 2, 1);
     273                    pChoiceLayout->addWidget(m_pPowerOffIcon, 3, 0);
     274                    pChoiceLayout->addWidget(m_pPowerOffRadio, 3, 1);
     275                    pChoiceLayout->addWidget(m_pDiscardCheckBox, 4, 1);
    241276                }
    242277                /* Configure layout: */
     
    286321
    287322    /* Check which close-actions are resticted: */
     323    bool fIsDetachAllowed = vboxGlobal().isSeparateProcess() && !(m_restictedCloseActions & MachineCloseAction_Detach);
    288324    bool fIsStateSavingAllowed = !(m_restictedCloseActions & MachineCloseAction_SaveState);
    289325    bool fIsACPIShutdownAllowed = !(m_restictedCloseActions & MachineCloseAction_Shutdown);
     
    291327    bool fIsPowerOffAndRestoreAllowed = fIsPowerOffAllowed && !(m_restictedCloseActions & MachineCloseAction_PowerOff_RestoringSnapshot);
    292328
     329    /* Make 'Detach' button visible/hidden depending on restriction: */
     330    setDetachButtonVisible(fIsDetachAllowed);
     331    /* Make 'Detach' button enabled/disabled depending on machine-state: */
     332    setDetachButtonEnabled(machineState != KMachineState_Stuck);
     333
    293334    /* Make 'Save state' button visible/hidden depending on restriction: */
    294335    setSaveButtonVisible(fIsStateSavingAllowed);
    295336    /* Make 'Save state' button enabled/disabled depending on machine-state: */
    296337    setSaveButtonEnabled(machineState != KMachineState_Stuck);
    297     /* Make 'Shutdown button' visible/hidden depending on restriction: */
     338
     339    /* Make 'Shutdown' button visible/hidden depending on restriction: */
    298340    setShutdownButtonVisible(fIsACPIShutdownAllowed);
     341    /* Make 'Shutdown' button enabled/disabled depending on console and machine-state: */
    299342    setShutdownButtonEnabled(m_fIsACPIEnabled && machineState != KMachineState_Stuck);
     343
    300344    /* Make 'Power off' button visible/hidden depending on restriction: */
    301345    setPowerOffButtonVisible(fIsPowerOffAllowed);
     
    310354    /* If choosing 'last choice' is possible: */
    311355    m_lastCloseAction = gEDataManager->lastMachineCloseAction(vboxGlobal().managedVMUuid());
    312     if (m_lastCloseAction == MachineCloseAction_SaveState && fIsStateSavingAllowed)
     356    if (m_lastCloseAction == MachineCloseAction_Detach && fIsDetachAllowed)
     357    {
     358        pRadioButtonToChoose = m_pDetachRadio;
     359    }
     360    else if (m_lastCloseAction == MachineCloseAction_SaveState && fIsStateSavingAllowed)
    313361    {
    314362        pRadioButtonToChoose = m_pSaveRadio;
     
    330378    else
    331379    {
    332         if (fIsStateSavingAllowed)
     380        if (fIsDetachAllowed)
     381            pRadioButtonToChoose = m_pDetachRadio;
     382        else if (fIsStateSavingAllowed)
    333383            pRadioButtonToChoose = m_pSaveRadio;
    334384        else if (fIsACPIShutdownAllowed && m_fIsACPIEnabled)
     
    358408
    359409    /* Translate radio-buttons: */
     410    m_pDetachRadio->setText(tr("&Continue running in the background"));
     411    m_pDetachRadio->setWhatsThis(tr("<p>Close the virtual machine windows but keep the virtual machine running.</p>"
     412                                    "<p>You can use the VirtualBox Manager to return to running the virtual machine in a window.</p>"));
    360413    m_pSaveRadio->setText(tr("&Save the machine state"));
    361414    m_pSaveRadio->setWhatsThis(tr("<p>Saves the current execution state of the virtual machine to the physical hard disk of the host PC.</p>"
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.h

    r52727 r53086  
    5656    void setPixmap(const QPixmap &pixmap);
    5757
     58    /* API: Detach-button stuff: */
     59    void setDetachButtonEnabled(bool fEnabled);
     60    void setDetachButtonVisible(bool fVisible);
    5861    /* API: Save-button stuff: */
    5962    void setSaveButtonEnabled(bool fEnabled);
     
    8487    QLabel *m_pIcon;
    8588    QLabel *m_pLabel;
     89    QLabel *m_pDetachIcon;
     90    QRadioButton *m_pDetachRadio;
    8691    QLabel *m_pSaveIcon;
    8792    QRadioButton *m_pSaveRadio;
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