VirtualBox

Changeset 106050 in vbox


Ignore:
Timestamp:
Sep 13, 2024 3:35:01 PM (3 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10513: VM Settings / Storage page: Adjusting many layout aspects to avoid widgets/layouts jumping around while switching between controllers and various types of attachments.

File:
1 edited

Legend:

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

    r106048 r106050  
    827827    /** Holds the medium device type. */
    828828    UIMediumDeviceType  m_enmType;
    829 };
    830 
    831 
    832 /** QWidget sub-class
    833   * with manual size-hint recalculation.
    834   * Tries to take into account size-hint even for hidden items.
    835   * Assumes QGridLayout is present as this widget is used purely
    836   * for controller/attachment pane. */
    837 class UIWidgetOfMaximumSize : public QWidget
    838 {
    839     Q_OBJECT;
    840 
    841 public:
    842 
    843     /** Constructs widget passing @a pParent to base-class. */
    844     UIWidgetOfMaximumSize(QWidget *pParent = 0);
    845 
    846     /** Returns the minimum widget size. */
    847     virtual QSize minimumSizeHint() const RT_OVERRIDE;
    848829};
    849830
     
    28462827
    28472828    drawFocus(pPainter, option, rect);
    2848 }
    2849 
    2850 
    2851 /*********************************************************************************************************************************
    2852 *   Class UIWidgetOfMaximumSize implementation.                                                                                  *
    2853 *********************************************************************************************************************************/
    2854 
    2855 UIWidgetOfMaximumSize::UIWidgetOfMaximumSize(QWidget *pParent /* = 0 */)
    2856     : QWidget(pParent)
    2857 {
    2858 }
    2859 
    2860 QSize UIWidgetOfMaximumSize::minimumSizeHint() const
    2861 {
    2862     /* Assume there is just one grid-layout: */
    2863     QList<QGridLayout*> gridLayouts = findChildren<QGridLayout*>();
    2864     AssertReturn(gridLayouts.size() == 1, QWidget::minimumSizeHint());
    2865     QGridLayout *pLayout = gridLayouts.first();
    2866     AssertPtrReturn(pLayout, QWidget::minimumSizeHint());
    2867 
    2868     /* Acquire layout spacing: */
    2869     const int iSpacing = pLayout->spacing();
    2870 
    2871     /* Calcualte column widths: */
    2872     QList<int> columns(pLayout->columnCount());
    2873     for (int iColumn = 0; iColumn < pLayout->columnCount(); ++iColumn)
    2874         for (int iRow = 0; iRow < pLayout->rowCount(); ++iRow)
    2875         {
    2876             QLayoutItem *pItem = pLayout->itemAtPosition(iRow, iColumn);
    2877             if (!pItem)
    2878                 continue;
    2879             if (QWidget *pWidget = pItem->widget())
    2880             {
    2881                 const QSizePolicy sp = pWidget->sizePolicy();
    2882                 if (sp.horizontalPolicy() != QSizePolicy::Ignored)
    2883                     columns[iColumn] = qMax(columns.at(iColumn), pWidget->minimumSizeHint().width());
    2884             }
    2885         }
    2886 
    2887     /* Calcualte row heights: */
    2888     QList<int> rows(pLayout->rowCount());
    2889     for (int iRow = 0; iRow < pLayout->rowCount(); ++iRow)
    2890         for (int iColumn = 0; iColumn < pLayout->columnCount(); ++iColumn)
    2891         {
    2892             QLayoutItem *pItem = pLayout->itemAtPosition(iRow, iColumn);
    2893             if (!pItem)
    2894                 continue;
    2895             if (QWidget *pWidget = pItem->widget())
    2896             {
    2897                 const QSizePolicy sp = pWidget->sizePolicy();
    2898                 if (sp.verticalPolicy() != QSizePolicy::Ignored)
    2899                     rows[iRow] = qMax(rows.at(iRow), pWidget->minimumSizeHint().height());
    2900             }
    2901         }
    2902 
    2903     /* Calculate effective layout size: */
    2904     int iTotalWidth = 0;
    2905     for (int iColumn = 0; iColumn < columns.size(); ++iColumn)
    2906         iTotalWidth += columns.at(iColumn) + iSpacing;
    2907     int iTotalHeight = 0;
    2908     for (int iRow = 0; iRow < rows.size(); ++iRow)
    2909         iTotalHeight += rows.at(iRow) + iSpacing;
    2910     return QSize(iTotalWidth, iTotalHeight);
    29112829}
    29122830
     
    46084526        if (m_pLabelSeparatorLeftPane)
    46094527            m_pLabelSeparatorLeftPane->setBuddy(m_pTreeViewStorage);
     4528        m_pTreeViewStorage->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
     4529        m_pTreeViewStorage->setMinimumHeight(150);
    46104530        m_pTreeViewStorage->setMouseTracking(true);
    46114531        m_pTreeViewStorage->setAcceptDrops(true);
     
    47854705{
    47864706    /* Create widget for controller case: */
    4787     UIWidgetOfMaximumSize *pWidgetController = new UIWidgetOfMaximumSize;
     4707    QWidget *pWidgetController = new QWidget;
    47884708    if (pWidgetController)
    47894709    {
     
    48644784{
    48654785    /* Create widget for attachment case: */
    4866     UIWidgetOfMaximumSize *pWidgetAttachment = new UIWidgetOfMaximumSize;
     4786    QWidget *pWidgetAttachment = new QWidget;
    48674787    if (pWidgetAttachment)
    48684788    {
     
    50794999            if (m_pLabelCDType)
    50805000            {
     5001                m_pLabelCDType->hide();
    50815002                m_pLabelCDType->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    50825003                m_pLayoutAttachment->addWidget(m_pLabelCDType, 12, 1);
     
    50865007            if (m_pFieldCDType)
    50875008            {
     5009                m_pFieldCDType->hide();
    50885010                m_pFieldCDType->setFullSizeSelection(true);
    50895011                m_pFieldCDType->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum));
     
    50955017            if (m_pLabelCDSize)
    50965018            {
     5019                m_pLabelCDSize->hide();
    50975020                m_pLabelCDSize->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    50985021                m_pLayoutAttachment->addWidget(m_pLabelCDSize, 13, 1);
     
    51025025            if (m_pFieldCDSize)
    51035026            {
     5027                m_pFieldCDSize->hide();
    51045028                m_pFieldCDSize->setFullSizeSelection(true);
    51055029                m_pFieldCDSize->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum));
     
    51115035            if (m_pLabelCDLocation)
    51125036            {
     5037                m_pLabelCDLocation->hide();
    51135038                m_pLabelCDLocation->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    51145039                m_pLayoutAttachment->addWidget(m_pLabelCDLocation, 14, 1);
     
    51185043            if (m_pFieldCDLocation)
    51195044            {
     5045                m_pFieldCDLocation->hide();
    51205046                m_pFieldCDLocation->setFullSizeSelection(true);
    51215047                m_pFieldCDLocation->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum));
     
    51275053            if (m_pLabelCDUsage)
    51285054            {
     5055                m_pLabelCDUsage->hide();
    51295056                m_pLabelCDUsage->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    51305057                m_pLayoutAttachment->addWidget(m_pLabelCDUsage, 15, 1);
     
    51345061            if (m_pFieldCDUsage)
    51355062            {
     5063                m_pFieldCDUsage->hide();
    51365064                m_pFieldCDUsage->setFullSizeSelection(true);
    51375065                m_pFieldCDUsage->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum));
     
    51435071            if (m_pLabelFDType)
    51445072            {
     5073                m_pLabelFDType->hide();
    51455074                m_pLabelFDType->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    51465075                m_pLayoutAttachment->addWidget(m_pLabelFDType, 16, 1);
     
    51505079            if (m_pFieldFDType)
    51515080            {
     5081                m_pFieldFDType->hide();
    51525082                m_pFieldFDType->setFullSizeSelection(true);
    51535083                m_pFieldFDType->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum));
     
    51595089            if (m_pLabelFDSize)
    51605090            {
     5091                m_pLabelFDSize->hide();
    51615092                m_pLabelFDSize->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    51625093                m_pLayoutAttachment->addWidget(m_pLabelFDSize, 17, 1);
     
    51665097            if (m_pFieldFDSize)
    51675098            {
     5099                m_pFieldFDSize->hide();
    51685100                m_pFieldFDSize->setFullSizeSelection(true);
    51695101                m_pFieldFDSize->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum));
     
    51755107            if (m_pLabelFDLocation)
    51765108            {
     5109                m_pLabelFDLocation->hide();
    51775110                m_pLabelFDLocation->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    51785111                m_pLayoutAttachment->addWidget(m_pLabelFDLocation, 18, 1);
     
    51825115            if (m_pFieldFDLocation)
    51835116            {
     5117                m_pFieldFDLocation->hide();
    51845118                m_pFieldFDLocation->setFullSizeSelection(true);
    51855119                m_pFieldFDLocation->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum));
     
    51915125            if (m_pLabelFDUsage)
    51925126            {
     5127                m_pLabelFDUsage->hide();
    51935128                m_pLabelFDUsage->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    51945129                m_pLayoutAttachment->addWidget(m_pLabelFDUsage, 19, 1);
     
    51985133            if (m_pFieldFDUsage)
    51995134            {
     5135                m_pFieldFDUsage->hide();
    52005136                m_pFieldFDUsage->setFullSizeSelection(true);
    52015137                m_pFieldFDUsage->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum));
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