- Timestamp:
- Dec 3, 2019 6:53:03 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.cpp
r82348 r82351 190 190 bool UIMachineSettingsSystem::isHIDEnabled() const 191 191 { 192 return (KPointingHIDType)m_pComboPointingHIDType->itemData(m_pComboPointingHIDType->currentIndex()).toInt() != KPointingHIDType_PS2Mouse;192 return m_pComboPointingHIDType->currentData().value<KPointingHIDType>() != KPointingHIDType_PS2Mouse; 193 193 } 194 194 … … 315 315 newSystemData.m_bootItems = m_pBootOrderEditor->value(); 316 316 newSystemData.m_chipsetType = (KChipsetType)m_pComboChipsetType->itemData(m_pComboChipsetType->currentIndex()).toInt(); 317 newSystemData.m_pointingHIDType = (KPointingHIDType)m_pComboPointingHIDType->itemData(m_pComboPointingHIDType->currentIndex()).toInt();317 newSystemData.m_pointingHIDType = m_pComboPointingHIDType->currentData().value<KPointingHIDType>(); 318 318 newSystemData.m_fEnabledIoApic = m_pCheckBoxApic->isChecked() || m_pSliderCPUCount->value() > 1 || 319 319 (KChipsetType)m_pComboChipsetType->itemData(m_pComboChipsetType->currentIndex()).toInt() == KChipsetType_ICH9; … … 866 866 void UIMachineSettingsSystem::repopulateComboPointingHIDType() 867 867 { 868 /* Is there any value currently present/selected? */ 869 KPointingHIDType enmCurrentValue = KPointingHIDType_None; 870 { 871 const int iCurrentIndex = m_pComboPointingHIDType->currentIndex(); 872 if (iCurrentIndex != -1) 873 enmCurrentValue = (KPointingHIDType)m_pComboPointingHIDType->itemData(iCurrentIndex).toInt(); 874 } 875 876 /* Clear combo: */ 877 m_pComboPointingHIDType->clear(); 878 879 /* Repopulate combo taking into account currently cached value: */ 880 const KPointingHIDType enmCachedValue = m_pCache->base().m_pointingHIDType; 881 { 882 /* "PS/2 Mouse" value is always here: */ 883 m_pComboPointingHIDType->addItem(gpConverter->toString(KPointingHIDType_PS2Mouse), (int)KPointingHIDType_PS2Mouse); 884 885 /* "USB Mouse" value is here only if it is currently selected: */ 886 if (enmCachedValue == KPointingHIDType_USBMouse) 887 m_pComboPointingHIDType->addItem(gpConverter->toString(KPointingHIDType_USBMouse), (int)KPointingHIDType_USBMouse); 888 889 /* "USB Mouse/Tablet" value is always here: */ 890 m_pComboPointingHIDType->addItem(gpConverter->toString(KPointingHIDType_USBTablet), (int)KPointingHIDType_USBTablet); 891 892 /* "PS/2 and USB Mouse" value is here only if it is currently selected: */ 893 if (enmCachedValue == KPointingHIDType_ComboMouse) 894 m_pComboPointingHIDType->addItem(gpConverter->toString(KPointingHIDType_ComboMouse), (int)KPointingHIDType_ComboMouse); 895 896 /* "USB Multi-Touch Mouse/Tablet" value is always here: */ 897 m_pComboPointingHIDType->addItem(gpConverter->toString(KPointingHIDType_USBMultiTouch), (int)KPointingHIDType_USBMultiTouch); 898 } 899 900 /* Was there any value previously present/selected? */ 901 if (enmCurrentValue != KPointingHIDType_None) 902 { 903 int iPreviousIndex = m_pComboPointingHIDType->findData((int)enmCurrentValue); 904 if (iPreviousIndex != -1) 905 m_pComboPointingHIDType->setCurrentIndex(iPreviousIndex); 868 /* Pointing HID Type combo-box created in the .ui file. */ 869 AssertPtrReturnVoid(m_pComboPointingHIDType); 870 { 871 /* Clear combo first of all: */ 872 m_pComboPointingHIDType->clear(); 873 874 /* Load currently supported pointing HID types: */ 875 CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties(); 876 QVector<KPointingHIDType> pointingHidTypes = comProperties.GetSupportedPointingHIDTypes(); 877 /* Take into account currently cached value: */ 878 const KPointingHIDType enmCachedValue = m_pCache->base().m_pointingHIDType; 879 if (!pointingHidTypes.contains(enmCachedValue)) 880 pointingHidTypes.prepend(enmCachedValue); 881 882 /* Populate combo finally: */ 883 foreach (const KPointingHIDType &enmType, pointingHidTypes) 884 m_pComboPointingHIDType->addItem(gpConverter->toString(enmType), QVariant::fromValue(enmType)); 906 885 } 907 886 } … … 946 925 void UIMachineSettingsSystem::retranslateComboPointingHIDType() 947 926 { 948 /* For each the element in KPointingHIDType enum: */ 949 for (int iIndex = (int)KPointingHIDType_None; iIndex < (int)KPointingHIDType_Max; ++iIndex) 950 { 951 /* Cast to the corresponding type: */ 952 const KPointingHIDType enmType = (KPointingHIDType)iIndex; 953 /* Look for the corresponding item: */ 954 const int iCorrespondingIndex = m_pComboPointingHIDType->findData((int)enmType); 955 /* Re-translate if corresponding item was found: */ 956 if (iCorrespondingIndex != -1) 957 m_pComboPointingHIDType->setItemText(iCorrespondingIndex, gpConverter->toString(enmType)); 927 /* For each the element in m_pComboPointingHIDType: */ 928 for (int iIndex = 0; iIndex < m_pComboPointingHIDType->count(); ++iIndex) 929 { 930 /* Apply retranslated text: */ 931 const KPointingHIDType enmType = m_pComboPointingHIDType->currentData().value<KPointingHIDType>(); 932 m_pComboPointingHIDType->setItemText(iIndex, gpConverter->toString(enmType)); 958 933 } 959 934 }
Note:
See TracChangeset
for help on using the changeset viewer.