Changeset 105524 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jul 26, 2024 3:23:34 PM (9 months ago)
- svn:sync-xref-src-repo-rev:
- 164189
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings/editors
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.cpp
r105521 r105524 111 111 m_pLabelFamily->setEnabled(fEnabled); 112 112 if (m_pLabelDistribution) 113 m_pLabelDistribution->setEnabled(fEnabled);113 setEnabledByReason(m_pLabelDistribution, 1, fEnabled); 114 114 if (m_pLabelType) 115 115 m_pLabelType->setEnabled(fEnabled); … … 117 117 m_pComboFamily->setEnabled(fEnabled); 118 118 if (m_pComboDistribution) 119 m_pComboDistribution->setEnabled(fEnabled);119 setEnabledByReason(m_pComboDistribution, 1, fEnabled); 120 120 if (m_pComboType) 121 121 m_pComboType->setEnabled(fEnabled); … … 689 689 QStringList() << distribution(), 690 690 enmArch); 691 m_pLabelDistribution->setEnabled(!distributions.isEmpty());692 m_pComboDistribution->setEnabled(!distributions.isEmpty());691 setEnabledByReason(m_pLabelDistribution, 2, !distributions.isEmpty()); 692 setEnabledByReason(m_pComboDistribution, 2, !distributions.isEmpty()); 693 693 694 694 /* Block signals initially and clear the combo: */ … … 830 830 m_pComboType->setCurrentIndex(iChosenIndex != -1 ? iChosenIndex : 0); 831 831 } 832 833 void UINameAndSystemEditor::setEnabledByReason(QWidget *pWidget, uint uReason, bool fEnabled) 834 { 835 /* Some widgets can be enabled by two independent reasons; 836 * and we want to actually enable them only by both. */ 837 838 /* Make sure passed widget is valid: */ 839 AssertPtrReturnVoid(pWidget); 840 /* Make sure uReason provided is equal to 1 or 2: */ 841 AssertReturnVoid(uReason == 1 || uReason == 2); 842 843 /* Property template: */ 844 QString strPropertyTemplate("enabledByReason_%1"); 845 846 /* Update value for passed uReason: */ 847 pWidget->setProperty(strPropertyTemplate.arg(uReason).toUtf8().constData(), fEnabled); 848 849 /* Make sure widget enabled only if requested by both reasons: */ 850 const QVariant property1 = pWidget->property(strPropertyTemplate.arg(1).toUtf8().constData()); 851 const QVariant property2 = pWidget->property(strPropertyTemplate.arg(2).toUtf8().constData()); 852 const bool fEnabledByReason1 = !property1.isValid() || property1.toBool(); 853 const bool fEnabledByReason2 = !property2.isValid() || property2.toBool(); 854 pWidget->setEnabled(fEnabledByReason1 && fEnabledByReason2); 855 } -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.h
r104631 r105524 184 184 /** Selects preferred type. */ 185 185 void selectPreferredType(); 186 187 /** Defines whether @a pWidget @a fEnabled by reason @a uReason. */ 188 static void setEnabledByReason(QWidget *pWidget, uint uReason, bool fEnabled); 186 189 187 190 /** @name Arguments
Note:
See TracChangeset
for help on using the changeset viewer.