VirtualBox

Changeset 89324 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 27, 2021 2:28:17 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10003: Introducing new Global Preferences page; That's Interface page allowing to change color-theme; For Windows only for now, macOS to go.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
4 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r89299 r89324  
    867867        src/settings/global/UIGlobalSettingsLanguage.h \
    868868        src/settings/global/UIGlobalSettingsDisplay.h \
     869        src/settings/global/UIGlobalSettingsInterface.h \
    869870        src/settings/machine/UIMachineSettingsAudio.h \
    870871        src/settings/machine/UIMachineSettingsDisplay.h \
     
    14081409        src/settings/global/UIGlobalSettingsLanguage.cpp \
    14091410        src/settings/global/UIGlobalSettingsDisplay.cpp \
     1411        src/settings/global/UIGlobalSettingsInterface.cpp \
    14101412        src/settings/machine/UIMachineSettingsAudio.cpp \
    14111413        src/settings/machine/UIMachineSettingsDisplay.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp

    r89295 r89324  
    19261926        case GlobalSettingsPageType_Proxy:      strResult = "Proxy"; break;
    19271927#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
     1928        case GlobalSettingsPageType_Interface:  strResult = "Interface"; break;
    19281929        default:
    19291930        {
     
    19511952    keys << "Proxy";      values << GlobalSettingsPageType_Proxy;
    19521953#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
     1954    keys << "Interface";  values << GlobalSettingsPageType_Interface;
    19531955    /* Invalid type for unknown words: */
    19541956    if (!keys.contains(strGlobalSettingsPageType, Qt::CaseInsensitive))
     
    19731975        case GlobalSettingsPageType_Proxy:      return UIIconPool::pixmap(":/proxy_warning_16px.png");
    19741976#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
     1977        case GlobalSettingsPageType_Interface:  return UIIconPool::pixmap(":/interface_warning_16px.png");
    19751978        default: AssertMsgFailed(("No pixmap for %d", type)); break;
    19761979    }
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r89295 r89324  
    832832    GlobalSettingsPageType_Proxy,
    833833#endif
     834    GlobalSettingsPageType_Interface,
    834835    GlobalSettingsPageType_Max
    835836};
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialogSpecific.cpp

    r87418 r89324  
    55
    66/*
    7  * Copyright (C) 2006-2020 Oracle Corporation
     7 * Copyright (C) 2006-2021 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3535#include "UIGlobalSettingsInput.h"
    3636#include "UIGlobalSettingsLanguage.h"
     37#ifdef VBOX_WS_WIN
     38# include "UIGlobalSettingsInterface.h"
     39#endif
    3740#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    3841# include "UIGlobalSettingsProxy.h"
     
    104107#endif
    105108
     109#ifdef VBOX_WS_WIN
     110    /* Interface page: */
     111    m_pSelector->setItemText(GlobalSettingsPageType_Interface, tr("Interface"));
     112#endif
     113
    106114    /* Polish the selector: */
    107115    m_pSelector->polish();
     
    242250                }
    243251#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
     252#ifdef VBOX_WS_WIN
     253                /* Interface page: */
     254                case GlobalSettingsPageType_Interface:
     255                {
     256                    pSettingsPage = new UIGlobalSettingsInterface;
     257                    addItem(":/interface_32px.png", ":/interface_24px.png", ":/interface_16px.png",
     258                            iPageIndex, "#userInterface", pSettingsPage);
     259                    addPageHelpKeyword(iPageIndex, "globalsettings");
     260                    break;
     261                }
     262#endif /* VBOX_WS_WIN */
    244263                default:
    245264                    break;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInterface.cpp

    r89263 r89324  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIMachineSettingsInterface class implementation.
     3 * VBox Qt GUI - UIGlobalSettingsInterface class implementation.
    44 */
    55
    66/*
    7  * Copyright (C) 2008-2020 Oracle Corporation
     7 * Copyright (C) 2008-2021 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1717
    1818/* Qt includes: */
    19 #include <QCheckBox>
    2019#include <QGridLayout>
    2120#include <QLabel>
    2221
    2322/* GUI includes: */
    24 #include "UIActionPool.h"
     23#include "UIColorThemeEditor.h"
    2524#include "UIExtraDataManager.h"
    26 #include "UIMachineSettingsInterface.h"
    27 #include "UIStatusBarEditorWindow.h"
    28 #include "UIMenuBarEditorWindow.h"
    29 #include "UIVisualStateEditor.h"
     25#include "UIGlobalSettingsInterface.h"
    3026
    31 /** Machine settings: User Interface page data structure. */
    32 struct UIDataSettingsMachineInterface
     27/** Global settings: User Interface page data structure. */
     28struct UIDataSettingsGlobalInterface
    3329{
    3430    /** Constructs data. */
    35     UIDataSettingsMachineInterface()
    36         : m_fStatusBarEnabled(false)
    37 #ifndef VBOX_WS_MAC
    38         , m_fMenuBarEnabled(false)
    39 #endif /* !VBOX_WS_MAC */
    40         , m_restrictionsOfMenuBar(UIExtraDataMetaDefs::MenuType_Invalid)
    41         , m_restrictionsOfMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_Invalid)
    42         , m_restrictionsOfMenuMachine(UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Invalid)
    43         , m_restrictionsOfMenuView(UIExtraDataMetaDefs::RuntimeMenuViewActionType_Invalid)
    44         , m_restrictionsOfMenuInput(UIExtraDataMetaDefs::RuntimeMenuInputActionType_Invalid)
    45         , m_restrictionsOfMenuDevices(UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Invalid)
    46 #ifdef VBOX_WITH_DEBUGGER_GUI
    47         , m_restrictionsOfMenuDebug(UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType_Invalid)
    48 #endif /* VBOX_WITH_DEBUGGER_GUI */
    49 #ifdef VBOX_WS_MAC
    50         , m_restrictionsOfMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType_Invalid)
    51 #endif /* VBOX_WS_MAC */
    52         , m_restrictionsOfMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_Invalid)
    53 #ifndef VBOX_WS_MAC
    54         , m_fShowMiniToolBar(false)
    55         , m_fMiniToolBarAtTop(false)
    56 #endif /* !VBOX_WS_MAC */
    57         , m_enmVisualState(UIVisualStateType_Invalid)
     31    UIDataSettingsGlobalInterface()
     32        : m_enmColorTheme(UIColorThemeType_Auto)
    5833    {}
    5934
    6035    /** Returns whether the @a other passed data is equal to this one. */
    61     bool equal(const UIDataSettingsMachineInterface &other) const
     36    bool equal(const UIDataSettingsGlobalInterface &other) const
    6237    {
    63         return true
    64                && (m_fStatusBarEnabled == other.m_fStatusBarEnabled)
    65                && (m_statusBarRestrictions == other.m_statusBarRestrictions)
    66                && (m_statusBarOrder == other.m_statusBarOrder)
    67 #ifndef VBOX_WS_MAC
    68                && (m_fMenuBarEnabled == other.m_fMenuBarEnabled)
    69 #endif /* !VBOX_WS_MAC */
    70                && (m_restrictionsOfMenuBar == other.m_restrictionsOfMenuBar)
    71                && (m_restrictionsOfMenuApplication == other.m_restrictionsOfMenuApplication)
    72                && (m_restrictionsOfMenuMachine == other.m_restrictionsOfMenuMachine)
    73                && (m_restrictionsOfMenuView == other.m_restrictionsOfMenuView)
    74                && (m_restrictionsOfMenuInput == other.m_restrictionsOfMenuInput)
    75                && (m_restrictionsOfMenuDevices == other.m_restrictionsOfMenuDevices)
    76 #ifdef VBOX_WITH_DEBUGGER_GUI
    77                && (m_restrictionsOfMenuDebug == other.m_restrictionsOfMenuDebug)
    78 #endif /* VBOX_WITH_DEBUGGER_GUI */
    79 #ifdef VBOX_WS_MAC
    80                && (m_restrictionsOfMenuWindow == other.m_restrictionsOfMenuWindow)
    81 #endif /* VBOX_WS_MAC */
    82                && (m_restrictionsOfMenuHelp == other.m_restrictionsOfMenuHelp)
    83 #ifndef VBOX_WS_MAC
    84                && (m_fShowMiniToolBar == other.m_fShowMiniToolBar)
    85                && (m_fMiniToolBarAtTop == other.m_fMiniToolBarAtTop)
    86 #endif /* !VBOX_WS_MAC */
    87                && (m_enmVisualState == other.m_enmVisualState)
    88                ;
     38        return    true
     39               && (m_enmColorTheme == other.m_enmColorTheme)
     40                  ;
    8941    }
    9042
    9143    /** Returns whether the @a other passed data is equal to this one. */
    92     bool operator==(const UIDataSettingsMachineInterface &other) const { return equal(other); }
     44    bool operator==(const UIDataSettingsGlobalInterface &other) const { return equal(other); }
    9345    /** Returns whether the @a other passed data is different from this one. */
    94     bool operator!=(const UIDataSettingsMachineInterface &other) const { return !equal(other); }
     46    bool operator!=(const UIDataSettingsGlobalInterface &other) const { return !equal(other); }
    9547
    96     /** Holds whether the status-bar is enabled. */
    97     bool                  m_fStatusBarEnabled;
    98     /** Holds the status-bar indicator restrictions. */
    99     QList<IndicatorType>  m_statusBarRestrictions;
    100     /** Holds the status-bar indicator order. */
    101     QList<IndicatorType>  m_statusBarOrder;
    102 
    103 #ifndef VBOX_WS_MAC
    104     /** Holds whether the menu-bar is enabled. */
    105     bool                                                m_fMenuBarEnabled;
    106 #endif /* !VBOX_WS_MAC */
    107     /** Holds the menu-bar menu restrictions. */
    108     UIExtraDataMetaDefs::MenuType                       m_restrictionsOfMenuBar;
    109     /** Holds the Application menu restrictions. */
    110     UIExtraDataMetaDefs::MenuApplicationActionType      m_restrictionsOfMenuApplication;
    111     /** Holds the Machine menu restrictions. */
    112     UIExtraDataMetaDefs::RuntimeMenuMachineActionType   m_restrictionsOfMenuMachine;
    113     /** Holds the View menu restrictions. */
    114     UIExtraDataMetaDefs::RuntimeMenuViewActionType      m_restrictionsOfMenuView;
    115     /** Holds the Input menu restrictions. */
    116     UIExtraDataMetaDefs::RuntimeMenuInputActionType     m_restrictionsOfMenuInput;
    117     /** Holds the Devices menu restrictions. */
    118     UIExtraDataMetaDefs::RuntimeMenuDevicesActionType   m_restrictionsOfMenuDevices;
    119 #ifdef VBOX_WITH_DEBUGGER_GUI
    120     /** Holds the Debug menu restrictions. */
    121     UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType  m_restrictionsOfMenuDebug;
    122 #endif /* VBOX_WITH_DEBUGGER_GUI */
    123 #ifdef VBOX_WS_MAC
    124     /** Holds the Window menu restrictions. */
    125     UIExtraDataMetaDefs::MenuWindowActionType           m_restrictionsOfMenuWindow;
    126 #endif /* VBOX_WS_MAC */
    127     /** Holds the Help menu restrictions. */
    128     UIExtraDataMetaDefs::MenuHelpActionType             m_restrictionsOfMenuHelp;
    129 
    130 #ifndef VBOX_WS_MAC
    131     /** Holds whether the mini-toolbar is enabled. */
    132     bool  m_fShowMiniToolBar;
    133     /** Holds whether the mini-toolbar should be aligned at top of screen. */
    134     bool  m_fMiniToolBarAtTop;
    135 #endif /* !VBOX_WS_MAC */
    136 
    137     /** Holds the visual state. */
    138     UIVisualStateType  m_enmVisualState;
     48    /** Holds the color-theme. */
     49    UIColorThemeType  m_enmColorTheme;
    13950};
    14051
    14152
    142 UIMachineSettingsInterface::UIMachineSettingsInterface(const QUuid &uMachineId)
    143     : m_uMachineId(uMachineId)
    144     , m_pActionPool(0)
    145     , m_pCache(0)
    146     , m_pEditorMenuBar(0)
    147     , m_pLabelVisualState(0)
    148     , m_pEditorVisualState(0)
    149     , m_pLabelMiniToolBar(0)
    150     , m_pCheckBoxShowMiniToolBar(0)
    151     , m_pCheckBoxMiniToolBarAlignment(0)
    152     , m_pEditorStatusBar(0)
     53/*********************************************************************************************************************************
     54*   Class UIGlobalSettingsInterface implementation.                                                                              *
     55*********************************************************************************************************************************/
     56
     57UIGlobalSettingsInterface::UIGlobalSettingsInterface()
     58    : m_pCache(0)
     59    , m_pLabelColorTheme(0)
     60    , m_pEditorColorTheme(0)
    15361{
    154     /* Prepare: */
    15562    prepare();
    15663}
    15764
    158 UIMachineSettingsInterface::~UIMachineSettingsInterface()
     65UIGlobalSettingsInterface::~UIGlobalSettingsInterface()
    15966{
    160     /* Cleanup: */
    16167    cleanup();
    16268}
    16369
    164 bool UIMachineSettingsInterface::changed() const
     70void UIGlobalSettingsInterface::loadToCacheFrom(QVariant &data)
    16571{
    166     return m_pCache->wasChanged();
    167 }
    168 
    169 void UIMachineSettingsInterface::loadToCacheFrom(QVariant &data)
    170 {
    171     /* Fetch data to machine: */
    172     UISettingsPageMachine::fetchData(data);
     72    /* Fetch data to properties: */
     73    UISettingsPageGlobal::fetchData(data);
    17374
    17475    /* Clear cache initially: */
    17576    m_pCache->clear();
    17677
    177     /* Prepare old interface data: */
    178     UIDataSettingsMachineInterface oldInterfaceData;
     78    /* Cache old data: */
     79    UIDataSettingsGlobalInterface oldData;
     80    oldData.m_enmColorTheme = gEDataManager->colorTheme();
     81    m_pCache->cacheInitialData(oldData);
    17982
    180     /* Gather old interface data: */
    181     oldInterfaceData.m_fStatusBarEnabled = gEDataManager->statusBarEnabled(m_machine.GetId());
    182     oldInterfaceData.m_statusBarRestrictions = gEDataManager->restrictedStatusBarIndicators(m_machine.GetId());
    183     oldInterfaceData.m_statusBarOrder = gEDataManager->statusBarIndicatorOrder(m_machine.GetId());
    184 #ifndef VBOX_WS_MAC
    185     oldInterfaceData.m_fMenuBarEnabled = gEDataManager->menuBarEnabled(m_machine.GetId());
    186 #endif
    187     oldInterfaceData.m_restrictionsOfMenuBar = gEDataManager->restrictedRuntimeMenuTypes(m_machine.GetId());
    188     oldInterfaceData.m_restrictionsOfMenuApplication = gEDataManager->restrictedRuntimeMenuApplicationActionTypes(m_machine.GetId());
    189     oldInterfaceData.m_restrictionsOfMenuMachine = gEDataManager->restrictedRuntimeMenuMachineActionTypes(m_machine.GetId());
    190     oldInterfaceData.m_restrictionsOfMenuView = gEDataManager->restrictedRuntimeMenuViewActionTypes(m_machine.GetId());
    191     oldInterfaceData.m_restrictionsOfMenuInput = gEDataManager->restrictedRuntimeMenuInputActionTypes(m_machine.GetId());
    192     oldInterfaceData.m_restrictionsOfMenuDevices = gEDataManager->restrictedRuntimeMenuDevicesActionTypes(m_machine.GetId());
    193 #ifdef VBOX_WITH_DEBUGGER_GUI
    194     oldInterfaceData.m_restrictionsOfMenuDebug = gEDataManager->restrictedRuntimeMenuDebuggerActionTypes(m_machine.GetId());
    195 #endif
    196 #ifdef VBOX_WS_MAC
    197     oldInterfaceData.m_restrictionsOfMenuWindow = gEDataManager->restrictedRuntimeMenuWindowActionTypes(m_machine.GetId());
    198 #endif
    199     oldInterfaceData.m_restrictionsOfMenuHelp = gEDataManager->restrictedRuntimeMenuHelpActionTypes(m_machine.GetId());
    200 #ifndef VBOX_WS_MAC
    201     oldInterfaceData.m_fShowMiniToolBar = gEDataManager->miniToolbarEnabled(m_machine.GetId());
    202     oldInterfaceData.m_fMiniToolBarAtTop = gEDataManager->miniToolbarAlignment(m_machine.GetId()) == Qt::AlignTop;
    203 #endif
    204     oldInterfaceData.m_enmVisualState = gEDataManager->requestedVisualState(m_machine.GetId());
    205 
    206     /* Cache old interface data: */
    207     m_pCache->cacheInitialData(oldInterfaceData);
    208 
    209     /* Upload machine to data: */
    210     UISettingsPageMachine::uploadData(data);
     83    /* Upload properties to data: */
     84    UISettingsPageGlobal::uploadData(data);
    21185}
    21286
    213 void UIMachineSettingsInterface::getFromCache()
     87void UIGlobalSettingsInterface::getFromCache()
    21488{
    215     /* Get old interface data from the cache: */
    216     const UIDataSettingsMachineInterface &oldInterfaceData = m_pCache->base();
    217 
    218     /* Load old interface data from the cache: */
    219     m_pEditorStatusBar->setStatusBarEnabled(oldInterfaceData.m_fStatusBarEnabled);
    220     m_pEditorStatusBar->setStatusBarConfiguration(oldInterfaceData.m_statusBarRestrictions,
    221                                                   oldInterfaceData.m_statusBarOrder);
    222 #ifndef VBOX_WS_MAC
    223     m_pEditorMenuBar->setMenuBarEnabled(oldInterfaceData.m_fMenuBarEnabled);
    224 #endif
    225     m_pEditorMenuBar->setRestrictionsOfMenuBar(oldInterfaceData.m_restrictionsOfMenuBar);
    226     m_pEditorMenuBar->setRestrictionsOfMenuApplication(oldInterfaceData.m_restrictionsOfMenuApplication);
    227     m_pEditorMenuBar->setRestrictionsOfMenuMachine(oldInterfaceData.m_restrictionsOfMenuMachine);
    228     m_pEditorMenuBar->setRestrictionsOfMenuView(oldInterfaceData.m_restrictionsOfMenuView);
    229     m_pEditorMenuBar->setRestrictionsOfMenuInput(oldInterfaceData.m_restrictionsOfMenuInput);
    230     m_pEditorMenuBar->setRestrictionsOfMenuDevices(oldInterfaceData.m_restrictionsOfMenuDevices);
    231 #ifdef VBOX_WITH_DEBUGGER_GUI
    232     m_pEditorMenuBar->setRestrictionsOfMenuDebug(oldInterfaceData.m_restrictionsOfMenuDebug);
    233 #endif
    234 #ifdef VBOX_WS_MAC
    235     m_pEditorMenuBar->setRestrictionsOfMenuWindow(oldInterfaceData.m_restrictionsOfMenuWindow);
    236 #endif
    237     m_pEditorMenuBar->setRestrictionsOfMenuHelp(oldInterfaceData.m_restrictionsOfMenuHelp);
    238 #ifndef VBOX_WS_MAC
    239     m_pCheckBoxShowMiniToolBar->setChecked(oldInterfaceData.m_fShowMiniToolBar);
    240     m_pCheckBoxMiniToolBarAlignment->setChecked(oldInterfaceData.m_fMiniToolBarAtTop);
    241 #endif
    242     m_pEditorVisualState->setMachineId(m_machine.GetId());
    243     m_pEditorVisualState->setValue(oldInterfaceData.m_enmVisualState);
    244 
    245     /* Polish page finally: */
    246     polishPage();
     89    /* Load old data from the cache: */
     90    const UIDataSettingsGlobalInterface &oldData = m_pCache->base();
     91    m_pEditorColorTheme->setValue(oldData.m_enmColorTheme);
    24792
    24893    /* Revalidate: */
     
    25095}
    25196
    252 void UIMachineSettingsInterface::putToCache()
     97void UIGlobalSettingsInterface::putToCache()
    25398{
    254     /* Prepare new interface data: */
    255     UIDataSettingsMachineInterface newInterfaceData;
     99    /* Prepare new data: */
     100    UIDataSettingsGlobalInterface newData;
    256101
    257     /* Gather new interface data: */
    258     newInterfaceData.m_fStatusBarEnabled = m_pEditorStatusBar->isStatusBarEnabled();
    259     newInterfaceData.m_statusBarRestrictions = m_pEditorStatusBar->statusBarIndicatorRestrictions();
    260     newInterfaceData.m_statusBarOrder = m_pEditorStatusBar->statusBarIndicatorOrder();
    261 #ifndef VBOX_WS_MAC
    262     newInterfaceData.m_fMenuBarEnabled = m_pEditorMenuBar->isMenuBarEnabled();
    263 #endif
    264     newInterfaceData.m_restrictionsOfMenuBar = m_pEditorMenuBar->restrictionsOfMenuBar();
    265     newInterfaceData.m_restrictionsOfMenuApplication = m_pEditorMenuBar->restrictionsOfMenuApplication();
    266     newInterfaceData.m_restrictionsOfMenuMachine = m_pEditorMenuBar->restrictionsOfMenuMachine();
    267     newInterfaceData.m_restrictionsOfMenuView = m_pEditorMenuBar->restrictionsOfMenuView();
    268     newInterfaceData.m_restrictionsOfMenuInput = m_pEditorMenuBar->restrictionsOfMenuInput();
    269     newInterfaceData.m_restrictionsOfMenuDevices = m_pEditorMenuBar->restrictionsOfMenuDevices();
    270 #ifdef VBOX_WITH_DEBUGGER_GUI
    271     newInterfaceData.m_restrictionsOfMenuDebug = m_pEditorMenuBar->restrictionsOfMenuDebug();
    272 #endif
    273 #ifdef VBOX_WS_MAC
    274     newInterfaceData.m_restrictionsOfMenuWindow = m_pEditorMenuBar->restrictionsOfMenuWindow();
    275 #endif
    276     newInterfaceData.m_restrictionsOfMenuHelp = m_pEditorMenuBar->restrictionsOfMenuHelp();
    277 #ifndef VBOX_WS_MAC
    278     newInterfaceData.m_fShowMiniToolBar = m_pCheckBoxShowMiniToolBar->isChecked();
    279     newInterfaceData.m_fMiniToolBarAtTop = m_pCheckBoxMiniToolBarAlignment->isChecked();
    280 #endif
    281     newInterfaceData.m_enmVisualState = m_pEditorVisualState->value();
    282 
    283     /* Cache new interface data: */
    284     m_pCache->cacheCurrentData(newInterfaceData);
     102    /* Cache new data: */
     103    newData.m_enmColorTheme = m_pEditorColorTheme->value();
     104    m_pCache->cacheCurrentData(newData);
    285105}
    286106
    287 void UIMachineSettingsInterface::saveFromCacheTo(QVariant &data)
     107void UIGlobalSettingsInterface::saveFromCacheTo(QVariant &data)
    288108{
    289     /* Fetch data to machine: */
    290     UISettingsPageMachine::fetchData(data);
     109    /* Fetch data to properties: */
     110    UISettingsPageGlobal::fetchData(data);
    291111
    292     /* Update interface data and failing state: */
    293     setFailed(!saveInterfaceData());
     112    /* Update data and failing state: */
     113    setFailed(!saveData());
    294114
    295     /* Upload machine to data: */
    296     UISettingsPageMachine::uploadData(data);
     115    /* Upload properties to data: */
     116    UISettingsPageGlobal::uploadData(data);
    297117}
    298118
    299 void UIMachineSettingsInterface::retranslateUi()
     119void UIGlobalSettingsInterface::retranslateUi()
    300120{
    301     m_pEditorMenuBar->setWhatsThis(tr("Allows to modify VM menu-bar contents."));
    302     m_pLabelVisualState->setText(tr("Visual State:"));
    303     m_pEditorVisualState->setWhatsThis(tr("Selects the visual state. If machine is running it will be applied as soon as possible,"
    304                                           "otherwise desired one will be defined."));
    305     m_pLabelMiniToolBar->setText(tr("Mini ToolBar:"));
    306     m_pCheckBoxShowMiniToolBar->setWhatsThis(tr("When checked, show the Mini ToolBar in full-screen and seamless modes."));
    307     m_pCheckBoxShowMiniToolBar->setText(tr("Show in &Full-screen/Seamless"));
    308     m_pCheckBoxMiniToolBarAlignment->setWhatsThis(tr("When checked, show the Mini ToolBar at the top of the screen, rather than in its"
    309                                               "default position at the bottom of the screen."));
    310     m_pCheckBoxMiniToolBarAlignment->setText(tr("Show at &Top of Screen"));
    311     m_pEditorStatusBar->setWhatsThis(tr("Allows to modify VM status-bar contents."));
     121    m_pLabelColorTheme->setText(tr("Color &Theme:"));
     122    m_pEditorColorTheme->setWhatsThis(tr("Selects the color theme. It can be Light, Dark or automatically detected (default)."));
    312123}
    313124
    314 void UIMachineSettingsInterface::polishPage()
     125void UIGlobalSettingsInterface::prepare()
    315126{
    316     /* Polish interface page availability: */
    317     m_pEditorMenuBar->setEnabled(isMachineInValidMode());
    318 #ifdef VBOX_WS_MAC
    319     m_pLabelMiniToolBar->hide();
    320     m_pCheckBoxShowMiniToolBar->hide();
    321     m_pCheckBoxMiniToolBarAlignment->hide();
    322 #else /* !VBOX_WS_MAC */
    323     m_pLabelMiniToolBar->setEnabled(isMachineInValidMode());
    324     m_pCheckBoxShowMiniToolBar->setEnabled(isMachineInValidMode());
    325     m_pCheckBoxMiniToolBarAlignment->setEnabled(isMachineInValidMode() && m_pCheckBoxShowMiniToolBar->isChecked());
    326 #endif /* !VBOX_WS_MAC */
    327     m_pEditorStatusBar->setEnabled(isMachineInValidMode());
    328 }
    329 
    330 void UIMachineSettingsInterface::prepare()
    331 {
    332     /* Prepare action-pool: */
    333     m_pActionPool = UIActionPool::create(UIActionPoolType_Runtime);
    334 
    335127    /* Prepare cache: */
    336     m_pCache = new UISettingsCacheMachineInterface;
     128    m_pCache = new UISettingsCacheGlobalInterface;
    337129    AssertPtrReturnVoid(m_pCache);
    338130
    339131    /* Prepare everything: */
    340132    prepareWidgets();
    341     prepareConnections();
    342133
    343134    /* Apply language settings: */
     
    345136}
    346137
    347 void UIMachineSettingsInterface::prepareWidgets()
     138void UIGlobalSettingsInterface::prepareWidgets()
    348139{
    349140    /* Prepare main layout: */
     
    352143    {
    353144        pLayoutMain->setColumnStretch(1, 1);
    354         pLayoutMain->setRowStretch(4, 1);
     145        pLayoutMain->setRowStretch(1, 1);
    355146
    356         /* Prepare menu-bar editor: */
    357         m_pEditorMenuBar = new UIMenuBarEditorWidget(this);
    358         if (m_pEditorMenuBar)
     147        /* Prepare color-theme label: */
     148        m_pLabelColorTheme = new QLabel(this);
     149        if (m_pLabelColorTheme)
    359150        {
    360             m_pEditorMenuBar->setActionPool(m_pActionPool);
    361             m_pEditorMenuBar->setMachineID(m_uMachineId);
    362 
    363             pLayoutMain->addWidget(m_pEditorMenuBar, 0, 0, 1, 3);
     151            m_pLabelColorTheme->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     152            pLayoutMain->addWidget(m_pLabelColorTheme, 0, 0);
    364153        }
    365 
    366         /* Prepare visual-state label: */
    367         m_pLabelVisualState = new QLabel(this);
    368         if (m_pLabelVisualState)
     154        /* Prepare color-theme editor: */
     155        m_pEditorColorTheme = new UIColorThemeEditor(this);
     156        if (m_pEditorColorTheme)
    369157        {
    370             m_pLabelVisualState->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    371             pLayoutMain->addWidget(m_pLabelVisualState, 1, 0);
    372         }
    373         /* Prepare visual-state editor: */
    374         m_pEditorVisualState = new UIVisualStateEditor(this);
    375         if (m_pEditorVisualState)
    376             pLayoutMain->addWidget(m_pEditorVisualState, 1, 1);
    377 
    378         /* Prepare mini-toolbar label: */
    379         m_pLabelMiniToolBar = new QLabel(this);
    380         if (m_pLabelMiniToolBar)
    381         {
    382             m_pLabelMiniToolBar->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    383             pLayoutMain->addWidget(m_pLabelMiniToolBar, 2, 0);
    384         }
    385         /* Prepare 'show mini-toolbar' check-box: */
    386         m_pCheckBoxShowMiniToolBar = new QCheckBox(this);
    387         if (m_pCheckBoxShowMiniToolBar)
    388             pLayoutMain->addWidget(m_pCheckBoxShowMiniToolBar, 2, 1);
    389         /* Prepare 'mini-toolbar alignment' check-box: */
    390         m_pCheckBoxMiniToolBarAlignment = new QCheckBox(this);
    391         if (m_pCheckBoxMiniToolBarAlignment)
    392             pLayoutMain->addWidget(m_pCheckBoxMiniToolBarAlignment, 3, 1);
    393 
    394         /* Prepare status-bar editor: */
    395         m_pEditorStatusBar = new UIStatusBarEditorWidget(this);
    396         if (m_pEditorStatusBar)
    397         {
    398             m_pEditorStatusBar->setMachineID(m_uMachineId);
    399             pLayoutMain->addWidget(m_pEditorStatusBar, 5, 0, 1, 3);
     158            m_pLabelColorTheme->setBuddy(m_pEditorColorTheme->focusProxy());
     159            pLayoutMain->addWidget(m_pEditorColorTheme, 0, 1);
    400160        }
    401161    }
    402162}
    403163
    404 void UIMachineSettingsInterface::prepareConnections()
     164void UIGlobalSettingsInterface::cleanup()
    405165{
    406     connect(m_pCheckBoxShowMiniToolBar, &QCheckBox::toggled,
    407             m_pCheckBoxMiniToolBarAlignment, &UIMachineSettingsInterface::setEnabled);
    408 }
    409 
    410 void UIMachineSettingsInterface::cleanup()
    411 {
    412     /* Cleanup action-pool: */
    413     UIActionPool::destroy(m_pActionPool);
    414 
    415166    /* Cleanup cache: */
    416167    delete m_pCache;
     
    418169}
    419170
    420 bool UIMachineSettingsInterface::saveInterfaceData()
     171bool UIGlobalSettingsInterface::saveData()
    421172{
    422173    /* Prepare result: */
    423174    bool fSuccess = true;
    424     /* Save display settings from the cache: */
    425     if (fSuccess && isMachineInValidMode() && m_pCache->wasChanged())
     175    /* Save settings from cache: */
     176    if (   fSuccess
     177        && m_pCache->wasChanged())
    426178    {
    427         /* Save 'Menu-bar' data from the cache: */
    428         if (fSuccess)
    429             fSuccess = saveMenuBarData();
    430         /* Save 'Status-bar' data from the cache: */
    431         if (fSuccess)
    432             fSuccess = saveStatusBarData();
    433         /* Save 'Mini-toolbar' data from the cache: */
    434         if (fSuccess)
    435             fSuccess = saveMiniToolbarData();
    436         /* Save 'Visual State' data from the cache: */
    437         if (fSuccess)
    438             fSuccess = saveVisualStateData();
     179        /* Get old data from cache: */
     180        const UIDataSettingsGlobalInterface &oldData = m_pCache->base();
     181        /* Get new data from cache: */
     182        const UIDataSettingsGlobalInterface &newData = m_pCache->data();
     183
     184        /* Save 'color-theme': */
     185        if (   fSuccess
     186            && newData.m_enmColorTheme != oldData.m_enmColorTheme)
     187            /* fSuccess = */ gEDataManager->setColorTheme(newData.m_enmColorTheme);
    439188    }
    440189    /* Return result: */
    441190    return fSuccess;
    442191}
    443 
    444 bool UIMachineSettingsInterface::saveMenuBarData()
    445 {
    446     /* Prepare result: */
    447     bool fSuccess = true;
    448     /* Save 'Menu-bar' data from the cache: */
    449     if (fSuccess)
    450     {
    451         /* Get old interface data from the cache: */
    452         const UIDataSettingsMachineInterface &oldInterfaceData = m_pCache->base();
    453         /* Get new interface data from the cache: */
    454         const UIDataSettingsMachineInterface &newInterfaceData = m_pCache->data();
    455 
    456 #ifndef VBOX_WS_MAC
    457         /* Save whether menu-bar is enabled: */
    458         if (fSuccess && newInterfaceData.m_fMenuBarEnabled != oldInterfaceData.m_fMenuBarEnabled)
    459             /* fSuccess = */ gEDataManager->setMenuBarEnabled(newInterfaceData.m_fMenuBarEnabled, m_machine.GetId());
    460 #endif
    461         /* Save menu-bar restrictions: */
    462         if (fSuccess && newInterfaceData.m_restrictionsOfMenuBar != oldInterfaceData.m_restrictionsOfMenuBar)
    463             /* fSuccess = */ gEDataManager->setRestrictedRuntimeMenuTypes(newInterfaceData.m_restrictionsOfMenuBar, m_machine.GetId());
    464         /* Save menu-bar Application menu restrictions: */
    465         if (fSuccess && newInterfaceData.m_restrictionsOfMenuApplication != oldInterfaceData.m_restrictionsOfMenuApplication)
    466             /* fSuccess = */ gEDataManager->setRestrictedRuntimeMenuApplicationActionTypes(newInterfaceData.m_restrictionsOfMenuApplication, m_machine.GetId());
    467         /* Save menu-bar Machine menu restrictions: */
    468         if (fSuccess && newInterfaceData.m_restrictionsOfMenuMachine != oldInterfaceData.m_restrictionsOfMenuMachine)
    469            /* fSuccess = */  gEDataManager->setRestrictedRuntimeMenuMachineActionTypes(newInterfaceData.m_restrictionsOfMenuMachine, m_machine.GetId());
    470         /* Save menu-bar View menu restrictions: */
    471         if (fSuccess && newInterfaceData.m_restrictionsOfMenuView != oldInterfaceData.m_restrictionsOfMenuView)
    472            /* fSuccess = */  gEDataManager->setRestrictedRuntimeMenuViewActionTypes(newInterfaceData.m_restrictionsOfMenuView, m_machine.GetId());
    473         /* Save menu-bar Input menu restrictions: */
    474         if (fSuccess && newInterfaceData.m_restrictionsOfMenuInput != oldInterfaceData.m_restrictionsOfMenuInput)
    475             /* fSuccess = */ gEDataManager->setRestrictedRuntimeMenuInputActionTypes(newInterfaceData.m_restrictionsOfMenuInput, m_machine.GetId());
    476         /* Save menu-bar Devices menu restrictions: */
    477         if (fSuccess && newInterfaceData.m_restrictionsOfMenuDevices != oldInterfaceData.m_restrictionsOfMenuDevices)
    478             /* fSuccess = */ gEDataManager->setRestrictedRuntimeMenuDevicesActionTypes(newInterfaceData.m_restrictionsOfMenuDevices, m_machine.GetId());
    479 #ifdef VBOX_WITH_DEBUGGER_GUI
    480         /* Save menu-bar Debug menu restrictions: */
    481         if (fSuccess && newInterfaceData.m_restrictionsOfMenuDebug != oldInterfaceData.m_restrictionsOfMenuDebug)
    482             /* fSuccess = */ gEDataManager->setRestrictedRuntimeMenuDebuggerActionTypes(newInterfaceData.m_restrictionsOfMenuDebug, m_machine.GetId());
    483 #endif
    484 #ifdef VBOX_WS_MAC
    485         /* Save menu-bar Window menu restrictions: */
    486         if (fSuccess && newInterfaceData.m_restrictionsOfMenuWindow != oldInterfaceData.m_restrictionsOfMenuWindow)
    487             /* fSuccess = */ gEDataManager->setRestrictedRuntimeMenuWindowActionTypes(newInterfaceData.m_restrictionsOfMenuWindow, m_machine.GetId());
    488 #endif
    489         /* Save menu-bar Help menu restrictions: */
    490         if (fSuccess && newInterfaceData.m_restrictionsOfMenuHelp != oldInterfaceData.m_restrictionsOfMenuHelp)
    491             /* fSuccess = */ gEDataManager->setRestrictedRuntimeMenuHelpActionTypes(newInterfaceData.m_restrictionsOfMenuHelp, m_machine.GetId());
    492     }
    493     /* Return result: */
    494     return fSuccess;
    495 }
    496 
    497 bool UIMachineSettingsInterface::saveStatusBarData()
    498 {
    499     /* Prepare result: */
    500     bool fSuccess = true;
    501     /* Save 'Status-bar' data from the cache: */
    502     if (fSuccess)
    503     {
    504         /* Get old interface data from the cache: */
    505         const UIDataSettingsMachineInterface &oldInterfaceData = m_pCache->base();
    506         /* Get new interface data from the cache: */
    507         const UIDataSettingsMachineInterface &newInterfaceData = m_pCache->data();
    508 
    509         /* Save whether status-bar is enabled: */
    510         if (fSuccess && newInterfaceData.m_fStatusBarEnabled != oldInterfaceData.m_fStatusBarEnabled)
    511             /* fSuccess = */ gEDataManager->setStatusBarEnabled(newInterfaceData.m_fStatusBarEnabled, m_machine.GetId());
    512         /* Save status-bar restrictions: */
    513         if (fSuccess && newInterfaceData.m_statusBarRestrictions != oldInterfaceData.m_statusBarRestrictions)
    514             /* fSuccess = */ gEDataManager->setRestrictedStatusBarIndicators(newInterfaceData.m_statusBarRestrictions, m_machine.GetId());
    515         /* Save status-bar order: */
    516         if (fSuccess && newInterfaceData.m_statusBarOrder != oldInterfaceData.m_statusBarOrder)
    517             /* fSuccess = */ gEDataManager->setStatusBarIndicatorOrder(newInterfaceData.m_statusBarOrder, m_machine.GetId());
    518     }
    519     /* Return result: */
    520     return fSuccess;
    521 }
    522 
    523 bool UIMachineSettingsInterface::saveMiniToolbarData()
    524 {
    525     /* Prepare result: */
    526     bool fSuccess = true;
    527     /* Save 'Mini-toolbar' data from the cache: */
    528     if (fSuccess)
    529     {
    530         /* Get old interface data from the cache: */
    531         const UIDataSettingsMachineInterface &oldInterfaceData = m_pCache->base(); Q_UNUSED(oldInterfaceData);
    532         /* Get new interface data from the cache: */
    533         const UIDataSettingsMachineInterface &newInterfaceData = m_pCache->data(); Q_UNUSED(newInterfaceData);
    534 
    535 #ifndef VBOX_WS_MAC
    536         /* Save whether mini-toolbar is enabled: */
    537         if (fSuccess && newInterfaceData.m_fShowMiniToolBar != oldInterfaceData.m_fShowMiniToolBar)
    538             /* fSuccess = */ gEDataManager->setMiniToolbarEnabled(newInterfaceData.m_fShowMiniToolBar, m_machine.GetId());
    539         /* Save whether mini-toolbar should be location at top of screen: */
    540         if (fSuccess && newInterfaceData.m_fMiniToolBarAtTop != oldInterfaceData.m_fMiniToolBarAtTop)
    541             /* fSuccess = */ gEDataManager->setMiniToolbarAlignment(newInterfaceData.m_fMiniToolBarAtTop ? Qt::AlignTop : Qt::AlignBottom, m_machine.GetId());
    542 #endif
    543     }
    544     /* Return result: */
    545     return fSuccess;
    546 }
    547 
    548 bool UIMachineSettingsInterface::saveVisualStateData()
    549 {
    550     /* Prepare result: */
    551     bool fSuccess = true;
    552     /* Save 'Visual State' data from the cache: */
    553     if (fSuccess)
    554     {
    555         /* Get old interface data from the cache: */
    556         const UIDataSettingsMachineInterface &oldInterfaceData = m_pCache->base();
    557         /* Get new interface data from the cache: */
    558         const UIDataSettingsMachineInterface &newInterfaceData = m_pCache->data();
    559 
    560         /* Save desired visual state: */
    561         if (fSuccess && newInterfaceData.m_enmVisualState != oldInterfaceData.m_enmVisualState)
    562             /* fSuccess = */ gEDataManager->setRequestedVisualState(newInterfaceData.m_enmVisualState, m_machine.GetId());
    563     }
    564     /* Return result: */
    565     return fSuccess;
    566 }
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInterface.h

    r89263 r89324  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIMachineSettingsInterface class declaration.
     3 * VBox Qt GUI - UIGlobalSettingsInterface class declaration.
    44 */
    55
    66/*
    7  * Copyright (C) 2008-2020 Oracle Corporation
     7 * Copyright (C) 2008-2021 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_settings_machine_UIMachineSettingsInterface_h
    19 #define FEQT_INCLUDED_SRC_settings_machine_UIMachineSettingsInterface_h
     18#ifndef FEQT_INCLUDED_SRC_settings_global_UIGlobalSettingsInterface_h
     19#define FEQT_INCLUDED_SRC_settings_global_UIGlobalSettingsInterface_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
     
    2626
    2727/* Forward declarations: */
    28 class QCheckBox;
    2928class QLabel;
    30 class UIActionPool;
    31 class UIMenuBarEditorWidget;
    32 class UIStatusBarEditorWidget;
    33 class UIVisualStateEditor;
    34 struct UIDataSettingsMachineInterface;
    35 typedef UISettingsCache<UIDataSettingsMachineInterface> UISettingsCacheMachineInterface;
     29class UIColorThemeEditor;
     30struct UIDataSettingsGlobalInterface;
     31typedef UISettingsCache<UIDataSettingsGlobalInterface> UISettingsCacheGlobalInterface;
    3632
    37 /** Machine settings: User Interface page. */
    38 class SHARED_LIBRARY_STUFF UIMachineSettingsInterface : public UISettingsPageMachine
     33/** Global settings: User Interface page. */
     34class SHARED_LIBRARY_STUFF UIGlobalSettingsInterface : public UISettingsPageGlobal
    3935{
    4036    Q_OBJECT;
     
    4339
    4440    /** Constructs User Interface settings page. */
    45     UIMachineSettingsInterface(const QUuid &uMachineId);
     41    UIGlobalSettingsInterface();
    4642    /** Destructs User Interface settings page. */
    47     ~UIMachineSettingsInterface();
     43    virtual ~UIGlobalSettingsInterface() /* override */;
    4844
    4945protected:
    50 
    51     /** Returns whether the page content was changed. */
    52     virtual bool changed() const /* override */;
    5346
    5447    /** Loads settings from external object(s) packed inside @a data to cache.
     
    6962    virtual void retranslateUi() /* override */;
    7063
    71     /** Performs final page polishing. */
    72     virtual void polishPage() /* override */;
    73 
    7464private:
    7565
     
    7868    /** Prepares widgets. */
    7969    void prepareWidgets();
    80     /** Prepares connections. */
    81     void prepareConnections();
    8270    /** Cleanups all. */
    8371    void cleanup();
    8472
    85     /** Saves existing interface data from the cache. */
    86     bool saveInterfaceData();
    87     /** Saves existing 'Menu-bar' data from the cache. */
    88     bool saveMenuBarData();
    89     /** Saves existing 'Status-bar' data from the cache. */
    90     bool saveStatusBarData();
    91     /** Saves existing 'Mini-toolbar' data from the cache. */
    92     bool saveMiniToolbarData();
    93     /** Saves existing 'Visual State' data from the cache. */
    94     bool saveVisualStateData();
    95 
    96     /** Holds the machine ID copy. */
    97     const QUuid    m_uMachineId;
    98     /** Holds the action-pool instance. */
    99     UIActionPool  *m_pActionPool;
     73    /** Saves existing data from cache. */
     74    bool saveData();
    10075
    10176    /** Holds the page data cache instance. */
    102     UISettingsCacheMachineInterface *m_pCache;
     77    UISettingsCacheGlobalInterface *m_pCache;
    10378
    10479    /** @name Widgets
    10580     * @{ */
    106         /** Holds the menu-bar editor instance. */
    107         UIMenuBarEditorWidget   *m_pEditorMenuBar;
    108         /** Holds the visual state label instance. */
    109         QLabel                  *m_pLabelVisualState;
    110         /** Holds the visual state label instance. */
    111         UIVisualStateEditor     *m_pEditorVisualState;
    112         /** Holds the mini-toolbar label instance. */
    113         QLabel                  *m_pLabelMiniToolBar;
    114         /** Holds the 'show mini-toolbar' check-box instance. */
    115         QCheckBox               *m_pCheckBoxShowMiniToolBar;
    116         /** Holds the 'mini-toolbar alignment' check-box instance. */
    117         QCheckBox               *m_pCheckBoxMiniToolBarAlignment;
    118         /** Holds the status-bar editor instance. */
    119         UIStatusBarEditorWidget *m_pEditorStatusBar;
     81        /** Holds the color theme label instance. */
     82        QLabel             *m_pLabelColorTheme;
     83        /** Holds the color theme label instance. */
     84        UIColorThemeEditor *m_pEditorColorTheme;
    12085    /** @} */
    12186};
    12287
    123 #endif /* !FEQT_INCLUDED_SRC_settings_machine_UIMachineSettingsInterface_h */
     88#endif /* !FEQT_INCLUDED_SRC_settings_global_UIGlobalSettingsInterface_h */
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