VirtualBox

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


Ignore:
Timestamp:
Jul 30, 2013 2:54:39 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: Runtime UI: Adding extra-data flag 'GUI/RestrictedVisualStates' to restrict unwanted visual-representation states.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackend.h

    r47265 r47478  
    5757template<> bool canConvert<StorageSlot>();
    5858template<> bool canConvert<RuntimeMenuType>();
     59template<> bool canConvert<UIVisualStateType>();
    5960template<> bool canConvert<DetailsElementType>();
    6061template<> bool canConvert<GlobalSettingsPageType>();
     
    9192template<> QString toInternalString(const RuntimeMenuType &runtimeMenuType);
    9293template<> RuntimeMenuType fromInternalString<RuntimeMenuType>(const QString &strRuntimeMenuType);
     94template<> QString toInternalString(const UIVisualStateType &visualStateType);
     95template<> UIVisualStateType fromInternalString<UIVisualStateType>(const QString &strVisualStateType);
    9396template<> QString toString(const DetailsElementType &detailsElementType);
    9497template<> DetailsElementType fromString<DetailsElementType>(const QString &strDetailsElementType);
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp

    r46898 r47478  
    3333template<> bool canConvert<StorageSlot>() { return true; }
    3434template<> bool canConvert<RuntimeMenuType>() { return true; }
     35template<> bool canConvert<UIVisualStateType>() { return true; }
    3536template<> bool canConvert<DetailsElementType>() { return true; }
    3637template<> bool canConvert<GlobalSettingsPageType>() { return true; }
     
    305306    /* Corresponding type for known words: */
    306307    return values.at(keys.indexOf(QRegExp(strRuntimeMenuType, Qt::CaseInsensitive)));
     308}
     309
     310/* QString <= UIVisualStateType: */
     311template<> QString toInternalString(const UIVisualStateType &visualStateType)
     312{
     313    QString strResult;
     314    switch (visualStateType)
     315    {
     316        case UIVisualStateType_Normal:     strResult = "Normal"; break;
     317        case UIVisualStateType_Fullscreen: strResult = "Fullscreen"; break;
     318        case UIVisualStateType_Seamless:   strResult = "Seamless"; break;
     319        case UIVisualStateType_Scale:      strResult = "Scale"; break;
     320        case UIVisualStateType_All:        strResult = "All"; break;
     321        default:
     322        {
     323            AssertMsgFailed(("No text for visual state type=%d", visualStateType));
     324            break;
     325        }
     326    }
     327    return strResult;
     328}
     329
     330/* UIVisualStateType <= QString: */
     331template<> UIVisualStateType fromInternalString<UIVisualStateType>(const QString &strVisualStateType)
     332{
     333    /* Here we have some fancy stuff allowing us
     334     * to search through the keys using 'case-insensitive' rule: */
     335    QStringList keys;     QList<UIVisualStateType> values;
     336    keys << "Normal";     values << UIVisualStateType_Normal;
     337    keys << "Fullscreen"; values << UIVisualStateType_Fullscreen;
     338    keys << "Seamless";   values << UIVisualStateType_Seamless;
     339    keys << "Scale";      values << UIVisualStateType_Scale;
     340    keys << "All";        values << UIVisualStateType_All;
     341    /* Invalid type for unknown words: */
     342    if (!keys.contains(strVisualStateType, Qt::CaseInsensitive))
     343        return UIVisualStateType_Invalid;
     344    /* Corresponding type for known words: */
     345    return values.at(keys.indexOf(QRegExp(strVisualStateType, Qt::CaseInsensitive)));
    307346}
    308347
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDefs.cpp

    r46797 r47478  
    5353/* Machine-window definitions: */
    5454const char* UIDefs::GUI_RestrictedRuntimeMenus = "GUI/RestrictedRuntimeMenus";
     55const char* UIDefs::GUI_RestrictedVisualStates = "GUI/RestrictedVisualStates";
    5556const char* UIDefs::GUI_Input_MachineShortcuts = "GUI/Input/MachineShortcuts";
    5657const char* UIDefs::GUI_LastNormalWindowPosition = "GUI/LastNormalWindowPosition";
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDefs.h

    r46898 r47478  
    125125    /* Machine-window declarations: */
    126126    extern const char* GUI_RestrictedRuntimeMenus;
     127    extern const char* GUI_RestrictedVisualStates;
    127128    extern const char* GUI_Input_MachineShortcuts;
    128129    extern const char* GUI_LastNormalWindowPosition;
     
    240241};
    241242
     243/* Runtime UI visual-state types: */
     244enum UIVisualStateType
     245{
     246    UIVisualStateType_Invalid    = 0,
     247    UIVisualStateType_Normal     = RT_BIT(0),
     248    UIVisualStateType_Fullscreen = RT_BIT(1),
     249    UIVisualStateType_Seamless   = RT_BIT(2),
     250    UIVisualStateType_Scale      = RT_BIT(3),
     251    UIVisualStateType_All        = 0xFF
     252};
     253
    242254/* Details element type: */
    243255enum DetailsElementType
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r47401 r47478  
    37793779        if (value != RuntimeMenuType_Invalid)
    37803780            result = static_cast<RuntimeMenuType>(result | value);
     3781    }
     3782    /* Return result: */
     3783    return result;
     3784}
     3785
     3786/* static */
     3787UIVisualStateType VBoxGlobal::restrictedVisualStateTypes(CMachine &machine)
     3788{
     3789    /* Prepare result: */
     3790    UIVisualStateType result = UIVisualStateType_Invalid;
     3791    /* Load restricted visual-state-types: */
     3792    QString strList(machine.GetExtraData(GUI_RestrictedVisualStates));
     3793    QStringList list = strList.split(',');
     3794    /* Convert list into appropriate values: */
     3795    foreach (const QString &strValue, list)
     3796    {
     3797        UIVisualStateType value = gpConverter->fromInternalString<UIVisualStateType>(strValue);
     3798        if (value != UIVisualStateType_Invalid)
     3799            result = static_cast<UIVisualStateType>(result | value);
    37813800    }
    37823801    /* Return result: */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r46831 r47478  
    375375    static bool shouldWeAllowSnapshotOperations(CMachine &machine, bool fIncludingSanityCheck = true);
    376376    static RuntimeMenuType restrictedRuntimeMenuTypes(CMachine &machine);
     377    static UIVisualStateType restrictedVisualStateTypes(CMachine &machine);
    377378    static QList<IndicatorType> restrictedStatusBarIndicators(CMachine &machine);
    378379    static QList<MachineCloseAction> restrictedMachineCloseActions(CMachine &machine);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.h

    r44529 r47478  
    2525
    2626/* GUI includes: */
    27 #include "UIMachineDefs.h"
     27#include "UIDefs.h"
    2828#ifdef Q_WS_MAC
    2929# include <CoreFoundation/CFBase.h>
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r45377 r47478  
    370370    , m_pSession(0)
    371371    , m_pVisualState(0)
     372    , m_allowedVisualStateTypes(UIVisualStateType_Invalid)
    372373{
    373374    /* Store self pointer: */
     
    505506    /* Load machine settings: */
    506507    CMachine machine = uisession()->session().GetMachine();
     508    UIVisualStateType restrictedVisualStateTypes = VBoxGlobal::restrictedVisualStateTypes(machine);
     509    m_allowedVisualStateTypes = static_cast<UIVisualStateType>(UIVisualStateType_All ^ restrictedVisualStateTypes);
    507510
    508511    /* Load extra-data settings: */
     
    520523            /* Test 'scale' flag: */
    521524            QString strScaleSettings = machine.GetExtraData(GUI_Scale);
    522             if (strScaleSettings == "on")
     525            if (strScaleSettings == "on" && isVisualStateAllowedScale())
    523526            {
    524527                fIsSomeExtendedModeChosen = true;
     
    532535            /* Test 'seamless' flag: */
    533536            QString strSeamlessSettings = machine.GetExtraData(GUI_Seamless);
    534             if (strSeamlessSettings == "on")
     537            if (strSeamlessSettings == "on" && isVisualStateAllowedSeamless())
    535538            {
    536539                fIsSomeExtendedModeChosen = true;
     
    545548            /* Test 'fullscreen' flag: */
    546549            QString strFullscreenSettings = machine.GetExtraData(GUI_Fullscreen);
    547             if (strFullscreenSettings == "on")
     550            if (strFullscreenSettings == "on" && isVisualStateAllowedFullscreen())
    548551            {
    549552                fIsSomeExtendedModeChosen = true;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r45377 r47478  
    2323#include <QObject>
    2424
    25 /* GUI includes:  */
     25/* GUI includes: */
     26#include "UIDefs.h"
    2627#include "UIMachineDefs.h"
    2728
     
    5051    UISession *uisession() const { return m_pSession; }
    5152
     53    /* API: Visual-state stuff: */
     54    bool isVisualStateAllowedFullscreen() const { return m_allowedVisualStateTypes & UIVisualStateType_Fullscreen; }
     55    bool isVisualStateAllowedSeamless() const { return m_allowedVisualStateTypes & UIVisualStateType_Seamless; }
     56    bool isVisualStateAllowedScale() const { return m_allowedVisualStateTypes & UIVisualStateType_Scale; }
     57
    5258private slots:
    5359
     
    7581    UISession *m_pSession;
    7682    UIVisualState *m_pVisualState;
     83    UIVisualStateType m_allowedVisualStateTypes;
    7784
    7885    /* Friend classes: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineDefs.h

    r46795 r47478  
    2222/* Global includes */
    2323#include <iprt/cdefs.h>
    24 
    25 /* Machine states enum: */
    26 enum UIVisualStateType
    27 {
    28     UIVisualStateType_Normal,
    29     UIVisualStateType_Fullscreen,
    30     UIVisualStateType_Seamless,
    31     UIVisualStateType_Scale
    32 };
    3324
    3425/* Machine elements enum: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r47396 r47478  
    448448    /* Update action states: */
    449449    gActionPool->action(UIActionIndexRuntime_Toggle_GuestAutoresize)->setEnabled(uisession()->isGuestSupportsGraphics());
    450     gActionPool->action(UIActionIndexRuntime_Toggle_Seamless)->setEnabled(uisession()->isGuestSupportsSeamless());
     450    gActionPool->action(UIActionIndexRuntime_Toggle_Seamless)->setEnabled(uisession()->isVisualStateAllowedSeamless() && uisession()->isGuestSupportsSeamless());
    451451}
    452452
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r47103 r47478  
    2121
    2222/* GUI includes: */
    23 #include "UIMachineDefs.h"
     23#include "UIDefs.h"
    2424#include <QIWithRetranslateUI.h>
    2525#ifdef VBOX_WITH_DEBUGGER_GUI
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineMenuBar.cpp

    r46847 r47478  
    3434#include "UINetworkManager.h"
    3535#include "VBoxGlobal.h"
     36#include "UISession.h"
    3637
    3738/* COM includes: */
     
    99100};
    100101
    101 UIMachineMenuBar::UIMachineMenuBar(const CMachine &machine)
     102UIMachineMenuBar::UIMachineMenuBar(UISession *pSession, const CMachine &machine)
    102103    /* On the Mac we add some items only the first time, cause otherwise they
    103104     * will be merged more than once to the application menu by Qt. */
    104     : m_machine(machine)
     105    : m_pSession(pSession)
     106    , m_machine(machine)
    105107{
    106108}
     
    226228
    227229    /* View submenu: */
    228     pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Fullscreen));
    229     pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Seamless));
    230     pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Scale));
    231     pMenu->addSeparator();
     230    bool fIsAllowedFullscreen = uisession()->isVisualStateAllowedFullscreen();
     231    bool fIsAllowedSeamless = uisession()->isVisualStateAllowedSeamless();
     232    bool fIsAllowedScale = uisession()->isVisualStateAllowedScale();
     233    gActionPool->action(UIActionIndexRuntime_Toggle_Fullscreen)->setEnabled(fIsAllowedFullscreen);
     234    if (fIsAllowedFullscreen)
     235        pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Fullscreen));
     236    gActionPool->action(UIActionIndexRuntime_Toggle_Seamless)->setEnabled(fIsAllowedSeamless);
     237    if (fIsAllowedSeamless)
     238        pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Seamless));
     239    gActionPool->action(UIActionIndexRuntime_Toggle_Scale)->setEnabled(fIsAllowedScale);
     240    if (fIsAllowedScale)
     241        pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Scale));
     242    if (fIsAllowedFullscreen || fIsAllowedSeamless || fIsAllowedScale)
     243        pMenu->addSeparator();
    232244    pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_GuestAutoresize));
    233245    pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_AdjustWindow));
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineMenuBar.h

    r46847 r47478  
    3333class QMenu;
    3434class QMenuBar;
     35class UISession;
    3536
    3637class UIMachineMenuBar
     
    3839public:
    3940
    40     UIMachineMenuBar(const CMachine &machine);
     41    UIMachineMenuBar(UISession *pSession, const CMachine &machine);
    4142
    4243    QMenu* createMenu(RuntimeMenuType fOptions = RuntimeMenuType_All);
     
    5455    void prepareMenuHelp(QMenu *pMenu);
    5556
     57    /* Helper: UI session stuff: */
     58    UISession* uisession() const { return m_pSession; }
     59
     60    /* Variables: */
     61    UISession *m_pSession;
    5662    CMachine m_machine;
    5763};
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.h

    r44909 r47478  
    2525/* GUI includes: */
    2626#include "QIWithRetranslateUI.h"
    27 #include "UIMachineDefs.h"
     27#include "UIDefs.h"
    2828
    2929/* COM includes: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.h

    r47396 r47478  
    2727
    2828/* GUI includes: */
    29 #include "UIMachineDefs.h"
     29#include "UIDefs.h"
    3030
    3131/* Forward declarations: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r47401 r47478  
    457457}
    458458
     459bool UISession::isVisualStateAllowedFullscreen() const
     460{
     461    return m_pMachine->isVisualStateAllowedFullscreen();
     462}
     463
     464bool UISession::isVisualStateAllowedSeamless() const
     465{
     466    return m_pMachine->isVisualStateAllowedSeamless();
     467}
     468
     469bool UISession::isVisualStateAllowedScale() const
     470{
     471    return m_pMachine->isVisualStateAllowedScale();
     472}
     473
    459474bool UISession::setPause(bool fOn)
    460475{
     
    904919void UISession::prepareMenuPool()
    905920{
    906     m_pMenuPool = new UIMachineMenuBar(session().GetMachine());
     921    m_pMenuPool = new UIMachineMenuBar(this, session().GetMachine());
    907922}
    908923
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r47396 r47478  
    103103    QCursor cursor() const { return m_cursor; }
    104104
     105    /* API: Visual-state stuff: */
     106    bool isVisualStateAllowedFullscreen() const;
     107    bool isVisualStateAllowedSeamless() const;
     108    bool isVisualStateAllowedScale() const;
     109
    105110    bool isSaved() const { return machineState() == KMachineState_Saved; }
    106111    bool isTurnedOff() const { return machineState() == KMachineState_PoweredOff ||
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp

    r46797 r47478  
    2929#include "UIMachineLogicFullscreen.h"
    3030#include "UIMachineWindowFullscreen.h"
     31#include "UIMachineDefs.h"
    3132#include "UIMiniToolBar.h"
    3233
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineWindowSeamless.cpp

    r46797 r47478  
    3131#include "UIMachineViewSeamless.h"
    3232#ifndef Q_WS_MAC
     33# include "UIMachineDefs.h"
    3334# include "UIMiniToolBar.h"
    3435#endif /* !Q_WS_MAC */
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