VirtualBox

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


Ignore:
Timestamp:
May 19, 2016 4:17:43 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
107319
Message:

FE/Qt: ​​​​​​​​​​bugref:7791: Runtime UI: Implement unfairly forgotten Machine menu Detach GUI action.

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

Legend:

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

    r60458 r61052  
    540540        case UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Pause:             strResult = "Pause"; break;
    541541        case UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Reset:             strResult = "Reset"; break;
     542        case UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Detach:            strResult = "Detach"; break;
    542543        case UIExtraDataMetaDefs::RuntimeMenuMachineActionType_SaveState:         strResult = "SaveState"; break;
    543544        case UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Shutdown:          strResult = "Shutdown"; break;
     
    565566    keys << "Pause";             values << UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Pause;
    566567    keys << "Reset";             values << UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Reset;
     568    keys << "Detach";            values << UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Detach;
    567569    keys << "SaveState";         values << UIExtraDataMetaDefs::RuntimeMenuMachineActionType_SaveState;
    568570    keys << "Shutdown";          values << UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Shutdown;
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r60599 r61052  
    381381        RuntimeMenuMachineActionType_Pause             = RT_BIT(3),
    382382        RuntimeMenuMachineActionType_Reset             = RT_BIT(4),
    383         RuntimeMenuMachineActionType_SaveState         = RT_BIT(5),
    384         RuntimeMenuMachineActionType_Shutdown          = RT_BIT(6),
    385         RuntimeMenuMachineActionType_PowerOff          = RT_BIT(7),
    386         RuntimeMenuMachineActionType_Nothing           = RT_BIT(8),
     383        RuntimeMenuMachineActionType_Detach            = RT_BIT(5),
     384        RuntimeMenuMachineActionType_SaveState         = RT_BIT(6),
     385        RuntimeMenuMachineActionType_Shutdown          = RT_BIT(7),
     386        RuntimeMenuMachineActionType_PowerOff          = RT_BIT(8),
     387        RuntimeMenuMachineActionType_Nothing           = RT_BIT(9),
    387388        RuntimeMenuMachineActionType_All               = 0xFFFF
    388389    };
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.cpp

    r60362 r61052  
    243243};
    244244
     245class UIActionSimplePerformDetach : public UIActionSimple
     246{
     247    Q_OBJECT;
     248
     249public:
     250
     251    UIActionSimplePerformDetach(UIActionPool *pParent)
     252        : UIActionSimple(pParent, ":/vm_create_shortcut_16px.png", ":/vm_create_shortcut_disabled_16px.png") {}
     253
     254protected:
     255
     256    /** Returns action extra-data ID. */
     257    virtual int extraDataID() const { return UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Detach; }
     258    /** Returns action extra-data key. */
     259    virtual QString extraDataKey() const { return gpConverter->toInternalString(UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Detach); }
     260    /** Returns whether action is allowed. */
     261    virtual bool isAllowed() const { return actionPool()->toRuntime()->isAllowedInMenuMachine(UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Detach); }
     262
     263    QString shortcutExtraDataID() const
     264    {
     265        return QString("DetachUI");
     266    }
     267
     268    void retranslateUi()
     269    {
     270        setName(QApplication::translate("UIActionPool", "&Detach GUI"));
     271        setStatusTip(QApplication::translate("UIActionPool", "Detach the GUI from headless VM"));
     272    }
     273};
     274
    245275class UIActionSimplePerformSaveState : public UIActionSimple
    246276{
     
    20742104    m_pool[UIActionIndexRT_M_Machine_T_Pause] = new UIActionTogglePause(this);
    20752105    m_pool[UIActionIndexRT_M_Machine_S_Reset] = new UIActionSimplePerformReset(this);
     2106    m_pool[UIActionIndexRT_M_Machine_S_Detach] = new UIActionSimplePerformDetach(this);
    20762107    m_pool[UIActionIndexRT_M_Machine_S_SaveState] = new UIActionSimplePerformSaveState(this);
    20772108    m_pool[UIActionIndexRT_M_Machine_S_Shutdown] = new UIActionSimplePerformShutdown(this);
     
    23722403    /* 'Reset' action: */
    23732404    fSeparator = addAction(pMenu, action(UIActionIndexRT_M_Machine_S_Reset)) || fSeparator;
     2405    /* 'Detach' action: */
     2406    fSeparator = addAction(pMenu, action(UIActionIndexRT_M_Machine_S_Detach)) || fSeparator;
    23742407    /* 'SaveState' action: */
    23752408    fSeparator = addAction(pMenu, action(UIActionIndexRT_M_Machine_S_SaveState)) || fSeparator;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.h

    r60362 r61052  
    4747    UIActionIndexRT_M_Machine_T_Pause,
    4848    UIActionIndexRT_M_Machine_S_Reset,
     49    UIActionIndexRT_M_Machine_S_Detach,
    4950    UIActionIndexRT_M_Machine_S_SaveState,
    5051    UIActionIndexRT_M_Machine_S_Shutdown,
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r61028 r61052  
    387387}
    388388#endif /* VBOX_WS_MAC */
     389
     390void UIMachineLogic::detach()
     391{
     392    /* Enable 'manual-override',
     393     * preventing automatic Runtime UI closing: */
     394    setManualOverrideMode(true);
     395
     396    /* Was the step successful? */
     397    bool fSuccess = true;
     398    LogRel(("GUI: Passing request to detach UI from machine-logic to UI session.\n"));
     399    fSuccess = uisession()->detach();
     400
     401    /* Manually close Runtime UI: */
     402    if (fSuccess)
     403        closeRuntimeUI();
     404}
    389405
    390406void UIMachineLogic::saveState()
     
    10031019
    10041020    /* Move actions into running-n-paused actions group: */
     1021    m_pRunningOrPausedActions->addAction(actionPool()->action(UIActionIndexRT_M_Machine_S_Detach));
    10051022    m_pRunningOrPausedActions->addAction(actionPool()->action(UIActionIndexRT_M_Machine_S_SaveState));
    10061023    m_pRunningOrPausedActions->addAction(actionPool()->action(UIActionIndexRT_M_Machine_S_Settings));
     
    10721089    connect(actionPool()->action(UIActionIndexRT_M_Machine_S_Reset), SIGNAL(triggered()),
    10731090            this, SLOT(sltReset()));
     1091    connect(actionPool()->action(UIActionIndexRT_M_Machine_S_Detach), SIGNAL(triggered()),
     1092            this, SLOT(sltDetach()), Qt::QueuedConnection);
    10741093    connect(actionPool()->action(UIActionIndexRT_M_Machine_S_SaveState), SIGNAL(triggered()),
    10751094            this, SLOT(sltSaveState()), Qt::QueuedConnection);
     
    15701589}
    15711590
     1591void UIMachineLogic::sltDetach()
     1592{
     1593    /* Make sure machine is in one of the allowed states: */
     1594    if (!uisession()->isRunning() && !uisession()->isPaused())
     1595    {
     1596        AssertMsgFailed(("Invalid machine-state. Action should be prohibited!"));
     1597        return;
     1598    }
     1599
     1600    detach();
     1601}
     1602
    15721603void UIMachineLogic::sltSaveState()
    15731604{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r60362 r61052  
    140140#endif /* VBOX_WS_MAC */
    141141
     142    /** Detach and close Runtime UI. */
     143    void detach();
    142144    /** Save VM state, then close Runtime UI. */
    143145    void saveState();
     
    267269    void sltReset();
    268270    void sltPause(bool fOn);
     271    void sltDetach();
    269272    void sltSaveState();
    270273    void sltShutdown();
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r60362 r61052  
    421421            /* Just close Runtime UI: */
    422422            LogRel(("GUI: Request for close-action to detach GUI.\n"));
    423             machineLogic()->closeRuntimeUI();
     423            machineLogic()->detach();
    424424            break;
    425425        }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMenuBarEditorWindow.cpp

    r60362 r61052  
    882882        prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_T_Pause));
    883883        prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_S_Reset));
     884        prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_S_Detach));
    884885        prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_S_SaveState));
    885886        prepareCopiedAction(pMenu, actionPool()->action(UIActionIndexRT_M_Machine_S_Shutdown));
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r61021 r61052  
    321321
    322322    /* True by default: */
     323    return true;
     324}
     325
     326bool UISession::detach()
     327{
     328    /* Nothing here for now: */
    323329    return true;
    324330}
     
    21322138    /* Get host and prepare restrictions: */
    21332139    const CHost host = vboxGlobal().host();
     2140    UIExtraDataMetaDefs::RuntimeMenuMachineActionType restrictionForMachine = UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Invalid;
    21342141    UIExtraDataMetaDefs::RuntimeMenuViewActionType restrictionForView = UIExtraDataMetaDefs::RuntimeMenuViewActionType_Invalid;
    21352142    UIExtraDataMetaDefs::RuntimeMenuDevicesActionType restrictionForDevices = UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Invalid;
     2143
     2144    /* Separate process stuff: */
     2145    {
     2146        /* Initialize 'Machine' menu: */
     2147        if (!vboxGlobal().isSeparateProcess())
     2148            restrictionForMachine = (UIExtraDataMetaDefs::RuntimeMenuMachineActionType)(restrictionForMachine | UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Detach);
     2149    }
    21362150
    21372151    /* VRDE server stuff: */
     
    22032217    }
    22042218
     2219    /* Apply cumulative restriction for 'Machine' menu: */
     2220    actionPool()->toRuntime()->setRestrictionForMenuMachine(UIActionRestrictionLevel_Session, restrictionForMachine);
    22052221    /* Apply cumulative restriction for 'View' menu: */
    22062222    actionPool()->toRuntime()->setRestrictionForMenuView(UIActionRestrictionLevel_Session, restrictionForView);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r60362 r61052  
    9494    bool initialize();
    9595    bool powerUp();
     96    bool detach();
    9697    bool saveState();
    9798    bool shutdown();
Note: See TracChangeset for help on using the changeset viewer.

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