VirtualBox

Changeset 97277 in vbox


Ignore:
Timestamp:
Oct 24, 2022 12:37:37 PM (2 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9866: Moving Detach action to upper level scope, it's not a part of Close menu anymore; Action still hidden for now since the functionality isn't yet implemented.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.cpp

    r96483 r97277  
    12151215};
    12161216
     1217/** Simple action extension, used as 'Perform Detach' action class. */
     1218class UIActionSimpleManagerCommonPerformDetach : public UIActionSimple
     1219{
     1220    Q_OBJECT;
     1221
     1222public:
     1223
     1224    /** Constructs action passing @a pParent to the base-class. */
     1225    UIActionSimpleManagerCommonPerformDetach(UIActionPool *pParent)
     1226        : UIActionSimple(pParent, ":/vm_create_shortcut_16px.png", ":/vm_create_shortcut_disabled_16px.png")
     1227    {}
     1228
     1229protected:
     1230
     1231    /** Returns shortcut extra-data ID. */
     1232    virtual QString shortcutExtraDataID() const RT_OVERRIDE
     1233    {
     1234        return QString("DetachUIVM");
     1235    }
     1236
     1237    /** Handles translation event. */
     1238    virtual void retranslateUi() RT_OVERRIDE
     1239    {
     1240        setName(QApplication::translate("UIActionPool", "&Detach GUI"));
     1241        setStatusTip(QApplication::translate("UIActionPool", "Detach the GUI from headless VM"));
     1242    }
     1243};
     1244
    12171245/** Simple menu action extension, used as 'Perform Discard' action class. */
    12181246class UIActionSimpleManagerCommonPerformDiscard : public UIActionSimple
     
    16461674};
    16471675
    1648 /** Simple action extension, used as 'Perform Detach' action class. */
    1649 class UIActionSimpleManagerClosePerformDetach : public UIActionSimple
    1650 {
    1651     Q_OBJECT;
    1652 
    1653 public:
    1654 
    1655     /** Constructs action passing @a pParent to the base-class. */
    1656     UIActionSimpleManagerClosePerformDetach(UIActionPool *pParent)
    1657         : UIActionSimple(pParent, ":/vm_create_shortcut_16px.png", ":/vm_create_shortcut_disabled_16px.png")
    1658     {}
    1659 
    1660 protected:
    1661 
    1662     /** Returns shortcut extra-data ID. */
    1663     virtual QString shortcutExtraDataID() const RT_OVERRIDE
    1664     {
    1665         return QString("DetachUIVM");
    1666     }
    1667 
    1668     /** Handles translation event. */
    1669     virtual void retranslateUi() RT_OVERRIDE
    1670     {
    1671         setName(QApplication::translate("UIActionPool", "&Detach GUI"));
    1672         setStatusTip(QApplication::translate("UIActionPool", "Detach the GUI from headless VM"));
    1673     }
    1674 };
    1675 
    16761676/** Simple action extension, used as 'Perform Save' action class. */
    16771677class UIActionSimpleManagerClosePerformSave : public UIActionSimple
     
    36453645    m_pool[UIActionIndexMN_M_Group_T_Pause] = new UIActionToggleManagerCommonPauseAndResume(this);
    36463646    m_pool[UIActionIndexMN_M_Group_S_Reset] = new UIActionSimpleManagerCommonPerformReset(this);
     3647    m_pool[UIActionIndexMN_M_Group_S_Detach] = new UIActionSimpleManagerCommonPerformDetach(this);
    36473648    m_pool[UIActionIndexMN_M_Group_M_Console] = new UIActionMenuManagerConsole(this);
    36483649    m_pool[UIActionIndexMN_M_Group_M_Console_S_CreateConnection] = new UIActionSimpleManagerConsolePerformCreateConnection(this);
     
    36503651    m_pool[UIActionIndexMN_M_Group_M_Console_S_ConfigureApplications] = new UIActionSimpleManagerConsolePerformConfigureApplications(this);
    36513652    m_pool[UIActionIndexMN_M_Group_M_Close] = new UIActionMenuManagerClose(this);
    3652     m_pool[UIActionIndexMN_M_Group_M_Close_S_Detach] = new UIActionSimpleManagerClosePerformDetach(this);
    36533653    m_pool[UIActionIndexMN_M_Group_M_Close_S_SaveState] = new UIActionSimpleManagerClosePerformSave(this);
    36543654    m_pool[UIActionIndexMN_M_Group_M_Close_S_Terminate] = new UIActionSimpleManagerClosePerformTerminate(this);
     
    36873687    m_pool[UIActionIndexMN_M_Machine_T_Pause] = new UIActionToggleManagerCommonPauseAndResume(this);
    36883688    m_pool[UIActionIndexMN_M_Machine_S_Reset] = new UIActionSimpleManagerCommonPerformReset(this);
     3689    m_pool[UIActionIndexMN_M_Machine_S_Detach] = new UIActionSimpleManagerCommonPerformDetach(this);
    36893690    m_pool[UIActionIndexMN_M_Machine_M_Console] = new UIActionMenuManagerConsole(this);
    36903691    m_pool[UIActionIndexMN_M_Machine_M_Console_S_CreateConnection] = new UIActionSimpleManagerConsolePerformCreateConnection(this);
     
    36973698    m_pool[UIActionIndexMN_M_Machine_M_Console_S_ShowLog] = new UIActionSimpleManagerConsolePerformShowLog(this);
    36983699    m_pool[UIActionIndexMN_M_Machine_M_Close] = new UIActionMenuManagerClose(this);
    3699     m_pool[UIActionIndexMN_M_Machine_M_Close_S_Detach] = new UIActionSimpleManagerClosePerformDetach(this);
    37003700    m_pool[UIActionIndexMN_M_Machine_M_Close_S_SaveState] = new UIActionSimpleManagerClosePerformSave(this);
    37013701    m_pool[UIActionIndexMN_M_Machine_M_Close_S_Terminate] = new UIActionSimpleManagerClosePerformTerminate(this);
     
    39593959                    << action(UIActionIndexMN_M_Group_T_Pause)
    39603960                    << action(UIActionIndexMN_M_Group_S_Reset)
     3961                    // << action(UIActionIndexMN_M_Group_S_Detach)
    39613962                    << action(UIActionIndexMN_M_Group_S_Discard)
    39623963                    << action(UIActionIndexMN_M_Group_S_ShowLogDialog)
     
    39713972                    << action(UIActionIndexMN_M_Group_M_Console_S_DeleteConnection)
    39723973                    << action(UIActionIndexMN_M_Group_M_Console_S_ConfigureApplications)
    3973                     // << action(UIActionIndexMN_M_Group_M_Close_S_Detach)
    39743974                    << action(UIActionIndexMN_M_Group_M_Close_S_SaveState)
    39753975                    << action(UIActionIndexMN_M_Group_M_Close_S_Terminate)
     
    39953995                    << action(UIActionIndexMN_M_Machine_T_Pause)
    39963996                    << action(UIActionIndexMN_M_Machine_S_Reset)
     3997                    // << action(UIActionIndexMN_M_Machine_S_Detach)
    39973998                    << action(UIActionIndexMN_M_Machine_S_Discard)
    39983999                    << action(UIActionIndexMN_M_Machine_S_ShowLogDialog)
     
    40134014                    << action(UIActionIndexMN_M_Machine_M_Console_S_ConfigureApplications)
    40144015                    << action(UIActionIndexMN_M_Machine_M_Console_S_ShowLog)
    4015                     // << action(UIActionIndexMN_M_Machine_M_Close_S_Detach)
    40164016                    << action(UIActionIndexMN_M_Machine_M_Close_S_SaveState)
    40174017                    << action(UIActionIndexMN_M_Machine_M_Close_S_Terminate)
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.h

    r96407 r97277  
    7979    UIActionIndexMN_M_Group_T_Pause,
    8080    UIActionIndexMN_M_Group_S_Reset,
     81    UIActionIndexMN_M_Group_S_Detach,
    8182    UIActionIndexMN_M_Group_M_Console,
    8283    UIActionIndexMN_M_Group_M_Console_S_CreateConnection,
     
    8485    UIActionIndexMN_M_Group_M_Console_S_ConfigureApplications,
    8586    UIActionIndexMN_M_Group_M_Close,
    86     UIActionIndexMN_M_Group_M_Close_S_Detach,
    8787    UIActionIndexMN_M_Group_M_Close_S_SaveState,
    8888    UIActionIndexMN_M_Group_M_Close_S_Terminate,
     
    120120    UIActionIndexMN_M_Machine_T_Pause,
    121121    UIActionIndexMN_M_Machine_S_Reset,
     122    UIActionIndexMN_M_Machine_S_Detach,
    122123    UIActionIndexMN_M_Machine_M_Console,
    123124    UIActionIndexMN_M_Machine_M_Console_S_CreateConnection,
     
    130131    UIActionIndexMN_M_Machine_M_Console_S_ShowLog,
    131132    UIActionIndexMN_M_Machine_M_Close,
    132     UIActionIndexMN_M_Machine_M_Close_S_Detach,
    133133    UIActionIndexMN_M_Machine_M_Close_S_SaveState,
    134134    UIActionIndexMN_M_Machine_M_Close_S_Terminate,
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r97076 r97277  
    16851685    {
    16861686        /* Check if current item could be detached: */
    1687         if (!isActionEnabled(UIActionIndexMN_M_Machine_M_Close_S_Detach, QList<UIVirtualMachineItem*>() << pItem))
     1687        if (!isActionEnabled(UIActionIndexMN_M_Machine_S_Detach, QList<UIVirtualMachineItem*>() << pItem))
    16881688            continue;
    16891689
     
    22312231    connect(actionPool()->action(UIActionIndexMN_M_Group_S_Reset), &UIAction::triggered,
    22322232            this, &UIVirtualBoxManager::sltPerformResetMachine);
     2233    connect(actionPool()->action(UIActionIndexMN_M_Group_S_Detach), &UIAction::triggered,
     2234            this, &UIVirtualBoxManager::sltPerformDetachMachineUI);
    22332235    connect(actionPool()->action(UIActionIndexMN_M_Group_S_Discard), &UIAction::triggered,
    22342236            this, &UIVirtualBoxManager::sltPerformDiscardMachineState);
     
    22712273    connect(actionPool()->action(UIActionIndexMN_M_Machine_S_Reset), &UIAction::triggered,
    22722274            this, &UIVirtualBoxManager::sltPerformResetMachine);
     2275    connect(actionPool()->action(UIActionIndexMN_M_Machine_S_Detach), &UIAction::triggered,
     2276            this, &UIVirtualBoxManager::sltPerformDetachMachineUI);
    22732277    connect(actionPool()->action(UIActionIndexMN_M_Machine_S_Discard), &UIAction::triggered,
    22742278            this, &UIVirtualBoxManager::sltPerformDiscardMachineState);
     
    23312335
    23322336    /* 'Group/Close' menu connections: */
    2333     connect(actionPool()->action(UIActionIndexMN_M_Group_M_Close_S_Detach), &UIAction::triggered,
    2334             this, &UIVirtualBoxManager::sltPerformDetachMachineUI);
    23352337    connect(actionPool()->action(UIActionIndexMN_M_Group_M_Close_S_SaveState), &UIAction::triggered,
    23362338            this, &UIVirtualBoxManager::sltPerformSaveMachineState);
     
    23432345
    23442346    /* 'Machine/Close' menu connections: */
    2345     connect(actionPool()->action(UIActionIndexMN_M_Machine_M_Close_S_Detach), &UIAction::triggered,
    2346             this, &UIVirtualBoxManager::sltPerformDetachMachineUI);
    23472347    connect(actionPool()->action(UIActionIndexMN_M_Machine_M_Close_S_SaveState), &UIAction::triggered,
    23482348            this, &UIVirtualBoxManager::sltPerformSaveMachineState);
     
    28112811        pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Group_T_Pause));
    28122812        pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Group_S_Reset));
     2813        // pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Group_S_Detach));
    28132814        pMenu->addMenu(actionPool()->action(UIActionIndexMN_M_Group_M_Close)->menu());
    28142815        pMenu->addSeparator();
     
    28702871        pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Machine_T_Pause));
    28712872        pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Reset));
     2873        // pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Detach));
    28722874        pMenu->addMenu(actionPool()->action(UIActionIndexMN_M_Machine_M_Close)->menu());
    28732875        pMenu->addSeparator();
     
    29242926    if (pItem->itemType() == UIVirtualMachineItemType_Local)
    29252927    {
    2926         // pMenu->addAction(action(UIActionIndexMN_M_Group_M_Close_S_Detach));
    29272928        pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Group_M_Close_S_SaveState));
    29282929        pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Group_M_Close_S_Shutdown));
     
    30703071    if (pItem->itemType() == UIVirtualMachineItemType_Local)
    30713072    {
    3072         // pMenu->addAction(action(UIActionIndexMN_M_Machine_M_Close_S_Detach));
    30733073        pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_Close_S_SaveState));
    30743074        pMenu->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_Close_S_Shutdown));
     
    31683168    actionPool()->action(UIActionIndexMN_M_Group_T_Pause)->setEnabled(isActionEnabled(UIActionIndexMN_M_Group_T_Pause, items));
    31693169    actionPool()->action(UIActionIndexMN_M_Group_S_Reset)->setEnabled(isActionEnabled(UIActionIndexMN_M_Group_S_Reset, items));
     3170    actionPool()->action(UIActionIndexMN_M_Group_S_Detach)->setEnabled(isActionEnabled(UIActionIndexMN_M_Group_S_Detach, items));
    31703171    actionPool()->action(UIActionIndexMN_M_Group_S_Discard)->setEnabled(isActionEnabled(UIActionIndexMN_M_Group_S_Discard, items));
    31713172    actionPool()->action(UIActionIndexMN_M_Group_S_ShowLogDialog)->setEnabled(isActionEnabled(UIActionIndexMN_M_Group_S_ShowLogDialog, items));
     
    31873188    actionPool()->action(UIActionIndexMN_M_Machine_T_Pause)->setEnabled(isActionEnabled(UIActionIndexMN_M_Machine_T_Pause, items));
    31883189    actionPool()->action(UIActionIndexMN_M_Machine_S_Reset)->setEnabled(isActionEnabled(UIActionIndexMN_M_Machine_S_Reset, items));
     3190    actionPool()->action(UIActionIndexMN_M_Machine_S_Detach)->setEnabled(isActionEnabled(UIActionIndexMN_M_Machine_S_Detach, items));
    31893191    actionPool()->action(UIActionIndexMN_M_Machine_S_Discard)->setEnabled(isActionEnabled(UIActionIndexMN_M_Machine_S_Discard, items));
    31903192    actionPool()->action(UIActionIndexMN_M_Machine_S_ShowLogDialog)->setEnabled(isActionEnabled(UIActionIndexMN_M_Machine_S_ShowLogDialog, items));
     
    32253227    /* Enable/disable group-close actions: */
    32263228    actionPool()->action(UIActionIndexMN_M_Group_M_Close)->setEnabled(isActionEnabled(UIActionIndexMN_M_Group_M_Close, items));
    3227     actionPool()->action(UIActionIndexMN_M_Group_M_Close_S_Detach)->setEnabled(isActionEnabled(UIActionIndexMN_M_Group_M_Close_S_Detach, items));
    32283229    actionPool()->action(UIActionIndexMN_M_Group_M_Close_S_SaveState)->setEnabled(isActionEnabled(UIActionIndexMN_M_Group_M_Close_S_SaveState, items));
    32293230    actionPool()->action(UIActionIndexMN_M_Group_M_Close_S_Terminate)->setEnabled(isActionEnabled(UIActionIndexMN_M_Group_M_Close_S_Terminate, items));
     
    32333234    /* Enable/disable machine-close actions: */
    32343235    actionPool()->action(UIActionIndexMN_M_Machine_M_Close)->setEnabled(isActionEnabled(UIActionIndexMN_M_Machine_M_Close, items));
    3235     actionPool()->action(UIActionIndexMN_M_Machine_M_Close_S_Detach)->setEnabled(isActionEnabled(UIActionIndexMN_M_Machine_M_Close_S_Detach, items));
    32363236    actionPool()->action(UIActionIndexMN_M_Machine_M_Close_S_SaveState)->setEnabled(isActionEnabled(UIActionIndexMN_M_Machine_M_Close_S_SaveState, items));
    32373237    actionPool()->action(UIActionIndexMN_M_Machine_M_Close_S_Terminate)->setEnabled(isActionEnabled(UIActionIndexMN_M_Machine_M_Close_S_Terminate, items));
     
    34603460                   isAtLeastOneItemRunning(items);
    34613461        }
     3462        case UIActionIndexMN_M_Group_S_Detach:
     3463        case UIActionIndexMN_M_Machine_S_Detach:
     3464        {
     3465            return isItemsLocal(items) &&
     3466                   isAtLeastOneItemRunning(items) &&
     3467                   isAtLeastOneItemDetachable(items);
     3468        }
    34623469        case UIActionIndexMN_M_Group_S_Refresh:
    34633470        case UIActionIndexMN_M_Machine_S_Refresh:
     
    35033510                   || (isItemsCloud(items) && isAtLeastOneItemDiscardable(items));
    35043511        }
    3505         case UIActionIndexMN_M_Group_M_Close_S_Detach:
    3506         case UIActionIndexMN_M_Machine_M_Close_S_Detach:
    35073512        case UIActionIndexMN_M_Group_M_Close_S_SaveState:
    35083513        case UIActionIndexMN_M_Machine_M_Close_S_SaveState:
     
    37173722}
    37183723
     3724/* static */
     3725bool UIVirtualBoxManager::isAtLeastOneItemDetachable(const QList<UIVirtualMachineItem*> &items)
     3726{
     3727    foreach (UIVirtualMachineItem *pItem, items)
     3728        if (pItem->isItemRunningHeadless())
     3729            return true;
     3730    return false;
     3731}
     3732
    37193733#ifdef VBOX_WS_X11
    37203734/* static */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h

    r97076 r97277  
    461461        /** Returns whether at least one of passed @a items is running. */
    462462        static bool isAtLeastOneItemRunning(const QList<UIVirtualMachineItem*> &items);
     463        /** Returns whether at least one of passed @a items is detachable. */
     464        static bool isAtLeastOneItemDetachable(const QList<UIVirtualMachineItem*> &items);
    463465
    464466#ifdef VBOX_WS_X11
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp

    r96407 r97277  
    14991499        pMenuGroup->addAction(actionPool()->action(UIActionIndexMN_M_Group_T_Pause));
    15001500        pMenuGroup->addAction(actionPool()->action(UIActionIndexMN_M_Group_S_Reset));
     1501        // pMenuGroup->addAction(actionPool()->action(UIActionIndexMN_M_Group_S_Detach));
    15011502        pMenuGroup->addMenu(actionPool()->action(UIActionIndexMN_M_Group_M_Close)->menu());
    15021503        pMenuGroup->addSeparator();
     
    15261527        pMenuMachine->addAction(actionPool()->action(UIActionIndexMN_M_Machine_T_Pause));
    15271528        pMenuMachine->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Reset));
     1529        // pMenuMachine->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Detach));
    15281530        pMenuMachine->addMenu(actionPool()->action(UIActionIndexMN_M_Machine_M_Close)->menu());
    15291531        pMenuMachine->addSeparator();
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