Changeset 94251 in vbox
- Timestamp:
- Mar 15, 2022 5:55:39 PM (3 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r94248 r94251 901 901 src/settings/editors/UIDefaultMachineFolderEditor.h \ 902 902 src/settings/editors/UIGlobalDisplayFeaturesEditor.h \ 903 src/settings/editors/UIGlobalProxyFeaturesEditor.h \ 903 904 src/settings/editors/UIGraphicsControllerEditor.h \ 904 905 src/settings/editors/UIHostComboEditor.h \ … … 1455 1456 src/settings/editors/UIDefaultMachineFolderEditor.cpp \ 1456 1457 src/settings/editors/UIGlobalDisplayFeaturesEditor.cpp \ 1458 src/settings/editors/UIGlobalProxyFeaturesEditor.cpp \ 1457 1459 src/settings/editors/UIGraphicsControllerEditor.cpp \ 1458 1460 src/settings/editors/UIHostComboEditor.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIGlobalProxyFeaturesEditor.cpp
r94248 r94251 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIGlobal DisplayFeaturesEditor class implementation.3 * VBox Qt GUI - UIGlobalProxyFeaturesEditor class implementation. 4 4 */ 5 5 … … 17 17 18 18 /* Qt includes: */ 19 #include <Q CheckBox>19 #include <QButtonGroup> 20 20 #include <QGridLayout> 21 21 #include <QLabel> 22 #include <QRadioButton> 23 #include <QRegularExpressionValidator> 22 24 23 25 /* 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 30 UIGlobalProxyFeaturesEditor::UIGlobalProxyFeaturesEditor(QWidget *pParent /* = 0 */) 31 31 : 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) 37 40 { 38 41 prepare(); 39 42 } 40 43 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) 44 void 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) 48 52 { 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; 51 67 } 52 68 } 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 74 KProxyMode 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 85 void 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 97 QString UIGlobalProxyFeaturesEditor::proxyHost() const 98 { 99 return m_pEditorHost ? m_pEditorHost->text() : m_strProxyHost; 100 } 101 102 void 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 136 void UIGlobalProxyFeaturesEditor::sltHandleProxyModeChanged() 137 { 138 /* Update widgets availability: */ 139 m_pWidgetSettings->setEnabled(m_pRadioButtonProxyEnabled->isChecked()); 140 141 /* Notify listeners: */ 142 emit sigProxyModeChanged(); 143 } 144 145 void 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) 69 156 { 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 } 72 178 } 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) 124 188 { 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); 127 215 } 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); 142 223 143 224 /* Apply language settings: */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIGlobalProxyFeaturesEditor.h
r94248 r94251 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIGlobal DisplayFeaturesEditor class declaration.3 * VBox Qt GUI - UIGlobalProxyFeaturesEditor class declaration. 4 4 */ 5 5 … … 16 16 */ 17 17 18 #ifndef FEQT_INCLUDED_SRC_settings_editors_UIGlobal DisplayFeaturesEditor_h19 #define FEQT_INCLUDED_SRC_settings_editors_UIGlobal DisplayFeaturesEditor_h18 #ifndef FEQT_INCLUDED_SRC_settings_editors_UIGlobalProxyFeaturesEditor_h 19 #define FEQT_INCLUDED_SRC_settings_editors_UIGlobalProxyFeaturesEditor_h 20 20 #ifndef RT_WITHOUT_PRAGMA_ONCE 21 21 # pragma once … … 25 25 #include "QIWithRetranslateUI.h" 26 26 27 /* COM includes: */ 28 #include "COMEnums.h" 29 27 30 /* Forward declarations: */ 28 class QCheckBox; 29 class QGridLayout; 31 class QButtonGroup; 30 32 class QLabel; 33 class QRadioButton; 34 class QILineEdit; 31 35 32 /** QWidget subclass used as global display features editor. */33 class SHARED_LIBRARY_STUFF UIGlobal DisplayFeaturesEditor : public QIWithRetranslateUI<QWidget>36 /** QWidget subclass used as global proxy features editor. */ 37 class SHARED_LIBRARY_STUFF UIGlobalProxyFeaturesEditor : public QIWithRetranslateUI<QWidget> 34 38 { 35 39 Q_OBJECT; 36 40 41 signals: 42 43 /** Notifies listeners about proxy mode changed. */ 44 void sigProxyModeChanged(); 45 /** Notifies listeners about proxy host changed. */ 46 void sigProxyHostChanged(); 47 37 48 public: 38 49 39 /** Constructs global display features editor passing @a pParent to the base-class. */40 UIGlobal DisplayFeaturesEditor(QWidget *pParent = 0);50 /** Constructs global proxy features editor passing @a pParent to the base-class. */ 51 UIGlobalProxyFeaturesEditor(QWidget *pParent = 0); 41 52 42 /** Defines whether 'activate on mouse hover' feature in @a fOn. */43 void set ActivateOnMouseHover(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; 46 57 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; 56 62 57 63 protected: … … 60 66 virtual void retranslateUi() RT_OVERRIDE; 61 67 68 private slots: 69 70 /** Handles proxy mode change. */ 71 void sltHandleProxyModeChanged(); 72 62 73 private: 63 74 … … 65 76 void prepare(); 66 77 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; 71 82 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; 80 97 }; 81 98 82 #endif /* !FEQT_INCLUDED_SRC_settings_editors_UIGlobal DisplayFeaturesEditor_h */99 #endif /* !FEQT_INCLUDED_SRC_settings_editors_UIGlobalProxyFeaturesEditor_h */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsProxy.cpp
r93996 r94251 17 17 18 18 /* Qt includes: */ 19 #include <QButtonGroup> 20 #include <QGridLayout> 21 #include <QLabel> 22 #include <QRadioButton> 23 #include <QRegularExpressionValidator> 19 #include <QVBoxLayout> 24 20 25 21 /* GUI includes: */ 26 #include "QILineEdit.h" 27 #include "QIWidgetValidator.h" 22 #include "UIGlobalProxyFeaturesEditor.h" 28 23 #include "UIGlobalSettingsProxy.h" 29 24 #include "UIExtraDataManager.h" 30 #include "UIMessageCenter.h"31 #include "UICommon.h"32 #include "VBoxUtils.h"33 25 34 26 /* COM includes: */ … … 72 64 UIGlobalSettingsProxy::UIGlobalSettingsProxy() 73 65 : 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)81 66 { 82 67 prepare(); … … 110 95 /* Load old data from cache: */ 111 96 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); 121 99 122 100 /* Revalidate: */ … … 130 108 131 109 /* 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(); 136 112 m_pCache->cacheCurrentData(newData); 137 113 } … … 152 128 { 153 129 /* Pass if proxy is disabled: */ 154 if ( !m_pRadioButtonProxyEnabled->isChecked())130 if (m_pEditorGlobalProxyFeatures->proxyMode() != KProxyMode_Manual) 155 131 return true; 156 132 … … 162 138 163 139 /* Check for URL presence: */ 164 if (m_pEditor Host->text().trimmed().isEmpty())140 if (m_pEditorGlobalProxyFeatures->proxyHost().trimmed().isEmpty()) 165 141 { 166 142 message.second << tr("No proxy URL is currently specified."); … … 171 147 172 148 /* Check for URL validness: */ 173 if (!QUrl(m_pEditor Host->text().trimmed()).isValid())149 if (!QUrl(m_pEditorGlobalProxyFeatures->proxyHost().trimmed()).isValid()) 174 150 { 175 151 message.second << tr("Invalid proxy URL is currently specified."); … … 180 156 181 157 /* Check for password presence: */ 182 if (!QUrl(m_pEditor Host->text().trimmed()).password().isEmpty())158 if (!QUrl(m_pEditorGlobalProxyFeatures->proxyHost().trimmed()).password().isEmpty()) 183 159 { 184 160 message.second << tr("You have provided a proxy password. " … … 199 175 void UIGlobalSettingsProxy::retranslateUi() 200 176 { 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();228 177 } 229 178 … … 245 194 { 246 195 /* 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(); 315 206 } 316 207 } … … 318 209 void UIGlobalSettingsProxy::prepareConnections() 319 210 { 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); 323 215 } 324 216 … … 339 231 { 340 232 /* Get old data from cache: */ 341 //const UIDataSettingsGlobalProxy &oldData = m_pCache->base();233 const UIDataSettingsGlobalProxy &oldData = m_pCache->base(); 342 234 /* Get new data from cache: */ 343 235 const UIDataSettingsGlobalProxy &newData = m_pCache->data(); 344 236 345 237 /* Save new data from cache: */ 346 if (fSuccess) 238 if ( fSuccess 239 && newData.m_enmProxyMode != oldData.m_enmProxyMode) 347 240 { 348 241 m_properties.SetProxyMode(newData.m_enmProxyMode); 349 242 fSuccess &= m_properties.isOk(); 350 243 } 351 if (fSuccess) 244 if ( fSuccess 245 && newData.m_strProxyHost != oldData.m_strProxyHost) 352 246 { 353 247 m_properties.SetProxyURL(newData.m_strProxyHost); -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsProxy.h
r93990 r94251 27 27 28 28 /* Forward declarations: */ 29 class QButtonGroup; 30 class QLabel; 31 class QRadioButton; 32 class QILineEdit; 29 class UIGlobalProxyFeaturesEditor; 33 30 struct UIDataSettingsGlobalProxy; 34 31 typedef UISettingsCache<UIDataSettingsGlobalProxy> UISettingsCacheGlobalProxy; … … 68 65 virtual void retranslateUi() RT_OVERRIDE; 69 66 70 private slots:71 72 /** Handles proxy toggling. */73 void sltHandleProxyToggle();74 75 67 private: 76 68 … … 92 84 /** @name Widgets 93 85 * @{ */ 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; 108 88 /** @} */ 109 89 };
Note:
See TracChangeset
for help on using the changeset viewer.