VirtualBox

Changeset 53040 in vbox for trunk


Ignore:
Timestamp:
Oct 13, 2014 1:08:07 PM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: Runtime UI rework/cleanup for 7115 (part #14): Better encapsulation for UIMachine (part #4).

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

Legend:

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

    r53000 r53040  
    251251bool UIMachine::prepare()
    252252{
     253    /* Try to prepare session UI: */
     254    if (!prepareSession())
     255        return false;
     256
     257    /* Prevent application from closing when all window(s) closed: */
     258    qApp->setQuitOnLastWindowClosed(false);
     259
     260    /* Cache medium data if necessary: */
     261    vboxGlobal().startMediumEnumeration(false /* force start */);
     262
     263    /* Prepare visual state: */
     264    prepareVisualState();
     265
     266    /* Now power up the machine.
     267     * Actually powerUp does more that just a power up,
     268     * so call it regardless of isSeparateProcess setting. */
     269    uisession()->powerUp();
     270
     271    /* Initialization of MachineLogic internals after the powerUp.
     272     * This is a hack, maybe more generic approach can be used. */
     273    machineLogic()->initializePostPowerUp();
     274
     275    /* True by default: */
     276    return true;
     277}
     278
     279bool UIMachine::prepareSession()
     280{
    253281    /* Try to create session UI: */
    254282    if (!UISession::create(m_pSession, this))
    255283        return false;
    256284
    257     /* Preventing application from closing in case of window(s) closed: */
    258     qApp->setQuitOnLastWindowClosed(false);
    259 
    260     /* Cache medium data only if really necessary: */
    261     vboxGlobal().startMediumEnumeration(false /* force start */);
    262 
    263     /* Load settings: */
    264     loadSettings();
    265 
    266     /* Prepare async visual-state change handler: */
     285    /* True by default: */
     286    return true;
     287}
     288
     289void UIMachine::prepareVisualState()
     290{
     291    /* Prepare async visual state type change handler: */
    267292    qRegisterMetaType<UIVisualStateType>();
    268293    connect(this, SIGNAL(sigRequestAsyncVisualStateChange(UIVisualStateType)),
     
    270295            Qt::QueuedConnection);
    271296
    272     /* Enter default (normal) state */
     297    /* Load restricted visual states: */
     298    UIVisualStateType restrictedVisualStates = gEDataManager->restrictedVisualStates(vboxGlobal().managedVMUuid());
     299    /* Acquire allowed visual states: */
     300    m_allowedVisualStates = static_cast<UIVisualStateType>(UIVisualStateType_All ^ restrictedVisualStates);
     301
     302    /* Load requested visual state: */
     303    UIVisualStateType requestedVisualState = gEDataManager->requestedVisualState(vboxGlobal().managedVMUuid());
     304    /* Check if requested visual state is allowed: */
     305    if (isVisualStateAllowed(requestedVisualState))
     306    {
     307        switch (requestedVisualState)
     308        {
     309            /* Direct transition to scale/fullscreen mode allowed: */
     310            case UIVisualStateType_Scale:      m_initialStateType = UIVisualStateType_Scale; break;
     311            case UIVisualStateType_Fullscreen: m_initialStateType = UIVisualStateType_Fullscreen; break;
     312            /* While to seamless is not, so we have to make request to do transition later: */
     313            case UIVisualStateType_Seamless:   uisession()->setRequestedVisualState(UIVisualStateType_Seamless); break;
     314            default: break;
     315        }
     316    }
     317
     318    /* Enter initial visual state: */
    273319    enterInitialVisualState();
    274 
    275     /* Now power up the machine.
    276      * Actually powerUp does more that just a power up,
    277      * so call it regardless of isSeparateProcess setting. */
    278     uisession()->powerUp();
    279 
    280     /* Initialization of MachineLogic internals after the powerUp.
    281      * This is a hack, maybe more generic approach can be used. */
    282     machineLogic()->initializePostPowerUp();
    283 
    284     /* True by default: */
    285     return true;
    286 }
    287 
    288 void UIMachine::loadSettings()
    289 {
    290     /* Load 'visual state' option: */
    291     if (uisession())
    292     {
    293         /* Load restricted visual states: */
    294         UIVisualStateType restrictedVisualStates = gEDataManager->restrictedVisualStates(vboxGlobal().managedVMUuid());
    295         /* Acquire allowed visual states: */
    296         m_allowedVisualStates = static_cast<UIVisualStateType>(UIVisualStateType_All ^ restrictedVisualStates);
    297 
    298         /* Load requested visual state: */
    299         UIVisualStateType requestedVisualState = gEDataManager->requestedVisualState(vboxGlobal().managedVMUuid());
    300         /* Check if requested visual state type allowed: */
    301         if (isVisualStateAllowed(requestedVisualState))
    302         {
    303             switch (requestedVisualState)
    304             {
    305                 /* Direct transition to scale/fullscreen mode allowed: */
    306                 case UIVisualStateType_Scale: m_initialStateType = UIVisualStateType_Scale; break;
    307                 case UIVisualStateType_Fullscreen: m_initialStateType = UIVisualStateType_Fullscreen; break;
    308                 /* While to seamless is not, so we have to request transition on GA capability-change event: */
    309                 case UIVisualStateType_Seamless: uisession()->setRequestedVisualState(UIVisualStateType_Seamless); break;
    310                 default: break;
    311             }
    312         }
    313     }
    314 }
    315 
    316 void UIMachine::saveSettings()
    317 {
    318     /* Save 'visual state' option: */
     320}
     321
     322void UIMachine::cleanupVisualState()
     323{
     324    /* Session UI can have requested visual state: */
    319325    if (uisession())
    320326    {
    321327        /* Get requested visual state: */
    322328        UIVisualStateType requestedVisualState = uisession()->requestedVisualState();
    323 
    324329        /* If requested state is invalid: */
    325330        if (requestedVisualState == UIVisualStateType_Invalid)
     
    332337        gEDataManager->setRequestedVisualState(requestedVisualState, vboxGlobal().managedVMUuid());
    333338    }
    334 }
    335 
    336 void UIMachine::cleanup()
    337 {
    338     /* Save settings: */
    339     saveSettings();
    340339
    341340    /* Delete visual state: */
    342341    delete m_pVisualState;
    343342    m_pVisualState = 0;
    344 
     343}
     344
     345void UIMachine::cleanupSession()
     346{
    345347    /* Destroy session UI if necessary: */
    346348    if (uisession())
    347349        UISession::destroy(m_pSession);
     350}
     351
     352void UIMachine::cleanup()
     353{
     354    /* Cleanup visual state: */
     355    cleanupVisualState();
     356
     357    /* Cleanup session UI: */
     358    cleanupSession();
    348359
    349360    /* Quit application: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r53000 r53040  
    8484    /** Prepare routine. */
    8585    bool prepare();
    86     /** Prepare routine: Loading stuff. */
    87     void loadSettings();
    88     /** Cleanup routine: Saving stuff. */
    89     void saveSettings();
     86    /** Prepare routine: Session stuff. */
     87    bool prepareSession();
     88    /** Prepare routine: Visual state stuff. */
     89    void prepareVisualState();
     90
     91    /** Cleanup routine: Visual state stuff. */
     92    void cleanupVisualState();
     93    /** Cleanup routine: Session stuff. */
     94    void cleanupSession();
    9095    /** Cleanup routine. */
    9196    void cleanup();
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