VirtualBox

Ignore:
Timestamp:
Apr 26, 2012 4:52:55 AM (13 years ago)
Author:
vboxsync
Message:

FE/Qt: UIMachine refactoring/cleanup.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r41062 r41063  
    77
    88/*
    9  * Copyright (C) 2010 Oracle Corporation
     9 * Copyright (C) 2010-2012 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1818 */
    1919
    20 /* Global includes */
     20/* Global includes: */
    2121#include <QTimer>
    2222
    23 /* Local includes */
     23/* Local includes: */
    2424#include "VBoxGlobal.h"
    2525#include "UIMachine.h"
     
    2828#include "UIMachineLogic.h"
    2929#include "UIMachineWindow.h"
    30 
    3130#ifdef Q_WS_MAC
    3231# include <ApplicationServices/ApplicationServices.h>
    3332#endif /* Q_WS_MAC */
    3433
     34/* Visual state interface: */
    3535class UIVisualState : public QObject
    3636{
    3737    Q_OBJECT;
    3838
     39signals:
     40
     41    /* Signal to change-state: */
     42    void sigChangeVisualState(UIVisualStateType newVisualStateType);
     43
    3944public:
    4045
    41     /* Visual state holder constructor: */
     46    /* Constructor: */
    4247    UIVisualState(QObject *pParent, UISession *pSession)
    4348        : QObject(pParent)
     
    5257    }
    5358
    54     /* Public getters: */
    55     UIMachineLogic* machineLogic() const  { return m_pMachineLogic; }
     59    /* Destructor: */
     60    ~UIVisualState()
     61    {
     62        /* Delete machine logic if exists: */
     63        if (m_pMachineLogic)
     64            UIMachineLogic::destroy(m_pMachineLogic);
     65    }
     66
     67    /* Visual state type getter: */
    5668    virtual UIVisualStateType visualStateType() const = 0;
    5769
     70    /* Machine logic getter: */
     71    UIMachineLogic* machineLogic() const { return m_pMachineLogic; }
     72
     73    /* Method to prepare change one visual state to another: */
    5874    virtual bool prepareChange(UIVisualStateType previousVisualStateType)
    5975    {
     
    7894    }
    7995
     96    /* Method to change one visual state to another: */
    8097    virtual void change() = 0;
    8198
     99    /* Method to finish change one visual state to another: */
    82100    virtual void finishChange()
    83101    {
     
    95113    }
    96114
    97 
    98 signals:
    99 
    100     /* Signal to change-state: */
    101     void sigChangeVisualState(UIVisualStateType visualStateType);
    102 
    103115protected:
    104116
    105     /* Protected members: */
     117    /* Variables: */
    106118    UISession *m_pSession;
    107119    UIMachineLogic *m_pMachineLogic;
     
    111123};
    112124
     125/* Normal visual state implementation: */
    113126class UIVisualStateNormal : public UIVisualState
    114127{
     
    117130public:
    118131
    119     /* Normal visual state holder constructor: */
     132    /* Constructor: */
    120133    UIVisualStateNormal(QObject *pParent, UISession *pSession)
    121134        : UIVisualState(pParent, pSession) {}
    122135
     136private slots:
     137
     138    /* State-change handlers: */
     139    void sltGoToFullscreenMode() { emit sigChangeVisualState(UIVisualStateType_Fullscreen); }
     140    void sltGoToSeamlessMode() { emit sigChangeVisualState(UIVisualStateType_Seamless); }
     141    void sltGoToScaleMode() { emit sigChangeVisualState(UIVisualStateType_Scale); }
     142
     143private:
     144
     145    /* Visual state type getter: */
    123146    UIVisualStateType visualStateType() const { return UIVisualStateType_Normal; }
    124147
     148    /* Method to change previous visual state to this one: */
    125149    void change()
    126150    {
     
    136160        m_pMachineLogic->initialize();
    137161    }
    138 
    139 private slots:
    140 
    141     void sltGoToFullscreenMode()
    142     {
    143         /* Change visual state to fullscreen: */
    144         emit sigChangeVisualState(UIVisualStateType_Fullscreen);
    145     }
    146 
    147     void sltGoToSeamlessMode()
    148     {
    149         /* Change visual state to seamless: */
    150         emit sigChangeVisualState(UIVisualStateType_Seamless);
    151     }
    152 
    153     void sltGoToScaleMode()
    154     {
    155         /* Change visual state to scale: */
    156         emit sigChangeVisualState(UIVisualStateType_Scale);
    157     }
    158162};
    159163
     164/* Fullscreen visual state implementation: */
    160165class UIVisualStateFullscreen : public UIVisualState
    161166{
     
    164169public:
    165170
    166     /* Fullscreen visual state holder constructor: */
     171    /* Constructor: */
    167172    UIVisualStateFullscreen(QObject *pParent, UISession *pSession)
    168173        : UIVisualState(pParent, pSession)
     
    179184    }
    180185
    181     /* Fullscreen visual state holder destructor: */
     186    /* Destructor: */
    182187    virtual ~UIVisualStateFullscreen()
    183188    {
     
    193198    }
    194199
     200private slots:
     201
     202    /* State-change handlers: */
     203    void sltGoToNormalMode() { emit sigChangeVisualState(UIVisualStateType_Normal); }
     204    void sltGoToSeamlessMode() { emit sigChangeVisualState(UIVisualStateType_Seamless); }
     205    void sltGoToScaleMode() { emit sigChangeVisualState(UIVisualStateType_Scale); }
     206
     207private:
     208
     209    /* Visual state type getter: */
    195210    UIVisualStateType visualStateType() const { return UIVisualStateType_Fullscreen; }
    196211
     212    /* Method to change previous visual state to this one: */
    197213    void change()
    198214    {
     
    208224        m_pMachineLogic->initialize();
    209225    }
    210 
    211 private slots:
    212 
    213     void sltGoToNormalMode()
    214     {
    215         /* Change visual state to normal: */
    216         emit sigChangeVisualState(UIVisualStateType_Normal);
    217     }
    218 
    219     void sltGoToSeamlessMode()
    220     {
    221         /* Change visual state to seamless: */
    222         emit sigChangeVisualState(UIVisualStateType_Seamless);
    223     }
    224 
    225     void sltGoToScaleMode()
    226     {
    227         /* Change visual state to scale: */
    228         emit sigChangeVisualState(UIVisualStateType_Scale);
    229     }
    230226};
    231227
     228/* Seamless visual state implementation: */
    232229class UIVisualStateSeamless : public UIVisualState
    233230{
     
    236233public:
    237234
    238     /* Seamless visual state holder constructor: */
     235    /* Constructor: */
    239236    UIVisualStateSeamless(QObject *pParent, UISession *pSession)
    240237        : UIVisualState(pParent, pSession)
     
    251248    }
    252249
    253     /* Seamless visual state holder destructor: */
     250    /* Destructor: */
    254251    virtual ~UIVisualStateSeamless()
    255252    {
     
    265262    }
    266263
     264private slots:
     265
     266    /* State-change handlers: */
     267    void sltGoToNormalMode() { emit sigChangeVisualState(UIVisualStateType_Normal); }
     268    void sltGoToFullscreenMode() { emit sigChangeVisualState(UIVisualStateType_Fullscreen); }
     269    void sltGoToScaleMode() { emit sigChangeVisualState(UIVisualStateType_Scale); }
     270
     271private:
     272
     273    /* Visual state type getter: */
    267274    UIVisualStateType visualStateType() const { return UIVisualStateType_Seamless; }
    268275
     276    /* Method to change previous visual state to this one: */
    269277    void change()
    270278    {
     
    280288        m_pMachineLogic->initialize();
    281289    }
    282 
    283 private slots:
    284 
    285     void sltGoToNormalMode()
    286     {
    287         /* Change visual state to normal: */
    288         emit sigChangeVisualState(UIVisualStateType_Normal);
    289     }
    290 
    291     void sltGoToFullscreenMode()
    292     {
    293         /* Change visual state to fullscreen: */
    294         emit sigChangeVisualState(UIVisualStateType_Fullscreen);
    295     }
    296 
    297     void sltGoToScaleMode()
    298     {
    299         /* Change visual state to scale: */
    300         emit sigChangeVisualState(UIVisualStateType_Scale);
    301     }
    302290};
    303291
     292/* Scale visual state implementation: */
    304293class UIVisualStateScale : public UIVisualState
    305294{
     
    308297public:
    309298
    310     /* Scale visual state holder constructor: */
     299    /* Constructor: */
    311300    UIVisualStateScale(QObject *pParent, UISession *pSession)
    312301        : UIVisualState(pParent, pSession)
     
    323312    }
    324313
    325     /* Seamless visual state holder destructor: */
     314    /* Destructor: */
    326315    virtual ~UIVisualStateScale()
    327316    {
     
    337326    }
    338327
     328private slots:
     329
     330    /* State-change handlers: */
     331    void sltGoToNormalMode() { emit sigChangeVisualState(UIVisualStateType_Normal); }
     332    void sltGoToFullscreenMode() { emit sigChangeVisualState(UIVisualStateType_Fullscreen); }
     333    void sltGoToSeamlessMode() { emit sigChangeVisualState(UIVisualStateType_Seamless); }
     334
     335private:
     336
     337    /* Visual state type getter: */
    339338    UIVisualStateType visualStateType() const { return UIVisualStateType_Scale; }
    340339
     340    /* Method to change previous visual state to this one: */
    341341    void change()
    342342    {
     
    352352        m_pMachineLogic->initialize();
    353353    }
    354 
    355 private slots:
    356 
    357     void sltGoToNormalMode()
    358     {
    359         /* Change visual state to normal: */
    360         emit sigChangeVisualState(UIVisualStateType_Normal);
    361     }
    362 
    363     void sltGoToFullscreenMode()
    364     {
    365         /* Change visual state to fullscreen: */
    366         emit sigChangeVisualState(UIVisualStateType_Fullscreen);
    367     }
    368 
    369     void sltGoToSeamlessMode()
    370     {
    371         /* Change visual state to seamless: */
    372         emit sigChangeVisualState(UIVisualStateType_Seamless);
    373     }
    374354};
    375355
     
    436416}
    437417
    438 void UIMachine::sltChangeVisualState(UIVisualStateType visualStateType)
     418void UIMachine::sltChangeVisualState(UIVisualStateType newVisualStateType)
    439419{
    440420    /* Create new state: */
    441421    UIVisualState *pNewVisualState = 0;
    442     switch (visualStateType)
     422    switch (newVisualStateType)
    443423    {
    444424        case UIVisualStateType_Normal:
     
    470450    }
    471451
     452    /* Get previous visual state type: */
    472453    UIVisualStateType previousVisualStateType = UIVisualStateType_Normal;
    473454    if (m_pVisualState)
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r41047 r41063  
    77
    88/*
    9  * Copyright (C) 2010-2011 Oracle Corporation
     9 * Copyright (C) 2010-2012 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    105105Q_DECLARE_METATYPE(USBTarget);
    106106
     107/* static */
    107108UIMachineLogic* UIMachineLogic::create(QObject *pParent,
    108109                                       UISession *pSession,
     
    126127    }
    127128    return logic;
     129}
     130
     131/* static */
     132void UIMachineLogic::destroy(UIMachineLogic *pWhichLogic)
     133{
     134    delete pWhichLogic;
    128135}
    129136
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r41047 r41063  
    66
    77/*
    8  * Copyright (C) 2010-2011 Oracle Corporation
     8 * Copyright (C) 2010-2012 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    5050public:
    5151
    52     /* Factory function to create required logic sub-child: */
     52    /* Factory functions to create/destroy required logic sub-child: */
    5353    static UIMachineLogic* create(QObject *pParent,
    5454                                  UISession *pSession,
    5555                                  UIVisualStateType visualStateType);
     56    static void destroy(UIMachineLogic *pWhichLogic);
    5657
    5758    /* Check if this mode is available: */
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