Changeset 100990 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Aug 28, 2023 3:43:56 PM (18 months ago)
- svn:sync-xref-src-repo-rev:
- 158931
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/UIAdvancedSettingsDialog.cpp
r100989 r100990 30 30 #include <QGridLayout> 31 31 #include <QLabel> 32 #include <QPainter> 32 33 #include <QProgressBar> 33 34 #include <QPushButton> … … 35 36 #include <QScrollBar> 36 37 #include <QStackedWidget> 38 #include <QStyle> 37 39 #include <QVariant> 38 40 … … 82 84 }; 83 85 86 /** QWidget sub-class, 87 * used as settings group-box. */ 88 class UISettingsGroupBox : public QWidget 89 { 90 Q_OBJECT; 91 92 public: 93 94 /** Constructs details element passing @a pParent to the base-class. */ 95 UISettingsGroupBox(QWidget *pParent = 0); 96 97 /** Defines @a strName. */ 98 void setName(const QString &strName); 99 100 /** Adds a @a pWidget into group-box. */ 101 void addWidget(QWidget *pWidget); 102 103 protected: 104 105 /** Handles paint @a pEvent. */ 106 virtual void paintEvent(QPaintEvent *pEvent) RT_OVERRIDE; 107 108 private: 109 110 /** Prepares all. */ 111 void prepare(); 112 113 /** Holds the element name.*/ 114 QString m_strName; 115 116 /** Holds the name label instance. */ 117 QLabel *m_pLabelName; 118 /** Holds the contents widget instance. */ 119 QWidget *m_pWidget; 120 /** Holds the contents layout instance. */ 121 QLayout *m_pLayout; 122 }; 123 84 124 85 125 /********************************************************************************************************************************* … … 104 144 (int)(iMinWidth / 1.6)); 105 145 return QSize(iMinWidth, iMinHeight); 146 } 147 148 149 /********************************************************************************************************************************* 150 * Class UISettingsGroupBox implementation. * 151 *********************************************************************************************************************************/ 152 153 UISettingsGroupBox::UISettingsGroupBox(QWidget *pParent /* = 0 */) 154 : QWidget(pParent) 155 , m_pLabelName(0) 156 , m_pWidget(0) 157 , m_pLayout(0) 158 { 159 prepare(); 160 } 161 162 void UISettingsGroupBox::setName(const QString &strName) 163 { 164 if (m_strName == strName) 165 return; 166 167 m_strName = strName; 168 if (m_pLabelName) 169 m_pLabelName->setText(m_strName); 170 } 171 172 void UISettingsGroupBox::addWidget(QWidget *pWidget) 173 { 174 m_pLayout->addWidget(pWidget); 175 } 176 177 void UISettingsGroupBox::paintEvent(QPaintEvent *pPaintEvent) 178 { 179 /* Prepare painter: */ 180 QPainter painter(this); 181 /* Avoid painting more than necessary: */ 182 painter.setClipRect(pPaintEvent->rect()); 183 184 /* Prepare palette colors: */ 185 const QPalette pal = QApplication::palette(); 186 QColor color0 = pal.color(QPalette::Window); 187 QColor color1 = pal.color(QPalette::Window).lighter(110); 188 color1.setAlpha(0); 189 QColor color2 = pal.color(QPalette::Window).darker(200); 190 191 /* Acquire contents rect: */ 192 QRect cRect = m_pWidget->geometry(); 193 const int iX = cRect.x(); 194 const int iY = cRect.y(); 195 const int iWidth = cRect.width(); 196 const int iHeight = cRect.height(); 197 198 /* Invent pixel metric: */ 199 const int iMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) / 4; 200 201 /* Top-left corner: */ 202 QRadialGradient grad1(QPointF(iX + iMetric, iY + iMetric), iMetric); 203 { 204 grad1.setColorAt(0, color2); 205 grad1.setColorAt(1, color1); 206 } 207 /* Top-right corner: */ 208 QRadialGradient grad2(QPointF(iX + iWidth - iMetric, iY + iMetric), iMetric); 209 { 210 grad2.setColorAt(0, color2); 211 grad2.setColorAt(1, color1); 212 } 213 /* Bottom-left corner: */ 214 QRadialGradient grad3(QPointF(iX + iMetric, iY + iHeight - iMetric), iMetric); 215 { 216 grad3.setColorAt(0, color2); 217 grad3.setColorAt(1, color1); 218 } 219 /* Botom-right corner: */ 220 QRadialGradient grad4(QPointF(iX + iWidth - iMetric, iY + iHeight - iMetric), iMetric); 221 { 222 grad4.setColorAt(0, color2); 223 grad4.setColorAt(1, color1); 224 } 225 226 /* Top line: */ 227 QLinearGradient grad5(QPointF(iX + iMetric, iY), QPointF(iX + iMetric, iY + iMetric)); 228 { 229 grad5.setColorAt(0, color1); 230 grad5.setColorAt(1, color2); 231 } 232 /* Bottom line: */ 233 QLinearGradient grad6(QPointF(iX + iMetric, iY + iHeight), QPointF(iX + iMetric, iY + iHeight - iMetric)); 234 { 235 grad6.setColorAt(0, color1); 236 grad6.setColorAt(1, color2); 237 } 238 /* Left line: */ 239 QLinearGradient grad7(QPointF(iX, iY + iHeight - iMetric), QPointF(iX + iMetric, iY + iHeight - iMetric)); 240 { 241 grad7.setColorAt(0, color1); 242 grad7.setColorAt(1, color2); 243 } 244 /* Right line: */ 245 QLinearGradient grad8(QPointF(iX + iWidth, iY + iHeight - iMetric), QPointF(iX + iWidth - iMetric, iY + iHeight - iMetric)); 246 { 247 grad8.setColorAt(0, color1); 248 grad8.setColorAt(1, color2); 249 } 250 251 /* Paint shape/shadow: */ 252 painter.fillRect(QRect(iX + iMetric, iY + iMetric, iWidth - iMetric * 2, iHeight - iMetric * 2), color0); 253 painter.fillRect(QRect(iX, iY, iMetric, iMetric), grad1); 254 painter.fillRect(QRect(iX + iWidth - iMetric, iY, iMetric, iMetric), grad2); 255 painter.fillRect(QRect(iX, iY + iHeight - iMetric, iMetric, iMetric), grad3); 256 painter.fillRect(QRect(iX + iWidth - iMetric, iY + iHeight - iMetric, iMetric, iMetric), grad4); 257 painter.fillRect(QRect(iX + iMetric, iY, iWidth - iMetric * 2, iMetric), grad5); 258 painter.fillRect(QRect(iX + iMetric, iY + iHeight - iMetric, iWidth - iMetric * 2, iMetric), grad6); 259 painter.fillRect(QRect(iX, iY + iMetric, iMetric, iHeight - iMetric * 2), grad7); 260 painter.fillRect(QRect(iX + iWidth - iMetric, iY + iMetric, iMetric, iHeight - iMetric * 2), grad8); 261 } 262 263 void UISettingsGroupBox::prepare() 264 { 265 /* Create main layout: */ 266 QVBoxLayout *pLayoutMain = new QVBoxLayout(this); 267 if (pLayoutMain) 268 { 269 pLayoutMain->setContentsMargins(0, 0, 0, 0); 270 271 /* Create name label: */ 272 m_pLabelName = new QLabel(this); 273 if (m_pLabelName) 274 pLayoutMain->addWidget(m_pLabelName); 275 276 /* Create contents widget: */ 277 m_pWidget = new QWidget(this); 278 if (m_pWidget) 279 { 280 m_pLayout = new QVBoxLayout(m_pWidget); 281 pLayoutMain->addWidget(m_pWidget); 282 } 283 } 106 284 } 107 285 … … 214 392 /* Translate warning-pane stuff: */ 215 393 m_pWarningPane->setWarningLabelText(tr("Invalid settings detected")); 394 395 /* Translate group-boxes: */ 396 foreach (int cId, m_pages.keys()) 397 m_pages.value(cId)->setName(m_pSelector->itemText(cId)); 216 398 217 399 /* Retranslate all validators: */ … … 392 574 cId, strLink, pSettingsPage, iParentId)) 393 575 { 394 /* Add page to scroll-viewport layout: */ 395 m_pScrollViewport->layout()->addWidget(pPage); 396 397 /* Remember widget for referencing: */ 398 m_pages[cId] = pPage; 576 /* Create group-box with page inside: */ 577 UISettingsGroupBox *pGroupBox = new UISettingsGroupBox(m_pScrollViewport); 578 if (pGroupBox) 579 { 580 pGroupBox->addWidget(pPage); 581 m_pScrollViewport->layout()->addWidget(pGroupBox); 582 583 /* Remember group-box for referencing: */ 584 m_pages[cId] = pGroupBox; 585 } 399 586 } 400 587 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UIAdvancedSettingsDialog.h
r100989 r100990 47 47 class QVariant; 48 48 class QIDialogButtonBox; 49 class UISettingsGroupBox; 49 50 class UISettingsPage; 50 51 class UISettingsPageValidator; … … 229 230 230 231 /** Holds the map of settings pages. */ 231 QMap<int, QWidget*> m_pages;232 QMap<int, UISettingsGroupBox*> m_pages; 232 233 233 234 /** Stores the help tag per page. */
Note:
See TracChangeset
for help on using the changeset viewer.