VirtualBox

Ignore:
Timestamp:
Jun 18, 2014 6:14:46 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: 6660: Advanced extra-data management framework: Integrate GUI_ShowMiniToolBar, GUI_MiniToolBarAutoHide, GUI_MiniToolBarAlignment.

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

Legend:

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

    r51579 r51654  
    9191template<> bool canConvert<GuruMeditationHandlerType>();
    9292template<> bool canConvert<HiDPIOptimizationType>();
     93template<> bool canConvert<MiniToolbarAlignment>();
    9394
    9495/* Declare COM canConvert specializations: */
     
    164165template<> QString toInternalString(const HiDPIOptimizationType &optimizationType);
    165166template<> HiDPIOptimizationType fromInternalString<HiDPIOptimizationType>(const QString &strOptimizationType);
     167template<> QString toInternalString(const MiniToolbarAlignment &miniToolbarAlignment);
     168template<> MiniToolbarAlignment fromInternalString<MiniToolbarAlignment>(const QString &strMiniToolbarAlignment);
    166169
    167170/* Declare COM conversion specializations: */
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp

    r51532 r51654  
    5555template<> bool canConvert<GuruMeditationHandlerType>() { return true; }
    5656template<> bool canConvert<HiDPIOptimizationType>() { return true; }
     57template<> bool canConvert<MiniToolbarAlignment>() { return true; }
    5758
    5859/* QString <= SizeSuffix: */
     
    932933    /* Here we have some fancy stuff allowing us
    933934     * to search through the keys using 'case-insensitive' rule: */
    934     QStringList keys;    QList<GlobalSettingsPageType> values;
     935    QStringList keys;     QList<GlobalSettingsPageType> values;
    935936    keys << "General";    values << GlobalSettingsPageType_General;
    936937    keys << "Input";      values << GlobalSettingsPageType_Input;
     
    12371238}
    12381239
     1240/* QString <= MiniToolbarAlignment: */
     1241template<> QString toInternalString(const MiniToolbarAlignment &miniToolbarAlignment)
     1242{
     1243    /* Return corresponding QString representation for passed enum value: */
     1244    switch (miniToolbarAlignment)
     1245    {
     1246        case MiniToolbarAlignment_Bottom: return "Bottom";
     1247        case MiniToolbarAlignment_Top:    return "Top";
     1248        default: AssertMsgFailed(("No text for '%d'", miniToolbarAlignment)); break;
     1249    }
     1250    /* Return QString() by default: */
     1251    return QString();
     1252}
     1253
     1254/* MiniToolbarAlignment <= QString: */
     1255template<> MiniToolbarAlignment fromInternalString<MiniToolbarAlignment>(const QString &strMiniToolbarAlignment)
     1256{
     1257    /* Here we have some fancy stuff allowing us
     1258     * to search through the keys using 'case-insensitive' rule: */
     1259    QStringList keys; QList<MiniToolbarAlignment> values;
     1260    keys << "Bottom"; values << MiniToolbarAlignment_Bottom;
     1261    keys << "Top";    values << MiniToolbarAlignment_Top;
     1262    /* Bottom type for unknown words: */
     1263    if (!keys.contains(strMiniToolbarAlignment, Qt::CaseInsensitive))
     1264        return MiniToolbarAlignment_Bottom;
     1265    /* Corresponding type for known words: */
     1266    return values.at(keys.indexOf(QRegExp(strMiniToolbarAlignment, Qt::CaseInsensitive)));
     1267}
     1268
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r51593 r51654  
    406406};
    407407
     408/** Runtime UI: Mini-toolbar alignment. */
     409enum MiniToolbarAlignment
     410{
     411    MiniToolbarAlignment_Bottom,
     412    MiniToolbarAlignment_Top
     413};
    408414
    409415#endif /* !___UIExtraDataDefs_h___ */
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r51596 r51654  
    955955}
    956956
     957bool UIExtraDataManager::showMiniToolbar(const QString &strID) const
     958{
     959    /* 'True' unless feature restricted: */
     960    return !isFeatureRestricted(GUI_ShowMiniToolBar, strID);
     961}
     962
     963void UIExtraDataManager::setShowMiniToolbar(bool fShown, const QString &strID)
     964{
     965    /* 'False' if feature restricted, null-string otherwise: */
     966    setExtraDataString(GUI_ShowMiniToolBar, toFeatureRestricted(!fShown), strID);
     967}
     968
     969bool UIExtraDataManager::autoHideMiniToolbar(const QString &strID) const
     970{
     971    /* 'True' unless feature restricted: */
     972    return !isFeatureRestricted(GUI_MiniToolBarAutoHide, strID);
     973}
     974
     975void UIExtraDataManager::setAutoHideMiniToolbar(bool fAutoHide, const QString &strID)
     976{
     977    /* 'False' if feature restricted, null-string otherwise: */
     978    setExtraDataString(GUI_MiniToolBarAutoHide, toFeatureRestricted(!fAutoHide), strID);
     979}
     980
     981Qt::AlignmentFlag UIExtraDataManager::miniToolbarAlignment(const QString &strID) const
     982{
     983    /* Return Qt::AlignBottom unless MiniToolbarAlignment_Top specified separately: */
     984    switch (gpConverter->fromInternalString<MiniToolbarAlignment>(extraDataString(GUI_MiniToolBarAlignment, strID)))
     985    {
     986        case MiniToolbarAlignment_Top: return Qt::AlignTop;
     987        default: break;
     988    }
     989    return Qt::AlignBottom;
     990}
     991
     992void UIExtraDataManager::setMiniToolbarAlignment(Qt::AlignmentFlag alignment, const QString &strID)
     993{
     994    /* Remove record unless Qt::AlignTop specified separately: */
     995    switch (alignment)
     996    {
     997        case Qt::AlignTop: setExtraDataString(GUI_MiniToolBarAlignment, gpConverter->toInternalString(MiniToolbarAlignment_Top), strID); return;
     998        default: break;
     999    }
     1000    setExtraDataString(GUI_MiniToolBarAlignment, QString(), strID);
     1001}
     1002
    9571003void UIExtraDataManager::sltExtraDataChange(QString strMachineID, QString strKey, QString strValue)
    9581004{
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r51596 r51654  
    277277    bool hidLedsSyncState(const QString &strID) const;
    278278
     279    /** Returns whether mini-toolbar should be shown for full and seamless screens. */
     280    bool showMiniToolbar(const QString &strID) const;
     281    /** Defines whether mini-toolbar should be @a fShown for full and seamless screens. */
     282    void setShowMiniToolbar(bool fShown, const QString &strID);
     283
     284    /** Returns whether mini-toolbar should auto-hide itself. */
     285    bool autoHideMiniToolbar(const QString &strID) const;
     286    /** Defines whether mini-toolbar should @a fAutoHide itself. */
     287    void setAutoHideMiniToolbar(bool fAutoHide, const QString &strID);
     288
     289    /** Returns mini-toolbar alignment. */
     290    Qt::AlignmentFlag miniToolbarAlignment(const QString &strID) const;
     291    /** Returns mini-toolbar @a alignment. */
     292    void setMiniToolbarAlignment(Qt::AlignmentFlag alignment, const QString &strID);
     293
    279294private slots:
    280295
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp

    r51248 r51654  
    234234void UIMachineWindowFullscreen::prepareMiniToolbar()
    235235{
    236     /* Get machine: */
    237     CMachine m = machine();
    238 
    239     /* Make sure mini-toolbar is necessary: */
    240     bool fIsActive = m.GetExtraData(GUI_ShowMiniToolBar) != "no";
    241     if (!fIsActive)
    242         return;
    243 
    244     /* Get the mini-toolbar alignment: */
    245     bool fIsAtTop = m.GetExtraData(GUI_MiniToolBarAlignment) == "top";
    246     /* Get the mini-toolbar auto-hide feature availability: */
    247     bool fIsAutoHide = m.GetExtraData(GUI_MiniToolBarAutoHide) != "off";
     236    /* Make sure mini-toolbar is not restricted: */
     237    if (!gEDataManager->showMiniToolbar(vboxGlobal().managedVMUuid()))
     238        return;
     239
    248240    /* Create mini-toolbar: */
    249241    m_pMiniToolBar = new UIRuntimeMiniToolBar(this,
    250                                               fIsAtTop ? Qt::AlignTop : Qt::AlignBottom,
    251242                                              IntegrationMode_Embedded,
    252                                               fIsAutoHide);
     243                                              gEDataManager->miniToolbarAlignment(vboxGlobal().managedVMUuid()),
     244                                              gEDataManager->autoHideMiniToolbar(vboxGlobal().managedVMUuid()));
    253245    QList<QMenu*> menus;
    254246    RuntimeMenuType restrictedMenus = gEDataManager->restrictedRuntimeMenuTypes(vboxGlobal().managedVMUuid());
     
    275267
    276268    /* Save mini-toolbar settings: */
    277     machine().SetExtraData(GUI_MiniToolBarAutoHide, m_pMiniToolBar->autoHide() ? QString() : "off");
     269    gEDataManager->setAutoHideMiniToolbar(m_pMiniToolBar->autoHide(), vboxGlobal().managedVMUuid());
    278270    /* Delete mini-toolbar: */
    279271    delete m_pMiniToolBar;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineWindowSeamless.cpp

    r51054 r51654  
    128128void UIMachineWindowSeamless::prepareMiniToolbar()
    129129{
    130     /* Get machine: */
    131     CMachine m = machine();
    132 
    133     /* Make sure mini-toolbar is necessary: */
    134     bool fIsActive = m.GetExtraData(GUI_ShowMiniToolBar) != "no";
    135     if (!fIsActive)
     130    /* Make sure mini-toolbar is not restricted: */
     131    if (!gEDataManager->showMiniToolbar(vboxGlobal().managedVMUuid()))
    136132        return;
    137133
    138     /* Get the mini-toolbar alignment: */
    139     bool fIsAtTop = m.GetExtraData(GUI_MiniToolBarAlignment) == "top";
    140     /* Get the mini-toolbar auto-hide feature availability: */
    141     bool fIsAutoHide = m.GetExtraData(GUI_MiniToolBarAutoHide) != "off";
    142134    /* Create mini-toolbar: */
    143135    m_pMiniToolBar = new UIRuntimeMiniToolBar(this,
    144                                               fIsAtTop ? Qt::AlignTop : Qt::AlignBottom,
    145136                                              IntegrationMode_External,
    146                                               fIsAutoHide);
     137                                              gEDataManager->miniToolbarAlignment(vboxGlobal().managedVMUuid()),
     138                                              gEDataManager->autoHideMiniToolbar(vboxGlobal().managedVMUuid()));
    147139    m_pMiniToolBar->show();
    148140    QList<QMenu*> menus;
     
    170162
    171163    /* Save mini-toolbar settings: */
    172     machine().SetExtraData(GUI_MiniToolBarAutoHide, m_pMiniToolBar->autoHide() ? QString() : "off");
     164    gEDataManager->setAutoHideMiniToolbar(m_pMiniToolBar->autoHide(), vboxGlobal().managedVMUuid());
    173165    /* Delete mini-toolbar: */
    174166    delete m_pMiniToolBar;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.cpp

    r51593 r51654  
    2323
    2424/* GUI includes: */
     25#include "QIWidgetValidator.h"
    2526#include "UIMachineSettingsGeneral.h"
     27#include "UIExtraDataManager.h"
    2628#include "UIMessageCenter.h"
    27 #include "QIWidgetValidator.h"
    2829#include "UIConverter.h"
    2930
     
    106107    generalData.m_strName = m_machine.GetName();
    107108    generalData.m_strGuestOsTypeId = m_machine.GetOSTypeId();
    108     QString strShowMiniToolBar = m_machine.GetExtraData(GUI_ShowMiniToolBar);
    109     generalData.m_fShowMiniToolBar = strShowMiniToolBar != "no";
    110     QString strMiniToolBarAlignment = m_machine.GetExtraData(GUI_MiniToolBarAlignment);
    111     generalData.m_fMiniToolBarAtTop = strMiniToolBarAlignment == "top";
     109    generalData.m_fShowMiniToolBar = gEDataManager->showMiniToolbar(m_machine.GetId());
     110    generalData.m_fMiniToolBarAtTop = gEDataManager->miniToolbarAlignment(m_machine.GetId()) == Qt::AlignTop;
    112111    generalData.m_strSnapshotsFolder = m_machine.GetSnapshotFolder();
    113112    generalData.m_strSnapshotsHomeDir = QFileInfo(m_machine.GetSettingsFilePath()).absolutePath();
     
    189188            m_machine.SetClipboardMode(generalData.m_clipboardMode);
    190189            m_machine.SetDnDMode(generalData.m_dndMode);
    191             m_machine.SetExtraData(GUI_ShowMiniToolBar, generalData.m_fShowMiniToolBar ? "yes" : "no");
    192             m_machine.SetExtraData(GUI_MiniToolBarAlignment, generalData.m_fMiniToolBarAtTop ? "top" : "bottom");
     190            gEDataManager->setShowMiniToolbar(generalData.m_fShowMiniToolBar, m_machine.GetId());
     191            gEDataManager->setMiniToolbarAlignment(generalData.m_fMiniToolBarAtTop ? Qt::AlignTop : Qt::AlignBottom, m_machine.GetId());
    193192            /* Description tab: */
    194193            m_machine.SetDescription(generalData.m_strDescription);
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.cpp

    r51079 r51654  
    4242
    4343UIRuntimeMiniToolBar::UIRuntimeMiniToolBar(QWidget *pParent,
     44                                           IntegrationMode integrationMode,
    4445                                           Qt::Alignment alignment,
    45                                            IntegrationMode integrationMode,
    46                                            bool fAutoHide /* = true*/)
     46                                           bool fAutoHide /* = true */)
    4747    : QWidget(pParent)
    4848    /* Variables: General stuff: */
     49    , m_integrationMode(integrationMode)
    4950    , m_alignment(alignment)
    50     , m_integrationMode(integrationMode)
    5151    , m_fAutoHide(fAutoHide)
    5252    /* Variables: Contents stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.h

    r50816 r51654  
    7171    /* Constructor/destructor: */
    7272    UIRuntimeMiniToolBar(QWidget *pParent,
     73                         IntegrationMode integrationMode,
    7374                         Qt::Alignment alignment,
    74                          IntegrationMode integrationMode,
    7575                         bool fAutoHide = true);
    7676    ~UIRuntimeMiniToolBar();
     
    131131
    132132    /* Variables: General stuff: */
     133    IntegrationMode m_integrationMode;
    133134    Qt::Alignment m_alignment;
    134     IntegrationMode m_integrationMode;
    135135    bool m_fAutoHide;
    136136
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