Changeset 106050 in vbox
- Timestamp:
- Sep 13, 2024 3:35:01 PM (3 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIStorageSettingsEditor.cpp
r106048 r106050 827 827 /** Holds the medium device type. */ 828 828 UIMediumDeviceType m_enmType; 829 };830 831 832 /** QWidget sub-class833 * 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 purely836 * for controller/attachment pane. */837 class UIWidgetOfMaximumSize : public QWidget838 {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;848 829 }; 849 830 … … 2846 2827 2847 2828 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() const2861 {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);2911 2829 } 2912 2830 … … 4608 4526 if (m_pLabelSeparatorLeftPane) 4609 4527 m_pLabelSeparatorLeftPane->setBuddy(m_pTreeViewStorage); 4528 m_pTreeViewStorage->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding); 4529 m_pTreeViewStorage->setMinimumHeight(150); 4610 4530 m_pTreeViewStorage->setMouseTracking(true); 4611 4531 m_pTreeViewStorage->setAcceptDrops(true); … … 4785 4705 { 4786 4706 /* Create widget for controller case: */ 4787 UIWidgetOfMaximumSize *pWidgetController = new UIWidgetOfMaximumSize;4707 QWidget *pWidgetController = new QWidget; 4788 4708 if (pWidgetController) 4789 4709 { … … 4864 4784 { 4865 4785 /* Create widget for attachment case: */ 4866 UIWidgetOfMaximumSize *pWidgetAttachment = new UIWidgetOfMaximumSize;4786 QWidget *pWidgetAttachment = new QWidget; 4867 4787 if (pWidgetAttachment) 4868 4788 { … … 5079 4999 if (m_pLabelCDType) 5080 5000 { 5001 m_pLabelCDType->hide(); 5081 5002 m_pLabelCDType->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 5082 5003 m_pLayoutAttachment->addWidget(m_pLabelCDType, 12, 1); … … 5086 5007 if (m_pFieldCDType) 5087 5008 { 5009 m_pFieldCDType->hide(); 5088 5010 m_pFieldCDType->setFullSizeSelection(true); 5089 5011 m_pFieldCDType->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum)); … … 5095 5017 if (m_pLabelCDSize) 5096 5018 { 5019 m_pLabelCDSize->hide(); 5097 5020 m_pLabelCDSize->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 5098 5021 m_pLayoutAttachment->addWidget(m_pLabelCDSize, 13, 1); … … 5102 5025 if (m_pFieldCDSize) 5103 5026 { 5027 m_pFieldCDSize->hide(); 5104 5028 m_pFieldCDSize->setFullSizeSelection(true); 5105 5029 m_pFieldCDSize->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum)); … … 5111 5035 if (m_pLabelCDLocation) 5112 5036 { 5037 m_pLabelCDLocation->hide(); 5113 5038 m_pLabelCDLocation->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 5114 5039 m_pLayoutAttachment->addWidget(m_pLabelCDLocation, 14, 1); … … 5118 5043 if (m_pFieldCDLocation) 5119 5044 { 5045 m_pFieldCDLocation->hide(); 5120 5046 m_pFieldCDLocation->setFullSizeSelection(true); 5121 5047 m_pFieldCDLocation->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum)); … … 5127 5053 if (m_pLabelCDUsage) 5128 5054 { 5055 m_pLabelCDUsage->hide(); 5129 5056 m_pLabelCDUsage->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 5130 5057 m_pLayoutAttachment->addWidget(m_pLabelCDUsage, 15, 1); … … 5134 5061 if (m_pFieldCDUsage) 5135 5062 { 5063 m_pFieldCDUsage->hide(); 5136 5064 m_pFieldCDUsage->setFullSizeSelection(true); 5137 5065 m_pFieldCDUsage->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum)); … … 5143 5071 if (m_pLabelFDType) 5144 5072 { 5073 m_pLabelFDType->hide(); 5145 5074 m_pLabelFDType->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 5146 5075 m_pLayoutAttachment->addWidget(m_pLabelFDType, 16, 1); … … 5150 5079 if (m_pFieldFDType) 5151 5080 { 5081 m_pFieldFDType->hide(); 5152 5082 m_pFieldFDType->setFullSizeSelection(true); 5153 5083 m_pFieldFDType->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum)); … … 5159 5089 if (m_pLabelFDSize) 5160 5090 { 5091 m_pLabelFDSize->hide(); 5161 5092 m_pLabelFDSize->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 5162 5093 m_pLayoutAttachment->addWidget(m_pLabelFDSize, 17, 1); … … 5166 5097 if (m_pFieldFDSize) 5167 5098 { 5099 m_pFieldFDSize->hide(); 5168 5100 m_pFieldFDSize->setFullSizeSelection(true); 5169 5101 m_pFieldFDSize->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum)); … … 5175 5107 if (m_pLabelFDLocation) 5176 5108 { 5109 m_pLabelFDLocation->hide(); 5177 5110 m_pLabelFDLocation->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 5178 5111 m_pLayoutAttachment->addWidget(m_pLabelFDLocation, 18, 1); … … 5182 5115 if (m_pFieldFDLocation) 5183 5116 { 5117 m_pFieldFDLocation->hide(); 5184 5118 m_pFieldFDLocation->setFullSizeSelection(true); 5185 5119 m_pFieldFDLocation->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum)); … … 5191 5125 if (m_pLabelFDUsage) 5192 5126 { 5127 m_pLabelFDUsage->hide(); 5193 5128 m_pLabelFDUsage->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 5194 5129 m_pLayoutAttachment->addWidget(m_pLabelFDUsage, 19, 1); … … 5198 5133 if (m_pFieldFDUsage) 5199 5134 { 5135 m_pFieldFDUsage->hide(); 5200 5136 m_pFieldFDUsage->setFullSizeSelection(true); 5201 5137 m_pFieldFDUsage->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum));
Note:
See TracChangeset
for help on using the changeset viewer.