- Timestamp:
- Oct 26, 2022 10:26:14 AM (2 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
- 2 copied
-
Makefile.kmk (modified) (2 diffs)
-
src/settings/editors/UIFontScaleEditor.cpp (copied) (copied from trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIScaleFactorEditor.cpp ) (14 diffs)
-
src/settings/editors/UIFontScaleEditor.h (copied) (copied from trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIScaleFactorEditor.h ) (9 diffs)
-
src/settings/global/UIGlobalSettingsDisplay.cpp (modified) (4 diffs)
-
src/settings/global/UIGlobalSettingsDisplay.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r97085 r97302 921 921 src/settings/editors/UIDragAndDropEditor.h \ 922 922 src/settings/editors/UIExecutionCapEditor.h \ 923 src/settings/editors/UIFontScaleEditor.h \ 923 924 src/settings/editors/UIGraphicsControllerEditor.h \ 924 925 src/settings/editors/UIHostComboEditor.h \ … … 1504 1505 src/settings/editors/UIDragAndDropEditor.cpp \ 1505 1506 src/settings/editors/UIExecutionCapEditor.cpp \ 1507 src/settings/editors/UIFontScaleEditor.cpp \ 1506 1508 src/settings/editors/UIGraphicsControllerEditor.cpp \ 1507 1509 src/settings/editors/UIHostComboEditor.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIFontScaleEditor.cpp
r97301 r97302 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI ScaleFactorEditor class implementation.3 * VBox Qt GUI - UIFontScaleEditor class implementation. 4 4 */ 5 5 … … 27 27 28 28 /* Qt includes: */ 29 #include <QComboBox>30 29 #include <QGridLayout> 31 30 #include <QLabel> … … 37 36 #include "QIAdvancedSlider.h" 38 37 #include "UIDesktopWidgetWatchdog.h" 39 #include "UI ScaleFactorEditor.h"38 #include "UIFontScaleEditor.h" 40 39 41 40 /* External includes: */ … … 43 42 44 43 45 UI ScaleFactorEditor::UIScaleFactorEditor(QWidget *pParent)44 UIFontScaleEditor::UIFontScaleEditor(QWidget *pParent) 46 45 : QIWithRetranslateUI<QWidget>(pParent) 47 46 , m_pLayout(0) 48 47 , m_pLabel(0) 49 , m_pMonitorComboBox(0)50 48 , m_pScaleSlider(0) 51 49 , m_pScaleSpinBox(0) 52 50 , m_pMinScaleLabel(0) 53 51 , m_pMaxScaleLabel(0) 54 , m_dDefaultScaleFactor(1.0)55 52 { 56 53 /* Prepare: */ 57 54 prepare(); 58 /* Append a default scale factor to the list as an global scale factor: */ 59 m_scaleFactors.append(1.0); 60 } 61 62 void UIScaleFactorEditor::setMonitorCount(int iMonitorCount) 63 { 64 if (!m_pMonitorComboBox) 65 return; 66 /* We always have 0th for global scale factor (in combo box and scale factor list): */ 67 int iEndMonitorCount = iMonitorCount + 1; 68 int iCurrentMonitorCount = m_pMonitorComboBox->count(); 69 if (iEndMonitorCount == iCurrentMonitorCount) 70 return; 71 m_pMonitorComboBox->setEnabled(iMonitorCount > 1); 72 m_pMonitorComboBox->blockSignals(true); 73 int iCurrentMonitorIndex = m_pMonitorComboBox->currentIndex(); 74 if (iCurrentMonitorCount < iEndMonitorCount) 75 { 76 for (int i = iCurrentMonitorCount; i < iEndMonitorCount; ++i) 77 m_pMonitorComboBox->insertItem(i, tr("Monitor %1").arg(i)); 78 } 79 else 80 { 81 for (int i = iCurrentMonitorCount - 1; i >= iEndMonitorCount; --i) 82 m_pMonitorComboBox->removeItem(i); 83 } 84 m_pMonitorComboBox->setEnabled(iMonitorCount > 1); 85 /* If we have a single monitor select the "All Monitors" item in the combo 86 but make sure we retain the scale factor of the 0th monitor: */ 87 if (iMonitorCount <= 1) 88 { 89 if (m_scaleFactors.size() >= 2) 90 m_scaleFactors[0] = m_scaleFactors[1]; 91 m_pMonitorComboBox->setCurrentIndex(0); 92 } 93 m_pMonitorComboBox->blockSignals(false); 94 /* Update the slider and spinbox values if the combobox index has changed: */ 95 if (iCurrentMonitorIndex != m_pMonitorComboBox->currentIndex()) 96 updateValuesAfterMonitorChange(); 97 } 98 99 void UIScaleFactorEditor::setScaleFactors(const QList<double> &scaleFactors) 100 { 101 m_scaleFactors.clear(); 102 /* If we have a single value from the extra data and we treat if as a default scale factor: */ 103 if (scaleFactors.size() == 1) 104 { 105 m_dDefaultScaleFactor = scaleFactors.at(0); 106 m_scaleFactors.append(m_dDefaultScaleFactor); 107 setIsGlobalScaleFactor(true); 108 return; 109 } 110 111 /* Insert 0th element as the global scalar value: */ 112 m_scaleFactors.append(m_dDefaultScaleFactor); 113 m_scaleFactors.append(scaleFactors); 114 setIsGlobalScaleFactor(false); 115 } 116 117 QList<double> UIScaleFactorEditor::scaleFactors() const 118 { 119 QList<double> scaleFactorList; 120 if (m_scaleFactors.size() == 0) 121 return scaleFactorList; 122 123 /* Decide if the users wants a global (not per monitor) scaling. */ 124 bool globalScaleFactor = false; 125 126 /* if "All Monitors" item is selected in the combobox: */ 127 if (m_pMonitorComboBox && m_pMonitorComboBox->currentIndex() == 0) 128 globalScaleFactor = true; 129 /* Also check if all of the monitor scale factors equal to the global scale factor: */ 130 if (!globalScaleFactor) 131 { 132 globalScaleFactor = true; 133 for (int i = 1; i < m_scaleFactors.size() && globalScaleFactor; ++i) 134 if (m_scaleFactors[0] != m_scaleFactors[i]) 135 globalScaleFactor = false; 136 } 137 138 if (globalScaleFactor) 139 { 140 scaleFactorList << m_scaleFactors.at(0); 141 } 142 else 143 { 144 /* Skip the 0th scale factor: */ 145 for (int i = 1; i < m_scaleFactors.size(); ++i) 146 scaleFactorList.append(m_scaleFactors.at(i)); 147 } 148 149 return scaleFactorList; 150 } 151 152 void UIScaleFactorEditor::setIsGlobalScaleFactor(bool bFlag) 153 { 154 if (!m_pMonitorComboBox) 155 return; 156 if (bFlag && m_pMonitorComboBox->count() >= 1) 157 m_pMonitorComboBox->setCurrentIndex(0); 158 else 159 if(m_pMonitorComboBox->count() >= 2) 160 m_pMonitorComboBox->setCurrentIndex(1); 161 updateValuesAfterMonitorChange(); 162 } 163 164 void UIScaleFactorEditor::setDefaultScaleFactor(double dDefaultScaleFactor) 165 { 166 m_dDefaultScaleFactor = dDefaultScaleFactor; 167 } 168 169 void UIScaleFactorEditor::setSpinBoxWidthHint(int iHint) 55 } 56 57 void UIFontScaleEditor::setSpinBoxWidthHint(int iHint) 170 58 { 171 59 m_pScaleSpinBox->setMinimumWidth(iHint); 172 60 } 173 61 174 int UI ScaleFactorEditor::minimumLabelHorizontalHint() const62 int UIFontScaleEditor::minimumLabelHorizontalHint() const 175 63 { 176 64 return m_pLabel ? m_pLabel->minimumSizeHint().width() : 0; 177 65 } 178 66 179 void UI ScaleFactorEditor::setMinimumLayoutIndent(int iIndent)67 void UIFontScaleEditor::setMinimumLayoutIndent(int iIndent) 180 68 { 181 69 if (m_pLayout) … … 183 71 } 184 72 185 void UI ScaleFactorEditor::retranslateUi()73 void UIFontScaleEditor::retranslateUi() 186 74 { 187 75 if (m_pLabel) 188 m_pLabel->setText(tr("Scale &Factor:")); 189 190 if (m_pMonitorComboBox) 191 { 192 if (m_pMonitorComboBox->count() > 0) 193 { 194 m_pMonitorComboBox->setItemText(0, tr("All Monitors")); 195 for (int i = 1; i < m_pMonitorComboBox->count(); ++i) 196 m_pMonitorComboBox->setItemText(i, tr("Monitor %1").arg(i)); 197 } 198 m_pMonitorComboBox->setToolTip(tr("Selects the index of monitor guest screen scale factor being defined for.")); 199 } 76 m_pLabel->setText(tr("F&ont Scaling:")); 200 77 201 78 if (m_pScaleSlider) 202 m_pScaleSlider->setToolTip(tr("Holds the guest screen scale factor."));79 m_pScaleSlider->setToolTip(tr("Holds the scaling factor for the font size.")); 203 80 if (m_pScaleSpinBox) 204 m_pScaleSpinBox->setToolTip(tr("Holds the guest screen scale factor."));81 m_pScaleSpinBox->setToolTip(tr("Holds the scaling factor for the font size.")); 205 82 206 83 if (m_pMinScaleLabel) … … 216 93 } 217 94 218 void UI ScaleFactorEditor::sltScaleSpinBoxValueChanged(int value)95 void UIFontScaleEditor::sltScaleSpinBoxValueChanged(int value) 219 96 { 220 97 setSliderValue(value); 221 if (m_pMonitorComboBox) 222 setScaleFactor(m_pMonitorComboBox->currentIndex(), value); 223 } 224 225 void UIScaleFactorEditor::sltScaleSliderValueChanged(int value) 98 } 99 100 void UIFontScaleEditor::sltScaleSliderValueChanged(int value) 226 101 { 227 102 setSpinBoxValue(value); 228 if (m_pMonitorComboBox) 229 setScaleFactor(m_pMonitorComboBox->currentIndex(), value); 230 } 231 232 void UIScaleFactorEditor::sltMonitorComboIndexChanged(int) 233 { 234 updateValuesAfterMonitorChange(); 235 } 236 237 void UIScaleFactorEditor::prepare() 103 } 104 105 void UIFontScaleEditor::sltMonitorComboIndexChanged(int) 106 { 107 } 108 109 void UIFontScaleEditor::prepare() 238 110 { 239 111 m_pLayout = new QGridLayout(this); … … 242 114 m_pLayout->setContentsMargins(0, 0, 0, 0); 243 115 m_pLayout->setColumnStretch(1, 1); 244 m_pLayout->setColumnStretch(2, 1);245 116 246 117 /* Prepare label: */ … … 250 121 m_pLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 251 122 m_pLayout->addWidget(m_pLabel, 0, 0); 252 }253 254 m_pMonitorComboBox = new QComboBox(this);255 if (m_pMonitorComboBox)256 {257 m_pMonitorComboBox->insertItem(0, "All Monitors");258 connect(m_pMonitorComboBox ,static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),259 this, &UIScaleFactorEditor::sltMonitorComboIndexChanged);260 261 m_pLayout->addWidget(m_pMonitorComboBox, 0, 1);262 123 } 263 124 … … 271 132 m_pScaleSlider->setSnappingEnabled(true); 272 133 connect(m_pScaleSlider, static_cast<void(QIAdvancedSlider::*)(int)>(&QIAdvancedSlider::valueChanged), 273 this, &UI ScaleFactorEditor::sltScaleSliderValueChanged);274 275 m_pLayout->addWidget(m_pScaleSlider, 0, 2, 1, 2);134 this, &UIFontScaleEditor::sltScaleSliderValueChanged); 135 136 m_pLayout->addWidget(m_pScaleSlider, 0, 1, 1, 4); 276 137 } 277 138 … … 282 143 m_pScaleSpinBox->setSuffix("%"); 283 144 connect(m_pScaleSpinBox ,static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), 284 this, &UI ScaleFactorEditor::sltScaleSpinBoxValueChanged);285 m_pLayout->addWidget(m_pScaleSpinBox, 0, 4);145 this, &UIFontScaleEditor::sltScaleSpinBoxValueChanged); 146 m_pLayout->addWidget(m_pScaleSpinBox, 0, 5); 286 147 } 287 148 288 149 m_pMinScaleLabel = new QLabel(this); 289 150 if (m_pMinScaleLabel) 290 m_pLayout->addWidget(m_pMinScaleLabel, 1, 2);151 m_pLayout->addWidget(m_pMinScaleLabel, 1, 1); 291 152 292 153 m_pMaxScaleLabel = new QLabel(this); 293 154 if (m_pMaxScaleLabel) 294 m_pLayout->addWidget(m_pMaxScaleLabel, 1, 3);155 m_pLayout->addWidget(m_pMaxScaleLabel, 1, 4); 295 156 } 296 157 … … 299 160 } 300 161 301 void UI ScaleFactorEditor::prepareScaleFactorMinMaxValues()162 void UIFontScaleEditor::prepareScaleFactorMinMaxValues() 302 163 { 303 164 const int iHostScreenCount = gpDesktop->screenCount(); … … 323 184 } 324 185 325 void UIScaleFactorEditor::setScaleFactor(int iMonitorIndex, int iScaleFactor) 326 { 327 /* Make sure we have the corresponding scale values for all monitors: */ 328 if (m_pMonitorComboBox->count() > m_scaleFactors.size()) 329 { 330 for (int i = m_scaleFactors.size(); i < m_pMonitorComboBox->count(); ++i) 331 m_scaleFactors.append(m_dDefaultScaleFactor); 332 } 333 m_scaleFactors[iMonitorIndex] = iScaleFactor / 100.0; 334 } 335 336 void UIScaleFactorEditor::setSliderValue(int iValue) 186 void UIFontScaleEditor::setSliderValue(int iValue) 337 187 { 338 188 if (m_pScaleSlider && iValue != m_pScaleSlider->value()) … … 344 194 } 345 195 346 void UI ScaleFactorEditor::setSpinBoxValue(int iValue)196 void UIFontScaleEditor::setSpinBoxValue(int iValue) 347 197 { 348 198 if (m_pScaleSpinBox && iValue != m_pScaleSpinBox->value()) … … 354 204 } 355 205 356 void UIScaleFactorEditor::updateValuesAfterMonitorChange()357 {358 /* Set the spinbox value for the currently selected monitor: */359 if (m_pMonitorComboBox)360 {361 int currentMonitorIndex = m_pMonitorComboBox->currentIndex();362 while (m_scaleFactors.size() <= currentMonitorIndex)363 m_scaleFactors.append(m_dDefaultScaleFactor);364 365 setSpinBoxValue(100 * m_scaleFactors.at(currentMonitorIndex));366 setSliderValue(100 * m_scaleFactors.at(currentMonitorIndex));367 368 }369 } -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIFontScaleEditor.h
r97301 r97302 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI ScaleFactorEditor class declaration.3 * VBox Qt GUI - UIFontScaleEditor class declaration. 4 4 */ 5 5 … … 26 26 */ 27 27 28 #ifndef FEQT_INCLUDED_SRC_settings_editors_UI ScaleFactorEditor_h29 #define FEQT_INCLUDED_SRC_settings_editors_UI ScaleFactorEditor_h28 #ifndef FEQT_INCLUDED_SRC_settings_editors_UIFontScaleEditor_h 29 #define FEQT_INCLUDED_SRC_settings_editors_UIFontScaleEditor_h 30 30 #ifndef RT_WITHOUT_PRAGMA_ONCE 31 31 # pragma once … … 37 37 38 38 /* Forward declarations: */ 39 class QComboBox;40 39 class QGridLayout; 41 40 class QLabel; … … 47 46 * It includes a combo box to select a monitor, a slider, and a spinbox to display/modify values. 48 47 * The first item in the combo box is used to change the scale factor of all monitors. */ 49 class SHARED_LIBRARY_STUFF UI ScaleFactorEditor : public QIWithRetranslateUI<QWidget>48 class SHARED_LIBRARY_STUFF UIFontScaleEditor : public QIWithRetranslateUI<QWidget> 50 49 { 51 50 Q_OBJECT; … … 54 53 55 54 /** Constructs editor passing @a pParent to the base-class. */ 56 UIScaleFactorEditor(QWidget *pParent); 57 58 /** Defines @a iMonitorCount. */ 59 void setMonitorCount(int iMonitorCount); 60 /** Defines a list of guest-screen @a scaleFactors. */ 61 void setScaleFactors(const QList<double> &scaleFactors); 62 63 /** Returns either a single global scale factor or a list of scale factor for each monitor. */ 64 QList<double> scaleFactors() const; 65 66 /** Defines @a dDefaultScaleFactor. */ 67 void setDefaultScaleFactor(double dDefaultScaleFactor); 55 UIFontScaleEditor(QWidget *pParent); 68 56 69 57 /** Defines minimum width @a iHint for internal spin-box. */ … … 96 84 void prepareScaleFactorMinMaxValues(); 97 85 98 /** Defines whether scale factor is @a fGlobal one. */ 99 void setIsGlobalScaleFactor(bool fGlobal); 100 /** Defines @a iScaleFactor for certain @a iMonitorIndex. */ 101 void setScaleFactor(int iMonitorIndex, int iScaleFactor); 86 102 87 /** Defines slider's @a iValue. */ 103 88 void setSliderValue(int iValue); … … 105 90 void setSpinBoxValue(int iValue); 106 91 107 /** Sets the spinbox and slider to scale factor of currently selected monitor. */108 void updateValuesAfterMonitorChange();109 92 110 93 /** @name Member widgets. … … 112 95 QGridLayout *m_pLayout; 113 96 QLabel *m_pLabel; 114 QComboBox *m_pMonitorComboBox;115 97 QIAdvancedSlider *m_pScaleSlider; 116 98 QSpinBox *m_pScaleSpinBox; … … 118 100 QLabel *m_pMaxScaleLabel; 119 101 /** @} */ 120 121 /** Holds the per-monitor scale factors. The 0th item is for all monitors (global). */122 QList<double> m_scaleFactors;123 /** Holds the default scale factor. */124 double m_dDefaultScaleFactor;125 102 }; 126 103 127 #endif /* !FEQT_INCLUDED_SRC_settings_editors_UI ScaleFactorEditor_h */104 #endif /* !FEQT_INCLUDED_SRC_settings_editors_UIFontScaleEditor_h */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsDisplay.cpp
r97245 r97302 32 32 #include "UIDesktopWidgetWatchdog.h" 33 33 #include "UIExtraDataManager.h" 34 #include "UIFontScaleEditor.h" 34 35 #include "UIDisplayFeaturesEditor.h" 35 36 #include "UIGlobalSettingsDisplay.h" … … 83 84 , m_pEditorScaleFactor(0) 84 85 , m_pEditorGlobalDisplayFeatures(0) 86 , m_pFontScaleEditor(0) 85 87 { 86 88 prepare(); … … 187 189 iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorScaleFactor->minimumLabelHorizontalHint()); 188 190 iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorGlobalDisplayFeatures->minimumLabelHorizontalHint()); 191 iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pFontScaleEditor->minimumLabelHorizontalHint()); 189 192 m_pEditorMaximumGuestScreenSize->setMinimumLayoutIndent(iMinimumLayoutHint); 190 193 m_pEditorScaleFactor->setMinimumLayoutIndent(iMinimumLayoutHint); 191 194 m_pEditorGlobalDisplayFeatures->setMinimumLayoutIndent(iMinimumLayoutHint); 195 m_pFontScaleEditor->setMinimumLayoutIndent(iMinimumLayoutHint); 192 196 } 193 197 … … 225 229 if (m_pEditorGlobalDisplayFeatures) 226 230 pLayout->addWidget(m_pEditorGlobalDisplayFeatures); 231 232 /* Prepare 'font scale' editor: */ 233 m_pFontScaleEditor = new UIFontScaleEditor(this); 234 if (m_pFontScaleEditor) 235 pLayout->addWidget(m_pFontScaleEditor); 227 236 228 237 /* Add stretch to the end: */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsDisplay.h
r97245 r97302 37 37 /* Forward declarations: */ 38 38 class UIDisplayFeaturesEditor; 39 class UIFontScaleEditor; 39 40 class UIMaximumGuestScreenSizeEditor; 40 41 class UIScaleFactorEditor; … … 99 100 /** Holds the global display features editor instance. */ 100 101 UIDisplayFeaturesEditor *m_pEditorGlobalDisplayFeatures; 102 /** Holds the font scale editor instance. */ 103 UIFontScaleEditor *m_pFontScaleEditor; 101 104 /** @} */ 102 105 };
Note:
See TracChangeset
for help on using the changeset viewer.

