VirtualBox

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


Ignore:
Timestamp:
Jun 21, 2013 2:32:44 PM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: Selector UI, Runtime UI: Extra-data flag to prevent snapshot-operations (create/delete).

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDefs.cpp

    r46686 r46726  
    4747const char* UIDefs::GUI_HideFromManager = "GUI/HideFromManager";
    4848const char* UIDefs::GUI_PreventReconfiguration = "GUI/PreventReconfiguration";
     49const char* UIDefs::GUI_PreventSnapshotOperations = "GUI/PreventSnapshotOperations";
    4950const char* UIDefs::GUI_HideDetails = "GUI/HideDetails";
    5051
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDefs.h

    r46708 r46726  
    119119    extern const char* GUI_HideFromManager;
    120120    extern const char* GUI_PreventReconfiguration;
     121    extern const char* GUI_PreventSnapshotOperations;
    121122    extern const char* GUI_HideDetails;
    122123
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r46708 r46726  
    37213721    /* 'true' if guest-screen auto-mounting approved by the extra-data: */
    37223722    return isApprovedByExtraData(machine, GUI_AutomountGuestScreens);
     3723}
     3724
     3725/* static */
     3726bool VBoxGlobal::shouldWeAllowSnapshotOperations(CMachine &machine,
     3727                                                 bool fIncludingSanityCheck /*= true*/)
     3728{
     3729    if (fIncludingSanityCheck)
     3730    {
     3731        /* 'false' for null machines,
     3732         * we can't operate snapshot in that case: */
     3733        if (machine.isNull())
     3734            return false;
     3735
     3736        /* 'false' for inaccessible machines,
     3737         * we can't operate snapshot in that case: */
     3738        if (!machine.GetAccessible())
     3739            return false;
     3740    }
     3741
     3742    /* 'true' if snapshot operations are not restricted by the extra-data: */
     3743    return !isApprovedByExtraData(machine, GUI_PreventSnapshotOperations);
    37233744}
    37243745
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r46708 r46726  
    383383                                    bool fIncludingMachineGeneralCheck = false);
    384384    static bool shouldWeAutoMountGuestScreens(CMachine &machine, bool fIncludingSanityCheck = true);
     385    static bool shouldWeAllowSnapshotOperations(CMachine &machine, bool fIncludingSanityCheck = true);
    385386    static QList<IndicatorType> restrictedStatusBarIndicators(CMachine &machine);
    386387    static QList<MachineCloseAction> restrictedMachineCloseActions(CMachine &machine);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineMenuBar.cpp

    r46626 r46726  
    3333#include "UIImageTools.h"
    3434#include "UINetworkManager.h"
     35#include "VBoxGlobal.h"
    3536
    3637/* COM includes: */
     
    9899};
    99100
    100 UIMachineMenuBar::UIMachineMenuBar()
     101UIMachineMenuBar::UIMachineMenuBar(const CMachine &machine)
    101102    /* On the Mac we add some items only the first time, cause otherwise they
    102103     * will be merged more than once to the application menu by Qt. */
    103104    : m_fIsFirstTime(true)
     105    , m_machine(machine)
    104106{
    105107}
     
    195197    /* Machine submenu: */
    196198    pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_SettingsDialog));
    197     pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TakeSnapshot));
     199    if (vboxGlobal().shouldWeAllowSnapshotOperations(m_machine))
     200        pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TakeSnapshot));
     201    else
     202        gActionPool->action(UIActionIndexRuntime_Simple_TakeSnapshot)->setEnabled(false);
    198203    pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TakeScreenshot));
    199204    pMenu->addAction(gActionPool->action(UIActionIndexRuntime_Simple_InformationDialog));
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineMenuBar.h

    r44529 r46726  
    2626#include <QList>
    2727
     28/* COM includes: */
     29#include "COMEnums.h"
     30#include "CMachine.h"
     31
    2832/* Global forwards */
    2933class QMenu;
     
    3337{
    3438public:
    35     UIMachineMenuBar();
     39
     40    UIMachineMenuBar(const CMachine &machine);
    3641
    3742    QMenu* createMenu(UIMainMenuType fOptions = UIMainMenuType_All);
     
    5055
    5156    bool m_fIsFirstTime;
     57    CMachine m_machine;
    5258};
    5359
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r46626 r46726  
    893893void UISession::prepareMenuPool()
    894894{
    895     m_pMenuPool = new UIMachineMenuBar;
     895    m_pMenuPool = new UIMachineMenuBar(session().GetMachine());
    896896}
    897897
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.cpp

    r45432 r46726  
    340340    , mTakeSnapshotAction (new QAction (mCurStateActionGroup))
    341341    , mCloneSnapshotAction(new QAction(mCurStateActionGroup))
     342    , m_fShapshotOperationsAllowed(false)
    342343{
    343344    /* Apply UI decorations */
     
    438439        mMachineId = QString::null;
    439440        mSessionState = KSessionState_Null;
     441        m_fShapshotOperationsAllowed = false;
    440442    }
    441443    else
     
    443445        mMachineId = aMachine.GetId();
    444446        mSessionState = aMachine.GetSessionState();
     447        m_fShapshotOperationsAllowed = vboxGlobal().shouldWeAllowSnapshotOperations(mMachine);
    445448    }
    446449
     
    509512
    510513    /* Enable/disable deleting snapshot */
    511     mDeleteSnapshotAction->setEnabled (   canTakeDeleteSnapshot
    512                                        && mCurSnapshotItem && item && !item->isCurrentStateItem());
     514    mDeleteSnapshotAction->setEnabled (m_fShapshotOperationsAllowed &&
     515                                       canTakeDeleteSnapshot && mCurSnapshotItem && item && !item->isCurrentStateItem());
    513516
    514517    /* Enable/disable the details action regardless of the session state */
     
    516519
    517520    /* Enable/disable taking snapshots */
    518     mTakeSnapshotAction->setEnabled (   (   canTakeDeleteSnapshot
    519                                          && mCurSnapshotItem && item && item->isCurrentStateItem())
    520                                      || (item && !mCurSnapshotItem));
     521    mTakeSnapshotAction->setEnabled (m_fShapshotOperationsAllowed &&
     522                                     ((canTakeDeleteSnapshot && mCurSnapshotItem && item && item->isCurrentStateItem()) ||
     523                                      (item && !mCurSnapshotItem)));
    521524
    522525    /* Enable/disable cloning snapshots */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.h

    r44528 r46726  
    109109
    110110    QTimer          mAgeUpdateTimer;
     111
     112    bool            m_fShapshotOperationsAllowed;
    111113};
    112114
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