- Timestamp:
- Sep 10, 2024 2:34:51 AM (3 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/UIAdvancedSettingsDialog.cpp
r105105 r105994 89 89 QString text1() const { return m_strText1; } 90 90 /** Defines @a strText1. */ 91 void setText1(const QString &strText1) { m_strText1 = strText1; }91 void setText1(const QString &strText1); 92 92 /** Returns text 2. */ 93 93 QString text2() const { return m_strText2; } 94 94 /** Defines @a strText2. */ 95 void setText2(const QString &strText2) { m_strText2 = strText2; }95 void setText2(const QString &strText2); 96 96 97 97 protected: … … 102 102 /** Handles paint @a pEvent. */ 103 103 virtual void paintEvent(QPaintEvent *pEvent) RT_OVERRIDE; 104 105 /** Calculates and returns minimum size-hint. */ 106 virtual QSize minimumSizeHint() const RT_OVERRIDE; 104 107 105 108 private: … … 262 265 { 263 266 setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); 267 } 268 269 void UIModeCheckBox::setText1(const QString &strText1) 270 { 271 m_strText1 = strText1; 272 updateGeometry(); 273 } 274 275 void UIModeCheckBox::setText2(const QString &strText2) 276 { 277 m_strText2 = strText2; 278 updateGeometry(); 264 279 } 265 280 … … 348 363 painter.restore(); 349 364 350 /* Prepare text 1/text2: */365 /* Prepare text stuff: */ 351 366 const QFont fnt = font(); 352 367 const QFontMetrics fm(fnt); 353 368 const QColor foreground1 = suitableForegroundColor(pal, backColor1); 354 const QString strName1 = text1(); 355 const QPoint point1 = QPoint(contentRect.left() + 5 /** @todo justify! */, 369 const QColor foreground2 = suitableForegroundColor(pal, backColor2); 370 /* Calculate text1 position: */ 371 const int iMaxSpace1 = contentRect.width() / 2 - 2 * fm.height(); 372 const int iTextSize1 = fm.horizontalAdvance(m_strText1); 373 const int iIndent1 = iMaxSpace1 > iTextSize1 ? (iMaxSpace1 - iTextSize1) / 2 : 0; 374 const QPoint point1 = QPoint(contentRect.left() + 5 /* margin */ + iIndent1, 356 375 contentRect.height() / 2 + fm.ascent() / 2 - 1 /* base line */); 357 const QColor foreground2 = suitableForegroundColor(pal, backColor2); 358 const QString strName2 = text2(); 359 const QPoint point2 = QPoint(contentRect.width() / 2 + 1 + 5 /** @todo justify! */, 376 /* Calculate text2 position: */ 377 const int iMaxSpace2 = contentRect.width() / 2 - 2 * fm.height(); 378 const int iTextSize2 = fm.horizontalAdvance(m_strText2); 379 const int iIndent2 = iMaxSpace2 > iTextSize2 ? (iMaxSpace2 - iTextSize2) / 2 : 0; 380 const QPoint point2 = QPoint(contentRect.width() / 2 + iIndent2, 360 381 contentRect.height() / 2 + fm.ascent() / 2 - 1 /* base line */); 361 382 … … 364 385 painter.setFont(fnt); 365 386 painter.setPen(foreground1); 366 painter.drawText(point1, strName1);387 painter.drawText(point1, text1()); 367 388 painter.setPen(foreground2); 368 painter.drawText(point2, strName2);389 painter.drawText(point2, text2()); 369 390 painter.restore(); 391 } 392 393 QSize UIModeCheckBox::minimumSizeHint() const 394 { 395 /* Acquire metrics: */ 396 const QFontMetrics fm(font()); 397 398 /* Looking for a max text size among those two: */ 399 int iMaxLength = 0; 400 iMaxLength = qMax(iMaxLength, fm.horizontalAdvance(m_strText1)); 401 iMaxLength = qMax(iMaxLength, fm.horizontalAdvance(m_strText2)); 402 403 /* Composing result: */ 404 QSize result( 5 /* left margin */ 405 + iMaxLength + 2 /* padding */ 406 + 2 * fm.height() /* spacing */ 407 + iMaxLength + 2 /* padding */ 408 + 2 * fm.height() /* right marging */, 409 2 * fm.height() /* vertical hint */); 410 //printf("UIModeCheckBox::minimumSizeHint(%dx%d)\n", 411 // result.width(), result.height()); 412 return result; 370 413 } 371 414
Note:
See TracChangeset
for help on using the changeset viewer.