VirtualBox

Changeset 81563 in vbox for trunk


Ignore:
Timestamp:
Oct 29, 2019 10:23:58 AM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: Adding necesarry extradata stuff to be able to disable some dialogs.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp

    r81422 r81563  
    5858template<> bool canConvert<UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface>() { return true; }
    5959template<> bool canConvert<UIExtraDataMetaDefs::DetailsElementOptionTypeDescription>() { return true; }
     60template<> bool canConvert<UIExtraDataMetaDefs::RestrictedDialogs>() { return true; }
    6061template<> bool canConvert<UIToolType>() { return true; }
    6162template<> bool canConvert<UIVisualStateType>() { return true; }
     
    14541455}
    14551456
     1457/* QString <= UIExtraDataMetaDefs::RestrictedDialogs: */
     1458template<> QString toInternalString(const UIExtraDataMetaDefs::RestrictedDialogs &enmRestrictedDialogs)
     1459{
     1460    QString strResult;
     1461    switch (enmRestrictedDialogs)
     1462    {
     1463        case UIExtraDataMetaDefs::RestrictedDialogs_VISOCreator:     strResult = "VISOCreator"; break;
     1464        case UIExtraDataMetaDefs::RestrictedDialogs_All:   strResult = "All"; break;
     1465        default:
     1466        {
     1467            AssertMsgFailed(("No text for details element option type=%d", enmRestrictedDialogs));
     1468            break;
     1469        }
     1470    }
     1471    return strResult;
     1472}
     1473
     1474/* UIExtraDataMetaDefs::RestrictedDialogs <= QString: */
     1475template<> UIExtraDataMetaDefs::RestrictedDialogs fromInternalString<UIExtraDataMetaDefs::RestrictedDialogs>(const QString &strRestrictedDialogs)
     1476{
     1477    /* Here we have some fancy stuff allowing us
     1478     * to search through the keys using 'case-insensitive' rule: */
     1479    QStringList keys;                        QList<UIExtraDataMetaDefs::RestrictedDialogs> values;
     1480    keys << "VISOCreator";                   values << UIExtraDataMetaDefs::RestrictedDialogs_VISOCreator;
     1481    keys << "All";                           values << UIExtraDataMetaDefs::RestrictedDialogs_All;
     1482    /* Invalid type for unknown words: */
     1483    if (!keys.contains(strRestrictedDialogs, Qt::CaseInsensitive))
     1484        return UIExtraDataMetaDefs::RestrictedDialogs_Invalid;
     1485    /* Corresponding type for known words: */
     1486    return values.at(keys.indexOf(QRegExp(strRestrictedDialogs, Qt::CaseInsensitive)));
     1487}
     1488
    14561489/* UIExtraDataMetaDefs::DetailsElementOptionTypeDescription <= QString: */
    14571490template<> UIExtraDataMetaDefs::DetailsElementOptionTypeDescription fromInternalString<UIExtraDataMetaDefs::DetailsElementOptionTypeDescription>(const QString &strDetailsElementOptionTypeDescription)
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.cpp

    r81309 r81563  
    239239const char *UIExtraDataDefs::GUI_GuestControl_LogViewerVisiblePanels = "GUI/LogViewerVisiblePanels";
    240240
     241/* Restricted dialogs: */
     242const char *UIExtraDataDefs::GUI_RestrictedDialogs = "GUI/RestrictedDialogs";
    241243
    242244/* Obsolete keys: */
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r81422 r81563  
    436436    /** @} */
    437437
     438    /** @name Restricted dialogs
     439      * @{ */
     440        SHARED_LIBRARY_STUFF extern const char *GUI_RestrictedDialogs;
     441    /** @} */
    438442
    439443    /** @name Old key support stuff.
     
    774778    };
    775779    Q_ENUM(DetailsElementOptionTypeDescription);
     780
     781    enum RestrictedDialogs
     782    {
     783        RestrictedDialogs_Invalid              = 0,
     784        RestrictedDialogs_VISOCreator          = RT_BIT(0),
     785        RestrictedDialogs_All                  = 0xFFFF
     786    };
     787    Q_ENUM(RestrictedDialogs);
    776788};
    777789
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r81358 r81563  
    19901990#endif /* VBOX_WITH_DEBUGGER_GUI */
    19911991           << GUI_ExtraDataManager_Geometry << GUI_ExtraDataManager_SplitterHints
    1992            << GUI_LogWindowGeometry;
     1992           << GUI_LogWindowGeometry
     1993           << GUI_RestrictedDialogs;
    19931994}
    19941995
     
    45194520}
    45204521
     4522UIExtraDataMetaDefs::RestrictedDialogs UIExtraDataManager::restrictedDialogs(const QUuid &uID)
     4523{
     4524    UIExtraDataMetaDefs::RestrictedDialogs result = UIExtraDataMetaDefs::RestrictedDialogs_Invalid;
     4525    foreach (const QString &strValue, extraDataStringList(GUI_RestrictedDialogs, uID))
     4526    {
     4527        UIExtraDataMetaDefs::RestrictedDialogs value =
     4528            gpConverter->fromInternalString<UIExtraDataMetaDefs::RestrictedDialogs>(strValue);
     4529        if (value != UIExtraDataMetaDefs::RestrictedDialogs_Invalid)
     4530            result = static_cast<UIExtraDataMetaDefs::RestrictedDialogs>(result | value);
     4531    }
     4532    return result;
     4533}
     4534
     4535void UIExtraDataManager::setRestrictedDialogs(UIExtraDataMetaDefs::RestrictedDialogs dialogs, const QUuid &uID)
     4536{
     4537    const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject;
     4538    const int iEnumIndex = smo.indexOfEnumerator("RestrictedDialogs");
     4539    QMetaEnum metaEnum = smo.enumerator(iEnumIndex);
     4540
     4541    QStringList result;
     4542    if (dialogs == UIExtraDataMetaDefs::RestrictedDialogs_All)
     4543        result << gpConverter->toInternalString(dialogs);
     4544    else
     4545    {
     4546        for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)
     4547        {
     4548            const UIExtraDataMetaDefs::RestrictedDialogs enumValue =
     4549                static_cast<UIExtraDataMetaDefs::RestrictedDialogs>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));
     4550            if (enumValue == UIExtraDataMetaDefs::RestrictedDialogs_Invalid ||
     4551                enumValue == UIExtraDataMetaDefs::RestrictedDialogs_All)
     4552                continue;
     4553            if (dialogs & enumValue)
     4554                result << gpConverter->toInternalString(enumValue);
     4555        }
     4556    }
     4557    setExtraDataStringList(GUI_RestrictedDialogs, result, uID);
     4558}
     4559
    45214560void UIExtraDataManager::sltExtraDataChange(const QUuid &uMachineID, const QString &strKey, const QString &strValue)
    45224561{
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r81358 r81563  
    750750        void setLogViewerVisiblePanels(const QStringList &panelNameList);
    751751        QStringList logViewerVisiblePanels();
     752    /** @} */
     753
     754    /** @name Restricted Dialogs
     755      * @{ */
     756        /** Returns a list of restricted dialogs. */
     757        UIExtraDataMetaDefs::RestrictedDialogs restrictedDialogs(const QUuid &uID);
     758        /** Defines restricted Runtime UI menu types. */
     759        void setRestrictedDialogs(UIExtraDataMetaDefs::RestrictedDialogs types, const QUuid &uID);
    752760    /** @} */
    753761
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp

    r81274 r81563  
    29162916
    29172917int UICommon::openMediumSelectorDialog(QWidget *pParent, UIMediumDeviceType  enmMediumType, QUuid &outUuid,
    2918                                          const QString &strMachineFolder, const QString &strMachineName,
    2919                                          const QString &strMachineGuestOSTypeId, bool fEnableCreate)
    2920 {
     2918                                       const QString &strMachineFolder, const QString &strMachineName,
     2919                                       const QString &strMachineGuestOSTypeId, bool fEnableCreate, const QUuid &uMachineID /* = QUuid() */)
     2920{
     2921    QUuid uMachineOrGlobalId = uMachineID == QUuid() ? gEDataManager->GlobalID : uMachineID;
     2922
    29212923    QWidget *pDialogParent = windowManager().realParentWindow(pParent);
    29222924    QPointer<UIMediumSelector> pSelector = new UIMediumSelector(enmMediumType, strMachineName,
    2923                                                                 strMachineFolder, strMachineGuestOSTypeId, pDialogParent);
     2925                                                                strMachineFolder, strMachineGuestOSTypeId,
     2926                                                                uMachineOrGlobalId, pDialogParent);
    29242927
    29252928    if (!pSelector)
     
    31833186                    int iDialogReturn = openMediumSelectorDialog(windowManager().mainWindowShown(), target.mediumType, uMediumID,
    31843187                                                                 strMachineFolder, comConstMachine.GetName(),
    3185                                                                  comConstMachine.GetOSTypeId(), true /*fEnableCreate */);
     3188                                                                 comConstMachine.GetOSTypeId(), true /*fEnableCreate */, comConstMachine.GetId());
    31863189                    if (iDialogReturn == UIMediumSelector::ReturnCode_LeftEmpty &&
    31873190                        (target.mediumType == UIMediumDeviceType_DVD || target.mediumType == UIMediumDeviceType_Floppy))
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h

    r80926 r81563  
    520520          * @param  strMachineGuestOSTypeId  Passes the type ID of machine's guest os,
    521521          * @param  fEnableCreate            Passes whether to show/enable create action in the medium selector dialog,
     522          * @param  uMachineID               Passes the machine UUID,
    522523          * returns the return code of the UIMediumSelector::ReturnCode as int. In case of a medium selection
    523524          *         UUID of the selected medium is stored in @param outUuid.*/
    524525        int openMediumSelectorDialog(QWidget *pParent, UIMediumDeviceType  enmMediumType, QUuid &outUuid,
    525526                                     const QString &strMachineFolder, const QString &strMachineName,
    526                                      const QString &strMachineGuestOSTypeId, bool fEnableCreate);
     527                                     const QString &strMachineGuestOSTypeId, bool fEnableCreate, const QUuid &uMachineID = QUuid());
    527528
    528529        /** Creates and shows a dialog (wizard) to create a medium of type @a enmMediumType.
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.cpp

    r81562 r81563  
    5454
    5555
    56 UIMediumSelector::UIMediumSelector(UIMediumDeviceType enmMediumType, const QString &machineName /* = QString() */,
    57                                    const QString &machineSettingsFilePath /* = QString() */,
    58                                    const QString &strMachineGuestOSTypeId /*= QString() */, QWidget *pParent /* = 0 */)
     56UIMediumSelector::UIMediumSelector(UIMediumDeviceType enmMediumType, const QString &machineName,
     57                                   const QString &machineSettingsFilePath, const QString &strMachineGuestOSTypeId,
     58                                   const QUuid &uMachineID, QWidget *pParent)
    5959    :QIWithRetranslateUI<QIMainDialog>(pParent)
    6060    , m_pCentralWidget(0)
     
    7979    , m_strMachineName(machineName)
    8080    , m_strMachineGuestOSTypeId(strMachineGuestOSTypeId)
     81    , m_uMachineID(uMachineID)
    8182{
    8283    /* Start full medium-enumeration (if necessary): */
     
    224225
    225226    m_pToolBar->addAction(m_pActionAdd);
    226     m_pToolBar->addAction(m_pActionCreate);
     227    if (!(gEDataManager->restrictedDialogs(m_uMachineID) & UIExtraDataMetaDefs::RestrictedDialogs_VISOCreator))
     228        m_pToolBar->addAction(m_pActionCreate);
    227229    m_pToolBar->addSeparator();
    228230    m_pToolBar->addAction(m_pActionRefresh);
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.h

    r77291 r81563  
    5151public:
    5252
    53     UIMediumSelector(UIMediumDeviceType enmMediumType, const QString &machineName = QString(),
    54                      const QString &machineSettingsFilePath = QString(), const QString &strMachineGuestOSTypeId = QString(),
    55                      QWidget *pParent = 0);
     53    UIMediumSelector(UIMediumDeviceType enmMediumType, const QString &machineName,
     54                     const QString &machineSettingsFilePath, const QString &strMachineGuestOSTypeId,
     55                     const QUuid &uMachineID, QWidget *pParent);
    5656    /** Disables/enables the create action and controls its visibility. */
    5757    void         setEnableCreateAction(bool fEnable);
     
    152152    QString               m_strMachineName;
    153153    QString               m_strMachineGuestOSTypeId;
     154    QUuid                 m_uMachineID;
    154155};
    155156
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp

    r81551 r81563  
    39393939                                                      strMachineFolder, m_strMachineName,
    39403940                                                      m_strMachineGuestOSTypeId,
    3941                                                       true /* enable create action: */);
     3941                                                      true /* enable create action: */, m_uMachineId);
    39423942
    39433943    if (iResult == UIMediumSelector::ReturnCode_Rejected ||
     
    48354835                                                      strMachineFolder, m_strMachineName,
    48364836                                                      m_strMachineGuestOSTypeId,
    4837                                                       true /* enable cr1eate action: */);
     4837                                                      true /* enable cr1eate action: */, m_uMachineId);
    48384838
    48394839    /* Continue only if iResult is either UIMediumSelector::ReturnCode_Accepted or UIMediumSelector::ReturnCode_LeftEmpty: */
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