Changeset 74732 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Oct 10, 2018 9:20:33 AM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/widgets
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIScaleFactorEditor.cpp
r74722 r74732 21 21 22 22 /* Qt includes: */ 23 #include <QComboBox> 24 #include <QGridLayout> 25 #include <QSpinBox> 23 # include <QComboBox> 24 # include <QGridLayout> 25 # include <QLabel> 26 # include <QSpacerItem> 27 # include <QSpinBox> 26 28 # include <QWidget> 27 29 28 30 /* GUI includes: */ 29 # include "QIAdvancedSlider.h"30 # include "UIScaleFactorEditor.h"31 # include "QIAdvancedSlider.h" 32 # include "UIScaleFactorEditor.h" 31 33 32 34 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ … … 38 40 , m_pMainLayout(0) 39 41 , m_pMonitorComboBox(0) 42 , m_pScaleSlider(0) 43 , m_pMaxScaleLabel(0) 44 , m_pMinScaleLabel(0) 40 45 { 41 46 /* Prepare: */ … … 71 76 int currentMonitorIndex = m_pMonitorComboBox->currentIndex(); 72 77 if (m_scaleFactors.size() > currentMonitorIndex && m_pScaleSpinBox) 73 m_pScaleSpinBox->setValue(100 * m_scaleFactors.at(currentMonitorIndex));78 setSpinBoxValue(100 * m_scaleFactors.at(currentMonitorIndex)); 74 79 } 75 80 } … … 82 87 void UIScaleFactorEditor::retranslateUi() 83 88 { 89 if (m_pMaxScaleLabel) 90 { 91 m_pMaxScaleLabel->setText(tr("Max")); 92 } 93 94 if (m_pMinScaleLabel) 95 { 96 m_pMinScaleLabel->setText(tr("Min")); 97 } 84 98 } 85 99 … … 104 118 105 119 /* Update the slider and spinbox values without emitting signals: */ 106 int scaleFactor = 100 * m_scaleFactors[index];120 int scaleFactor = 100 * m_scaleFactors[index]; 107 121 setSliderValue(scaleFactor); 108 122 setSpinBoxValue(scaleFactor); … … 114 128 if (!m_pMainLayout) 115 129 return; 130 QMargins margins = m_pMainLayout->contentsMargins(); 131 m_pMainLayout->setContentsMargins(0, margins.top(), 0, margins.bottom()); 116 132 m_pMonitorComboBox = new QComboBox; 117 133 if (m_pMonitorComboBox) … … 121 137 this, &UIScaleFactorEditor::sltMonitorComboIndexChanged); 122 138 } 123 m_pScaleSpinBox = new QSpinBox; 124 if (m_pScaleSpinBox) 125 { 126 m_pMainLayout->addWidget(m_pScaleSpinBox, 0, 2); 127 m_pScaleSpinBox->setMinimum(100); 128 m_pScaleSpinBox->setMaximum(200); 129 connect(m_pScaleSpinBox ,static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), 130 this, &UIScaleFactorEditor::sltScaleSpinBoxValueChanged); 131 } 132 139 140 QGridLayout *pSliderLayout = new QGridLayout; 141 pSliderLayout->setSpacing(0); 133 142 m_pScaleSlider = new QIAdvancedSlider; 134 143 { 135 m_pMainLayout->addWidget(m_pScaleSlider, 0, 1);144 pSliderLayout->addWidget(m_pScaleSlider, 0, 0, 1, 3); 136 145 m_pScaleSlider->setMinimum(100); 137 146 m_pScaleSlider->setMaximum(200); … … 143 152 this, &UIScaleFactorEditor::sltScaleSliderValueChanged); 144 153 } 154 155 m_pMinScaleLabel = new QLabel; 156 if (m_pMinScaleLabel) 157 pSliderLayout->addWidget(m_pMinScaleLabel, 1, 0); 158 159 QSpacerItem *pSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); 160 if (pSpacer) 161 pSliderLayout->addItem(pSpacer, 1, 1); 162 163 m_pMaxScaleLabel = new QLabel; 164 if (m_pMaxScaleLabel) 165 pSliderLayout->addWidget(m_pMaxScaleLabel, 1, 2); 166 167 m_pMainLayout->addLayout(pSliderLayout, 0, 1, 2, 1); 168 169 m_pScaleSpinBox = new QSpinBox; 170 if (m_pScaleSpinBox) 171 { 172 m_pMainLayout->addWidget(m_pScaleSpinBox, 0, 3); 173 m_pScaleSpinBox->setMinimum(100); 174 m_pScaleSpinBox->setMaximum(200); 175 connect(m_pScaleSpinBox ,static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), 176 this, &UIScaleFactorEditor::sltScaleSpinBoxValueChanged); 177 } 178 179 145 180 setLayout(m_pMainLayout); 181 retranslateUi(); 146 182 } 147 183 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIScaleFactorEditor.h
r74722 r74732 30 30 class QComboBox; 31 31 class QGridLayout; 32 class QLabel; 32 33 class QSpinBox; 33 34 class QWidget; … … 40 41 Q_OBJECT; 41 42 42 signals:43 44 43 public: 45 44 … … 51 50 52 51 protected: 52 53 53 virtual void retranslateUi() /* override */; 54 54 55 55 private slots: 56 56 57 void sltScaleSpinBoxValueChanged(int value); 57 58 void sltScaleSliderValueChanged(int value); … … 59 60 60 61 private: 62 61 63 void prepare(); 62 64 void setScaleFactor(int iMonitorIndex, int iScaleFactor); 65 /* Blocks slider's signals before settting the value. */ 63 66 void setSliderValue(int iValue); 67 /* Blocks slider's signals before settting the value. */ 64 68 void setSpinBoxValue(int iValue); 65 69 QSpinBox *m_pScaleSpinBox; … … 67 71 QComboBox *m_pMonitorComboBox; 68 72 QIAdvancedSlider *m_pScaleSlider; 73 QLabel *m_pMaxScaleLabel; 74 QLabel *m_pMinScaleLabel; 69 75 /* Stores the per-monitor scale factors in range [.., 1, ..] */ 70 76 QList<double> m_scaleFactors;
Note:
See TracChangeset
for help on using the changeset viewer.