VirtualBox

Changeset 52998 in vbox


Ignore:
Timestamp:
Oct 8, 2014 4:17:50 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
96458
Message:

FE/Qt: Runtime UI rework/cleanup for 7115 (part #7): Small UIConsoleEventHandler rework/cleanup.

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

Legend:

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

    r52898 r52998  
    3737
    3838/* static */
    39 UIConsoleEventHandler *UIConsoleEventHandler::m_pInstance = 0;
     39UIConsoleEventHandler *UIConsoleEventHandler::m_spInstance = 0;
    4040
    4141/* static */
    42 UIConsoleEventHandler* UIConsoleEventHandler::instance(UISession *pSession /* = 0 */)
    43 {
    44     if (!m_pInstance)
     42void UIConsoleEventHandler::create(UISession *pSession)
     43{
     44    if (!m_spInstance)
    4545    {
    46         m_pInstance = new UIConsoleEventHandler(pSession);
    47         m_pInstance->prepare();
     46        m_spInstance = new UIConsoleEventHandler(pSession);
     47        m_spInstance->prepare();
    4848    }
    49     return m_pInstance;
    5049}
    5150
     
    5352void UIConsoleEventHandler::destroy()
    5453{
    55     if (m_pInstance)
     54    if (m_spInstance)
    5655    {
    57         m_pInstance->cleanup();
    58         delete m_pInstance;
    59         m_pInstance = 0;
     56        m_spInstance->cleanup();
     57        delete m_spInstance;
     58        m_spInstance = 0;
    6059    }
    6160}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIConsoleEventHandler.h

    r52898 r52998  
    7373public:
    7474
    75     /** Static instance factory. */
    76     static UIConsoleEventHandler* instance(UISession *pSession = 0);
     75    /** Static instance wrapper. */
     76    static UIConsoleEventHandler* instance() { return m_spInstance; }
     77    /** Static instance constructor. */
     78    static void create(UISession *pSession);
    7779    /** Static instance destructor. */
    7880    static void destroy();
     
    9698
    9799    /** Holds the static instance. */
    98     static UIConsoleEventHandler *m_pInstance;
     100    static UIConsoleEventHandler *m_spInstance;
    99101
    100102    /** Holds the UI session reference. */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r52991 r52998  
    968968void UISession::prepareConsoleEventHandlers()
    969969{
    970     /* Initialize console event-handler: */
    971     UIConsoleEventHandler::instance(this);
     970    /* Create console event-handler: */
     971    UIConsoleEventHandler::create(this);
    972972
    973973    /* Add console event connections: */
     
    10291029    m_pActionPool->toRuntime()->setSession(this);
    10301030
    1031     /* Get host/machine: */
    1032     const CHost host = vboxGlobal().host();
    1033     const CMachine machine = session().GetConsole().GetMachine();
    1034     UIExtraDataMetaDefs::RuntimeMenuDevicesActionType restriction = UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Invalid;
    1035 
    1036     /* Storage stuff: */
    1037     {
    1038         /* Initialize CD/FD menus: */
    1039         int iDevicesCountCD = 0;
    1040         int iDevicesCountFD = 0;
    1041         foreach (const CMediumAttachment &attachment, machine.GetMediumAttachments())
    1042         {
    1043             if (attachment.GetType() == KDeviceType_DVD)
    1044                 ++iDevicesCountCD;
    1045             if (attachment.GetType() == KDeviceType_Floppy)
    1046                 ++iDevicesCountFD;
    1047         }
    1048         QAction *pOpticalDevicesMenu = actionPool()->action(UIActionIndexRT_M_Devices_M_OpticalDevices);
    1049         QAction *pFloppyDevicesMenu = actionPool()->action(UIActionIndexRT_M_Devices_M_FloppyDevices);
    1050         pOpticalDevicesMenu->setData(iDevicesCountCD);
    1051         pFloppyDevicesMenu->setData(iDevicesCountFD);
    1052         if (!iDevicesCountCD)
    1053             restriction = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restriction | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_OpticalDevices);
    1054         if (!iDevicesCountFD)
    1055             restriction = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restriction | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_FloppyDevices);
    1056     }
    1057 
    1058     /* Network stuff: */
    1059     {
    1060         /* Initialize Network menu: */
    1061         bool fAtLeastOneAdapterActive = false;
    1062         const KChipsetType chipsetType = machine.GetChipsetType();
    1063         ULONG uSlots = vboxGlobal().virtualBox().GetSystemProperties().GetMaxNetworkAdapters(chipsetType);
    1064         for (ULONG uSlot = 0; uSlot < uSlots; ++uSlot)
    1065         {
    1066             const CNetworkAdapter &adapter = machine.GetNetworkAdapter(uSlot);
    1067             if (adapter.GetEnabled())
     1031        /* Get host/machine: */
     1032        const CHost host = vboxGlobal().host();
     1033        const CMachine machine = session().GetConsole().GetMachine();
     1034        UIExtraDataMetaDefs::RuntimeMenuDevicesActionType restriction = UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Invalid;
     1035
     1036        /* Storage stuff: */
     1037        {
     1038            /* Initialize CD/FD menus: */
     1039            int iDevicesCountCD = 0;
     1040            int iDevicesCountFD = 0;
     1041            foreach (const CMediumAttachment &attachment, machine.GetMediumAttachments())
    10681042            {
    1069                 fAtLeastOneAdapterActive = true;
    1070                 break;
     1043                if (attachment.GetType() == KDeviceType_DVD)
     1044                    ++iDevicesCountCD;
     1045                if (attachment.GetType() == KDeviceType_Floppy)
     1046                    ++iDevicesCountFD;
    10711047            }
    1072         }
    1073         if (!fAtLeastOneAdapterActive)
    1074             restriction = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restriction | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Network);
    1075     }
    1076 
    1077     /* USB stuff: */
    1078     {
    1079         /* Check whether there is at least one USB controller with an available proxy. */
    1080         const bool fUSBEnabled =    !machine.GetUSBDeviceFilters().isNull()
    1081                                  && !machine.GetUSBControllers().isEmpty()
    1082                                  && machine.GetUSBProxyAvailable();
    1083         if (!fUSBEnabled)
    1084             restriction = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restriction | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_USBDevices);
    1085     }
    1086 
    1087     /* WebCams stuff: */
    1088     {
    1089         /* Check whether there is an accessible video input devices pool: */
    1090         host.GetVideoInputDevices();
    1091         const bool fWebCamsEnabled = host.isOk() && !machine.GetUSBControllers().isEmpty();
    1092         if (!fWebCamsEnabled)
    1093             restriction = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restriction | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_WebCams);
    1094     }
    1095 
    1096     /* Apply cumulative restriction: */
    1097     actionPool()->toRuntime()->setRestrictionForMenuDevices(UIActionRestrictionLevel_Session, restriction);
     1048            QAction *pOpticalDevicesMenu = actionPool()->action(UIActionIndexRT_M_Devices_M_OpticalDevices);
     1049            QAction *pFloppyDevicesMenu = actionPool()->action(UIActionIndexRT_M_Devices_M_FloppyDevices);
     1050            pOpticalDevicesMenu->setData(iDevicesCountCD);
     1051            pFloppyDevicesMenu->setData(iDevicesCountFD);
     1052            if (!iDevicesCountCD)
     1053                restriction = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restriction | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_OpticalDevices);
     1054            if (!iDevicesCountFD)
     1055                restriction = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restriction | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_FloppyDevices);
     1056        }
     1057
     1058        /* Network stuff: */
     1059        {
     1060            /* Initialize Network menu: */
     1061            bool fAtLeastOneAdapterActive = false;
     1062            const KChipsetType chipsetType = machine.GetChipsetType();
     1063            ULONG uSlots = vboxGlobal().virtualBox().GetSystemProperties().GetMaxNetworkAdapters(chipsetType);
     1064            for (ULONG uSlot = 0; uSlot < uSlots; ++uSlot)
     1065            {
     1066                const CNetworkAdapter &adapter = machine.GetNetworkAdapter(uSlot);
     1067                if (adapter.GetEnabled())
     1068                {
     1069                    fAtLeastOneAdapterActive = true;
     1070                    break;
     1071                }
     1072            }
     1073            if (!fAtLeastOneAdapterActive)
     1074                restriction = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restriction | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Network);
     1075        }
     1076
     1077        /* USB stuff: */
     1078        {
     1079            /* Check whether there is at least one USB controller with an available proxy. */
     1080            const bool fUSBEnabled =    !machine.GetUSBDeviceFilters().isNull()
     1081                                     && !machine.GetUSBControllers().isEmpty()
     1082                                     && machine.GetUSBProxyAvailable();
     1083            if (!fUSBEnabled)
     1084                restriction = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restriction | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_USBDevices);
     1085        }
     1086
     1087        /* WebCams stuff: */
     1088        {
     1089            /* Check whether there is an accessible video input devices pool: */
     1090            host.GetVideoInputDevices();
     1091            const bool fWebCamsEnabled = host.isOk() && !machine.GetUSBControllers().isEmpty();
     1092            if (!fWebCamsEnabled)
     1093                restriction = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restriction | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_WebCams);
     1094        }
     1095
     1096        /* Apply cumulative restriction: */
     1097        actionPool()->toRuntime()->setRestrictionForMenuDevices(UIActionRestrictionLevel_Session, restriction);
    10981098
    10991099#ifdef Q_WS_MAC
    1100     /* Create Mac OS X menu-bar: */
    1101     m_pMenuBar = new UIMenuBar;
    1102     AssertPtrReturnVoid(m_pMenuBar);
    1103     {
    1104         /* Configure Mac OS X menu-bar: */
    1105         connect(gEDataManager, SIGNAL(sigMenuBarConfigurationChange()),
    1106                 this, SLOT(sltHandleMenuBarConfigurationChange()));
    1107         /* Update Mac OS X menu-bar: */
    1108         updateMenu();
    1109     }
     1100        /* Create Mac OS X menu-bar: */
     1101        m_pMenuBar = new UIMenuBar;
     1102        AssertPtrReturnVoid(m_pMenuBar);
     1103        {
     1104            /* Configure Mac OS X menu-bar: */
     1105            connect(gEDataManager, SIGNAL(sigMenuBarConfigurationChange()),
     1106                    this, SLOT(sltHandleMenuBarConfigurationChange()));
     1107            /* Update Mac OS X menu-bar: */
     1108            updateMenu();
     1109        }
    11101110#endif /* Q_WS_MAC */
    11111111}
     
    12921292{
    12931293    /* Destroy console event-handler: */
    1294     UIConsoleEventHandler::destroy();
     1294        UIConsoleEventHandler::destroy();
    12951295}
    12961296
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