- Timestamp:
- Oct 11, 2018 10:16:30 AM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp
r74722 r74757 3972 3972 double UIExtraDataManager::scaleFactor(const QString &strID, const int uScreenIndex) 3973 3973 { 3974 /* Get corresponding extra-data value: */ 3975 const QString strValue = extraDataString(extraDataKeyPerScreen(GUI_ScaleFactor, uScreenIndex), strID); 3976 3977 /* Try to convert loaded data to double: */ 3974 /* Get corresponding extra-data: */ 3975 const QStringList data = extraDataStringList(GUI_ScaleFactor, strID); 3976 3977 /* 1.0 is default scale factor: */ 3978 if (data.size() == 0) 3979 return 1.0; 3980 3981 int index = uScreenIndex; 3982 /* use the 0th. scale factor in case we dont have a scale factor for @p uScreenIndex: */ 3983 if (data.size() <= uScreenIndex) 3984 index = 0; 3985 3978 3986 bool fOk = false; 3979 double dValue = strValue.toDouble(&fOk); 3980 3981 /* Invent the default value: */ 3982 if (!fOk || !dValue) 3983 dValue = 1; 3984 3985 /* Return value: */ 3986 return dValue; 3987 double scaleFactor = data[index].toDouble(&fOk); 3988 if (!fOk) 3989 return 1.0; 3990 return scaleFactor; 3991 } 3992 3993 QList<double> UIExtraDataManager::scaleFactors(const QString &strID) 3994 { 3995 QList<double> scaleFactorList; 3996 const QStringList data = extraDataStringList(GUI_ScaleFactor, strID); 3997 bool fOk = false; 3998 double scaleFactor; 3999 for (int i = 0; i < data.size(); ++i) 4000 { 4001 scaleFactor = data[i].toDouble(&fOk); 4002 if (!fOk) 4003 scaleFactor = 1.0; 4004 scaleFactorList.append(scaleFactor); 4005 } 4006 return scaleFactorList; 3987 4007 } 3988 4008 3989 4009 void UIExtraDataManager::setScaleFactor(double dScaleFactor, const QString &strID, const int uScreenIndex) 3990 4010 { 3991 /* Set corresponding extra-data value: */ 3992 setExtraDataString(extraDataKeyPerScreen(GUI_ScaleFactor, uScreenIndex), QString::number(dScaleFactor), strID); 4011 QStringList data = extraDataStringList(GUI_ScaleFactor, strID); 4012 4013 /* Just make sure that we have corresponding data item: */ 4014 if (data.size() <= uScreenIndex) 4015 { 4016 int listSize = data.size(); 4017 for (int i = listSize; i <= uScreenIndex; ++i) 4018 data.append(QString::number(1.0)); 4019 } 4020 4021 data[uScreenIndex] = QString::number(dScaleFactor); 4022 4023 setExtraDataStringList(GUI_ScaleFactor, data, strID); 4024 } 4025 4026 void UIExtraDataManager::setScaleFactors(const QList<double> &scaleFactors, const QString &strID) 4027 { 4028 QStringList data; 4029 for (int i = 0; i < scaleFactors.size(); ++i) 4030 data.append(QString::number(scaleFactors[i])); 4031 setExtraDataStringList(GUI_ScaleFactor, data, strID); 3993 4032 } 3994 4033 … … 4527 4566 emit sigStatusBarConfigurationChange(strMachineID); 4528 4567 /* Scale-factor change: */ 4529 else if (strKey .contains(GUI_ScaleFactor))4568 else if (strKey ==GUI_ScaleFactor) 4530 4569 emit sigScaleFactorChange(strMachineID); 4531 4570 /* Scaling optimization type change: */ -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h
r74722 r74757 598 598 /** Returns the scale-factor. */ 599 599 double scaleFactor(const QString &strID, const int uScreenIndex); 600 QList<double> scaleFactors(const QString &strID); 600 601 /** Defines the @a dScaleFactor. */ 601 602 void setScaleFactor(double dScaleFactor, const QString &strID, const int uScreenIndex); 603 void setScaleFactors(const QList<double> &scaleFactors, const QString &strID); 602 604 603 605 /** Returns the scaling optimization type. */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp
r74722 r74757 47 47 : m_iCurrentVRAM(0) 48 48 , m_cGuestScreenCount(0) 49 , m_dScaleFactor(1.0)50 49 , m_f3dAccelerationEnabled(false) 51 50 #ifdef VBOX_WITH_VIDEOHWACCEL … … 74 73 && (m_iCurrentVRAM == other.m_iCurrentVRAM) 75 74 && (m_cGuestScreenCount == other.m_cGuestScreenCount) 76 && (m_dScaleFactor == other.m_dScaleFactor)77 75 && (m_scaleFactors == other.m_scaleFactors) 78 76 && (m_f3dAccelerationEnabled == other.m_f3dAccelerationEnabled) … … 245 243 int m_cGuestScreenCount; 246 244 /** Holds the guest screen scale-factor. */ 247 double m_dScaleFactor;248 245 QList<double> m_scaleFactors; 249 246 /** Holds whether the 3D acceleration is enabled. */ … … 364 361 oldDisplayData.m_iCurrentVRAM = m_machine.GetVRAMSize(); 365 362 oldDisplayData.m_cGuestScreenCount = m_machine.GetMonitorCount(); 366 oldDisplayData.m_dScaleFactor = gEDataManager->scaleFactor(m_machine.GetId(), 0); 367 oldDisplayData.m_scaleFactors.clear(); 368 for (unsigned i = 0; i < m_machine.GetMonitorCount(); ++i) 369 oldDisplayData.m_scaleFactors.append(gEDataManager->scaleFactor(m_machine.GetId(), (int)i)); 370 363 oldDisplayData.m_scaleFactors = gEDataManager->scaleFactors(m_machine.GetId()); 371 364 oldDisplayData.m_f3dAccelerationEnabled = m_machine.GetAccelerate3DEnabled(); 372 365 #ifdef VBOX_WITH_VIDEOHWACCEL … … 1293 1286 screens.resize(m_pEditorVideoScreenCount->value()); 1294 1287 m_pScrollerVideoCaptureScreens->setValue(screens); 1288 m_pScaleFactorEditor->setMonitorCount(m_pEditorVideoScreenCount->value()); 1295 1289 } 1296 1290 … … 1408 1402 1409 1403 /* Save guest-screen scale-factor: */ 1410 if (fSuccess && newDisplayData.m_dScaleFactor != oldDisplayData.m_dScaleFactor)1411 /* fSuccess = */ gEDataManager->setScaleFactor(newDisplayData.m_dScaleFactor, strMachineId, 0);1412 1404 if (fSuccess && newDisplayData.m_scaleFactors != oldDisplayData.m_scaleFactors) 1413 1405 { 1414 int listSize = newDisplayData.m_scaleFactors.size(); 1415 for (int i = 0; i < listSize; ++i) 1416 gEDataManager->setScaleFactor(newDisplayData.m_scaleFactors[i], strMachineId, i); 1406 gEDataManager->setScaleFactors(newDisplayData.m_scaleFactors, strMachineId); 1417 1407 } 1418 1408 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIScaleFactorEditor.cpp
r74732 r74757 56 56 57 57 m_pMonitorComboBox->blockSignals(true); 58 m_pMonitorComboBox->clear(); 59 for (int i = 0; i < iMonitorCount; ++i) 60 { 61 m_pMonitorComboBox->addItem(QString("Monitor %1").arg(i)); 62 58 int iCurrentMonitorCount = m_pMonitorComboBox->count(); 59 int iCurrentMonitorIndex = m_pMonitorComboBox->currentIndex(); 60 //m_pMonitorComboBox->clear(); 61 if (iCurrentMonitorCount < iMonitorCount) 62 { 63 for (int i = iCurrentMonitorCount; i < iMonitorCount; ++i) 64 { 65 m_pMonitorComboBox->addItem(QString("Monitor %1").arg(i)); 66 /* In case that we have increased the # of monitors add new scale factors to the scale factor cache: */ 67 if (i >= m_scaleFactors.size()) 68 m_scaleFactors.append(1.0); 69 } 70 } 71 else 72 { 73 for (int i = iCurrentMonitorCount - 1; i >= iMonitorCount; --i) 74 m_pMonitorComboBox->removeItem(i); 63 75 } 64 76 m_pMonitorComboBox->blockSignals(false); 77 78 if (iCurrentMonitorIndex != m_pMonitorComboBox->currentIndex()) 79 showMonitorScaleFactor(); 65 80 } 66 81 … … 69 84 if (m_scaleFactors == scaleFactors) 70 85 return; 71 m_scaleFactors = scaleFactors; 72 73 /* Set the spinbox value for the currently selected monitor: */ 74 if (m_pMonitorComboBox) 75 { 76 int currentMonitorIndex = m_pMonitorComboBox->currentIndex(); 77 if (m_scaleFactors.size() > currentMonitorIndex && m_pScaleSpinBox) 78 setSpinBoxValue(100 * m_scaleFactors.at(currentMonitorIndex)); 79 } 80 } 86 /* if m_scaleFactors has more items than @p scaleFactors than we keep the additional items 87 this can happen for example when extra data has 4 scale factor while machine has 5 monitors: */ 88 if (m_scaleFactors.size() > scaleFactors.size()) 89 { 90 for (int i = 0; i < scaleFactors.size(); ++i) 91 m_scaleFactors[i] = scaleFactors[i]; 92 } 93 else 94 { 95 m_scaleFactors = scaleFactors; 96 } 97 showMonitorScaleFactor(); 98 } 99 81 100 82 101 const QList<double>& UIScaleFactorEditor::scaleFactors() const … … 212 231 } 213 232 } 233 234 void UIScaleFactorEditor::showMonitorScaleFactor() 235 { 236 /* Set the spinbox value for the currently selected monitor: */ 237 if (m_pMonitorComboBox) 238 { 239 int currentMonitorIndex = m_pMonitorComboBox->currentIndex(); 240 if (m_scaleFactors.size() > currentMonitorIndex && m_pScaleSpinBox) 241 { 242 setSpinBoxValue(100 * m_scaleFactors.at(currentMonitorIndex)); 243 setSliderValue(100 * m_scaleFactors.at(currentMonitorIndex)); 244 } 245 } 246 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIScaleFactorEditor.h
r74732 r74757 61 61 private: 62 62 63 void prepare();64 void setScaleFactor(int iMonitorIndex, int iScaleFactor);63 void prepare(); 64 void setScaleFactor(int iMonitorIndex, int iScaleFactor); 65 65 /* Blocks slider's signals before settting the value. */ 66 void setSliderValue(int iValue);66 void setSliderValue(int iValue); 67 67 /* Blocks slider's signals before settting the value. */ 68 void setSpinBoxValue(int iValue); 68 void setSpinBoxValue(int iValue); 69 /* Set the spinbox and slider to scale factor of currently selected monitor */ 70 void showMonitorScaleFactor(); 69 71 QSpinBox *m_pScaleSpinBox; 70 72 QGridLayout *m_pMainLayout;
Note:
See TracChangeset
for help on using the changeset viewer.