VirtualBox

Changeset 94251 in vbox


Ignore:
Timestamp:
Mar 15, 2022 5:55:39 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6899: Global preferences: Reworking Proxy page to increase page accessibility; Moving contents to separate editor.

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

Legend:

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

    r94248 r94251  
    901901        src/settings/editors/UIDefaultMachineFolderEditor.h \
    902902        src/settings/editors/UIGlobalDisplayFeaturesEditor.h \
     903        src/settings/editors/UIGlobalProxyFeaturesEditor.h \
    903904        src/settings/editors/UIGraphicsControllerEditor.h \
    904905        src/settings/editors/UIHostComboEditor.h \
     
    14551456        src/settings/editors/UIDefaultMachineFolderEditor.cpp \
    14561457        src/settings/editors/UIGlobalDisplayFeaturesEditor.cpp \
     1458        src/settings/editors/UIGlobalProxyFeaturesEditor.cpp \
    14571459        src/settings/editors/UIGraphicsControllerEditor.cpp \
    14581460        src/settings/editors/UIHostComboEditor.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIGlobalProxyFeaturesEditor.cpp

    r94248 r94251  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIGlobalDisplayFeaturesEditor class implementation.
     3 * VBox Qt GUI - UIGlobalProxyFeaturesEditor class implementation.
    44 */
    55
     
    1717
    1818/* Qt includes: */
    19 #include <QCheckBox>
     19#include <QButtonGroup>
    2020#include <QGridLayout>
    2121#include <QLabel>
     22#include <QRadioButton>
     23#include <QRegularExpressionValidator>
    2224
    2325/* GUI includes: */
    24 #include "UIGlobalDisplayFeaturesEditor.h"
    25 #ifdef VBOX_WS_X11
    26 # include "VBoxUtils-x11.h"
    27 #endif
    28 
    29 
    30 UIGlobalDisplayFeaturesEditor::UIGlobalDisplayFeaturesEditor(QWidget *pParent /* = 0 */)
     26#include "QILineEdit.h"
     27#include "UIGlobalProxyFeaturesEditor.h"
     28
     29
     30UIGlobalProxyFeaturesEditor::UIGlobalProxyFeaturesEditor(QWidget *pParent /* = 0 */)
    3131    : QIWithRetranslateUI<QWidget>(pParent)
    32     , m_fActivateOnMouseHover(false)
    33     , m_fDisableHostScreenSaver(false)
    34     , m_pLabel(0)
    35     , m_pCheckBoxActivateOnMouseHover(0)
    36     , m_pCheckBoxDisableHostScreenSaver(0)
     32    , m_enmProxyMode(KProxyMode_Max)
     33    , m_pButtonGroup(0)
     34    , m_pRadioButtonProxyAuto(0)
     35    , m_pRadioButtonProxyDisabled(0)
     36    , m_pRadioButtonProxyEnabled(0)
     37    , m_pWidgetSettings(0)
     38    , m_pLabelHost(0)
     39    , m_pEditorHost(0)
    3740{
    3841    prepare();
    3942}
    4043
    41 void UIGlobalDisplayFeaturesEditor::setActivateOnMouseHover(bool fOn)
    42 {
    43     if (m_pCheckBoxActivateOnMouseHover)
    44     {
    45         /* Update cached value and
    46          * check-box if value has changed: */
    47         if (m_fActivateOnMouseHover != fOn)
     44void UIGlobalProxyFeaturesEditor::setProxyMode(KProxyMode enmMode)
     45{
     46    /* Update cached value and
     47     * radio-buttons if value has changed: */
     48    if (m_enmProxyMode != enmMode)
     49    {
     50        m_enmProxyMode = enmMode;
     51        switch (m_enmProxyMode)
    4852        {
    49             m_fActivateOnMouseHover = fOn;
    50             m_pCheckBoxActivateOnMouseHover->setCheckState(fOn ? Qt::Checked : Qt::Unchecked);
     53            case KProxyMode_System:
     54                if (m_pRadioButtonProxyAuto)
     55                    m_pRadioButtonProxyAuto->setChecked(true);
     56                break;
     57            case KProxyMode_NoProxy:
     58                if (m_pRadioButtonProxyDisabled)
     59                    m_pRadioButtonProxyDisabled->setChecked(true);
     60                break;
     61            case KProxyMode_Manual:
     62                if (m_pRadioButtonProxyEnabled)
     63                    m_pRadioButtonProxyEnabled->setChecked(true);
     64                break;
     65            case KProxyMode_Max:
     66                break;
    5167        }
    5268    }
    53 }
    54 
    55 bool UIGlobalDisplayFeaturesEditor::activateOnMouseHover() const
    56 {
    57     return   m_pCheckBoxActivateOnMouseHover
    58            ? m_pCheckBoxActivateOnMouseHover->checkState() == Qt::Checked
    59            : m_fActivateOnMouseHover;
    60 }
    61 
    62 void UIGlobalDisplayFeaturesEditor::setDisableHostScreenSaver(bool fOn)
    63 {
    64     if (m_pCheckBoxDisableHostScreenSaver)
    65     {
    66         /* Update cached value and
    67          * check-box if value has changed: */
    68         if (m_fDisableHostScreenSaver != fOn)
     69
     70    /* Update widgets availability: */
     71    sltHandleProxyModeChanged();
     72}
     73
     74KProxyMode UIGlobalProxyFeaturesEditor::proxyMode() const
     75{
     76    return   m_pRadioButtonProxyEnabled && m_pRadioButtonProxyEnabled->isChecked()
     77           ? KProxyMode_Manual
     78           : m_pRadioButtonProxyDisabled && m_pRadioButtonProxyDisabled->isChecked()
     79           ? KProxyMode_NoProxy
     80           : m_pRadioButtonProxyAuto && m_pRadioButtonProxyAuto->isChecked()
     81           ? KProxyMode_System
     82           : m_enmProxyMode;
     83}
     84
     85void UIGlobalProxyFeaturesEditor::setProxyHost(const QString &strHost)
     86{
     87    /* Update cached value and
     88     * line-edit if value has changed: */
     89    if (m_strProxyHost != strHost)
     90    {
     91        m_strProxyHost = strHost;
     92        if (m_pEditorHost)
     93            m_pEditorHost->setText(m_strProxyHost);
     94    }
     95}
     96
     97QString UIGlobalProxyFeaturesEditor::proxyHost() const
     98{
     99    return m_pEditorHost ? m_pEditorHost->text() : m_strProxyHost;
     100}
     101
     102void UIGlobalProxyFeaturesEditor::retranslateUi()
     103{
     104    /* Translate proxy mode editor: */
     105    if (m_pRadioButtonProxyAuto)
     106    {
     107        m_pRadioButtonProxyAuto->setToolTip(tr("When chosen, VirtualBox will try to auto-detect host proxy settings for tasks "
     108                                               "like downloading Guest Additions from the network or checking for updates."));
     109        m_pRadioButtonProxyAuto->setText(tr("&Auto-detect Host Proxy Settings"));
     110    }
     111    if (m_pRadioButtonProxyDisabled)
     112    {
     113        m_pRadioButtonProxyDisabled->setToolTip(tr("When chosen, VirtualBox will use direct Internet connection for tasks like "
     114                                                   "downloading Guest Additions from the network or checking for updates."));
     115        m_pRadioButtonProxyDisabled->setText(tr("&Direct Connection to the Internet"));
     116    }
     117    if (m_pRadioButtonProxyEnabled)
     118    {
     119        m_pRadioButtonProxyEnabled->setToolTip(tr("When chosen, VirtualBox will use the proxy settings supplied for tasks like "
     120                                                  "downloading Guest Additions from the network or checking for updates."));
     121        m_pRadioButtonProxyEnabled->setText(tr("&Manual Proxy Configuration"));
     122    }
     123
     124    /* Translate proxy host editor: */
     125    if (m_pLabelHost)
     126        m_pLabelHost->setText(tr("&URL:"));
     127    if (m_pEditorHost)
     128        m_pEditorHost->setToolTip(tr("Holds the proxy URL. "
     129                                     "The format is: "
     130                                     "<table cellspacing=0 style='white-space:pre'>"
     131                                     "<tr><td>[{type}://][{userid}[:{password}]@]{server}[:{port}]</td></tr>"
     132                                     "<tr><td>http://username:[email protected]:port</td></tr>"
     133                                     "</table>"));
     134}
     135
     136void UIGlobalProxyFeaturesEditor::sltHandleProxyModeChanged()
     137{
     138    /* Update widgets availability: */
     139    m_pWidgetSettings->setEnabled(m_pRadioButtonProxyEnabled->isChecked());
     140
     141    /* Notify listeners: */
     142    emit sigProxyModeChanged();
     143}
     144
     145void UIGlobalProxyFeaturesEditor::prepare()
     146{
     147    /* Prepare main layout: */
     148    QGridLayout *pLayout = new QGridLayout(this);
     149    if (pLayout)
     150    {
     151        pLayout->setContentsMargins(0, 0, 0, 0);
     152
     153        /* Prepare button-group: */
     154        m_pButtonGroup = new QButtonGroup(this);
     155        if (m_pButtonGroup)
    69156        {
    70             m_fDisableHostScreenSaver = fOn;
    71             m_pCheckBoxDisableHostScreenSaver->setCheckState(fOn ? Qt::Checked : Qt::Unchecked);
     157            /* Prepare 'proxy auto' button: */
     158            m_pRadioButtonProxyAuto = new QRadioButton(this);
     159            if (m_pRadioButtonProxyAuto)
     160            {
     161                m_pButtonGroup->addButton(m_pRadioButtonProxyAuto);
     162                pLayout->addWidget(m_pRadioButtonProxyAuto, 0, 0, 1, 2);
     163            }
     164            /* Prepare 'proxy disabled' button: */
     165            m_pRadioButtonProxyDisabled = new QRadioButton(this);
     166            if (m_pRadioButtonProxyDisabled)
     167            {
     168                m_pButtonGroup->addButton(m_pRadioButtonProxyDisabled);
     169                pLayout->addWidget(m_pRadioButtonProxyDisabled, 1, 0, 1, 2);
     170            }
     171            /* Prepare 'proxy enabled' button: */
     172            m_pRadioButtonProxyEnabled = new QRadioButton(this);
     173            if (m_pRadioButtonProxyEnabled)
     174            {
     175                m_pButtonGroup->addButton(m_pRadioButtonProxyEnabled);
     176                pLayout->addWidget(m_pRadioButtonProxyEnabled, 2, 0, 1, 2);
     177            }
    72178        }
    73     }
    74 }
    75 
    76 bool UIGlobalDisplayFeaturesEditor::disableHostScreenSaver() const
    77 {
    78     return   m_pCheckBoxDisableHostScreenSaver
    79            ? m_pCheckBoxDisableHostScreenSaver->checkState() == Qt::Checked
    80            : m_fDisableHostScreenSaver;
    81 }
    82 
    83 int UIGlobalDisplayFeaturesEditor::minimumLabelHorizontalHint() const
    84 {
    85     return m_pLabel->minimumSizeHint().width();
    86 }
    87 
    88 void UIGlobalDisplayFeaturesEditor::setMinimumLayoutIndent(int iIndent)
    89 {
    90     if (m_pLayout)
    91         m_pLayout->setColumnMinimumWidth(0, iIndent);
    92 }
    93 
    94 void UIGlobalDisplayFeaturesEditor::retranslateUi()
    95 {
    96     if (m_pLabel)
    97         m_pLabel->setText(tr("Extended Features:"));
    98     if (m_pCheckBoxActivateOnMouseHover)
    99     {
    100         m_pCheckBoxActivateOnMouseHover->setToolTip(tr("When checked, machine windows will be raised "
    101                                                        "when the mouse pointer moves over them."));
    102         m_pCheckBoxActivateOnMouseHover->setText(tr("&Raise Window Under Mouse Pointer"));
    103     }
    104     if (m_pCheckBoxDisableHostScreenSaver)
    105     {
    106         m_pCheckBoxDisableHostScreenSaver->setToolTip(tr("When checked, screen saver of "
    107                                                          "the host OS is disabled."));
    108         m_pCheckBoxDisableHostScreenSaver->setText(tr("&Disable Host Screen Saver"));
    109     }
    110 }
    111 
    112 void UIGlobalDisplayFeaturesEditor::prepare()
    113 {
    114     /* Prepare main layout: */
    115     m_pLayout = new QGridLayout(this);
    116     if (m_pLayout)
    117     {
    118         m_pLayout->setContentsMargins(0, 0, 0, 0);
    119         m_pLayout->setColumnStretch(1, 1);
    120 
    121         /* Prepare label: */
    122         m_pLabel = new QLabel(this);
    123         if (m_pLabel)
     179
     180        /* Prepare 20-px shifting spacer: */
     181        QSpacerItem *pSpacerItem = new QSpacerItem(20, 0, QSizePolicy::Fixed, QSizePolicy::Minimum);
     182        if (pSpacerItem)
     183            pLayout->addItem(pSpacerItem, 3, 0);
     184
     185        /* Prepare settings widget: */
     186        m_pWidgetSettings = new QWidget(this);
     187        if (m_pWidgetSettings)
    124188        {
    125             m_pLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    126             m_pLayout->addWidget(m_pLabel, 0, 0);
     189            /* Prepare settings layout widget: */
     190            QHBoxLayout *pLayoutSettings = new QHBoxLayout(m_pWidgetSettings);
     191            if (pLayoutSettings)
     192            {
     193                pLayoutSettings->setContentsMargins(0, 0, 0, 0);
     194
     195                /* Prepare host label: */
     196                m_pLabelHost = new QLabel(m_pWidgetSettings);
     197                if (m_pLabelHost)
     198                {
     199                    m_pLabelHost->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     200                    pLayoutSettings->addWidget(m_pLabelHost);
     201                }
     202                /* Prepare host editor: */
     203                m_pEditorHost = new QILineEdit(m_pWidgetSettings);
     204                if (m_pEditorHost)
     205                {
     206                    if (m_pLabelHost)
     207                        m_pLabelHost->setBuddy(m_pEditorHost);
     208                    m_pEditorHost->setValidator(new QRegularExpressionValidator(QRegularExpression("\\S+"), m_pEditorHost));
     209
     210                    pLayoutSettings->addWidget(m_pEditorHost);
     211                }
     212            }
     213
     214            pLayout->addWidget(m_pWidgetSettings, 3, 1);
    127215        }
    128         /* Prepare 'activate on mouse hover' check-box: */
    129         m_pCheckBoxActivateOnMouseHover = new QCheckBox(this);
    130         if (m_pCheckBoxActivateOnMouseHover)
    131             m_pLayout->addWidget(m_pCheckBoxActivateOnMouseHover, 0, 1);
    132         /* Prepare 'disable host screen saver' check-box: */
    133 #if defined(VBOX_WS_WIN)
    134         m_pCheckBoxDisableHostScreenSaver = new QCheckBox(this);
    135 #elif defined(VBOX_WS_X11)
    136         if (NativeWindowSubsystem::X11CheckDBusScreenSaverServices())
    137             m_pCheckBoxDisableHostScreenSaver = new QCheckBox(this);
    138 #endif /* VBOX_WS_X11 */
    139         if (m_pCheckBoxDisableHostScreenSaver)
    140             m_pLayout->addWidget(m_pCheckBoxDisableHostScreenSaver, 1, 1);
    141     }
     216    }
     217
     218    /* Prepare connections: */
     219    connect(m_pButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked),
     220            this, &UIGlobalProxyFeaturesEditor::sltHandleProxyModeChanged);
     221    connect(m_pEditorHost, &QILineEdit::textEdited,
     222            this, &UIGlobalProxyFeaturesEditor::sigProxyHostChanged);
    142223
    143224    /* Apply language settings: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIGlobalProxyFeaturesEditor.h

    r94248 r94251  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIGlobalDisplayFeaturesEditor class declaration.
     3 * VBox Qt GUI - UIGlobalProxyFeaturesEditor class declaration.
    44 */
    55
     
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_settings_editors_UIGlobalDisplayFeaturesEditor_h
    19 #define FEQT_INCLUDED_SRC_settings_editors_UIGlobalDisplayFeaturesEditor_h
     18#ifndef FEQT_INCLUDED_SRC_settings_editors_UIGlobalProxyFeaturesEditor_h
     19#define FEQT_INCLUDED_SRC_settings_editors_UIGlobalProxyFeaturesEditor_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
     
    2525#include "QIWithRetranslateUI.h"
    2626
     27/* COM includes: */
     28#include "COMEnums.h"
     29
    2730/* Forward declarations: */
    28 class QCheckBox;
    29 class QGridLayout;
     31class QButtonGroup;
    3032class QLabel;
     33class QRadioButton;
     34class QILineEdit;
    3135
    32 /** QWidget subclass used as global display features editor. */
    33 class SHARED_LIBRARY_STUFF UIGlobalDisplayFeaturesEditor : public QIWithRetranslateUI<QWidget>
     36/** QWidget subclass used as global proxy features editor. */
     37class SHARED_LIBRARY_STUFF UIGlobalProxyFeaturesEditor : public QIWithRetranslateUI<QWidget>
    3438{
    3539    Q_OBJECT;
    3640
     41signals:
     42
     43    /** Notifies listeners about proxy mode changed. */
     44    void sigProxyModeChanged();
     45    /** Notifies listeners about proxy host changed. */
     46    void sigProxyHostChanged();
     47
    3748public:
    3849
    39     /** Constructs global display features editor passing @a pParent to the base-class. */
    40     UIGlobalDisplayFeaturesEditor(QWidget *pParent = 0);
     50    /** Constructs global proxy features editor passing @a pParent to the base-class. */
     51    UIGlobalProxyFeaturesEditor(QWidget *pParent = 0);
    4152
    42     /** Defines whether 'activate on mouse hover' feature in @a fOn. */
    43     void setActivateOnMouseHover(bool fOn);
    44     /** Returns 'activate on mouse hover' feature value. */
    45     bool activateOnMouseHover() const;
     53    /** Defines proxy @a enmMode. */
     54    void setProxyMode(KProxyMode enmMode);
     55    /** Returns proxy mode. */
     56    KProxyMode proxyMode() const;
    4657
    47     /** Defines whether 'disable host screen-saver' feature in @a fOn. */
    48     void setDisableHostScreenSaver(bool fOn);
    49     /** Returns 'disable host screen-saver' feature value. */
    50     bool disableHostScreenSaver() const;
    51 
    52     /** Returns minimum layout hint. */
    53     int minimumLabelHorizontalHint() const;
    54     /** Defines minimum layout @a iIndent. */
    55     void setMinimumLayoutIndent(int iIndent);
     58    /** Defines proxy @a strHost. */
     59    void setProxyHost(const QString &strHost);
     60    /** Returns proxy host. */
     61    QString proxyHost() const;
    5662
    5763protected:
     
    6066    virtual void retranslateUi() RT_OVERRIDE;
    6167
     68private slots:
     69
     70    /** Handles proxy mode change. */
     71    void sltHandleProxyModeChanged();
     72
    6273private:
    6374
     
    6576    void prepare();
    6677
    67     /** Holds the 'activate on mouse hover' feature value. */
    68     bool  m_fActivateOnMouseHover;
    69     /** Holds the 'disable host screen-saver' feature value. */
    70     bool  m_fDisableHostScreenSaver;
     78    /** Holds the proxy mode. */
     79    KProxyMode  m_enmProxyMode;
     80    /** Holds the proxy host. */
     81    QString     m_strProxyHost;
    7182
    72     /** Holds the main layout instance. */
    73     QGridLayout *m_pLayout;
    74     /** Holds the label instance. */
    75     QLabel      *m_pLabel;
    76     /** Holds the check-box instance. */
    77     QCheckBox   *m_pCheckBoxActivateOnMouseHover;
    78     /** Holds the check-box instance. */
    79     QCheckBox   *m_pCheckBoxDisableHostScreenSaver;
     83    /** Holds the button-group instance. */
     84    QButtonGroup *m_pButtonGroup;
     85    /** Holds the 'proxy auto' radio-button instance. */
     86    QRadioButton *m_pRadioButtonProxyAuto;
     87    /** Holds the 'proxy disabled' radio-button instance. */
     88    QRadioButton *m_pRadioButtonProxyDisabled;
     89    /** Holds the 'proxy enabled' radio-button instance. */
     90    QRadioButton *m_pRadioButtonProxyEnabled;
     91    /** Holds the settings widget instance. */
     92    QWidget      *m_pWidgetSettings;
     93    /** Holds the host label instance. */
     94    QLabel       *m_pLabelHost;
     95    /** Holds the host editor instance. */
     96    QILineEdit   *m_pEditorHost;
    8097};
    8198
    82 #endif /* !FEQT_INCLUDED_SRC_settings_editors_UIGlobalDisplayFeaturesEditor_h */
     99#endif /* !FEQT_INCLUDED_SRC_settings_editors_UIGlobalProxyFeaturesEditor_h */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsProxy.cpp

    r93996 r94251  
    1717
    1818/* Qt includes: */
    19 #include <QButtonGroup>
    20 #include <QGridLayout>
    21 #include <QLabel>
    22 #include <QRadioButton>
    23 #include <QRegularExpressionValidator>
     19#include <QVBoxLayout>
    2420
    2521/* GUI includes: */
    26 #include "QILineEdit.h"
    27 #include "QIWidgetValidator.h"
     22#include "UIGlobalProxyFeaturesEditor.h"
    2823#include "UIGlobalSettingsProxy.h"
    2924#include "UIExtraDataManager.h"
    30 #include "UIMessageCenter.h"
    31 #include "UICommon.h"
    32 #include "VBoxUtils.h"
    3325
    3426/* COM includes: */
     
    7264UIGlobalSettingsProxy::UIGlobalSettingsProxy()
    7365    : m_pCache(0)
    74     , m_pButtonGroup(0)
    75     , m_pRadioButtonProxyAuto(0)
    76     , m_pRadioButtonProxyDisabled(0)
    77     , m_pRadioButtonProxyEnabled(0)
    78     , m_pWidgetSettings(0)
    79     , m_pLabelHost(0)
    80     , m_pEditorHost(0)
    8166{
    8267    prepare();
     
    11095    /* Load old data from cache: */
    11196    const UIDataSettingsGlobalProxy &oldData = m_pCache->base();
    112     switch (oldData.m_enmProxyMode)
    113     {
    114         case KProxyMode_System:  m_pRadioButtonProxyAuto->setChecked(true); break;
    115         case KProxyMode_NoProxy: m_pRadioButtonProxyDisabled->setChecked(true); break;
    116         case KProxyMode_Manual:  m_pRadioButtonProxyEnabled->setChecked(true); break;
    117         case KProxyMode_Max:     break; /* (compiler warnings) */
    118     }
    119     m_pEditorHost->setText(oldData.m_strProxyHost);
    120     sltHandleProxyToggle();
     97    m_pEditorGlobalProxyFeatures->setProxyMode(oldData.m_enmProxyMode);
     98    m_pEditorGlobalProxyFeatures->setProxyHost(oldData.m_strProxyHost);
    12199
    122100    /* Revalidate: */
     
    130108
    131109    /* Cache new data: */
    132     newData.m_enmProxyMode = m_pRadioButtonProxyEnabled->isChecked()
    133                            ? KProxyMode_Manual : m_pRadioButtonProxyDisabled->isChecked()
    134                            ? KProxyMode_NoProxy : KProxyMode_System;
    135     newData.m_strProxyHost = m_pEditorHost->text();
     110    newData.m_enmProxyMode = m_pEditorGlobalProxyFeatures->proxyMode();
     111    newData.m_strProxyHost = m_pEditorGlobalProxyFeatures->proxyHost();
    136112    m_pCache->cacheCurrentData(newData);
    137113}
     
    152128{
    153129    /* Pass if proxy is disabled: */
    154     if (!m_pRadioButtonProxyEnabled->isChecked())
     130    if (m_pEditorGlobalProxyFeatures->proxyMode() != KProxyMode_Manual)
    155131        return true;
    156132
     
    162138
    163139    /* Check for URL presence: */
    164     if (m_pEditorHost->text().trimmed().isEmpty())
     140    if (m_pEditorGlobalProxyFeatures->proxyHost().trimmed().isEmpty())
    165141    {
    166142        message.second << tr("No proxy URL is currently specified.");
     
    171147
    172148    /* Check for URL validness: */
    173     if (!QUrl(m_pEditorHost->text().trimmed()).isValid())
     149    if (!QUrl(m_pEditorGlobalProxyFeatures->proxyHost().trimmed()).isValid())
    174150    {
    175151        message.second << tr("Invalid proxy URL is currently specified.");
     
    180156
    181157    /* Check for password presence: */
    182     if (!QUrl(m_pEditorHost->text().trimmed()).password().isEmpty())
     158    if (!QUrl(m_pEditorGlobalProxyFeatures->proxyHost().trimmed()).password().isEmpty())
    183159    {
    184160        message.second << tr("You have provided a proxy password. "
     
    199175void UIGlobalSettingsProxy::retranslateUi()
    200176{
    201     m_pRadioButtonProxyAuto->setToolTip(tr("When chosen, VirtualBox will try to auto-detect host proxy settings for tasks like "
    202                                            "downloading Guest Additions from the network or checking for updates."));
    203     m_pRadioButtonProxyAuto->setText(tr("&Auto-detect Host Proxy Settings"));
    204     m_pRadioButtonProxyDisabled->setToolTip(tr("When chosen, VirtualBox will use direct Internet connection for tasks like "
    205                                                "downloading Guest Additions from the network or checking for updates."));
    206     m_pRadioButtonProxyDisabled->setText(tr("&Direct Connection to the Internet"));
    207     m_pRadioButtonProxyEnabled->setToolTip(tr("When chosen, VirtualBox will use the proxy settings supplied for tasks like "
    208                                               "downloading Guest Additions from the network or checking for updates."));
    209     m_pRadioButtonProxyEnabled->setText(tr("&Manual Proxy Configuration"));
    210 
    211     /* Translate proxy URL editor: */
    212     m_pLabelHost->setText(tr("&URL:"));
    213     m_pEditorHost->setToolTip(tr("Holds the proxy URL. "
    214                                  "The format is: "
    215                                  "<table cellspacing=0 style='white-space:pre'>"
    216                                  "<tr><td>[{type}://][{userid}[:{password}]@]{server}[:{port}]</td></tr>"
    217                                  "<tr><td>http://username:[email protected]:port</td></tr>"
    218                                  "</table>"));
    219 }
    220 
    221 void UIGlobalSettingsProxy::sltHandleProxyToggle()
    222 {
    223     /* Update widgets availability: */
    224     m_pWidgetSettings->setEnabled(m_pRadioButtonProxyEnabled->isChecked());
    225 
    226     /* Revalidate: */
    227     revalidate();
    228177}
    229178
     
    245194{
    246195    /* Prepare main layout: */
    247     QGridLayout *pLayoutMain = new QGridLayout(this);
    248     if (pLayoutMain)
    249     {
    250         pLayoutMain->setRowStretch(4, 1);
    251 
    252         /* Prepare button-group: */
    253         m_pButtonGroup = new QButtonGroup(this);
    254         if (m_pButtonGroup)
    255         {
    256             /* Prepare 'proxy auto' button: */
    257             m_pRadioButtonProxyAuto = new QRadioButton(this);
    258             if (m_pRadioButtonProxyAuto)
    259             {
    260                 m_pButtonGroup->addButton(m_pRadioButtonProxyAuto);
    261                 pLayoutMain->addWidget(m_pRadioButtonProxyAuto, 0, 0, 1, 2);
    262             }
    263             /* Prepare 'proxy disabled' button: */
    264             m_pRadioButtonProxyDisabled = new QRadioButton(this);
    265             if (m_pRadioButtonProxyDisabled)
    266             {
    267                 m_pButtonGroup->addButton(m_pRadioButtonProxyDisabled);
    268                 pLayoutMain->addWidget(m_pRadioButtonProxyDisabled, 1, 0, 1, 2);
    269             }
    270             /* Prepare 'proxy enabled' button: */
    271             m_pRadioButtonProxyEnabled = new QRadioButton(this);
    272             if (m_pRadioButtonProxyEnabled)
    273             {
    274                 m_pButtonGroup->addButton(m_pRadioButtonProxyEnabled);
    275                 pLayoutMain->addWidget(m_pRadioButtonProxyEnabled, 2, 0, 1, 2);
    276             }
    277         }
    278 
    279         /* Prepare 20-px shifting spacer: */
    280         QSpacerItem *pSpacerItem = new QSpacerItem(20, 0, QSizePolicy::Fixed, QSizePolicy::Minimum);
    281         if (pSpacerItem)
    282             pLayoutMain->addItem(pSpacerItem, 3, 0);
    283 
    284         /* Prepare settings widget: */
    285         m_pWidgetSettings = new QWidget(this);
    286         if (m_pWidgetSettings)
    287         {
    288             /* Prepare settings layout widget: */
    289             QHBoxLayout *pLayoutSettings = new QHBoxLayout(m_pWidgetSettings);
    290             if (pLayoutSettings)
    291             {
    292                 pLayoutSettings->setContentsMargins(0, 0, 0, 0);
    293 
    294                 /* Prepare host label: */
    295                 m_pLabelHost = new QLabel(m_pWidgetSettings);
    296                 if (m_pLabelHost)
    297                 {
    298                     m_pLabelHost->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    299                     pLayoutSettings->addWidget(m_pLabelHost);
    300                 }
    301                 /* Prepare host editor: */
    302                 m_pEditorHost = new QILineEdit(m_pWidgetSettings);
    303                 if (m_pEditorHost)
    304                 {
    305                     if (m_pLabelHost)
    306                         m_pLabelHost->setBuddy(m_pEditorHost);
    307                     m_pEditorHost->setValidator(new QRegularExpressionValidator(QRegularExpression("\\S+"), m_pEditorHost));
    308 
    309                     pLayoutSettings->addWidget(m_pEditorHost);
    310                 }
    311             }
    312 
    313             pLayoutMain->addWidget(m_pWidgetSettings, 3, 1);
    314         }
     196    QVBoxLayout *pLayout = new QVBoxLayout(this);
     197    if (pLayout)
     198    {
     199        /* Prepare global proxy features editor: */
     200        m_pEditorGlobalProxyFeatures = new UIGlobalProxyFeaturesEditor(this);
     201        if (m_pEditorGlobalProxyFeatures)
     202            pLayout->addWidget(m_pEditorGlobalProxyFeatures);
     203
     204        /* Add stretch to the end: */
     205        pLayout->addStretch();
    315206    }
    316207}
     
    318209void UIGlobalSettingsProxy::prepareConnections()
    319210{
    320     connect(m_pButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked),
    321             this, &UIGlobalSettingsProxy::sltHandleProxyToggle);
    322     connect(m_pEditorHost, &QILineEdit::textEdited, this, &UIGlobalSettingsProxy::revalidate);
     211    connect(m_pEditorGlobalProxyFeatures, &UIGlobalProxyFeaturesEditor::sigProxyModeChanged,
     212            this, &UIGlobalSettingsProxy::revalidate);
     213    connect(m_pEditorGlobalProxyFeatures, &UIGlobalProxyFeaturesEditor::sigProxyHostChanged,
     214            this, &UIGlobalSettingsProxy::revalidate);
    323215}
    324216
     
    339231    {
    340232        /* Get old data from cache: */
    341         //const UIDataSettingsGlobalProxy &oldData = m_pCache->base();
     233        const UIDataSettingsGlobalProxy &oldData = m_pCache->base();
    342234        /* Get new data from cache: */
    343235        const UIDataSettingsGlobalProxy &newData = m_pCache->data();
    344236
    345237        /* Save new data from cache: */
    346         if (fSuccess)
     238        if (   fSuccess
     239            && newData.m_enmProxyMode != oldData.m_enmProxyMode)
    347240        {
    348241            m_properties.SetProxyMode(newData.m_enmProxyMode);
    349242            fSuccess &= m_properties.isOk();
    350243        }
    351         if (fSuccess)
     244        if (   fSuccess
     245            && newData.m_strProxyHost != oldData.m_strProxyHost)
    352246        {
    353247            m_properties.SetProxyURL(newData.m_strProxyHost);
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsProxy.h

    r93990 r94251  
    2727
    2828/* Forward declarations: */
    29 class QButtonGroup;
    30 class QLabel;
    31 class QRadioButton;
    32 class QILineEdit;
     29class UIGlobalProxyFeaturesEditor;
    3330struct UIDataSettingsGlobalProxy;
    3431typedef UISettingsCache<UIDataSettingsGlobalProxy> UISettingsCacheGlobalProxy;
     
    6865    virtual void retranslateUi() RT_OVERRIDE;
    6966
    70 private slots:
    71 
    72     /** Handles proxy toggling. */
    73     void sltHandleProxyToggle();
    74 
    7567private:
    7668
     
    9284    /** @name Widgets
    9385     * @{ */
    94         /** Holds the button-group instance. */
    95         QButtonGroup *m_pButtonGroup;
    96         /** Holds the 'proxy auto' radio-button instance. */
    97         QRadioButton *m_pRadioButtonProxyAuto;
    98         /** Holds the 'proxy disabled' radio-button instance. */
    99         QRadioButton *m_pRadioButtonProxyDisabled;
    100         /** Holds the 'proxy enabled' radio-button instance. */
    101         QRadioButton *m_pRadioButtonProxyEnabled;
    102         /** Holds the settings widget instance. */
    103         QWidget      *m_pWidgetSettings;
    104         /** Holds the host label instance. */
    105         QLabel       *m_pLabelHost;
    106         /** Holds the host editor instance. */
    107         QILineEdit   *m_pEditorHost;
     86        /** Holds the global proxy features editor instance. */
     87        UIGlobalProxyFeaturesEditor *m_pEditorGlobalProxyFeatures;
    10888    /** @} */
    10989};
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