VirtualBox

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


Ignore:
Timestamp:
Aug 4, 2017 4:15:21 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8900: Selector UI: Save/restore Machine/Global tools order/layout at exit/startup.

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

Legend:

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

    r66588 r68304  
    8585template<> bool canConvert<UIExtraDataMetaDefs::MenuWindowActionType>();
    8686#endif /* VBOX_WS_MAC */
     87template<> bool canConvert<ToolTypeMachine>();
     88template<> bool canConvert<ToolTypeGlobal>();
    8789template<> bool canConvert<UIVisualStateType>();
    8890template<> bool canConvert<DetailsElementType>();
     
    157159template<> UIExtraDataMetaDefs::MenuWindowActionType fromInternalString<UIExtraDataMetaDefs::MenuWindowActionType>(const QString &strMenuWindowActionType);
    158160#endif /* VBOX_WS_MAC */
     161template<> QString toInternalString(const ToolTypeMachine &enmToolTypeMachine);
     162template<> ToolTypeMachine fromInternalString<ToolTypeMachine>(const QString &strToolTypeMachine);
     163template<> QString toInternalString(const ToolTypeGlobal &enmToolTypeGlobal);
     164template<> ToolTypeGlobal fromInternalString<ToolTypeGlobal>(const QString &strToolTypeGlobal);
    159165template<> QString toInternalString(const UIVisualStateType &visualStateType);
    160166template<> UIVisualStateType fromInternalString<UIVisualStateType>(const QString &strVisualStateType);
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp

    r66588 r68304  
    5353template<> bool canConvert<UIExtraDataMetaDefs::MenuWindowActionType>() { return true; }
    5454#endif /* VBOX_WS_MAC */
     55template<> bool canConvert<ToolTypeMachine>() { return true; }
     56template<> bool canConvert<ToolTypeGlobal>() { return true; }
    5557template<> bool canConvert<UIVisualStateType>() { return true; }
    5658template<> bool canConvert<DetailsElementType>() { return true; }
     
    856858#endif /* VBOX_WS_MAC */
    857859
     860/* QString <= ToolTypeMachine: */
     861template<> QString toInternalString(const ToolTypeMachine &enmToolTypeMachine)
     862{
     863    QString strResult;
     864    switch (enmToolTypeMachine)
     865    {
     866        case ToolTypeMachine_Details:   strResult = "Details"; break;
     867        case ToolTypeMachine_Snapshots: strResult = "Snapshots"; break;
     868        default:
     869        {
     870            AssertMsgFailed(("No text for machine tool type=%d", enmToolTypeMachine));
     871            break;
     872        }
     873    }
     874    return strResult;
     875}
     876
     877/* ToolTypeMachine <= QString: */
     878template<> ToolTypeMachine fromInternalString<ToolTypeMachine>(const QString &strToolTypeMachine)
     879{
     880    /* Here we have some fancy stuff allowing us
     881     * to search through the keys using 'case-insensitive' rule: */
     882    QStringList keys;    QList<ToolTypeMachine> values;
     883    keys << "Details";   values << ToolTypeMachine_Details;
     884    keys << "Snapshots"; values << ToolTypeMachine_Snapshots;
     885    /* Invalid type for unknown words: */
     886    if (!keys.contains(strToolTypeMachine, Qt::CaseInsensitive))
     887        return ToolTypeMachine_Invalid;
     888    /* Corresponding type for known words: */
     889    return values.at(keys.indexOf(QRegExp(strToolTypeMachine, Qt::CaseInsensitive)));
     890}
     891
     892/* QString <= ToolTypeGlobal: */
     893template<> QString toInternalString(const ToolTypeGlobal &enmToolTypeGlobal)
     894{
     895    QString strResult;
     896    switch (enmToolTypeGlobal)
     897    {
     898        case ToolTypeGlobal_VirtualMedia: strResult = "VirtualMedia"; break;
     899        case ToolTypeGlobal_HostNetwork:  strResult = "HostNetwork"; break;
     900        default:
     901        {
     902            AssertMsgFailed(("No text for global tool type=%d", enmToolTypeGlobal));
     903            break;
     904        }
     905    }
     906    return strResult;
     907}
     908
     909/* ToolTypeGlobal <= QString: */
     910template<> ToolTypeGlobal fromInternalString<ToolTypeGlobal>(const QString &strToolTypeGlobal)
     911{
     912    /* Here we have some fancy stuff allowing us
     913     * to search through the keys using 'case-insensitive' rule: */
     914    QStringList keys;       QList<ToolTypeGlobal> values;
     915    keys << "VirtualMedia"; values << ToolTypeGlobal_VirtualMedia;
     916    keys << "HostNetwork";  values << ToolTypeGlobal_HostNetwork;
     917    /* Invalid type for unknown words: */
     918    if (!keys.contains(strToolTypeGlobal, Qt::CaseInsensitive))
     919        return ToolTypeGlobal_Invalid;
     920    /* Corresponding type for known words: */
     921    return values.at(keys.indexOf(QRegExp(strToolTypeGlobal, Qt::CaseInsensitive)));
     922}
     923
    858924/* QString <= UIVisualStateType: */
    859925template<> QString toInternalString(const UIVisualStateType &visualStateType)
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.cpp

    r68212 r68304  
    8181const char* UIExtraDataDefs::GUI_Toolbar = "GUI/Toolbar";
    8282const char* UIExtraDataDefs::GUI_Toolbar_Text = "GUI/Toolbar/Text";
     83const char* UIExtraDataDefs::GUI_Toolbar_MachineTools_Order = "GUI/Toolbar/MachineTools/Order";
     84const char* UIExtraDataDefs::GUI_Toolbar_GlobalTools_Order = "GUI/Toolbar/GlobalTools/Order";
    8385const char* UIExtraDataDefs::GUI_Statusbar = "GUI/Statusbar";
    8486const char* UIExtraDataDefs::GUI_GroupDefinitions = "GUI/GroupDefinitions";
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r68212 r68304  
    136136        /** Holds whether selector-window tool-bar text visible. */
    137137        extern const char* GUI_Toolbar_Text;
     138        /** Holds the selector-window machine tools order. */
     139        extern const char* GUI_Toolbar_MachineTools_Order;
     140        /** Holds the selector-window global tools order. */
     141        extern const char* GUI_Toolbar_GlobalTools_Order;
    138142        /** Holds whether selector-window status-bar visible. */
    139143        extern const char* GUI_Statusbar;
     
    599603
    600604
     605/** Selector UI: Machine tool types. */
     606enum ToolTypeMachine
     607{
     608    ToolTypeMachine_Invalid,
     609    ToolTypeMachine_Desktop,
     610    ToolTypeMachine_Details,
     611    ToolTypeMachine_Snapshots,
     612};
     613Q_DECLARE_METATYPE(ToolTypeMachine);
     614
     615/** Selector UI: Global tool types. */
     616enum ToolTypeGlobal
     617{
     618    ToolTypeGlobal_Invalid,
     619    ToolTypeGlobal_Desktop,
     620    ToolTypeGlobal_VirtualMedia,
     621    ToolTypeGlobal_HostNetwork,
     622};
     623Q_DECLARE_METATYPE(ToolTypeGlobal);
     624
    601625/** Selector UI: Details-element types. */
    602626enum DetailsElementType
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r68212 r68304  
    19481948           << GUI_RecentListHD << GUI_RecentListCD << GUI_RecentListFD
    19491949           << GUI_LastSelectorWindowPosition << GUI_SplitterSizes
    1950            << GUI_Toolbar << GUI_Toolbar_Text << GUI_Statusbar
     1950           << GUI_Toolbar << GUI_Toolbar_Text
     1951           << GUI_Toolbar_MachineTools_Order << GUI_Toolbar_GlobalTools_Order
     1952           << GUI_Statusbar
    19511953           << GUI_GroupDefinitions << GUI_LastItemSelected
    19521954           << GUI_DetailsPageBoxes << GUI_PreviewUpdate
     
    26872689}
    26882690
     2691QList<ToolTypeMachine> UIExtraDataManager::selectorWindowToolsOrderMachine()
     2692{
     2693    /* Prepare result: */
     2694    QList<ToolTypeMachine> result;
     2695    /* Get machine tools order: */
     2696    foreach (const QString &strValue, extraDataStringList(GUI_Toolbar_MachineTools_Order))
     2697    {
     2698        const ToolTypeMachine enmValue = gpConverter->fromInternalString<ToolTypeMachine>(strValue);
     2699        if (enmValue != ToolTypeMachine_Invalid && !result.contains(enmValue))
     2700            result << enmValue;
     2701    }
     2702    /* Return result: */
     2703    return result;
     2704}
     2705
     2706void UIExtraDataManager::setSelectorWindowToolsOrderMachine(const QList<ToolTypeMachine> &aOrder)
     2707{
     2708    /* Parse passed list: */
     2709    QStringList aSerializedOrder;
     2710    foreach (const ToolTypeMachine &enmToolType, aOrder)
     2711        aSerializedOrder << gpConverter->toInternalString(enmToolType);
     2712
     2713    /* Re-cache corresponding extra-data: */
     2714    setExtraDataStringList(GUI_Toolbar_MachineTools_Order, aSerializedOrder);
     2715}
     2716
     2717QList<ToolTypeGlobal> UIExtraDataManager::selectorWindowToolsOrderGlobal()
     2718{
     2719    /* Prepare result: */
     2720    QList<ToolTypeGlobal> result;
     2721    /* Get global tools order: */
     2722    foreach (const QString &strValue, extraDataStringList(GUI_Toolbar_GlobalTools_Order))
     2723    {
     2724        const ToolTypeGlobal enmValue = gpConverter->fromInternalString<ToolTypeGlobal>(strValue);
     2725        if (enmValue != ToolTypeGlobal_Invalid && !result.contains(enmValue))
     2726            result << enmValue;
     2727    }
     2728    /* Return result: */
     2729    return result;
     2730}
     2731
     2732void UIExtraDataManager::setSelectorWindowToolsOrderGlobal(const QList<ToolTypeGlobal> &aOrder)
     2733{
     2734    /* Parse passed list: */
     2735    QStringList aSerializedOrder;
     2736    foreach (const ToolTypeGlobal &enmToolType, aOrder)
     2737        aSerializedOrder << gpConverter->toInternalString(enmToolType);
     2738
     2739    /* Re-cache corresponding extra-data: */
     2740    setExtraDataStringList(GUI_Toolbar_GlobalTools_Order, aSerializedOrder);
     2741}
     2742
    26892743bool UIExtraDataManager::selectorWindowStatusBarVisible()
    26902744{
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r68212 r68304  
    301301        /** Defines whether selector-window tool-bar text @a fVisible. */
    302302        void setSelectorWindowToolBarTextVisible(bool fVisible);
     303
     304        /** Returns selector-window machine tools order. */
     305        QList<ToolTypeMachine> selectorWindowToolsOrderMachine();
     306        /** Defines selector-window machine tools @a aOrder. */
     307        void setSelectorWindowToolsOrderMachine(const QList<ToolTypeMachine> &aOrder);
     308
     309        /** Returns selector-window global tools order. */
     310        QList<ToolTypeGlobal> selectorWindowToolsOrderGlobal();
     311        /** Defines selector-window global tools @a aOrder. */
     312        void setSelectorWindowToolsOrderGlobal(const QList<ToolTypeGlobal> &aOrder);
    303313
    304314        /** Returns whether selector-window status-bar visible. */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r68285 r68304  
    154154    {
    155155        // WORKAROUND:
    156         // By some reason some of X11 DEs unable to update()
    157         // tab-bars on startup.  Let's try to _create_ them instead.
    158         /* Make sure 'Details' and 'Snapshots' Machine tools ares opened at startup for now: */
    159         actionPool()->action(UIActionIndexST_M_Tools_M_Machine_Snapshots)->trigger();
    160         actionPool()->action(UIActionIndexST_M_Tools_M_Machine_Details)->trigger();
     156        // By some reason some of X11 DEs unable to update() tab-bars on startup.
     157        // Let's just _create_ them later, asynchronously after the showEvent().
     158        /* Restore previously opened Machine tools at startup: */
     159        QMap<ToolTypeMachine, QAction*> mapActionsMachine;
     160        mapActionsMachine[ToolTypeMachine_Details] = actionPool()->action(UIActionIndexST_M_Tools_M_Machine_Details);
     161        mapActionsMachine[ToolTypeMachine_Snapshots] = actionPool()->action(UIActionIndexST_M_Tools_M_Machine_Snapshots);
     162        for (int i = m_orderMachine.size() - 1; i >= 0; --i)
     163            mapActionsMachine.value(m_orderMachine.at(i))->trigger();
     164        /* Make sure further action triggering cause tool type switch as well: */
     165        actionPool()->action(UIActionIndexST_M_Tools_T_Machine)->setProperty("watch_child_activation", true);
    161166    }
    162167}
     
    11061111{
    11071112    /* First, make sure corresponding tool set opened: */
    1108     if (!actionPool()->action(UIActionIndexST_M_Tools_T_Machine)->isChecked())
     1113    if (   !actionPool()->action(UIActionIndexST_M_Tools_T_Machine)->isChecked()
     1114        && actionPool()->action(UIActionIndexST_M_Tools_T_Machine)->property("watch_child_activation").toBool())
    11091115        actionPool()->action(UIActionIndexST_M_Tools_T_Machine)->setChecked(true);
    11101116
     
    11271133{
    11281134    /* First, make sure corresponding tool set opened: */
    1129     if (!actionPool()->action(UIActionIndexST_M_Tools_T_Global)->isChecked())
     1135    if (   !actionPool()->action(UIActionIndexST_M_Tools_T_Global)->isChecked()
     1136        && actionPool()->action(UIActionIndexST_M_Tools_T_Global)->property("watch_child_activation").toBool())
    11301137        actionPool()->action(UIActionIndexST_M_Tools_T_Global)->setChecked(true);
    11311138
     
    21152122        statusBar()->setHidden(!gEDataManager->selectorWindowStatusBarVisible());
    21162123    }
     2124
     2125    /* Restore toolbar Machine/Global tools orders:  */
     2126    {
     2127        m_orderMachine = gEDataManager->selectorWindowToolsOrderMachine();
     2128        m_orderGlobal = gEDataManager->selectorWindowToolsOrderGlobal();
     2129
     2130        /* We can restore previously opened Global tools right here: */
     2131        QMap<ToolTypeGlobal, QAction*> mapActionsGlobal;
     2132        mapActionsGlobal[ToolTypeGlobal_VirtualMedia] = actionPool()->action(UIActionIndexST_M_Tools_M_Global_VirtualMediaManager);
     2133        mapActionsGlobal[ToolTypeGlobal_HostNetwork] = actionPool()->action(UIActionIndexST_M_Tools_M_Global_HostNetworkManager);
     2134        for (int i = m_orderGlobal.size() - 1; i >= 0; --i)
     2135            mapActionsGlobal.value(m_orderGlobal.at(i))->trigger();
     2136        /* Make sure further action triggering cause tool type switch as well: */
     2137        actionPool()->action(UIActionIndexST_M_Tools_T_Global)->setProperty("watch_child_activation", true);
     2138
     2139        /* But we can't restore previously opened Machine tools here,
     2140         * see the reason in corresponding async sltHandlePolishEvent slot. */
     2141    }
    21172142}
    21182143
    21192144void UISelectorWindow::saveSettings()
    21202145{
     2146    /* Save toolbar Machine/Global tools orders: */
     2147    {
     2148        gEDataManager->setSelectorWindowToolsOrderMachine(m_pToolbarTools->tabOrderMachine());
     2149        gEDataManager->setSelectorWindowToolsOrderGlobal(m_pToolbarTools->tabOrderGlobal());
     2150    }
     2151
    21212152    /* Save toolbar and statusbar visibility: */
    21222153    {
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h

    r68282 r68304  
    356356    UIToolsToolbar *m_pToolbarTools;
    357357
     358    /** Holds the Machine Tools order. */
     359    QList<ToolTypeMachine> m_orderMachine;
     360    /** Holds the Global Tools order. */
     361    QList<ToolTypeGlobal> m_orderGlobal;
     362
    358363    /** Holds the Chooser-pane instance. */
    359364    UIGChooser         *m_pPaneChooser;
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIToolsPaneGlobal.h

    r68285 r68304  
    2424/* GUI includes: */
    2525#include "QIWithRetranslateUI.h"
     26#include "UIExtraDataDefs.h"
    2627
    2728/* Forward declarations: */
     
    3536class UIVMItem;
    3637class CMachine;
    37 
    38 
    39 /** Global tool types. */
    40 enum ToolTypeGlobal
    41 {
    42     ToolTypeGlobal_Invalid,
    43     ToolTypeGlobal_Desktop,
    44     ToolTypeGlobal_VirtualMedia,
    45     ToolTypeGlobal_HostNetwork,
    46 };
    47 
    48 /* Make sure QVariant can eat ToolTypeGlobal: */
    49 Q_DECLARE_METATYPE(ToolTypeGlobal);
    5038
    5139
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIToolsPaneMachine.h

    r68285 r68304  
    2424/* GUI includes: */
    2525#include "QIWithRetranslateUI.h"
     26#include "UIExtraDataDefs.h"
    2627
    2728/* Forward declarations: */
     
    3536class UIVMItem;
    3637class CMachine;
    37 
    38 
    39 /** Machine tool types. */
    40 enum ToolTypeMachine
    41 {
    42     ToolTypeMachine_Invalid,
    43     ToolTypeMachine_Desktop,
    44     ToolTypeMachine_Details,
    45     ToolTypeMachine_Snapshots,
    46 };
    47 
    48 /* Make sure QVariant can eat ToolTypeMachine: */
    49 Q_DECLARE_METATYPE(ToolTypeMachine);
    5038
    5139
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIToolsToolbar.cpp

    r68230 r68304  
    7676}
    7777
     78QList<ToolTypeMachine> UIToolsToolbar::tabOrderMachine() const
     79{
     80    QList<ToolTypeMachine> list;
     81    foreach (const QUuid &uuid, m_pTabBarMachine->tabOrder())
     82        list << m_mapTabIdsMachine.key(uuid);
     83    return list;
     84}
     85
     86QList<ToolTypeGlobal> UIToolsToolbar::tabOrderGlobal() const
     87{
     88    QList<ToolTypeGlobal> list;
     89    foreach (const QUuid &uuid, m_pTabBarGlobal->tabOrder())
     90        list << m_mapTabIdsGlobal.key(uuid);
     91    return list;
     92}
     93
    7894void UIToolsToolbar::sltHandleOpenToolMachine()
    7995{
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIToolsToolbar.h

    r68230 r68304  
    7272    void setToolButtonStyle(Qt::ToolButtonStyle enmStyle);
    7373
     74    /** Returns Machine tab-bar order. */
     75    QList<ToolTypeMachine> tabOrderMachine() const;
     76    /** Returns Global tab-bar order. */
     77    QList<ToolTypeGlobal> tabOrderGlobal() const;
     78
    7479private slots:
    7580
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UITabBar.cpp

    r68299 r68304  
    543543}
    544544
     545QList<QUuid> UITabBar::tabOrder() const
     546{
     547    QList<QUuid> list;
     548    foreach (UITabBarItem *pItem, m_aItems)
     549        list << pItem->uuid();
     550    return list;
     551}
     552
    545553void UITabBar::paintEvent(QPaintEvent *pEvent)
    546554{
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UITabBar.h

    r68298 r68304  
    6767    bool setCurrent(const QUuid &uuid);
    6868
     69    /** Return tab-bar order ID list. */
     70    QList<QUuid> tabOrder() const;
     71
    6972protected:
    7073
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