VirtualBox

Changeset 62081 in vbox for trunk


Ignore:
Timestamp:
Jul 6, 2016 5:45:23 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8399: Medium Type Change dialog cleanup/rework (part 04): Refactoring.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/UIMediumTypeChangeDialog.cpp

    r62080 r62081  
    103103        }
    104104    }
     105    AssertPtrReturnVoid(pCheckedButton);
    105106
    106107    /* Determine chosen type: */
     
    129130    /* Create main layout: */
    130131    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    131 
    132     /* Create label: */
    133     m_pLabel = new QILabel(this);
    134     /* Configure label: */
    135     m_pLabel->setWordWrap(true);
    136     m_pLabel->useSizeHintForWidth(450);
    137     m_pLabel->updateGeometry();
    138     /* Add label into main layout: */
    139     pMainLayout->addWidget(m_pLabel);
    140 
    141     /* Create group-box: */
    142     m_pGroupBox = new QGroupBox(this);
    143     /* Add group-box into main layout: */
    144     pMainLayout->addWidget(m_pGroupBox);
    145 
    146     /* Create button-box: */
    147     m_pButtonBox = new QIDialogButtonBox(this);
    148     /* Configure button-box: */
    149     m_pButtonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    150     m_pButtonBox->button(QDialogButtonBox::Ok)->setDefault(true);
    151     connect(m_pButtonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(sltAccept()));
    152     connect(m_pButtonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(sltReject()));
    153     /* Add button-box into main layout: */
    154     pMainLayout->addWidget(m_pButtonBox);
    155 
    156     /* Add a stretch to main layout: */
    157     pMainLayout->addStretch();
    158 
    159     /* Prepare radio-buttons: */
    160     prepareMediumTypeButtons();
     132    AssertPtrReturnVoid(pMainLayout);
     133    {
     134        /* Create label: */
     135        m_pLabel = new QILabel;
     136        AssertPtrReturnVoid(m_pLabel);
     137        {
     138            /* Configure label: */
     139            m_pLabel->setWordWrap(true);
     140            m_pLabel->useSizeHintForWidth(450);
     141            m_pLabel->updateGeometry();
     142        }
     143        /* Add label into main layout: */
     144        pMainLayout->addWidget(m_pLabel);
     145
     146        /* Create group-box: */
     147        m_pGroupBox = new QGroupBox;
     148        AssertPtrReturnVoid(m_pGroupBox);
     149        {
     150            /* Configure group-box: */
     151            m_pGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     152
     153            /* Prepares radio-buttons: */
     154            prepareMediumTypeButtons();
     155        }
     156        /* Add group-box into main layout: */
     157        pMainLayout->addWidget(m_pGroupBox);
     158
     159        /* Add a stretch to main layout: */
     160        pMainLayout->addStretch();
     161
     162        /* Create button-box: */
     163        m_pButtonBox = new QIDialogButtonBox;
     164        AssertPtrReturnVoid(m_pButtonBox);
     165        {
     166            /* Configure button-box: */
     167            m_pButtonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
     168            m_pButtonBox->button(QDialogButtonBox::Ok)->setDefault(true);
     169            connect(m_pButtonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(sltAccept()));
     170            connect(m_pButtonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(sltReject()));
     171        }
     172        /* Add button-box into main layout: */
     173        pMainLayout->addWidget(m_pButtonBox);
     174    }
    161175
    162176    /* Retranslate: */
    163177    retranslateUi();
    164178
     179    /* Revalidate: */
     180    sltValidate();
     181
    165182    /* Resize to minimum size: */
    166183    resize(minimumSizeHint());
     
    174191    /* Create group-box layout: */
    175192    m_pGroupBoxLayout = new QVBoxLayout(m_pGroupBox);
    176     /* Populate radio-buttons: */
    177     prepareMediumTypeButton(KMediumType_Normal);
    178     prepareMediumTypeButton(KMediumType_Immutable);
    179     prepareMediumTypeButton(KMediumType_Writethrough);
    180     prepareMediumTypeButton(KMediumType_Shareable);
    181     prepareMediumTypeButton(KMediumType_MultiAttach);
    182     /* Make sure button reflecting current type is checked: */
    183     QList<QRadioButton*> buttons = findChildren<QRadioButton*>();
    184     for (int i = 0; i < buttons.size(); ++i)
    185     {
    186         if (buttons[i]->property("mediumType").value<KMediumType>() == m_enmMediumTypeOld)
    187         {
    188             buttons[i]->setChecked(true);
    189             buttons[i]->setFocus();
    190             break;
    191         }
    192     }
    193     /* Revalidate finally: */
    194     sltValidate();
     193    AssertPtrReturnVoid(m_pGroupBoxLayout);
     194    {
     195        /* Populate radio-buttons: */
     196        prepareMediumTypeButton(KMediumType_Normal);
     197        prepareMediumTypeButton(KMediumType_Immutable);
     198        prepareMediumTypeButton(KMediumType_Writethrough);
     199        prepareMediumTypeButton(KMediumType_Shareable);
     200        prepareMediumTypeButton(KMediumType_MultiAttach);
     201        /* Make sure button reflecting current type is checked: */
     202        QList<QRadioButton*> buttons = m_pGroupBox->findChildren<QRadioButton*>();
     203        for (int i = 0; i < buttons.size(); ++i)
     204        {
     205            if (buttons[i]->property("mediumType").value<KMediumType>() == m_enmMediumTypeOld)
     206            {
     207                buttons[i]->setChecked(true);
     208                buttons[i]->setFocus();
     209                break;
     210            }
     211        }
     212    }
    195213}
    196214
     
    199217    /* Create radio-button: */
    200218    QRadioButton *pRadioButton = new QRadioButton(m_pGroupBox);
    201     /* Configure radio-button: */
    202     connect(pRadioButton, SIGNAL(clicked()), this, SLOT(sltValidate()));
    203     pRadioButton->setProperty("mediumType", QVariant::fromValue(mediumType));
     219    AssertPtrReturnVoid(pRadioButton);
     220    {
     221        /* Configure radio-button: */
     222        connect(pRadioButton, SIGNAL(clicked()), this, SLOT(sltValidate()));
     223        pRadioButton->setProperty("mediumType", QVariant::fromValue(mediumType));
     224    }
    204225    /* Add radio-button into layout: */
    205226    m_pGroupBoxLayout->addWidget(pRadioButton);
Note: See TracChangeset for help on using the changeset viewer.

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