Changeset 54305 in vbox
- Timestamp:
- Feb 19, 2015 6:38:23 PM (10 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r54285 r54305 69 69 # include "CHostNetworkInterface.h" 70 70 # include "CVRDEServer.h" 71 # include "CNetworkAdapter.h" 71 72 # include "CEmulatedUSB.h" 72 73 # ifdef VBOX_WITH_DRAG_AND_DROP … … 2007 2008 } 2008 2009 2010 void UIMessageCenter::cannotToggleVideoCapture(const CMachine &machine, bool fEnable) 2011 { 2012 /* Get machine-name preserving error-info: */ 2013 QString strMachineName(CMachine(machine).GetName()); 2014 error(0, MessageType_Error, 2015 fEnable ? 2016 tr("Failed to enable video capturing for the virtual machine <b>%1</b>.").arg(strMachineName) : 2017 tr("Failed to disable video capturing for the virtual machine <b>%1</b>.").arg(strMachineName), 2018 formatErrorInfo(machine)); 2019 } 2020 2009 2021 void UIMessageCenter::cannotToggleVRDEServer(const CVRDEServer &server, const QString &strMachineName, bool fEnable) 2010 2022 { … … 2016 2028 } 2017 2029 2018 void UIMessageCenter::cannotToggleVideoCapture(const CMachine &machine, bool fEnable) 2019 { 2020 /* Get machine-name preserving error-info: */ 2021 QString strMachineName(CMachine(machine).GetName()); 2022 error(0, MessageType_Error, 2023 fEnable ? 2024 tr("Failed to enable video capturing for the virtual machine <b>%1</b>.").arg(strMachineName) : 2025 tr("Failed to disable video capturing for the virtual machine <b>%1</b>.").arg(strMachineName), 2026 formatErrorInfo(machine)); 2030 void UIMessageCenter::cannotToggleNetworkAdapterCable(const CNetworkAdapter &adapter, const QString &strMachineName, bool fConnect) 2031 { 2032 error(0, MessageType_Error, 2033 fConnect ? 2034 tr("Failed to connect network adapter cable of the virtual machine <b>%1</b>.").arg(strMachineName) : 2035 tr("Failed to disconnect network adapter cable of the virtual machine <b>%1</b>.").arg(strMachineName), 2036 formatErrorInfo(adapter)); 2027 2037 } 2028 2038 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r54223 r54305 298 298 void cannotAttachWebCam(const CEmulatedUSB &dispatcher, const QString &strWebCamName, const QString &strMachineName) const; 299 299 void cannotDetachWebCam(const CEmulatedUSB &dispatcher, const QString &strWebCamName, const QString &strMachineName) const; 300 void cannotToggleVideoCapture(const CMachine &machine, bool fEnable); 300 301 void cannotToggleVRDEServer(const CVRDEServer &server, const QString &strMachineName, bool fEnable); 301 void cannotToggle VideoCapture(const CMachine &machine, bool fEnable);302 void cannotToggleNetworkAdapterCable(const CNetworkAdapter &adapter, const QString &strMachineName, bool fConnect); 302 303 void remindAboutGuestAdditionsAreNotActive() const; 303 304 void cannotMountGuestAdditions(const QString &strMachineName) const; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r54303 r54305 1605 1605 1606 1606 /* Update Video Capture state: */ 1607 AssertMsg(machine().isOk(), ("Machine should be OK!\n"));1608 1607 machine().SetVideoCaptureEnabled(fEnabled); 1609 /* Machine is not OK? */1610 1608 if (!machine().isOk()) 1611 1609 { 1610 /* Make sure action is updated: */ 1611 uisession()->updateStatusVideoCapture(); 1612 1612 /* Notify about the error: */ 1613 msgCenter().cannotToggleVideoCapture(machine(), fEnabled); 1614 /* Make sure action is updated! */ 1613 return msgCenter().cannotToggleVideoCapture(machine(), fEnabled); 1614 } 1615 1616 /* Save machine-settings: */ 1617 machine().SaveSettings(); 1618 if (!machine().isOk()) 1619 { 1620 /* Make sure action is updated: */ 1615 1621 uisession()->updateStatusVideoCapture(); 1616 } 1617 /* Machine is OK? */ 1618 else 1619 { 1620 /* Save machine-settings: */ 1621 machine().SaveSettings(); 1622 /* Machine is not OK? */ 1623 if (!machine().isOk()) 1624 { 1625 /* Notify about the error: */ 1626 msgCenter().cannotSaveMachineSettings(machine()); 1627 /* Make sure action is updated! */ 1628 uisession()->updateStatusVideoCapture(); 1629 } 1622 /* Notify about the error: */ 1623 return msgCenter().cannotSaveMachineSettings(machine()); 1630 1624 } 1631 1625 } … … 1639 1633 /* Access VRDE server: */ 1640 1634 CVRDEServer server = machine().GetVRDEServer(); 1641 AssertMsg(!server.isNull(), ("VRDE server should NOT be null!\n")); 1642 if (!machine().isOk() || server.isNull()) 1643 return; 1635 AssertMsgReturnVoid(machine().isOk() && !server.isNull(), 1636 ("VRDE server should NOT be null!\n")); 1644 1637 1645 1638 /* Make sure something had changed: */ … … 1647 1640 return; 1648 1641 1649 /* Server is OK? */ 1650 if (server.isOk()) 1651 { 1652 /* Update VRDE server state: */ 1653 server.SetEnabled(fEnabled); 1654 /* Server still OK? */ 1655 if (server.isOk()) 1656 { 1657 /* Save machine-settings: */ 1658 machine().SaveSettings(); 1659 /* Machine still OK? */ 1660 if (!machine().isOk()) 1661 { 1662 /* Notify about the error: */ 1663 msgCenter().cannotSaveMachineSettings(machine()); 1664 /* Make sure action is updated! */ 1665 uisession()->updateStatusVRDE(); 1666 } 1667 } 1668 else 1669 { 1670 /* Notify about the error: */ 1671 msgCenter().cannotToggleVRDEServer(server, machineName(), fEnabled); 1672 /* Make sure action is updated! */ 1673 uisession()->updateStatusVRDE(); 1674 } 1642 /* Update VRDE server state: */ 1643 server.SetEnabled(fEnabled); 1644 if (!server.isOk()) 1645 { 1646 /* Make sure action is updated: */ 1647 uisession()->updateStatusVRDE(); 1648 /* Notify about the error: */ 1649 return msgCenter().cannotToggleVRDEServer(server, machineName(), fEnabled); 1650 } 1651 1652 /* Save machine-settings: */ 1653 machine().SaveSettings(); 1654 if (!machine().isOk()) 1655 { 1656 /* Make sure action is updated: */ 1657 uisession()->updateStatusVRDE(); 1658 /* Notify about the error: */ 1659 return msgCenter().cannotSaveMachineSettings(machine()); 1675 1660 } 1676 1661 } … … 1828 1813 } 1829 1814 1830 /** Toggles network adapter's <i>Cable Connected</i> state. */1831 1815 void UIMachineLogic::sltToggleNetworkAdapterConnection() 1832 1816 { 1817 /* Do not process if window(s) missed! */ 1818 if (!isMachineWindowsCreated()) 1819 return; 1820 1833 1821 /* Get and check 'the sender' action object: */ 1834 1822 QAction *pAction = qobject_cast<QAction*>(sender()); 1835 Assert ReturnVoid(pAction);1823 AssertMsgReturnVoid(pAction, ("Sender action should NOT be null!\n")); 1836 1824 1837 1825 /* Get operation target: */ 1838 1826 CNetworkAdapter adapter = machine().GetNetworkAdapter((ULONG)pAction->property("slot").toInt()); 1839 AssertReturnVoid(machine().isOk() && !adapter.isNull()); 1827 AssertMsgReturnVoid(machine().isOk() && !adapter.isNull(), 1828 ("Network adapter should NOT be null!\n")); 1840 1829 1841 1830 /* Connect/disconnect cable to/from target: */ 1842 adapter.SetCableConnected(!adapter.GetCableConnected()); 1831 const bool fConnect = !adapter.GetCableConnected(); 1832 adapter.SetCableConnected(fConnect); 1833 if (!adapter.isOk()) 1834 return msgCenter().cannotToggleNetworkAdapterCable(adapter, machineName(), fConnect); 1835 1836 /* Save machine-settings: */ 1843 1837 machine().SaveSettings(); 1844 1838 if (!machine().isOk()) 1845 msgCenter().cannotSaveMachineSettings(machine());1839 return msgCenter().cannotSaveMachineSettings(machine()); 1846 1840 } 1847 1841 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r54303 r54305 746 746 void UISession::sltVRDEChange() 747 747 { 748 /* Get VRDE server: */749 const CVRDEServer &server = machine().GetVRDEServer();750 bool fIsVRDEServerAvailable = !server.isNull();751 /* Show/Hide VRDE action depending on VRDE server availability status: */752 // TODO: Is this status can be changed at runtime? 753 / / Because if no => the place for that stuff is in prepareActions().754 actionPool()->action(UIActionIndexRT_M_View_T_VRDEServer)-> setVisible(fIsVRDEServerAvailable);755 /* Check/Uncheck VRDE action depending on VRDE server activity status: */756 if (fIsVRDEServerAvailable)757 actionPool()->action(UIActionIndexRT_M_View_T_VRDEServer)->setChecked(server.GetEnabled()); 748 /* Make sure VRDE server is present: */ 749 const CVRDEServer server = machine().GetVRDEServer(); 750 AssertMsgReturnVoid(machine().isOk() && !server.isNull(), 751 ("VRDE server should NOT be null!\n")); 752 753 /* Check/Uncheck VRDE Server action depending on feature status: */ 754 actionPool()->action(UIActionIndexRT_M_View_T_VRDEServer)->blockSignals(true); 755 actionPool()->action(UIActionIndexRT_M_View_T_VRDEServer)->setChecked(server.GetEnabled()); 756 actionPool()->action(UIActionIndexRT_M_View_T_VRDEServer)->blockSignals(false); 757 758 758 /* Notify listeners about VRDE change: */ 759 759 emit sigVRDEChange(); … … 763 763 { 764 764 /* Check/Uncheck Video Capture action depending on feature status: */ 765 actionPool()->action(UIActionIndexRT_M_View_M_VideoCapture_T_Start)->blockSignals(true); 765 766 actionPool()->action(UIActionIndexRT_M_View_M_VideoCapture_T_Start)->setChecked(machine().GetVideoCaptureEnabled()); 767 actionPool()->action(UIActionIndexRT_M_View_M_VideoCapture_T_Start)->blockSignals(false); 768 766 769 /* Notify listeners about Video Capture change: */ 767 770 emit sigVideoCaptureChange(); … … 1074 1077 /* Get host: */ 1075 1078 const CHost host = vboxGlobal().host(); 1076 UIExtraDataMetaDefs::RuntimeMenuDevicesActionType restriction = UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Invalid; 1079 UIExtraDataMetaDefs::RuntimeMenuViewActionType restrictionForView = UIExtraDataMetaDefs::RuntimeMenuViewActionType_Invalid; 1080 UIExtraDataMetaDefs::RuntimeMenuDevicesActionType restrictionForDevices = UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Invalid; 1081 1082 /* VRDE server stuff: */ 1083 { 1084 /* Initialize 'View' menu: */ 1085 const CVRDEServer server = machine().GetVRDEServer(); 1086 if (server.isNull()) 1087 restrictionForView = (UIExtraDataMetaDefs::RuntimeMenuViewActionType)(restrictionForView | UIExtraDataMetaDefs::RuntimeMenuViewActionType_VRDEServer); 1088 } 1077 1089 1078 1090 /* Storage stuff: */ … … 1093 1105 pFloppyDevicesMenu->setData(iDevicesCountFD); 1094 1106 if (!iDevicesCountCD) 1095 restriction = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restriction| UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_OpticalDevices);1107 restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_OpticalDevices); 1096 1108 if (!iDevicesCountFD) 1097 restriction = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restriction| UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_FloppyDevices);1109 restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_FloppyDevices); 1098 1110 } 1099 1111 … … 1114 1126 } 1115 1127 if (!fAtLeastOneAdapterActive) 1116 restriction = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restriction| UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Network);1128 restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Network); 1117 1129 } 1118 1130 … … 1124 1136 && machine().GetUSBProxyAvailable(); 1125 1137 if (!fUSBEnabled) 1126 restriction = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restriction| UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_USBDevices);1138 restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_USBDevices); 1127 1139 } 1128 1140 … … 1133 1145 const bool fWebCamsEnabled = host.isOk() && !machine().GetUSBControllers().isEmpty(); 1134 1146 if (!fWebCamsEnabled) 1135 restriction = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restriction | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_WebCams); 1136 } 1137 1138 /* Apply cumulative restriction: */ 1139 actionPool()->toRuntime()->setRestrictionForMenuDevices(UIActionRestrictionLevel_Session, restriction); 1147 restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_WebCams); 1148 } 1149 1150 /* Apply cumulative restriction for 'View' menu: */ 1151 actionPool()->toRuntime()->setRestrictionForMenuView(UIActionRestrictionLevel_Session, restrictionForView); 1152 /* Apply cumulative restriction for 'Devices' menu: */ 1153 actionPool()->toRuntime()->setRestrictionForMenuDevices(UIActionRestrictionLevel_Session, restrictionForDevices); 1140 1154 1141 1155 #ifdef Q_WS_MAC -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r54160 r54305 245 245 const QVector<ComObjPtr<UIFrameBuffer> >& frameBuffers() const { return m_frameBufferVector; } 246 246 247 /* Temporary API:*/247 /** Updates VRDE Server action state. */ 248 248 void updateStatusVRDE() { sltVRDEChange(); } 249 /** Updates Video Capture action state. */ 249 250 void updateStatusVideoCapture() { sltVideoCaptureChange(); } 250 251
Note:
See TracChangeset
for help on using the changeset viewer.