VirtualBox

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


Ignore:
Timestamp:
Nov 25, 2020 4:56:23 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
141520
Message:

FE/Qt: bugref:9827: Global properties / Display page: Heavy rework, replacing widgets with corresponding editor classes.

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

Legend:

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

    r86814 r86978  
    850850        src/settings/editors/UIHotKeyEditor.h \
    851851        src/settings/editors/UILanguageSettingsEditor.h \
     852        src/settings/editors/UIMaximumGuestScreenSizeEditor.h \
    852853        src/settings/editors/UINameAndSystemEditor.h \
    853854        src/settings/editors/UINetworkAttachmentEditor.h \
     
    13761377        src/settings/editors/UIHotKeyEditor.cpp \
    13771378        src/settings/editors/UILanguageSettingsEditor.cpp \
     1379        src/settings/editors/UIMaximumGuestScreenSizeEditor.cpp \
    13781380        src/settings/editors/UINameAndSystemEditor.cpp \
    13791381        src/settings/editors/UINetworkAttachmentEditor.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackend.h

    r86977 r86978  
    262262template<> SHARED_LIBRARY_STUFF InformationElementType fromInternalString<InformationElementType>(const QString &strInformationElementType);
    263263template<> SHARED_LIBRARY_STUFF QIcon toIcon(const InformationElementType &informationElementType);
     264template<> SHARED_LIBRARY_STUFF QString toString(const MaximumGuestScreenSizePolicy &enmMaximumGuestScreenSizePolicy);
    264265template<> SHARED_LIBRARY_STUFF QString toInternalString(const MaximumGuestScreenSizePolicy &enmMaximumGuestScreenSizePolicy);
    265266template<> SHARED_LIBRARY_STUFF MaximumGuestScreenSizePolicy fromInternalString<MaximumGuestScreenSizePolicy>(const QString &strMaximumGuestScreenSizePolicy);
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp

    r86977 r86978  
    24582458
    24592459/* QString <= MaximumGuestScreenSizePolicy: */
     2460template<> QString toString(const MaximumGuestScreenSizePolicy &enmMaximumGuestScreenSizePolicy)
     2461{
     2462    QString strResult;
     2463    switch (enmMaximumGuestScreenSizePolicy)
     2464    {
     2465        case MaximumGuestScreenSizePolicy_Any:       strResult = QApplication::translate("UICommon", "None", "Maximum Guest Screen Size"); break;
     2466        case MaximumGuestScreenSizePolicy_Fixed:     strResult = QApplication::translate("UICommon", "Hint", "Maximum Guest Screen Size"); break;
     2467        case MaximumGuestScreenSizePolicy_Automatic: strResult = QApplication::translate("UICommon", "Automatic", "Maximum Guest Screen Size"); break;
     2468        default:
     2469        {
     2470            AssertMsgFailed(("No text for maximum guest resolution policy=%d", enmMaximumGuestScreenSizePolicy));
     2471            break;
     2472        }
     2473    }
     2474    return strResult;
     2475}
     2476
     2477/* QString <= MaximumGuestScreenSizePolicy: */
    24602478template<> QString toInternalString(const MaximumGuestScreenSizePolicy &enmMaximumGuestScreenSizePolicy)
    24612479{
     
    24672485        default:
    24682486        {
    2469             AssertMsgFailed(("No text for max guest resolution policy=%d", enmMaximumGuestScreenSizePolicy));
     2487            AssertMsgFailed(("No text for maximum guest resolution policy=%d", enmMaximumGuestScreenSizePolicy));
    24702488            break;
    24712489        }
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r86977 r86978  
    10711071    MaximumGuestScreenSizePolicy_Automatic
    10721072};
     1073Q_DECLARE_METATYPE(MaximumGuestScreenSizePolicy);
    10731074
    10741075
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIMaximumGuestScreenSizeEditor.cpp

    r86910 r86978  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIAudioControllerEditor class implementation.
     3 * VBox Qt GUI - UIMaximumGuestScreenSizeEditor class implementation.
    44 */
    55
     
    2020#include <QHBoxLayout>
    2121#include <QLabel>
     22#include <QSpinBox>
    2223
    2324/* GUI includes: */
     
    2526#include "UICommon.h"
    2627#include "UIConverter.h"
    27 #include "UIAudioControllerEditor.h"
    28 
    29 /* COM includes: */
    30 #include "CSystemProperties.h"
    31 
    32 
    33 UIAudioControllerEditor::UIAudioControllerEditor(QWidget *pParent /* = 0 */, bool fWithLabel /* = false */)
     28#include "UIMaximumGuestScreenSizeEditor.h"
     29
     30
     31/*********************************************************************************************************************************
     32*   Class UIMaximumGuestScreenSizeValue implementation.                                                                          *
     33*********************************************************************************************************************************/
     34
     35UIMaximumGuestScreenSizeValue::UIMaximumGuestScreenSizeValue(MaximumGuestScreenSizePolicy enmPolicy /* = MaximumGuestScreenSizePolicy_Any */,
     36                                                             const QSize &size /* = QSize() */)
     37    : m_enmPolicy(enmPolicy)
     38    , m_size(size)
     39{
     40}
     41
     42bool UIMaximumGuestScreenSizeValue::equal(const UIMaximumGuestScreenSizeValue &other) const
     43{
     44    return true
     45           && (m_enmPolicy == other.m_enmPolicy)
     46           && (m_size == other.m_size)
     47           ;
     48}
     49
     50
     51/*********************************************************************************************************************************
     52*   Class UIMaximumGuestScreenSizeEditor implementation.                                                                         *
     53*********************************************************************************************************************************/
     54
     55UIMaximumGuestScreenSizeEditor::UIMaximumGuestScreenSizeEditor(QWidget *pParent /* = 0 */, bool fWithLabels /* = false */)
    3456    : QIWithRetranslateUI<QWidget>(pParent)
    35     , m_fWithLabel(fWithLabel)
    36     , m_enmValue(KAudioControllerType_Max)
    37     , m_pLabel(0)
    38     , m_pCombo(0)
     57    , m_fWithLabels(fWithLabels)
     58    , m_pLabelPolicy(0)
     59    , m_pComboPolicy(0)
     60    , m_pLabelMaxWidth(0)
     61    , m_pSpinboxMaxWidth(0)
     62    , m_pLabelMaxHeight(0)
     63    , m_pSpinboxMaxHeight(0)
    3964{
    4065    prepare();
    4166}
    4267
    43 void UIAudioControllerEditor::setValue(KAudioControllerType enmValue)
    44 {
    45     if (m_pCombo)
    46     {
    47         /* Update cached value and
    48          * combo if value has changed: */
    49         if (m_enmValue != enmValue)
    50         {
    51             m_enmValue = enmValue;
    52             populateCombo();
    53         }
    54 
    55         /* Look for proper index to choose: */
    56         int iIndex = m_pCombo->findData(QVariant::fromValue(m_enmValue));
     68QWidget *UIMaximumGuestScreenSizeEditor::focusProxy1() const
     69{
     70    return m_pComboPolicy->focusProxy();
     71}
     72
     73QWidget *UIMaximumGuestScreenSizeEditor::focusProxy2() const
     74{
     75    return m_pSpinboxMaxWidth;
     76}
     77
     78QWidget *UIMaximumGuestScreenSizeEditor::focusProxy3() const
     79{
     80    return m_pSpinboxMaxHeight;
     81}
     82
     83void UIMaximumGuestScreenSizeEditor::setValue(const UIMaximumGuestScreenSizeValue &guiValue)
     84{
     85    /* Update cached value if value has changed: */
     86    if (m_guiValue != guiValue)
     87        m_guiValue = guiValue;
     88
     89    /* Look for proper policy index to choose: */
     90    if (m_pComboPolicy)
     91    {
     92        const int iIndex = m_pComboPolicy->findData(QVariant::fromValue(guiValue.m_enmPolicy));
    5793        if (iIndex != -1)
    58             m_pCombo->setCurrentIndex(iIndex);
    59     }
    60 }
    61 
    62 KAudioControllerType UIAudioControllerEditor::value() const
    63 {
    64     return m_pCombo ? m_pCombo->currentData().value<KAudioControllerType>() : m_enmValue;
    65 }
    66 
    67 void UIAudioControllerEditor::retranslateUi()
    68 {
    69     if (m_pLabel)
    70         m_pLabel->setText(tr("Audio &Controller:"));
    71     if (m_pCombo)
    72     {
    73         for (int i = 0; i < m_pCombo->count(); ++i)
    74         {
    75             const KAudioControllerType enmType = m_pCombo->itemData(i).value<KAudioControllerType>();
    76             m_pCombo->setItemText(i, gpConverter->toString(enmType));
    77         }
    78     }
    79 }
    80 
    81 void UIAudioControllerEditor::sltHandleCurrentIndexChanged()
    82 {
    83     if (m_pCombo)
    84         emit sigValueChanged(m_pCombo->itemData(m_pCombo->currentIndex()).value<KAudioControllerType>());
    85 }
    86 
    87 void UIAudioControllerEditor::prepare()
     94        {
     95            m_pComboPolicy->setCurrentIndex(iIndex);
     96            sltHandleCurrentPolicyIndexChanged();
     97        }
     98    }
     99    /* Load size as well: */
     100    if (m_pSpinboxMaxWidth && m_pSpinboxMaxHeight)
     101    {
     102        if (guiValue.m_enmPolicy == MaximumGuestScreenSizePolicy_Fixed)
     103        {
     104            m_pSpinboxMaxWidth->setValue(guiValue.m_size.width());
     105            m_pSpinboxMaxHeight->setValue(guiValue.m_size.height());
     106        }
     107    }
     108}
     109
     110UIMaximumGuestScreenSizeValue UIMaximumGuestScreenSizeEditor::value() const
     111{
     112    return   m_pComboPolicy && m_pSpinboxMaxWidth && m_pSpinboxMaxHeight
     113           ? UIMaximumGuestScreenSizeValue(m_pComboPolicy->currentData().value<MaximumGuestScreenSizePolicy>(),
     114                                           QSize(m_pSpinboxMaxWidth->value(), m_pSpinboxMaxHeight->value()))
     115           : m_guiValue;
     116}
     117
     118void UIMaximumGuestScreenSizeEditor::retranslateUi()
     119{
     120    if (m_pLabelPolicy)
     121        m_pLabelPolicy->setText(tr("Maximum Guest Screen &Size:"));
     122    if (m_pLabelMaxWidth)
     123        m_pLabelMaxWidth->setText(tr("&Width:"));
     124    if (m_pSpinboxMaxWidth)
     125        m_pSpinboxMaxWidth->setWhatsThis(tr("Holds the maximum width which we would like the guest to use."));
     126    if (m_pLabelMaxHeight)
     127        m_pLabelMaxHeight->setText(tr("&Height:"));
     128    if (m_pSpinboxMaxHeight)
     129        m_pSpinboxMaxHeight->setWhatsThis(tr("Holds the maximum height which we would like the guest to use."));
     130
     131    if (m_pComboPolicy)
     132    {
     133        for (int i = 0; i < m_pComboPolicy->count(); ++i)
     134        {
     135            const MaximumGuestScreenSizePolicy enmType = m_pComboPolicy->itemData(i).value<MaximumGuestScreenSizePolicy>();
     136            m_pComboPolicy->setItemText(i, gpConverter->toString(enmType));
     137            switch (enmType)
     138            {
     139                case MaximumGuestScreenSizePolicy_Automatic:
     140                    m_pComboPolicy->setItemData(i,
     141                                                tr("Suggest a reasonable maximum screen size to the guest. The guest "
     142                                                   "will only see this suggestion when guest additions are installed."),
     143                                                Qt::ToolTipRole);
     144                    break;
     145                case MaximumGuestScreenSizePolicy_Any:
     146                    m_pComboPolicy->setItemData(i,
     147                                                tr("Do not attempt to limit the size of the guest screen."),
     148                                                Qt::ToolTipRole);
     149                    break;
     150                case MaximumGuestScreenSizePolicy_Fixed:
     151                    m_pComboPolicy->setItemData(i,
     152                                                tr("Suggest a maximum screen size to the guest. The guest will only see "
     153                                                   "this suggestion when guest additions are installed."),
     154                                                Qt::ToolTipRole);
     155                    break;
     156            }
     157        }
     158    }
     159}
     160
     161void UIMaximumGuestScreenSizeEditor::sltHandleCurrentPolicyIndexChanged()
     162{
     163    if (m_pComboPolicy)
     164    {
     165        /* Get current size-combo tool-tip data: */
     166        const QString strCurrentComboItemTip = m_pComboPolicy->currentData(Qt::ToolTipRole).toString();
     167        m_pComboPolicy->setWhatsThis(strCurrentComboItemTip);
     168
     169        /* Get current size-combo item data: */
     170        const MaximumGuestScreenSizePolicy enmPolicy = m_pComboPolicy->currentData().value<MaximumGuestScreenSizePolicy>();
     171        /* Should be combo-level widgets enabled? */
     172        const bool fComboLevelWidgetsEnabled = enmPolicy == MaximumGuestScreenSizePolicy_Fixed;
     173        /* Enable/disable combo-level widgets: */
     174        if (m_pLabelMaxWidth)
     175            m_pLabelMaxWidth->setEnabled(fComboLevelWidgetsEnabled);
     176        if (m_pSpinboxMaxWidth)
     177            m_pSpinboxMaxWidth->setEnabled(fComboLevelWidgetsEnabled);
     178        if (m_pLabelMaxHeight)
     179            m_pLabelMaxHeight->setEnabled(fComboLevelWidgetsEnabled);
     180        if (m_pSpinboxMaxHeight)
     181            m_pSpinboxMaxHeight->setEnabled(fComboLevelWidgetsEnabled);
     182
     183        /* Notify listeners: */
     184        emit sigValueChanged(value());
     185    }
     186}
     187
     188void UIMaximumGuestScreenSizeEditor::sltHandleSizeChanged()
     189{
     190    if (m_pSpinboxMaxWidth && m_pSpinboxMaxHeight)
     191    {
     192        /* Notify listeners: */
     193        emit sigValueChanged(value());
     194    }
     195}
     196
     197void UIMaximumGuestScreenSizeEditor::prepare()
    88198{
    89199    /* Create main layout: */
    90     QGridLayout *pMainLayout = new QGridLayout(this);
    91     if (pMainLayout)
    92     {
    93         pMainLayout->setContentsMargins(0, 0, 0, 0);
    94         int iRow = 0;
    95 
    96         /* Create label: */
    97         if (m_fWithLabel)
    98             m_pLabel = new QLabel(this);
    99         if (m_pLabel)
    100             pMainLayout->addWidget(m_pLabel, 0, iRow++, 1, 1);
    101 
    102         /* Create combo layout: */
    103         QHBoxLayout *pComboLayout = new QHBoxLayout;
    104         if (pComboLayout)
    105         {
    106             /* Create combo: */
    107             m_pCombo = new QIComboBox(this);
    108             if (m_pCombo)
     200    QGridLayout *pLayoutMain = new QGridLayout(this);
     201    if (pLayoutMain)
     202    {
     203        pLayoutMain->setContentsMargins(0, 0, 0, 0);
     204
     205        const int iMinWidth = 640;
     206        const int iMinHeight = 480;
     207        const int iMaxSize = 16 * _1K;
     208
     209        int iColumn = 0;
     210        if (m_fWithLabels)
     211        {
     212            /* Prepare policy label: */
     213            m_pLabelPolicy = new QLabel(this);
     214            if (m_pLabelPolicy)
    109215            {
    110                 setFocusProxy(m_pCombo->focusProxy());
    111                 /* This is necessary since contents is dynamical now: */
    112                 m_pCombo->setSizeAdjustPolicy(QComboBox::AdjustToContents);
    113                 if (m_pLabel)
    114                     m_pLabel->setBuddy(m_pCombo->focusProxy());
    115                 connect(m_pCombo, static_cast<void(QIComboBox::*)(int)>(&QIComboBox::currentIndexChanged),
    116                         this, &UIAudioControllerEditor::sltHandleCurrentIndexChanged);
    117                 pComboLayout->addWidget(m_pCombo);
     216               m_pLabelPolicy->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     217               pLayoutMain->addWidget(m_pLabelPolicy, 0, iColumn++);
    118218            }
    119 
    120             /* Add stretch: */
    121             pComboLayout->addStretch();
    122 
    123             /* Add combo-layout into main-layout: */
    124             pMainLayout->addLayout(pComboLayout, 0, iRow++, 1, 1);
     219        }
     220        /* Prepare policy combo: */
     221        m_pComboPolicy = new QIComboBox(this);
     222        if (m_pComboPolicy)
     223        {
     224            if (m_pLabelPolicy)
     225                m_pLabelPolicy->setBuddy(m_pComboPolicy);
     226            connect(m_pComboPolicy, static_cast<void(QIComboBox::*)(int)>(&QIComboBox::activated),
     227                    this, &UIMaximumGuestScreenSizeEditor::sltHandleCurrentPolicyIndexChanged);
     228
     229            pLayoutMain->addWidget(m_pComboPolicy, 0, iColumn++);
     230        }
     231
     232        iColumn = 0;
     233        if (m_fWithLabels)
     234        {
     235            /* Prepare max width label: */
     236            m_pLabelMaxWidth = new QLabel(this);
     237            if (m_pLabelMaxWidth)
     238            {
     239                m_pLabelMaxWidth->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     240                pLayoutMain->addWidget(m_pLabelMaxWidth, 1, iColumn++);
     241            }
     242        }
     243        /* Prepare max width spinbox: */
     244        m_pSpinboxMaxWidth = new QSpinBox(this);
     245        if (m_pSpinboxMaxWidth)
     246        {
     247            if (m_pLabelMaxWidth)
     248                m_pLabelMaxWidth->setBuddy(m_pSpinboxMaxWidth);
     249            m_pSpinboxMaxWidth->setMinimum(iMinWidth);
     250            m_pSpinboxMaxWidth->setMaximum(iMaxSize);
     251            connect(m_pSpinboxMaxWidth, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged),
     252                    this, &UIMaximumGuestScreenSizeEditor::sltHandleSizeChanged);
     253
     254            pLayoutMain->addWidget(m_pSpinboxMaxWidth, 1, iColumn++);
     255        }
     256
     257        iColumn = 0;
     258        if (m_fWithLabels)
     259        {
     260            /* Prepare max height label: */
     261            m_pLabelMaxHeight = new QLabel(this);
     262            if (m_pLabelMaxHeight)
     263            {
     264                m_pLabelMaxHeight->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     265                pLayoutMain->addWidget(m_pLabelMaxHeight, 2, iColumn++);
     266            }
     267        }
     268        /* Prepare max width spinbox: */
     269        m_pSpinboxMaxHeight = new QSpinBox(this);
     270        if (m_pSpinboxMaxHeight)
     271        {
     272            if (m_pLabelMaxHeight)
     273                m_pLabelMaxHeight->setBuddy(m_pSpinboxMaxHeight);
     274            m_pSpinboxMaxHeight->setMinimum(iMinHeight);
     275            m_pSpinboxMaxHeight->setMaximum(iMaxSize);
     276            connect(m_pSpinboxMaxHeight, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged),
     277                    this, &UIMaximumGuestScreenSizeEditor::sltHandleSizeChanged);
     278
     279            pLayoutMain->addWidget(m_pSpinboxMaxHeight, 2, iColumn++);
    125280        }
    126281    }
     
    133288}
    134289
    135 void UIAudioControllerEditor::populateCombo()
    136 {
    137     if (m_pCombo)
     290void UIMaximumGuestScreenSizeEditor::populateCombo()
     291{
     292    if (m_pComboPolicy)
    138293    {
    139294        /* Clear combo first of all: */
    140         m_pCombo->clear();
    141 
    142         /* Load currently supported audio driver types: */
    143         CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties();
    144         m_supportedValues = comProperties.GetSupportedAudioControllerTypes();
    145 
    146         /* Make sure requested value if sane is present as well: */
    147         if (   m_enmValue != KAudioControllerType_Max
    148             && !m_supportedValues.contains(m_enmValue))
    149             m_supportedValues.prepend(m_enmValue);
     295        m_pComboPolicy->clear();
     296
     297        /* Init currently supported maximum guest size policy types: */
     298        QList<MaximumGuestScreenSizePolicy> supportedValues = QList<MaximumGuestScreenSizePolicy>()
     299                                                          << MaximumGuestScreenSizePolicy_Automatic
     300                                                          << MaximumGuestScreenSizePolicy_Any
     301                                                          << MaximumGuestScreenSizePolicy_Fixed;
    150302
    151303        /* Update combo with all the supported values: */
    152         foreach (const KAudioControllerType &enmType, m_supportedValues)
    153             m_pCombo->addItem(QString(), QVariant::fromValue(enmType));
     304        foreach (const MaximumGuestScreenSizePolicy &enmType, supportedValues)
     305            m_pComboPolicy->addItem(QString(), QVariant::fromValue(enmType));
    154306
    155307        /* Retranslate finally: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIMaximumGuestScreenSizeEditor.h

    r86910 r86978  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIAudioControllerEditor class declaration.
     3 * VBox Qt GUI - UIMaximumGuestScreenSizeEditor class declaration.
    44 */
    55
     
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_settings_editors_UIAudioControllerEditor_h
    19 #define FEQT_INCLUDED_SRC_settings_editors_UIAudioControllerEditor_h
     18#ifndef FEQT_INCLUDED_SRC_settings_editors_UIMaximumGuestScreenSizeEditor_h
     19#define FEQT_INCLUDED_SRC_settings_editors_UIMaximumGuestScreenSizeEditor_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
     
    2727/* GUI includes: */
    2828#include "QIWithRetranslateUI.h"
     29#include "UIExtraDataDefs.h"
    2930#include "UILibraryDefs.h"
    30 
    31 /* COM includes: */
    32 #include "COMEnums.h"
    3331
    3432/* Forward declarations: */
    3533class QLabel;
     34class QSpinBox;
    3635class QIComboBox;
    3736
    38 /** QWidget subclass used as an audio controller editor. */
    39 class SHARED_LIBRARY_STUFF UIAudioControllerEditor : public QIWithRetranslateUI<QWidget>
     37
     38/** Maximum guest screen size value. */
     39struct SHARED_LIBRARY_STUFF UIMaximumGuestScreenSizeValue
     40{
     41    /** Constructs maximum guest screen size value. */
     42    UIMaximumGuestScreenSizeValue(MaximumGuestScreenSizePolicy enmPolicy = MaximumGuestScreenSizePolicy_Any,
     43                                  const QSize &resolution = QSize());
     44
     45    /** Returns whether the @a other passed data is equal to this one. */
     46    bool equal(const UIMaximumGuestScreenSizeValue &other) const;
     47    /** Returns whether the @a other passed data is equal to this one. */
     48    bool operator==(const UIMaximumGuestScreenSizeValue &other) const { return equal(other); }
     49    /** Returns whether the @a other passed data is different from this one. */
     50    bool operator!=(const UIMaximumGuestScreenSizeValue &other) const { return !equal(other); }
     51
     52    /** Holds the maximum guest-screen policy. */
     53    MaximumGuestScreenSizePolicy  m_enmPolicy;
     54    /** Holds the maximum guest-screen size. */
     55    QSize                         m_size;
     56};
     57Q_DECLARE_METATYPE(UIMaximumGuestScreenSizeValue);
     58
     59
     60/** QWidget subclass used as a maximum guest screen size editor. */
     61class SHARED_LIBRARY_STUFF UIMaximumGuestScreenSizeEditor : public QIWithRetranslateUI<QWidget>
    4062{
    4163    Q_OBJECT;
     
    4365signals:
    4466
    45     /** Notifies listeners about @a enmValue change. */
    46     void sigValueChanged(KAudioControllerType enmValue);
     67    /** Notifies listeners about @a guiValue change. */
     68    void sigValueChanged(const UIMaximumGuestScreenSizeValue &guiValue);
    4769
    4870public:
    4971
    50     /** Constructs audio controller editor passing @a pParent to the base-class.
    51       * @param  fWithLabel  Brings whether we should add label ourselves. */
    52     UIAudioControllerEditor(QWidget *pParent = 0, bool fWithLabel = false);
     72    /** Constructs maximum guest screen size editor passing @a pParent to the base-class.
     73      * @param  fWithLabels  Brings whether we should add labels ourselves. */
     74    UIMaximumGuestScreenSizeEditor(QWidget *pParent = 0, bool fWithLabels = false);
    5375
    54     /** Defines editor @a enmValue. */
    55     void setValue(KAudioControllerType enmValue);
     76    /** Returns focus proxy 1. */
     77    QWidget *focusProxy1() const;
     78    /** Returns focus proxy 2. */
     79    QWidget *focusProxy2() const;
     80    /** Returns focus proxy 3. */
     81    QWidget *focusProxy3() const;
     82
     83    /** Defines editor @a guiValue. */
     84    void setValue(const UIMaximumGuestScreenSizeValue &guiValue);
    5685    /** Returns editor value. */
    57     KAudioControllerType value() const;
    58 
    59     /** Returns the vector of supported values. */
    60     QVector<KAudioControllerType> supportedValues() const { return m_supportedValues; }
     86    UIMaximumGuestScreenSizeValue value() const;
    6187
    6288protected:
     
    6793private slots:
    6894
    69     /** Handles current index change. */
    70     void sltHandleCurrentIndexChanged();
     95    /** Handles current policy index change. */
     96    void sltHandleCurrentPolicyIndexChanged();
     97    /** Handles size change. */
     98    void sltHandleSizeChanged();
    7199
    72100private:
     
    77105    void populateCombo();
    78106
    79     /** Holds whether descriptive label should be created. */
    80     bool  m_fWithLabel;
     107    /** Holds whether descriptive labels should be created. */
     108    bool  m_fWithLabels;
    81109
    82110    /** Holds the value to be selected. */
    83     KAudioControllerType  m_enmValue;
     111    UIMaximumGuestScreenSizeValue  m_guiValue;
    84112
    85     /** Holds the vector of supported values. */
    86     QVector<KAudioControllerType>  m_supportedValues;
    87 
    88     /** Holds the label instance. */
    89     QLabel     *m_pLabel;
    90     /** Holds the combo instance. */
    91     QIComboBox *m_pCombo;
     113    /** Holds the policy label instance. */
     114    QLabel     *m_pLabelPolicy;
     115    /** Holds the policy combo instance. */
     116    QIComboBox *m_pComboPolicy;
     117    /** Holds the max width label instance. */
     118    QLabel     *m_pLabelMaxWidth;
     119    /** Holds the max width spinbox instance. */
     120    QSpinBox   *m_pSpinboxMaxWidth;
     121    /** Holds the max height label instance. */
     122    QLabel     *m_pLabelMaxHeight;
     123    /** Holds the max height spinbox instance. */
     124    QSpinBox   *m_pSpinboxMaxHeight;
    92125};
    93126
    94 #endif /* !FEQT_INCLUDED_SRC_settings_editors_UIAudioControllerEditor_h */
     127
     128#endif /* !FEQT_INCLUDED_SRC_settings_editors_UIMaximumGuestScreenSizeEditor_h */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsDisplay.cpp

    r86977 r86978  
    1818/* Qt includes: */
    1919#include <QCheckBox>
    20 #include <QComboBox>
    2120#include <QGridLayout>
    2221#include <QLabel>
    23 #include <QSpacerItem>
    24 #include <QSpinBox>
    2522
    2623/* GUI includes: */
     
    2825#include "UIExtraDataManager.h"
    2926#include "UIGlobalSettingsDisplay.h"
     27#include "UIMaximumGuestScreenSizeEditor.h"
    3028#include "UIMessageCenter.h"
    3129#include "UIScaleFactorEditor.h"
    3230
     31
    3332/** Global settings: Display page data structure. */
    3433struct UIDataSettingsGlobalDisplay
     
    3635    /** Constructs data. */
    3736    UIDataSettingsGlobalDisplay()
    38         : m_enmMaximumGuestScreenSizePolicy(MaximumGuestScreenSizePolicy_Automatic)
    39         , m_maximumGuestScreenSize(QSize())
    40         , m_fActivateHoveredMachineWindow(false)
     37        : m_fActivateHoveredMachineWindow(false)
    4138    {}
    4239
     
    4542    {
    4643        return true
    47                && (m_enmMaximumGuestScreenSizePolicy == other.m_enmMaximumGuestScreenSizePolicy)
    48                && (m_maximumGuestScreenSize == other.m_maximumGuestScreenSize)
     44               && (m_guiMaximumGuestScreenSizeValue == other.m_guiMaximumGuestScreenSizeValue)
    4945               && (m_fActivateHoveredMachineWindow == other.m_fActivateHoveredMachineWindow)
    5046               && (m_scaleFactors == other.m_scaleFactors)
     
    5753    bool operator!=(const UIDataSettingsGlobalDisplay &other) const { return !equal(other); }
    5854
    59     /** Holds the maximum guest-screen size policy. */
    60     MaximumGuestScreenSizePolicy m_enmMaximumGuestScreenSizePolicy;
    61     /** Holds the maximum guest-screen size. */
    62     QSize m_maximumGuestScreenSize;
     55    /** Holds the maximum guest-screen size value. */
     56    UIMaximumGuestScreenSizeValue  m_guiMaximumGuestScreenSizeValue;
    6357    /** Holds whether we should automatically activate machine window under the mouse cursor. */
    64     bool m_fActivateHoveredMachineWindow;
     58    bool                           m_fActivateHoveredMachineWindow;
    6559    /** Holds the guest screen scale-factor. */
    66     QList<double> m_scaleFactors;
     60    QList<double>                  m_scaleFactors;
    6761};
    6862
     
    7064UIGlobalSettingsDisplay::UIGlobalSettingsDisplay()
    7165    : m_pCache(0)
    72     , m_pLabelMaxGuestScreenSize(0)
    73     , m_pComboMaxGuestScreenSize(0)
    74     , m_pLabelMaxGuestScreenWidth(0)
    75     , m_pSpinboxMaxGuestScreenWidth(0)
    76     , m_pLabelMaxGuestScreenHeight(0)
    77     , m_pSpinboxMaxGuestScreenHeight(0)
     66    , m_pLabelMaximumGuestScreenSizePolicy(0)
     67    , m_pLabelMaximumGuestScreenWidth(0)
     68    , m_pLabelMaximumGuestScreenHeight(0)
     69    , m_pEditorMaximumGuestScreenSize(0)
    7870    , m_pLabelScaleFactor(0)
    7971    , m_pEditorScaleFactor(0)
     
    8173    , m_pCheckBoxActivateOnMouseHover(0)
    8274{
    83     /* Prepare: */
    8475    prepare();
    8576}
     
    8778UIGlobalSettingsDisplay::~UIGlobalSettingsDisplay()
    8879{
    89     /* Cleanup: */
    9080    cleanup();
    9181}
     
    9989    m_pCache->clear();
    10090
    101     /* Prepare old display data: */
    102     UIDataSettingsGlobalDisplay oldDisplayData;
    103 
    104     /* Gather old display data: */
    105     oldDisplayData.m_enmMaximumGuestScreenSizePolicy = gEDataManager->maxGuestResolutionPolicy();
    106     if (oldDisplayData.m_enmMaximumGuestScreenSizePolicy == MaximumGuestScreenSizePolicy_Fixed)
    107         oldDisplayData.m_maximumGuestScreenSize = gEDataManager->maxGuestResolutionForPolicyFixed();
    108     oldDisplayData.m_fActivateHoveredMachineWindow = gEDataManager->activateHoveredMachineWindow();
    109     oldDisplayData.m_scaleFactors = gEDataManager->scaleFactors(UIExtraDataManager::GlobalID);
    110 
    111     /* Cache old display data: */
    112     m_pCache->cacheInitialData(oldDisplayData);
     91    /* Cache old data: */
     92    UIDataSettingsGlobalDisplay oldData;
     93    oldData.m_guiMaximumGuestScreenSizeValue = UIMaximumGuestScreenSizeValue(gEDataManager->maxGuestResolutionPolicy(),
     94                                                                             gEDataManager->maxGuestResolutionForPolicyFixed());
     95    oldData.m_fActivateHoveredMachineWindow = gEDataManager->activateHoveredMachineWindow();
     96    oldData.m_scaleFactors = gEDataManager->scaleFactors(UIExtraDataManager::GlobalID);
     97    m_pCache->cacheInitialData(oldData);
    11398
    11499    /* Upload properties to data: */
     
    118103void UIGlobalSettingsDisplay::getFromCache()
    119104{
    120     /* Get old display data from the cache: */
    121     const UIDataSettingsGlobalDisplay &oldDisplayData = m_pCache->base();
    122 
    123     /* Load old display data from the cache: */
    124     m_pComboMaxGuestScreenSize->setCurrentIndex(m_pComboMaxGuestScreenSize->findData((int)oldDisplayData.m_enmMaximumGuestScreenSizePolicy));
    125     if (oldDisplayData.m_enmMaximumGuestScreenSizePolicy == MaximumGuestScreenSizePolicy_Fixed)
    126     {
    127         m_pSpinboxMaxGuestScreenWidth->setValue(oldDisplayData.m_maximumGuestScreenSize.width());
    128         m_pSpinboxMaxGuestScreenHeight->setValue(oldDisplayData.m_maximumGuestScreenSize.height());
    129     }
    130     m_pCheckBoxActivateOnMouseHover->setChecked(oldDisplayData.m_fActivateHoveredMachineWindow);
    131     m_pEditorScaleFactor->setScaleFactors(oldDisplayData.m_scaleFactors);
     105    /* Load old data from cache: */
     106    const UIDataSettingsGlobalDisplay &oldData = m_pCache->base();
     107    m_pEditorMaximumGuestScreenSize->setValue(oldData.m_guiMaximumGuestScreenSizeValue);
     108    m_pCheckBoxActivateOnMouseHover->setChecked(oldData.m_fActivateHoveredMachineWindow);
     109    m_pEditorScaleFactor->setScaleFactors(oldData.m_scaleFactors);
    132110    m_pEditorScaleFactor->setMonitorCount(gpDesktop->screenCount());
    133111}
     
    135113void UIGlobalSettingsDisplay::putToCache()
    136114{
    137     /* Prepare new display data: */
    138     UIDataSettingsGlobalDisplay newDisplayData = m_pCache->base();
    139 
    140     /* Gather new display data: */
    141     newDisplayData.m_enmMaximumGuestScreenSizePolicy = (MaximumGuestScreenSizePolicy)m_pComboMaxGuestScreenSize->itemData(m_pComboMaxGuestScreenSize->currentIndex()).toInt();
    142     if (newDisplayData.m_enmMaximumGuestScreenSizePolicy == MaximumGuestScreenSizePolicy_Fixed)
    143         newDisplayData.m_maximumGuestScreenSize = QSize(m_pSpinboxMaxGuestScreenWidth->value(), m_pSpinboxMaxGuestScreenHeight->value());
    144     newDisplayData.m_fActivateHoveredMachineWindow = m_pCheckBoxActivateOnMouseHover->isChecked();
    145     newDisplayData.m_scaleFactors = m_pEditorScaleFactor->scaleFactors();
    146 
    147     /* Cache new display data: */
    148     m_pCache->cacheCurrentData(newDisplayData);
     115    /* Prepare new data: */
     116    UIDataSettingsGlobalDisplay newData = m_pCache->base();
     117
     118    /* Cache new data: */
     119    newData.m_guiMaximumGuestScreenSizeValue = m_pEditorMaximumGuestScreenSize->value();
     120    newData.m_fActivateHoveredMachineWindow = m_pCheckBoxActivateOnMouseHover->isChecked();
     121    newData.m_scaleFactors = m_pEditorScaleFactor->scaleFactors();
     122    m_pCache->cacheCurrentData(newData);
    149123}
    150124
     
    154128    UISettingsPageGlobal::fetchData(data);
    155129
    156     /* Update display data and failing state: */
     130    /* Update data and failing state: */
    157131    setFailed(!saveDisplayData());
    158132
     
    163137void UIGlobalSettingsDisplay::retranslateUi()
    164138{
    165     m_pLabelMaxGuestScreenSize->setText(tr("Maximum Guest Screen &Size:"));
    166     m_pLabelMaxGuestScreenWidth->setText(tr("&Width:"));
    167     m_pSpinboxMaxGuestScreenWidth->setWhatsThis(tr("Holds the maximum width which we would like the guest to use."));
    168     m_pLabelMaxGuestScreenHeight->setText(tr("&Height:"));
    169     m_pSpinboxMaxGuestScreenHeight->setWhatsThis(tr("Holds the maximum height which we would like the guest to use."));
    170     m_pLabelScaleFactor->setText(tr("Scale Factor:"));
     139    m_pLabelMaximumGuestScreenSizePolicy->setText(tr("Maximum Guest Screen &Size:"));
     140    m_pLabelMaximumGuestScreenWidth->setText(tr("&Width:"));
     141    m_pLabelMaximumGuestScreenHeight->setText(tr("&Height:"));
     142    m_pLabelScaleFactor->setText(tr("Scale &Factor:"));
    171143    m_pEditorScaleFactor->setWhatsThis(tr("Controls the guest screen scale factor."));
    172144    m_pLabelMachineWindows->setText(tr("Machine Windows:"));
    173145    m_pCheckBoxActivateOnMouseHover->setWhatsThis(tr("When checked, machine windows will be raised when the mouse pointer moves over them."));
    174146    m_pCheckBoxActivateOnMouseHover->setText(tr("&Raise Window Under Mouse"));
    175 
    176     /* Reload combo-box: */
    177     reloadMaximumGuestScreenSizePolicyComboBox();
    178 }
    179 
    180 void UIGlobalSettingsDisplay::sltHandleMaximumGuestScreenSizePolicyChange()
    181 {
    182     /* Get current size-combo tool-tip data: */
    183     const QString strCurrentComboItemTip = m_pComboMaxGuestScreenSize->itemData(m_pComboMaxGuestScreenSize->currentIndex(), Qt::ToolTipRole).toString();
    184     m_pComboMaxGuestScreenSize->setWhatsThis(strCurrentComboItemTip);
    185 
    186     /* Get current size-combo item data: */
    187     const MaximumGuestScreenSizePolicy enmPolicy = (MaximumGuestScreenSizePolicy)m_pComboMaxGuestScreenSize->itemData(m_pComboMaxGuestScreenSize->currentIndex()).toInt();
    188     /* Should be combo-level widgets enabled? */
    189     const bool fComboLevelWidgetsEnabled = enmPolicy == MaximumGuestScreenSizePolicy_Fixed;
    190     /* Enable/disable combo-level widgets: */
    191     m_pLabelMaxGuestScreenWidth->setEnabled(fComboLevelWidgetsEnabled);
    192     m_pSpinboxMaxGuestScreenWidth->setEnabled(fComboLevelWidgetsEnabled);
    193     m_pLabelMaxGuestScreenHeight->setEnabled(fComboLevelWidgetsEnabled);
    194     m_pSpinboxMaxGuestScreenHeight->setEnabled(fComboLevelWidgetsEnabled);
    195147}
    196148
     
    203155    /* Prepare everything: */
    204156    prepareWidgets();
    205     prepareConnections();
    206157
    207158    /* Apply language settings: */
     
    218169        pLayoutMain->setRowStretch(6, 1);
    219170
    220         const int iMinWidth = 640;
    221         const int iMinHeight = 480;
    222         const int iMaxSize = 16 * _1K;
    223 
    224         /* Prepare max guest screen size label: */
    225         m_pLabelMaxGuestScreenSize = new QLabel(this);
    226         if (m_pLabelMaxGuestScreenSize)
    227         {
    228            m_pLabelMaxGuestScreenSize->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    229            pLayoutMain->addWidget(m_pLabelMaxGuestScreenSize, 0, 0);
    230         }
    231         /* Prepare max guest screen size combo: */
    232         m_pComboMaxGuestScreenSize = new QComboBox(this);
    233         if (m_pComboMaxGuestScreenSize)
    234         {
    235             if (m_pLabelMaxGuestScreenSize)
    236                 m_pLabelMaxGuestScreenSize->setBuddy(m_pComboMaxGuestScreenSize);
    237             pLayoutMain->addWidget(m_pComboMaxGuestScreenSize, 0, 1, 1, 2);
    238         }
    239 
    240         /* Prepare max guest screen width label: */
    241         m_pLabelMaxGuestScreenWidth = new QLabel(this);
    242         if (m_pLabelMaxGuestScreenWidth)
    243         {
    244             m_pLabelMaxGuestScreenWidth->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    245             pLayoutMain->addWidget(m_pLabelMaxGuestScreenWidth, 1, 0);
    246         }
    247         /* Prepare max guest screen width spinbox: */
    248         m_pSpinboxMaxGuestScreenWidth = new QSpinBox(this);
    249         if (m_pSpinboxMaxGuestScreenWidth)
    250         {
    251             if (m_pLabelMaxGuestScreenWidth)
    252                 m_pLabelMaxGuestScreenWidth->setBuddy(m_pSpinboxMaxGuestScreenWidth);
    253             m_pSpinboxMaxGuestScreenWidth->setMinimum(iMinWidth);
    254             m_pSpinboxMaxGuestScreenWidth->setMaximum(iMaxSize);
    255 
    256             pLayoutMain->addWidget(m_pSpinboxMaxGuestScreenWidth, 1, 1, 1, 2);
    257         }
    258 
    259         /* Prepare max guest screen height label: */
    260         m_pLabelMaxGuestScreenHeight = new QLabel(this);
    261         if (m_pLabelMaxGuestScreenHeight)
    262         {
    263             m_pLabelMaxGuestScreenHeight->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    264             pLayoutMain->addWidget(m_pLabelMaxGuestScreenHeight, 2, 0);
    265         }
    266         /* Prepare max guest screen width spinbox: */
    267         m_pSpinboxMaxGuestScreenHeight = new QSpinBox(this);
    268         if (m_pSpinboxMaxGuestScreenHeight)
    269         {
    270             if (m_pLabelMaxGuestScreenHeight)
    271                 m_pLabelMaxGuestScreenHeight->setBuddy(m_pSpinboxMaxGuestScreenHeight);
    272             m_pSpinboxMaxGuestScreenHeight->setMinimum(iMinHeight);
    273             m_pSpinboxMaxGuestScreenHeight->setMaximum(iMaxSize);
    274 
    275             pLayoutMain->addWidget(m_pSpinboxMaxGuestScreenHeight, 2, 1, 1, 2);
     171        /* Prepare maximum guest screen size label: */
     172        m_pLabelMaximumGuestScreenSizePolicy = new QLabel(this);
     173        if (m_pLabelMaximumGuestScreenSizePolicy)
     174        {
     175           m_pLabelMaximumGuestScreenSizePolicy->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     176           pLayoutMain->addWidget(m_pLabelMaximumGuestScreenSizePolicy, 0, 0);
     177        }
     178        /* Prepare maximum guest screen width label: */
     179        m_pLabelMaximumGuestScreenWidth = new QLabel(this);
     180        if (m_pLabelMaximumGuestScreenWidth)
     181        {
     182            m_pLabelMaximumGuestScreenWidth->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     183            pLayoutMain->addWidget(m_pLabelMaximumGuestScreenWidth, 1, 0);
     184        }
     185        /* Prepare maximum guest screen height label: */
     186        m_pLabelMaximumGuestScreenHeight = new QLabel(this);
     187        if (m_pLabelMaximumGuestScreenHeight)
     188        {
     189            m_pLabelMaximumGuestScreenHeight->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     190            pLayoutMain->addWidget(m_pLabelMaximumGuestScreenHeight, 2, 0);
     191        }
     192        /* Prepare maximum guest screen size editor: */
     193        m_pEditorMaximumGuestScreenSize = new UIMaximumGuestScreenSizeEditor(this);
     194        if (m_pEditorMaximumGuestScreenSize)
     195        {
     196            if (m_pLabelMaximumGuestScreenSizePolicy)
     197                m_pLabelMaximumGuestScreenSizePolicy->setBuddy(m_pEditorMaximumGuestScreenSize->focusProxy1());
     198            if (m_pLabelMaximumGuestScreenWidth)
     199                m_pLabelMaximumGuestScreenWidth->setBuddy(m_pEditorMaximumGuestScreenSize->focusProxy2());
     200            if (m_pLabelMaximumGuestScreenHeight)
     201                m_pLabelMaximumGuestScreenHeight->setBuddy(m_pEditorMaximumGuestScreenSize->focusProxy3());
     202            pLayoutMain->addWidget(m_pEditorMaximumGuestScreenSize, 0, 1, 3, 2);
    276203        }
    277204
     
    286213        m_pEditorScaleFactor = new UIScaleFactorEditor(this);
    287214        if (m_pEditorScaleFactor)
     215        {
     216            if (m_pLabelScaleFactor)
     217                m_pLabelScaleFactor->setBuddy(m_pEditorScaleFactor->focusProxy());
    288218            pLayoutMain->addWidget(m_pEditorScaleFactor, 3, 1, 2, 2);
     219        }
    289220
    290221        /* Prepare 'machine-windows' label: */
     
    302233}
    303234
    304 void UIGlobalSettingsDisplay::prepareConnections()
    305 {
    306     connect(m_pComboMaxGuestScreenSize, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated),
    307             this, &UIGlobalSettingsDisplay::sltHandleMaximumGuestScreenSizePolicyChange);
    308 }
    309 
    310235void UIGlobalSettingsDisplay::cleanup()
    311236{
     
    315240}
    316241
    317 void UIGlobalSettingsDisplay::reloadMaximumGuestScreenSizePolicyComboBox()
    318 {
    319     /* Remember current position: */
    320     int iCurrentPosition = m_pComboMaxGuestScreenSize->currentIndex();
    321     if (iCurrentPosition == -1)
    322         iCurrentPosition = 0;
    323 
    324     /* Clear combo-box: */
    325     m_pComboMaxGuestScreenSize->clear();
    326 
    327     /* Create corresponding items: */
    328     m_pComboMaxGuestScreenSize->addItem(tr("Automatic", "Maximum Guest Screen Size"),
    329                                    QVariant((int)MaximumGuestScreenSizePolicy_Automatic));
    330     m_pComboMaxGuestScreenSize->setItemData(m_pComboMaxGuestScreenSize->count() - 1,
    331                                        tr("Suggest a reasonable maximum screen size to the guest. "
    332                                           "The guest will only see this suggestion when guest additions are installed."),
    333                                        Qt::ToolTipRole);
    334     m_pComboMaxGuestScreenSize->addItem(tr("None", "Maximum Guest Screen Size"),
    335                                    QVariant((int)MaximumGuestScreenSizePolicy_Any));
    336     m_pComboMaxGuestScreenSize->setItemData(m_pComboMaxGuestScreenSize->count() - 1,
    337                                        tr("Do not attempt to limit the size of the guest screen."),
    338                                        Qt::ToolTipRole);
    339     m_pComboMaxGuestScreenSize->addItem(tr("Hint", "Maximum Guest Screen Size"),
    340                                    QVariant((int)MaximumGuestScreenSizePolicy_Fixed));
    341     m_pComboMaxGuestScreenSize->setItemData(m_pComboMaxGuestScreenSize->count() - 1,
    342                                        tr("Suggest a maximum screen size to the guest. "
    343                                           "The guest will only see this suggestion when guest additions are installed."),
    344                                        Qt::ToolTipRole);
    345 
    346     /* Choose previous position: */
    347     m_pComboMaxGuestScreenSize->setCurrentIndex(iCurrentPosition);
    348     sltHandleMaximumGuestScreenSizePolicyChange();
    349 }
    350 
    351242bool UIGlobalSettingsDisplay::saveDisplayData()
    352243{
    353244    /* Prepare result: */
    354245    bool fSuccess = true;
    355     /* Save display settings from the cache: */
     246    /* Save display settings from cache: */
    356247    if (fSuccess && m_pCache->wasChanged())
    357248    {
    358         /* Get old display data from the cache: */
    359         const UIDataSettingsGlobalDisplay &oldDisplayData = m_pCache->base();
    360         /* Get new display data from the cache: */
    361         const UIDataSettingsGlobalDisplay &newDisplayData = m_pCache->data();
    362 
    363         /* Save maximum guest resolution policy and/or value: */
    364         if (   fSuccess
    365             && (   newDisplayData.m_enmMaximumGuestScreenSizePolicy != oldDisplayData.m_enmMaximumGuestScreenSizePolicy
    366                 || newDisplayData.m_maximumGuestScreenSize != oldDisplayData.m_maximumGuestScreenSize))
    367             gEDataManager->setMaxGuestScreenResolution(newDisplayData.m_enmMaximumGuestScreenSizePolicy, newDisplayData.m_maximumGuestScreenSize);
     249        /* Get old data from cache: */
     250        const UIDataSettingsGlobalDisplay &oldData = m_pCache->base();
     251        /* Get new data from cache: */
     252        const UIDataSettingsGlobalDisplay &newData = m_pCache->data();
     253
     254        /* Save maximum guest screen size and policy: */
     255        if (fSuccess && newData.m_guiMaximumGuestScreenSizeValue != oldData.m_guiMaximumGuestScreenSizeValue)
     256            gEDataManager->setMaxGuestScreenResolution(newData.m_guiMaximumGuestScreenSizeValue.m_enmPolicy,
     257                                                       newData.m_guiMaximumGuestScreenSizeValue.m_size);
    368258        /* Save whether hovered machine-window should be activated automatically: */
    369         if (fSuccess && newDisplayData.m_fActivateHoveredMachineWindow != oldDisplayData.m_fActivateHoveredMachineWindow)
    370             gEDataManager->setActivateHoveredMachineWindow(newDisplayData.m_fActivateHoveredMachineWindow);
     259        if (fSuccess && newData.m_fActivateHoveredMachineWindow != oldData.m_fActivateHoveredMachineWindow)
     260            gEDataManager->setActivateHoveredMachineWindow(newData.m_fActivateHoveredMachineWindow);
    371261        /* Save guest-screen scale-factor: */
    372         if (fSuccess && newDisplayData.m_scaleFactors != oldDisplayData.m_scaleFactors)
    373             gEDataManager->setScaleFactors(newDisplayData.m_scaleFactors, UIExtraDataManager::GlobalID);
     262        if (fSuccess && newData.m_scaleFactors != oldData.m_scaleFactors)
     263            gEDataManager->setScaleFactors(newData.m_scaleFactors, UIExtraDataManager::GlobalID);
    374264    }
    375265    /* Return result: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsDisplay.h

    r86095 r86978  
    2727/* Forward declarations: */
    2828class QCheckBox;
    29 class QComboBox;
    3029class QLabel;
    31 class QSpinBox;
     30class UIMaximumGuestScreenSizeEditor;
    3231class UIScaleFactorEditor;
    3332struct UIDataSettingsGlobalDisplay;
     
    4443    UIGlobalSettingsDisplay();
    4544    /** Destructs Display settings page. */
    46     ~UIGlobalSettingsDisplay();
     45    virtual ~UIGlobalSettingsDisplay() /* override */;
    4746
    4847protected:
     
    6564    virtual void retranslateUi() /* override */;
    6665
    67 private slots:
    68 
    69     /** Handles maximum guest-screen size policy change. */
    70     void sltHandleMaximumGuestScreenSizePolicyChange();
    71 
    7266private:
    7367
     
    7670    /** Prepares widgets. */
    7771    void prepareWidgets();
    78     /** Prepares connections. */
    79     void prepareConnections();
    8072    /** Cleanups all. */
    8173    void cleanup();
    8274
    83     /** Reloads maximum guest-screen size policy combo-box. */
    84     void reloadMaximumGuestScreenSizePolicyComboBox();
    85 
    86     /** Saves existing display data from the cache. */
     75    /** Saves existing data from the cache. */
    8776    bool saveDisplayData();
    8877
     
    9281    /** @name Widgets
    9382     * @{ */
    94         /** Holds the max guest screen size label instance. */
    95         QLabel              *m_pLabelMaxGuestScreenSize;
    96         /** Holds the max guest screen size combo instance. */
    97         QComboBox           *m_pComboMaxGuestScreenSize;
    98         /** Holds the max guest screen width label instance. */
    99         QLabel              *m_pLabelMaxGuestScreenWidth;
    100         /** Holds the max guest screen width spinbox instance. */
    101         QSpinBox            *m_pSpinboxMaxGuestScreenWidth;
    102         /** Holds the max guest screen height label instance. */
    103         QLabel              *m_pLabelMaxGuestScreenHeight;
    104         /** Holds the max guest screen height spinbox instance. */
    105         QSpinBox            *m_pSpinboxMaxGuestScreenHeight;
     83        /** Holds the maximum guest screen size label instance. */
     84        QLabel                         *m_pLabelMaximumGuestScreenSizePolicy;
     85        /** Holds the maximum guest screen width label instance. */
     86        QLabel                         *m_pLabelMaximumGuestScreenWidth;
     87        /** Holds the maximum guest screen height label instance. */
     88        QLabel                         *m_pLabelMaximumGuestScreenHeight;
     89        /** Holds the maximum guest screen size editor instance. */
     90        UIMaximumGuestScreenSizeEditor *m_pEditorMaximumGuestScreenSize;
    10691        /** Holds the scale-factor label instance. */
    107         QLabel              *m_pLabelScaleFactor;
     92        QLabel                         *m_pLabelScaleFactor;
    10893        /** Holds the scale-factor editor instance. */
    109         UIScaleFactorEditor *m_pEditorScaleFactor;
     94        UIScaleFactorEditor            *m_pEditorScaleFactor;
    11095        /** Holds the 'machine-windows' label instance. */
    111         QLabel              *m_pLabelMachineWindows;
     96        QLabel                         *m_pLabelMachineWindows;
    11297        /** Holds the 'activate on mouse hover' check-box instance. */
    113         QCheckBox           *m_pCheckBoxActivateOnMouseHover;
     98        QCheckBox                      *m_pCheckBoxActivateOnMouseHover;
    11499    /** @} */
    115100};
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette