VirtualBox

Changeset 90032 in vbox


Ignore:
Timestamp:
Jul 5, 2021 3:34:39 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9996: UINativeWizard: Introducing title label on other platforms as well; Before it was macOS only; That requires dimension sync with watermark pixmap.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/wizards
Files:
2 edited

Legend:

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

    r89995 r90032  
    9797    , m_iLastIndex(-1)
    9898    , m_pLabelPixmap(0)
    99 #ifdef VBOX_WS_MAC
     99    , m_pLayoutRight(0)
    100100    , m_pLabelPageTitle(0)
    101 #endif
    102101    , m_pWidgetStack(0)
    103102{
     
    233232    UINativeWizardPage *pPage = qobject_cast<UINativeWizardPage*>(m_pWidgetStack->widget(iIndex));
    234233    AssertPtrReturnVoid(pPage);
    235 #ifdef VBOX_WS_MAC
    236234    m_pLabelPageTitle->setText(pPage->title());
    237 #endif
    238235    if (iIndex > m_iLastIndex)
    239236        pPage->initializePage();
     
    345342            }
    346343
    347 #ifdef VBOX_WS_MAC
    348             /* Prepare right layout on macOS for nativity purposes: */
    349             QVBoxLayout *pLayoutRight = new QVBoxLayout;
    350             if (pLayoutRight)
     344            /* Prepare right layout: */
     345            m_pLayoutRight = new QVBoxLayout;
     346            if (m_pLayoutRight)
    351347            {
    352348                /* Prepare page title label: */
     
    360356                    m_pLabelPageTitle->setFont(labelFont);
    361357
    362                     pLayoutRight->addWidget(m_pLabelPageTitle);
     358                    m_pLayoutRight->addWidget(m_pLabelPageTitle);
    363359                }
    364360
     361#ifdef VBOX_WS_MAC
    365362                /* Prepare frame around widget-stack on macOS for nativity purposes: */
    366363                UIFrame *pFrame = new UIFrame(this);
     
    381378
    382379                    /* Add to layout: */
    383                     pLayoutRight->addWidget(pFrame);
     380                    m_pLayoutRight->addWidget(pFrame);
    384381                }
     382#else /* !VBOX_WS_MAC */
     383                /* Prepare widget-stack directly on other platforms: */
     384                m_pWidgetStack = new QStackedWidget(this);
     385                if (m_pWidgetStack)
     386                {
     387                    connect(m_pWidgetStack, &QStackedWidget::currentChanged, this, &UINativeWizard::sltCurrentIndexChanged);
     388                    m_pLayoutRight->addWidget(m_pWidgetStack);
     389                }
     390#endif /* !VBOX_WS_MAC */
    385391
    386392                /* Add to layout: */
    387                 pLayoutUpper->addLayout(pLayoutRight);
     393                pLayoutUpper->addLayout(m_pLayoutRight);
    388394            }
    389 #else /* !VBOX_WS_MAC */
    390             /* Prepare widget-stack directly on other platforms: */
    391             m_pWidgetStack = new QStackedWidget(this);
    392             if (m_pWidgetStack)
    393             {
    394                 connect(m_pWidgetStack, &QStackedWidget::currentChanged, this, &UINativeWizard::sltCurrentIndexChanged);
    395                 pLayoutUpper->addWidget(m_pWidgetStack);
    396             }
    397 #endif /* !VBOX_WS_MAC */
    398395
    399396            /* Add to layout: */
     
    504501void UINativeWizard::resizeToGoldenRatio()
    505502{
    506 #ifdef VBOX_WS_MAC
    507     /* Hide/show title label on macOS only, on Windows/X11 there is no title label. */
     503    /* Standard top margin for Basic mode case: */
     504    const int iT = m_enmMode == WizardMode_Basic
     505                 ? qApp->style()->pixelMetric(QStyle::PM_LayoutTopMargin)
     506                 : 0;
     507    m_pLayoutRight->setContentsMargins(0, iT, 0, 0);
     508    /* Show title label for Basic mode case: */
    508509    m_pLabelPageTitle->setVisible(m_enmMode == WizardMode_Basic);
    509 #else
     510#ifndef VBOX_WS_MAC
    510511    /* Hide/show pixmap label on Windows/X11 only, on macOS it's in the background: */
    511512    m_pLabelPixmap->setVisible(!m_strPixmapName.isEmpty() && m_enmMode == WizardMode_Basic);
     
    542543            if (!m_strPixmapName.isEmpty())
    543544                iWidth += 145;
     545            /* Advance height for spacing & title height: */
     546            if (m_pLayoutRight)
     547            {
     548                int iL, iT, iR, iB;
     549                m_pLayoutRight->getContentsMargins(&iL, &iT, &iR, &iB);
     550                iHeight += iT + m_pLayoutRight->spacing() + iB;
     551            }
     552            if (m_pLabelPageTitle)
     553                iHeight += m_pLabelPageTitle->minimumSizeHint().height();
    544554#endif /* !VBOX_WS_MAC */
    545555            const double dRatio = (double)iWidth / iHeight;
     
    607617    const QRgb rgbFrame = imageOld.pixel(imageOld.width() - 1, 0);
    608618
    609     /* Upscale desired height up to pixmap device pixel ratio: */
    610     const int iDesiredHeight = m_pWidgetStack->minimumSizeHint().height() * pixmapOld.devicePixelRatio();
     619    /* Compose desired height up to pixmap device pixel ratio: */
     620    int iL, iT, iR, iB;
     621    m_pLayoutRight->getContentsMargins(&iL, &iT, &iR, &iB);
     622    const int iSpacing = iT + m_pLayoutRight->spacing() + iB;
     623    const int iTitleHeight = m_pLabelPageTitle->minimumSizeHint().height();
     624    const int iStackHeight = m_pWidgetStack->minimumSizeHint().height();
     625    const int iDesiredHeight = (iTitleHeight + iSpacing + iStackHeight) * pixmapOld.devicePixelRatio();
    611626    /* Create final image on the basis of incoming, applying the rules: */
    612627    QImage imageNew(imageOld.width(), qMax(imageOld.height(), iDesiredHeight), imageOld.format());
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/UINativeWizard.h

    r89967 r90032  
    3535class QPushButton;
    3636class QStackedWidget;
     37class QVBoxLayout;
    3738class UINativeWizardPage;
    3839
     
    164165    /** Holds the pixmap label instance. */
    165166    QLabel                               *m_pLabelPixmap;
    166 #ifdef VBOX_WS_MAC
     167    /** Holds the right layout instance. */
     168    QVBoxLayout                          *m_pLayoutRight;
     169    /** Holds the title label instance. */
    167170    QLabel                               *m_pLabelPageTitle;
    168 #endif
    169171    /** Holds the widget-stack instance. */
    170172    QStackedWidget                       *m_pWidgetStack;
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