Changeset 704 in vbox for trunk/src/VBox/Frontends/VirtualBox/include
- Timestamp:
- Feb 6, 2007 1:47:46 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h
r563 r704 34 34 #include <quuid.h> 35 35 #include <qthread.h> 36 #include <qpopupmenu.h> 37 #include <qtooltip.h> 36 38 37 39 #include <qptrvector.h> … … 224 226 } 225 227 228 QString toString (CEnums::USBDeviceFilterAction t) const 229 { 230 AssertMsg (!usbFilterActionTypes [t].isNull(), ("No text for %d", t)); 231 return usbFilterActionTypes [t]; 232 } 233 226 234 CEnums::VRDPAuthType toVRDPAuthType (const QString &s) const 227 235 { … … 230 238 AssertMsg (it != vrdpAuthTypes.end(), ("No value for {%s}", s.latin1())); 231 239 return CEnums::VRDPAuthType (it - vrdpAuthTypes.begin()); 240 } 241 242 CEnums::USBDeviceFilterAction toUSBDevFilterAction (const QString &s) const 243 { 244 QStringVector::const_iterator it = 245 qFind (usbFilterActionTypes.begin(), usbFilterActionTypes.end(), s); 246 AssertMsg (it != usbFilterActionTypes.end(), ("No value for {%s}", s.latin1())); 247 return CEnums::USBDeviceFilterAction (it - usbFilterActionTypes.begin()); 232 248 } 233 249 … … 464 480 QStringVector diskStorageTypes; 465 481 QStringVector vrdpAuthTypes; 482 QStringVector usbFilterActionTypes; 466 483 QStringVector diskControllerDevices; 467 484 QStringVector audioDriverTypes; … … 477 494 inline VBoxGlobal &vboxGlobal() { return VBoxGlobal::instance(); } 478 495 496 497 /** 498 * USB Popup Menu class. 499 * This class provides the list of USB devices attached to the host. 500 */ 501 class VBoxUSBMenu : public QPopupMenu 502 { 503 Q_OBJECT 504 505 public: 506 507 enum { USBDevicesMenuNoDevicesId = 1 }; 508 509 VBoxUSBMenu (QWidget *aParent) : QPopupMenu (aParent) 510 { 511 connect (this, SIGNAL (aboutToShow()), 512 this, SLOT (processAboutToShow())); 513 connect (this, SIGNAL (highlighted (int)), 514 this, SLOT (processHighlighted (int))); 515 } 516 517 const CUSBDevice& getUSB (int aIndex) 518 { 519 return usbDevicesMap [aIndex]; 520 } 521 522 private slots: 523 524 void processAboutToShow() 525 { 526 clear(), usbDevicesMap.clear(); 527 CHost host = vboxGlobal().virtualBox().GetHost(); 528 529 bool isUSBEmpty = host.GetUSBDevices().GetCount() == 0; 530 if (isUSBEmpty) 531 { 532 insertItem ( 533 tr ("<no available devices>", "USB devices"), 534 USBDevicesMenuNoDevicesId); 535 setItemEnabled (USBDevicesMenuNoDevicesId, false); 536 } 537 else 538 { 539 CHostUSBDeviceEnumerator en = host.GetUSBDevices().Enumerate(); 540 while (en.HasMore()) 541 { 542 CHostUSBDevice iterator = en.GetNext(); 543 CUSBDevice usb = CUnknown (iterator); 544 int id = insertItem (vboxGlobal().details (usb)); 545 usbDevicesMap [id] = usb; 546 } 547 } 548 } 549 550 void processHighlighted (int aIndex) 551 { 552 /* the <no available devices> item is highlighted */ 553 if (aIndex == USBDevicesMenuNoDevicesId) 554 { 555 QToolTip::add (this, 556 tr ("No supported devices connected to the host PC", 557 "USB device tooltip")); 558 return; 559 } 560 561 CUSBDevice usb = usbDevicesMap [aIndex]; 562 /* if null then some other item but a USB device is highlighted */ 563 if (usb.isNull()) 564 { 565 QToolTip::remove (this); 566 return; 567 } 568 569 QToolTip::remove (this); 570 QToolTip::add (this, vboxGlobal().toolTip (usb)); 571 } 572 573 private: 574 575 QMap <int, CUSBDevice> usbDevicesMap; 576 }; 577 479 578 #endif /* __VBoxGlobal_h__ */ 480
Note:
See TracChangeset
for help on using the changeset viewer.