Changeset 90151 in vbox
- Timestamp:
- Jul 12, 2021 7:21:04 AM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 8 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r90003 r90151 651 651 src/wizards/addcloudvm/UIWizardAddCloudVMPageBasic1.h \ 652 652 src/wizards/addcloudvm/UIWizardAddCloudVMPageExpert.h \ 653 src/wizards/editors/UIHostNameDomainEditor.h \ 653 654 src/wizards/newcloudvm/UIWizardNewCloudVM.h \ 654 655 src/wizards/newcloudvm/UIWizardNewCloudVMPageBasic1.h \ … … 1148 1149 src/wizards/addcloudvm/UIWizardAddCloudVMPageBasic1.cpp \ 1149 1150 src/wizards/addcloudvm/UIWizardAddCloudVMPageExpert.cpp \ 1151 src/wizards/editors/UIHostNameDomainEditor.cpp \ 1150 1152 src/wizards/newcloudvm/UIWizardNewCloudVM.cpp \ 1151 1153 src/wizards/newcloudvm/UIWizardNewCloudVMPageBasic1.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp
r90132 r90151 984 984 unattendedInstallData.m_strUserName = comUnattendedInstaller.GetUser(); 985 985 unattendedInstallData.m_strPassword = comUnattendedInstaller.GetPassword(); 986 unattendedInstallData.m_strHostname = comUnattendedInstaller.GetHostname();987 986 unattendedInstallData.m_fInstallGuestAdditions = comUnattendedInstaller.GetInstallGuestAdditions(); 988 987 unattendedInstallData.m_strGuestAdditionsISOPath = comUnattendedInstaller.GetAdditionsIsoPath(); … … 2656 2655 comUnattendedInstaller.SetPassword(unattendedData.m_strPassword); 2657 2656 checkUnattendedInstallError(comUnattendedInstaller); 2658 comUnattendedInstaller.SetHostname(unattendedData.m_strHostname );2657 comUnattendedInstaller.SetHostname(unattendedData.m_strHostnameDomain); 2659 2658 checkUnattendedInstallError(comUnattendedInstaller); 2660 2659 comUnattendedInstaller.SetProductKey(unattendedData.m_strProductKey); -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIUserNamePasswordEditor.cpp
r90124 r90151 381 381 this, &UIUserNamePasswordEditor::sltUserNameChanged); 382 382 383 /* Cache the original back color of the line edit to restore it correctly: */384 if (m_pUserNameLineEdit)385 m_orginalLineEditBaseColor = m_pUserNameLineEdit->palette().color(QPalette::Base);386 387 383 retranslateUi(); 388 384 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIUserNamePasswordEditor.h
r90039 r90151 88 88 QLabel *m_pPasswordLabel; 89 89 QLabel *m_pPasswordRepeatLabel; 90 QColor m_orginalLineEditBaseColor;91 90 92 91 bool m_fShowPlaceholderText; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIHostNameDomainEditor.cpp
r90124 r90151 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI UserNamePasswordEditor class implementation.3 * VBox Qt GUI - UIHostNameDomainEditor class implementation. 4 4 */ 5 5 … … 20 20 #include <QLabel> 21 21 #include <QLineEdit> 22 #include <QRegularExpressionValidator> 22 23 #include <QStyle> 23 24 #include <QVBoxLayout> … … 29 30 #include "UICommon.h" 30 31 #include "UIIconPool.h" 31 #include "UI UserNamePasswordEditor.h"32 #include "UIHostNameDomainEditor.h" 32 33 #include "UIWizardNewVM.h" 33 34 34 /*********************************************************************************************************************************35 * UIPasswordLineEdit definition. *36 *********************************************************************************************************************************/37 38 class UIPasswordLineEdit : public QLineEdit39 {40 Q_OBJECT;41 42 signals:43 44 void sigTextVisibilityToggled(bool fTextVisible);45 46 public:47 48 UIPasswordLineEdit(QWidget *pParent = 0);49 void toggleTextVisibility(bool fTextVisible);50 void mark(bool fError, const QString &strErrorToolTip);51 52 protected:53 54 virtual void resizeEvent(QResizeEvent *pEvent) /* override */;55 virtual void paintEvent(QPaintEvent *pPaintEvent) /* override */;56 57 private slots:58 59 void sltHandleTextVisibilityChange();60 61 private:62 63 void prepare();64 void adjustTextVisibilityButtonGeometry();65 66 QIToolButton *m_pTextVisibilityButton;67 QIcon m_markIcon;68 QLabel *m_pErrorIconLabel;69 QString m_strErrorToolTip;70 /** When true the line edit is marked with some icon to indicate some error. */71 bool m_fMarkForError;72 };73 35 74 36 75 /********************************************************************************************************************************* 76 * UIPasswordLineEdit implementation. * 77 *********************************************************************************************************************************/ 78 79 UIPasswordLineEdit::UIPasswordLineEdit(QWidget *pParent /*= 0 */) 80 : QLineEdit(pParent) 81 , m_pTextVisibilityButton(0) 82 , m_pErrorIconLabel(0) 83 , m_fMarkForError(false) 37 UIHostNameDomainEditor::UIHostNameDomainEditor(QWidget *pParent /* = 0 */) 38 : QIWithRetranslateUI<QWidget>(pParent) 39 , m_pHostnameLineEdit(0) 40 , m_pDomainLineEdit(0) 41 , m_pHostnameLabel(0) 42 , m_pDomainLabel(0) 84 43 { 85 44 prepare(); 86 45 } 87 46 88 void UIPasswordLineEdit::toggleTextVisibility(bool fTextVisible) 47 QString UIHostNameDomainEditor::hostname() const 89 48 { 90 AssertPtrReturnVoid(m_pTextVisibilityButton); 91 92 if (fTextVisible) 93 { 94 setEchoMode(QLineEdit::Normal); 95 if (m_pTextVisibilityButton) 96 m_pTextVisibilityButton->setIcon(UIIconPool::iconSet(":/eye_closed_10px.png")); 97 } 98 else 99 { 100 setEchoMode(QLineEdit::Password); 101 if (m_pTextVisibilityButton) 102 m_pTextVisibilityButton->setIcon(UIIconPool::iconSet(":/eye_10px.png")); 103 } 104 } 105 106 void UIPasswordLineEdit::mark(bool fError, const QString &strErrorToolTip) 107 { 108 if (m_fMarkForError == fError && m_strErrorToolTip == strErrorToolTip) 109 return; 110 m_fMarkForError = fError; 111 m_strErrorToolTip = strErrorToolTip; 112 update(); 113 } 114 115 void UIPasswordLineEdit::prepare() 116 { 117 m_markIcon = UIIconPool::iconSet(":/status_error_16px.png"); 118 /* Prepare text visibility button: */ 119 m_pTextVisibilityButton = new QIToolButton(this); 120 if (m_pTextVisibilityButton) 121 { 122 m_pTextVisibilityButton->setIconSize(QSize(10, 10)); 123 m_pTextVisibilityButton->setFocusPolicy(Qt::ClickFocus); 124 m_pTextVisibilityButton->setCursor(Qt::ArrowCursor); 125 m_pTextVisibilityButton->show(); 126 connect(m_pTextVisibilityButton, &QToolButton::clicked, this, &UIPasswordLineEdit::sltHandleTextVisibilityChange); 127 } 128 m_pErrorIconLabel = new QLabel(this); 129 toggleTextVisibility(false); 130 adjustTextVisibilityButtonGeometry(); 131 } 132 133 void UIPasswordLineEdit::adjustTextVisibilityButtonGeometry() 134 { 135 AssertPtrReturnVoid(m_pTextVisibilityButton); 136 137 #ifdef VBOX_WS_MAC 138 /* Do not forget to update QIToolButton size on macOS, it's FIXED: */ 139 m_pTextVisibilityButton->setFixedSize(m_pTextVisibilityButton->minimumSizeHint()); 140 /* Calculate suitable position for a QIToolButton, it's FRAMELESS: */ 141 const int iWidth = m_pTextVisibilityButton->width(); 142 const int iMinHeight = qMin(height(), m_pTextVisibilityButton->height()); 143 const int iMaxHeight = qMax(height(), m_pTextVisibilityButton->height()); 144 const int iHalfHeightDiff = (iMaxHeight - iMinHeight) / 2; 145 m_pTextVisibilityButton->setGeometry(width() - iWidth - iHalfHeightDiff, iHalfHeightDiff, iWidth, iWidth); 146 #else 147 int iFrameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); 148 int iSize = height() - 2 * iFrameWidth; 149 m_pTextVisibilityButton->setGeometry(width() - iSize, iFrameWidth, iSize, iSize); 150 #endif 151 } 152 153 void UIPasswordLineEdit::resizeEvent(QResizeEvent *pEvent) 154 { 155 /* Call to base-class: */ 156 QLineEdit::resizeEvent(pEvent); 157 adjustTextVisibilityButtonGeometry(); 158 } 159 160 void UIPasswordLineEdit::paintEvent(QPaintEvent *pPaintEvent) 161 { 162 QLineEdit::paintEvent(pPaintEvent); 163 if (m_fMarkForError) 164 { 165 const int iIconMargin = 1. * QApplication::style()->pixelMetric(QStyle::PM_LayoutTopMargin); 166 int iIconSize = height() - 2 * iIconMargin; 167 if (!m_pErrorIconLabel) 168 m_pErrorIconLabel = new QLabel(this); 169 m_pErrorIconLabel->setPixmap(m_markIcon.pixmap(windowHandle(), QSize(iIconSize, iIconSize))); 170 int iIconX = width() - iIconSize - iIconMargin; 171 if (m_pTextVisibilityButton) 172 iIconX -= m_pTextVisibilityButton->width() - iIconMargin; 173 m_pErrorIconLabel->move(iIconX, iIconMargin); 174 m_pErrorIconLabel->setToolTip(m_strErrorToolTip); 175 m_pErrorIconLabel->show(); 176 } 177 else 178 { 179 if (m_pErrorIconLabel) 180 m_pErrorIconLabel->hide(); 181 } 182 } 183 184 void UIPasswordLineEdit::sltHandleTextVisibilityChange() 185 { 186 bool fTextVisible = false; 187 if (echoMode() == QLineEdit::Normal) 188 fTextVisible = false; 189 else 190 fTextVisible = true; 191 toggleTextVisibility(fTextVisible); 192 emit sigTextVisibilityToggled(fTextVisible); 193 } 194 195 196 /********************************************************************************************************************************* 197 * UIUserNamePasswordEditor implementation. * 198 *********************************************************************************************************************************/ 199 200 UIUserNamePasswordEditor::UIUserNamePasswordEditor(QWidget *pParent /* = 0 */) 201 : QIWithRetranslateUI<QWidget>(pParent) 202 , m_pUserNameLineEdit(0) 203 , m_pPasswordLineEdit(0) 204 , m_pPasswordRepeatLineEdit(0) 205 , m_pUserNameLabel(0) 206 , m_pPasswordLabel(0) 207 , m_pPasswordRepeatLabel(0) 208 , m_fShowPlaceholderText(true) 209 , m_fLabelsVisible(true) 210 { 211 prepare(); 212 } 213 214 QString UIUserNamePasswordEditor::userName() const 215 { 216 if (m_pUserNameLineEdit) 217 return m_pUserNameLineEdit->text(); 49 if (m_pHostnameLineEdit) 50 return m_pHostnameLineEdit->text(); 218 51 return QString(); 219 52 } 220 53 221 void UIUserNamePasswordEditor::setUserName(const QString &strUserName) 54 bool UIHostNameDomainEditor::isComplete() const 222 55 { 223 if (m_pUserNameLineEdit)224 return m_pUserNameLineEdit->setText(strUserName);56 return m_pHostnameLineEdit && m_pHostnameLineEdit->hasAcceptableInput() && 57 m_pDomainLineEdit && m_pDomainLineEdit->hasAcceptableInput(); 225 58 } 226 59 227 QString UIUserNamePasswordEditor::password() const 60 void UIHostNameDomainEditor::setHostname(const QString &strHostname) 228 61 { 229 if (m_pPasswordLineEdit) 230 return m_pPasswordLineEdit->text(); 62 if (m_pHostnameLineEdit) 63 m_pHostnameLineEdit->setText(strHostname); 64 } 65 66 QString UIHostNameDomainEditor::domain() const 67 { 68 if (m_pDomainLineEdit) 69 return m_pDomainLineEdit->text(); 231 70 return QString(); 232 71 } 233 72 234 void UI UserNamePasswordEditor::setPassword(const QString &strPassword)73 void UIHostNameDomainEditor::setDomain(const QString &strDomain) 235 74 { 236 if (m_pPasswordLineEdit) 237 m_pPasswordLineEdit->setText(strPassword); 238 if (m_pPasswordRepeatLineEdit) 239 m_pPasswordRepeatLineEdit->setText(strPassword); 75 if (m_pDomainLineEdit) 76 m_pDomainLineEdit->setText(strDomain); 240 77 } 241 78 242 bool UIUserNamePasswordEditor::isUserNameComplete() 79 QString UIHostNameDomainEditor::hostnameDomain() const 243 80 { 244 bool fComplete = (m_pUserNameLineEdit && !m_pUserNameLineEdit->text().isEmpty()); 245 if (m_pUserNameLineEdit) 246 m_pUserNameLineEdit->mark(!fComplete, UIUserNamePasswordEditor::tr("Invalid username")); 247 return fComplete; 81 if (m_pHostnameLineEdit && m_pDomainLineEdit) 82 return QString("%1.%2").arg(m_pHostnameLineEdit->text()).arg(m_pDomainLineEdit->text()); 83 return QString(); 248 84 } 249 85 250 bool UIUserNamePasswordEditor::isPasswordComplete()86 void UIHostNameDomainEditor::retranslateUi() 251 87 { 252 bool fPasswordOK = true; 253 if (m_pPasswordLineEdit && m_pPasswordRepeatLineEdit) 88 QString strHostnameTooltip(tr("Type the hostname which will be used in attended install:")); 89 QString strDomainTooltip(tr("The domain name")); 90 if (m_pHostnameLabel) 254 91 { 255 if (m_pPasswordLineEdit->text() != m_pPasswordRepeatLineEdit->text()) 256 fPasswordOK = false; 257 if (m_pPasswordLineEdit->text().isEmpty()) 258 fPasswordOK = false; 259 m_pPasswordLineEdit->mark(!fPasswordOK, m_strPasswordError); 260 m_pPasswordRepeatLineEdit->mark(!fPasswordOK, m_strPasswordError); 92 m_pHostnameLabel->setText(tr("Hostna&me:")); 93 m_pHostnameLabel->setToolTip(strHostnameTooltip); 261 94 } 262 return fPasswordOK; 95 if (m_pHostnameLineEdit) 96 m_pHostnameLineEdit->setToolTip(strHostnameTooltip); 97 if (m_pDomainLabel) 98 { 99 m_pDomainLabel->setText(tr("&Domain")); 100 m_pDomainLabel->setToolTip(strDomainTooltip); 101 } 102 m_pDomainLineEdit->setToolTip(strDomainTooltip); 263 103 } 264 104 265 bool UIUserNamePasswordEditor::isComplete()105 void UIHostNameDomainEditor::addLineEdit(int &iRow, QLabel *&pLabel, QILineEdit *&pLineEdit, QGridLayout *pLayout) 266 106 { 267 bool fUserNameField = isUserNameComplete(); 268 bool fPasswordField = isPasswordComplete(); 269 return fUserNameField && fPasswordField; 270 } 107 AssertReturnVoid(pLayout); 108 if (pLabel || pLineEdit) 109 return; 271 110 272 void UIUserNamePasswordEditor::setPlaceholderTextEnabled(bool fEnabled)273 {274 if (m_fShowPlaceholderText == fEnabled)275 return;276 m_fShowPlaceholderText = fEnabled;277 retranslateUi();278 }279 280 void UIUserNamePasswordEditor::setLabelsVisible(bool fVisible)281 {282 if (m_fLabelsVisible == fVisible)283 return;284 m_fLabelsVisible = fVisible;285 m_pUserNameLabel->setVisible(fVisible);286 m_pPasswordLabel->setVisible(fVisible);287 m_pPasswordRepeatLabel->setVisible(fVisible);288 289 }290 291 void UIUserNamePasswordEditor::retranslateUi()292 {293 QString strPassword = UIUserNamePasswordEditor::tr("Pass&word");294 QString strRepeatPassword = UIUserNamePasswordEditor::tr("&Repeat Password");295 QString strUsername = UIUserNamePasswordEditor::tr("U&sername");296 if (m_pUserNameLabel)297 {298 m_pUserNameLabel->setText(QString("%1%2").arg(strUsername).arg(":"));299 m_pUserNameLabel->setToolTip(UIUserNamePasswordEditor::tr("Type the user name which will be used in attended install:"));300 301 }302 if (m_pPasswordLabel)303 {304 m_pPasswordLabel->setText(QString("%1%2").arg(strPassword).arg(":"));305 m_pPasswordLabel->setToolTip(UIUserNamePasswordEditor::tr("Type the password for the user name"));306 307 }308 if (m_pPasswordRepeatLabel)309 {310 m_pPasswordRepeatLabel->setText(QString("%1%2").arg(strRepeatPassword).arg(":"));311 m_pPasswordRepeatLabel->setToolTip(UIUserNamePasswordEditor::tr("Retype the password:"));312 }313 314 if (m_fShowPlaceholderText)315 {316 if(m_pUserNameLineEdit)317 m_pUserNameLineEdit->setPlaceholderText(strUsername.remove('&'));318 if (m_pPasswordLineEdit)319 m_pPasswordLineEdit->setPlaceholderText(strPassword.remove('&'));320 if (m_pPasswordRepeatLineEdit)321 m_pPasswordRepeatLineEdit->setPlaceholderText(strRepeatPassword.remove('&'));322 }323 else324 {325 if(m_pUserNameLineEdit)326 m_pUserNameLineEdit->setPlaceholderText(QString());327 if (m_pPasswordLineEdit)328 m_pPasswordLineEdit->setPlaceholderText(QString());329 if (m_pPasswordRepeatLineEdit)330 m_pPasswordRepeatLineEdit->setPlaceholderText(QString());331 }332 m_strPasswordError = UIUserNamePasswordEditor::tr("Invalid password pair");333 }334 335 template <class T>336 void UIUserNamePasswordEditor::addLineEdit(int &iRow, QLabel *&pLabel, T *&pLineEdit, QGridLayout *pLayout)337 {338 if (!pLayout || pLabel || pLineEdit)339 return;340 111 pLabel = new QLabel; 341 if (!pLabel) 342 return; 112 AssertReturnVoid(pLabel); 343 113 pLabel->setAlignment(Qt::AlignRight); 344 114 pLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); … … 346 116 pLayout->addWidget(pLabel, iRow, 0, 1, 1); 347 117 348 pLineEdit = new T;349 if (!pLineEdit)350 return; 118 pLineEdit = new QILineEdit; 119 AssertReturnVoid(pLineEdit); 120 351 121 pLayout->addWidget(pLineEdit, iRow, 1, 1, 3); 122 // QRegularExpression hostNameRegex("^[a-zA-Z0-9-.]{2,}\\.[a-zA-Z0-9-.]+$");^[a-zA-Z0-9-.]{2,}\.[a-zA-Z0-9-.]+$ 123 /* Host name and domain should be strings of minimum length of 2 and composed of alpha numerics, '-', and '.': */ 124 m_pHostnameLineEdit->setValidator(new QRegularExpressionValidator(QRegularExpression("^[a-zA-Z0-9-.]{2,}"), this)); 352 125 353 126 pLabel->setBuddy(pLineEdit); … … 356 129 } 357 130 358 void UI UserNamePasswordEditor::prepare()131 void UIHostNameDomainEditor::prepare() 359 132 { 360 133 QGridLayout *pMainLayout = new QGridLayout; … … 366 139 setLayout(pMainLayout); 367 140 int iRow = 0; 368 addLineEdit<QILineEdit>(iRow, m_pUserNameLabel, m_pUserNameLineEdit, pMainLayout); 369 addLineEdit<UIPasswordLineEdit>(iRow, m_pPasswordLabel, m_pPasswordLineEdit, pMainLayout); 370 addLineEdit<UIPasswordLineEdit>(iRow, m_pPasswordRepeatLabel, m_pPasswordRepeatLineEdit, pMainLayout); 141 addLineEdit(iRow, m_pHostnameLabel, m_pHostnameLineEdit, pMainLayout); 142 addLineEdit(iRow, m_pDomainLabel, m_pDomainLineEdit, pMainLayout); 371 143 372 connect(m_pPasswordLineEdit, &UIPasswordLineEdit::sigTextVisibilityToggled, 373 this, &UIUserNamePasswordEditor::sltHandlePasswordVisibility); 374 connect(m_pPasswordRepeatLineEdit, &UIPasswordLineEdit::sigTextVisibilityToggled, 375 this, &UIUserNamePasswordEditor::sltHandlePasswordVisibility); 376 connect(m_pPasswordLineEdit, &UIPasswordLineEdit::textChanged, 377 this, &UIUserNamePasswordEditor::sltPasswordChanged); 378 connect(m_pPasswordRepeatLineEdit, &UIPasswordLineEdit::textChanged, 379 this, &UIUserNamePasswordEditor::sltPasswordChanged); 380 connect(m_pUserNameLineEdit, &QILineEdit::textChanged, 381 this, &UIUserNamePasswordEditor::sltUserNameChanged); 144 connect(m_pHostnameLineEdit, &QILineEdit::textChanged, 145 this, &UIHostNameDomainEditor::sltHostnameChanged); 146 connect(m_pDomainLineEdit, &QILineEdit::textChanged, 147 this, &UIHostNameDomainEditor::sltDomainChanged); 382 148 383 /* Cache the original back color of the line edit to restore it correctly: */384 if (m_pUserNameLineEdit)385 m_orginalLineEditBaseColor = m_pUserNameLineEdit->palette().color(QPalette::Base);386 149 387 150 retranslateUi(); 388 151 } 389 152 390 void UI UserNamePasswordEditor::sltHandlePasswordVisibility(bool fPasswordVisible)153 void UIHostNameDomainEditor::sltHostnameChanged() 391 154 { 392 if (m_pPasswordLineEdit) 393 m_pPasswordLineEdit->toggleTextVisibility(fPasswordVisible); 394 if (m_pPasswordRepeatLineEdit) 395 m_pPasswordRepeatLineEdit->toggleTextVisibility(fPasswordVisible); 155 m_pHostnameLineEdit->mark(!m_pHostnameLineEdit->hasAcceptableInput(), 156 tr("Hostname should be a string of length 2. Allowed characters are alphanumerics, '-', and '.'" )); 157 emit sigHostnameDomainChanged(hostnameDomain()); 396 158 } 397 159 398 void UI UserNamePasswordEditor::sltUserNameChanged()160 void UIHostNameDomainEditor::sltDomainChanged() 399 161 { 400 isUserNameComplete(); 401 emit sigUserNameChanged(m_pUserNameLineEdit->text()); 162 m_pDomainLineEdit->mark(!m_pDomainLineEdit->hasAcceptableInput(), 163 tr("Domain name should be a string of length 2. Allowed characters are alphanumerics, '-', and '.'" )); 164 165 emit sigHostnameDomainChanged(hostnameDomain()); 402 166 } 403 404 void UIUserNamePasswordEditor::sltPasswordChanged()405 {406 isPasswordComplete();407 emit sigPasswordChanged(m_pPasswordLineEdit->text());408 }409 410 411 #include "UIUserNamePasswordEditor.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIHostNameDomainEditor.h
r90124 r90151 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI UserNamePasswordEditor class declaration.3 * VBox Qt GUI - UIHostNameDomainEditor class declaration. 4 4 */ 5 5 … … 16 16 */ 17 17 18 #ifndef FEQT_INCLUDED_SRC_widgets_UI UserNamePasswordEditor_h19 #define FEQT_INCLUDED_SRC_widgets_UI UserNamePasswordEditor_h18 #ifndef FEQT_INCLUDED_SRC_widgets_UIHostNameDomainEditor_h 19 #define FEQT_INCLUDED_SRC_widgets_UIHostNameDomainEditor_h 20 20 #ifndef RT_WITHOUT_PRAGMA_ONCE 21 21 # pragma once … … 35 35 class UIPasswordLineEdit; 36 36 37 class UI UserNamePasswordEditor : public QIWithRetranslateUI<QWidget>37 class UIHostNameDomainEditor : public QIWithRetranslateUI<QWidget> 38 38 { 39 39 … … 42 42 signals: 43 43 44 void sigUserNameChanged(const QString &strUserName); 45 void sigPasswordChanged(const QString &strPassword); 44 void sigHostnameDomainChanged(const QString &strHostNameDomain); 46 45 47 46 public: 48 47 49 UI UserNamePasswordEditor(QWidget *pParent = 0);48 UIHostNameDomainEditor(QWidget *pParent = 0); 50 49 51 QString userName() const;52 void set UserName(const QString &strUserName);50 QString hostname() const; 51 void setHostname(const QString &strHostname); 53 52 54 QString password() const;55 void set Password(const QString &strPassword);53 QString domain() const; 54 void setDomain(const QString &strDomain); 56 55 57 /** Returns false if username or password fields are empty, or password fields do not match. */ 58 bool isComplete(); 56 QString hostnameDomain() const; 59 57 60 /** When fEnabled true place holder texts for the line edits are shown. */ 61 void setPlaceholderTextEnabled(bool fEnabled); 62 void setLabelsVisible(bool fVisible); 58 bool isComplete() const; 63 59 64 60 protected: … … 68 64 private slots: 69 65 70 void sltHandlePasswordVisibility(bool fPasswordVisible); 71 void sltUserNameChanged(); 72 void sltPasswordChanged(); 66 void sltHostnameChanged(); 67 void sltDomainChanged(); 73 68 74 69 private: 75 70 76 71 void prepare(); 77 template <class T> 78 void addLineEdit(int &iRow, QLabel *&pLabel, T *&pLineEdit, QGridLayout *pLayout); 72 void addLineEdit(int &iRow, QLabel *&pLabel, QILineEdit *&pLineEdit, QGridLayout *pLayout); 79 73 80 bool isUserNameComplete();81 bool isPasswordComplete();74 QILineEdit *m_pHostnameLineEdit; 75 QILineEdit *m_pDomainLineEdit; 82 76 83 QILineEdit *m_pUserNameLineEdit; 84 UIPasswordLineEdit *m_pPasswordLineEdit; 85 UIPasswordLineEdit *m_pPasswordRepeatLineEdit; 77 QLabel *m_pHostnameLabel; 78 QLabel *m_pDomainLabel; 86 79 87 QLabel *m_pUserNameLabel;88 QLabel *m_pPasswordLabel;89 QLabel *m_pPasswordRepeatLabel;90 QColor m_orginalLineEditBaseColor;91 92 bool m_fShowPlaceholderText;93 bool m_fLabelsVisible;94 95 QString m_strPasswordError;96 80 }; 97 81 98 #endif /* !FEQT_INCLUDED_SRC_widgets_UI UserNamePasswordEditor_h */82 #endif /* !FEQT_INCLUDED_SRC_widgets_UIHostNameDomainEditor_h */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp
r90109 r90151 742 742 } 743 743 744 const QString &UIWizardNewVM::hostname () const745 { 746 return m_unattendedInstallData.m_strHostname ;747 } 748 749 void UIWizardNewVM::setHostname (const QString &strHostname)750 { 751 m_unattendedInstallData.m_strHostname = strHostname;744 const QString &UIWizardNewVM::hostnameDomain() const 745 { 746 return m_unattendedInstallData.m_strHostnameDomain; 747 } 748 749 void UIWizardNewVM::setHostnameDomain(const QString &strHostnameDomain) 750 { 751 m_unattendedInstallData.m_strHostnameDomain = strHostnameDomain; 752 752 } 753 753 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.h
r90109 r90151 52 52 QString m_strUserName; 53 53 QString m_strPassword; 54 QString m_strHostname ;54 QString m_strHostnameDomain; 55 55 QString m_strProductKey; 56 56 bool m_fInstallGuestAdditions; … … 134 134 void setGuestAdditionsISOPath(const QString &strGAISOPath); 135 135 136 const QString &hostname () const;137 void setHostname (const QString &strHostname);136 const QString &hostnameDomain() const; 137 void setHostnameDomain(const QString &strHostname); 138 138 139 139 const QString &productKey() const; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMUnattendedPageBasic.cpp
r90106 r90151 32 32 #include "UIIconPool.h" 33 33 #include "UIUserNamePasswordEditor.h" 34 #include "UIHostNameDomainEditor.h" 34 35 #include "UIWizardNewVMUnattendedPageBasic.h" 35 36 #include "UIWizardNewVM.h" … … 61 62 , m_pStartHeadlessCheckBox(0) 62 63 , m_pUserNamePasswordEditor(0) 63 , m_pHostnameLineEdit(0) 64 , m_pHostnameLabel(0) 64 , m_pHostnameDomainEditor(0) 65 65 , m_pGAISOPathLabel(0) 66 66 , m_pGAISOFilePathSelector(0) … … 101 101 connect(m_pGAInstallationISOContainer, &QGroupBox::toggled, 102 102 this, &UIWizardNewVMUnattendedPageBasic::sltInstallGACheckBoxToggle); 103 if (m_pHostname LineEdit)104 connect(m_pHostname LineEdit, &QLineEdit::textChanged,105 this, &UIWizardNewVMUnattendedPageBasic::sltHostname Changed);103 if (m_pHostnameDomainEditor) 104 connect(m_pHostnameDomainEditor, &UIHostNameDomainEditor::sigHostnameDomainChanged, 105 this, &UIWizardNewVMUnattendedPageBasic::sltHostnameDomainChanged); 106 106 if (m_pProductKeyLineEdit) 107 107 connect(m_pProductKeyLineEdit, &QLineEdit::textChanged, … … 120 120 "hostname. Additionally you can enable guest additions install. " 121 121 "For Microsoft Windows guests it is possible to provide a product key.</p>")); 122 if (m_pHostnameLabel)123 m_pHostnameLabel->setText(UIWizardNewVM::tr("Hostna&me:"));124 125 122 if (m_pGAISOPathLabel) 126 123 m_pGAISOPathLabel->setText(UIWizardNewVM::tr("GA I&nstallation ISO:")); … … 166 163 m_pUserNamePasswordEditor->blockSignals(false); 167 164 } 168 if (m_pHostnameLineEdit && !m_userModifiedParameters.contains("Hostname")) 169 { 170 m_pHostnameLineEdit->blockSignals(true); 171 m_pHostnameLineEdit->setText(pWizard->hostname()); 172 m_pHostnameLineEdit->blockSignals(false); 165 if (m_pHostnameDomainEditor) 166 { 167 m_pHostnameDomainEditor->blockSignals(true); 168 169 if (!m_userModifiedParameters.contains("HostnameDomain")) 170 { 171 m_pHostnameDomainEditor->setHostname(pWizard->machineBaseName()); 172 m_pHostnameDomainEditor->setDomain("myguest.virtualbox.org"); 173 /* Initialize unattended hostname here since we cannot get the efault value from CUnattended this early (unlike username etc): */ 174 newVMWizardPropertySet(HostnameDomain, m_pHostnameDomainEditor->hostnameDomain()); 175 } 176 177 m_pHostnameDomainEditor->blockSignals(false); 173 178 } 174 179 if (m_pGAInstallationISOContainer && !m_userModifiedParameters.contains("InstallGuestAdditions")) … … 196 201 if (m_pUserNamePasswordEditor && !m_pUserNamePasswordEditor->isComplete()) 197 202 return false; 203 if (m_pHostnameDomainEditor && !m_pHostnameDomainEditor->isComplete()) 204 return false; 198 205 return true; 199 206 } … … 245 252 } 246 253 247 void UIWizardNewVMUnattendedPageBasic::sltHostnameChanged(const QString &strHostname) 248 { 249 newVMWizardPropertySet(Hostname, strHostname); 250 m_userModifiedParameters << "Hostname"; 254 void UIWizardNewVMUnattendedPageBasic::sltHostnameDomainChanged(const QString &strHostnameDomain) 255 { 256 newVMWizardPropertySet(HostnameDomain, strHostnameDomain); 257 m_userModifiedParameters << "HostnameDomain"; 258 emit completeChanged(); 251 259 } 252 260 … … 304 312 } 305 313 306 m_pHostnameLabel = new QLabel; 307 if (m_pHostnameLabel) 308 { 309 m_pHostnameLabel->setAlignment(Qt::AlignRight); 310 m_pHostnameLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 311 pAdditionalOptionsContainerLayout->addWidget(m_pHostnameLabel, 1, 0); 312 } 313 m_pHostnameLineEdit = new QLineEdit; 314 if (m_pHostnameLineEdit) 315 { 316 if (m_pHostnameLabel) 317 m_pHostnameLabel->setBuddy(m_pHostnameLineEdit); 318 pAdditionalOptionsContainerLayout->addWidget(m_pHostnameLineEdit, 1, 1, 1, 2); 314 m_pHostnameDomainEditor = new UIHostNameDomainEditor; 315 if (m_pHostnameDomainEditor) 316 { 317 // if (m_pHostnameLabel) 318 // m_pHostnameLabel->setBuddy(m_pHostnameLineEdit); 319 // QRegularExpression hostNameRegex("^[a-zA-Z0-9-.]{2,}\\.[a-zA-Z0-9-.]+$");^[a-zA-Z0-9-.]{2,}\.[a-zA-Z0-9-.]+$ 320 // m_pHostnameLineEdit->setValidator(new QRegularExpressionValidator(hostNameRegex, this)); 321 // m_pHostnameLineEdit->setInputMask("NNNNN-NNNNN-NNNNN-NNNNN-NNNNN;#"); 322 pAdditionalOptionsContainerLayout->addWidget(m_pHostnameDomainEditor, 1, 0, 2, 3); 319 323 } 320 324 321 325 m_pStartHeadlessCheckBox = new QCheckBox; 322 326 if (m_pStartHeadlessCheckBox) 323 pAdditionalOptionsContainerLayout->addWidget(m_pStartHeadlessCheckBox, 2, 1);327 pAdditionalOptionsContainerLayout->addWidget(m_pStartHeadlessCheckBox, 3, 1); 324 328 325 329 return m_pAdditionalOptionsContainer; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMUnattendedPageBasic.h
r90101 r90151 35 35 class UIFilePathSelector; 36 36 class UIUserNamePasswordEditor; 37 class UIHostNameDomainEditor; 37 38 struct UIUnattendedInstallData; 38 39 … … 64 65 void sltPasswordChanged(const QString &strPassword); 65 66 void sltUserNameChanged(const QString &strUserName); 66 void sltHostname Changed(const QString &strHostname);67 void sltHostnameDomainChanged(const QString &strHostname); 67 68 void sltProductKeyChanged(const QString &strProductKey); 68 69 void sltStartHeadlessChanged(bool fStartHeadless); … … 93 94 QCheckBox *m_pStartHeadlessCheckBox; 94 95 UIUserNamePasswordEditor *m_pUserNamePasswordEditor; 95 QLineEdit *m_pHostnameLineEdit; 96 QLabel *m_pHostnameLabel; 96 UIHostNameDomainEditor *m_pHostnameDomainEditor; 97 // QLineEdit *m_pHostnameLineEdit; 98 // QLabel *m_pHostnameLabel; 97 99 QLabel *m_pGAISOPathLabel; 98 100 UIFilePathSelector *m_pGAISOFilePathSelector;
Note:
See TracChangeset
for help on using the changeset viewer.