VirtualBox

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


Ignore:
Timestamp:
Oct 13, 2014 3:01:22 PM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: Runtime UI rework/cleanup for 7115 (part #16): Better encapsulation for UISession (part #1).

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

Legend:

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

    r53043 r53046  
    213213    prepareMachineLogic();
    214214
    215     /* Now power up the machine.
    216      * Actually powerUp does more that just a power up,
    217      * so call it regardless of isSeparateProcess setting. */
    218     uisession()->powerUp();
    219 
    220     /* Initialization of MachineLogic internals after the powerUp.
    221      * This is a hack, maybe more generic approach can be used. */
    222     machineLogic()->initializePostPowerUp();
     215    /* Try to initialize session UI: */
     216    if (!uisession()->initialize())
     217        return false;
    223218
    224219    /* True by default: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r53030 r53046  
    829829{
    830830    /* We should check for entering/exiting requested modes: */
    831     connect(uisession(), SIGNAL(sigStarted()), this, SLOT(sltCheckForRequestedVisualStateType()));
     831    connect(uisession(), SIGNAL(sigInitialized()), this, SLOT(sltCheckForRequestedVisualStateType()));
    832832    connect(uisession(), SIGNAL(sigAdditionsStateChange()), this, SLOT(sltCheckForRequestedVisualStateType()));
    833833
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r53029 r53046  
    156156}
    157157
    158 void UISession::powerUp()
    159 {
    160     /* Prepare powerup: */
    161     bool fPrepared = preparePowerUp();
    162     if (!fPrepared)
    163         return;
     158bool UISession::initialize()
     159{
     160    /* Preprocess initialization: */
     161    if (!preprocessInitialization())
     162        return false;
     163
     164    /* Notify user about mouse&keyboard auto-capturing: */
     165    if (vboxGlobal().settings().autoCapture())
     166        popupCenter().remindAboutAutoCapture(machineLogic()->activeMachineWindow());
     167
     168    /* Check if we are in teleportation waiting mode.
     169     * In that case no first run wizard is necessary. */
     170    m_machineState = machine().GetState();
     171    if (   isFirstTimeStarted()
     172        && !((   m_machineState == KMachineState_PoweredOff
     173              || m_machineState == KMachineState_Aborted
     174              || m_machineState == KMachineState_Teleported)
     175             && machine().GetTeleporterEnabled()))
     176    {
     177        UISafePointerWizard pWizard = new UIWizardFirstRun(mainMachineWindow(), machine());
     178        pWizard->prepare();
     179        pWizard->exec();
     180        if (pWizard)
     181            delete pWizard;
     182    }
    164183
    165184    /* Apply debug settings from the command line. */
    166     if (debugger().isOk())
     185    if (!debugger().isNull() && debugger().isOk())
    167186    {
    168187        if (vboxGlobal().isPatmDisabled())
     
    180199    }
    181200
     201    /* Power UP if this is NOT separate process: */
    182202    if (!vboxGlobal().isSeparateProcess())
    183     {
    184         /* Power UP machine: */
    185 #ifdef VBOX_WITH_DEBUGGER_GUI
    186         CProgress progress = vboxGlobal().isStartPausedEnabled() || vboxGlobal().isDebuggerAutoShowEnabled() ?
    187                              console().PowerUpPaused() : console().PowerUp();
    188 #else /* !VBOX_WITH_DEBUGGER_GUI */
    189         CProgress progress = console().PowerUp();
    190 #endif /* !VBOX_WITH_DEBUGGER_GUI */
    191 
    192         /* Check for immediate failure: */
    193         if (!console().isOk())
    194         {
    195             if (vboxGlobal().showStartVMErrors())
    196                 msgCenter().cannotStartMachine(console(), machineName());
    197             closeRuntimeUI();
    198             return;
    199         }
    200 
    201         /* Guard progressbar warnings from auto-closing: */
    202         if (uimachine()->machineLogic())
    203             uimachine()->machineLogic()->setPreventAutoClose(true);
    204 
    205         /* Show "Starting/Restoring" progress dialog: */
    206         if (isSaved())
    207         {
    208             msgCenter().showModalProgressDialog(progress, machineName(), ":/progress_state_restore_90px.png", 0, 0);
    209             /* After restoring from 'saved' state, machine-window(s) geometry should be adjusted: */
    210             machineLogic()->adjustMachineWindowsGeometry();
    211         }
    212         else
    213             msgCenter().showModalProgressDialog(progress, machineName(), ":/progress_start_90px.png");
    214 
    215         /* Check for a progress failure: */
    216         if (!progress.isOk() || progress.GetResultCode() != 0)
    217         {
    218             if (vboxGlobal().showStartVMErrors())
    219                 msgCenter().cannotStartMachine(progress, machineName());
    220             closeRuntimeUI();
    221             return;
    222         }
    223 
    224         /* Allow further auto-closing: */
    225         if (uimachine()->machineLogic())
    226             uimachine()->machineLogic()->setPreventAutoClose(false);
    227     }
    228     else
    229     {
    230         /* Fetch the current mouse state: */
     203        if (!powerUp())
     204            return false;
     205
     206    /* Check if we missed a really quick termination after successful startup: */
     207    if (isTurnedOff())
     208        return false;
     209
     210    /* Postprocess initialization: */
     211    if (!postprocessInitialization())
     212        return false;
     213
     214    /* Fetch corresponding states: */
     215    if (vboxGlobal().isSeparateProcess())
     216    {
    231217        m_fIsMouseSupportsAbsolute = mouse().GetAbsoluteSupported();
    232218        m_fIsMouseSupportsRelative = mouse().GetRelativeSupported();
    233219        m_fIsMouseSupportsMultiTouch = mouse().GetMultiTouchSupported();
    234220        m_fIsMouseHostCursorNeeded = mouse().GetNeedsHostCursor();
    235         /* Fetch the current guest additions state: */
    236221        sltAdditionsChange();
    237222    }
    238 
    239     /* Check if we missed a really quick termination after successful startup, and process it if we did: */
    240     if (isTurnedOff())
    241     {
    242         closeRuntimeUI();
    243         return;
    244     }
    245 
    246     /* Check if the required virtualization features are active. We get this info only when the session is active. */
    247     const bool fIs64BitsGuest = vboxGlobal().virtualBox().GetGuestOSType(guest().GetOSTypeId()).GetIs64Bit();
    248     const bool fRecommendVirtEx = vboxGlobal().virtualBox().GetGuestOSType(guest().GetOSTypeId()).GetRecommendedVirtEx();
    249     AssertMsg(!fIs64BitsGuest || fRecommendVirtEx, ("Virtualization support missed for 64bit guest!\n"));
    250     bool fIsVirtEnabled = debugger().GetHWVirtExEnabled();
    251     if (fRecommendVirtEx && !fIsVirtEnabled)
    252     {
    253         bool fShouldWeClose;
    254 
    255         bool fVTxAMDVSupported = vboxGlobal().host().GetProcessorFeature(KProcessorFeature_HWVirtEx);
    256 
    257         QApplication::processEvents();
    258         setPause(true);
    259 
    260         if (fIs64BitsGuest)
    261             fShouldWeClose = msgCenter().warnAboutVirtNotEnabled64BitsGuest(fVTxAMDVSupported);
    262         else
    263             fShouldWeClose = msgCenter().warnAboutVirtNotEnabledGuestRequired(fVTxAMDVSupported);
    264 
    265         if (fShouldWeClose)
    266         {
    267             /* At this point the console is powered up.
    268              * So we have to close this session again. */
    269             CProgress progress = console().PowerDown();
    270             if (console().isOk())
    271             {
    272                 /* Guard progressbar warnings from auto-closing: */
    273                 if (uimachine()->machineLogic())
    274                     uimachine()->machineLogic()->setPreventAutoClose(true);
    275                 /* Show the power down progress dialog */
    276                 msgCenter().showModalProgressDialog(progress, machineName(), ":/progress_poweroff_90px.png");
    277                 if (!progress.isOk() || progress.GetResultCode() != 0)
    278                     msgCenter().cannotPowerDownMachine(progress, machineName());
    279                 /* Allow further auto-closing: */
    280                 if (uimachine()->machineLogic())
    281                     uimachine()->machineLogic()->setPreventAutoClose(false);
    282             }
    283             else
    284                 msgCenter().cannotPowerDownMachine(console());
    285             closeRuntimeUI();
    286             return;
    287         }
    288 
    289         setPause(false);
    290     }
     223    machineLogic()->initializePostPowerUp();
    291224
    292225#ifdef VBOX_WITH_VIDEOHWACCEL
     226    /* Log whether 2D video acceleration is enabled: */
    293227    LogRel(("2D video acceleration is %s.\n",
    294228           machine().GetAccelerate2DVideoEnabled() && VBoxGlobal::isAcceleration2DVideoAvailable()
    295                  ? "enabled"
    296                  : "disabled"));
     229           ? "enabled" : "disabled"));
    297230#endif /* VBOX_WITH_VIDEOHWACCEL */
    298231
    299 /* Check if HID LEDs sync is enabled and add a log message about it. */
     232/* Log whether HID LEDs sync is enabled: */
    300233#if defined(Q_WS_MAC) || defined(Q_WS_WIN)
    301     if(uimachine()->machineLogic()->isHidLedsSyncEnabled())
    302         LogRel(("HID LEDs sync is enabled.\n"));
    303     else
    304         LogRel(("HID LEDs sync is disabled.\n"));
    305 #else
     234    LogRel(("HID LEDs sync is %s.\n",
     235            uimachine()->machineLogic()->isHidLedsSyncEnabled()
     236            ? "enabled" : "disabled"));
     237#else /* !Q_WS_MAC && !Q_WS_WIN */
    306238    LogRel(("HID LEDs sync is not supported on this platform.\n"));
    307 #endif
     239#endif /* !Q_WS_MAC && !Q_WS_WIN */
    308240
    309241#ifdef VBOX_GUI_WITH_PIDFILE
    310242    vboxGlobal().createPidfile();
    311 #endif
    312 
    313     /* Warn listeners about machine was started: */
    314     emit sigStarted();
     243#endif /* VBOX_GUI_WITH_PIDFILE */
     244
     245    /* Warn listeners about we are initialized: */
     246    emit sigInitialized();
     247
     248    /* True by default: */
     249    return true;
     250}
     251
     252bool UISession::powerUp()
     253{
     254    /* Power UP machine: */
     255#ifdef VBOX_WITH_DEBUGGER_GUI
     256    CProgress progress = vboxGlobal().isStartPausedEnabled() || vboxGlobal().isDebuggerAutoShowEnabled() ?
     257                         console().PowerUpPaused() : console().PowerUp();
     258#else /* !VBOX_WITH_DEBUGGER_GUI */
     259    CProgress progress = console().PowerUp();
     260#endif /* !VBOX_WITH_DEBUGGER_GUI */
     261
     262    /* Check for immediate failure: */
     263    if (!console().isOk() || progress.isNull())
     264    {
     265        if (vboxGlobal().showStartVMErrors())
     266            msgCenter().cannotStartMachine(console(), machineName());
     267        return false;
     268    }
     269
     270    /* Guard progressbar warnings from auto-closing: */
     271    if (uimachine()->machineLogic())
     272        uimachine()->machineLogic()->setPreventAutoClose(true);
     273
     274    /* Show "Starting/Restoring" progress dialog: */
     275    if (isSaved())
     276    {
     277        msgCenter().showModalProgressDialog(progress, machineName(), ":/progress_state_restore_90px.png", 0, 0);
     278        /* After restoring from 'saved' state, machine-window(s) geometry should be adjusted: */
     279        machineLogic()->adjustMachineWindowsGeometry();
     280    }
     281    else
     282        msgCenter().showModalProgressDialog(progress, machineName(), ":/progress_start_90px.png");
     283
     284    /* Check for progress failure: */
     285    if (!progress.isOk() || progress.GetResultCode() != 0)
     286    {
     287        if (vboxGlobal().showStartVMErrors())
     288            msgCenter().cannotStartMachine(progress, machineName());
     289        return false;
     290    }
     291
     292    /* Allow further auto-closing: */
     293    if (uimachine()->machineLogic())
     294        uimachine()->machineLogic()->setPreventAutoClose(false);
     295
     296    /* True by default: */
     297    return true;
    315298}
    316299
     
    891874    , m_fAllCloseActionsRestricted(false)
    892875    /* Common flags: */
    893     , m_fIsStarted(false)
     876    , m_fInitialized(false)
    894877    , m_fIsFirstTimeStarted(false)
    895878    , m_fIsGuestResizeIgnored(false)
     
    11011084void UISession::prepareConnections()
    11021085{
    1103     connect(this, SIGNAL(sigStarted()), this, SLOT(sltMarkStarted()));
     1086    connect(this, SIGNAL(sigInitialized()), this, SLOT(sltMarkInitialized()));
    11041087    connect(this, SIGNAL(sigCloseRuntimeUI()), this, SLOT(sltCloseRuntimeUI()));
    11051088
     
    16821665}
    16831666
    1684 bool UISession::preparePowerUp()
    1685 {
    1686     /* Notify user about mouse&keyboard auto-capturing: */
    1687     if (vboxGlobal().settings().autoCapture())
    1688         popupCenter().remindAboutAutoCapture(machineLogic()->activeMachineWindow());
    1689 
    1690     /* Check if we are in teleportation waiting mode.
    1691      * In that case no first run wizard is necessary. */
    1692     m_machineState = machine().GetState();
    1693     if (   isFirstTimeStarted()
    1694         && !((   m_machineState == KMachineState_PoweredOff
    1695               || m_machineState == KMachineState_Aborted
    1696               || m_machineState == KMachineState_Teleported)
    1697              && machine().GetTeleporterEnabled()))
    1698     {
    1699         UISafePointerWizard pWizard = new UIWizardFirstRun(mainMachineWindow(), machine());
    1700         pWizard->prepare();
    1701         pWizard->exec();
    1702         if (pWizard)
    1703             delete pWizard;
    1704     }
    1705 
     1667bool UISession::preprocessInitialization()
     1668{
    17061669#ifdef VBOX_WITH_NETFLT
    17071670    /* Skip further checks if VM in saved state */
     
    17581721    if (!failedInterfaceNames.isEmpty())
    17591722    {
    1760         if (msgCenter().UIMessageCenter::cannotStartWithoutNetworkIf(machineName(), failedInterfaceNames.join(", ")))
     1723        if (msgCenter().cannotStartWithoutNetworkIf(machineName(), failedInterfaceNames.join(", ")))
    17611724            machineLogic()->openNetworkSettingsDialog();
    17621725        else
    1763         {
    1764             closeRuntimeUI();
    17651726            return false;
    1766         }
    17671727    }
    17681728#endif /* VBOX_WITH_NETFLT */
    17691729
     1730    /* True by default: */
     1731    return true;
     1732}
     1733
     1734bool UISession::postprocessInitialization()
     1735{
     1736    /* Check if the required virtualization features are active. We get this info only when the session is active. */
     1737    const bool fIs64BitsGuest = vboxGlobal().virtualBox().GetGuestOSType(guest().GetOSTypeId()).GetIs64Bit();
     1738    const bool fRecommendVirtEx = vboxGlobal().virtualBox().GetGuestOSType(guest().GetOSTypeId()).GetRecommendedVirtEx();
     1739    AssertMsg(!fIs64BitsGuest || fRecommendVirtEx, ("Virtualization support missed for 64bit guest!\n"));
     1740    bool fIsVirtEnabled = debugger().GetHWVirtExEnabled();
     1741    if (fRecommendVirtEx && !fIsVirtEnabled)
     1742    {
     1743        /* Check whether vt-x / amd-v supported: */
     1744        bool fVTxAMDVSupported = vboxGlobal().host().GetProcessorFeature(KProcessorFeature_HWVirtEx);
     1745
     1746        /* Pause VM: */
     1747        setPause(true);
     1748
     1749        /* Ask the user about further actions: */
     1750        bool fShouldWeClose;
     1751        if (fIs64BitsGuest)
     1752            fShouldWeClose = msgCenter().warnAboutVirtNotEnabled64BitsGuest(fVTxAMDVSupported);
     1753        else
     1754            fShouldWeClose = msgCenter().warnAboutVirtNotEnabledGuestRequired(fVTxAMDVSupported);
     1755
     1756        /* If user asked to close VM: */
     1757        if (fShouldWeClose)
     1758        {
     1759            /* Prevent auto-closure during power off sequence: */
     1760            machineLogic()->setPreventAutoClose(true);
     1761            /* Power off VM: */
     1762            bool fServerCrashed = false;
     1763            powerOff(false, fServerCrashed);
     1764            return false;
     1765        }
     1766
     1767        /* Resume VM: */
     1768        setPause(false);
     1769    }
     1770
     1771    /* True by default: */
    17701772    return true;
    17711773}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r53029 r53046  
    9090
    9191    /* API: Runtime UI stuff: */
    92     void powerUp();
     92    bool initialize();
     93    bool powerUp();
    9394    bool saveState();
    9495    bool shutdown();
     
    181182    bool wasPaused() const { return machineStatePrevious() == KMachineState_Paused ||
    182183                                    machineStatePrevious() == KMachineState_TeleportingPausedVM; }
    183     bool isStarted() const { return m_fIsStarted; }
     184    bool isInitialized() const { return m_fInitialized; }
    184185    bool isFirstTimeStarted() const { return m_fIsFirstTimeStarted; }
    185186    bool isGuestResizeIgnored() const { return m_fIsGuestResizeIgnored; }
     
    285286
    286287    /* Session signals: */
    287     void sigStarted();
     288    void sigInitialized();
    288289
    289290public slots:
     
    300301
    301302    /** Marks machine started. */
    302     void sltMarkStarted() { m_fIsStarted = true; }
     303    void sltMarkInitialized() { m_fInitialized = true; }
    303304
    304305    /* Handler: Close Runtime UI stuff: */
     
    371372    WId winId() const;
    372373    void setPointerShape(const uchar *pShapeData, bool fHasAlpha, uint uXHot, uint uYHot, uint uWidth, uint uHeight);
    373     bool preparePowerUp();
     374    bool preprocessInitialization();
     375    bool postprocessInitialization();
    374376    int countOfVisibleWindows();
    375377
     
    470472
    471473    /* Common flags: */
    472     bool m_fIsStarted : 1;
     474    bool m_fInitialized : 1;
    473475    bool m_fIsFirstTimeStarted : 1;
    474476    bool m_fIsGuestResizeIgnored : 1;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp

    r52889 r53046  
    285285        uisession()->setRequestedVisualState(UIVisualStateType_Normal);
    286286
    287         /* If session started already => push mode-change directly: */
    288         if (uisession()->isStarted())
     287        /* If session already initialized => push mode-change directly: */
     288        if (uisession()->isInitialized())
    289289            sltCheckForRequestedVisualStateType();
    290290    }
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