Changeset 52998 in vbox
- Timestamp:
- Oct 8, 2014 4:17:50 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 96458
- 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 37 37 38 38 /* static */ 39 UIConsoleEventHandler *UIConsoleEventHandler::m_ pInstance = 0;39 UIConsoleEventHandler *UIConsoleEventHandler::m_spInstance = 0; 40 40 41 41 /* static */ 42 UIConsoleEventHandler* UIConsoleEventHandler::instance(UISession *pSession /* = 0 */)43 { 44 if (!m_ pInstance)42 void UIConsoleEventHandler::create(UISession *pSession) 43 { 44 if (!m_spInstance) 45 45 { 46 m_ pInstance = new UIConsoleEventHandler(pSession);47 m_ pInstance->prepare();46 m_spInstance = new UIConsoleEventHandler(pSession); 47 m_spInstance->prepare(); 48 48 } 49 return m_pInstance;50 49 } 51 50 … … 53 52 void UIConsoleEventHandler::destroy() 54 53 { 55 if (m_ pInstance)54 if (m_spInstance) 56 55 { 57 m_ pInstance->cleanup();58 delete m_ pInstance;59 m_ pInstance = 0;56 m_spInstance->cleanup(); 57 delete m_spInstance; 58 m_spInstance = 0; 60 59 } 61 60 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIConsoleEventHandler.h
r52898 r52998 73 73 public: 74 74 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); 77 79 /** Static instance destructor. */ 78 80 static void destroy(); … … 96 98 97 99 /** Holds the static instance. */ 98 static UIConsoleEventHandler *m_ pInstance;100 static UIConsoleEventHandler *m_spInstance; 99 101 100 102 /** Holds the UI session reference. */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r52991 r52998 968 968 void UISession::prepareConsoleEventHandlers() 969 969 { 970 /* Initialize console event-handler: */971 UIConsoleEventHandler:: instance(this);970 /* Create console event-handler: */ 971 UIConsoleEventHandler::create(this); 972 972 973 973 /* Add console event connections: */ … … 1029 1029 m_pActionPool->toRuntime()->setSession(this); 1030 1030 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()) 1068 1042 { 1069 fAtLeastOneAdapterActive = true; 1070 break; 1043 if (attachment.GetType() == KDeviceType_DVD) 1044 ++iDevicesCountCD; 1045 if (attachment.GetType() == KDeviceType_Floppy) 1046 ++iDevicesCountFD; 1071 1047 } 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); 1098 1098 1099 1099 #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 } 1110 1110 #endif /* Q_WS_MAC */ 1111 1111 } … … 1292 1292 { 1293 1293 /* Destroy console event-handler: */ 1294 UIConsoleEventHandler::destroy();1294 UIConsoleEventHandler::destroy(); 1295 1295 } 1296 1296
Note:
See TracChangeset
for help on using the changeset viewer.