VirtualBox

Ignore:
Timestamp:
Jul 26, 2024 3:23:34 PM (9 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
164189
Message:

FE/Qt: bugref:10543: Name and OS Type editor: Some children can be enabled by two independent reasons and we want to actually enable them only by both.

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  
    111111        m_pLabelFamily->setEnabled(fEnabled);
    112112    if (m_pLabelDistribution)
    113         m_pLabelDistribution->setEnabled(fEnabled);
     113        setEnabledByReason(m_pLabelDistribution, 1, fEnabled);
    114114    if (m_pLabelType)
    115115        m_pLabelType->setEnabled(fEnabled);
     
    117117        m_pComboFamily->setEnabled(fEnabled);
    118118    if (m_pComboDistribution)
    119         m_pComboDistribution->setEnabled(fEnabled);
     119        setEnabledByReason(m_pComboDistribution, 1, fEnabled);
    120120    if (m_pComboType)
    121121        m_pComboType->setEnabled(fEnabled);
     
    689689                                                                       QStringList() << distribution(),
    690690                                                                       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());
    693693
    694694    /* Block signals initially and clear the combo: */
     
    830830    m_pComboType->setCurrentIndex(iChosenIndex != -1 ? iChosenIndex : 0);
    831831}
     832
     833void 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  
    184184    /** Selects preferred type. */
    185185    void selectPreferredType();
     186
     187    /** Defines whether @a pWidget @a fEnabled by reason @a uReason. */
     188    static void setEnabledByReason(QWidget *pWidget, uint uReason, bool fEnabled);
    186189
    187190    /** @name Arguments
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette