VirtualBox

Ignore:
Timestamp:
May 29, 2012 3:15:39 PM (13 years ago)
Author:
vboxsync
Message:

FE/Qt: UISession cleanup.

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

Legend:

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

    r41122 r41484  
    6060    /* Common variables: */
    6161    , m_pMenuPool(0)
    62     , m_machineState(KMachineState_Null)
    63 #if defined(Q_WS_WIN)
     62    , m_machineState(session().GetMachine().GetState())
     63#ifdef Q_WS_WIN
    6464    , m_alphaCursor(0)
    65 #endif
     65#endif /* Q_WS_WIN */
    6666    /* Common flags: */
    6767    , m_fIsFirstTimeStarted(false)
     
    8989    , m_fIsHidingHostPointer(true)
    9090{
    91     /* Explicit initialize the console event handler */
    92     UIConsoleEventHandler::instance(this);
    93 
    94     /* Add console event connections */
    95     connect(gConsoleEvents, SIGNAL(sigMousePointerShapeChange(bool, bool, QPoint, QSize, QVector<uint8_t>)),
    96             this, SLOT(sltMousePointerShapeChange(bool, bool, QPoint, QSize, QVector<uint8_t>)));
    97 
    98     connect(gConsoleEvents, SIGNAL(sigMouseCapabilityChange(bool, bool, bool)),
    99             this, SLOT(sltMouseCapabilityChange(bool, bool, bool)));
    100 
    101     connect(gConsoleEvents, SIGNAL(sigKeyboardLedsChangeEvent(bool, bool, bool)),
    102             this, SLOT(sltKeyboardLedsChangeEvent(bool, bool, bool)));
    103 
    104     connect(gConsoleEvents, SIGNAL(sigStateChange(KMachineState)),
    105             this, SLOT(sltStateChange(KMachineState)));
    106 
    107     connect(gConsoleEvents, SIGNAL(sigAdditionsChange()),
    108             this, SLOT(sltAdditionsChange()));
    109 
    110     connect(gConsoleEvents, SIGNAL(sigVRDEChange()),
    111             this, SLOT(sltVRDEChange()));
    112 
    113     connect(gConsoleEvents, SIGNAL(sigNetworkAdapterChange(CNetworkAdapter)),
    114             this, SIGNAL(sigNetworkAdapterChange(CNetworkAdapter)));
    115 
    116     connect(gConsoleEvents, SIGNAL(sigMediumChange(CMediumAttachment)),
    117             this, SIGNAL(sigMediumChange(CMediumAttachment)));
    118 
    119     connect(gConsoleEvents, SIGNAL(sigUSBControllerChange()),
    120             this, SIGNAL(sigUSBControllerChange()));
    121 
    122     connect(gConsoleEvents, SIGNAL(sigUSBDeviceStateChange(CUSBDevice, bool, CVirtualBoxErrorInfo)),
    123             this, SIGNAL(sigUSBDeviceStateChange(CUSBDevice, bool, CVirtualBoxErrorInfo)));
    124 
    125     connect(gConsoleEvents, SIGNAL(sigSharedFolderChange()),
    126             this, SIGNAL(sigSharedFolderChange()));
    127 
    128     connect(gConsoleEvents, SIGNAL(sigRuntimeError(bool, QString, QString)),
    129             this, SIGNAL(sigRuntimeError(bool, QString, QString)));
    130 
    131 #ifdef Q_WS_MAC
    132     connect(gConsoleEvents, SIGNAL(sigShowWindow()),
    133             this, SIGNAL(sigShowWindows()),
    134             Qt::QueuedConnection);
    135 #endif /* Q_WS_MAC */
    136 
    137     connect(gConsoleEvents, SIGNAL(sigCPUExecutionCapChange()),
    138             this, SIGNAL(sigCPUExecutionCapChange()));
    139 
    140     connect(gConsoleEvents, SIGNAL(sigGuestMonitorChange(KGuestMonitorChangedEventType, ulong, QRect)),
    141             this, SIGNAL(sigGuestMonitorChange(KGuestMonitorChangedEventType, ulong, QRect)));
     91    /* Prepare console event-handlers: */
     92    prepareConsoleEventHandlers();
    14293
    14394    /* Prepare framebuffers: */
    14495    prepareFramebuffers();
    14596
    146     /* Prepare main menu: */
     97    /* Prepare main-menu: */
    14798    prepareMenuPool();
    14899
    149     /* Load uisession settings: */
     100    /* Load settings: */
    150101    loadSessionSettings();
    151102
     
    161112UISession::~UISession()
    162113{
    163     /* Save uisession settings: */
     114    /* Save settings: */
    164115    saveSessionSettings();
    165116
    166     /* Cleanup main menu: */
     117    /* Cleanup main-menu: */
    167118    cleanupMenuPool();
    168119
     
    170121    cleanupFramebuffers();
    171122
    172     /* Destroy the console event handler */
    173     UIConsoleEventHandler::destroy();
    174 
    175 #if defined(Q_WS_WIN)
     123    /* Cleanup console event-handlers: */
     124    cleanupConsoleEventHandlers();
     125
     126#ifdef Q_WS_WIN
    176127    /* Destroy alpha cursor: */
    177128    if (m_alphaCursor)
    178129        DestroyIcon(m_alphaCursor);
    179 #endif
     130#endif /* Q_WS_WIN */
    180131}
    181132
     
    313264}
    314265
     266UIMachineLogic* UISession::machineLogic() const
     267{
     268    return uimachine()->machineLogic();
     269}
     270
    315271QWidget* UISession::mainMachineWindow() const
    316272{
    317     return uimachine()->machineLogic()->mainMachineWindow();
    318 }
    319 
    320 UIMachineLogic* UISession::machineLogic() const
    321 {
    322     return uimachine()->machineLogic();
     273    return machineLogic()->mainMachineWindow();
    323274}
    324275
     
    349300bool UISession::setPause(bool fOn)
    350301{
    351     /* Commenting it out as isPaused() could reflect
    352      * quite obsolete state due to synchronization: */
    353     //if (isPaused() == fOn)
    354     //    return true;
    355 
    356302    CConsole console = session().GetConsole();
    357303
     
    655601}
    656602
     603void UISession::prepareConsoleEventHandlers()
     604{
     605    /* Initialize console event-handler: */
     606    UIConsoleEventHandler::instance(this);
     607
     608    /* Add console event connections: */
     609    connect(gConsoleEvents, SIGNAL(sigMousePointerShapeChange(bool, bool, QPoint, QSize, QVector<uint8_t>)),
     610            this, SLOT(sltMousePointerShapeChange(bool, bool, QPoint, QSize, QVector<uint8_t>)));
     611
     612    connect(gConsoleEvents, SIGNAL(sigMouseCapabilityChange(bool, bool, bool)),
     613            this, SLOT(sltMouseCapabilityChange(bool, bool, bool)));
     614
     615    connect(gConsoleEvents, SIGNAL(sigKeyboardLedsChangeEvent(bool, bool, bool)),
     616            this, SLOT(sltKeyboardLedsChangeEvent(bool, bool, bool)));
     617
     618    connect(gConsoleEvents, SIGNAL(sigStateChange(KMachineState)),
     619            this, SLOT(sltStateChange(KMachineState)));
     620
     621    connect(gConsoleEvents, SIGNAL(sigAdditionsChange()),
     622            this, SLOT(sltAdditionsChange()));
     623
     624    connect(gConsoleEvents, SIGNAL(sigVRDEChange()),
     625            this, SLOT(sltVRDEChange()));
     626
     627    connect(gConsoleEvents, SIGNAL(sigNetworkAdapterChange(CNetworkAdapter)),
     628            this, SIGNAL(sigNetworkAdapterChange(CNetworkAdapter)));
     629
     630    connect(gConsoleEvents, SIGNAL(sigMediumChange(CMediumAttachment)),
     631            this, SIGNAL(sigMediumChange(CMediumAttachment)));
     632
     633    connect(gConsoleEvents, SIGNAL(sigUSBControllerChange()),
     634            this, SIGNAL(sigUSBControllerChange()));
     635
     636    connect(gConsoleEvents, SIGNAL(sigUSBDeviceStateChange(CUSBDevice, bool, CVirtualBoxErrorInfo)),
     637            this, SIGNAL(sigUSBDeviceStateChange(CUSBDevice, bool, CVirtualBoxErrorInfo)));
     638
     639    connect(gConsoleEvents, SIGNAL(sigSharedFolderChange()),
     640            this, SIGNAL(sigSharedFolderChange()));
     641
     642    connect(gConsoleEvents, SIGNAL(sigRuntimeError(bool, QString, QString)),
     643            this, SIGNAL(sigRuntimeError(bool, QString, QString)));
     644
     645#ifdef Q_WS_MAC
     646    connect(gConsoleEvents, SIGNAL(sigShowWindow()),
     647            this, SIGNAL(sigShowWindows()), Qt::QueuedConnection);
     648#endif /* Q_WS_MAC */
     649
     650    connect(gConsoleEvents, SIGNAL(sigCPUExecutionCapChange()),
     651            this, SIGNAL(sigCPUExecutionCapChange()));
     652
     653    connect(gConsoleEvents, SIGNAL(sigGuestMonitorChange(KGuestMonitorChangedEventType, ulong, QRect)),
     654            this, SIGNAL(sigGuestMonitorChange(KGuestMonitorChangedEventType, ulong, QRect)));
     655}
     656
    657657void UISession::prepareFramebuffers()
    658658{
     
    749749    }
    750750    m_frameBufferVector.clear();
     751}
     752
     753void UISession::cleanupConsoleEventHandlers()
     754{
     755    /* Destroy console event-handler: */
     756    UIConsoleEventHandler::destroy();
    751757}
    752758
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r41051 r41484  
    8888    CSession& session() { return m_session; }
    8989    KMachineState machineState() const { return m_machineState; }
     90    UIMachineLogic* machineLogic() const;
    9091    QWidget* mainMachineWindow() const;
    91     UIMachineLogic* machineLogic() const;
    9292    QMenu* newMenu(UIMainMenuType fOptions = UIMainMenuType_All);
    9393    QMenuBar* newMenuBar(UIMainMenuType fOptions = UIMainMenuType_All);
     
    201201
    202202    /* Prepare helpers: */
     203    void prepareConsoleEventHandlers();
    203204    void prepareFramebuffers();
    204205    void prepareMenuPool();
     
    209210    void cleanupMenuPool();
    210211    void cleanupFramebuffers();
     212    void cleanupConsoleEventHandlers();
    211213
    212214    /* Common helpers: */
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