VirtualBox

Ignore:
Timestamp:
Nov 11, 2010 6:23:37 PM (14 years ago)
Author:
vboxsync
Message:

FE/Qt4-OSX: Make the settings page animation much smoother by removing the
jumping on some of the included setting pages.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/settings
Files:
5 edited

Legend:

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

    r33631 r34004  
    163163void UISettingsDialog::sltCategoryChanged(int cId)
    164164{
    165     QWidget *pRootPage = m_pSelector->rootPage(cId);
     165    int index = m_pages[cId];
    166166#ifdef Q_WS_MAC
    167167    QSize cs = size();
    168     /* First make all fully resizeable: */
    169     setMinimumSize(QSize(minimumWidth(), 0));
    170     setMaximumSize(QSize(minimumWidth(), QWIDGETSIZE_MAX));
    171     for (int i = 0; i < m_pStack->count(); ++i)
    172         m_pStack->widget(i)->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored);
    173     int a = m_pStack->indexOf(pRootPage);
    174     if (a < m_sizeList.count())
    175     {
    176         QSize ss = m_sizeList.at(a);
    177         m_pStack->widget(a)->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
     168    if (index < m_sizeList.count())
     169    {
     170        QSize ss = m_sizeList.at(index);
    178171        /* Switch to the new page first if we are shrinking: */
    179172        if (cs.height() > ss.height())
    180             m_pStack->setCurrentIndex(m_pStack->indexOf(pRootPage));
     173            m_pStack->setCurrentIndex(index);
    181174        /* Do the animation: */
    182175        ::darwinWindowAnimateResize(this, QRect (x(), y(), ss.width(), ss.height()));
    183176        /* Switch to the new page last if we are zooming: */
    184177        if (cs.height() <= ss.height())
    185             m_pStack->setCurrentIndex(m_pStack->indexOf(pRootPage));
    186         /* Make the widget fixed size: */
    187         setFixedSize(ss);
     178            m_pStack->setCurrentIndex(index);
    188179    }
    189180    ::darwinSetShowsResizeIndicator(this, false);
    190181#else
    191182    m_pLbTitle->setText(m_pSelector->itemText(cId));
    192     m_pStack->setCurrentIndex(m_pStack->indexOf(pRootPage));
     183    m_pStack->setCurrentIndex(index);
    193184#endif
    194185#ifdef VBOX_GUI_WITH_TOOLBAR_SETTINGS
     
    281272                                          cId, strLink, pSettingsPage, iParentId);
    282273    if (pPage)
    283         m_pStack->addWidget(pPage);
     274    {
     275#ifdef Q_WS_MAC
     276        /* On OSX we add a stretch to the vertical end to make sure the page is
     277         * always top aligned. */
     278        QWidget *pW = new QWidget();
     279        pW->setContentsMargins(0, 0, 0, 0);
     280        QVBoxLayout *pBox = new QVBoxLayout(pW);
     281        VBoxGlobal::setLayoutMargin(pBox, 0);
     282        pBox->addWidget(pPage);
     283        pBox->addStretch(0);
     284        m_pages[cId] = m_pStack->addWidget(pW);
     285#else /* Q_WS_MAC */
     286        m_pages[cId] = m_pStack->addWidget(pPage);
     287#endif /* !Q_WS_MAC */
     288    }
    284289    if (pSettingsPage)
    285290        assignValidator(pSettingsPage);
     
    474479    {
    475480        m_pStack->widget(i)->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
     481        /* Prevent this widgets to go in the Small/Mini size state which is
     482         * available on Mac OS X. Not sure why this happens but this seems to help
     483         * against. */
     484        QList <QWidget*> list = m_pStack->widget(i)->findChildren<QWidget*>();
     485        for (int a = 0; a < list.size(); ++a)
     486        {
     487            QWidget *w = list.at(a);
     488            if (w->parent() == m_pStack->widget(i))
     489                w->setFixedHeight(w->sizeHint().height());
     490        }
    476491        m_pStack->setCurrentIndex(i);
     492        /* Now make sure the layout is freshly calculated. */
    477493        layout()->activate();
    478494        QSize s = minimumSize();
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.h

    r33631 r34004  
    117117    QPointer<QWidget> m_pWhatsThisCandidate;
    118118
     119    QMap<int, int> m_pages;
    119120#ifdef Q_WS_MAC
    120121    QList<QSize> m_sizeList;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsAudio.ui

    r33882 r34004  
    131131     <property name="sizeHint" >
    132132      <size>
    133        <width>20</width>
    134        <height>40</height>
     133       <width>0</width>
     134       <height>0</height>
    135135      </size>
    136136     </property>
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.cpp

    r33906 r34004  
    5959    connect (mTbMAC, SIGNAL (clicked()), this, SLOT (generateMac()));
    6060    connect (mPbPortForwarding, SIGNAL (clicked()), this, SLOT (sltOpenPortForwardingDlg()));
    61 
    62 #ifdef Q_WS_MAC
    63     /* Prevent this widgets to go in the Small/Mini size state which is
    64      * available on Mac OS X. Not sure why this happens but this seems to help
    65      * against. */
    66     QList <QWidget*> list = findChildren <QWidget*>();
    67     foreach (QWidget *w, list)
    68         if (w->parent() == this)
    69             w->setFixedHeight (w->sizeHint().height());
    70 #endif /* Q_WS_MAC */
    7161
    7262    /* Applying language settings */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.cpp

    r33932 r34004  
    4747     * 1. Floppy, 2. DVD-ROM, 3. Hard Disk, 4. Network.
    4848     * But maximum boot devices count supported by machine
    49      * should be retreived through the ISystemProperties getter.
     49     * should be retrieved through the ISystemProperties getter.
    5050     * Moreover, possible boot device types are not listed in some separate Main vector,
    5151     * so we should get them (randomely?) from the list of all device types.
     
    7474    }
    7575
     76    /* Add all available devices types, so we could initially calculate the
     77     * right size. */
     78    for (int i = 0; i < m_possibleBootItems.size(); ++i)
     79    {
     80        QString name = vboxGlobal().toString(m_possibleBootItems[i]);
     81        QTreeWidgetItem *pItem = new QTreeWidgetItem(QStringList(name));
     82        pItem->setData(0, ITEM_TYPE_ROLE, QVariant(m_possibleBootItems[i]));
     83        pItem->setCheckState(0, Qt::Unchecked);
     84        mTwBootOrder->addTopLevelItem(pItem);
     85    }
     86
    7687    /* Setup validators */
    7788    mLeMemory->setValidator (new QIntValidator (mSlMemory->minRAM(), mSlMemory->maxRAM(), this));
     
    220231void UIMachineSettingsSystem::getFromCache()
    221232{
     233    /* Remove any old data in the boot view. */
     234    QAbstractItemView *iv = qobject_cast <QAbstractItemView*> (mTwBootOrder);
     235    iv->model()->removeRows(0, iv->model()->rowCount());
    222236    /* Apply internal variables data to QWidget(s): */
    223237    for (int i = 0; i < m_cache.m_bootItems.size(); ++i)
     
    246260    int iChipsetPositionPos = mCbChipset->findData(m_cache.m_chipsetType);
    247261    mCbChipset->setCurrentIndex(iChipsetPositionPos == -1 ? 0 : iChipsetPositionPos);
    248     adjustBootOrderTWSize();
    249262    if (!m_cache.m_fPFHwVirtExSupported)
    250263        mTwSystem->removeTab(2);
     
    529542    int h = 2 * mTwBootOrder->frameWidth();
    530543    int w = h;
    531 #ifdef Q_WS_MAC
    532     int left, top, right, bottom;
    533     mTwBootOrder->getContentsMargins (&left, &top, &right, &bottom);
    534     h += top + bottom;
    535     w += left + right;
    536 #else /* Q_WS_MAC */
    537     w += 4;
    538 #endif /* Q_WS_MAC */
    539     mTwBootOrder->setFixedSize (
    540         iv->sizeHintForColumn (0) + w,
    541         iv->sizeHintForRow (0) * mTwBootOrder->topLevelItemCount() + h);
     544    mTwBootOrder->setFixedSize(
     545        iv->sizeHintForColumn(0) + w,
     546        iv->sizeHintForRow(0) * mTwBootOrder->topLevelItemCount() + h);
    542547
    543548    /* Update the layout system */
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