VirtualBox

Changeset 41591 in vbox


Ignore:
Timestamp:
Jun 6, 2012 7:04:53 AM (13 years ago)
Author:
vboxsync
Message:

FE/Qt: VBoxGlobal little cleanup, some includes refactoring.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r41590 r41591  
    421421        src/settings/machine/UIMachineSettingsPortForwardingDlg.cpp \
    422422        src/settings/machine/UIMachineSettingsStorage.cpp \
     423        src/settings/machine/UIMachineSettingsUSB.cpp \
    423424        src/wizards/importappliance/UIWizardImportApp.cpp
    424425
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp

    r41587 r41591  
    3434
    3535/* COM includes: */
     36#include "CConsole.h"
    3637#include "CDisplay.h"
    3738
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMInformationDlg.cpp

    r41587 r41591  
    3737/* COM includes: */
    3838#include "COMEnums.h"
     39#include "CConsole.h"
    3940#include "CSystemProperties.h"
    4041#include "CMachineDebugger.h"
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r41590 r41591  
    5050
    5151/* COM includes: */
     52#include "CConsole.h"
    5253#include "CSystemProperties.h"
    5354#include "CVirtualBoxErrorInfo.h"
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r41590 r41591  
    3232#include <QTimer>
    3333#include <QDir>
    34 #include <QHelpEvent>
    3534#include <QLocale>
    3635#include <QNetworkProxy>
     
    54615460 */
    54625461
    5463 /**
    5464  *  USB Popup Menu class methods
    5465  *  This class provides the list of USB devices attached to the host.
    5466  */
    5467 VBoxUSBMenu::VBoxUSBMenu (QWidget *aParent) : QMenu (aParent)
    5468 {
    5469     connect (this, SIGNAL (aboutToShow()),
    5470              this, SLOT   (processAboutToShow()));
    5471 //    connect (this, SIGNAL (hovered (QAction *)),
    5472 //             this, SLOT   (processHighlighted (QAction *)));
    5473 }
    5474 
    5475 const CUSBDevice& VBoxUSBMenu::getUSB (QAction *aAction)
    5476 {
    5477     return mUSBDevicesMap [aAction];
    5478 }
    5479 
    5480 void VBoxUSBMenu::setConsole (const CConsole &aConsole)
    5481 {
    5482     mConsole = aConsole;
    5483 }
    5484 
    5485 void VBoxUSBMenu::processAboutToShow()
    5486 {
    5487     clear();
    5488     mUSBDevicesMap.clear();
    5489 
    5490     CHost host = vboxGlobal().host();
    5491 
    5492     bool isUSBEmpty = host.GetUSBDevices().size() == 0;
    5493     if (isUSBEmpty)
    5494     {
    5495         QAction *action = addAction (tr ("<no devices available>", "USB devices"));
    5496         action->setEnabled (false);
    5497         action->setToolTip (tr ("No supported devices connected to the host PC",
    5498                                 "USB device tooltip"));
    5499     }
    5500     else
    5501     {
    5502         CHostUSBDeviceVector devvec = host.GetUSBDevices();
    5503         for (int i = 0; i < devvec.size(); ++i)
    5504         {
    5505             CHostUSBDevice dev = devvec[i];
    5506             CUSBDevice usb (dev);
    5507             QAction *action = addAction (vboxGlobal().details (usb));
    5508             action->setCheckable (true);
    5509             mUSBDevicesMap [action] = usb;
    5510             /* check if created item was already attached to this session */
    5511             if (!mConsole.isNull())
    5512             {
    5513                 CUSBDevice attachedUSB =
    5514                     mConsole.FindUSBDeviceById (usb.GetId());
    5515                 action->setChecked (!attachedUSB.isNull());
    5516                 action->setEnabled (dev.GetState() !=
    5517                                     KUSBDeviceState_Unavailable);
    5518             }
    5519         }
    5520     }
    5521 }
    5522 
    5523 bool VBoxUSBMenu::event(QEvent *aEvent)
    5524 {
    5525     /* We provide dynamic tooltips for the usb devices */
    5526     if (aEvent->type() == QEvent::ToolTip)
    5527     {
    5528         QHelpEvent *helpEvent = static_cast<QHelpEvent *> (aEvent);
    5529         QAction *action = actionAt (helpEvent->pos());
    5530         if (action)
    5531         {
    5532             CUSBDevice usb = mUSBDevicesMap [action];
    5533             if (!usb.isNull())
    5534             {
    5535                 QToolTip::showText (helpEvent->globalPos(), vboxGlobal().toolTip (usb));
    5536                 return true;
    5537             }
    5538         }
    5539     }
    5540     return QMenu::event (aEvent);
    5541 }
    5542 
    5543 /**
    5544  *  Enable/Disable Menu class.
    5545  *  This class provides enable/disable menu items.
    5546  */
    5547 VBoxSwitchMenu::VBoxSwitchMenu (QWidget *aParent, QAction *aAction,
    5548                                 bool aInverted)
    5549     : QMenu (aParent), mAction (aAction), mInverted (aInverted)
    5550 {
    5551     /* this menu works only with toggle action */
    5552     Assert (aAction->isCheckable());
    5553     addAction(aAction);
    5554     connect (this, SIGNAL (aboutToShow()),
    5555              this, SLOT   (processAboutToShow()));
    5556 }
    5557 
    5558 void VBoxSwitchMenu::setToolTip (const QString &aTip)
    5559 {
    5560     mAction->setToolTip (aTip);
    5561 }
    5562 
    5563 void VBoxSwitchMenu::processAboutToShow()
    5564 {
    5565     QString text = mAction->isChecked() ^ mInverted ? tr ("Disable") : tr ("Enable");
    5566     mAction->setText (text);
    5567 }
    5568 
    55695462bool VBoxGlobal::switchToMachine(CMachine &machine)
    55705463{
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r41590 r41591  
    3838#include "CVirtualBox.h"
    3939#include "CSession.h"
    40 #include "CConsole.h"
    4140#include "CMachine.h"
    4241#include "CMedium.h"
     
    891890inline VBoxGlobal &vboxGlobal() { return VBoxGlobal::instance(); }
    892891
    893 // Helper classes
    894 ////////////////////////////////////////////////////////////////////////////////
    895 
    896 /**
    897  *  USB Popup Menu class.
    898  *  This class provides the list of USB devices attached to the host.
    899  */
    900 class VBoxUSBMenu : public QMenu
    901 {
    902     Q_OBJECT
    903 
    904 public:
    905 
    906     VBoxUSBMenu (QWidget *);
    907 
    908     const CUSBDevice& getUSB (QAction *aAction);
    909 
    910     void setConsole (const CConsole &);
    911 
    912 private slots:
    913 
    914     void processAboutToShow();
    915 
    916 private:
    917     bool event(QEvent *aEvent);
    918 
    919     QMap <QAction *, CUSBDevice> mUSBDevicesMap;
    920     CConsole mConsole;
    921 };
    922 
    923 /**
    924  *  Enable/Disable Menu class.
    925  *  This class provides enable/disable menu items.
    926  */
    927 class VBoxSwitchMenu : public QMenu
    928 {
    929     Q_OBJECT
    930 
    931 public:
    932 
    933     VBoxSwitchMenu (QWidget *, QAction *, bool aInverted = false);
    934 
    935     void setToolTip (const QString &);
    936 
    937 private slots:
    938 
    939     void processAboutToShow();
    940 
    941 private:
    942 
    943     QAction *mAction;
    944     bool     mInverted;
    945 };
    946 
    947892#endif /* __VBoxGlobal_h__ */
    948893
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIConsoleEventHandler.cpp

    r41587 r41591  
    2828
    2929/* COM includes: */
     30#include "CConsole.h"
    3031#include "CEventSource.h"
    3132
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp

    r41587 r41591  
    2828
    2929/* COM includes: */
     30#include "CConsole.h"
    3031#include "CSystemProperties.h"
    3132#include "CMachineDebugger.h"
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp

    r41107 r41591  
    1818 */
    1919
    20 /* Global includes */
     20/* Qt includes: */
    2121#include <QKeyEvent>
    22 
    23 /* Local includes */
     22#ifdef Q_WS_X11
     23# include <QX11Info>
     24#endif /* Q_WS_X11 */
     25
     26/* GUI includes: */
    2427#include "VBoxGlobal.h"
    2528#include "UIMessageCenter.h"
     
    3639#include "UIHotKeyEditor.h"
    3740
     41/* Other VBox includes: */
    3842#ifdef Q_WS_X11
    39 # include <QX11Info>
    4043# include <X11/XKBlib.h>
    4144# include <X11/keysym.h>
     
    5962# include <Carbon/Carbon.h>
    6063#endif /* Q_WS_MAC */
     64
     65/* COM includes: */
     66#include "CConsole.h"
    6167
    6268/* Enums representing different keyboard-states: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r41587 r41591  
    5656/* COM includes: */
    5757#include "CSession.h"
     58#include "CConsole.h"
    5859#include "CDisplay.h"
    5960#include "CFramebuffer.h"
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r41590 r41591  
    3939
    4040/* COM includes: */
     41#include "CConsole.h"
    4142#include "CSnapshot.h"
    4243
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp

    r41587 r41591  
    5656
    5757/* COM includes: */
     58#include "CConsole.h"
    5859#include "CMouse.h"
    5960#include "CFramebuffer.h"
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r41587 r41591  
    5454
    5555/* COM includes: */
     56#include "CConsole.h"
    5657#include "CSystemProperties.h"
    5758#include "CMachineDebugger.h"
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp

    r41587 r41591  
    4444
    4545/* COM includes: */
     46#include "CConsole.h"
    4647#include "CMediumAttachment.h"
    4748#include "CUSBController.h"
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.cpp

    r41587 r41591  
    3636
    3737/* COM includes: */
     38#include "CConsole.h"
    3839#include "CDisplay.h"
    3940
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.cpp

    r41587 r41591  
    3636
    3737/* COM includes: */
     38#include "CConsole.h"
    3839#include "CDisplay.h"
    3940
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMPreviewWindow.cpp

    r41587 r41591  
    3131
    3232/* COM includes: */
     33#include "CConsole.h"
    3334#include "CDisplay.h"
    3435
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.cpp

    r40870 r41591  
    2121# include "precomp.h"
    2222#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
    23 /* Local includes */
     23
     24/* Qt includes: */
     25#include <QDateTime>
     26#include <QHeaderView>
     27#include <QMenu>
     28#include <QScrollBar>
     29#include <QWindowsStyle>
     30
     31/* GUI includes: */
    2432#include "UIIconPool.h"
    2533#include "UIMessageCenter.h"
     
    3240#include "UISelectorShortcuts.h"
    3341
    34 /* Global includes */
    35 #include <QDateTime>
    36 #include <QHeaderView>
    37 #include <QMenu>
    38 #include <QScrollBar>
    39 #include <QWindowsStyle>
     42/* COM includes: */
     43#include "CConsole.h"
    4044
    4145#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsUSB.cpp

    r41587 r41591  
    2020/* Qt includes: */
    2121#include <QHeaderView>
     22#include <QHelpEvent>
     23#include <QToolTip>
    2224
    2325/* GUI includes: */
     
    3234
    3335/* COM includes: */
     36#include "CConsole.h"
    3437#include "CUSBController.h"
    3538#include "CUSBDevice.h"
     
    4245/* Using declarations: */
    4346using namespace VBoxGlobalDefs;
     47
     48/**
     49 *  USB popup menu class.
     50 *  This class provides the list of USB devices attached to the host.
     51 */
     52class VBoxUSBMenu : public QMenu
     53{
     54    Q_OBJECT;
     55
     56public:
     57
     58    /* Constructor: */
     59    VBoxUSBMenu(QWidget *)
     60    {
     61        connect(this, SIGNAL(aboutToShow()), this, SLOT(processAboutToShow()));
     62    }
     63
     64    /* Returns USB device related to passed action: */
     65    const CUSBDevice& getUSB(QAction *pAction)
     66    {
     67        return m_usbDeviceMap[pAction];
     68    }
     69
     70    /* Console setter: */
     71    void setConsole(const CConsole &console)
     72    {
     73        m_console = console;
     74    }
     75
     76private slots:
     77
     78    /* Prepare menu appearance: */
     79    void processAboutToShow()
     80    {
     81        clear();
     82        m_usbDeviceMap.clear();
     83
     84        CHost host = vboxGlobal().host();
     85
     86        bool fIsUSBEmpty = host.GetUSBDevices().size() == 0;
     87        if (fIsUSBEmpty)
     88        {
     89            QAction *pAction = addAction(tr("<no devices available>", "USB devices"));
     90            pAction->setEnabled(false);
     91            pAction->setToolTip(tr("No supported devices connected to the host PC", "USB device tooltip"));
     92        }
     93        else
     94        {
     95            CHostUSBDeviceVector devvec = host.GetUSBDevices();
     96            for (int i = 0; i < devvec.size(); ++i)
     97            {
     98                CHostUSBDevice dev = devvec[i];
     99                CUSBDevice usb(dev);
     100                QAction *pAction = addAction(vboxGlobal().details(usb));
     101                pAction->setCheckable(true);
     102                m_usbDeviceMap[pAction] = usb;
     103                /* Check if created item was already attached to this session: */
     104                if (!m_console.isNull())
     105                {
     106                    CUSBDevice attachedUSB = m_console.FindUSBDeviceById(usb.GetId());
     107                    pAction->setChecked(!attachedUSB.isNull());
     108                    pAction->setEnabled(dev.GetState() != KUSBDeviceState_Unavailable);
     109                }
     110            }
     111        }
     112    }
     113
     114private:
     115
     116    /* Event handler: */
     117    bool event(QEvent *pEvent)
     118    {
     119        /* We provide dynamic tooltips for the usb devices: */
     120        if (pEvent->type() == QEvent::ToolTip)
     121        {
     122            QHelpEvent *pHelpEvent = static_cast<QHelpEvent*>(pEvent);
     123            QAction *pAction = actionAt(pHelpEvent->pos());
     124            if (pAction)
     125            {
     126                CUSBDevice usb = m_usbDeviceMap[pAction];
     127                if (!usb.isNull())
     128                {
     129                    QToolTip::showText(pHelpEvent->globalPos(), vboxGlobal().toolTip(usb));
     130                    return true;
     131                }
     132            }
     133        }
     134        /* Call to base-class: */
     135        return QMenu::event(pEvent);
     136    }
     137
     138    QMap<QAction*, CUSBDevice> m_usbDeviceMap;
     139    CConsole m_console;
     140};
    44141
    45142UIMachineSettingsUSB::UIMachineSettingsUSB(UISettingsPageType type)
     
    9391036}
    9401037
     1038#include "UIMachineSettingsUSB.moc"
     1039
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVM.cpp

    r41415 r41591  
    1818 */
    1919
    20 /* Local includes: */
     20/* GUI includes: */
    2121#include "UIWizardCloneVM.h"
    2222#include "UIWizardCloneVMPageBasic1.h"
     
    2626#include "VBoxGlobal.h"
    2727#include "UIMessageCenter.h"
     28
     29/* COM includes: */
     30#include "CConsole.h"
    2831
    2932UIWizardCloneVM::UIWizardCloneVM(QWidget *pParent, const CMachine &machine, CSnapshot snapshot /* = CSnapshot() */)
Note: See TracChangeset for help on using the changeset viewer.

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