Changeset 97307 in vbox for trunk/src/VBox
- Timestamp:
- Oct 26, 2022 3:28:31 PM (2 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.cpp
r96808 r97307 207 207 const char *UIExtraDataDefs::GUI_ScaleFactor = "GUI/ScaleFactor"; 208 208 const char *UIExtraDataDefs::GUI_Scaling_Optimization = "GUI/Scaling/Optimization"; 209 const char *UIExtraDataDefs::GUI_FontScaleFactor = "GUI/FontScaleFactor"; 209 210 210 211 /* Virtual Machine: Session Information Dialog: */ -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h
r96816 r97307 384 384 /** Holds the scaling optimization type. */ 385 385 SHARED_LIBRARY_STUFF extern const char *GUI_Scaling_Optimization; 386 /** Holds the font scale factor. */ 387 SHARED_LIBRARY_STUFF extern const char *GUI_FontScaleFactor; 386 388 /** @} */ 387 389 -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp
r96808 r97307 2610 2610 } 2611 2611 2612 void UIExtraDataManager::setFontScaleFactor(int iFontScaleFactor) 2613 { 2614 int iMax = 200; 2615 int iMin = 40; 2616 if (iFontScaleFactor < iMin || iFontScaleFactor > iMax) 2617 return; 2618 setExtraDataString(GUI_FontScaleFactor, QString::number(iFontScaleFactor)); 2619 } 2620 2621 int UIExtraDataManager::fontScaleFactor() 2622 { 2623 QString strFontScaleFactor = extraDataString(GUI_FontScaleFactor); 2624 bool fConversion = false; 2625 int iScaleFactor = strFontScaleFactor.toInt(&fConversion); 2626 int iMax = 200; 2627 int iMin = 40; 2628 if (!fConversion || iScaleFactor < iMin || iScaleFactor > iMax) 2629 return 100; 2630 return iScaleFactor; 2631 } 2632 2612 2633 void UIExtraDataManager::setHostKeyCombination(const QString &strHostCombo) 2613 2634 { -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h
r96808 r97307 284 284 /* Sets whether host screen saver is disabled when a vm is running. */ 285 285 void setDisableHostScreenSaver(bool fActivate); 286 /* Set global font scale factor as percentage. 100% is for no scaling. */ 287 void setFontScaleFactor(int iFontScaleFactor); 288 int fontScaleFactor(); 286 289 /** @} */ 287 290 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp
r96808 r97307 730 730 m_recentMediaExcludeList << "ad-hoc.viso"; 731 731 #endif 732 733 scaleApplicationFont(gEDataManager->fontScaleFactor()); 734 } 735 736 void UICommon::scaleApplicationFont(int iFontScaleFactor) 737 { 738 QFont appFont = qApp->font(); 739 if (appFont.pixelSize() != -1) 740 appFont.setPixelSize(iFontScaleFactor / 100 * appFont.pixelSize()); 741 else 742 appFont.setPointSize(iFontScaleFactor / 100 * appFont.pointSize()); 743 qApp->setFont(appFont); 732 744 } 733 745 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h
r96808 r97307 527 527 /** @} */ 528 528 529 /* Scales the qApp's font. iFontScaleFactor is percentage thus 100% is for no scaling. */ 530 void scaleApplicationFont(int iFontScaleFactor); 531 529 532 public slots: 530 533 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIFontScaleEditor.cpp
r97302 r97307 101 101 { 102 102 setSpinBoxValue(value); 103 setFontScaleFactor(value); 104 } 105 106 void UIFontScaleEditor::setFontScaleFactor(int iFontScaleFactor) 107 { 108 setSliderValue(iFontScaleFactor); 109 setSpinBoxValue(iFontScaleFactor); 110 } 111 112 int UIFontScaleEditor::fontScaleFactor() const 113 { 114 return m_pScaleSlider->value(); 103 115 } 104 116 … … 156 168 } 157 169 158 prepareScaleFactorMinMax Values();170 prepareScaleFactorMinMax(); 159 171 retranslateUi(); 160 172 } 161 173 162 void UIFontScaleEditor::prepareScaleFactorMinMaxValues() 163 { 164 const int iHostScreenCount = gpDesktop->screenCount(); 165 if (iHostScreenCount == 0) 166 return; 167 double dMaxDevicePixelRatio = gpDesktop->devicePixelRatio(0); 168 for (int i = 1; i < iHostScreenCount; ++i) 169 if (dMaxDevicePixelRatio < gpDesktop->devicePixelRatio(i)) 170 dMaxDevicePixelRatio = gpDesktop->devicePixelRatio(i); 171 172 const int iMinimum = 100; 173 const int iMaximum = ceil(iMinimum + 100 * dMaxDevicePixelRatio); 174 void UIFontScaleEditor::prepareScaleFactorMinMax() 175 { 176 m_pScaleSlider->blockSignals(true); 177 m_pScaleSpinBox->blockSignals(true); 178 const int iMinimum = 40; 179 const int iMaximum = 200; 174 180 175 181 const int iStep = 25; … … 182 188 m_pScaleSpinBox->setMinimum(iMinimum); 183 189 m_pScaleSpinBox->setMaximum(iMaximum); 190 m_pScaleSlider->blockSignals(false); 191 m_pScaleSpinBox->blockSignals(false); 184 192 } 185 193 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIFontScaleEditor.h
r97302 r97307 63 63 void setMinimumLayoutIndent(int iIndent); 64 64 65 void setFontScaleFactor(int iFontScaleFactor); 66 int fontScaleFactor() const; 67 65 68 protected: 66 69 … … 82 85 void prepare(); 83 86 /** Prepare min/max values of related widgets wrt. device pixel ratio(s). */ 84 void prepareScaleFactorMinMaxValues(); 85 87 void prepareScaleFactorMinMax(); 86 88 87 89 /** Defines slider's @a iValue. */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsDisplay.cpp
r97302 r97307 56 56 && (m_fActivateHoveredMachineWindow == other.m_fActivateHoveredMachineWindow) 57 57 && (m_fDisableHostScreenSaver == other.m_fDisableHostScreenSaver) 58 && (m_iFontScalingFactor == other.m_iFontScalingFactor) 58 59 ; 59 60 } … … 72 73 /** Holds whether we should disable host sceen saver on a vm is running. */ 73 74 bool m_fDisableHostScreenSaver; 75 /** Holds font scaling factor. */ 76 int m_iFontScalingFactor; 74 77 }; 75 78 … … 120 123 oldData.m_fDisableHostScreenSaver = gEDataManager->disableHostScreenSaver(); 121 124 #endif 125 oldData.m_iFontScalingFactor = gEDataManager->fontScaleFactor(); 122 126 m_pCache->cacheInitialData(oldData); 123 127 … … 146 150 m_pEditorGlobalDisplayFeatures->setDisableHostScreenSaver(oldData.m_fDisableHostScreenSaver); 147 151 } 152 if (m_pFontScaleEditor) 153 m_pFontScaleEditor->setFontScaleFactor(oldData.m_iFontScalingFactor); 148 154 } 149 155 … … 167 173 newData.m_fDisableHostScreenSaver = m_pEditorGlobalDisplayFeatures->disableHostScreenSaver(); 168 174 } 175 if (m_pFontScaleEditor) 176 newData.m_iFontScalingFactor = m_pFontScaleEditor->fontScaleFactor(); 169 177 m_pCache->cacheCurrentData(newData); 170 178 } … … 283 291 /* fSuccess = */ gEDataManager->setDisableHostScreenSaver(newData.m_fDisableHostScreenSaver); 284 292 #endif /* VBOX_WS_WIN || VBOX_WS_X11 */ 293 /* Save font scale factor: */ 294 if ( fSuccess 295 && newData.m_iFontScalingFactor != oldData.m_iFontScalingFactor) 296 /* fSuccess = */ gEDataManager->setFontScaleFactor(newData.m_iFontScalingFactor); 285 297 } 286 298 /* Return result: */
Note:
See TracChangeset
for help on using the changeset viewer.