VirtualBox

Changeset 108277 in vbox


Ignore:
Timestamp:
Feb 18, 2025 12:56:35 PM (3 weeks ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167605
Message:

FE/Qt: bugref:10814: VBox Manager / Tool-pane: Support for simultaneously having global and machine current tools/items selected; Items will be added / layed out in later commits.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIGlobalToolsManagerWidget.cpp

    r108272 r108277  
    7676{
    7777    AssertPtrReturn(toolMenu(), UIToolType_Invalid);
    78     return toolMenu()->toolsType();
     78    return toolMenu()->toolsType(UIToolClass_Global);
    7979}
    8080
     
    180180    /* On any VM registered switch from Home to Machines: */
    181181    AssertPtrReturnVoid(toolMenu());
    182     if (fRegistered && toolMenu()->toolsType() == UIToolType_Home)
     182    if (fRegistered && toolMenu()->toolsType(UIToolClass_Global) == UIToolType_Home)
    183183        setMenuToolType(UIToolType_Machines);
    184184}
     
    288288{
    289289    /* Open tool last chosen in tools-menu: */
    290     switchToolTo(toolMenu()->toolsType());
     290    switchToolTo(toolMenu()->toolsType(UIToolClass_Global));
    291291
    292292    /* Update tools restrictions: */
     
    346346
    347347    /* Make sure no restricted tool is selected: */
    348     if (restrictedTypes.contains(toolMenu()->toolsType()))
     348    if (restrictedTypes.contains(toolMenu()->toolsType(UIToolClass_Global)))
    349349        setMenuToolType(UIToolType_Home);
    350350
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIMachineToolsManagerWidget.cpp

    r108173 r108277  
    139139{
    140140    AssertPtrReturn(toolMenu(), UIToolType_Invalid);
    141     return toolMenu()->toolsType();
     141    return toolMenu()->toolsType(UIToolClass_Machine);
    142142}
    143143
     
    310310        /* If Error-pane is chosen currently => switch to tool currently chosen in tools-menu: */
    311311        if (toolPane()->currentTool() == UIToolType_Error)
    312             switchToolTo(toolMenu()->toolsType());
     312            switchToolTo(toolMenu()->toolsType(UIToolClass_Machine));
    313313
    314314        /* If we still have same item selected: */
     
    496496
    497497    /* Open tool last chosen in tools-menu: */
    498     switchToolTo(toolMenu()->toolsType());
     498    switchToolTo(toolMenu()->toolsType(UIToolClass_Machine));
    499499}
    500500
     
    554554        /* If Error-pane is chosen currently => switch to tool currently chosen in tools-menu: */
    555555        if (toolPane()->currentTool() == UIToolType_Error)
    556             switchToolTo(toolMenu()->toolsType());
     556            switchToolTo(toolMenu()->toolsType(UIToolClass_Machine));
    557557
    558558        /* Propagate current items to the Tools pane: */
     
    586586                        << UIToolType_Logs
    587587                        << UIToolType_FileManager;
    588     if (restrictedTypes.contains(toolMenu()->toolsType()))
     588    if (restrictedTypes.contains(toolMenu()->toolsType(UIToolClass_Machine)))
    589589        toolMenu()->setToolsType(UIToolType_Details);
    590590    const QList restrictions(restrictedTypes.begin(), restrictedTypes.end());
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UITools.cpp

    r108214 r108277  
    6363}
    6464
    65 UIToolType UITools::toolsType() const
     65UIToolType UITools::toolsType(UIToolClass enmClass) const
    6666{
    67     return m_pToolsModel->toolsType();
     67    return m_pToolsModel->toolsType(enmClass);
    6868}
    6969
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UITools.h

    r108214 r108277  
    7575        /** Defines current tools @a enmType. */
    7676        void setToolsType(UIToolType enmType);
    77         /** Returns current tools type. */
    78         UIToolType toolsType() const;
     77        /** Returns current tools type for the @a enmClass specified. */
     78        UIToolType toolsType(UIToolClass enmClass) const;
    7979
    8080        /** Defines whether tool items @a fEnabled. */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsItem.cpp

    r108213 r108277  
    164164
    165165        /* Compose the state of current item: */
    166         if (item() && item() == item()->model()->currentItem())
     166        if (item() && item() == item()->model()->currentItem(item()->itemClass()))
    167167        {
    168168            state.active = true;
     
    545545{
    546546    /* If that item is current: */
    547     if (model()->currentItem() == this)
     547    if (model()->currentItem(itemClass()) == this)
    548548    {
    549549        /* Unset the current item: */
     
    625625    {
    626626        /* Selection background: */
    627         if (model()->currentItem() == this)
     627        if (model()->currentItem(itemClass()) == this)
    628628        {
    629629            /* Prepare color: */
     
    720720    {
    721721        /* Selection background: */
    722         if (model()->currentItem() == this)
     722        if (model()->currentItem(itemClass()) == this)
    723723        {
    724724            /* Acquire token color: */
     
    823823
    824824    /* Selection frame: */
    825     if (model()->currentItem() == this)
     825    if (model()->currentItem(itemClass()) == this)
    826826        strokeColor = pal.color(QPalette::Active, QPalette::Highlight).lighter(m_iHighlightLightnessStart - 40);
    827827    /* Hovering frame: */
     
    857857    /* Selected or hovered item foreground for popup mode: */
    858858    if (   model()->isPopup()
    859         && (model()->currentItem() == this || isHovered()))
     859        && (model()->currentItem(itemClass()) == this || isHovered()))
    860860    {
    861861        /* Get background color: */
    862862        const QColor highlight = pal.color(QPalette::Active, QPalette::Highlight);
    863         const QColor background = model()->currentItem() == this
     863        const QColor background = model()->currentItem(itemClass()) == this
    864864                                ? highlight.lighter(m_iHighlightLightnessStart)
    865865                                : highlight.lighter(m_iHoverLightnessStart);
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsModel.cpp

    r108276 r108277  
    108108void UIToolsModel::setToolsType(UIToolType enmType)
    109109{
    110     if (!currentItem() || currentItem()->itemType() != enmType)
     110    const UIToolClass enmClass = UIToolStuff::castTypeToClass(enmType);
     111    if (!currentItem(enmClass) || currentItem(enmClass)->itemType() != enmType)
    111112        setCurrentItem(item(enmType));
    112113}
    113114
    114 UIToolType UIToolsModel::toolsType() const
    115 {
    116     return currentItem() ? currentItem()->itemType() : UIToolType_Invalid;
     115UIToolType UIToolsModel::toolsType(UIToolClass enmClass) const
     116{
     117    return currentItem(enmClass) ? currentItem(enmClass)->itemType() : UIToolType_Invalid;
    117118}
    118119
     
    160161void UIToolsModel::setCurrentItem(UIToolsItem *pItem)
    161162{
    162     /* Is there something changed? */
    163     if (m_pCurrentItem == pItem)
    164         return;
    165 
    166     /* Remember old current-item: */
    167     UIToolsItem *pOldCurrentItem = m_pCurrentItem;
    168 
    169     /* Update current item: */
    170     m_pCurrentItem = pItem;
    171 
    172     /* Update old item (if any): */
    173     if (pOldCurrentItem)
    174         pOldCurrentItem->update();
    175     /* Update new item (if any): */
    176     if (m_pCurrentItem)
    177         m_pCurrentItem->update();
    178 
    179     /* Notify about selection change: */
    180     emit sigSelectionChanged(toolsType());
    181 }
    182 
    183 UIToolsItem *UIToolsModel::currentItem() const
    184 {
    185     return m_pCurrentItem;
     163    /* Valid item passed? */
     164    if (pItem)
     165    {
     166        /* What's the item class? */
     167        const UIToolClass enmClass = pItem->itemClass();
     168
     169        /* Is there something changed? */
     170        if (m_mapCurrentItems.value(enmClass) == pItem)
     171            return;
     172
     173        /* Remember old current-item: */
     174        UIToolsItem *pOldCurrentItem = m_mapCurrentItems.value(enmClass);
     175        /* Set new item as current: */
     176        m_mapCurrentItems[enmClass] = pItem;
     177
     178        /* Update old item (if any): */
     179        if (pOldCurrentItem)
     180            pOldCurrentItem->update();
     181        /* Update new item: */
     182        m_mapCurrentItems.value(enmClass)->update();
     183
     184        /* Notify about selection change: */
     185        emit sigSelectionChanged(toolsType(enmClass));
     186    }
     187    /* Null item passed? */
     188    else
     189    {
     190        /* Is there something changed? */
     191        if (   !m_mapCurrentItems.value(UIToolClass_Global)
     192            && !m_mapCurrentItems.value(UIToolClass_Machine))
     193            return;
     194
     195        /* Clear all current items: */
     196        m_mapCurrentItems[UIToolClass_Global] = 0;
     197        m_mapCurrentItems[UIToolClass_Machine] = 0;
     198
     199        /* Notify about selection change: */
     200        emit sigSelectionChanged(UIToolType_Invalid);
     201    }
     202}
     203
     204UIToolsItem *UIToolsModel::currentItem(UIToolClass enmClass) const
     205{
     206    return m_mapCurrentItems.value(enmClass);
    186207}
    187208
     
    541562
    542563    /* Assign values depending on model class: */
    543     if (m_enmClass == UIToolClass_Global)
     564    if (   m_enmClass == UIToolClass_Global
     565        || m_enmClass == UIToolClass_Invalid)
    544566    {
    545567        UIToolsItem *pItem = item(enmTypeGlobal);
     
    548570        setCurrentItem(pItem);
    549571    }
    550     else if (m_enmClass == UIToolClass_Machine)
     572    if (   m_enmClass == UIToolClass_Machine
     573        || m_enmClass == UIToolClass_Invalid)
    551574    {
    552575        UIToolsItem *pItem = item(enmTypeMachine);
     
    564587
    565588    /* Update values depending on model class: */
    566     if (currentItem())
    567     {
    568         if (m_enmClass == UIToolClass_Global)
    569             enmTypeGlobal = currentItem()->itemType();
    570         else if (m_enmClass == UIToolClass_Machine)
    571             enmTypeMachine = currentItem()->itemType();
     589    if (   m_enmClass == UIToolClass_Global
     590        || m_enmClass == UIToolClass_Invalid)
     591    {
     592        if (UIToolsItem *pItem = currentItem(UIToolClass_Global))
     593            enmTypeGlobal = pItem->itemType();
     594    }
     595    if (   m_enmClass == UIToolClass_Machine
     596        || m_enmClass == UIToolClass_Invalid)
     597    {
     598        if (UIToolsItem *pItem = currentItem(UIToolClass_Machine))
     599            enmTypeMachine = pItem->itemType();
    572600    }
    573601
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsModel.h

    r108266 r108277  
    111111        /** Defines current tools @a enmType. */
    112112        void setToolsType(UIToolType enmType);
    113         /** Returns current tools type. */
    114         UIToolType toolsType() const;
     113        /** Returns current tools type for the @a enmClass specified. */
     114        UIToolType toolsType(UIToolClass enmClass) const;
    115115
    116116        /** Defines whether tool items @a fEnabled.*/
     
    144144        /** Defines current @a pItem. */
    145145        void setCurrentItem(UIToolsItem *pItem);
    146         /** Returns current item. */
    147         UIToolsItem *currentItem() const;
     146        /** Returns current item for the @a enmClass specified. */
     147        UIToolsItem *currentItem(UIToolClass enmClass) const;
    148148    /** @} */
    149149
     
    267267    /** @name Selection stuff.
    268268      * @{ */
    269         /** Holds the selected item reference. */
    270         QPointer<UIToolsItem>  m_pCurrentItem;
     269        /** Holds the selected item map reference. */
     270        QMap<UIToolClass, QPointer<UIToolsItem> >  m_mapCurrentItems;
    271271    /** @} */
    272272
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