VirtualBox

Changeset 59727 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Feb 18, 2016 6:40:57 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: Qt5 migration (part 96): Preferences/Settings Dialogs: New size adjustment mechanism for Qt5, also allow to resize dialog manually for now.

File:
1 edited

Legend:

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

    r59094 r59727  
    185185    int index = m_pages[cId];
    186186#ifdef Q_WS_MAC
     187# if QT_VERSION < 0x050000
    187188    QSize cs = size();
    188189    if (index < m_sizeList.count())
     
    199200    }
    200201    ::darwinSetShowsResizeIndicator(this, false);
     202# else /* QT_VERSION >= 0x050000 */
     203    /* If index is within the stored size list bounds: */
     204    if (index < m_sizeList.count())
     205    {
     206        /* Get current/stored size: */
     207        const QSize cs = size();
     208        const QSize ss = m_sizeList.at(index);
     209
     210        /* Switch to the new page first if we are shrinking: */
     211        if (cs.height() > ss.height())
     212            m_pStack->setCurrentIndex(index);
     213
     214        /* Do the animation: */
     215        ::darwinWindowAnimateResize(this, QRect (x(), y(), ss.width(), ss.height()));
     216
     217        /* Switch to the new page last if we are zooming: */
     218        if (cs.height() <= ss.height())
     219            m_pStack->setCurrentIndex(index);
     220
     221        /* Unlock all page policies but lock the current one: */
     222        for (int i = 0; i < m_pStack->count(); ++i)
     223            m_pStack->widget(i)->setSizePolicy(QSizePolicy::Minimum, i == index ? QSizePolicy::Minimum : QSizePolicy::Ignored);
     224        /* And make sure layouts are freshly calculated: */
     225        foreach (QLayout *pLayout, findChildren<QLayout*>())
     226        {
     227            pLayout->update();
     228            pLayout->activate();
     229        }
     230    }
     231# endif /* QT_VERSION >= 0x050000 */
    201232#else
    202233    m_pLbTitle->setText(m_pSelector->itemText(cId));
     
    592623    ::darwinSetHidesAllTitleButtons(this);
    593624
     625# if QT_VERSION < 0x050000
    594626    /* Set all size policies to ignored: */
    595627    for (int i = 0; i < m_pStack->count(); ++i)
     
    618650        m_pStack->widget(i)->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored);
    619651    }
     652# else /* QT_VERSION >= 0x050000 */
     653    /* Unlock all page policies initially: */
     654    for (int i = 0; i < m_pStack->count(); ++i)
     655        m_pStack->widget(i)->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored);
     656
     657    /* Activate every single page to get the optimal size: */
     658    for (int i = m_pStack->count() - 1; i >= 0; --i)
     659    {
     660        /* Activate current page: */
     661        m_pStack->setCurrentIndex(i);
     662
     663        /* Lock current page policy temporary: */
     664        m_pStack->widget(i)->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
     665        /* And make sure layouts are freshly calculated: */
     666        foreach (QLayout *pLayout, findChildren<QLayout*>())
     667        {
     668            pLayout->update();
     669            pLayout->activate();
     670        }
     671
     672        /* Acquire minimum size-hint: */
     673        QSize s = minimumSizeHint();
     674        /* HACK ALERT!
     675         * Take into account the height of native tool-bar title.
     676         * It will be applied only after widget is really shown.
     677         * The height is 11pix * 2 (possible HiDPI support). */
     678        s.setHeight(s.height() + 11 * 2);
     679        /* Also make sure that width is no less than tool-bar: */
     680        if (iMinWidth > s.width())
     681            s.setWidth(iMinWidth);
     682        /* And remember the size finally: */
     683        m_sizeList.insert(0, s);
     684
     685        /* Unlock the policy for current page again: */
     686        m_pStack->widget(i)->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored);
     687    }
     688# endif /* QT_VERSION >= 0x050000 */
    620689
    621690    sltCategoryChanged(m_pSelector->currentId());
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