Changeset 95002 in vbox
- Timestamp:
- May 13, 2022 10:59:28 AM (3 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIToolBar.cpp
r94995 r95002 56 56 } 57 57 58 bool QIToolBar::useTextLabels() const 59 { 60 /* Depending on parent, return the style: */ 61 if (m_pMainWindow) 62 return m_pMainWindow->toolButtonStyle() == Qt::ToolButtonTextUnderIcon; 63 else 64 return toolButtonStyle() == Qt::ToolButtonTextUnderIcon; 65 } 66 58 67 #ifdef VBOX_WS_MAC 59 68 void QIToolBar::enableMacToolbar() … … 140 149 if (!m_icnBranding.isNull()) 141 150 { 142 /* Configure font to fit width (m_iBrandingWidth - 2 * 4): */151 /* A bit of common stuff: */ 143 152 QFont fnt = font(); 144 153 int iTextWidth = 0; 145 for (int i = 0; i <= 10; ++i) // no more than 10 tries .. 154 int iTextHeight = 0; 155 156 /* Configure font to fit width (m_iBrandingWidth - 2 * 4): */ 157 if (useTextLabels()) 146 158 { 147 if (fnt.pixelSize() == -1) 148 fnt.setPointSize(fnt.pointSize() - i); 149 else 150 fnt.setPixelSize(fnt.pixelSize() - i); 151 iTextWidth = QFontMetrics(fnt).size(0, m_strBranding).width(); 152 if (iTextWidth <= m_iBrandingWidth - 2 * 4) 153 break; 159 for (int i = 0; i <= 10; ++i) // no more than 10 tries .. 160 { 161 if (fnt.pixelSize() == -1) 162 fnt.setPointSize(fnt.pointSize() - i); 163 else 164 fnt.setPixelSize(fnt.pixelSize() - i); 165 iTextWidth = QFontMetrics(fnt).size(0, m_strBranding).width(); 166 if (iTextWidth <= m_iBrandingWidth - 2 * 4) 167 break; 168 } 169 iTextHeight = QFontMetrics(fnt).height(); 154 170 } 155 const int iFontHeight = QFontMetrics(fnt).height();156 171 157 172 /* Draw pixmap: */ 158 173 const int iIconSize = qMin(rectangle.height(), 32 /* default */); 159 174 const int iIconMarginH = (m_iBrandingWidth - iIconSize) / 2; 160 const int iIconMarginV = (rectangle.height() - iIconSize - i FontHeight) / 2;175 const int iIconMarginV = (rectangle.height() - iIconSize - iTextHeight) / 2; 161 176 const int iIconX = rectangle.width() - iIconSize - iIconMarginH; 162 177 const int iIconY = iIconMarginV; … … 164 179 165 180 /* Draw text path: */ 166 const int iTextMargingH = (m_iBrandingWidth - iTextWidth) / 2; 167 const int iTextX = rectangle.width() - iTextWidth - iTextMargingH; 168 const int iTextY = iIconY + iIconSize + iFontHeight; 169 QPainterPath textPath; 170 textPath.addText(0, 0, fnt, m_strBranding); 171 textPath.translate(iTextX, iTextY); 172 painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); 173 painter.setPen(QPen(m_clrBranding.darker(80), 2, Qt::SolidLine, Qt::RoundCap)); 174 painter.drawPath(QPainterPathStroker().createStroke(textPath)); 175 painter.setBrush(Qt::black); 176 painter.setPen(Qt::NoPen); 177 painter.drawPath(textPath); 181 if (useTextLabels()) 182 { 183 const int iTextMargingH = (m_iBrandingWidth - iTextWidth) / 2; 184 const int iTextX = rectangle.width() - iTextWidth - iTextMargingH; 185 const int iTextY = iIconY + iIconSize + iTextHeight; 186 QPainterPath textPath; 187 textPath.addText(0, 0, fnt, m_strBranding); 188 textPath.translate(iTextX, iTextY); 189 painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); 190 painter.setPen(QPen(m_clrBranding.darker(80), 2, Qt::SolidLine, Qt::RoundCap)); 191 painter.drawPath(QPainterPathStroker().createStroke(textPath)); 192 painter.setBrush(Qt::black); 193 painter.setPen(Qt::NoPen); 194 painter.drawPath(textPath); 195 } 178 196 } 179 197 } -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIToolBar.h
r94995 r95002 57 57 /** Defines whether tool-bar should use text-labels. */ 58 58 void setUseTextLabels(bool fEnable); 59 /** Returns whether tool-bar should use text-labels. */ 60 bool useTextLabels() const; 59 61 60 62 #ifdef VBOX_WS_MAC -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp
r94998 r95002 309 309 if (pResult == pShowToolBarText) 310 310 { 311 m_pToolBar->setToolButtonStyle( pResult->isChecked() 312 ? Qt::ToolButtonTextUnderIcon 313 : Qt::ToolButtonIconOnly); 311 m_pToolBar->setUseTextLabels(pResult->isChecked()); 314 312 gEDataManager->setSelectorWindowToolBarTextVisible(pResult->isChecked()); 315 313 } … … 632 630 m_pToolBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 633 631 m_pToolBar->setContextMenuPolicy(Qt::CustomContextMenu); 634 m_pToolBar->set ToolButtonStyle(Qt::ToolButtonTextUnderIcon);632 m_pToolBar->setUseTextLabels(true); 635 633 #ifdef VBOX_WS_MAC 636 634 m_pToolBar->emulateMacToolbar(); … … 810 808 /* Restore toolbar settings: */ 811 809 { 812 m_pToolBar->setToolButtonStyle( gEDataManager->selectorWindowToolBarTextVisible() 813 ? Qt::ToolButtonTextUnderIcon 814 : Qt::ToolButtonIconOnly); 810 m_pToolBar->setUseTextLabels(gEDataManager->selectorWindowToolBarTextVisible()); 815 811 } 816 812
Note:
See TracChangeset
for help on using the changeset viewer.