VirtualBox

Changeset 2492 in vbox for trunk/src/VBox/Frontends


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

Status Tips done for network adapters dropped and led context menu.
Status Tips done for host floppy & cd/dvd drives dropped and led context menu.

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

Legend:

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

    r2458 r2492  
    140140    void prepareFloppyMenu();
    141141    void prepareDVDMenu();
    142 
    143142    void prepareNetworkMenu();
    144     void activateNetworkMenu (int);
     143
     144    void highlightFloppy (int);
     145    void highlightDVD (int);
     146    void highlightNetworkMenu (int);
     147
     148    void hideFloppyMenu();
     149    void hideDVDMenu();
     150    void hideNetworkMenu();
    145151
    146152    void captureFloppy (int id);
    147153    void captureDVD (int id);
     154    void activateNetworkMenu (int);
    148155    void switchUSB (int id);
    149156    void activateSFMenu();
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp

    r2458 r2492  
    168168
    169169    CMachine mMachine;
     170};
     171
     172/** class StatusTipEvent
     173 *
     174 *  The StatusTipEvent class is an auxiliary QEvent class
     175 *  for carrying statusTip text of non-QAction menu item's.
     176 *  This event is posted then the menu item is highlighted but
     177 *  processed later in VBoxConsoleWnd::event() handler to
     178 *  avoid statusBar messaging collisions.
     179 */
     180class StatusTipEvent : public QEvent
     181{
     182public:
     183    enum { Type = QEvent::User + 10 };
     184    StatusTipEvent (const QString &aTip)
     185        : QEvent ((QEvent::Type) Type), mTip (aTip) {}
     186
     187    QString mTip;
    170188};
    171189
     
    547565    connect (devicesNetworkMenu, SIGNAL(activated(int)), this, SLOT(activateNetworkMenu(int)));
    548566
     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()));
     574
    549575    connect (helpWebAction, SIGNAL (activated()),
    550576             &vboxProblem(), SLOT (showHelpWebDialog()));
     
    10161042#endif
    10171043            }
     1044            break;
     1045        }
     1046        case StatusTipEvent::Type:
     1047        {
     1048            StatusTipEvent *ev = (StatusTipEvent*) e;
     1049            ((QMainWindow*)this)->statusBar()->message (ev->mTip);
    10181050            break;
    10191051        }
     
    21632195
    21642196/**
     2197 *  Sets the statusTip text for the highlighted host floppy drive
     2198 */
     2199void 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 */
     2214void 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 */
     2229void 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 */
     2243void 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 */
     2252void 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 */
     2261void VBoxConsoleWnd::hideNetworkMenu()
     2262{
     2263    if (devicesMenu->itemParameter (devicesNetworkMenuId))
     2264        ((QMainWindow*)this)->statusBar()->clear();
     2265}
     2266
     2267/**
    21652268 *  Captures a floppy device corresponding to a given menu id.
    21662269 */
     
    23072410    if (ind == net_light)
    23082411    {
     2412        devicesMenu->setItemParameter (devicesNetworkMenuId, 1);
    23092413        devicesNetworkMenu->exec (e->globalPos());
     2414        devicesMenu->setItemParameter (devicesNetworkMenuId, 0);
    23102415    }
    23112416}
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