Changeset 98621 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Feb 17, 2023 3:21:52 PM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 155917
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp
r98547 r98621 758 758 QApplication::translate("UIMessageCenter", "Failed to acquire update agent parameter.") + 759 759 UIErrorString::formatErrorInfo(comAgent)); 760 } 761 762 /* static */ 763 void UINotificationMessage::cannotAcquireEmulatedUSBParameter(const CEmulatedUSB &comDispatcher) 764 { 765 createMessage( 766 QApplication::translate("UIMessageCenter", "Emulated USB failure ..."), 767 QApplication::translate("UIMessageCenter", "Failed to acquire emulated USB parameter.") + 768 UIErrorString::formatErrorInfo(comDispatcher)); 760 769 } 761 770 -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h
r98547 r98621 326 326 * @param comAgent Brings the object parameter get acquired from. */ 327 327 static void cannotAcquireUpdateAgentParameter(const CUpdateAgent &comAgent); 328 /** Notifies about inability to acquire IEmulatedUSB parameter. 329 * @param comDispatcher Brings the object parameter get acquired from. */ 330 static void cannotAcquireEmulatedUSBParameter(const CEmulatedUSB &comDispatcher); 328 331 /** Notifies about inability to acquire IVirtualSystemDescription parameter. 329 332 * @param comVsd Brings the object parameter get acquired from. */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp
r98620 r98621 559 559 { 560 560 return uisession()->detachUSBDevice(uId); 561 } 562 563 bool UIMachine::webcamDevices(QList<WebcamDeviceInfo> &guiWebcamDevices) 564 { 565 return uisession()->webcamDevices(guiWebcamDevices); 566 } 567 568 bool UIMachine::webcamAttach(const QString &strPath, const QString &strName) 569 { 570 return uisession()->webcamAttach(strPath, strName); 571 } 572 573 bool UIMachine::webcamDetach(const QString &strPath, const QString &strName) 574 { 575 return uisession()->webcamDetach(strPath, strName); 561 576 } 562 577 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h
r98620 r98621 417 417 /** Detaches USB device with passed @a uId. */ 418 418 bool detachUSBDevice(const QUuid &uId); 419 420 /** Returns a list of web cam devices. */ 421 bool webcamDevices(QList<WebcamDeviceInfo> &guiWebcamDevices); 422 /** Attaches web cam device with passed @a strName and @a strPath. */ 423 bool webcamAttach(const QString &strPath, const QString &strName); 424 /** Detaches web cam device with passed @a strName and @a strPath. */ 425 bool webcamDetach(const QString &strPath, const QString &strName); 419 426 /** @} */ 420 427 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineDefs.h
r98620 r98621 88 88 }; 89 89 90 /** Robust struct to bring web cam device info to machine-logic. */ 91 struct WebcamDeviceInfo 92 { 93 QString m_strName; 94 QString m_strPath; 95 QString m_strToolTip; 96 bool m_fIsChecked; 97 }; 98 90 99 #endif /* !FEQT_INCLUDED_SRC_runtime_UIMachineDefs_h */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r98620 r98621 1107 1107 m_menuUpdateHandlers[UIActionIndexRT_M_Devices_M_Network] = &UIMachineLogic::updateMenuDevicesNetwork; 1108 1108 m_menuUpdateHandlers[UIActionIndexRT_M_Devices_M_USBDevices] = &UIMachineLogic::updateMenuDevicesUSB; 1109 m_menuUpdateHandlers[UIActionIndexRT_M_Devices_M_WebCams] = &UIMachineLogic::updateMenuDevicesWeb Cams;1109 m_menuUpdateHandlers[UIActionIndexRT_M_Devices_M_WebCams] = &UIMachineLogic::updateMenuDevicesWebcams; 1110 1110 m_menuUpdateHandlers[UIActionIndexRT_M_Devices_M_SharedClipboard] = &UIMachineLogic::updateMenuDevicesSharedClipboard; 1111 1111 m_menuUpdateHandlers[UIActionIndexRT_M_Devices_M_DragAndDrop] = &UIMachineLogic::updateMenuDevicesDragAndDrop; … … 2280 2280 } 2281 2281 2282 void UIMachineLogic::sltAttachWeb CamDevice()2282 void UIMachineLogic::sltAttachWebcamDevice() 2283 2283 { 2284 2284 /* Get and check sender action object: */ … … 2289 2289 WebCamTarget target = pAction->data().value<WebCamTarget>(); 2290 2290 2291 /* Get current emulated USB: */2292 CEmulatedUSB dispatcher = console().GetEmulatedUSB();2293 2294 2291 /* Attach webcam device: */ 2295 2292 if (target.attach) 2296 { 2297 /* Try to attach corresponding device: */ 2298 dispatcher.WebcamAttach(target.path, ""); 2299 /* Check if dispatcher is OK: */ 2300 if (!dispatcher.isOk()) 2301 UINotificationMessage::cannotAttachWebCam(dispatcher, target.name, machineName()); 2302 } 2293 uimachine()->webcamAttach(target.path, target.name); 2303 2294 /* Detach webcam device: */ 2304 2295 else 2305 { 2306 /* Try to detach corresponding device: */ 2307 dispatcher.WebcamDetach(target.path); 2308 /* Check if dispatcher is OK: */ 2309 if (!dispatcher.isOk()) 2310 UINotificationMessage::cannotDetachWebCam(dispatcher, target.name, machineName()); 2311 } 2296 uimachine()->webcamDetach(target.path, target.name); 2312 2297 } 2313 2298 … … 2818 2803 } 2819 2804 2820 void UIMachineLogic::updateMenuDevicesWeb Cams(QMenu *pMenu)2805 void UIMachineLogic::updateMenuDevicesWebcams(QMenu *pMenu) 2821 2806 { 2822 2807 /* Clear contents: */ 2823 2808 pMenu->clear(); 2824 2809 2825 /* Get current host: */ 2826 const CHost host = uiCommon().host(); 2827 /* Get host webcam list: */ 2828 const CHostVideoInputDeviceVector webcams = host.GetVideoInputDevices(); 2810 /* Acquire device list: */ 2811 QList<WebcamDeviceInfo> guiWebcamDevices; 2812 const bool fSuccess = uimachine()->webcamDevices(guiWebcamDevices); 2829 2813 2830 2814 /* If webcam list is empty: */ 2831 if ( webcams.isEmpty())2815 if (!fSuccess || guiWebcamDevices.isEmpty()) 2832 2816 { 2833 2817 /* Add only one - "empty" action: */ … … 2842 2826 { 2843 2827 /* Populate menu with host webcams: */ 2844 const QVector<QString> attachedWebcamPaths = console().GetEmulatedUSB().GetWebcams(); 2845 foreach (const CHostVideoInputDevice &webcam, webcams) 2846 { 2847 /* Get webcam data: */ 2848 const QString strWebcamName = webcam.GetName(); 2849 const QString strWebcamPath = webcam.GetPath(); 2850 2851 /* Create/configure webcam action: */ 2852 QAction *pAttachWebcamAction = pMenu->addAction(strWebcamName, 2853 this, SLOT(sltAttachWebCamDevice())); 2854 pAttachWebcamAction->setToolTip(uiCommon().usbToolTip(webcam)); 2828 foreach (const WebcamDeviceInfo &guiWebcamDevice, guiWebcamDevices) 2829 { 2830 /* Create webcam device action: */ 2831 QAction *pAttachWebcamAction = pMenu->addAction(guiWebcamDevice.m_strName, 2832 this, SLOT(sltAttachWebcamDevice())); 2833 pAttachWebcamAction->setToolTip(guiWebcamDevice.m_strToolTip); 2855 2834 pAttachWebcamAction->setCheckable(true); 2856 2857 /* Check if that webcam was already attached to this session: */ 2858 pAttachWebcamAction->setChecked(attachedWebcamPaths.contains(strWebcamPath)); 2859 2860 /* Set USB attach data: */ 2861 pAttachWebcamAction->setData(QVariant::fromValue(WebCamTarget(!pAttachWebcamAction->isChecked(), strWebcamName, strWebcamPath))); 2835 pAttachWebcamAction->setChecked(guiWebcamDevice.m_fIsChecked); 2836 pAttachWebcamAction->setData(QVariant::fromValue(WebCamTarget(!pAttachWebcamAction->isChecked(), 2837 guiWebcamDevice.m_strName, 2838 guiWebcamDevice.m_strPath))); 2862 2839 } 2863 2840 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
r98605 r98621 302 302 void sltOpenSettingsDialogSharedFolders(); 303 303 void sltAttachUSBDevice(); 304 void sltAttachWeb CamDevice();304 void sltAttachWebcamDevice(); 305 305 void sltChangeSharedClipboardType(QAction *pAction); 306 306 void sltToggleNetworkAdapterConnection(); … … 353 353 void updateMenuDevicesUSB(QMenu *pMenu); 354 354 /** Update 'Devices' : 'Web Cams' menu routine. */ 355 void updateMenuDevicesWeb Cams(QMenu *pMenu);355 void updateMenuDevicesWebcams(QMenu *pMenu); 356 356 /** Update 'Devices' : 'Shared Clipboard' menu routine. */ 357 357 void updateMenuDevicesSharedClipboard(QMenu *pMenu); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r98620 r98621 57 57 58 58 /* COM includes: */ 59 #include "CEmulatedUSB.h" 59 60 #include "CGraphicsAdapter.h" 60 61 #include "CHostNetworkInterface.h" 61 62 #include "CHostUSBDevice.h" 63 #include "CHostVideoInputDevice.h" 62 64 #include "CMedium.h" 63 65 #include "CMediumAttachment.h" … … 466 468 UINotificationMessage::cannotDetachUSBDevice(comConsole, uiCommon().usbDetails(comUSBDevice)); 467 469 /// @todo make sure UICommon::usbDetails is checked for errors as well 470 } 471 return fSuccess; 472 } 473 474 bool UISession::webcamDevices(QList<WebcamDeviceInfo> &guiWebcamDevices) 475 { 476 const CHost comHost = uiCommon().host(); 477 const CHostVideoInputDeviceVector comHostVideoInputDevices = comHost.GetVideoInputDevices(); 478 bool fSuccess = comHost.isOk(); 479 if (!fSuccess) 480 UINotificationMessage::cannotAcquireHostParameter(comHost); 481 else 482 { 483 CConsole comConsole = console(); 484 CEmulatedUSB comEmulatedUSB = comConsole.GetEmulatedUSB(); 485 fSuccess = comConsole.isOk(); 486 if (!fSuccess) 487 UINotificationMessage::cannotAcquireConsoleParameter(comConsole); 488 else 489 { 490 const QVector<QString> attachedWebcamPaths = comEmulatedUSB.GetWebcams(); 491 fSuccess = comEmulatedUSB.isOk(); 492 if (!fSuccess) 493 UINotificationMessage::cannotAcquireEmulatedUSBParameter(comEmulatedUSB); 494 else 495 { 496 foreach (const CHostVideoInputDevice &comHostVideoInputDevice, comHostVideoInputDevices) 497 { 498 /* Fill structure fields: */ 499 WebcamDeviceInfo guiWebcamDevice; 500 if (fSuccess) 501 { 502 guiWebcamDevice.m_strName = comHostVideoInputDevice.GetName(); 503 fSuccess = comHostVideoInputDevice.isOk(); 504 } 505 if (fSuccess) 506 { 507 guiWebcamDevice.m_strPath = comHostVideoInputDevice.GetPath(); 508 fSuccess = comHostVideoInputDevice.isOk(); 509 } 510 if (fSuccess) 511 { 512 /// @todo make sure UICommon::usbToolTip is checked for errors as well 513 guiWebcamDevice.m_strToolTip = uiCommon().usbToolTip(comHostVideoInputDevice); 514 fSuccess = comHostVideoInputDevice.isOk(); 515 } 516 if (fSuccess) 517 guiWebcamDevice.m_fIsChecked = attachedWebcamPaths.contains(guiWebcamDevice.m_strPath); 518 519 /* Append or break if necessary: */ 520 if (fSuccess) 521 guiWebcamDevices << guiWebcamDevice; 522 else 523 break; 524 } 525 } 526 } 527 } 528 return fSuccess; 529 } 530 531 bool UISession::webcamAttach(const QString &strPath, const QString &strName) 532 { 533 CConsole comConsole = console(); 534 CEmulatedUSB comDispatcher = comConsole.GetEmulatedUSB(); 535 bool fSuccess = comConsole.isOk(); 536 if (!fSuccess) 537 UINotificationMessage::cannotAcquireConsoleParameter(comConsole); 538 else 539 { 540 comDispatcher.WebcamAttach(strPath, ""); 541 fSuccess = comDispatcher.isOk(); 542 if (!fSuccess) 543 UINotificationMessage::cannotAttachWebCam(comDispatcher, strName, machineName()); 544 } 545 return fSuccess; 546 } 547 548 bool UISession::webcamDetach(const QString &strPath, const QString &strName) 549 { 550 CConsole comConsole = console(); 551 CEmulatedUSB comDispatcher = comConsole.GetEmulatedUSB(); 552 bool fSuccess = comConsole.isOk(); 553 if (!fSuccess) 554 UINotificationMessage::cannotAcquireConsoleParameter(comConsole); 555 else 556 { 557 comDispatcher.WebcamDetach(strPath); 558 fSuccess = comDispatcher.isOk(); 559 if (!fSuccess) 560 UINotificationMessage::cannotDetachWebCam(comDispatcher, strName, machineName()); 468 561 } 469 562 return fSuccess; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r98620 r98621 282 282 /** Detaches USB device with passed @a uId. */ 283 283 bool detachUSBDevice(const QUuid &uId); 284 285 /** Returns a list of web cam devices. */ 286 bool webcamDevices(QList<WebcamDeviceInfo> &guiWebcamDevices); 287 /** Attaches web cam device with passed @a strName and @a strPath. */ 288 bool webcamAttach(const QString &strPath, const QString &strName); 289 /** Detaches web cam device with passed @a strName and @a strPath. */ 290 bool webcamDetach(const QString &strPath, const QString &strName); 284 291 /** @} */ 285 292
Note:
See TracChangeset
for help on using the changeset viewer.