VirtualBox

Changeset 99142 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 23, 2023 12:50:41 PM (22 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10322: Runtime UI: Rework for UIMachine prepare/cleanup cascade; Initialize branding and guest screen data last, these update procedures can be reused after VM restart.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r99141 r99142  
    14701470
    14711471    /* Prepare VM related stuff: */
    1472     prepareBranding();
    14731472    prepareActions();
    14741473    prepareHostScreenData();
    1475     prepareGuestScreenData();
    14761474    prepareKeyboard();
    14771475    prepareClose();
    14781476    prepareVisualState();
     1477
     1478    /* Update VM related stuff: */
     1479    updateBranding();
     1480    updateGuestScreenData();
    14791481    enterInitialVisualState();
    14801482
     
    15631565}
    15641566
    1565 void UIMachine::prepareBranding()
    1566 {
    1567     /* Create the icon dynamically: */
    1568     m_pMachineWindowIcon = new QIcon;
    1569     acquireUserMachineIcon(*m_pMachineWindowIcon);
    1570 
    1571 #ifndef VBOX_WS_MAC
    1572     /* Load user's machine-window name postfix: */
    1573     const QUuid uMachineID = uiCommon().managedVMUuid();
    1574     m_strMachineWindowNamePostfix = gEDataManager->machineWindowNamePostfix(uMachineID);
    1575 #endif /* !VBOX_WS_MAC */
    1576 }
    1577 
    15781567void UIMachine::prepareActions()
    15791568{
     
    16841673}
    16851674
    1686 void UIMachine::prepareGuestScreenData()
     1675void UIMachine::prepareKeyboard()
     1676{
     1677#if defined(VBOX_WS_MAC) || defined(VBOX_WS_WIN)
     1678    /* Load extra-data value: */
     1679    m_fIsHidLedsSyncEnabled = gEDataManager->hidLedsSyncState(uiCommon().managedVMUuid());
     1680    /* Connect to extra-data changes to be able to enable/disable feature dynamically: */
     1681    connect(gEDataManager, &UIExtraDataManager::sigHidLedsSyncStateChange,
     1682            this, &UIMachine::sltHidLedsSyncStateChanged);
     1683#endif /* VBOX_WS_MAC || VBOX_WS_WIN */
     1684}
     1685
     1686void UIMachine::prepareClose()
     1687{
     1688    /* What is the default close action and the restricted are? */
     1689    const QUuid uMachineID = uiCommon().managedVMUuid();
     1690    m_defaultCloseAction = gEDataManager->defaultMachineCloseAction(uMachineID);
     1691    m_restrictedCloseActions = gEDataManager->restrictedMachineCloseActions(uMachineID);
     1692}
     1693
     1694void UIMachine::prepareVisualState()
     1695{
     1696    /* Prepare async visual state type change handler: */
     1697    qRegisterMetaType<UIVisualStateType>();
     1698    connect(this, &UIMachine::sigRequestAsyncVisualStateChange,
     1699            this, &UIMachine::sltChangeVisualState,
     1700            Qt::QueuedConnection);
     1701
     1702    /* Load restricted visual states: */
     1703    UIVisualStateType enmRestrictedVisualStates = gEDataManager->restrictedVisualStates(uiCommon().managedVMUuid());
     1704    /* Acquire allowed visual states: */
     1705    m_enmAllowedVisualStates = static_cast<UIVisualStateType>(UIVisualStateType_All ^ enmRestrictedVisualStates);
     1706
     1707    /* Load requested visual state, it can override initial one: */
     1708    m_enmRequestedVisualState = gEDataManager->requestedVisualState(uiCommon().managedVMUuid());
     1709    /* Check if requested visual state is allowed: */
     1710    if (isVisualStateAllowed(m_enmRequestedVisualState))
     1711    {
     1712        switch (m_enmRequestedVisualState)
     1713        {
     1714            /* Direct transition allowed to scale/fullscreen modes only: */
     1715            case UIVisualStateType_Scale:
     1716            case UIVisualStateType_Fullscreen:
     1717                m_enmInitialVisualState = m_enmRequestedVisualState;
     1718                break;
     1719            default:
     1720                break;
     1721        }
     1722    }
     1723}
     1724
     1725void UIMachine::updateBranding()
     1726{
     1727    /* Create the icon dynamically: */
     1728    delete m_pMachineWindowIcon;
     1729    m_pMachineWindowIcon = new QIcon;
     1730    acquireUserMachineIcon(*m_pMachineWindowIcon);
     1731
     1732#ifndef VBOX_WS_MAC
     1733    /* Load user's machine-window name postfix: */
     1734    const QUuid uMachineID = uiCommon().managedVMUuid();
     1735    m_strMachineWindowNamePostfix = gEDataManager->machineWindowNamePostfix(uMachineID);
     1736#endif /* !VBOX_WS_MAC */
     1737}
     1738
     1739void UIMachine::updateGuestScreenData()
    16871740{
    16881741    /* Accquire guest-screen count: */
     
    17401793}
    17411794
    1742 void UIMachine::prepareKeyboard()
    1743 {
    1744 #if defined(VBOX_WS_MAC) || defined(VBOX_WS_WIN)
    1745     /* Load extra-data value: */
    1746     m_fIsHidLedsSyncEnabled = gEDataManager->hidLedsSyncState(uiCommon().managedVMUuid());
    1747     /* Connect to extra-data changes to be able to enable/disable feature dynamically: */
    1748     connect(gEDataManager, &UIExtraDataManager::sigHidLedsSyncStateChange,
    1749             this, &UIMachine::sltHidLedsSyncStateChanged);
    1750 #endif /* VBOX_WS_MAC || VBOX_WS_WIN */
    1751 }
    1752 
    1753 void UIMachine::prepareClose()
    1754 {
    1755     /* What is the default close action and the restricted are? */
    1756     const QUuid uMachineID = uiCommon().managedVMUuid();
    1757     m_defaultCloseAction = gEDataManager->defaultMachineCloseAction(uMachineID);
    1758     m_restrictedCloseActions = gEDataManager->restrictedMachineCloseActions(uMachineID);
    1759 }
    1760 
    1761 void UIMachine::prepareVisualState()
    1762 {
    1763     /* Prepare async visual state type change handler: */
    1764     qRegisterMetaType<UIVisualStateType>();
    1765     connect(this, &UIMachine::sigRequestAsyncVisualStateChange,
    1766             this, &UIMachine::sltChangeVisualState,
    1767             Qt::QueuedConnection);
    1768 
    1769     /* Load restricted visual states: */
    1770     UIVisualStateType enmRestrictedVisualStates = gEDataManager->restrictedVisualStates(uiCommon().managedVMUuid());
    1771     /* Acquire allowed visual states: */
    1772     m_enmAllowedVisualStates = static_cast<UIVisualStateType>(UIVisualStateType_All ^ enmRestrictedVisualStates);
    1773 
    1774     /* Load requested visual state, it can override initial one: */
    1775     m_enmRequestedVisualState = gEDataManager->requestedVisualState(uiCommon().managedVMUuid());
    1776     /* Check if requested visual state is allowed: */
    1777     if (isVisualStateAllowed(m_enmRequestedVisualState))
    1778     {
    1779         switch (m_enmRequestedVisualState)
    1780         {
    1781             /* Direct transition allowed to scale/fullscreen modes only: */
    1782             case UIVisualStateType_Scale:
    1783             case UIVisualStateType_Fullscreen:
    1784                 m_enmInitialVisualState = m_enmRequestedVisualState;
    1785                 break;
    1786             default:
    1787                 break;
    1788         }
    1789     }
    1790 }
    1791 
    17921795void UIMachine::enterInitialVisualState()
    17931796{
     
    17991802    /* Delete machine-logic if any: */
    18001803    UIMachineLogic::destroy(m_pMachineLogic);
     1804}
     1805
     1806void UIMachine::cleanupBranding()
     1807{
     1808    /* Cleanup machine-window icon: */
     1809    delete m_pMachineWindowIcon;
     1810    m_pMachineWindowIcon = 0;
    18011811}
    18021812
     
    18221832}
    18231833
    1824 void UIMachine::cleanupBranding()
    1825 {
    1826     /* Cleanup machine-window icon: */
    1827     delete m_pMachineWindowIcon;
    1828     m_pMachineWindowIcon = 0;
    1829 }
    1830 
    18311834void UIMachine::cleanupSession()
    18321835{
     
    18481851    /* Cleanup stuff: */
    18491852    cleanupMachineLogic();
     1853    cleanupBranding();
    18501854    cleanupHostScreenData();
    18511855    cleanupActions();
    1852     cleanupBranding();
    18531856    cleanupSession();
    18541857    cleanupNotificationCenter();
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r99141 r99142  
    846846    /** Prepare routine: Session stuff. */
    847847    bool prepareSession();
    848     /** Prepare routine: Branding. */
    849     void prepareBranding();
    850848    /** Prepare routine: Actions stuff. */
    851849    void prepareActions();
    852850    /** Prepare routine: Host-screen data stuff. */
    853851    void prepareHostScreenData();
    854     /** Prepare routine: Guest-screen data stuff. */
    855     void prepareGuestScreenData();
    856852    /** Prepare routine: Keyboard stuff. */
    857853    void prepareKeyboard();
     
    861857    void prepareVisualState();
    862858
     859    /** Update routine: Branding. */
     860    void updateBranding();
     861    /** Update routine: Guest screen data stuff. */
     862    void updateGuestScreenData();
     863
    863864    /** Moves VM to initial state. */
    864865    void enterInitialVisualState();
     
    866867    /** Cleanup routine: Machine-logic stuff. */
    867868    void cleanupMachineLogic();
     869    /** Cleanup routine: Branding. */
     870    void cleanupBranding();
    868871    /** Cleanup routine: Host-screen data stuff. */
    869872    void cleanupHostScreenData();
    870873    /** Cleanup routine: Actions stuff. */
    871874    void cleanupActions();
    872     /** Cleanup routine: Branding. */
    873     void cleanupBranding();
    874875    /** Cleanup routine: Session stuff. */
    875876    void cleanupSession();
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