Changeset 101333 in vbox for trunk/src/VBox
- Timestamp:
- Oct 3, 2023 2:40:43 PM (16 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIStorageSettingsEditor.cpp
r101332 r101333 42 42 #include <QMouseEvent> 43 43 #include <QPainter> 44 #include <QSizePolicy> 44 45 #include <QSpinBox> 45 46 #include <QStackedWidget> … … 818 819 /** Holds the medium device type. */ 819 820 UIMediumDeviceType m_enmType; 821 }; 822 823 824 /** QWidget sub-class 825 * with manual size-hint recalculation. 826 * Tries to take into account size-hint even for hidden items. 827 * Assumes QGridLayout is present as this widget is used purely 828 * for controller/attachment pane. */ 829 class UIWidgetOfMaximumSize : public QWidget 830 { 831 Q_OBJECT; 832 833 public: 834 835 /** Constructs widget passing @a pParent to base-class. */ 836 UIWidgetOfMaximumSize(QWidget *pParent = 0); 837 838 /** Returns the minimum widget size. */ 839 virtual QSize minimumSizeHint() const RT_OVERRIDE; 820 840 }; 821 841 … … 2829 2849 2830 2850 /********************************************************************************************************************************* 2851 * Class UIWidgetOfMaximumSize implementation. * 2852 *********************************************************************************************************************************/ 2853 2854 UIWidgetOfMaximumSize::UIWidgetOfMaximumSize(QWidget *pParent /* = 0 */) 2855 : QWidget(pParent) 2856 { 2857 } 2858 2859 QSize UIWidgetOfMaximumSize::minimumSizeHint() const 2860 { 2861 /* Assume there is just one grid-layout: */ 2862 QList<QGridLayout*> gridLayouts = findChildren<QGridLayout*>(); 2863 AssertReturn(gridLayouts.size() == 1, QWidget::minimumSizeHint()); 2864 QGridLayout *pLayout = gridLayouts.first(); 2865 AssertPtrReturn(pLayout, QWidget::minimumSizeHint()); 2866 2867 /* Acquire layout spacing: */ 2868 const int iSpacing = pLayout->spacing(); 2869 2870 /* Calcualte column widths: */ 2871 QList<int> columns(pLayout->columnCount()); 2872 for (int iColumn = 0; iColumn < pLayout->columnCount(); ++iColumn) 2873 for (int iRow = 0; iRow < pLayout->rowCount(); ++iRow) 2874 { 2875 QLayoutItem *pItem = pLayout->itemAtPosition(iRow, iColumn); 2876 if (!pItem) 2877 continue; 2878 if (QWidget *pWidget = pItem->widget()) 2879 { 2880 const QSizePolicy sp = pWidget->sizePolicy(); 2881 if (sp.horizontalPolicy() != QSizePolicy::Ignored) 2882 columns[iColumn] = qMax(columns.at(iColumn), pWidget->minimumSizeHint().width()); 2883 } 2884 } 2885 2886 /* Calcualte row heights: */ 2887 QList<int> rows(pLayout->rowCount()); 2888 for (int iRow = 0; iRow < pLayout->rowCount(); ++iRow) 2889 for (int iColumn = 0; iColumn < pLayout->columnCount(); ++iColumn) 2890 { 2891 QLayoutItem *pItem = pLayout->itemAtPosition(iRow, iColumn); 2892 if (!pItem) 2893 continue; 2894 if (QWidget *pWidget = pItem->widget()) 2895 { 2896 const QSizePolicy sp = pWidget->sizePolicy(); 2897 if (sp.verticalPolicy() != QSizePolicy::Ignored) 2898 rows[iRow] = qMax(rows.at(iRow), pWidget->minimumSizeHint().height()); 2899 } 2900 } 2901 2902 /* Calculate effective layout size: */ 2903 int iTotalWidth = 0; 2904 for (int iColumn = 0; iColumn < columns.size(); ++iColumn) 2905 iTotalWidth += columns.at(iColumn) + iSpacing; 2906 int iTotalHeight = 0; 2907 for (int iRow = 0; iRow < rows.size(); ++iRow) 2908 iTotalHeight += rows.at(iRow) + iSpacing; 2909 return QSize(iTotalWidth, iTotalHeight); 2910 } 2911 2912 2913 /********************************************************************************************************************************* 2831 2914 * Class UIStorageSettingsEditor implementation. * 2832 2915 *********************************************************************************************************************************/ … … 4541 4624 { 4542 4625 /* Create widget for controller case: */ 4543 QWidget *pWidgetController = new QWidget;4626 UIWidgetOfMaximumSize *pWidgetController = new UIWidgetOfMaximumSize; 4544 4627 if (pWidgetController) 4545 4628 { … … 4620 4703 { 4621 4704 /* Create widget for attachment case: */ 4622 QWidget *pWidgetAttachment = new QWidget;4705 UIWidgetOfMaximumSize *pWidgetAttachment = new UIWidgetOfMaximumSize; 4623 4706 if (pWidgetAttachment) 4624 4707 {
Note:
See TracChangeset
for help on using the changeset viewer.