Changeset 4202 in vbox
- Timestamp:
- Aug 17, 2007 11:34:46 AM (17 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h
r4201 r4202 98 98 void additionsStateChanged (const QString &, bool, bool); 99 99 void mediaChanged (VBoxDefs::DiskType aType); 100 void networkStateChange(); 101 void usbStateChange(); 100 102 void sharedFoldersChanged(); 101 103 -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h
r4201 r4202 48 48 class VBoxUSBMenu; 49 49 class VBoxSwitchMenu; 50 class VBoxUSBLedTip;51 class VBoxNetworkLedTip;52 50 53 51 class VBoxConsoleWnd : public QMainWindow … … 170 168 void updateMouseState (int state); 171 169 void updateAdditionsState (const QString&, bool, bool); 170 void updateNetworkAdarptersState(); 171 void updateUsbState(); 172 172 void updateMediaState (VBoxDefs::DiskType aType); 173 173 void updateSharedFoldersState(); … … 272 272 QHBox *hostkey_hbox; 273 273 QLabel *hostkey_name; 274 275 VBoxUSBLedTip *mUsbLedTip;276 VBoxNetworkLedTip *mNetworkLedTip;277 274 278 275 QTimer *idle_timer; -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxDefs.h
r4201 r4202 134 134 SessionStateChangeEventType, 135 135 SnapshotEventType, 136 NetworkAdapterChangeEventType, 137 USBCtlStateChangeEventType, 136 138 USBDeviceStateChangeEventType, 137 139 SharedFolderChangeEventType, -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r4201 r4202 250 250 : QEvent ((QEvent::Type) VBoxDefs::MediaChangeEventType) 251 251 , mType (aType) {} 252 VBoxDefs::DiskType type() const { return mType; }252 VBoxDefs::DiskType diskType() const { return mType; } 253 253 private: 254 254 VBoxDefs::DiskType mType; … … 300 300 }; 301 301 302 /** Network adapter change event */ 303 class NetworkAdapterChangeEvent : public QEvent 304 { 305 public: 306 NetworkAdapterChangeEvent (INetworkAdapter *aAdapter) : 307 QEvent ((QEvent::Type) VBoxDefs::NetworkAdapterChangeEventType), 308 mAdapter (aAdapter) {} 309 INetworkAdapter* networkAdapter() { return mAdapter; } 310 private: 311 INetworkAdapter *mAdapter; 312 }; 313 314 /** USB controller state change event */ 315 class USBControllerStateChangeEvent : public QEvent 316 { 317 public: 318 USBControllerStateChangeEvent() 319 : QEvent ((QEvent::Type) VBoxDefs::USBCtlStateChangeEventType) {} 320 }; 321 302 322 /** USB device state change event */ 303 323 class USBDeviceStateChangeEvent : public QEvent … … 432 452 STDMETHOD(OnNetworkAdapterChange) (INetworkAdapter *aNetworkAdapter) 433 453 { 454 QApplication::postEvent (mView, 455 new NetworkAdapterChangeEvent (aNetworkAdapter)); 434 456 return S_OK; 435 457 } … … 452 474 STDMETHOD(OnUSBControllerChange)() 453 475 { 476 QApplication::postEvent (mView, 477 new USBControllerStateChangeEvent()); 454 478 return S_OK; 455 479 } … … 1000 1024 1001 1025 /* report to the VM thread that we finished resizing */ 1002 cconsole.GetDisplay().ResizeCompleted (0);1026 cconsole.GetDisplay().ResizeCompleted (0); 1003 1027 1004 1028 mIgnoreMainwndResize = oldIgnoreMainwndResize; … … 1109 1133 LogFlowFunc (("MediaChangeEvent\n")); 1110 1134 1111 emit mediaChanged (mce-> type());1135 emit mediaChanged (mce->diskType()); 1112 1136 return true; 1113 1137 } … … 1133 1157 } 1134 1158 1159 case VBoxDefs::NetworkAdapterChangeEventType: 1160 { 1161 /* no specific adapter information stored in this 1162 * event is currently used */ 1163 emit networkStateChange(); 1164 return true; 1165 } 1166 1167 case VBoxDefs::USBCtlStateChangeEventType: 1168 { 1169 emit usbStateChange(); 1170 return true; 1171 } 1172 1135 1173 case VBoxDefs::USBDeviceStateChangeEventType: 1136 1174 { … … 1151 1189 } 1152 1190 1191 emit usbStateChange(); 1153 1192 /// @todo update menu entries 1154 1193 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
r4201 r4202 52 52 #include <iprt/param.h> 53 53 #include <iprt/path.h> 54 55 /** class VBoxUSBLedTip56 *57 * The VBoxUSBLedTip class is an auxiliary ToolTip class58 * for the USB LED indicator.59 */60 class VBoxUSBLedTip : public QToolTip61 {62 public:63 64 VBoxUSBLedTip (QWidget *aWidget, const CConsole &aConsole, bool aUSBEnabled) :65 QToolTip (aWidget), mConsole (aConsole), mUSBEnabled (aUSBEnabled) {}66 67 ~VBoxUSBLedTip() { remove (parentWidget()); }68 69 bool isUSBEnabled() const { return mUSBEnabled; }70 71 protected:72 73 void maybeTip (const QPoint &/* aPoint */)74 {75 QString ttip = VBoxConsoleWnd::tr (76 "<qt><nobr>Indicates the activity of "77 "attached USB devices:</nobr>"78 "%1</qt>",79 "USB device indicator");80 81 QString info;82 83 if (mUSBEnabled)84 {85 CUSBDeviceEnumerator en = mConsole.GetUSBDevices().Enumerate();86 while (en.HasMore())87 {88 CUSBDevice usb = en.GetNext();89 info += QString ("<br><b><nobr>%1</nobr></b>")90 .arg (vboxGlobal().details (usb));91 }92 if (info.isNull())93 info = VBoxConsoleWnd::tr ("<br><nobr><b>No USB devices attached</b></nobr>",94 "USB device indicator");95 }96 else97 info = VBoxConsoleWnd::tr ("<br><nobr><b>USB Controller is disabled</b></nobr>",98 "USB device indicator");99 100 tip (parentWidget()->rect(), ttip.arg (info));101 }102 103 private:104 105 CConsole mConsole;106 bool mUSBEnabled;107 };108 109 /** class VBoxNetworkLedTip110 *111 * The VBoxNetworkLedTip class is an auxiliary ToolTip class112 * for the Network LED indicator.113 */114 class VBoxNetworkLedTip : public QToolTip115 {116 public:117 118 VBoxNetworkLedTip (QWidget *aWidget, const CMachine &aMachine) :119 QToolTip (aWidget), mMachine (aMachine) {}120 121 ~VBoxNetworkLedTip() { remove (parentWidget()); }122 123 protected:124 125 void maybeTip (const QPoint &/* aPoint */)126 {127 QString ttip = VBoxConsoleWnd::tr (128 "<qt><nobr>Indicates the activity of the network interfaces:</nobr>"129 "%1</qt>",130 "Network adapters indicator");131 132 QString info;133 134 ulong count = vboxGlobal().virtualBox().GetSystemProperties().GetNetworkAdapterCount();135 for (ulong slot = 0; slot < count; ++ slot)136 {137 CNetworkAdapter adapter = mMachine.GetNetworkAdapter (slot);138 if (adapter.GetEnabled())139 info += VBoxConsoleWnd::tr ("<br><nobr><b>Adapter %1 (%2)</b>: cable %3</nobr>",140 "Network adapters indicator")141 .arg (slot)142 .arg (vboxGlobal().toString (adapter.GetAttachmentType()))143 .arg (adapter.GetCableConnected() ?144 VBoxConsoleWnd::tr ("connected", "Network adapters indicator") :145 VBoxConsoleWnd::tr ("disconnected", "Network adapters indicator"));146 }147 148 if (info.isNull())149 info = VBoxConsoleWnd::tr ("<br><nobr><b>All network adapters are disabled</b></nobr>",150 "Network adapters indicator");151 152 tip (parentWidget()->rect(), ttip.arg (info));153 }154 155 private:156 157 CMachine mMachine;158 };159 54 160 55 /** class StatusTipEvent … … 209 104 #endif 210 105 , console (0) 211 , mUsbLedTip (0)212 , mNetworkLedTip (0)213 106 , machine_state (CEnums::InvalidMachineState) 214 107 , no_auto_close (false) … … 660 553 VBoxConsoleWnd::~VBoxConsoleWnd() 661 554 { 662 if (mUsbLedTip)663 delete mUsbLedTip;664 if (mNetworkLedTip)665 delete mNetworkLedTip;666 555 #ifdef Q_WS_MAC 667 556 /* release the dock images */ … … 816 705 usb_light->setState (isUSBEnabled ? CEnums::DeviceIdle 817 706 : CEnums::InvalidActivity); 818 mUsbLedTip = new VBoxUSBLedTip (usb_light, cconsole, isUSBEnabled); 819 } 820 821 /* initialize network stuff */ 822 mNetworkLedTip = new VBoxNetworkLedTip (net_light, cmachine); 707 } 823 708 824 709 /* initialize vrdp stuff */ … … 858 743 connect (console, SIGNAL (mediaChanged (VBoxDefs::DiskType)), 859 744 this, SLOT (updateMediaState (VBoxDefs::DiskType))); 745 connect (console, SIGNAL (usbStateChange()), 746 this, SLOT (updateUsbState())); 747 connect (console, SIGNAL (networkStateChange()), 748 this, SLOT (updateNetworkAdarptersState())); 860 749 connect (console, SIGNAL (sharedFoldersChanged()), 861 750 this, SLOT (updateSharedFoldersState())); … … 1698 1587 net_light->setState (count > 0 ? CEnums::DeviceIdle 1699 1588 : CEnums::InvalidActivity); 1589 1590 /* update tooltip */ 1591 QString ttip = VBoxConsoleWnd::tr ( 1592 "<qt><nobr>Indicates the activity of the network interfaces:</nobr>" 1593 "%1</qt>", 1594 "Network adapters indicator"); 1595 QString info; 1596 1597 for (ulong slot = 0; slot < maxCount; ++ slot) 1598 { 1599 CNetworkAdapter adapter = cmachine.GetNetworkAdapter (slot); 1600 if (adapter.GetEnabled()) 1601 info += VBoxConsoleWnd::tr ("<br><nobr><b>Adapter %1 (%2)</b>: cable %3</nobr>", 1602 "Network adapters indicator") 1603 .arg (slot) 1604 .arg (vboxGlobal().toString (adapter.GetAttachmentType())) 1605 .arg (adapter.GetCableConnected() ? 1606 VBoxConsoleWnd::tr ("connected", "Network adapters indicator") : 1607 VBoxConsoleWnd::tr ("disconnected", "Network adapters indicator")); 1608 } 1609 1610 if (info.isNull()) 1611 info = VBoxConsoleWnd::tr ("<br><nobr><b>All network adapters are disabled</b></nobr>", 1612 "Network adapters indicator"); 1613 1614 QToolTip::add (net_light, ttip.arg (info)); 1700 1615 } 1701 1616 if (element & USBStuff) … … 1703 1618 /// @todo (r=dmik) do we really need to disable the control while 1704 1619 // in Pause? Check the same for CD/DVD above. 1705 if (mUsbLedTip && mUsbLedTip->isUSBEnabled()) 1620 if (!usb_light->isHidden()) 1621 { 1706 1622 devicesUSBMenu->setEnabled (machine_state == CEnums::Running); 1623 1624 /* update tooltip */ 1625 QString ttip = VBoxConsoleWnd::tr ( 1626 "<qt><nobr>Indicates the activity of " 1627 "attached USB devices:</nobr>" 1628 "%1</qt>", 1629 "USB device indicator"); 1630 QString info; 1631 1632 if (cmachine.GetUSBController().GetEnabled()) 1633 { 1634 CUSBDeviceEnumerator en = cconsole.GetUSBDevices().Enumerate(); 1635 while (en.HasMore()) 1636 { 1637 CUSBDevice usb = en.GetNext(); 1638 info += QString ("<br><b><nobr>%1</nobr></b>") 1639 .arg (vboxGlobal().details (usb)); 1640 } 1641 if (info.isNull()) 1642 info = VBoxConsoleWnd::tr ("<br><nobr><b>No USB devices attached</b></nobr>", 1643 "USB device indicator"); 1644 } 1645 else 1646 info = VBoxConsoleWnd::tr ("<br><nobr><b>USB Controller is disabled</b></nobr>", 1647 "USB device indicator"); 1648 1649 QToolTip::add (usb_light, ttip.arg (info)); 1650 } 1707 1651 } 1708 1652 if (element & VRDPStuff) … … 2942 2886 } 2943 2887 2888 void VBoxConsoleWnd::updateUsbState() 2889 { 2890 updateAppearanceOf (USBStuff); 2891 } 2892 2893 void VBoxConsoleWnd::updateNetworkAdarptersState() 2894 { 2895 updateAppearanceOf (NetworkStuff); 2896 } 2897 2944 2898 /** 2945 2899 * Helper to safely close the main console window.
Note:
See TracChangeset
for help on using the changeset viewer.