Changeset 2493 in vbox
- Timestamp:
- May 4, 2007 11:49:02 AM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 20923
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h
r2492 r2493 142 142 void prepareNetworkMenu(); 143 143 144 void highlightFloppy (int); 145 void highlightDVD (int); 146 void highlightNetworkMenu (int); 147 148 void hideFloppyMenu(); 149 void hideDVDMenu(); 150 void hideNetworkMenu(); 151 152 void captureFloppy (int id); 153 void captureDVD (int id); 154 void activateNetworkMenu (int); 155 void switchUSB (int id); 144 void setDynamicMenuItemStatusTip (int aId); 145 146 void captureFloppy (int aId); 147 void captureDVD (int aId); 148 void activateNetworkMenu (int aId); 149 void switchUSB (int aId); 156 150 void activateSFMenu(); 157 151 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
r2492 r2493 565 565 connect (devicesNetworkMenu, SIGNAL(activated(int)), this, SLOT(activateNetworkMenu(int))); 566 566 567 connect (devicesMountFloppyMenu, SIGNAL(highlighted(int)), this, SLOT(highlightFloppy(int))); 568 connect (devicesMountDVDMenu, SIGNAL(highlighted(int)), this, SLOT(highlightDVD(int))); 569 connect (devicesNetworkMenu, SIGNAL(highlighted(int)), this, SLOT(highlightNetworkMenu(int))); 570 571 connect (devicesMountFloppyMenu, SIGNAL(aboutToHide()), this, SLOT(hideFloppyMenu())); 572 connect (devicesMountDVDMenu, SIGNAL(aboutToHide()), this, SLOT(hideDVDMenu())); 573 connect (devicesNetworkMenu, SIGNAL(aboutToHide()), this, SLOT(hideNetworkMenu())); 567 connect (devicesMountFloppyMenu, SIGNAL (highlighted (int)), 568 this, SLOT (setDynamicMenuItemStatusTip (int))); 569 connect (devicesMountDVDMenu, SIGNAL (highlighted (int)), 570 this, SLOT (setDynamicMenuItemStatusTip (int))); 571 connect (devicesNetworkMenu, SIGNAL (highlighted (int)), 572 this, SLOT (setDynamicMenuItemStatusTip (int))); 573 574 /* Cleanup the status bar tip when a menu with dynamic items is 575 * hidden. This is necessary for context menus in the first place but also 576 * for normal menus (because Qt will not do it on pressing ESC if the menu 577 * is constructed of dynamic items only) */ 578 connect (devicesMountFloppyMenu, SIGNAL (aboutToHide()), 579 statusBar(), SLOT (clear())); 580 connect (devicesMountDVDMenu, SIGNAL (aboutToHide()), 581 statusBar(), SLOT (clear())); 582 connect (devicesNetworkMenu, SIGNAL (aboutToHide()), 583 statusBar(), SLOT (clear())); 574 584 575 585 connect (helpWebAction, SIGNAL (activated()), … … 2109 2119 devicesMountFloppyImageAction->addTo (devicesMountFloppyMenu); 2110 2120 2111 / / if shown as a context menu2121 /* if shown as a context menu */ 2112 2122 if (devicesMenu->itemParameter (devicesMountFloppyMenuId)) 2113 2123 { … … 2151 2161 devicesMountDVDImageAction->addTo (devicesMountDVDMenu); 2152 2162 2153 / / if shown as a context menu2163 /* if shown as a context menu */ 2154 2164 if (devicesMenu->itemParameter (devicesMountDVDMenuId)) 2155 2165 { … … 2160 2170 2161 2171 /** 2162 * Prepares the "Network adapter" menu by populating the existent adapt ors.2172 * Prepares the "Network adapter" menu by populating the existent adapters. 2163 2173 */ 2164 2174 void VBoxConsoleWnd::prepareNetworkMenu() … … 2169 2179 { 2170 2180 CNetworkAdapter adapter = csession.GetMachine().GetNetworkAdapter (slot); 2171 int id = devicesNetworkMenu->insertItem (tr ("Adapter %1" ).arg (slot));2181 int id = devicesNetworkMenu->insertItem (tr ("Adapter %1", "network").arg (slot)); 2172 2182 devicesNetworkMenu->setItemEnabled (id, adapter.GetEnabled()); 2173 2183 devicesNetworkMenu->setItemChecked (id, adapter.GetEnabled() && adapter.GetCableConnected()); 2184 } 2185 } 2186 2187 void VBoxConsoleWnd::setDynamicMenuItemStatusTip (int aId) 2188 { 2189 QString tip; 2190 2191 if (sender() == devicesMountFloppyMenu) 2192 { 2193 if (hostFloppyMap.find (aId) != hostFloppyMap.end()) 2194 tip = tr ("Mount the selected physical drive of the host PC", 2195 "Floppy tip"); 2196 } 2197 else if (sender() == devicesMountDVDMenu) 2198 { 2199 if (hostDVDMap.find (aId) != hostDVDMap.end()) 2200 tip = tr ("Mount the selected physical drive of the host PC", 2201 "CD/DVD tip"); 2202 } 2203 else if (sender() == devicesNetworkMenu) 2204 { 2205 tip = devicesNetworkMenu->isItemChecked (aId) ? 2206 tr ("Disconnect the cable from the selected virtual network adapter") : 2207 tr ("Connect the cable to the selected virtual network adapter"); 2208 } 2209 2210 if (!tip.isNull()) 2211 { 2212 StatusTipEvent *ev = new StatusTipEvent (tip); 2213 QApplication::postEvent (this, ev); 2214 } 2215 } 2216 2217 /** 2218 * Captures a floppy device corresponding to a given menu id. 2219 */ 2220 void VBoxConsoleWnd::captureFloppy (int aId) 2221 { 2222 if (!console) return; 2223 2224 CHostFloppyDrive d = hostFloppyMap [aId]; 2225 /* if null then some other item but host drive is selected */ 2226 if (d.isNull()) return; 2227 2228 CFloppyDrive drv = csession.GetMachine().GetFloppyDrive(); 2229 drv.CaptureHostDrive (d); 2230 AssertWrapperOk (drv); 2231 2232 if (drv.isOk()) 2233 { 2234 // @todo: save the settings only on power off if the appropriate flag is set 2235 // console->machine().SaveSettings(); 2236 updateAppearanceOf (FloppyStuff); 2237 } 2238 } 2239 2240 /** 2241 * Captures a CD/DVD-ROM device corresponding to a given menu id. 2242 */ 2243 void VBoxConsoleWnd::captureDVD (int aId) 2244 { 2245 if (!console) return; 2246 2247 CHostDVDDrive d = hostDVDMap [aId]; 2248 /* if null then some other item but host drive is selected */ 2249 if (d.isNull()) return; 2250 2251 CDVDDrive drv = csession.GetMachine().GetDVDDrive(); 2252 drv.CaptureHostDrive (d); 2253 AssertWrapperOk (drv); 2254 2255 if (drv.isOk()) 2256 { 2257 // @todo: save the settings only on power off if the appropriate flag is set 2258 // console->machine().SaveSettings(); 2259 updateAppearanceOf (DVDStuff); 2174 2260 } 2175 2261 } … … 2195 2281 2196 2282 /** 2197 * Sets the statusTip text for the highlighted host floppy drive2198 */2199 void VBoxConsoleWnd::highlightFloppy (int aId)2200 {2201 QString tip = hostFloppyMap.find (aId) != hostFloppyMap.end() ?2202 tr ("Mount the physical drive of the host PC") :2203 QString::null;2204 if (!tip.isNull())2205 {2206 StatusTipEvent *ev = new StatusTipEvent (tip);2207 QApplication::postEvent (this, ev);2208 }2209 }2210 2211 /**2212 * Sets the statusTip text for the highlighted host cd/dvd drive2213 */2214 void VBoxConsoleWnd::highlightDVD (int aId)2215 {2216 QString tip = hostDVDMap.find (aId) != hostDVDMap.end() ?2217 tr ("Mount the physical drive of the host PC") :2218 QString::null;2219 if (!tip.isNull())2220 {2221 StatusTipEvent *ev = new StatusTipEvent (tip);2222 QApplication::postEvent (this, ev);2223 }2224 }2225 2226 /**2227 * Sets the statusTip text for the highlighted adaptor2228 */2229 void VBoxConsoleWnd::highlightNetworkMenu (int aId)2230 {2231 QString tip = !devicesNetworkMenu->isItemEnabled (aId) ?2232 tr ("This adaptor is not enabled") :2233 devicesNetworkMenu->isItemChecked (aId) ?2234 tr ("Disconnect the cable from the virtual network adapter") :2235 tr ("Connect the cable to the virtual network adapter");2236 StatusTipEvent *ev = new StatusTipEvent (tip);2237 QApplication::postEvent (this, ev);2238 }2239 2240 /**2241 * Clears the statusTip text for the led context floppy drive menu2242 */2243 void VBoxConsoleWnd::hideFloppyMenu()2244 {2245 if (devicesMenu->itemParameter (devicesMountFloppyMenuId))2246 ((QMainWindow*)this)->statusBar()->clear();2247 }2248 2249 /**2250 * Clears the statusTip text for the led context cd/dvd drive menu2251 */2252 void VBoxConsoleWnd::hideDVDMenu()2253 {2254 if (devicesMenu->itemParameter (devicesMountDVDMenuId))2255 ((QMainWindow*)this)->statusBar()->clear();2256 }2257 2258 /**2259 * Clears the statusTip text for the led context network adapters menu2260 */2261 void VBoxConsoleWnd::hideNetworkMenu()2262 {2263 if (devicesMenu->itemParameter (devicesNetworkMenuId))2264 ((QMainWindow*)this)->statusBar()->clear();2265 }2266 2267 /**2268 * Captures a floppy device corresponding to a given menu id.2269 */2270 void VBoxConsoleWnd::captureFloppy (int id)2271 {2272 if (!console) return;2273 2274 CHostFloppyDrive d = hostFloppyMap [id];2275 // if null then some other item but host drive is selected2276 if (d.isNull()) return;2277 2278 CFloppyDrive drv = csession.GetMachine().GetFloppyDrive();2279 drv.CaptureHostDrive (d);2280 AssertWrapperOk (drv);2281 2282 if (drv.isOk())2283 {2284 // @todo: save the settings only on power off if the appropriate flag is set2285 // console->machine().SaveSettings();2286 updateAppearanceOf (FloppyStuff);2287 }2288 }2289 2290 /**2291 * Captures a CD/DVD-ROM device corresponding to a given menu id.2292 */2293 void VBoxConsoleWnd::captureDVD (int id)2294 {2295 if (!console) return;2296 2297 CHostDVDDrive d = hostDVDMap [id];2298 // if null then some other item but host drive is selected2299 if (d.isNull()) return;2300 2301 CDVDDrive drv = csession.GetMachine().GetDVDDrive();2302 drv.CaptureHostDrive (d);2303 AssertWrapperOk (drv);2304 2305 if (drv.isOk())2306 {2307 // @todo: save the settings only on power off if the appropriate flag is set2308 // console->machine().SaveSettings();2309 updateAppearanceOf (DVDStuff);2310 }2311 }2312 2313 /**2314 2283 * Attach/Detach selected USB Device. 2315 2284 */ 2316 void VBoxConsoleWnd::switchUSB (int id)2285 void VBoxConsoleWnd::switchUSB (int aId) 2317 2286 { 2318 2287 if (!console) return; … … 2321 2290 AssertWrapperOk (csession); 2322 2291 2323 CUSBDevice usb = devicesUSBMenu->getUSB ( id);2292 CUSBDevice usb = devicesUSBMenu->getUSB (aId); 2324 2293 /* if null then some other item but a USB device is selected */ 2325 2294 if (usb.isNull()) 2326 2295 return; 2327 2296 2328 if (devicesUSBMenu->isItemChecked ( id))2297 if (devicesUSBMenu->isItemChecked (aId)) 2329 2298 { 2330 2299 cconsole.DetachUSBDevice (usb.GetId()); … … 2410 2379 if (ind == net_light) 2411 2380 { 2381 /* set "this is a context menu" flag */ 2412 2382 devicesMenu->setItemParameter (devicesNetworkMenuId, 1); 2413 2383 devicesNetworkMenu->exec (e->globalPos());
Note:
See TracChangeset
for help on using the changeset viewer.