Changeset 102526 in vbox
- Timestamp:
- Dec 7, 2023 3:19:36 PM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsPage.cpp
r101397 r102526 34 34 35 35 /* GUI includes: */ 36 #include "UICommon.h" 36 37 #include "UIConverter.h" 37 38 #include "UISettingsPage.h" … … 194 195 /* Prepare painter: */ 195 196 QPainter painter(this); 197 painter.setRenderHint(QPainter::Antialiasing); 198 painter.setRenderHint(QPainter::TextAntialiasing); 196 199 /* Avoid painting more than necessary: */ 197 200 painter.setClipRect(pPaintEvent->rect()); 198 201 199 /* Prepare palette colors: */ 200 const QPalette pal = QApplication::palette(); 201 QColor color0 = pal.color(QPalette::Window); 202 QColor color1 = pal.color(QPalette::Window).lighter(110); 203 color1.setAlpha(0); 204 QColor color2 = pal.color(QPalette::Window).darker(200); 205 206 /* Acquire contents rect: */ 207 QRect cRect = m_pWidget->geometry(); 208 const int iX = cRect.x(); 209 const int iY = cRect.y(); 210 const int iWidth = cRect.width(); 211 const int iHeight = cRect.height(); 212 213 /* Invent pixel metric: */ 214 const int iMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) / 4; 215 216 /* Top-left corner: */ 217 QRadialGradient grad1(QPointF(iX + iMetric, iY + iMetric), iMetric); 202 /* Prepare colors: */ 203 const bool fActive = window() && window()->isActiveWindow(); 204 QColor col1; 205 QColor col2; 206 if (uiCommon().isInDarkMode()) 218 207 { 219 grad1.setColorAt(0, color2);220 grad1.setColorAt(1, color1);208 col1 = qApp->palette().color(fActive ? QPalette::Active : QPalette::Inactive, QPalette::Window).lighter(130); 209 col2 = qApp->palette().color(fActive ? QPalette::Active : QPalette::Inactive, QPalette::Window).lighter(150); 221 210 } 222 /* Top-right corner: */ 223 QRadialGradient grad2(QPointF(iX + iWidth - iMetric, iY + iMetric), iMetric); 211 else 224 212 { 225 grad2.setColorAt(0, color2);226 grad2.setColorAt(1, color1);213 col1 = qApp->palette().color(fActive ? QPalette::Active : QPalette::Inactive, QPalette::Window).darker(105); 214 col2 = qApp->palette().color(fActive ? QPalette::Active : QPalette::Inactive, QPalette::Window).darker(120); 227 215 } 228 /* Bottom-left corner: */ 229 QRadialGradient grad3(QPointF(iX + iMetric, iY + iHeight - iMetric), iMetric); 230 { 231 grad3.setColorAt(0, color2); 232 grad3.setColorAt(1, color1); 233 } 234 /* Botom-right corner: */ 235 QRadialGradient grad4(QPointF(iX + iWidth - iMetric, iY + iHeight - iMetric), iMetric); 236 { 237 grad4.setColorAt(0, color2); 238 grad4.setColorAt(1, color1); 239 } 240 241 /* Top line: */ 242 QLinearGradient grad5(QPointF(iX + iMetric, iY), QPointF(iX + iMetric, iY + iMetric)); 243 { 244 grad5.setColorAt(0, color1); 245 grad5.setColorAt(1, color2); 246 } 247 /* Bottom line: */ 248 QLinearGradient grad6(QPointF(iX + iMetric, iY + iHeight), QPointF(iX + iMetric, iY + iHeight - iMetric)); 249 { 250 grad6.setColorAt(0, color1); 251 grad6.setColorAt(1, color2); 252 } 253 /* Left line: */ 254 QLinearGradient grad7(QPointF(iX, iY + iHeight - iMetric), QPointF(iX + iMetric, iY + iHeight - iMetric)); 255 { 256 grad7.setColorAt(0, color1); 257 grad7.setColorAt(1, color2); 258 } 259 /* Right line: */ 260 QLinearGradient grad8(QPointF(iX + iWidth, iY + iHeight - iMetric), QPointF(iX + iWidth - iMetric, iY + iHeight - iMetric)); 261 { 262 grad8.setColorAt(0, color1); 263 grad8.setColorAt(1, color2); 264 } 265 266 /* Paint shape/shadow: */ 267 painter.fillRect(QRect(iX + iMetric, iY + iMetric, iWidth - iMetric * 2, iHeight - iMetric * 2), color0); 268 painter.fillRect(QRect(iX, iY, iMetric, iMetric), grad1); 269 painter.fillRect(QRect(iX + iWidth - iMetric, iY, iMetric, iMetric), grad2); 270 painter.fillRect(QRect(iX, iY + iHeight - iMetric, iMetric, iMetric), grad3); 271 painter.fillRect(QRect(iX + iWidth - iMetric, iY + iHeight - iMetric, iMetric, iMetric), grad4); 272 painter.fillRect(QRect(iX + iMetric, iY, iWidth - iMetric * 2, iMetric), grad5); 273 painter.fillRect(QRect(iX + iMetric, iY + iHeight - iMetric, iWidth - iMetric * 2, iMetric), grad6); 274 painter.fillRect(QRect(iX, iY + iMetric, iMetric, iHeight - iMetric * 2), grad7); 275 painter.fillRect(QRect(iX + iWidth - iMetric, iY + iMetric, iMetric, iHeight - iMetric * 2), grad8); 216 217 /* Prepare painter path: */ 218 const QRect widgetRect = rect(); 219 QPainterPath path; 220 int iRadius = 6; 221 QSizeF arcSize(2 * iRadius, 2 * iRadius); 222 path.moveTo(widgetRect.x() + iRadius, widgetRect.y()); 223 path.arcTo(QRectF(path.currentPosition(), arcSize).translated(-iRadius, 0), 90, 90); 224 path.lineTo(path.currentPosition().x(), widgetRect.height() - iRadius); 225 path.arcTo(QRectF(path.currentPosition(), arcSize).translated(0, -iRadius), 180, 90); 226 path.lineTo(widgetRect.width() - iRadius, path.currentPosition().y()); 227 path.arcTo(QRectF(path.currentPosition(), arcSize).translated(-iRadius, -2 * iRadius), 270, 90); 228 path.lineTo(path.currentPosition().x(), widgetRect.y() + iRadius); 229 path.arcTo(QRectF(path.currentPosition(), arcSize).translated(-2 * iRadius, -iRadius), 0, 90); 230 path.closeSubpath(); 231 232 /* Painting stuff: */ 233 painter.fillPath(path, col1); 234 painter.strokePath(path, col2); 276 235 } 277 236 … … 285 244 if (pLayoutMain) 286 245 { 287 pLayoutMain->setContentsMargins(0, 0, 0, 0);288 pLayoutMain->setSpacing(0);289 290 246 /* Create name label: */ 291 247 m_pLabelName = new QLabel(this); … … 305 261 if (m_pLayout) 306 262 { 263 m_pLayout->setContentsMargins(0, 0, 0, 0); 264 307 265 m_pLayout->addWidget(m_pPage); 308 266 /// @todo what about removal handling?
Note:
See TracChangeset
for help on using the changeset viewer.