Changeset 104631 in vbox
- Timestamp:
- May 14, 2024 2:05:33 PM (7 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIComboBox.cpp
r101563 r104631 313 313 } 314 314 315 void QIComboBox::mark(bool fError, const QString &strErrorMessage /* = QString() */)315 void QIComboBox::mark(bool fError, const QString &strErrorMessage, const QString &strNoErrorMessage) 316 316 { 317 317 AssertPtrReturnVoid(m_pComboBox); 318 318 QILineEdit *pLineEdit = isEditable() ? qobject_cast<QILineEdit*>(m_pComboBox->lineEdit()) : 0; 319 setMarkable(true); 319 320 if (pLineEdit) 320 pLineEdit->mark(fError, strErrorMessage );321 pLineEdit->mark(fError, strErrorMessage, strNoErrorMessage); 321 322 } 322 323 … … 385 386 AssertPtrReturnVoid(m_pComboBox); 386 387 m_pComboBox->setItemText(iIndex, strText); 388 } 389 390 void QIComboBox::setMarkable(bool fMarkable) 391 { 392 QILineEdit *pLineEdit = isEditable() ? qobject_cast<QILineEdit*>(m_pComboBox->lineEdit()) : 0; 393 if (pLineEdit) 394 pLineEdit->setMarkable(fMarkable); 387 395 } 388 396 -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIComboBox.h
r98103 r104631 130 130 void setSizeAdjustPolicy(QComboBox::SizeAdjustPolicy enmPolicy); 131 131 /** Marks the line edit of the combobox. Refer to QILineEdit::mark(..). */ 132 void mark(bool fError, const QString &strErrorMessage = QString());132 void mark(bool fError, const QString &strErrorMessage, const QString &strNoErrorMessage); 133 133 134 134 /** Inserts separator at position with specified @a iIndex. */ 135 135 void insertSeparator(int iIndex); 136 137 /** Calls QILineEdit member's setMarkable API. */ 138 void setMarkable(bool fMarkable); 136 139 137 140 public slots: -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILineEdit.cpp
r104585 r104631 50 50 , m_pIconLabel(0) 51 51 , m_fMarkForError(false) 52 , m_fMarkable(false) 53 , m_iIconMargin(0) 52 54 { 53 55 prepare(); … … 79 81 } 80 82 81 void QILineEdit::mark(bool fError, const QString &strErrorMessage /* = QString() */)83 void QILineEdit::mark(bool fError, const QString &strErrorMessage, const QString &strNoErrorMessage) 82 84 { 83 /* Check if something really changed: */84 if ( fError == m_fMarkForError && m_strErrorMessage == strErrorMessage)85 AssertPtrReturnVoid(m_pIconLabel); 86 if (!m_fMarkable) 85 87 return; 86 88 87 /* Save new values: */ 88 m_fMarkForError = fError; 89 m_strErrorMessage = strErrorMessage; 89 const QIcon icon = fError ? UIIconPool::iconSet(":/status_error_16px.png") : UIIconPool::iconSet(":/status_check_16px.png"); 90 const int iIconMetric = qMin((int)(QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * .625), height()); 91 const qreal fDevicePixelRatio = gpDesktop->devicePixelRatio(m_pIconLabel); 92 const QString strToolTip = fError ? strErrorMessage : strNoErrorMessage; 93 const QPixmap iconPixmap = icon.pixmap(QSize(iIconMetric, iIconMetric), fDevicePixelRatio); 94 m_pIconLabel->setPixmap(iconPixmap); 95 m_pIconLabel->resize(m_pIconLabel->minimumSizeHint()); 96 m_pIconLabel->setToolTip(strToolTip); 97 m_iIconMargin = (height() - m_pIconLabel->height()) / 2; 98 update(); 99 } 90 100 91 /* Update accordingly: */ 92 if (m_fMarkForError) 93 { 94 /* Create label if absent: */ 95 if (!m_pIconLabel) 96 m_pIconLabel = new QLabel(this); 97 98 /* Update label content, visibility & position: */ 99 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * .625; 100 const int iShift = height() > iIconMetric ? (height() - iIconMetric) / 2 : 0; 101 const qreal fDevicePixelRatio = window() && window()->windowHandle() ? window()->windowHandle()->devicePixelRatio() : 1; 102 m_pIconLabel->setPixmap(m_markIcon.pixmap(QSize(iIconMetric, iIconMetric), fDevicePixelRatio)); 103 m_pIconLabel->setToolTip(m_strErrorMessage); 104 m_pIconLabel->move(width() - iIconMetric - iShift, iShift); 105 m_pIconLabel->show(); 106 } 107 else 108 { 109 /* Hide label: */ 110 if (m_pIconLabel) 111 m_pIconLabel->hide(); 112 } 101 void QILineEdit::setMarkable(bool fMarkable) 102 { 103 if (m_fMarkable == fMarkable) 104 return; 105 m_fMarkable = fMarkable; 106 update(); 113 107 } 114 108 … … 142 136 /* Call to base-class: */ 143 137 QLineEdit::resizeEvent(pResizeEvent); 138 if (m_fMarkable) 139 moveIconLabel(); 140 } 144 141 145 /* Update error label position: */ 146 if (m_pIconLabel) 147 { 148 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * .625; 149 const int iShift = height() > iIconMetric ? (height() - iIconMetric) / 2 : 0; 150 m_pIconLabel->move(width() - iIconMetric - iShift, iShift); 151 } 142 void QILineEdit::moveIconLabel() 143 { 144 AssertPtrReturnVoid(m_pIconLabel); 145 m_pIconLabel->move(width() - m_pIconLabel->width() - m_iIconMargin, m_iIconMargin); 146 } 147 148 void QILineEdit::showEvent(QShowEvent *pShowEvent) 149 { 150 /* Call to base-class: */ 151 QLineEdit::showEvent(pShowEvent); 152 if (m_fMarkable) 153 moveIconLabel(); 152 154 } 153 155 … … 171 173 } 172 174 173 /* Prepare warning icon: */174 m_ markIcon = UIIconPool::iconSet(":/status_error_16px.png");175 /* Prepare icon label: */ 176 m_pIconLabel = new QLabel(this); 175 177 } 176 178 … … 194 196 return sa; 195 197 } 196 197 UIMarkableLineEdit::UIMarkableLineEdit(QWidget *pParent /* = 0 */)198 : QLineEdit(pParent)199 , m_pIconLabel(0)200 {201 prepare();202 }203 204 void UIMarkableLineEdit::mark(bool fError, const QString &strErrorMessage, const QString &strNoErrorMessage)205 {206 AssertPtrReturnVoid(m_pIconLabel);207 const QIcon icon = fError ? UIIconPool::iconSet(":/status_error_16px.png") : UIIconPool::iconSet(":/status_check_16px.png");208 const int iIconMetric = qMin((int)(QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * .625), height());209 const qreal fDevicePixelRatio = gpDesktop->devicePixelRatio(m_pIconLabel);210 const QString strToolTip = fError ? strErrorMessage : strNoErrorMessage;211 const QPixmap iconPixmap = icon.pixmap(QSize(iIconMetric, iIconMetric), fDevicePixelRatio);212 m_pIconLabel->setPixmap(iconPixmap);213 m_pIconLabel->resize(m_pIconLabel->minimumSizeHint());214 m_pIconLabel->setToolTip(strToolTip);215 m_iIconMargin = (height() - m_pIconLabel->height()) / 2;216 update();217 }218 219 void UIMarkableLineEdit::moveIconLabel()220 {221 AssertPtrReturnVoid(m_pIconLabel);222 m_pIconLabel->move(width() - m_pIconLabel->width() - m_iIconMargin, m_iIconMargin);223 }224 225 void UIMarkableLineEdit::resizeEvent(QResizeEvent *pResizeEvent)226 {227 /* Call to base-class: */228 QLineEdit::resizeEvent(pResizeEvent);229 moveIconLabel();230 }231 232 void UIMarkableLineEdit::showEvent(QShowEvent *pShowEvent)233 {234 /* Call to base-class: */235 QLineEdit::showEvent(pShowEvent);236 moveIconLabel();237 }238 239 void UIMarkableLineEdit::prepare()240 {241 QHBoxLayout *pMainLayout = new QHBoxLayout(this);242 AssertReturnVoid(pMainLayout);243 pMainLayout->setContentsMargins(0, 0, 0, 0);244 m_pIconLabel = new QLabel(this);245 AssertReturnVoid(m_pIconLabel);246 } -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILineEdit.h
r104575 r104631 63 63 64 64 /** Puts an icon to mark some error on the right hand side of the line edit. @p is used as tooltip of the icon. */ 65 void mark(bool fError, const QString &strErrorMessage = QString()); 65 void mark(bool fError, const QString &strErrorMessage, const QString &strNoErrorMessage); 66 67 void setMarkable(bool fMarkable); 66 68 67 69 protected: … … 72 74 /** Handles resize @a pEvent. */ 73 75 virtual void resizeEvent(QResizeEvent *pResizeEvent) RT_OVERRIDE; 76 77 /** Handles show @a pEvent. */ 78 virtual void showEvent(QShowEvent *pEvent) RT_OVERRIDE; 74 79 75 80 private slots: … … 86 91 QSize fitTextWidth(const QString &strText) const; 87 92 93 /** Sets the geometry of the icon label. */ 94 void moveIconLabel(); 95 88 96 /** Holds whether this is allowed to copy contents when disabled. */ 89 97 bool m_fAllowToCopyContentsWhenDisabled; … … 92 100 93 101 QLabel *m_pIconLabel; 94 QIcon m_markIcon;95 102 bool m_fMarkForError; 103 bool m_fMarkable; 96 104 QString m_strErrorMessage; 97 }; 98 99 class SHARED_LIBRARY_STUFF UIMarkableLineEdit : public QLineEdit 100 { 101 Q_OBJECT; 102 103 signals: 104 105 106 public: 107 108 UIMarkableLineEdit(QWidget *pParent = 0); 109 void mark(bool fError, const QString &strErrorMessage, const QString &strNoErrorMessage); 110 111 /** @name Pass through functions for QILineEdit. 112 * @{ */ 113 114 115 /** @} */ 116 117 private: 118 119 /** Handles resize @a pEvent. */ 120 virtual void resizeEvent(QResizeEvent *pEvent) RT_OVERRIDE; 121 /** Handles show @a pEvent. */ 122 virtual void showEvent(QShowEvent *pEvent) RT_OVERRIDE; 123 void moveIconLabel(); 124 void prepare(); 125 126 QLabel *m_pIconLabel; 127 int m_iIconMargin; 105 int m_iIconMargin; 128 106 }; 129 107 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIFDCreationDialog.cpp
r104226 r104631 186 186 { 187 187 bool fIsFileUnique = checkFilePath(strPath); 188 m_pFilePathSelector->mark(!fIsFileUnique, tr("File already exists") );188 m_pFilePathSelector->mark(!fIsFileUnique, tr("File already exists"), tr("File path is valid")); 189 189 190 190 if (m_pButtonBox && m_pButtonBox->button(QDialogButtonBox::Ok)) -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIBootFailureDialog.cpp
r104358 r104631 244 244 bool fISOValid = checkISOImage(); 245 245 if (m_pBootImageSelector) 246 { 247 m_pBootImageSelector->mark(!fISOValid, tr("The selected path is invalid.")); 248 } 246 m_pBootImageSelector->mark(!fISOValid, tr("The selected path is invalid."), tr("The path is valid.")); 247 249 248 if (m_pResetButton) 250 249 m_pResetButton->setEnabled(fISOValid); -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.cpp
r104546 r104631 240 240 } 241 241 242 void UINameAndSystemEditor::markImageEditor(bool fError, const QString &strErrorMessage )242 void UINameAndSystemEditor::markImageEditor(bool fError, const QString &strErrorMessage, const QString &strNoErrorMessage) 243 243 { 244 244 if (m_pSelectorImage) 245 m_pSelectorImage->mark(fError, strErrorMessage );245 m_pSelectorImage->mark(fError, strErrorMessage, strNoErrorMessage); 246 246 } 247 247 … … 431 431 } 432 432 /* Prepare name editor: */ 433 m_pEditorName = new UIMarkableLineEdit(this);433 m_pEditorName = new QILineEdit(this); 434 434 if (m_pEditorName) 435 435 { 436 436 m_pLabelName->setBuddy(m_pEditorName); 437 m_pEditorName->setMarkable(true); 437 438 m_pLayout->addWidget(m_pEditorName, iRow, 1, 1, 2); 438 439 } … … 602 603 { 603 604 if (m_pEditorName) 604 connect(m_pEditorName, & UIMarkableLineEdit::textChanged,605 connect(m_pEditorName, &QILineEdit::textChanged, 605 606 this, &UINameAndSystemEditor::sigNameChanged); 606 607 if (m_pSelectorPath) -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.h
r104313 r104631 46 46 class QString; 47 47 class UIFilePathSelector; 48 class UIMarkableLineEdit;49 48 50 49 /** UIEditor sub-class providing complex editor for basic VM parameters. */ … … 131 130 /** Passes the @p fError and @a strErrorMessage to UIFilePathSelector::mark(bool) 132 131 * effectively changing the background color and error-text. */ 133 void markImageEditor(bool fError, const QString &strErrorMessage );132 void markImageEditor(bool fError, const QString &strErrorMessage, const QString &strNoErrorMessage); 134 133 135 134 /** @p names and @p indices are parallel array storing edition names and their indices, respectively.*/ … … 221 220 QLabel *m_pLabelName; 222 221 /** Holds the VM name editor instance. */ 223 UIMarkableLineEdit *m_pEditorName;222 QILineEdit *m_pEditorName; 224 223 225 224 /** Holds the VM path label instance. */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIHostnameDomainNameEditor.cpp
r104546 r104631 138 138 } 139 139 140 void UIHostnameDomainNameEditor::addLineEdit(int &iRow, QLabel *&pLabel, UIMarkableLineEdit *&pLineEdit, QGridLayout *pLayout)140 void UIHostnameDomainNameEditor::addLineEdit(int &iRow, QLabel *&pLabel, QILineEdit *&pLineEdit, QGridLayout *pLayout) 141 141 { 142 142 AssertReturnVoid(pLayout); … … 149 149 pLayout->addWidget(pLabel, iRow, 0, 1, 1); 150 150 151 pLineEdit = new UIMarkableLineEdit;151 pLineEdit = new QILineEdit; 152 152 AssertReturnVoid(pLineEdit); 153 pLineEdit->setMarkable(true); 153 154 154 155 pLayout->addWidget(pLineEdit, iRow, 1, 1, 3); … … 174 175 m_pDomainNameLineEdit->setValidator(new QRegularExpressionValidator(QRegularExpression("^[a-zA-Z0-9-.]{2,}[$a-zA-Z0-9-]"), this)); 175 176 176 connect(m_pHostnameLineEdit, & UIMarkableLineEdit::textChanged,177 connect(m_pHostnameLineEdit, &QILineEdit::textChanged, 177 178 this, &UIHostnameDomainNameEditor::sltHostnameChanged); 178 connect(m_pDomainNameLineEdit, & UIMarkableLineEdit::textChanged,179 connect(m_pDomainNameLineEdit, &QILineEdit::textChanged, 179 180 this, &UIHostnameDomainNameEditor::sltDomainChanged); 180 181 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIHostnameDomainNameEditor.h
r104546 r104631 40 40 class QLabel; 41 41 class QILineEdit; 42 class UIMarkableLineEdit;43 42 class UIPasswordLineEdit; 44 43 … … 79 78 80 79 void prepare(); 81 void addLineEdit(int &iRow, QLabel *&pLabel, UIMarkableLineEdit *&pLineEdit, QGridLayout *pLayout);80 void addLineEdit(int &iRow, QLabel *&pLabel, QILineEdit *&pLineEdit, QGridLayout *pLayout); 82 81 83 UIMarkableLineEdit *m_pHostnameLineEdit;84 UIMarkableLineEdit *m_pDomainNameLineEdit;82 QILineEdit *m_pHostnameLineEdit; 83 QILineEdit *m_pDomainNameLineEdit; 85 84 86 85 QLabel *m_pHostnameLabel; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIUserNamePasswordEditor.cpp
r104546 r104631 347 347 setLayout(pMainLayout); 348 348 int iRow = 0; 349 addLineEdit< UIMarkableLineEdit>(iRow, m_pUserNameLabel, m_pUserNameLineEdit, pMainLayout);349 addLineEdit<QILineEdit>(iRow, m_pUserNameLabel, m_pUserNameLineEdit, pMainLayout); 350 350 addLineEdit<UIPasswordLineEdit>(iRow, m_pPasswordLabel, m_pPasswordLineEdit, pMainLayout); 351 351 addLineEdit<UIPasswordLineEdit>(iRow, m_pPasswordRepeatLabel, m_pPasswordRepeatLineEdit, pMainLayout); 352 353 m_pUserNameLineEdit->setMarkable(true); 352 354 353 355 connect(m_pPasswordLineEdit, &UIPasswordLineEdit::sigTextVisibilityToggled, … … 359 361 connect(m_pPasswordRepeatLineEdit, &UIPasswordLineEdit::textChanged, 360 362 this, &UIUserNamePasswordEditor::sltPasswordChanged); 361 connect(m_pUserNameLineEdit, & UIMarkableLineEdit::textChanged,363 connect(m_pUserNameLineEdit, &QILineEdit::textChanged, 362 364 this, &UIUserNamePasswordEditor::sltUserNameChanged); 363 365 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIUserNamePasswordEditor.h
r103947 r104631 45 45 class QILineEdit; 46 46 class QIToolButton; 47 class UIMarkableLineEdit;48 47 class UIPasswordLineEdit; 49 48 … … 126 125 bool isPasswordComplete(); 127 126 128 UIMarkableLineEdit*m_pUserNameLineEdit;127 QILineEdit *m_pUserNameLineEdit; 129 128 UIPasswordLineEdit *m_pPasswordLineEdit; 130 129 UIPasswordLineEdit *m_pPasswordRepeatLineEdit; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardCloneVMEditors.cpp
r104546 r104631 75 75 QDir dir(strPath); 76 76 bool fInvalidPath = strPath.isEmpty() || !dir.exists() || !dir.isReadable(); 77 m_pPathSelector->mark(fInvalidPath, UIWizardCloneVM::tr("Path is invalid") );77 m_pPathSelector->mark(fInvalidPath, UIWizardCloneVM::tr("Path is invalid"), UIWizardCloneVM::tr("Path is valid")); 78 78 79 79 /* Check if there is already a machine folder for this name and path: */ … … 152 152 } 153 153 154 m_pNameLineEdit = new UIMarkableLineEdit();154 m_pNameLineEdit = new QILineEdit(); 155 155 if (m_pNameLineEdit) 156 156 { 157 m_pNameLineEdit->setMarkable(true); 157 158 m_pContainerLayout->addWidget(m_pNameLineEdit, 0, 1, 1, 1); 158 159 m_pNameLineEdit->setText(UIWizardCloneVM::tr("%1 Clone").arg(m_strOriginalName)); 159 connect(m_pNameLineEdit, & UIMarkableLineEdit::textChanged,160 connect(m_pNameLineEdit, &QILineEdit::textChanged, 160 161 this, &UICloneVMNamePathEditor::sigCloneNameChanged); 161 162 if (m_pNameLabel) -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardCloneVMEditors.h
r103950 r104631 48 48 class QILineEdit; 49 49 class UIFilePathSelector; 50 class UIMarkableLineEdit;51 50 52 51 /** MAC address policies. */ … … 95 94 96 95 QGridLayout *m_pContainerLayout; 97 UIMarkableLineEdit *m_pNameLineEdit;96 QILineEdit *m_pNameLineEdit; 98 97 UIFilePathSelector *m_pPathSelector; 99 98 QLabel *m_pNameLabel; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardDiskEditors.cpp
r104358 r104631 334 334 if (QFileInfo(mediumFilePath()).exists()) 335 335 { 336 m_pLocationEditor->mark(true, tr("Disk file name is not unique") );336 m_pLocationEditor->mark(true, tr("Disk file name is not unique"), tr("Disk file name is valid")); 337 337 return false; 338 338 } 339 m_pLocationEditor->mark(false); 339 m_pLocationEditor->mark(false, tr("Disk file name is not unique"), tr("Disk file name is valid")); 340 340 341 return true; 341 342 } … … 356 357 } 357 358 if (m_pLocationEditor) 359 { 360 m_pLocationEditor->setMarkable(true); 358 361 m_pLocationEditor->setToolTip(tr("Holds the location of the virtual disk file.")); 362 } 359 363 if (m_pLocationOpenButton) 360 364 m_pLocationEditor->setToolTip(tr("Opens file selection dialog so that a location for the disk file can be selected.")); -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardNewVMEditors.cpp
r103950 r104631 198 198 bool fError = !UIWizardNewVMUnattendedCommon::checkGAISOFile(path()); 199 199 if (m_pGAISOFilePathSelector) 200 m_pGAISOFilePathSelector->mark(fError, UIWizardNewVM::tr("Invalid Guest Additions installation media")); 200 m_pGAISOFilePathSelector->mark(fError, UIWizardNewVM::tr("Invalid guest additions installation media"), 201 UIWizardNewVM::tr("Guest additions installation media is valid")); 201 202 } 202 203 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMExpertPage.cpp
r103957 r104631 468 468 m_pNameAndSystemEditor->markNameEditor(m_pNameAndSystemEditor->name().isEmpty()); 469 469 m_pNameAndSystemEditor->markImageEditor(!UIWizardNewVMNameOSTypeCommon::checkISOFile(m_pNameAndSystemEditor), 470 UIWizardNewVM::tr("Invalid file path or unreadable file")); 470 UIWizardNewVM::tr("Invalid file path or unreadable file"), 471 UIWizardNewVM::tr("File path is valid")); 471 472 } 472 473 UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>(); -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMNameOSTypePage.cpp
r104358 r104631 720 720 m_pNameAndSystemEditor->markNameEditor(m_pNameAndSystemEditor->name().isEmpty()); 721 721 m_pNameAndSystemEditor->markImageEditor(!UIWizardNewVMNameOSTypeCommon::checkISOFile(m_pNameAndSystemEditor), 722 UIWizardNewVM::tr("Invalid file path or unreadable file")); 722 UIWizardNewVM::tr("Invalid file path or unreadable file"), 723 UIWizardNewVM::tr("File path is valid")); 723 724 } 724 725 }
Note:
See TracChangeset
for help on using the changeset viewer.