Changeset 104585 in vbox
- Timestamp:
- May 13, 2024 11:37:59 AM (7 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/activity/overview/UIVMActivityOverviewWidget.cpp
r104393 r104585 2106 2106 int iColumnTitleWidth = m_columnTitles.value(i, QString()).length(); 2107 2107 int iMax = iColumnStringWidth > iColumnTitleWidth ? iColumnStringWidth : iColumnTitleWidth; 2108 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 2109 columnWidthsInPixels[i] = iMax * fontMetrics.horizontalAdvance('x') + 2110 #else 2111 columnWidthsInPixels[i] = iMax * fontMetrics.width('x') + 2112 #endif 2113 QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin) + 2114 QApplication::style()->pixelMetric(QStyle::PM_LayoutRightMargin) + 2115 m_iSortIndicatorWidth; 2108 columnWidthsInPixels[i] = iMax * fontMetrics.horizontalAdvance('x') 2109 + QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin) 2110 + QApplication::style()->pixelMetric(QStyle::PM_LayoutRightMargin) 2111 + m_iSortIndicatorWidth; 2116 2112 } 2117 2113 m_pTableView->setMinimumColumnWidths(columnWidthsInPixels); -
trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.cpp
r104498 r104585 660 660 else 661 661 strAxisText = QString::number(iTotalSeconds - iTimeIndex); 662 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 663 int iTextWidth = fontMetrics.horizontalAdvance(strAxisText); 664 #else 665 int iTextWidth = fontMetrics.width(strAxisText); 666 #endif 667 int iTextX = m_lineChartRect.left() + i * m_lineChartRect.width() / (float) (iXSubAxisCount + 1); 662 const int iTextWidth = fontMetrics.horizontalAdvance(strAxisText); 663 const int iTextX = m_lineChartRect.left() + i * m_lineChartRect.width() / (float) (iXSubAxisCount + 1); 668 664 if (i == 0) 669 665 { … … 816 812 font.setPixelSize(iFontSize); 817 813 --iFontSize; 818 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)819 814 } while (QFontMetrics(font).horizontalAdvance(m_strGAWarning) >= 0.8 * m_lineChartRect.width()); 820 #else821 } while (QFontMetrics(font).width(m_strGAWarning) >= 0.8 * m_lineChartRect.width());822 #endif823 815 font.setBold(true); 824 816 painter.setFont(font); … … 1233 1225 if (pLabel) 1234 1226 { 1235 QFontMetrics labelFontMetric(pLabel->font()); 1236 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 1237 int iWidth = m_iMaximumLabelLength * labelFontMetric.horizontalAdvance('X'); 1238 #else 1239 int iWidth = m_iMaximumLabelLength * labelFontMetric.width('X'); 1240 #endif 1227 const QFontMetrics labelFontMetric(pLabel->font()); 1228 const int iWidth = m_iMaximumLabelLength * labelFontMetric.horizontalAdvance('X'); 1241 1229 foreach (QLabel *pInfoLabel, m_infoLabels) 1242 1230 pInfoLabel->setFixedWidth(iWidth); -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILabel.cpp
r103362 r104585 335 335 const QString strFlat = removeHtmlTags(QString(strWork).remove(strCompact)); 336 336 /* What size will the text have without the compact text: */ 337 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)338 337 const int iFlatWidth = fm.horizontalAdvance(strFlat); 339 #else340 const int iFlatWidth = fm.width(strFlat);341 #endif342 338 /* Create the shortened text: */ 343 339 const QString strNew = fm.elidedText(strElide, toTextElideMode(strElideMode), width() - (2 * HOR_PADDING) - iFlatWidth); -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILineEdit.cpp
r104575 r104585 188 188 // The margins are based on qlineedit.cpp of Qt. 189 189 // Maybe they where changed at some time in the future. 190 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)191 190 QSize sc(fontMetrics().horizontalAdvance(strText) + 2 * 2, 192 191 fontMetrics().xHeight() + 2 * 1); 193 #else194 QSize sc(fontMetrics().width(strText) + 2 * 2,195 fontMetrics().xHeight() + 2 * 1);196 #endif197 192 const QSize sa = style()->sizeFromContents(QStyle::CT_LineEdit, &sof, sc, this); 198 193 -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp
r104450 r104585 335 335 336 336 /* Calculate width: */ 337 const int iWidth = m_iMargin + 338 pixmapSize.width() + 339 2 * m_iSpacing + 340 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 341 qMax(fm.horizontalAdvance(index.data(Field_Name).toString()), 342 fm.horizontalAdvance(index.data(Field_ID).toString())) + 343 #else 344 qMax(fm.width(index.data(Field_Name).toString()), 345 fm.width(index.data(Field_ID).toString())) + 346 #endif 347 m_iMargin; 337 const int iWidth = m_iMargin 338 + pixmapSize.width() 339 + 2 * m_iSpacing 340 + qMax(fm.horizontalAdvance(index.data(Field_Name).toString()), 341 fm.horizontalAdvance(index.data(Field_ID).toString())) 342 + m_iMargin; 348 343 /* Calculate height: */ 349 const int iHeight = m_iMargin +350 351 fm.height() + m_iSpacing + fm.height()) +352 344 const int iHeight = m_iMargin 345 + qMax(pixmapSize.height(), 346 fm.height() + m_iSpacing + fm.height()) 347 + m_iMargin; 353 348 354 349 /* Return result: */ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp
r104358 r104585 2508 2508 const int iSpinBoxEditFieldWidth = rect.width(); 2509 2509 const int iSpinBoxDelta = qMax(0, iSpinBoxWidth - iSpinBoxEditFieldWidth); 2510 QFontMetrics metrics(pSpinBox->font(), pSpinBox);2510 const QFontMetrics metrics(pSpinBox->font(), pSpinBox); 2511 2511 const QString strDummy(cCount, '0'); 2512 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)2513 2512 const int iTextWidth = metrics.horizontalAdvance(strDummy); 2514 #else2515 const int iTextWidth = metrics.width(strDummy);2516 #endif2517 2513 2518 2514 /* Tune spin-box minimum-width: */ -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpViewer.cpp
r104576 r104585 345 345 AssertReturnVoid(pLayout && m_pSearchLineEdit); 346 346 setFocusProxy(m_pSearchLineEdit); 347 QFontMetrics fontMetric(m_pSearchLineEdit->font()); 348 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 347 const QFontMetrics fontMetric(m_pSearchLineEdit->font()); 349 348 setMinimumSize(40 * fontMetric.horizontalAdvance("x"), 350 349 fontMetric.height() + 351 350 qApp->style()->pixelMetric(QStyle::PM_LayoutBottomMargin) + 352 351 qApp->style()->pixelMetric(QStyle::PM_LayoutTopMargin)); 353 354 #else355 setMinimumSize(40 * fontMetric.width("x"),356 fontMetric.height() +357 qApp->style()->pixelMetric(QStyle::PM_LayoutBottomMargin) +358 qApp->style()->pixelMetric(QStyle::PM_LayoutTopMargin));359 #endif360 352 connect(m_pSearchLineEdit, &UISearchLineEdit::textChanged, 361 353 this, &UIFindInPageWidget::sigSearchTextChanged); -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogPage.cpp
r103940 r104585 173 173 174 174 /* Compute a width for 132 characters plus scrollbar and frame width: */ 175 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 176 int iDefaultWidth = m_pTextEdit->fontMetrics().horizontalAdvance(QChar('x')) * 132 + 177 #else 178 int iDefaultWidth = m_pTextEdit->fontMetrics().width(QChar('x')) * 132 + 179 #endif 180 m_pTextEdit->verticalScrollBar()->width() + 181 m_pTextEdit->frameWidth() * 2; 175 const int iDefaultWidth = m_pTextEdit->fontMetrics().horizontalAdvance(QChar('x')) * 132 176 + m_pTextEdit->verticalScrollBar()->width() 177 + m_pTextEdit->frameWidth() * 2; 182 178 183 179 return iDefaultWidth; -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerFilterWidget.cpp
r103977 r104585 121 121 setContextMenuPolicy(Qt::NoContextMenu); 122 122 createButtons(); 123 /** Try to guess the width of the space between filter terms so that remove button 124 we display when a term is selected does not hide the next/previous word: */ 125 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 126 int spaceWidth = fontMetrics().horizontalAdvance(' '); 127 #else 128 int spaceWidth = fontMetrics().width(' '); 129 #endif 130 if (spaceWidth != 0) 131 m_iTrailingSpaceCount = (m_iRemoveTermButtonSize / spaceWidth) + 1; 123 /* Try to guess the width of the space between filter terms so that remove button 124 * we display when a term is selected does not hide the next/previous word: */ 125 const int iSpaceWidth = fontMetrics().horizontalAdvance(' '); 126 if (iSpaceWidth != 0) 127 m_iTrailingSpaceCount = (m_iRemoveTermButtonSize / iSpaceWidth) + 1; 132 128 } 133 129 … … 164 160 if (!m_pClearAllButton || !m_pRemoveTermButton) 165 161 createButtons(); 166 int clearButtonSize = height();167 168 int deltaHeight = 0.5 * (height() - m_pClearAllButton->height());162 const int iClearButtonSize = height(); 163 164 const int iDeltaHeight = 0.5 * (height() - m_pClearAllButton->height()); 169 165 #ifdef VBOX_WS_MAC 170 m_pClearAllButton->setGeometry(width() - clearButtonSize - 2, deltaHeight, clearButtonSize, clearButtonSize);166 m_pClearAllButton->setGeometry(width() - iClearButtonSize - 2, iDeltaHeight, iClearButtonSize, iClearButtonSize); 171 167 #else 172 m_pClearAllButton->setGeometry(width() - clearButtonSize - 1, deltaHeight, clearButtonSize, clearButtonSize);168 m_pClearAllButton->setGeometry(width() - iClearButtonSize - 1, iDeltaHeight, iClearButtonSize, iClearButtonSize); 173 169 #endif 174 170 … … 177 173 if (hasSelectedText()) 178 174 { 179 //int deltaHeight = 0.5 * (height() - m_pClearAllButton->height());180 175 m_pRemoveTermButton->show(); 181 int buttonSize = m_iRemoveTermButtonSize; 182 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 183 int charWidth = fontMetrics().horizontalAdvance('x'); 176 const int iButtonSize = m_iRemoveTermButtonSize; 177 const int iCharWidth = fontMetrics().horizontalAdvance('x'); 178 #ifdef VBOX_WS_MAC 179 int iButtonLeft = cursorRect().left() + 1; 184 180 #else 185 int charWidth = fontMetrics().width('x');181 int iButtonLeft = cursorRect().right() - 0.9 * iCharWidth; 186 182 #endif 187 #ifdef VBOX_WS_MAC 188 int buttonLeft = cursorRect().left() + 1; 189 #else 190 int buttonLeft = cursorRect().right() - 0.9 * charWidth; 191 #endif 192 /* If buttonLeft is in far right of the line edit, move the 183 /* If iButtonLeft is in far right of the line edit, move the 193 184 button to left side of the selected word: */ 194 if ( buttonLeft + buttonSize >= width() - clearButtonSize)195 { 196 int selectionWidth = charWidth * selectedText().length();197 buttonLeft -= (selectionWidth + buttonSize);198 } 199 m_pRemoveTermButton->setGeometry( buttonLeft, deltaHeight, buttonSize, buttonSize);185 if (iButtonLeft + iButtonSize >= width() - iClearButtonSize) 186 { 187 const int iSelectionWidth = iCharWidth * selectedText().length(); 188 iButtonLeft -= (iSelectionWidth + iButtonSize); 189 } 190 m_pRemoveTermButton->setGeometry(iButtonLeft, iDeltaHeight, iButtonSize, iButtonSize); 200 191 } 201 192 else -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.cpp
r103988 r104585 356 356 return 0; 357 357 358 int digits = 1; 359 int max = qMax(1, blockCount()); 360 while (max >= 10) { 361 max /= 10; 362 ++digits; 363 } 364 365 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 366 int space = 3 + fontMetrics().horizontalAdvance(QLatin1Char('9')) * digits; 367 #else 368 int space = 3 + fontMetrics().width(QLatin1Char('9')) * digits; 369 #endif 370 371 return space; 358 int iDigits = 1; 359 int iMax = qMax(1, blockCount()); 360 while (iMax >= 10) { 361 iMax /= 10; 362 ++iDigits; 363 } 364 365 return 3 + fontMetrics().horizontalAdvance(QLatin1Char('9')) * iDigits; 372 366 } 373 367 -
trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerWidget.cpp
r104393 r104585 242 242 return 0; 243 243 /* Compute a width for 132 characters plus scrollbar and frame width: */ 244 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 245 int iDefaultWidth = pBrowser->fontMetrics().horizontalAdvance(QChar('x')) * 132 + 246 #else 247 int iDefaultWidth = pBrowser->fontMetrics().width(QChar('x')) * 132 + 248 #endif 249 pBrowser->verticalScrollBar()->width() + 250 pBrowser->frameWidth() * 2; 244 const int iDefaultWidth = pBrowser->fontMetrics().horizontalAdvance(QChar('x')) * 132 245 + pBrowser->verticalScrollBar()->width() 246 + pBrowser->frameWidth() * 2; 251 247 252 248 return iDefaultWidth; -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.cpp
r104251 r104585 585 585 586 586 /* Return text size, based on font-metrics: */ 587 QFontMetrics fm(font, pPaintDevice); 588 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 587 const QFontMetrics fm(font, pPaintDevice); 589 588 return QSize(fm.horizontalAdvance(strText), fm.height()); 590 #else591 return QSize(fm.width(strText), fm.height());592 #endif593 589 } 594 590 … … 597 593 { 598 594 /* Return text width: */ 599 QFontMetrics fm(font, pPaintDevice);595 const QFontMetrics fm(font, pPaintDevice); 600 596 QString strString; 601 597 strString.fill('_', iCount); 602 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)603 598 return fm.horizontalAdvance(strString); 604 #else605 return fm.width(strString);606 #endif607 599 } 608 600 … … 615 607 616 608 /* Check if passed text fits maximum width: */ 617 QFontMetrics fm(font, pPaintDevice); 618 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 609 const QFontMetrics fm(font, pPaintDevice); 619 610 if (fm.horizontalAdvance(strText) <= iWidth) 620 #else621 if (fm.width(strText) <= iWidth)622 #endif623 611 return strText; 624 612 625 613 /* Truncate otherwise: */ 626 QString strEllipsis = QString("..."); 627 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 628 int iEllipsisWidth = fm.horizontalAdvance(strEllipsis + " "); 614 const QString strEllipsis = QString("..."); 615 const int iEllipsisWidth = fm.horizontalAdvance(strEllipsis + " "); 629 616 while (!strText.isEmpty() && fm.horizontalAdvance(strText) + iEllipsisWidth > iWidth) 630 617 strText.truncate(strText.size() - 1); 631 #else632 int iEllipsisWidth = fm.width(strEllipsis + " ");633 while (!strText.isEmpty() && fm.width(strText) + iEllipsisWidth > iWidth)634 strText.truncate(strText.size() - 1);635 #endif636 618 return strText + strEllipsis; 637 619 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGlobal.cpp
r104313 r104585 516 516 QPaintDevice *pPaintDevice = model()->paintDevice(); 517 517 const QFontMetrics fm(m_nameFont, pPaintDevice); 518 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)519 518 const int iMinimumNameWidth = fm.horizontalAdvance(compressText(m_nameFont, pPaintDevice, name(), 520 519 textWidth(m_nameFont, pPaintDevice, 15))); 521 #else522 const int iMinimumNameWidth = fm.width(compressText(m_nameFont, pPaintDevice, name(), textWidth(m_nameFont, pPaintDevice, 15)));523 #endif524 520 525 521 /* Is there something changed? */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.cpp
r104313 r104585 1562 1562 1563 1563 /* Prepare variables: */ 1564 int iHeaderSpacing = data(GroupItemData_HeaderSpacing).toInt();1564 const int iHeaderSpacing = data(GroupItemData_HeaderSpacing).toInt(); 1565 1565 1566 1566 /* Calculate minimum visible name size: */ 1567 1567 QPaintDevice *pPaintDevice = model()->paintDevice(); 1568 QFontMetrics fm(m_nameFont, pPaintDevice); 1569 int iMaximumNameWidth = textWidth(m_nameFont, pPaintDevice, 20); 1570 QString strCompressedName = compressText(m_nameFont, pPaintDevice, name(), iMaximumNameWidth); 1571 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 1572 int iMinimumNameWidth = fm.horizontalAdvance(strCompressedName); 1573 #else 1574 int iMinimumNameWidth = fm.width(strCompressedName); 1575 #endif 1576 int iMinimumNameHeight = fm.height(); 1568 const QFontMetrics fm(m_nameFont, pPaintDevice); 1569 const int iMaximumNameWidth = textWidth(m_nameFont, pPaintDevice, 20); 1570 const QString strCompressedName = compressText(m_nameFont, pPaintDevice, name(), iMaximumNameWidth); 1571 const int iMinimumNameWidth = fm.horizontalAdvance(strCompressedName); 1572 const int iMinimumNameHeight = fm.height(); 1577 1573 1578 1574 /* Calculate minimum width: */ … … 1611 1607 1612 1608 /* Calculate new minimum header size: */ 1613 QSize minimumHeaderSize = QSize(iHeaderWidth, iHeaderHeight);1609 const QSize minimumHeaderSize = QSize(iHeaderWidth, iHeaderHeight); 1614 1610 1615 1611 /* Is there something changed? */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemMachine.cpp
r104313 r104585 776 776 /* Calculate new minimum name width: */ 777 777 QPaintDevice *pPaintDevice = model()->paintDevice(); 778 QFontMetrics fm(m_nameFont, pPaintDevice); 779 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 780 int iMinimumNameWidth = fm.horizontalAdvance(compressText(m_nameFont, pPaintDevice, name(), 781 textWidth(m_nameFont, pPaintDevice, 15))); 782 #else 783 int iMinimumNameWidth = fm.width(compressText(m_nameFont, pPaintDevice, name(), textWidth(m_nameFont, pPaintDevice, 15))); 784 #endif 778 const QFontMetrics fm(m_nameFont, pPaintDevice); 779 const int iMinimumNameWidth = fm.horizontalAdvance(compressText(m_nameFont, pPaintDevice, name(), 780 textWidth(m_nameFont, pPaintDevice, 15))); 785 781 786 782 /* Is there something changed? */ … … 801 797 && !cache()->toLocal()->snapshotName().isEmpty()) 802 798 { 803 QFontMetrics fm(m_snapshotNameFont, model()->paintDevice()); 804 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 805 int iBracketWidth = fm.horizontalAdvance("()"); /* bracket width */ 806 int iActualTextWidth = fm.horizontalAdvance(cache()->toLocal()->snapshotName()); /* snapshot-name width */ 807 int iMinimumTextWidth = fm.horizontalAdvance("..."); /* ellipsis width */ 808 #else 809 int iBracketWidth = fm.width("()"); /* bracket width */ 810 int iActualTextWidth = fm.width(cache()->toLocal()->snapshotName()); /* snapshot-name width */ 811 int iMinimumTextWidth = fm.width("..."); /* ellipsis width */ 812 #endif 799 const QFontMetrics fm(m_snapshotNameFont, model()->paintDevice()); 800 const int iBracketWidth = fm.horizontalAdvance("()"); /* bracket width */ 801 const int iActualTextWidth = fm.horizontalAdvance(cache()->toLocal()->snapshotName()); /* snapshot-name width */ 802 const int iMinimumTextWidth = fm.horizontalAdvance("..."); /* ellipsis width */ 813 803 iMinimumSnapshotNameWidth = iBracketWidth + qMin(iActualTextWidth, iMinimumTextWidth); 814 804 } … … 897 887 898 888 /* Calculate new visible snapshot-name: */ 899 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 900 int iBracketWidth = QFontMetrics(m_snapshotNameFont, pPaintDevice).horizontalAdvance("()"); 901 #else 902 int iBracketWidth = QFontMetrics(m_snapshotNameFont, pPaintDevice).width("()"); 903 #endif 889 const int iBracketWidth = QFontMetrics(m_snapshotNameFont, pPaintDevice).horizontalAdvance("()"); 904 890 QString strVisibleSnapshotName = compressText(m_snapshotNameFont, pPaintDevice, cache()->toLocal()->snapshotName(), 905 891 m_iMaximumSnapshotNameWidth - iBracketWidth); 906 892 strVisibleSnapshotName = QString("(%1)").arg(strVisibleSnapshotName); 907 QSize visibleSnapshotNameSize = textSize(m_snapshotNameFont, pPaintDevice, strVisibleSnapshotName);893 const QSize visibleSnapshotNameSize = textSize(m_snapshotNameFont, pPaintDevice, strVisibleSnapshotName); 908 894 909 895 /* Update linked values: */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsElement.cpp
r104393 r104585 360 360 /* Cache name: */ 361 361 m_strName = strName; 362 QFontMetrics fm(m_nameFont, model()->paintDevice()); 363 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 362 const QFontMetrics fm(m_nameFont, model()->paintDevice()); 364 363 m_nameSize = QSize(fm.horizontalAdvance(m_strName), fm.height()); 365 #else366 m_nameSize = QSize(fm.width(m_strName), fm.height());367 #endif368 364 369 365 /* Update linked values: */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsItem.cpp
r101560 r104585 645 645 const int iWidthOf15Letters = textWidthMonospace(m_nameFont, pPaintDevice, 15); 646 646 const QString strNameCompressedTo15Letters = compressText(m_nameFont, pPaintDevice, m_strName, iWidthOf15Letters); 647 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)648 647 const QSize minimumNameSize = QSize(fm.horizontalAdvance(strNameCompressedTo15Letters), fm.height()); 649 #else650 const QSize minimumNameSize = QSize(fm.width(strNameCompressedTo15Letters), fm.height());651 #endif652 648 653 649 /* Update linked values: */ … … 700 696 { 701 697 /* Return text width, based on font-metrics: */ 702 QFontMetrics fm(font, pPaintDevice);698 const QFontMetrics fm(font, pPaintDevice); 703 699 QString strString; 704 700 strString.fill('_', iCount); 705 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)706 701 return fm.horizontalAdvance(strString); 707 #else708 return fm.width(strString);709 #endif710 702 } 711 703 … … 718 710 719 711 /* Check if passed text already fits maximum width: */ 720 QFontMetrics fm(font, pPaintDevice); 721 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 712 const QFontMetrics fm(font, pPaintDevice); 722 713 if (fm.horizontalAdvance(strText) <= iWidth) 723 #else724 if (fm.width(strText) <= iWidth)725 #endif726 714 return strText; 727 715 728 716 /* Truncate otherwise: */ 729 QString strEllipsis = QString("..."); 730 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 731 int iEllipsisWidth = fm.horizontalAdvance(strEllipsis + " "); 717 const QString strEllipsis = QString("..."); 718 const int iEllipsisWidth = fm.horizontalAdvance(strEllipsis + " "); 732 719 while (!strText.isEmpty() && fm.horizontalAdvance(strText) + iEllipsisWidth > iWidth) 733 720 strText.truncate(strText.size() - 1); 734 #else735 int iEllipsisWidth = fm.width(strEllipsis + " ");736 while (!strText.isEmpty() && fm.width(strText) + iEllipsisWidth > iWidth)737 strText.truncate(strText.size() - 1);738 #endif739 721 return strText + strEllipsis; 740 722 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationConfiguration.cpp
r104530 r104585 244 244 const QFontMetrics &fontMetrics, int &iMaxColumn1Length) 245 245 { 246 int iRow = m_pTableWidget->rowCount();246 const int iRow = m_pTableWidget->rowCount(); 247 247 m_pTableWidget->insertRow(iRow); 248 248 m_pTableWidget->setRowHeight(iRow, fontMetrics.height() + m_iRowTopMargin + m_iRowBottomMargin); 249 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)250 249 iMaxColumn1Length = qMax(iMaxColumn1Length, fontMetrics.horizontalAdvance(strText1)); 251 #else252 iMaxColumn1Length = qMax(iMaxColumn1Length, fontMetrics.width(strText1));253 #endif254 250 m_pTableWidget->setItem(iRow, 1, new QITableWidgetItem(strText1)); 255 251 m_pTableWidget->setItem(iRow, 2, new QITableWidgetItem(strText2)); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationRuntime.cpp
r104530 r104585 221 221 strLongest = strLabel; 222 222 } 223 QFontMetrics fontMetrics(font()); 224 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 223 const QFontMetrics fontMetrics(font()); 225 224 setColumnWidth(0, 1.5 * fontMetrics.horizontalAdvance(*strLongest)); 226 #else227 setColumnWidth(0, 1.5 * fontMetrics.width(*strLongest));228 #endif229 225 230 226 /* Make the API calls and populate the table: */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UISerialSettingsEditor.cpp
r104313 r104585 364 364 if (m_pLabelIRQ) 365 365 m_pLabelIRQ->setBuddy(m_pLineEditIRQ); 366 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)367 366 m_pLineEditIRQ->setFixedWidth(m_pLineEditIRQ->fontMetrics().horizontalAdvance("8888")); 368 #else369 m_pLineEditIRQ->setFixedWidth(m_pLineEditIRQ->fontMetrics().width("8888"));370 #endif371 367 m_pLineEditIRQ->setValidator(new QIULongValidator(0, 255, this)); 372 368 pLayoutPortSettings->addWidget(m_pLineEditIRQ, 0, 3); … … 382 378 if (m_pLabelIOAddress) 383 379 m_pLabelIOAddress->setBuddy(m_pLineEditIOAddress); 384 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)385 380 m_pLineEditIOAddress->setFixedWidth(m_pLineEditIOAddress->fontMetrics().horizontalAdvance("8888888")); 386 #else387 m_pLineEditIOAddress->setFixedWidth(m_pLineEditIOAddress->fontMetrics().width("8888888"));388 #endif389 381 m_pLineEditIOAddress->setValidator(new QIULongValidator(0, 0xFFFF, this)); 390 382 pLayoutPortSettings->addWidget(m_pLineEditIOAddress, 0, 5); -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UISharedFoldersEditor.cpp
r104313 r104585 186 186 return; 187 187 const QFontMetrics fm = treeWidget()->fontMetrics(); 188 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)189 188 const int iOldSize = fm.horizontalAdvance(strOneString); 190 #else191 const int iOldSize = fm.width(strOneString);192 #endif193 189 const int iItemIndent = parentItem() ? treeWidget()->indentation() * 2 : treeWidget()->indentation(); 194 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)195 190 int iIndentSize = fm.horizontalAdvance(" ... "); 196 #else197 int iIndentSize = fm.width(" ... ");198 #endif199 191 if (iColumn == 0) 200 192 iIndentSize += iItemIndent; … … 208 200 do 209 201 { 210 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)211 202 iTextWidth = fm.horizontalAdvance(strOneString); 212 #else213 iTextWidth = fm.width(strOneString);214 #endif215 203 if ( iTextWidth 216 204 && iTextWidth + iIndentSize > cWidth) … … 256 244 if (iPosition || m_enmFormat == FormatType_EllipsisFile) 257 245 strOneString.insert(iPosition, "..."); 258 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)259 246 const int iNewSize = fm.horizontalAdvance(strOneString); 260 #else261 const int iNewSize = fm.width(strOneString);262 #endif263 247 setText(iColumn, iNewSize < iOldSize ? strOneString : m_fields.at(iColumn)); 264 248 setToolTip(iColumn, text(iColumn) == getText(iColumn) ? QString() : getText(iColumn)); 265 249 266 250 /* Calculate item's size-hint: */ 267 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)268 251 setSizeHint(iColumn, QSize(fm.horizontalAdvance(QString(" %1 ").arg(getText(iColumn))), fm.height())); 269 #else270 setSizeHint(iColumn, QSize(fm.width(QString(" %1 ").arg(getText(iColumn))), fm.height()));271 #endif272 252 } 273 253 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIStorageSettingsEditor.cpp
r104313 r104585 2791 2791 QFont font = pModel->data(index, Qt::FontRole).value<QFont>(); 2792 2792 QFontMetrics fm(font); 2793 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)2794 2793 while ((strShortText.size() > 1) && (fm.horizontalAdvance(strShortText) + fm.horizontalAdvance("...") > iTextWidth)) 2795 #else2796 while ((strShortText.size() > 1) && (fm.width(strShortText) + fm.width("...") > iTextWidth))2797 #endif2798 2794 strShortText.truncate(strShortText.size() - 1); 2799 2795 if (strShortText != strText) -
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
r104358 r104585 2107 2107 painterFont.setBold(true); 2108 2108 painter.setFont(painterFont); 2109 QFontMetrics fontMetrics = painter.fontMetrics(); 2110 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 2111 int iMargin = 0.25 * fontMetrics.horizontalAdvance('X'); 2112 #else 2113 int iMargin = 0.25 * fontMetrics.width('X'); 2114 #endif 2109 const QFontMetrics fontMetrics = painter.fontMetrics(); 2110 const int iMargin = 0.25 * fontMetrics.horizontalAdvance('X'); 2115 2111 2116 2112 int iTopWidth = 0; … … 2125 2121 #endif 2126 2122 foreach (const QString &strPart, strList) 2127 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)2128 2123 iTopWidth = qMax(iTopWidth, fontMetrics.horizontalAdvance(strPart)); 2129 #else2130 iTopWidth = qMax(iTopWidth, fontMetrics.width(strPart));2131 #endif2132 2124 strList.clear(); 2133 2125 #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) … … 2141 2133 int iBottomWidth = 0; 2142 2134 foreach (const QString &strPart, strList) 2143 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)2144 2135 iBottomWidth = qMax(iBottomWidth, fontMetrics.horizontalAdvance(strPart)); 2145 #else2146 iBottomWidth = qMax(iBottomWidth, fontMetrics.width(strPart));2147 #endif2148 2136 int iTextWidth = 2 * iMargin + qMax(iTopWidth, iBottomWidth); 2149 2137 int iTextHeight = 0; … … 2170 2158 } 2171 2159 2172 QFontMetrics fontMetrics = painter.fontMetrics(); 2173 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 2174 int iMargin = 0.25 * fontMetrics.horizontalAdvance('X'); 2175 #else 2176 int iMargin = 0.25 * fontMetrics.width('X'); 2177 #endif 2160 const QFontMetrics fontMetrics = painter.fontMetrics(); 2161 const int iMargin = 0.25 * fontMetrics.horizontalAdvance('X'); 2178 2162 QRect textRect; 2179 2163 if (key.keyboardRegion() == KeyboardRegion_MultimediaKeys) -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIFilePathSelector.cpp
r104358 r104585 498 498 return strFullText; 499 499 500 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 501 int iOldSize = fontMetrics().horizontalAdvance(strFullText); 502 int iIndentSize = fontMetrics().horizontalAdvance("x...x"); 503 #else 504 int iOldSize = fontMetrics().width(strFullText); 505 int iIndentSize = fontMetrics().width("x...x"); 506 #endif 500 const int iOldSize = fontMetrics().horizontalAdvance(strFullText); 501 const int iIndentSize = fontMetrics().horizontalAdvance("x...x"); 507 502 508 503 /* Compress text: */ … … 512 507 int iTextWidth = 0; 513 508 do { 514 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)515 509 iTextWidth = fontMetrics().horizontalAdvance(strFullText); 516 #else517 iTextWidth = fontMetrics().width(strFullText);518 #endif519 510 if (iTextWidth + iIndentSize > iWidth) 520 511 { … … 538 529 539 530 strFullText.insert(iPosition, "..."); 540 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 541 int newSize = fontMetrics().horizontalAdvance(strFullText); 542 #else 543 int newSize = fontMetrics().width(strFullText); 544 #endif 531 const int newSize = fontMetrics().horizontalAdvance(strFullText); 545 532 546 533 return newSize < iOldSize ? strFullText : fullPath(false); -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIFileTableNavigationWidget.cpp
r103711 r104585 166 166 if (i < folderList.size() - 1) 167 167 { 168 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)169 168 iWidth += fontMetrics().horizontalAdvance(" > "); 170 #else171 iWidth += fontMetrics().width(" > ");172 #endif173 169 strWord.append("<b> > </b>"); 174 170 } 175 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)176 171 iWidth += fontMetrics().horizontalAdvance(strFolder); 177 #else178 iWidth += fontMetrics().width(strFolder);179 #endif180 172 181 173 if (iWidth < width()) -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPortForwardingTable.cpp
r104358 r104585 774 774 case UIPortForwardingDataType_GuestIp: 775 775 { 776 QFontMetrics fm = qobject_cast<QWidget*>(parent())->fontMetrics(); 777 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 776 const QFontMetrics fm = qobject_cast<QWidget*>(parent())->fontMetrics(); 778 777 return QSize(fm.horizontalAdvance(" 888.888.888.888 "), fm.height()); 779 #else780 return QSize(fm.width(" 888.888.888.888 "), fm.height());781 #endif782 778 } 783 779 default: return QVariant(); -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UISearchLineEdit.cpp
r98103 r104585 57 57 /* Draw the total match count and the current scrolled item's index on the right hand side of the line edit: */ 58 58 QPainter painter(this); 59 QFont pfont = font(); 60 QString strText = QString("%1/%2").arg(QString::number(m_iScrollToIndex + 1)).arg(QString::number(m_iMatchCount)); 61 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 62 QSize textSize(QApplication::fontMetrics().horizontalAdvance(strText), 63 QApplication::fontMetrics().height()); 64 #else 65 QSize textSize(QApplication::fontMetrics().width(strText), 66 QApplication::fontMetrics().height()); 67 #endif 59 const QFont pfont = font(); 60 const QString strText = QString("%1/%2").arg(QString::number(m_iScrollToIndex + 1)).arg(QString::number(m_iMatchCount)); 61 const QSize textSize(QApplication::fontMetrics().horizontalAdvance(strText), 62 QApplication::fontMetrics().height()); 68 63 69 64 /* Dont draw anything if we dont have enough space: */ 70 65 if (textSize.width() > 0.5 * width()) 71 66 return; 72 int iTopMargin = (height() - textSize.height()) / 2;73 int iRightMargin = iTopMargin;67 const int iTopMargin = (height() - textSize.height()) / 2; 68 const int iRightMargin = iTopMargin; 74 69 75 70 QColor fontColor(Qt::black); -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsTextPane.cpp
r103795 r104585 206 206 foreach (const UITextTableLine &line, m_text) 207 207 { 208 bool fRightColumnPresent = !line.string2().isEmpty();208 const bool fRightColumnPresent = !line.string2().isEmpty(); 209 209 if (fRightColumnPresent) 210 210 fSingleColumnText = false; 211 QString strLeftLine = fRightColumnPresent ? line.string1() + ":" : line.string1(); 212 QString strRightLine = line.string2(); 213 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) 211 const QString strLeftLine = fRightColumnPresent ? line.string1() + ":" : line.string1(); 212 const QString strRightLine = line.string2(); 214 213 iMaximumLeftColumnWidth = qMax(iMaximumLeftColumnWidth, fm.horizontalAdvance(strLeftLine)); 215 214 iMaximumRightColumnWidth = qMax(iMaximumRightColumnWidth, fm.horizontalAdvance(strRightLine)); 216 #else217 iMaximumLeftColumnWidth = qMax(iMaximumLeftColumnWidth, fm.width(strLeftLine));218 iMaximumRightColumnWidth = qMax(iMaximumRightColumnWidth, fm.width(strRightLine));219 #endif220 215 } 221 216 iMaximumLeftColumnWidth += 1; … … 521 516 QRect symbolRect = QRect(layoutPosition.x() + linePosition.x() + iSymbolX, 522 517 layoutPosition.y() + linePosition.y(), 523 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)524 518 fm.horizontalAdvance(strLayoutText[iTextPosition]) + 1, 525 #else526 fm.width(strLayoutText[iTextPosition]) + 1,527 #endif528 519 fm.height()); 529 520 formatRegion += symbolRect; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVMPageSource.cpp
r104568 r104585 357 357 * horizontally and 8 lines vertically: */ 358 358 const QFontMetrics fm(m_pSourceInstanceList->font()); 359 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)360 359 const int iFontWidth = fm.horizontalAdvance('x'); 361 #else362 const int iFontWidth = fm.width('x');363 #endif364 360 const int iTotalWidth = 50 * iFontWidth; 365 361 const int iFontHeight = fm.height(); -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageExpert.cpp
r104559 r104585 227 227 m_pProfileInstanceLabel->setBuddy(m_pProfileInstanceLabel); 228 228 const QFontMetrics fm(m_pProfileInstanceList->font()); 229 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)230 229 const int iFontWidth = fm.horizontalAdvance('x'); 231 #else232 const int iFontWidth = fm.width('x');233 #endif234 230 const int iTotalWidth = 50 * iFontWidth; 235 231 const int iFontHeight = fm.height(); -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageSource.cpp
r104559 r104585 588 588 m_pProfileInstanceLabel->setBuddy(m_pProfileInstanceLabel); 589 589 const QFontMetrics fm(m_pProfileInstanceList->font()); 590 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)591 590 const int iFontWidth = fm.horizontalAdvance('x'); 592 #else593 const int iFontWidth = fm.width('x');594 #endif595 591 const int iTotalWidth = 50 * iFontWidth; 596 592 const int iFontHeight = fm.height(); -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVMPageSource.cpp
r104566 r104585 415 415 * horizontally and 8 lines vertically: */ 416 416 const QFontMetrics fm(m_pSourceImageList->font()); 417 #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)418 417 const int iFontWidth = fm.horizontalAdvance('x'); 419 #else420 const int iFontWidth = fm.width('x');421 #endif422 418 const int iTotalWidth = 50 * iFontWidth; 423 419 const int iFontHeight = fm.height();
Note:
See TracChangeset
for help on using the changeset viewer.