VirtualBox

Changeset 2493 in vbox


Ignore:
Timestamp:
May 4, 2007 11:49:02 AM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
20923
Message:

FE/Qt: Dynamic menu item status tips: simplification and language corrections.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h

    r2492 r2493  
    142142    void prepareNetworkMenu();
    143143
    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);
    156150    void activateSFMenu();
    157151
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp

    r2492 r2493  
    565565    connect (devicesNetworkMenu, SIGNAL(activated(int)), this, SLOT(activateNetworkMenu(int)));
    566566
    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()));
    574584
    575585    connect (helpWebAction, SIGNAL (activated()),
     
    21092119    devicesMountFloppyImageAction->addTo (devicesMountFloppyMenu);
    21102120
    2111     // if shown as a context menu
     2121    /* if shown as a context menu */
    21122122    if (devicesMenu->itemParameter (devicesMountFloppyMenuId))
    21132123    {
     
    21512161    devicesMountDVDImageAction->addTo (devicesMountDVDMenu);
    21522162
    2153     // if shown as a context menu
     2163    /* if shown as a context menu */
    21542164    if (devicesMenu->itemParameter (devicesMountDVDMenuId))
    21552165    {
     
    21602170
    21612171/**
    2162  *  Prepares the "Network adapter" menu by populating the existent adaptors.
     2172 *  Prepares the "Network adapter" menu by populating the existent adapters.
    21632173 */
    21642174void VBoxConsoleWnd::prepareNetworkMenu()
     
    21692179    {
    21702180        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));
    21722182        devicesNetworkMenu->setItemEnabled (id, adapter.GetEnabled());
    21732183        devicesNetworkMenu->setItemChecked (id, adapter.GetEnabled() && adapter.GetCableConnected());
     2184    }
     2185}
     2186
     2187void 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 */
     2220void 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 */
     2243void 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);
    21742260    }
    21752261}
     
    21952281
    21962282/**
    2197  *  Sets the statusTip text for the highlighted host floppy drive
    2198  */
    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 drive
    2213  */
    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 adaptor
    2228  */
    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 menu
    2242  */
    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 menu
    2251  */
    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 menu
    2260  */
    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 selected
    2276     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 set
    2285 //        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 selected
    2299     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 set
    2308 //        console->machine().SaveSettings();
    2309         updateAppearanceOf (DVDStuff);
    2310     }
    2311 }
    2312 
    2313 /**
    23142283 *  Attach/Detach selected USB Device.
    23152284 */
    2316 void VBoxConsoleWnd::switchUSB (int id)
     2285void VBoxConsoleWnd::switchUSB (int aId)
    23172286{
    23182287    if (!console) return;
     
    23212290    AssertWrapperOk (csession);
    23222291
    2323     CUSBDevice usb = devicesUSBMenu->getUSB (id);
     2292    CUSBDevice usb = devicesUSBMenu->getUSB (aId);
    23242293    /* if null then some other item but a USB device is selected */
    23252294    if (usb.isNull())
    23262295        return;
    23272296
    2328     if (devicesUSBMenu->isItemChecked (id))
     2297    if (devicesUSBMenu->isItemChecked (aId))
    23292298    {
    23302299        cconsole.DetachUSBDevice (usb.GetId());
     
    24102379    if (ind == net_light)
    24112380    {
     2381        /* set "this is a context menu" flag */
    24122382        devicesMenu->setItemParameter (devicesNetworkMenuId, 1);
    24132383        devicesNetworkMenu->exec (e->globalPos());
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette