VirtualBox

Ignore:
Timestamp:
Jun 19, 2014 11:20:16 AM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: 6660: Advanced extra-data management framework: Integrate GUI_LastCloseAction.

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

Legend:

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

    r51654 r51663  
    833833}
    834834
    835 MachineCloseAction UIExtraDataManager::defaultMachineCloseAction(const QString &strID) const
    836 {
    837     return gpConverter->fromInternalString<MachineCloseAction>(extraDataString(GUI_DefaultCloseAction, strID));
    838 }
    839 
    840835int UIExtraDataManager::hostScreenForPassedGuestScreen(int iGuestScreenIndex, const QString &strID)
    841836{
     
    861856}
    862857
     858QList<IndicatorType> UIExtraDataManager::restrictedStatusBarIndicators(const QString &strID) const
     859{
     860    /* Prepare result: */
     861    QList<IndicatorType> result;
     862    /* Load restricted status-bar-indicators: */
     863    foreach (const QString &strValue, extraDataStringList(GUI_RestrictedStatusBarIndicators, strID))
     864    {
     865        IndicatorType value = gpConverter->fromInternalString<IndicatorType>(strValue);
     866        if (value != IndicatorType_Invalid)
     867            result << value;
     868    }
     869    /* Return result: */
     870    return result;
     871}
     872
     873QList<GlobalSettingsPageType> UIExtraDataManager::restrictedGlobalSettingsPages() const
     874{
     875    /* Prepare result: */
     876    QList<GlobalSettingsPageType> result;
     877    /* Load restricted global-settings-pages: */
     878    foreach (const QString &strValue, extraDataStringList(GUI_RestrictedGlobalSettingsPages))
     879    {
     880        GlobalSettingsPageType value = gpConverter->fromInternalString<GlobalSettingsPageType>(strValue);
     881        if (value != GlobalSettingsPageType_Invalid)
     882            result << value;
     883    }
     884    /* Return result: */
     885    return result;
     886}
     887
     888QList<MachineSettingsPageType> UIExtraDataManager::restrictedMachineSettingsPages(const QString &strID) const
     889{
     890    /* Prepare result: */
     891    QList<MachineSettingsPageType> result;
     892    /* Load restricted machine-settings-pages: */
     893    foreach (const QString &strValue, extraDataStringList(GUI_RestrictedMachineSettingsPages, strID))
     894    {
     895        MachineSettingsPageType value = gpConverter->fromInternalString<MachineSettingsPageType>(strValue);
     896        if (value != MachineSettingsPageType_Invalid)
     897            result << value;
     898    }
     899    /* Return result: */
     900    return result;
     901}
     902
     903#ifndef Q_WS_MAC
     904QStringList UIExtraDataManager::machineWindowIconNames(const QString &strID) const
     905{
     906    return extraDataStringList(GUI_MachineWindowIcons, strID);
     907}
     908
     909QString UIExtraDataManager::machineWindowNamePostfix(const QString &strID) const
     910{
     911    return extraDataString(GUI_MachineWindowNamePostfix, strID);
     912}
     913#endif /* !Q_WS_MAC */
     914
     915GuruMeditationHandlerType UIExtraDataManager::guruMeditationHandlerType(const QString &strID) const
     916{
     917    return gpConverter->fromInternalString<GuruMeditationHandlerType>(extraDataString(GUI_GuruMeditationHandler, strID));
     918}
     919
     920HiDPIOptimizationType UIExtraDataManager::hiDPIOptimizationType(const QString &strID) const
     921{
     922    return gpConverter->fromInternalString<HiDPIOptimizationType>(extraDataString(GUI_HiDPI_Optimization, strID));
     923}
     924
     925bool UIExtraDataManager::passCADtoGuest(const QString &strID) const
     926{
     927    /* 'False' unless feature allowed: */
     928    return isFeatureAllowed(GUI_PassCAD, strID);
     929}
     930
     931bool UIExtraDataManager::hidLedsSyncState(const QString &strID) const
     932{
     933    /* 'True' unless feature restricted: */
     934    return !isFeatureRestricted(GUI_HidLedsSync, strID);
     935}
     936
     937bool UIExtraDataManager::showMiniToolbar(const QString &strID) const
     938{
     939    /* 'True' unless feature restricted: */
     940    return !isFeatureRestricted(GUI_ShowMiniToolBar, strID);
     941}
     942
     943void UIExtraDataManager::setShowMiniToolbar(bool fShown, const QString &strID)
     944{
     945    /* 'False' if feature restricted, null-string otherwise: */
     946    setExtraDataString(GUI_ShowMiniToolBar, toFeatureRestricted(!fShown), strID);
     947}
     948
     949bool UIExtraDataManager::autoHideMiniToolbar(const QString &strID) const
     950{
     951    /* 'True' unless feature restricted: */
     952    return !isFeatureRestricted(GUI_MiniToolBarAutoHide, strID);
     953}
     954
     955void UIExtraDataManager::setAutoHideMiniToolbar(bool fAutoHide, const QString &strID)
     956{
     957    /* 'False' if feature restricted, null-string otherwise: */
     958    setExtraDataString(GUI_MiniToolBarAutoHide, toFeatureRestricted(!fAutoHide), strID);
     959}
     960
     961Qt::AlignmentFlag UIExtraDataManager::miniToolbarAlignment(const QString &strID) const
     962{
     963    /* Return Qt::AlignBottom unless MiniToolbarAlignment_Top specified separately: */
     964    switch (gpConverter->fromInternalString<MiniToolbarAlignment>(extraDataString(GUI_MiniToolBarAlignment, strID)))
     965    {
     966        case MiniToolbarAlignment_Top: return Qt::AlignTop;
     967        default: break;
     968    }
     969    return Qt::AlignBottom;
     970}
     971
     972void UIExtraDataManager::setMiniToolbarAlignment(Qt::AlignmentFlag alignment, const QString &strID)
     973{
     974    /* Remove record unless Qt::AlignTop specified separately: */
     975    switch (alignment)
     976    {
     977        case Qt::AlignTop: setExtraDataString(GUI_MiniToolBarAlignment, gpConverter->toInternalString(MiniToolbarAlignment_Top), strID); return;
     978        default: break;
     979    }
     980    setExtraDataString(GUI_MiniToolBarAlignment, QString(), strID);
     981}
     982
     983MachineCloseAction UIExtraDataManager::defaultMachineCloseAction(const QString &strID) const
     984{
     985    return gpConverter->fromInternalString<MachineCloseAction>(extraDataString(GUI_DefaultCloseAction, strID));
     986}
     987
    863988MachineCloseAction UIExtraDataManager::restrictedMachineCloseActions(const QString &strID) const
    864989{
     
    8761001}
    8771002
    878 QList<IndicatorType> UIExtraDataManager::restrictedStatusBarIndicators(const QString &strID) const
    879 {
    880     /* Prepare result: */
    881     QList<IndicatorType> result;
    882     /* Load restricted status-bar-indicators: */
    883     foreach (const QString &strValue, extraDataStringList(GUI_RestrictedStatusBarIndicators, strID))
    884     {
    885         IndicatorType value = gpConverter->fromInternalString<IndicatorType>(strValue);
    886         if (value != IndicatorType_Invalid)
    887             result << value;
    888     }
    889     /* Return result: */
    890     return result;
    891 }
    892 
    893 QList<GlobalSettingsPageType> UIExtraDataManager::restrictedGlobalSettingsPages() const
    894 {
    895     /* Prepare result: */
    896     QList<GlobalSettingsPageType> result;
    897     /* Load restricted global-settings-pages: */
    898     foreach (const QString &strValue, extraDataStringList(GUI_RestrictedGlobalSettingsPages))
    899     {
    900         GlobalSettingsPageType value = gpConverter->fromInternalString<GlobalSettingsPageType>(strValue);
    901         if (value != GlobalSettingsPageType_Invalid)
    902             result << value;
    903     }
    904     /* Return result: */
    905     return result;
    906 }
    907 
    908 QList<MachineSettingsPageType> UIExtraDataManager::restrictedMachineSettingsPages(const QString &strID) const
    909 {
    910     /* Prepare result: */
    911     QList<MachineSettingsPageType> result;
    912     /* Load restricted machine-settings-pages: */
    913     foreach (const QString &strValue, extraDataStringList(GUI_RestrictedMachineSettingsPages, strID))
    914     {
    915         MachineSettingsPageType value = gpConverter->fromInternalString<MachineSettingsPageType>(strValue);
    916         if (value != MachineSettingsPageType_Invalid)
    917             result << value;
    918     }
    919     /* Return result: */
    920     return result;
    921 }
    922 
    923 #ifndef Q_WS_MAC
    924 QStringList UIExtraDataManager::machineWindowIconNames(const QString &strID) const
    925 {
    926     return extraDataStringList(GUI_MachineWindowIcons, strID);
    927 }
    928 
    929 QString UIExtraDataManager::machineWindowNamePostfix(const QString &strID) const
    930 {
    931     return extraDataString(GUI_MachineWindowNamePostfix, strID);
    932 }
    933 #endif /* !Q_WS_MAC */
    934 
    935 GuruMeditationHandlerType UIExtraDataManager::guruMeditationHandlerType(const QString &strID) const
    936 {
    937     return gpConverter->fromInternalString<GuruMeditationHandlerType>(extraDataString(GUI_GuruMeditationHandler, strID));
    938 }
    939 
    940 HiDPIOptimizationType UIExtraDataManager::hiDPIOptimizationType(const QString &strID) const
    941 {
    942     return gpConverter->fromInternalString<HiDPIOptimizationType>(extraDataString(GUI_HiDPI_Optimization, strID));
    943 }
    944 
    945 bool UIExtraDataManager::passCADtoGuest(const QString &strID) const
    946 {
    947     /* 'False' unless feature allowed: */
    948     return isFeatureAllowed(GUI_PassCAD, strID);
    949 }
    950 
    951 bool UIExtraDataManager::hidLedsSyncState(const QString &strID) const
    952 {
    953     /* 'True' unless feature restricted: */
    954     return !isFeatureRestricted(GUI_HidLedsSync, strID);
    955 }
    956 
    957 bool UIExtraDataManager::showMiniToolbar(const QString &strID) const
    958 {
    959     /* 'True' unless feature restricted: */
    960     return !isFeatureRestricted(GUI_ShowMiniToolBar, strID);
    961 }
    962 
    963 void 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 
    969 bool UIExtraDataManager::autoHideMiniToolbar(const QString &strID) const
    970 {
    971     /* 'True' unless feature restricted: */
    972     return !isFeatureRestricted(GUI_MiniToolBarAutoHide, strID);
    973 }
    974 
    975 void 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 
    981 Qt::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 
    992 void 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);
     1003MachineCloseAction UIExtraDataManager::lastMachineCloseAction(const QString &strID) const
     1004{
     1005    return gpConverter->fromInternalString<MachineCloseAction>(extraDataString(GUI_LastCloseAction, strID));
     1006}
     1007
     1008void UIExtraDataManager::setLastMachineCloseAction(MachineCloseAction machineCloseAction, const QString &strID)
     1009{
     1010    setExtraDataString(GUI_LastCloseAction, gpConverter->toInternalString(machineCloseAction), strID);
    10011011}
    10021012
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r51654 r51663  
    245245    void setGuestScreenAutoResize(bool fEnabled, const QString &strID);
    246246
    247     /** Returns default machine close action. */
    248     MachineCloseAction defaultMachineCloseAction(const QString &strID) const;
    249     /** Returns restricted machine close actions. */
    250     MachineCloseAction restrictedMachineCloseActions(const QString &strID) const;
    251 
    252247    /** Returns restricted Runtime UI status-bar indicators. */
    253248    QList<IndicatorType> restrictedStatusBarIndicators(const QString &strID) const;
     
    291286    /** Returns mini-toolbar @a alignment. */
    292287    void setMiniToolbarAlignment(Qt::AlignmentFlag alignment, const QString &strID);
     288
     289    /** Returns default machine close action. */
     290    MachineCloseAction defaultMachineCloseAction(const QString &strID) const;
     291    /** Returns restricted machine close actions. */
     292    MachineCloseAction restrictedMachineCloseActions(const QString &strID) const;
     293
     294    /** Returns last machine close action. */
     295    MachineCloseAction lastMachineCloseAction(const QString &strID) const;
     296    /** Defines last @a machineCloseAction. */
     297    void setLastMachineCloseAction(MachineCloseAction machineCloseAction, const QString &strID);
    293298
    294299private slots:
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.cpp

    r49468 r51663  
    3333/* GUI includes: */
    3434# include "UIVMCloseDialog.h"
     35# include "UIExtraDataManager.h"
    3536# include "UIMessageCenter.h"
     37# include "UIConverter.h"
    3638# include "VBoxGlobal.h"
    3739# include "QIDialogButtonBox.h"
    38 # include "UIConverter.h"
    3940
    4041/* COM includes: */
     
    9293        m_lastCloseAction == MachineCloseAction_Shutdown && !m_fIsACPIEnabled)
    9394        newCloseAction = MachineCloseAction_Shutdown;
    94     m_machine.SetExtraData(GUI_LastCloseAction, gpConverter->toInternalString(newCloseAction));
     95    gEDataManager->setLastMachineCloseAction(newCloseAction, vboxGlobal().managedVMUuid());
    9596
    9697    /* Hide the dialog: */
     
    309310    QRadioButton *pRadioButtonToChoose = 0;
    310311    /* If choosing 'last choice' is possible: */
    311     m_lastCloseAction = gpConverter->fromInternalString<MachineCloseAction>(m_machine.GetExtraData(GUI_LastCloseAction));
     312    m_lastCloseAction = gEDataManager->lastMachineCloseAction(vboxGlobal().managedVMUuid());
    312313    if (m_lastCloseAction == MachineCloseAction_SaveState && fIsStateSavingAllowed)
    313314    {
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