Changeset 49333 in vbox
- Timestamp:
- Oct 30, 2013 1:42:57 PM (11 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 11 edited
- 2 copied
-
VirtualBox2.qrc (modified) (1 diff)
-
images/web_camera_16px.png (copied) (copied from trunk/src/VBox/Frontends/VirtualBox/images/usb_16px.png )
-
images/web_camera_disabled_16px.png (copied) (copied from trunk/src/VBox/Frontends/VirtualBox/images/usb_disabled_16px.png )
-
src/globals/UIMessageCenter.cpp (modified) (2 diffs)
-
src/globals/UIMessageCenter.h (modified) (1 diff)
-
src/globals/VBoxGlobal.cpp (modified) (2 diffs)
-
src/globals/VBoxGlobal.h (modified) (2 diffs)
-
src/runtime/UIActionPoolRuntime.cpp (modified) (2 diffs)
-
src/runtime/UIActionPoolRuntime.h (modified) (1 diff)
-
src/runtime/UIMachineLogic.cpp (modified) (6 diffs)
-
src/runtime/UIMachineLogic.h (modified) (1 diff)
-
src/runtime/UIMachineMenuBar.cpp (modified) (1 diff)
-
src/runtime/UISession.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/VirtualBox2.qrc
r48388 r49333 217 217 <file alias="vrdp_warning_16px.png">images/vrdp_warning_16px.png</file> 218 218 <file alias="reset_warnings_16px.png">images/reset_warnings_16px.png</file> 219 <file alias="web_camera_16px.png">images/web_camera_16px.png</file> 220 <file alias="web_camera_disabled_16px.png">images/web_camera_disabled_16px.png</file> 219 221 </qresource> 220 222 </RCC> -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r49272 r49333 64 64 #include "CHostNetworkInterface.h" 65 65 #include "CVRDEServer.h" 66 #include "CEmulatedUSB.h" 66 67 #ifdef VBOX_WITH_DRAG_AND_DROP 67 68 # include "CGuest.h" … … 1932 1933 .arg(strDevice, strMachineName), 1933 1934 formatErrorInfo(errorInfo)); 1935 } 1936 1937 void UIMessageCenter::cannotAttachWebCam(const CEmulatedUSB &dispatcher, const QString &strWebCamName, const QString &strMachineName) const 1938 { 1939 error(0, MessageType_Error, 1940 tr("Failed to attach the webcam <b>%1</b> to the virtual machine <b>%2</b>.") 1941 .arg(strWebCamName, strMachineName), 1942 formatErrorInfo(dispatcher)); 1943 } 1944 1945 void UIMessageCenter::cannotDetachWebCam(const CEmulatedUSB &dispatcher, const QString &strWebCamName, const QString &strMachineName) const 1946 { 1947 error(0, MessageType_Error, 1948 tr("Failed to detach the webcam <b>%1</b> from the virtual machine <b>%2</b>.") 1949 .arg(strWebCamName, strMachineName), 1950 formatErrorInfo(dispatcher)); 1934 1951 } 1935 1952 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r48458 r49333 295 295 void cannotDetachUSBDevice(const CConsole &console, const QString &strDevice) const; 296 296 void cannotDetachUSBDevice(const CVirtualBoxErrorInfo &errorInfo, const QString &strDevice, const QString &strMachineName) const; 297 void cannotAttachWebCam(const CEmulatedUSB &dispatcher, const QString &strWebCamName, const QString &strMachineName) const; 298 void cannotDetachWebCam(const CEmulatedUSB &dispatcher, const QString &strWebCamName, const QString &strMachineName) const; 297 299 void cannotToggleVRDEServer(const CVRDEServer &server, const QString &strMachineName, bool fEnable); 298 300 void cannotToggleVideoCapture(const CMachine &machine, bool fEnable); -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r49307 r49333 108 108 #include "CUSBController.h" 109 109 #include "CHostUSBDevice.h" 110 #include "CHostVideoInputDevice.h" 110 111 #include "CMediumFormat.h" 111 112 #include "CSharedFolder.h" … … 1077 1078 1078 1079 return tip; 1080 } 1081 1082 /** Returns the multi-line description of the given CHostVideoInputDevice filter. */ 1083 QString VBoxGlobal::toolTip(const CHostVideoInputDevice &webcam) const 1084 { 1085 QStringList records; 1086 1087 QString strAlias = webcam.GetAlias(); 1088 if (!strAlias.isEmpty()) 1089 records << tr("<nobr>Alias: %1</nobr>", "webcam tooltip").arg(strAlias); 1090 1091 QString strName = webcam.GetName(); 1092 if (!strName.isEmpty()) 1093 records << tr("<nobr>Name: %1</nobr>", "webcam tooltip").arg(strName); 1094 1095 QString strPath = webcam.GetPath(); 1096 if (!strPath.isEmpty()) 1097 records << tr("<nobr>Path: %1</nobr>", "webcam tooltip").arg(strPath); 1098 1099 return records.join("<br>"); 1079 1100 } 1080 1101 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r48906 r49333 50 50 class CMedium; 51 51 class CUSBDevice; 52 class CHostVideoInputDevice; 52 53 class QSpinBox; 53 54 class UIMediumEnumerator; … … 232 233 QString toolTip (const CUSBDevice &aDevice) const; 233 234 QString toolTip (const CUSBDeviceFilter &aFilter) const; 235 QString toolTip(const CHostVideoInputDevice &webcam) const; 234 236 235 237 QString detailsReport (const CMachine &aMachine, bool aWithLinks); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.cpp
r49277 r49333 727 727 { 728 728 setName(QApplication::translate("UIActionPool", "&USB Devices")); 729 } 730 }; 731 732 class UIActionMenuWebCams : public UIActionMenu 733 { 734 Q_OBJECT; 735 736 public: 737 738 UIActionMenuWebCams(UIActionPool *pParent) 739 : UIActionMenu(pParent, ":/web_camera_16px.png", ":/web_camera_disabled_16px.png") 740 { 741 qobject_cast<UIMenu*>(menu())->setShowToolTips(true); 742 retranslateUi(); 743 } 744 745 protected: 746 747 void retranslateUi() 748 { 749 setName(QApplication::translate("UIActionPool", "&Webcams")); 729 750 } 730 751 }; … … 1277 1298 delete m_pool[UIActionIndexRuntime_Menu_USBDevices]; 1278 1299 m_pool[UIActionIndexRuntime_Menu_USBDevices] = new UIActionMenuUSBDevices(this); 1300 if (m_pool[UIActionIndexRuntime_Menu_WebCams]) 1301 delete m_pool[UIActionIndexRuntime_Menu_WebCams]; 1302 m_pool[UIActionIndexRuntime_Menu_WebCams] = new UIActionMenuWebCams(this); 1279 1303 if (m_pool[UIActionIndexRuntime_Menu_SharedClipboard]) 1280 1304 delete m_pool[UIActionIndexRuntime_Menu_SharedClipboard]; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.h
r46626 r49333 58 58 UIActionIndexRuntime_Menu_FloppyDevices, 59 59 UIActionIndexRuntime_Menu_USBDevices, 60 UIActionIndexRuntime_Menu_WebCams, 60 61 UIActionIndexRuntime_Menu_SharedClipboard, 61 62 UIActionIndexRuntime_Menu_DragAndDrop, -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r49177 r49333 72 72 #include "CVRDEServer.h" 73 73 #include "CSystemProperties.h" 74 #include "CHostVideoInputDevice.h" 75 #include "CEmulatedUSB.h" 74 76 #ifdef Q_WS_MAC 75 77 # include "CGuest.h" … … 130 132 }; 131 133 Q_DECLARE_METATYPE(USBTarget); 134 135 /** Describes enumerated webcam item. */ 136 struct WebCamTarget 137 { 138 WebCamTarget() : attach(false), name(QString()), path(QString()) {} 139 WebCamTarget(bool fAttach, const QString &strName, const QString &strPath) 140 : attach(fAttach), name(strName), path(strPath) {} 141 bool attach; 142 QString name; 143 QString path; 144 }; 145 Q_DECLARE_METATYPE(WebCamTarget); 132 146 133 147 /* static */ … … 786 800 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_FloppyDevices)); 787 801 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_USBDevices)); 802 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_WebCams)); 788 803 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_SharedClipboard)); 789 804 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_DragAndDrop)); … … 847 862 connect(gActionPool->action(UIActionIndexRuntime_Menu_USBDevices)->menu(), SIGNAL(aboutToShow()), 848 863 this, SLOT(sltPrepareUSBMenu())); 864 connect(gActionPool->action(UIActionIndexRuntime_Menu_WebCams)->menu(), SIGNAL(aboutToShow()), 865 this, SLOT(sltPrepareWebCamMenu())); 849 866 connect(gActionPool->action(UIActionIndexRuntime_Menu_SharedClipboard)->menu(), SIGNAL(aboutToShow()), 850 867 this, SLOT(sltPrepareSharedClipboardMenu())); … … 1834 1851 } 1835 1852 1853 /** 1854 * Prepares menu content when user hovers <b>Webcam</b> submenu of the <b>Devices</b> menu. 1855 * @note If host currently have no webcams attached there will be just one dummy action 1856 * called <i>No Webcams Connected</i>. Otherwise there will be actions corresponding 1857 * to existing webcams allowing user to attach/detach them within the guest. 1858 * @note In order to enumerate webcams GUI assigns #WebCamTarget object as internal data 1859 * for each the enumerated webcam menu action. Corresponding #sltAttachWebCamDevice 1860 * slot will be called on action triggering. It will parse assigned #WebCamTarget data. 1861 */ 1862 void UIMachineLogic::sltPrepareWebCamMenu() 1863 { 1864 /* Get and check the sender menu object: */ 1865 QMenu *pMenu = qobject_cast<QMenu*>(sender()); 1866 QMenu *pWebCamMenu = gActionPool->action(UIActionIndexRuntime_Menu_WebCams)->menu(); 1867 AssertReturnVoid(pMenu == pWebCamMenu); Q_UNUSED(pWebCamMenu); 1868 1869 /* Clear menu initially: */ 1870 pMenu->clear(); 1871 1872 /* Get current host: */ 1873 const CHost &host = vboxGlobal().host(); 1874 1875 /* Get host webcams list: */ 1876 const CHostVideoInputDeviceVector &webcams = host.GetVideoInputDevices(); 1877 1878 /* If webcam list is empty: */ 1879 if (webcams.isEmpty()) 1880 { 1881 /* Add only one - "empty" action: */ 1882 QAction *pEmptyMenuAction = new QAction(pMenu); 1883 pEmptyMenuAction->setEnabled(false); 1884 pEmptyMenuAction->setText(tr("No Webcams Connected")); 1885 pEmptyMenuAction->setToolTip(tr("No supported devices connected to the host PC")); 1886 pEmptyMenuAction->setIcon(UIIconPool::iconSet(":/vm_delete_16px.png", ":/vm_delete_disabled_16px.png")); // TODO: Change icon! 1887 pMenu->addAction(pEmptyMenuAction); 1888 } 1889 /* If webcam list is NOT empty: */ 1890 else 1891 { 1892 /* Populate menu with host webcams: */ 1893 const QVector<QString> &attachedWebcamPaths = session().GetConsole().GetEmulatedUSB().GetWebcams(); 1894 foreach (const CHostVideoInputDevice &webcam, webcams) 1895 { 1896 /* Get webcam data: */ 1897 const QString &strWebcamName = webcam.GetName(); 1898 const QString &strWebcamPath = webcam.GetPath(); 1899 1900 /* Create/configure webcam action: */ 1901 QAction *pAttachWebcamAction = new QAction(strWebcamName, pMenu); 1902 pAttachWebcamAction->setToolTip(vboxGlobal().toolTip(webcam)); 1903 pAttachWebcamAction->setCheckable(true); 1904 pAttachWebcamAction->setChecked(attachedWebcamPaths.contains(strWebcamPath)); 1905 pAttachWebcamAction->setData(QVariant::fromValue(WebCamTarget(!pAttachWebcamAction->isChecked(), strWebcamName, strWebcamPath))); 1906 connect(pAttachWebcamAction, SIGNAL(triggered(bool)), this, SLOT(sltAttachWebCamDevice())); 1907 pMenu->addAction(pAttachWebcamAction); 1908 } 1909 } 1910 } 1911 1836 1912 void UIMachineLogic::sltAttachUSBDevice() 1837 1913 { … … 1877 1953 msgCenter().cannotDetachUSBDevice(console, vboxGlobal().details(device)); 1878 1954 } 1955 } 1956 } 1957 1958 /** 1959 * Attaches/detaches webcam within the guest. 1960 * @note In order to attach/detach webcams #sltPrepareWebCamMenu assigns #WebCamTarget object 1961 * as internal data for each the enumerated webcam menu action. Corresponding data 1962 * will be parsed here resulting in device attaching/detaching. 1963 */ 1964 void UIMachineLogic::sltAttachWebCamDevice() 1965 { 1966 /* Get and check sender action object: */ 1967 QAction *pAction = qobject_cast<QAction*>(sender()); 1968 AssertReturnVoid(pAction); 1969 1970 /* Get operation target: */ 1971 WebCamTarget target = pAction->data().value<WebCamTarget>(); 1972 1973 /* Get current emulated USB: */ 1974 const CConsole &console = session().GetConsole(); 1975 CEmulatedUSB dispatcher = console.GetEmulatedUSB(); 1976 1977 /* Attach webcam device: */ 1978 if (target.attach) 1979 { 1980 /* Try to attach corresponding device: */ 1981 dispatcher.WebcamAttach(target.path, ""); 1982 /* Check if dispatcher is OK: */ 1983 if (!dispatcher.isOk()) 1984 msgCenter().cannotAttachWebCam(dispatcher, target.name, console.GetMachine().GetName()); 1985 } 1986 /* Detach webcam device: */ 1987 else 1988 { 1989 /* Try to detach corresponding device: */ 1990 dispatcher.WebcamDetach(target.path); 1991 /* Check if dispatcher is OK: */ 1992 if (!dispatcher.isOk()) 1993 msgCenter().cannotDetachWebCam(dispatcher, target.name, console.GetMachine().GetName()); 1879 1994 } 1880 1995 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
r49309 r49333 204 204 void sltMountRecentStorageMedium(); 205 205 void sltPrepareUSBMenu(); 206 void sltPrepareWebCamMenu(); 206 207 void sltAttachUSBDevice(); 208 void sltAttachWebCamDevice(); 207 209 void sltPrepareSharedClipboardMenu(); 208 210 void sltChangeSharedClipboardType(QAction *pAction); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineMenuBar.cpp
r47478 r49333 256 256 pMenu->addMenu(gActionPool->action(UIActionIndexRuntime_Menu_FloppyDevices)->menu()); 257 257 pMenu->addMenu(gActionPool->action(UIActionIndexRuntime_Menu_USBDevices)->menu()); 258 pMenu->addMenu(gActionPool->action(UIActionIndexRuntime_Menu_WebCams)->menu()); 258 259 pMenu->addMenu(gActionPool->action(UIActionIndexRuntime_Menu_SharedClipboard)->menu()); 259 260 pMenu->addMenu(gActionPool->action(UIActionIndexRuntime_Menu_DragAndDrop)->menu()); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r49177 r49333 76 76 #include "CUSBController.h" 77 77 #include "CUSBDeviceFilters.h" 78 #include "CHostVideoInputDevice.h" 78 79 #include "CSnapshot.h" 79 80 #include "CMedium.h" … … 1410 1411 void UISession::reinitMenuPool() 1411 1412 { 1413 /* Get host: */ 1414 const CHost &host = vboxGlobal().host(); 1415 1412 1416 /* Get uisession machine: */ 1413 1417 const CMachine &machine = session().GetConsole().GetMachine(); … … 1448 1452 } 1449 1453 } 1454 1450 1455 /* Show/Hide Network Adapters action depending on overall adapters activity status: */ 1451 1456 gActionPool->action(UIActionIndexRuntime_Simple_NetworkSettings)->setVisible(fAtLeastOneAdapterActive); … … 1454 1459 /* USB stuff: */ 1455 1460 { 1456 /* 1457 * Check whether there is at least one OHCI USB controllers with 1458 * an available proxy. 1459 */ 1461 /* Check whether there is at least one OHCI USB controllers with an available proxy. */ 1460 1462 const CUSBDeviceFilters &filters = machine.GetUSBDeviceFilters(); 1461 1463 ULONG cOhciCtls = machine.GetUSBControllerCountByType(KUSBControllerType_OHCI); … … 1464 1466 /* Show/Hide USB menu depending on controller availability, activity and USB-proxy presence: */ 1465 1467 gActionPool->action(UIActionIndexRuntime_Menu_USBDevices)->setVisible(fUSBEnabled); 1468 } 1469 1470 /* WebCams stuff: */ 1471 { 1472 /* Check whether there is an accessible video input devices pool: */ 1473 const CHostVideoInputDeviceVector &webcams = host.GetVideoInputDevices(); 1474 bool fWebCamsEnabled = host.isOk(); Q_UNUSED(webcams); 1475 1476 /* Show/Hide WebCams menu depending on ExtPack availability: */ 1477 gActionPool->action(UIActionIndexRuntime_Menu_WebCams)->setVisible(fWebCamsEnabled); 1466 1478 } 1467 1479 }
Note:
See TracChangeset
for help on using the changeset viewer.

