VirtualBox

Changeset 108266 in vbox


Ignore:
Timestamp:
Feb 17, 2025 8:11:25 PM (3 weeks ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167591
Message:

FE/Qt: bugref:10814: VBox Manager / Tool-pane: Rework for loading/saving current global/machine tool types; A bit of corresponding rework in prepare/cleanup cascade.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r108193 r108266  
    28732873}
    28742874
    2875 QList<UIToolType> UIExtraDataManager::toolsPaneLastItemsChosen()
     2875void UIExtraDataManager::toolsPaneLastItemsChosen(UIToolType &enmTypeGlobal, UIToolType &enmTypeMachine)
    28762876{
    28772877    /* Parse loaded data: */
     
    28842884    }
    28852885
    2886     /* Return result: */
    2887     return result;
    2888 }
    2889 
    2890 void UIExtraDataManager::setToolsPaneLastItemsChosen(const QList<UIToolType> &set)
     2886    /* Assign values: */
     2887    enmTypeGlobal = result.value(0);
     2888    if (!UIToolStuff::isTypeOfClass(enmTypeGlobal, UIToolClass_Global))
     2889        enmTypeGlobal = UIToolType_Home;
     2890    enmTypeMachine = result.value(1);
     2891    if (!UIToolStuff::isTypeOfClass(enmTypeMachine, UIToolClass_Machine))
     2892        enmTypeMachine = UIToolType_Details;
     2893}
     2894
     2895void UIExtraDataManager::setToolsPaneLastItemsChosen(UIToolType enmTypeGlobal, UIToolType enmTypeMachine)
    28912896{
    28922897    /* Serialize passed values: */
     2898    const QList<UIToolType> currentTypes = QList<UIToolType>() << enmTypeGlobal << enmTypeMachine;
    28932899    QStringList data;
    2894     foreach (const UIToolType &enmType, set)
     2900    foreach (const UIToolType &enmType, currentTypes)
    28952901        data << gpConverter->toInternalString(enmType);
    28962902
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r108193 r108266  
    400400
    401401        /** Returns last selected tool set of VirtualBox Manager. */
    402         QList<UIToolType> toolsPaneLastItemsChosen();
     402        void toolsPaneLastItemsChosen(UIToolType &enmTypeGlobal, UIToolType &enmTypeMachine);
    403403        /** Defines last selected tool @a set of VirtualBox Manager. */
    404         void setToolsPaneLastItemsChosen(const QList<UIToolType> &set);
     404        void setToolsPaneLastItemsChosen(UIToolType enmTypeGlobal, UIToolType enmTypeMachine);
    405405        /** Returns the list of detached tools of VirtualBox Manager. */
    406406        QList<UIToolType> detachedTools();
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsModel.cpp

    r108225 r108266  
    3535/* GUI includes: */
    3636#include "UIActionPoolManager.h"
     37#include "UICommon.h"
    3738#include "UIExtraDataManager.h"
    3839#include "UIIconPool.h"
     
    7475    sltItemMinimumHeightHintChanged();
    7576
    76     /* Load settings: */
    77     loadSettings();
     77    /* Load current items finally: */
     78    loadCurrentItems();
    7879}
    7980
     
    166167    UIToolsItem *pOldCurrentItem = m_pCurrentItem;
    167168
    168     /* If there is item: */
    169     if (pItem)
    170     {
    171         /* Set this item as current: */
    172         m_pCurrentItem = pItem;
    173 
    174         /* Load last tool types: */
    175         UIToolType enmTypeGlobal, enmTypeMachine;
    176         loadLastToolTypes(enmTypeGlobal, enmTypeMachine);
    177 
    178         /* Depending on tool class: */
    179         switch (m_enmClass)
    180         {
    181             case UIToolClass_Global: enmTypeGlobal = m_pCurrentItem->itemType(); break;
    182             case UIToolClass_Machine: enmTypeMachine = m_pCurrentItem->itemType(); break;
    183             default: break;
    184         }
    185 
    186         /* Save selected items data: */
    187         const QList<UIToolType> currentTypes = QList<UIToolType>() << enmTypeGlobal << enmTypeMachine;
    188         LogRel2(("GUI: UIToolsModel: Saving tool items as: Global=%d, Machine=%d\n",
    189                  (int)enmTypeGlobal, (int)enmTypeMachine));
    190         gEDataManager->setToolsPaneLastItemsChosen(currentTypes);
    191     }
    192     /* Otherwise reset current item: */
    193     else
    194         m_pCurrentItem = 0;
     169    /* Update current item: */
     170    m_pCurrentItem = pItem;
    195171
    196172    /* Update old item (if any): */
     
    431407}
    432408
     409void UIToolsModel::sltHandleCommitData()
     410{
     411    /* Save current items first of all: */
     412    saveCurrentItems();
     413}
     414
    433415void UIToolsModel::sltRetranslateUI()
    434416{
     
    558540void UIToolsModel::prepareConnections()
    559541{
     542    /* UICommon connections: */
     543    connect(&uiCommon(), &UICommon::sigAskToCommitData,
     544            this, &UIToolsModel::sltHandleCommitData);
     545
    560546    /* Translation stuff: */
    561547    connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI,
     
    563549}
    564550
    565 void UIToolsModel::loadSettings()
     551void UIToolsModel::loadCurrentItems()
    566552{
    567553    /* Load last tool types: */
    568554    UIToolType enmTypeGlobal, enmTypeMachine;
    569     loadLastToolTypes(enmTypeGlobal, enmTypeMachine);
    570 
    571     /* Depending on tool class: */
    572     UIToolsItem *pCurrentItem = 0;
    573     switch (m_enmClass)
    574     {
    575         case UIToolClass_Global:
    576         {
    577             foreach (UIToolsItem *pItem, items())
    578                 if (pItem->itemType() == enmTypeGlobal)
    579                     pCurrentItem = pItem;
    580             if (!pCurrentItem)
    581                 pCurrentItem = item(UIToolType_Home);
    582             break;
    583         }
    584         case UIToolClass_Machine:
    585         {
    586             foreach (UIToolsItem *pItem, items())
    587                 if (pItem->itemType() == enmTypeMachine)
    588                     pCurrentItem = pItem;
    589             if (!pCurrentItem)
    590                 pCurrentItem = item(UIToolType_Details);
    591             break;
    592         }
    593         default:
    594             break;
    595     }
    596     setCurrentItem(pCurrentItem);
    597 }
    598 
    599 /* static */
    600 void UIToolsModel::loadLastToolTypes(UIToolType &enmTypeGlobal, UIToolType &enmTypeMachine)
    601 {
    602     /* Load selected items data: */
    603     const QList<UIToolType> data = gEDataManager->toolsPaneLastItemsChosen();
    604     enmTypeGlobal = data.value(0);
    605     if (!UIToolStuff::isTypeOfClass(enmTypeGlobal, UIToolClass_Global))
    606         enmTypeGlobal = UIToolType_Home;
    607     enmTypeMachine = data.value(1);
    608     if (!UIToolStuff::isTypeOfClass(enmTypeMachine, UIToolClass_Machine))
    609         enmTypeMachine = UIToolType_Details;
     555    gEDataManager->toolsPaneLastItemsChosen(enmTypeGlobal, enmTypeMachine);
    610556    LogRel2(("GUI: UIToolsModel: Restoring tool items as: Global=%d, Machine=%d\n",
    611557             (int)enmTypeGlobal, (int)enmTypeMachine));
     558
     559    /* Assign values depending on model class: */
     560    if (m_enmClass == UIToolClass_Global)
     561    {
     562        UIToolsItem *pItem = item(enmTypeGlobal);
     563        if (!pItem)
     564            pItem = item(UIToolType_Home);
     565        setCurrentItem(pItem);
     566    }
     567    else if (m_enmClass == UIToolClass_Machine)
     568    {
     569        UIToolsItem *pItem = item(enmTypeMachine);
     570        if (!pItem)
     571            pItem = item(UIToolType_Details);
     572        setCurrentItem(pItem);
     573    }
     574}
     575
     576void UIToolsModel::saveCurrentItems()
     577{
     578    /* Load last tool types: */
     579    UIToolType enmTypeGlobal, enmTypeMachine;
     580    gEDataManager->toolsPaneLastItemsChosen(enmTypeGlobal, enmTypeMachine);
     581
     582    /* Update values depending on model class: */
     583    if (m_pCurrentItem)
     584    {
     585        if (m_enmClass == UIToolClass_Global)
     586            enmTypeGlobal = m_pCurrentItem->itemType();
     587        else if (m_enmClass == UIToolClass_Machine)
     588            enmTypeMachine = m_pCurrentItem->itemType();
     589    }
     590
     591    /* Save selected items data: */
     592    LogRel2(("GUI: UIToolsModel: Saving tool items as: Global=%d, Machine=%d\n",
     593             (int)enmTypeGlobal, (int)enmTypeMachine));
     594    gEDataManager->setToolsPaneLastItemsChosen(enmTypeGlobal, enmTypeMachine);
    612595}
    613596
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsModel.h

    r108214 r108266  
    186186    /** @name Event handling stuff.
    187187     * @{ */
    188        /** Handles translation event. */
    189        void sltRetranslateUI();
     188        /** Handles request to commit data. */
     189        void sltHandleCommitData();
     190
     191        /** Handles translation event. */
     192        void sltRetranslateUI();
    190193    /** @} */
    191194
     
    210213        /** Prepare connections. */
    211214        void prepareConnections();
    212         /** Loads settings. */
    213         void loadSettings();
    214 
    215         /** Loads last tool types. */
    216         static void loadLastToolTypes(UIToolType &enmTypeGlobal, UIToolType &enmTypeMachine);
     215
     216        /** Loads current items from extra-data. */
     217        void loadCurrentItems();
     218        /** Saves current items to extra-data. */
     219        void saveCurrentItems();
    217220
    218221        /** Cleanups items. */
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