Changeset 281 in vbox
- Timestamp:
- Jan 24, 2007 4:42:35 PM (18 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h
r263 r281 202 202 devicesMountDVDMenuId, 203 203 devicesUSBMenuId, 204 devicesUSBMenuNoDevicesId, 204 205 #ifdef VBOX_WITH_DEBUGGER_GUI 205 206 dbgMenuId, -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h
r253 r281 278 278 } 279 279 280 QString toString (CEnums::USBDeviceState aState) const 281 { 282 AssertMsg (!USBDeviceStates [aState].isNull(), ("No text for %d", aState)); 283 return USBDeviceStates [aState]; 284 } 285 280 286 QPixmap snapshotIcon (bool online) const 281 287 { … … 283 289 } 284 290 285 / / details generators291 /* details generators */ 286 292 287 293 QString details (const CHardDisk &aHD, bool aPredict = false) const; 288 294 295 QString details (const CUSBDevice &aDevice) const; 296 QString toolTip (const CUSBDevice &aDevice) const; 297 289 298 QString prepareFileNameForHTML (const QString &fn) const; 290 299 291 300 QString detailsReport (const CMachine &m, bool isNewVM, bool withLinks) const; 292 301 293 / / VirtualBox helpers302 /* VirtualBox helpers */ 294 303 295 304 CSession openSession (const QUuid &id); … … 304 313 VBoxMediaList currentMediaList() const { return media_list; } 305 314 306 / / various helpers315 /* various helpers */ 307 316 308 317 void languageChange(); 309 318 310 void cleanup(); // made public for internal purposes 311 312 // public static stuff 319 /* made public for internal purposes */ 320 void cleanup(); 321 322 /* public static stuff */ 313 323 314 324 static QIconSet iconSet (const char *aNormal, … … 345 355 void mediaEnumerated (const VBoxMediaList &list); 346 356 347 / /signals emitted when the VirtualBox callback is called by the server348 //(not that currently these signals are emitted only when the application349 // is the in the VM selector mode)357 /* signals emitted when the VirtualBox callback is called by the server 358 * (not that currently these signals are emitted only when the application 359 * is the in the VM selector mode) */ 350 360 351 361 void machineStateChanged (const VBoxMachineStateChangeEvent &e); … … 414 424 QStringVector audioDriverTypes; 415 425 QStringVector networkAttachmentTypes; 426 QStringVector USBDeviceStates; 416 427 417 428 mutable bool detailReportTemplatesReady; … … 423 434 inline VBoxGlobal &vboxGlobal() { return VBoxGlobal::instance(); } 424 435 425 #endif / / __VBoxGlobal_h__426 436 #endif /* __VBoxGlobal_h__ */ 437 -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h
r237 r281 180 180 #endif 181 181 182 void cannotAttachUSBDevice (const CConsole &console, const QString &device); 183 void cannotDetachUSBDevice (const CConsole &console, const QString &device); 184 182 185 bool confirmReleaseImage (QWidget*, QString); 183 186 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
r263 r281 71 71 public: 72 72 73 VBoxUSBLedTip (QWidget *aWidget, const CSession &aSession) : 74 QToolTip (aWidget), mSession (aSession) {} 73 VBoxUSBLedTip (QWidget *aWidget, const CConsole &aConsole, bool aUSBEnabled) : 74 QToolTip (aWidget), mConsole (aConsole), mUSBEnabled (aUSBEnabled) {} 75 75 76 ~VBoxUSBLedTip() { remove (parentWidget()); } 76 77 77 78 protected: 78 79 79 80 void maybeTip (const QPoint &/* aPoint */) 80 81 { 81 CUSBDeviceEnumerator en = mSession.GetConsole().GetUSBDevices().Enumerate(); 82 QString toolTip = VBoxConsoleWnd::tr ( 83 "<qt>Indicates the activity of " 84 "attached USB devices<br>" 85 "%1</qt>", 86 "USB device indicator"); 87 82 88 QString devices; 83 while (en.HasMore()) 84 { 85 CUSBDevice usb = en.GetNext(); 86 devices += QString ("[<b><nobr>%1 %2 (%3)</nobr></b>]<br>") 87 .arg (usb.GetManufacturer()) 88 .arg (usb.GetProduct()) 89 .arg (usb.GetRevision()); 90 } 91 QString toolTip = QObject::tr ( 92 "<qt>Indicates the activity of " 93 "the attached USB devices" 94 "<br>%1</qt>" 95 ); 96 if (devices.isNull()) 97 devices += QObject::tr ("[<b>not attached</b>]"); 89 90 if (mUSBEnabled) 91 { 92 CUSBDeviceEnumerator en = mConsole.GetUSBDevices().Enumerate(); 93 while (en.HasMore()) 94 { 95 CUSBDevice usb = en.GetNext(); 96 devices += QString ("[<b><nobr>%1</nobr></b>]<br>") 97 .arg (vboxGlobal().details (usb)); 98 } 99 if (devices.isNull()) 100 devices = VBoxConsoleWnd::tr ("<nobr>[<b>not attached</b>]</nobr>", 101 "USB device indicator"); 102 } 103 else 104 devices = VBoxConsoleWnd::tr ("<nobr>[<b>USB Controller is disabled</b>]</nobr>", 105 "USB device indicator"); 106 98 107 tip (parentWidget()->rect(), toolTip.arg (devices)); 99 108 } 100 109 101 const CSession &mSession; 110 private: 111 112 CConsole mConsole; 113 bool mUSBEnabled; 102 114 }; 103 115 … … 293 305 devicesMenu->insertItem (VBoxGlobal::iconSet ("usb_16px.png", "usb_disabled_16px.png"), 294 306 QString::null, devicesUSBMenu, devicesUSBMenuId); 307 devicesMenu->insertSeparator(); 295 308 devicesInstallGuestToolsAction->addTo (devicesMenu); 296 309 menuBar()->insertItem (QString::null, devicesMenu, devicesMenuId); … … 451 464 VBoxConsoleWnd::~VBoxConsoleWnd() 452 465 { 453 delete mUsbLedTip; 466 if (mUsbLedTip) 467 delete mUsbLedTip; 454 468 } 455 469 … … 561 575 562 576 /* initialize usb stuff */ 563 bool isUsbAvailable = cmachine.GetUSBController().GetEnabled(); 564 devicesMenu->setItemVisible (devicesUSBMenuId, isUsbAvailable); 565 mUsbLedTip = new VBoxUSBLedTip (usb_light, csession); 577 bool isUSBEnabled = cmachine.GetUSBController().GetEnabled(); 578 devicesUSBMenu->setEnabled (isUSBEnabled); 579 usb_light->setState (CEnums::InvalidActivity); 580 mUsbLedTip = new VBoxUSBLedTip (usb_light, cconsole, isUSBEnabled); 566 581 567 582 /* start an idle timer that will update device lighths */ … … 1778 1793 1779 1794 devicesUSBMenu->clear(); 1795 hostUSBMap.clear(); 1796 1780 1797 CHost host = vboxGlobal().virtualBox().GetHost(); 1781 1798 … … 1783 1800 if (isUSBEmpty) 1784 1801 { 1785 int id = devicesUSBMenu->insertItem (tr ("[No device attached to host]")); 1786 devicesUSBMenu->setItemEnabled (id, !isUSBEmpty); 1802 devicesUSBMenu->insertItem ( 1803 tr ("<no available devices>", "USB devices"), 1804 devicesUSBMenuNoDevicesId); 1805 devicesUSBMenu->setItemEnabled (devicesUSBMenuNoDevicesId, false); 1787 1806 return; 1788 1807 } … … 1793 1812 CHostUSBDevice iterator = en.GetNext(); 1794 1813 CUSBDevice usb = CUnknown (iterator); 1795 int id = devicesUSBMenu->insertItem (QString ("%1 %2 [%3]") 1796 .arg (usb.GetManufacturer()) 1797 .arg (usb.GetProduct()) 1798 .arg (usb.GetRevision())); 1814 int id = devicesUSBMenu->insertItem (vboxGlobal().details (usb)); 1799 1815 hostUSBMap [id] = usb; 1800 1816 CUSBDevice attachedUSB = … … 1859 1875 if (!console) return; 1860 1876 1877 CConsole cconsole = csession.GetConsole(); 1878 AssertWrapperOk (csession); 1879 1880 /* the <no available devices> item should be always disabled */ 1881 AssertReturnVoid (id != devicesUSBMenuNoDevicesId); 1882 1861 1883 CUSBDevice usb = hostUSBMap [id]; 1862 /* if null then some other item but usb device is selected */ 1863 if (usb.isNull()) return; 1884 /* if null then some other item but a USB device is selected */ 1885 if (usb.isNull()) 1886 return; 1864 1887 1865 1888 if (devicesUSBMenu->isItemChecked (id)) 1866 csession.GetConsole().DetachUSBDevice (usb.GetId()); 1889 { 1890 cconsole.DetachUSBDevice (usb.GetId()); 1891 if (!cconsole.isOk()) 1892 { 1893 /// @todo (r=dmik) the dialog should be either modeless 1894 // or we have to pause the VM 1895 vboxProblem().cannotDetachUSBDevice (cconsole, 1896 vboxGlobal().details (usb)); 1897 } 1898 } 1867 1899 else 1868 csession.GetConsole().AttachUSBDevice (usb.GetId()); 1900 { 1901 cconsole.AttachUSBDevice (usb.GetId()); 1902 if (!cconsole.isOk()) 1903 { 1904 /// @todo (r=dmik) the dialog should be either modeless 1905 // or we have to pause the VM 1906 vboxProblem().cannotAttachUSBDevice (cconsole, 1907 vboxGlobal().details (usb)); 1908 } 1909 } 1869 1910 } 1870 1911 … … 1876 1917 if (!console) return; 1877 1918 1919 /* the <no available devices> item is highlighted */ 1920 if (id == devicesUSBMenuNoDevicesId) 1921 { 1922 QToolTip::add (devicesUSBMenu, 1923 tr ("No supported devices connected to the host PC", 1924 "USB device tooltip")); 1925 return; 1926 } 1927 1878 1928 CUSBDevice usb = hostUSBMap [id]; 1879 /* if null then some other item but usb device is selected */ 1880 if (usb.isNull()) return; 1881 1882 QString tip = tr ("Vendor ID: %1\nProduct ID: %2\nSerial Number: %3") 1883 .arg (usb.GetVendorId()).arg (usb.GetProductId()).arg (usb.GetSerialNumber()); 1884 QToolTip::remove (devicesUSBMenu); 1929 /* if null then some other item but a USB device is highlighted */ 1930 if (usb.isNull()) 1931 { 1932 QToolTip::remove (devicesUSBMenu); 1933 return; 1934 } 1935 1936 QString tip = vboxGlobal().toolTip (usb); 1937 1885 1938 QToolTip::add (devicesUSBMenu, tip); 1886 1939 } … … 1890 1943 if (ind == cd_light) 1891 1944 { 1892 / / set "this is a context menu" flag1945 /* set "this is a context menu" flag */ 1893 1946 devicesMenu->setItemParameter (devicesMountDVDMenuId, 1); 1894 1947 devicesMountDVDMenu->exec (e->globalPos()); … … 1898 1951 if (ind == fd_light) 1899 1952 { 1900 / / set "this is a context menu" flag1953 /* set "this is a context menu" flag */ 1901 1954 devicesMenu->setItemParameter (devicesMountFloppyMenuId, 1); 1902 1955 devicesMountFloppyMenu->exec (e->globalPos()); … … 1906 1959 if (ind == usb_light) 1907 1960 { 1908 // set "this is a context menu" flag 1909 devicesMenu->setItemParameter (devicesUSBMenuId, 1); 1910 devicesUSBMenu->exec (e->globalPos()); 1911 devicesMenu->setItemParameter (devicesUSBMenuId, 0); 1961 if (devicesUSBMenu->isEnabled()) 1962 { 1963 /* set "this is a context menu" flag */ 1964 devicesMenu->setItemParameter (devicesUSBMenuId, 1); 1965 devicesUSBMenu->exec (e->globalPos()); 1966 devicesMenu->setItemParameter (devicesUSBMenuId, 0); 1967 } 1912 1968 } 1913 1969 } -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp
r168 r281 329 329 , audioDriverTypes (CEnums::AudioDriverType_COUNT) 330 330 , networkAttachmentTypes (CEnums::NetworkAttachmentType_COUNT) 331 , USBDeviceStates (CEnums::USBDeviceState_COUNT) 331 332 , detailReportTemplatesReady (false) 332 333 { … … 588 589 589 590 return details; 591 } 592 593 /** 594 * Returns the details of the given USB device as a single-line string. 595 */ 596 QString VBoxGlobal::details (const CUSBDevice &aDevice) const 597 { 598 QString details; 599 QString m = aDevice.GetManufacturer(); 600 QString p = aDevice.GetProduct(); 601 if (m.isEmpty() && p.isEmpty()) 602 details += QString().sprintf ( 603 tr ("Unknown device %04hX:%04hX", "USB device details"), 604 aDevice.GetVendorId(), aDevice.GetProductId()); 605 else 606 { 607 if (!m.isEmpty()) 608 details += m; 609 if (!p.isEmpty()) 610 details += " " + p; 611 } 612 ushort r = aDevice.GetRevision(); 613 if (r != 0) 614 details += QString().sprintf (" [%04hX]", r); 615 616 return details; 617 } 618 619 /** 620 * Returns the multi-line description of the given USB device. 621 */ 622 QString VBoxGlobal::toolTip (const CUSBDevice &aDevice) const 623 { 624 QString tip = QString().sprintf ( 625 tr ("<nobr>Vendor ID: %04hX</nobr><br>" 626 "<nobr>Product ID: %04hX</nobr><br>" 627 "<nobr>Revision: %04hX</nobr>", "USB device tooltip"), 628 aDevice.GetVendorId(), aDevice.GetProductId(), 629 aDevice.GetRevision()); 630 631 QString ser = aDevice.GetSerialNumber(); 632 if (!ser.isEmpty()) 633 tip += QString (tr ("<br><nobr>Serial No. %1</nobr>", "USB device tooltip")) 634 .arg (ser); 635 636 /* add the state field if it's a host USB device */ 637 CHostUSBDevice hostDev = CUnknown (aDevice); 638 if (!hostDev.isNull()) 639 { 640 tip += QString (tr ("<br><nobr>State: %1</nobr>", "USB device tooltip")) 641 .arg (vboxGlobal().toString (hostDev.GetState())); 642 } 643 644 return tip; 590 645 } 591 646 … … 1164 1219 networkAttachmentTypes [CEnums::HostInterfaceNetworkAttachment] = 1165 1220 tr ("Host Interface", "NetworkAttachmentType"); 1221 1222 USBDeviceStates [CEnums::USBDeviceNotSupported] = 1223 tr ("Not supported", "USBDeviceState"); 1224 USBDeviceStates [CEnums::USBDeviceUnavailable] = 1225 tr ("Unavailable", "USBDeviceState"); 1226 USBDeviceStates [CEnums::USBDeviceBusy] = 1227 tr ("Busy", "USBDeviceState"); 1228 USBDeviceStates [CEnums::USBDeviceAvailable] = 1229 tr ("Available", "USBDeviceState"); 1230 USBDeviceStates [CEnums::USBDeviceHeld] = 1231 tr ("Held", "USBDeviceState"); 1232 USBDeviceStates [CEnums::USBDeviceCaptured] = 1233 tr ("Captured", "USBDeviceState"); 1166 1234 1167 1235 detailReportTemplatesReady = false; -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp
r237 r281 1101 1101 #endif 1102 1102 1103 void VBoxProblemReporter::cannotAttachUSBDevice (const CConsole &console, 1104 const QString &device) 1105 { 1106 /* preserve the current error info before calling the object again */ 1107 COMErrorInfo errInfo = console.errorInfo(); 1108 1109 message (&vboxGlobal().consoleWnd(), Error, 1110 tr ("Failed to attach the USB device <b>%1</b> " 1111 "to the virtual machine <b>%2</b>.") 1112 .arg (device) 1113 .arg (console.GetMachine().GetName()), 1114 formatErrorInfo (errInfo)); 1115 } 1116 1117 void VBoxProblemReporter::cannotDetachUSBDevice (const CConsole &console, 1118 const QString &device) 1119 { 1120 /* preserve the current error info before calling the object again */ 1121 COMErrorInfo errInfo = console.errorInfo(); 1122 1123 message (&vboxGlobal().consoleWnd(), Error, 1124 tr ("Failed to detach the USB device <b>%1</b> " 1125 "from the virtual machine <b>%2</b>.") 1126 .arg (device) 1127 .arg (console.GetMachine().GetName()), 1128 formatErrorInfo (errInfo)); 1129 } 1130 1103 1131 /** @return false if the dialog wasn't actually shown (i.e. it was autoconfirmed) */ 1104 1132 bool VBoxProblemReporter::remindAboutInputCapture() … … 1288 1316 console.Pause(); 1289 1317 type = Critical; 1290 severity = tr (" Fatal Error", "runtime error info");1318 severity = tr ("<nobr>Fatal Error</nobr>", "runtime error info"); 1291 1319 } 1292 1320 else if (state == CEnums::Paused) 1293 1321 { 1294 1322 type = Error; 1295 severity = tr (" Non-Fatal Error", "runtime error info");1323 severity = tr ("<nobr>Non-Fatal Error</nobr>", "runtime error info"); 1296 1324 } 1297 1325 else 1298 1326 { 1299 1327 type = Warning; 1300 severity = tr (" Warning", "runtime error info");1328 severity = tr ("<nobr>Warning</nobr>", "runtime error info"); 1301 1329 } 1302 1330 … … 1316 1344 "<tr><td>%3</td><td>%4</td></tr>" 1317 1345 "</table>") 1318 .arg (tr (" Error ID:", "runtime error info"),1346 .arg (tr ("<nobrl>Error ID: </nobr>", "runtime error info"), 1319 1347 errorID) 1320 .arg (tr (" ErrorSeverity: ", "runtime error info"),1348 .arg (tr ("Severity: ", "runtime error info"), 1321 1349 severity); 1322 1350
Note:
See TracChangeset
for help on using the changeset viewer.