- Timestamp:
- May 3, 2007 9:34:13 AM (18 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h
r2412 r2458 40 40 # undef PAGE_SHIFT 41 41 # include <Carbon/Carbon.h> 42 #endif 42 #endif 43 43 44 44 class QAction; … … 53 53 class VBoxSwitchMenu; 54 54 class VBoxUSBLedTip; 55 class VBoxNetworkLedTip; 55 56 56 57 class VBoxConsoleWnd : public QMainWindow … … 140 141 void prepareDVDMenu(); 141 142 143 void prepareNetworkMenu(); 144 void activateNetworkMenu (int); 145 142 146 void captureFloppy (int id); 143 147 void captureDVD (int id); … … 207 211 QPopupMenu *devicesMountDVDMenu; 208 212 QPopupMenu *devicesSharedFolders; 213 QPopupMenu *devicesNetworkMenu; 209 214 VBoxUSBMenu *devicesUSBMenu; 210 215 VBoxSwitchMenu *devicesVRDPMenu; … … 226 231 devicesMountDVDMenuId, 227 232 devicesUSBMenuId, 233 devicesNetworkMenuId, 228 234 #ifdef VBOX_WITH_DEBUGGER_GUI 229 235 dbgMenuId, … … 245 251 246 252 VBoxUSBLedTip *mUsbLedTip; 253 VBoxNetworkLedTip *mNetworkLedTip; 247 254 248 255 QTimer *idle_timer; … … 280 287 CGImageRef dockImgBack100x75; 281 288 CGImageRef dockImgOS; 282 #endif 289 #endif 283 290 }; 284 291 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
r2423 r2458 119 119 }; 120 120 121 /** class VBoxNetworkLedTip 122 * 123 * The VBoxNetworkLedTip class is an auxiliary ToolTip class 124 * for the Network LED indicator. 125 */ 126 class VBoxNetworkLedTip : public QToolTip 127 { 128 public: 129 130 VBoxNetworkLedTip (QWidget *aWidget, const CMachine &aMachine) : 131 QToolTip (aWidget), mMachine (aMachine) {} 132 133 ~VBoxNetworkLedTip() { remove (parentWidget()); } 134 135 protected: 136 137 void maybeTip (const QPoint &/* aPoint */) 138 { 139 QString toolTip = VBoxConsoleWnd::tr ( 140 "<qt>Indicates the activity of the network interfaces", 141 "Network adapters indicator" 142 ); 143 144 QString devices; 145 146 ulong count = vboxGlobal().virtualBox().GetSystemProperties().GetNetworkAdapterCount(); 147 for (ulong slot = 0; slot < count; ++ slot) 148 { 149 CNetworkAdapter adapter = mMachine.GetNetworkAdapter (slot); 150 if (adapter.GetEnabled()) 151 devices += VBoxConsoleWnd::tr ("<br><nobr>[Adapter %1 (%2): cable %3]</nobr>", 152 "Network adapters indicator") 153 .arg (slot) 154 .arg (vboxGlobal().toString (adapter.GetAttachmentType())) 155 .arg (adapter.GetCableConnected() ? 156 VBoxConsoleWnd::tr ("connected", "Network adapters indicator") : 157 VBoxConsoleWnd::tr ("disconnected", "Network adapters indicator")); 158 } 159 160 if (devices.isNull()) 161 devices = VBoxConsoleWnd::tr ("<br><nobr>[<b>All Network adapters are disabled</b>]</nobr>", 162 "Network adapters indicator"); 163 164 tip (parentWidget()->rect(), toolTip + devices); 165 } 166 167 private: 168 169 CMachine mMachine; 170 }; 171 121 172 /** \class VBoxConsoleWnd 122 173 * … … 147 198 , console (0) 148 199 , mUsbLedTip (0) 200 , mNetworkLedTip (0) 149 201 , machine_state (CEnums::InvalidMachineState) 150 202 , no_auto_close (false) … … 164 216 , dockImgBack100x75 (NULL) 165 217 , dockImgOS (NULL) 166 #endif 218 #endif 167 219 { 168 220 if (aSelf) … … 325 377 326 378 devicesSharedFolders = new QPopupMenu (devicesMenu, "devicesSharedFolders"); 379 devicesNetworkMenu = new QPopupMenu (devicesMenu, "devicesNetworkMenu"); 327 380 devicesUSBMenu = new VBoxUSBMenu (devicesMenu); 328 381 devicesVRDPMenu = new VBoxSwitchMenu (devicesMenu, devicesSwitchVrdpAction); … … 341 394 devicesSFDialogAction->addTo (devicesMenu); 342 395 devicesSFMenuSeparatorId = devicesMenu->insertSeparator(); 396 devicesMenu->insertItem (VBoxGlobal::iconSet ("nw_16px.png", "nw_disabled_16px.png"), 397 QString::null, devicesNetworkMenu, devicesNetworkMenuId); 398 devicesMenu->insertSeparator(); 343 399 devicesSwitchVrdpAction->addTo (devicesMenu); 344 400 devicesVRDPMenuSeparatorId = devicesMenu->insertSeparator(); … … 483 539 connect (devicesMountFloppyMenu, SIGNAL(aboutToShow()), this, SLOT(prepareFloppyMenu())); 484 540 connect (devicesMountDVDMenu, SIGNAL(aboutToShow()), this, SLOT(prepareDVDMenu())); 541 connect (devicesNetworkMenu, SIGNAL(aboutToShow()), this, SLOT(prepareNetworkMenu())); 485 542 486 543 connect (devicesMountFloppyMenu, SIGNAL(activated(int)), this, SLOT(captureFloppy(int))); … … 488 545 connect (devicesUSBMenu, SIGNAL(activated(int)), this, SLOT(switchUSB(int))); 489 546 connect (devicesSharedFolders, SIGNAL(activated(int)), this, SLOT(activateSFMenu())); 547 connect (devicesNetworkMenu, SIGNAL(activated(int)), this, SLOT(activateNetworkMenu(int))); 490 548 491 549 connect (helpWebAction, SIGNAL (activated()), … … 503 561 this, SLOT (showIndicatorContextMenu (QIStateIndicator *, QContextMenuEvent *))); 504 562 connect (sf_state, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)), 563 this, SLOT (showIndicatorContextMenu (QIStateIndicator *, QContextMenuEvent *))); 564 connect (net_light, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)), 505 565 this, SLOT (showIndicatorContextMenu (QIStateIndicator *, QContextMenuEvent *))); 506 566 … … 537 597 SetApplicationDockTileImage (dockImgOS); 538 598 OverlayApplicationDockTileImage (dockImgStateRunning); 539 #endif 599 #endif 540 600 } 541 601 … … 544 604 if (mUsbLedTip) 545 605 delete mUsbLedTip; 606 if (mNetworkLedTip) 607 delete mNetworkLedTip; 546 608 #ifdef Q_WS_MAC 547 609 /* release the dock images */ … … 560 622 if (dockImgOS) 561 623 CGImageRelease (dockImgOS); 562 #endif 624 #endif 563 625 } 564 626 … … 694 756 } 695 757 758 /* initialize network stuff */ 759 mNetworkLedTip = new VBoxNetworkLedTip (net_light, cmachine); 760 696 761 /* initialize vrdp stuff */ 697 762 CVRDPServer vrdpsrv = cmachine.GetVRDPServer(); … … 732 797 QImage osImg75x75 = vboxGlobal().vmGuestOSTypeIcon (osType).convertToImage().smoothScale (75, 75); 733 798 QImage osImg = QImage::fromMimeSource ("dock_0.png"); 734 bitBlt (&osImg, 25, 22, 799 bitBlt (&osImg, 25, 22, 735 800 &osImg75x75, 0, 0, 736 801 75, 75, /* conversion_flags */ 0); … … 738 803 QImage osImg100x75 = vboxGlobal().vmGuestOSTypeIcon (osType).convertToImage().smoothScale (100, 75); 739 804 QImage osImg = QImage::fromMimeSource ("dock_1.png"); 740 bitBlt (&osImg, 14, 22, 805 bitBlt (&osImg, 14, 22, 741 806 &osImg100x75, 0, 0, 742 807 100, 75, /* conversion_flags */ 0); 743 # endif 808 # endif 744 809 if (dockImgOS) 745 810 CGImageRelease (dockImgOS); … … 1307 1372 devicesMenu->changeItem (devicesMountFloppyMenuId, tr ("Mount &Floppy")); 1308 1373 devicesMenu->changeItem (devicesMountDVDMenuId, tr ("Mount &CD/DVD-ROM")); 1374 devicesMenu->changeItem (devicesNetworkMenuId, tr ("&Network Adapters")); 1309 1375 devicesMenu->changeItem (devicesUSBMenuId, tr ("&USB Devices")); 1310 1376 … … 1479 1545 net_light->setState (count > 0 ? CEnums::DeviceIdle 1480 1546 : CEnums::InvalidActivity); 1481 QString tip = tr (1482 "<qt>Indicates the activity of the network interfaces"1483 "<br>[<b>%1 adapter(s)</b>]</qt>"1484 );1485 QToolTip::add (net_light, tip.arg (count));1486 1547 } 1487 1548 if (element & USBStuff) … … 2067 2128 2068 2129 /** 2130 * Prepares the "Network adapter" menu by populating the existent adaptors. 2131 */ 2132 void VBoxConsoleWnd::prepareNetworkMenu() 2133 { 2134 devicesNetworkMenu->clear(); 2135 ulong count = vboxGlobal().virtualBox().GetSystemProperties().GetNetworkAdapterCount(); 2136 for (ulong slot = 0; slot < count; ++ slot) 2137 { 2138 CNetworkAdapter adapter = csession.GetMachine().GetNetworkAdapter (slot); 2139 int id = devicesNetworkMenu->insertItem (tr ("Adapter %1").arg (slot)); 2140 devicesNetworkMenu->setItemEnabled (id, adapter.GetEnabled()); 2141 devicesNetworkMenu->setItemChecked (id, adapter.GetEnabled() && adapter.GetCableConnected()); 2142 } 2143 } 2144 2145 /** 2146 * Switch the cable connected/disconnected for the selected network adapter 2147 */ 2148 void VBoxConsoleWnd::activateNetworkMenu (int aId) 2149 { 2150 ulong count = vboxGlobal().virtualBox().GetSystemProperties().GetNetworkAdapterCount(); 2151 for (ulong slot = 0; slot < count; ++ slot) 2152 { 2153 if (aId == devicesNetworkMenu->idAt (slot)) 2154 { 2155 CNetworkAdapter adapter = csession.GetMachine().GetNetworkAdapter (slot); 2156 bool connected = adapter.GetCableConnected(); 2157 if (adapter.GetEnabled()) 2158 adapter.SetCableConnected (!connected); 2159 break; 2160 } 2161 } 2162 } 2163 2164 /** 2069 2165 * Captures a floppy device corresponding to a given menu id. 2070 2166 */ … … 2207 2303 { 2208 2304 devicesSharedFolders->exec (e->globalPos()); 2305 } 2306 else 2307 if (ind == net_light) 2308 { 2309 devicesNetworkMenu->exec (e->globalPos()); 2209 2310 } 2210 2311 }
Note:
See TracChangeset
for help on using the changeset viewer.