VirtualBox

Changeset 51565 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jun 6, 2014 10:51:02 AM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
94230
Message:

FE/Qt: 6660: Advanced extra-data management framework: Integrate GUI_Fullscreen, GUI_Seamless, GUI_Scale.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r51558 r51565  
    791791}
    792792
    793 UIVisualStateType UIExtraDataManager::restrictedVisualStateTypes(const QString &strID) const
     793UIVisualStateType UIExtraDataManager::restrictedVisualStates(const QString &strID) const
    794794{
    795795    /* Prepare result: */
     
    804804    /* Return result: */
    805805    return result;
     806}
     807
     808UIVisualStateType UIExtraDataManager::requestedVisualState(const QString &strID) const
     809{
     810    if (isFeatureAllowed(GUI_Fullscreen, strID)) return UIVisualStateType_Fullscreen;
     811    if (isFeatureAllowed(GUI_Seamless, strID)) return UIVisualStateType_Seamless;
     812    if (isFeatureAllowed(GUI_Scale, strID)) return UIVisualStateType_Scale;
     813    return UIVisualStateType_Normal;
     814}
     815
     816void UIExtraDataManager::setRequestedVisualState(UIVisualStateType visualState, const QString &strID)
     817{
     818    setExtraDataString(GUI_Fullscreen, toFeatureAllowed(visualState == UIVisualStateType_Fullscreen), strID);
     819    setExtraDataString(GUI_Seamless, toFeatureAllowed(visualState == UIVisualStateType_Seamless), strID);
     820    setExtraDataString(GUI_Scale, toFeatureAllowed(visualState == UIVisualStateType_Scale), strID);
    806821}
    807822
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r51558 r51565  
    227227    RuntimeMenuHelpActionType restrictedRuntimeMenuHelpActionTypes(const QString &strID) const;
    228228
    229     /** Returns restricted Runtime UI visual-state types. */
    230     UIVisualStateType restrictedVisualStateTypes(const QString &strID) const;
     229    /** Returns restricted Runtime UI visual-states. */
     230    UIVisualStateType restrictedVisualStates(const QString &strID) const;
     231
     232    /** Returns requested Runtime UI visual-state. */
     233    UIVisualStateType requestedVisualState(const QString &strID) const;
     234    /** Defines requested Runtime UI visual-state as @a visualState. */
     235    void setRequestedVisualState(UIVisualStateType visualState, const QString &strID);
    231236
    232237    /** Returns default machine close action. */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r51456 r51565  
    40214021    /* process command line */
    40224022
    4023     bool bForceSeamless = false;
    4024     bool bForceFullscreen = false;
     4023    UIVisualStateType visualStateType = UIVisualStateType_Invalid;
    40254024
    40264025#ifdef Q_WS_X11
     
    40674066        }
    40684067#endif /* VBOX_GUI_WITH_PIDFILE */
     4068        else if (!::strcmp(arg, "-fullscreen") || !::strcmp(arg, "--fullscreen"))
     4069        {
     4070            visualStateType = UIVisualStateType_Fullscreen;
     4071        }
    40694072        else if (!::strcmp(arg, "-seamless") || !::strcmp(arg, "--seamless"))
    40704073        {
    4071             bForceSeamless = true;
    4072         }
    4073         else if (!::strcmp(arg, "-fullscreen") || !::strcmp(arg, "--fullscreen"))
    4074         {
    4075             bForceFullscreen = true;
     4074            visualStateType = UIVisualStateType_Seamless;
     4075        }
     4076        else if (!::strcmp(arg, "-scale") || !::strcmp(arg, "--scale"))
     4077        {
     4078            visualStateType = UIVisualStateType_Scale;
    40764079        }
    40774080        else if (!::strcmp (arg, "-comment") || !::strcmp (arg, "--comment"))
     
    42364239        mVBox.SetSettingsSecret(mSettingsPw);
    42374240
    4238     if (bForceSeamless && !vmUuid.isEmpty())
    4239     {
    4240         mVBox.FindMachine(vmUuid).SetExtraData(GUI_Seamless, "on");
    4241     }
    4242     else if (bForceFullscreen && !vmUuid.isEmpty())
    4243     {
    4244         mVBox.FindMachine(vmUuid).SetExtraData(GUI_Fullscreen, "on");
    4245     }
     4241    if (visualStateType != UIVisualStateType_Invalid && !vmUuid.isEmpty())
     4242        gEDataManager->setRequestedVisualState(visualStateType, vmUuid);
    42464243
    42474244#ifdef VBOX_WITH_DEBUGGER_GUI
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r51054 r51565  
    8989    , m_pSession(0)
    9090    , m_pVisualState(0)
    91     , m_allowedVisualStateTypes(UIVisualStateType_Invalid)
     91    , m_allowedVisualStates(UIVisualStateType_Invalid)
    9292{
    9393    /* Store self pointer: */
     
    196196void UIMachine::loadMachineSettings()
    197197{
    198     /* Load machine settings: */
    199     CMachine machine = uisession()->session().GetMachine();
    200     UIVisualStateType restrictedVisualStateTypes = gEDataManager->restrictedVisualStateTypes(vboxGlobal().managedVMUuid());
    201     m_allowedVisualStateTypes = static_cast<UIVisualStateType>(UIVisualStateType_All ^ restrictedVisualStateTypes);
    202 
    203     /* Load extra-data settings: */
    204     {
    205         /* Machine while saving own settings will save "on" only for current
    206          * visual representation mode if its differs from normal mode of course.
    207          * But user can alter extra data manually in machine xml file and set there
    208          * more than one visual representation mode flags. Shame on such user!
    209          * There is no reason to enter in more than one visual representation mode
    210          * at machine start, so we are choosing first of requested modes: */
    211         bool fIsSomeExtendedModeChosen = false;
    212 
    213         if (!fIsSomeExtendedModeChosen)
     198    /* Load 'visual state' option: */
     199    {
     200        /* Load restricted visual states: */
     201        UIVisualStateType restrictedVisualStates = gEDataManager->restrictedVisualStates(vboxGlobal().managedVMUuid());
     202        /* Acquire allowed visual states: */
     203        m_allowedVisualStates = static_cast<UIVisualStateType>(UIVisualStateType_All ^ restrictedVisualStates);
     204
     205        /* Load requested visual state: */
     206        UIVisualStateType requestedVisualState = gEDataManager->requestedVisualState(vboxGlobal().managedVMUuid());
     207        /* Check if requested visual state type allowed: */
     208        if (isVisualStateAllowed(requestedVisualState))
    214209        {
    215             /* Test 'scale' flag: */
    216             QString strScaleSettings = machine.GetExtraData(GUI_Scale);
    217             if (strScaleSettings == "on" && isVisualStateAllowedScale())
     210            switch (requestedVisualState)
    218211            {
    219                 fIsSomeExtendedModeChosen = true;
    220                 /* We can enter scale mode initially: */
    221                 initialStateType = UIVisualStateType_Scale;
    222             }
    223         }
    224 
    225         if (!fIsSomeExtendedModeChosen)
    226         {
    227             /* Test 'seamless' flag: */
    228             QString strSeamlessSettings = machine.GetExtraData(GUI_Seamless);
    229             if (strSeamlessSettings == "on" && isVisualStateAllowedSeamless())
    230             {
    231                 fIsSomeExtendedModeChosen = true;
    232                 /* We can't enter seamless mode initially,
    233                  * so we should ask ui-session for that: */
    234                 uisession()->setRequestedVisualState(UIVisualStateType_Seamless);
    235             }
    236         }
    237 
    238         if (!fIsSomeExtendedModeChosen)
    239         {
    240             /* Test 'fullscreen' flag: */
    241             QString strFullscreenSettings = machine.GetExtraData(GUI_Fullscreen);
    242             if (strFullscreenSettings == "on" && isVisualStateAllowedFullscreen())
    243             {
    244                 fIsSomeExtendedModeChosen = true;
    245                 /* We can enter fullscreen mode initially: */
    246                 initialStateType = UIVisualStateType_Fullscreen;
    247             }
    248         }
    249     }
    250 }
    251 
    252 void UIMachine::saveMachineSettings()
    253 {
    254     /* Save machine settings: */
    255     CMachine machine = uisession()->session().GetMachine();
    256 
    257     /* Save extra-data settings: */
    258     {
    259         /* Prepare extra-data values: */
    260         QString strFullscreenRequested;
    261         QString strSeamlessRequested;
    262         QString strScaleRequested;
    263         /* Check if some state was requested: */
    264         if (uisession()->requestedVisualState() != UIVisualStateType_Invalid)
    265         {
    266             switch (uisession()->requestedVisualState())
    267             {
    268                 case UIVisualStateType_Fullscreen: strFullscreenRequested = "on"; break;
    269                 case UIVisualStateType_Seamless: strSeamlessRequested = "on"; break;
    270                 case UIVisualStateType_Scale: strScaleRequested = "on"; break;
     212                /* Direct transition to scale/fullscreen mode allowed: */
     213                case UIVisualStateType_Scale: initialStateType = UIVisualStateType_Scale; break;
     214                case UIVisualStateType_Fullscreen: initialStateType = UIVisualStateType_Fullscreen; break;
     215                /* While to seamless is not, so we have to request transition on GA capability-change event: */
     216                case UIVisualStateType_Seamless: uisession()->setRequestedVisualState(UIVisualStateType_Seamless); break;
    271217                default: break;
    272218            }
    273219        }
    274         /* Check if some state still exists: */
    275         else if (m_pVisualState)
     220    }
     221}
     222
     223void UIMachine::saveMachineSettings()
     224{
     225    /* Save 'visual state' option: */
     226    {
     227        /* Get requested visual state: */
     228        UIVisualStateType requestedVisualState = uisession()->requestedVisualState();
     229
     230        /* If requested state is invalid: */
     231        if (requestedVisualState == UIVisualStateType_Invalid)
    276232        {
    277             switch (m_pVisualState->visualStateType())
    278             {
    279                 case UIVisualStateType_Fullscreen: strFullscreenRequested = "on"; break;
    280                 case UIVisualStateType_Seamless: strSeamlessRequested = "on"; break;
    281                 case UIVisualStateType_Scale: strScaleRequested = "on"; break;
    282                 default: break;
    283             }
     233            /* Get current if still exists or normal otherwise: */
     234            requestedVisualState = m_pVisualState ? m_pVisualState->visualStateType() : UIVisualStateType_Normal;
    284235        }
    285         /* Rewrite extra-data values: */
    286         machine.SetExtraData(GUI_Fullscreen, strFullscreenRequested);
    287         machine.SetExtraData(GUI_Seamless, strSeamlessRequested);
    288         machine.SetExtraData(GUI_Scale, strScaleRequested);
     236
     237        /* Save requested visual state: */
     238        gEDataManager->setRequestedVisualState(requestedVisualState, vboxGlobal().managedVMUuid());
    289239    }
    290240}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r51187 r51565  
    5454    UISession *uisession() const { return m_pSession; }
    5555
    56     /* API: Visual-state stuff: */
    57     bool isVisualStateAllowedFullscreen() const { return m_allowedVisualStateTypes & UIVisualStateType_Fullscreen; }
    58     bool isVisualStateAllowedSeamless() const { return m_allowedVisualStateTypes & UIVisualStateType_Seamless; }
    59     bool isVisualStateAllowedScale() const { return m_allowedVisualStateTypes & UIVisualStateType_Scale; }
     56    /** Returns whether requested visual @a state allowed. */
     57    bool isVisualStateAllowed(UIVisualStateType state) const { return m_allowedVisualStates & state; }
    6058
    6159    /** Requests async visual-state change. */
     
    8785    UISession *m_pSession;
    8886    UIVisualState *m_pVisualState;
    89     UIVisualStateType m_allowedVisualStateTypes;
     87    UIVisualStateType m_allowedVisualStates;
    9088
    9189    /* Friend classes: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r51476 r51565  
    503503    /* Update action states: */
    504504    gActionPool->action(UIActionIndexRuntime_Toggle_GuestAutoresize)->setEnabled(uisession()->isGuestSupportsGraphics());
    505     gActionPool->action(UIActionIndexRuntime_Toggle_Seamless)->setEnabled(uisession()->isVisualStateAllowedSeamless() && uisession()->isGuestSupportsSeamless());
     505    gActionPool->action(UIActionIndexRuntime_Toggle_Seamless)->setEnabled(uisession()->isVisualStateAllowed(UIVisualStateType_Seamless) &&
     506                                                                          uisession()->isGuestSupportsSeamless());
    506507}
    507508
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineMenuBar.cpp

    r51398 r51565  
    356356
    357357    /* Mode flags: */
    358     bool fIsAllowedFullscreen = m_pSession->isVisualStateAllowedFullscreen() &&
     358    bool fIsAllowedFullscreen = m_pSession->isVisualStateAllowed(UIVisualStateType_Fullscreen) &&
    359359                                (m_pSession->allowedActionsMenuView() & RuntimeMenuViewActionType_Fullscreen);
    360     bool fIsAllowedSeamless = m_pSession->isVisualStateAllowedSeamless() &&
     360    bool fIsAllowedSeamless = m_pSession->isVisualStateAllowed(UIVisualStateType_Seamless) &&
    361361                              (m_pSession->allowedActionsMenuView() & RuntimeMenuViewActionType_Seamless);
    362     bool fIsAllowedScale = m_pSession->isVisualStateAllowedScale() &&
     362    bool fIsAllowedScale = m_pSession->isVisualStateAllowed(UIVisualStateType_Scale) &&
    363363                           (m_pSession->allowedActionsMenuView() & RuntimeMenuViewActionType_Scale);
    364364
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r51436 r51565  
    507507}
    508508
    509 bool UISession::isVisualStateAllowedFullscreen() const
    510 {
    511     return m_pMachine->isVisualStateAllowedFullscreen();
    512 }
    513 
    514 bool UISession::isVisualStateAllowedSeamless() const
    515 {
    516     return m_pMachine->isVisualStateAllowedSeamless();
    517 }
    518 
    519 bool UISession::isVisualStateAllowedScale() const
    520 {
    521     return m_pMachine->isVisualStateAllowedScale();
     509bool UISession::isVisualStateAllowed(UIVisualStateType state) const
     510{
     511    return m_pMachine->isVisualStateAllowed(state);
    522512}
    523513
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r51395 r51565  
    157157    /** @} */
    158158
    159     /* API: Visual-state stuff: */
    160     bool isVisualStateAllowedFullscreen() const;
    161     bool isVisualStateAllowedSeamless() const;
    162     bool isVisualStateAllowedScale() const;
     159    /** Returns whether visual @a state is allowed. */
     160    bool isVisualStateAllowed(UIVisualStateType state) const;
    163161    /** Requests visual-state change. */
    164162    void changeVisualState(UIVisualStateType visualStateType);
Note: See TracChangeset for help on using the changeset viewer.

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