VirtualBox

Changeset 66437 in vbox


Ignore:
Timestamp:
Apr 5, 2017 1:28:39 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: Machine settings: User Interface page: Proper loading, caching, saving.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsInterface.cpp

    r66345 r66437  
    162162    m_pCache->clear();
    163163
    164     /* Prepare interface data: */
    165     UIDataSettingsMachineInterface interfaceData;
    166 
    167     /* Cache interface data: */
    168     interfaceData.m_fStatusBarEnabled = gEDataManager->statusBarEnabled(m_machine.GetId());
    169     interfaceData.m_statusBarRestrictions = gEDataManager->restrictedStatusBarIndicators(m_machine.GetId());
    170     interfaceData.m_statusBarOrder = gEDataManager->statusBarIndicatorOrder(m_machine.GetId());
    171 #ifndef VBOX_WS_MAC
    172     interfaceData.m_fMenuBarEnabled = gEDataManager->menuBarEnabled(m_machine.GetId());
    173 #endif /* !VBOX_WS_MAC */
    174     interfaceData.m_restrictionsOfMenuBar = gEDataManager->restrictedRuntimeMenuTypes(m_machine.GetId());
    175     interfaceData.m_restrictionsOfMenuApplication = gEDataManager->restrictedRuntimeMenuApplicationActionTypes(m_machine.GetId());
    176     interfaceData.m_restrictionsOfMenuMachine = gEDataManager->restrictedRuntimeMenuMachineActionTypes(m_machine.GetId());
    177     interfaceData.m_restrictionsOfMenuView = gEDataManager->restrictedRuntimeMenuViewActionTypes(m_machine.GetId());
    178     interfaceData.m_restrictionsOfMenuInput = gEDataManager->restrictedRuntimeMenuInputActionTypes(m_machine.GetId());
    179     interfaceData.m_restrictionsOfMenuDevices = gEDataManager->restrictedRuntimeMenuDevicesActionTypes(m_machine.GetId());
    180 #ifdef VBOX_WITH_DEBUGGER_GUI
    181     interfaceData.m_restrictionsOfMenuDebug = gEDataManager->restrictedRuntimeMenuDebuggerActionTypes(m_machine.GetId());
    182 #endif /* VBOX_WITH_DEBUGGER_GUI */
    183 #ifdef VBOX_WS_MAC
    184     interfaceData.m_restrictionsOfMenuWindow = gEDataManager->restrictedRuntimeMenuWindowActionTypes(m_machine.GetId());
    185 #endif /* VBOX_WS_MAC */
    186     interfaceData.m_restrictionsOfMenuHelp = gEDataManager->restrictedRuntimeMenuHelpActionTypes(m_machine.GetId());
    187 #ifndef VBOX_WS_MAC
    188     interfaceData.m_fShowMiniToolBar = gEDataManager->miniToolbarEnabled(m_machine.GetId());
    189     interfaceData.m_fMiniToolBarAtTop = gEDataManager->miniToolbarAlignment(m_machine.GetId()) == Qt::AlignTop;
    190 #endif /* !VBOX_WS_MAC */
    191 
    192     /* Cache interface data: */
    193     m_pCache->cacheInitialData(interfaceData);
     164    /* Prepare old interface data: */
     165    UIDataSettingsMachineInterface oldInterfaceData;
     166
     167    /* Gather old interface data: */
     168    oldInterfaceData.m_fStatusBarEnabled = gEDataManager->statusBarEnabled(m_machine.GetId());
     169    oldInterfaceData.m_statusBarRestrictions = gEDataManager->restrictedStatusBarIndicators(m_machine.GetId());
     170    oldInterfaceData.m_statusBarOrder = gEDataManager->statusBarIndicatorOrder(m_machine.GetId());
     171#ifndef VBOX_WS_MAC
     172    oldInterfaceData.m_fMenuBarEnabled = gEDataManager->menuBarEnabled(m_machine.GetId());
     173#endif
     174    oldInterfaceData.m_restrictionsOfMenuBar = gEDataManager->restrictedRuntimeMenuTypes(m_machine.GetId());
     175    oldInterfaceData.m_restrictionsOfMenuApplication = gEDataManager->restrictedRuntimeMenuApplicationActionTypes(m_machine.GetId());
     176    oldInterfaceData.m_restrictionsOfMenuMachine = gEDataManager->restrictedRuntimeMenuMachineActionTypes(m_machine.GetId());
     177    oldInterfaceData.m_restrictionsOfMenuView = gEDataManager->restrictedRuntimeMenuViewActionTypes(m_machine.GetId());
     178    oldInterfaceData.m_restrictionsOfMenuInput = gEDataManager->restrictedRuntimeMenuInputActionTypes(m_machine.GetId());
     179    oldInterfaceData.m_restrictionsOfMenuDevices = gEDataManager->restrictedRuntimeMenuDevicesActionTypes(m_machine.GetId());
     180#ifdef VBOX_WITH_DEBUGGER_GUI
     181    oldInterfaceData.m_restrictionsOfMenuDebug = gEDataManager->restrictedRuntimeMenuDebuggerActionTypes(m_machine.GetId());
     182#endif
     183#ifdef VBOX_WS_MAC
     184    oldInterfaceData.m_restrictionsOfMenuWindow = gEDataManager->restrictedRuntimeMenuWindowActionTypes(m_machine.GetId());
     185#endif
     186    oldInterfaceData.m_restrictionsOfMenuHelp = gEDataManager->restrictedRuntimeMenuHelpActionTypes(m_machine.GetId());
     187#ifndef VBOX_WS_MAC
     188    oldInterfaceData.m_fShowMiniToolBar = gEDataManager->miniToolbarEnabled(m_machine.GetId());
     189    oldInterfaceData.m_fMiniToolBarAtTop = gEDataManager->miniToolbarAlignment(m_machine.GetId()) == Qt::AlignTop;
     190#endif
     191
     192    /* Cache old interface data: */
     193    m_pCache->cacheInitialData(oldInterfaceData);
    194194
    195195    /* Upload machine to data: */
     
    199199void UIMachineSettingsInterface::getFromCache()
    200200{
    201     /* Get interface data from cache: */
    202     const UIDataSettingsMachineInterface &interfaceData = m_pCache->base();
    203 
    204     /* Prepare interface data: */
    205     m_pStatusBarEditor->setStatusBarEnabled(interfaceData.m_fStatusBarEnabled);
    206     m_pStatusBarEditor->setStatusBarConfiguration(interfaceData.m_statusBarRestrictions,
    207                                                   interfaceData.m_statusBarOrder);
    208 #ifndef VBOX_WS_MAC
    209     m_pMenuBarEditor->setMenuBarEnabled(interfaceData.m_fMenuBarEnabled);
    210 #endif /* !VBOX_WS_MAC */
    211     m_pMenuBarEditor->setRestrictionsOfMenuBar(interfaceData.m_restrictionsOfMenuBar);
    212     m_pMenuBarEditor->setRestrictionsOfMenuApplication(interfaceData.m_restrictionsOfMenuApplication);
    213     m_pMenuBarEditor->setRestrictionsOfMenuMachine(interfaceData.m_restrictionsOfMenuMachine);
    214     m_pMenuBarEditor->setRestrictionsOfMenuView(interfaceData.m_restrictionsOfMenuView);
    215     m_pMenuBarEditor->setRestrictionsOfMenuInput(interfaceData.m_restrictionsOfMenuInput);
    216     m_pMenuBarEditor->setRestrictionsOfMenuDevices(interfaceData.m_restrictionsOfMenuDevices);
    217 #ifdef VBOX_WITH_DEBUGGER_GUI
    218     m_pMenuBarEditor->setRestrictionsOfMenuDebug(interfaceData.m_restrictionsOfMenuDebug);
    219 #endif /* VBOX_WITH_DEBUGGER_GUI */
    220 #ifdef VBOX_WS_MAC
    221     m_pMenuBarEditor->setRestrictionsOfMenuWindow(interfaceData.m_restrictionsOfMenuWindow);
    222 #endif /* VBOX_WS_MAC */
    223     m_pMenuBarEditor->setRestrictionsOfMenuHelp(interfaceData.m_restrictionsOfMenuHelp);
    224 #ifndef VBOX_WS_MAC
    225     m_pCheckBoxShowMiniToolBar->setChecked(interfaceData.m_fShowMiniToolBar);
    226     m_pComboToolBarAlignment->setChecked(interfaceData.m_fMiniToolBarAtTop);
    227 #endif /* !VBOX_WS_MAC */
     201    /* Get old interface data from the cache: */
     202    const UIDataSettingsMachineInterface &oldInterfaceData = m_pCache->base();
     203
     204    /* Load old interface data to the page: */
     205    m_pStatusBarEditor->setStatusBarEnabled(oldInterfaceData.m_fStatusBarEnabled);
     206    m_pStatusBarEditor->setStatusBarConfiguration(oldInterfaceData.m_statusBarRestrictions,
     207                                                  oldInterfaceData.m_statusBarOrder);
     208#ifndef VBOX_WS_MAC
     209    m_pMenuBarEditor->setMenuBarEnabled(oldInterfaceData.m_fMenuBarEnabled);
     210#endif
     211    m_pMenuBarEditor->setRestrictionsOfMenuBar(oldInterfaceData.m_restrictionsOfMenuBar);
     212    m_pMenuBarEditor->setRestrictionsOfMenuApplication(oldInterfaceData.m_restrictionsOfMenuApplication);
     213    m_pMenuBarEditor->setRestrictionsOfMenuMachine(oldInterfaceData.m_restrictionsOfMenuMachine);
     214    m_pMenuBarEditor->setRestrictionsOfMenuView(oldInterfaceData.m_restrictionsOfMenuView);
     215    m_pMenuBarEditor->setRestrictionsOfMenuInput(oldInterfaceData.m_restrictionsOfMenuInput);
     216    m_pMenuBarEditor->setRestrictionsOfMenuDevices(oldInterfaceData.m_restrictionsOfMenuDevices);
     217#ifdef VBOX_WITH_DEBUGGER_GUI
     218    m_pMenuBarEditor->setRestrictionsOfMenuDebug(oldInterfaceData.m_restrictionsOfMenuDebug);
     219#endif
     220#ifdef VBOX_WS_MAC
     221    m_pMenuBarEditor->setRestrictionsOfMenuWindow(oldInterfaceData.m_restrictionsOfMenuWindow);
     222#endif
     223    m_pMenuBarEditor->setRestrictionsOfMenuHelp(oldInterfaceData.m_restrictionsOfMenuHelp);
     224#ifndef VBOX_WS_MAC
     225    m_pCheckBoxShowMiniToolBar->setChecked(oldInterfaceData.m_fShowMiniToolBar);
     226    m_pComboToolBarAlignment->setChecked(oldInterfaceData.m_fMiniToolBarAtTop);
     227#endif
    228228
    229229    /* Polish page finally: */
     
    236236void UIMachineSettingsInterface::putToCache()
    237237{
    238     /* Prepare interface data: */
    239     UIDataSettingsMachineInterface interfaceData = m_pCache->base();
    240 
    241     /* Gather interface data from page: */
    242     interfaceData.m_fStatusBarEnabled = m_pStatusBarEditor->isStatusBarEnabled();
    243     interfaceData.m_statusBarRestrictions = m_pStatusBarEditor->statusBarIndicatorRestrictions();
    244     interfaceData.m_statusBarOrder = m_pStatusBarEditor->statusBarIndicatorOrder();
    245 #ifndef VBOX_WS_MAC
    246     interfaceData.m_fMenuBarEnabled = m_pMenuBarEditor->isMenuBarEnabled();
    247 #endif /* !VBOX_WS_MAC */
    248     interfaceData.m_restrictionsOfMenuBar = m_pMenuBarEditor->restrictionsOfMenuBar();
    249     interfaceData.m_restrictionsOfMenuApplication = m_pMenuBarEditor->restrictionsOfMenuApplication();
    250     interfaceData.m_restrictionsOfMenuMachine = m_pMenuBarEditor->restrictionsOfMenuMachine();
    251     interfaceData.m_restrictionsOfMenuView = m_pMenuBarEditor->restrictionsOfMenuView();
    252     interfaceData.m_restrictionsOfMenuInput = m_pMenuBarEditor->restrictionsOfMenuInput();
    253     interfaceData.m_restrictionsOfMenuDevices = m_pMenuBarEditor->restrictionsOfMenuDevices();
    254 #ifdef VBOX_WITH_DEBUGGER_GUI
    255     interfaceData.m_restrictionsOfMenuDebug = m_pMenuBarEditor->restrictionsOfMenuDebug();
    256 #endif /* VBOX_WITH_DEBUGGER_GUI */
    257 #ifdef VBOX_WS_MAC
    258     interfaceData.m_restrictionsOfMenuWindow = m_pMenuBarEditor->restrictionsOfMenuWindow();
    259 #endif /* VBOX_WS_MAC */
    260     interfaceData.m_restrictionsOfMenuHelp = m_pMenuBarEditor->restrictionsOfMenuHelp();
    261 #ifndef VBOX_WS_MAC
    262     interfaceData.m_fShowMiniToolBar = m_pCheckBoxShowMiniToolBar->isChecked();
    263     interfaceData.m_fMiniToolBarAtTop = m_pComboToolBarAlignment->isChecked();
    264 #endif /* !VBOX_WS_MAC */
    265 
    266     /* Cache interface data: */
    267     m_pCache->cacheCurrentData(interfaceData);
     238    /* Prepare new interface data: */
     239    UIDataSettingsMachineInterface newInterfaceData = m_pCache->base();
     240
     241    /* Gather new interface data from page: */
     242    newInterfaceData.m_fStatusBarEnabled = m_pStatusBarEditor->isStatusBarEnabled();
     243    newInterfaceData.m_statusBarRestrictions = m_pStatusBarEditor->statusBarIndicatorRestrictions();
     244    newInterfaceData.m_statusBarOrder = m_pStatusBarEditor->statusBarIndicatorOrder();
     245#ifndef VBOX_WS_MAC
     246    newInterfaceData.m_fMenuBarEnabled = m_pMenuBarEditor->isMenuBarEnabled();
     247#endif
     248    newInterfaceData.m_restrictionsOfMenuBar = m_pMenuBarEditor->restrictionsOfMenuBar();
     249    newInterfaceData.m_restrictionsOfMenuApplication = m_pMenuBarEditor->restrictionsOfMenuApplication();
     250    newInterfaceData.m_restrictionsOfMenuMachine = m_pMenuBarEditor->restrictionsOfMenuMachine();
     251    newInterfaceData.m_restrictionsOfMenuView = m_pMenuBarEditor->restrictionsOfMenuView();
     252    newInterfaceData.m_restrictionsOfMenuInput = m_pMenuBarEditor->restrictionsOfMenuInput();
     253    newInterfaceData.m_restrictionsOfMenuDevices = m_pMenuBarEditor->restrictionsOfMenuDevices();
     254#ifdef VBOX_WITH_DEBUGGER_GUI
     255    newInterfaceData.m_restrictionsOfMenuDebug = m_pMenuBarEditor->restrictionsOfMenuDebug();
     256#endif
     257#ifdef VBOX_WS_MAC
     258    newInterfaceData.m_restrictionsOfMenuWindow = m_pMenuBarEditor->restrictionsOfMenuWindow();
     259#endif
     260    newInterfaceData.m_restrictionsOfMenuHelp = m_pMenuBarEditor->restrictionsOfMenuHelp();
     261#ifndef VBOX_WS_MAC
     262    newInterfaceData.m_fShowMiniToolBar = m_pCheckBoxShowMiniToolBar->isChecked();
     263    newInterfaceData.m_fMiniToolBarAtTop = m_pComboToolBarAlignment->isChecked();
     264#endif
     265
     266    /* Cache new interface data: */
     267    m_pCache->cacheCurrentData(newInterfaceData);
    268268}
    269269
     
    276276    if (isMachineInValidMode() && m_pCache->wasChanged())
    277277    {
    278         /* Get interface data from cache: */
    279         const UIDataSettingsMachineInterface &interfaceData = m_pCache->data();
    280 
    281         /* Store interface data: */
    282         if (isMachineInValidMode())
    283         {
    284             gEDataManager->setStatusBarEnabled(interfaceData.m_fStatusBarEnabled, m_machine.GetId());
    285             gEDataManager->setRestrictedStatusBarIndicators(interfaceData.m_statusBarRestrictions, m_machine.GetId());
    286             gEDataManager->setStatusBarIndicatorOrder(interfaceData.m_statusBarOrder, m_machine.GetId());
    287 #ifndef VBOX_WS_MAC
    288             gEDataManager->setMenuBarEnabled(interfaceData.m_fMenuBarEnabled, m_machine.GetId());
    289 #endif /* !VBOX_WS_MAC */
    290             gEDataManager->setRestrictedRuntimeMenuTypes(interfaceData.m_restrictionsOfMenuBar, m_machine.GetId());
    291             gEDataManager->setRestrictedRuntimeMenuApplicationActionTypes(interfaceData.m_restrictionsOfMenuApplication, m_machine.GetId());
    292             gEDataManager->setRestrictedRuntimeMenuMachineActionTypes(interfaceData.m_restrictionsOfMenuMachine, m_machine.GetId());
    293             gEDataManager->setRestrictedRuntimeMenuViewActionTypes(interfaceData.m_restrictionsOfMenuView, m_machine.GetId());
    294             gEDataManager->setRestrictedRuntimeMenuInputActionTypes(interfaceData.m_restrictionsOfMenuInput, m_machine.GetId());
    295             gEDataManager->setRestrictedRuntimeMenuDevicesActionTypes(interfaceData.m_restrictionsOfMenuDevices, m_machine.GetId());
    296 #ifdef VBOX_WITH_DEBUGGER_GUI
    297             gEDataManager->setRestrictedRuntimeMenuDebuggerActionTypes(interfaceData.m_restrictionsOfMenuDebug, m_machine.GetId());
    298 #endif /* VBOX_WITH_DEBUGGER_GUI */
    299 #ifdef VBOX_WS_MAC
    300             gEDataManager->setRestrictedRuntimeMenuWindowActionTypes(interfaceData.m_restrictionsOfMenuWindow, m_machine.GetId());
    301 #endif /* VBOX_WS_MAC */
    302             gEDataManager->setRestrictedRuntimeMenuHelpActionTypes(interfaceData.m_restrictionsOfMenuHelp, m_machine.GetId());
    303 #ifndef VBOX_WS_MAC
    304             gEDataManager->setMiniToolbarEnabled(interfaceData.m_fShowMiniToolBar, m_machine.GetId());
    305             gEDataManager->setMiniToolbarAlignment(interfaceData.m_fMiniToolBarAtTop ? Qt::AlignTop : Qt::AlignBottom, m_machine.GetId());
    306 #endif /* !VBOX_WS_MAC */
    307         }
     278        /* Get old interface data from the cache: */
     279        const UIDataSettingsMachineInterface &oldInterfaceData = m_pCache->base();
     280        /* Get new interface data from the cache: */
     281        const UIDataSettingsMachineInterface &newInterfaceData = m_pCache->data();
     282
     283        /* Store whether status-bar is enabled: */
     284        if (newInterfaceData.m_fStatusBarEnabled != oldInterfaceData.m_fStatusBarEnabled)
     285            gEDataManager->setStatusBarEnabled(newInterfaceData.m_fStatusBarEnabled, m_machine.GetId());
     286        /* Store status-bar restrictions: */
     287        if (newInterfaceData.m_statusBarRestrictions != oldInterfaceData.m_statusBarRestrictions)
     288            gEDataManager->setRestrictedStatusBarIndicators(newInterfaceData.m_statusBarRestrictions, m_machine.GetId());
     289        /* Store status-bar order: */
     290        if (newInterfaceData.m_statusBarOrder != oldInterfaceData.m_statusBarOrder)
     291            gEDataManager->setStatusBarIndicatorOrder(newInterfaceData.m_statusBarOrder, m_machine.GetId());
     292#ifndef VBOX_WS_MAC
     293        /* Store whether menu-bar is enabled: */
     294        if (newInterfaceData.m_fMenuBarEnabled != oldInterfaceData.m_fMenuBarEnabled)
     295            gEDataManager->setMenuBarEnabled(newInterfaceData.m_fMenuBarEnabled, m_machine.GetId());
     296#endif
     297        /* Store menu-bar restrictions: */
     298        if (newInterfaceData.m_restrictionsOfMenuBar != oldInterfaceData.m_restrictionsOfMenuBar)
     299            gEDataManager->setRestrictedRuntimeMenuTypes(newInterfaceData.m_restrictionsOfMenuBar, m_machine.GetId());
     300        /* Store menu-bar Application menu restrictions: */
     301        if (newInterfaceData.m_restrictionsOfMenuApplication != oldInterfaceData.m_restrictionsOfMenuApplication)
     302            gEDataManager->setRestrictedRuntimeMenuApplicationActionTypes(newInterfaceData.m_restrictionsOfMenuApplication, m_machine.GetId());
     303        /* Store menu-bar Machine menu restrictions: */
     304        if (newInterfaceData.m_restrictionsOfMenuMachine != oldInterfaceData.m_restrictionsOfMenuMachine)
     305            gEDataManager->setRestrictedRuntimeMenuMachineActionTypes(newInterfaceData.m_restrictionsOfMenuMachine, m_machine.GetId());
     306        /* Store menu-bar View menu restrictions: */
     307        if (newInterfaceData.m_restrictionsOfMenuView != oldInterfaceData.m_restrictionsOfMenuView)
     308            gEDataManager->setRestrictedRuntimeMenuViewActionTypes(newInterfaceData.m_restrictionsOfMenuView, m_machine.GetId());
     309        /* Store menu-bar Input menu restrictions: */
     310        if (newInterfaceData.m_restrictionsOfMenuInput != oldInterfaceData.m_restrictionsOfMenuInput)
     311            gEDataManager->setRestrictedRuntimeMenuInputActionTypes(newInterfaceData.m_restrictionsOfMenuInput, m_machine.GetId());
     312        /* Store menu-bar Devices menu restrictions: */
     313        if (newInterfaceData.m_restrictionsOfMenuDevices != oldInterfaceData.m_restrictionsOfMenuDevices)
     314            gEDataManager->setRestrictedRuntimeMenuDevicesActionTypes(newInterfaceData.m_restrictionsOfMenuDevices, m_machine.GetId());
     315#ifdef VBOX_WITH_DEBUGGER_GUI
     316        /* Store menu-bar Debug menu restrictions: */
     317        if (newInterfaceData.m_restrictionsOfMenuDebug != oldInterfaceData.m_restrictionsOfMenuDebug)
     318            gEDataManager->setRestrictedRuntimeMenuDebuggerActionTypes(newInterfaceData.m_restrictionsOfMenuDebug, m_machine.GetId());
     319#endif
     320#ifdef VBOX_WS_MAC
     321        /* Store menu-bar Window menu restrictions: */
     322        if (newInterfaceData.m_restrictionsOfMenuWindow != oldInterfaceData.m_restrictionsOfMenuWindow)
     323            gEDataManager->setRestrictedRuntimeMenuWindowActionTypes(newInterfaceData.m_restrictionsOfMenuWindow, m_machine.GetId());
     324#endif
     325        /* Store menu-bar Help menu restrictions: */
     326        if (newInterfaceData.m_restrictionsOfMenuHelp != oldInterfaceData.m_restrictionsOfMenuHelp)
     327            gEDataManager->setRestrictedRuntimeMenuHelpActionTypes(newInterfaceData.m_restrictionsOfMenuHelp, m_machine.GetId());
     328#ifndef VBOX_WS_MAC
     329        /* Store whether mini-toolbar is enabled: */
     330        if (newInterfaceData.m_fShowMiniToolBar != oldInterfaceData.m_fShowMiniToolBar)
     331            gEDataManager->setMiniToolbarEnabled(newInterfaceData.m_fShowMiniToolBar, m_machine.GetId());
     332        /* Store whether mini-toolbar should be location at top of screen: */
     333        if (newInterfaceData.m_fMiniToolBarAtTop != oldInterfaceData.m_fMiniToolBarAtTop)
     334            gEDataManager->setMiniToolbarAlignment(newInterfaceData.m_fMiniToolBarAtTop ? Qt::AlignTop : Qt::AlignBottom, m_machine.GetId());
     335#endif
    308336    }
    309337
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