VirtualBox

Ignore:
Timestamp:
Jan 19, 2018 1:06:48 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9072: A bit of rework for UIVMLogViewerFilterPanel::prepareRadioButtonGroup(), proper prepare cascade and HiDPI awareness.

File:
1 edited

Legend:

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

    r70645 r70646  
    404404void UIVMLogViewerFilterPanel::prepareRadioButtonGroup()
    405405{
    406     m_pButtonGroup = new QButtonGroup(this);
    407     AssertPtrReturnVoid(m_pButtonGroup);
    408 
    409     m_pRadioButtonContainer = new QFrame(this);
    410     m_pRadioButtonContainer->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
     406    /* Create radio-button container: */
     407    m_pRadioButtonContainer = new QFrame;
    411408    AssertPtrReturnVoid(m_pRadioButtonContainer);
    412 
    413     QHBoxLayout* containerLayout = (new QHBoxLayout(m_pRadioButtonContainer));
    414     AssertPtrReturnVoid(containerLayout);
    415     containerLayout->setContentsMargins(0, 0, 0, 0);
    416     containerLayout->setSpacing(0);
    417 
    418     m_pAndRadioButton = new QRadioButton(this);
    419     m_pOrRadioButton =  new QRadioButton(this);
    420     AssertPtrReturnVoid(m_pAndRadioButton);
    421     AssertPtrReturnVoid(m_pOrRadioButton);
    422 
    423     m_pButtonGroup->addButton(m_pAndRadioButton, static_cast<int>(AndButton));
    424     m_pButtonGroup->addButton(m_pOrRadioButton, static_cast<int>(OrButton));
    425     m_pOrRadioButton->setText("Or");
    426     m_pAndRadioButton->setText("And");
    427     m_pOrRadioButton->setChecked(true);
     409    {
     410        /* Configure container: */
     411        m_pRadioButtonContainer->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
     412
     413        /* Create container layout: */
     414        QHBoxLayout *pContainerLayout = new QHBoxLayout(m_pRadioButtonContainer);
     415        AssertPtrReturnVoid(pContainerLayout);
     416        {
     417            /* Configure layout: */
     418#ifdef VBOX_WS_MAC
     419            pContainerLayout->setContentsMargins(5, 0, 0, 5);
     420            pContainerLayout->setSpacing(5);
     421#else
     422            pContainerLayout->setContentsMargins(qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) / 2, 0,
     423                                                 qApp->style()->pixelMetric(QStyle::PM_LayoutRightMargin) / 2, 0);
     424            pContainerLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing) / 2);
     425#endif
     426
     427            /* Create button-group: */
     428            m_pButtonGroup = new QButtonGroup(this);
     429            AssertPtrReturnVoid(m_pButtonGroup);
     430            {
     431                /* Create 'Or' radio-button: */
     432                m_pOrRadioButton = new QRadioButton;
     433                AssertPtrReturnVoid(m_pOrRadioButton);
     434                {
     435                    /* Configure radio-button: */
     436                    m_pButtonGroup->addButton(m_pOrRadioButton, static_cast<int>(OrButton));
     437                    m_pOrRadioButton->setChecked(true);
     438                    // Here goes only usual configuration, but not the NLS assignment,
     439                    // is missed 'tr' intentional? Otherwise add it and move to retranslateUi().
     440                    m_pOrRadioButton->setText("Or");
     441
     442                    /* Add into layout: */
     443                    pContainerLayout->addWidget(m_pOrRadioButton);
     444                }
     445
     446                /* Create 'And' radio-button: */
     447                m_pAndRadioButton = new QRadioButton;
     448                AssertPtrReturnVoid(m_pAndRadioButton);
     449                {
     450                    /* Configure radio-button: */
     451                    m_pButtonGroup->addButton(m_pAndRadioButton, static_cast<int>(AndButton));
     452                    // Here goes only usual configuration, but not the NLS assignment,
     453                    // is missed 'tr' intentional? Otherwise add it and move to retranslateUi().
     454                    m_pAndRadioButton->setText("And");
     455
     456                    /* Add into layout: */
     457                    pContainerLayout->addWidget(m_pAndRadioButton);
     458                }
     459            }
     460        }
     461
     462        /* Add into layout: */
     463        mainLayout()->addWidget(m_pRadioButtonContainer);
     464    }
     465
     466    /* Initialize other related stuff: */
    428467    m_eFilterOperatorButton = OrButton;
    429 
    430     containerLayout->addWidget(m_pOrRadioButton);
    431     containerLayout->addWidget(m_pAndRadioButton);
    432     mainLayout()->addWidget(m_pRadioButtonContainer);
    433468}
    434469
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