Changeset 51532 in vbox
- Timestamp:
- Jun 4, 2014 3:07:21 PM (11 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp
r51531 r51532 747 747 template<> DetailsElementType fromString<DetailsElementType>(const QString &strDetailsElementType) 748 748 { 749 QHash<QString, DetailsElementType> list; 750 list.insert(QApplication::translate("VBoxGlobal", "General", "DetailsElementType"), DetailsElementType_General); 751 list.insert(QApplication::translate("VBoxGlobal", "Preview", "DetailsElementType"), DetailsElementType_Preview); 752 list.insert(QApplication::translate("VBoxGlobal", "System", "DetailsElementType"), DetailsElementType_System); 753 list.insert(QApplication::translate("VBoxGlobal", "Display", "DetailsElementType"), DetailsElementType_Display); 754 list.insert(QApplication::translate("VBoxGlobal", "Storage", "DetailsElementType"), DetailsElementType_Storage); 755 list.insert(QApplication::translate("VBoxGlobal", "Audio", "DetailsElementType"), DetailsElementType_Audio); 756 list.insert(QApplication::translate("VBoxGlobal", "Network", "DetailsElementType"), DetailsElementType_Network); 757 list.insert(QApplication::translate("VBoxGlobal", "Serial ports", "DetailsElementType"), DetailsElementType_Serial); 749 /* Here we have some fancy stuff allowing us 750 * to search through the keys using 'case-insensitive' rule: */ 751 QStringList keys; QList<DetailsElementType> values; 752 keys << QApplication::translate("VBoxGlobal", "General", "DetailsElementType"); values << DetailsElementType_General; 753 keys << QApplication::translate("VBoxGlobal", "Preview", "DetailsElementType"); values << DetailsElementType_Preview; 754 keys << QApplication::translate("VBoxGlobal", "System", "DetailsElementType"); values << DetailsElementType_System; 755 keys << QApplication::translate("VBoxGlobal", "Display", "DetailsElementType"); values << DetailsElementType_Display; 756 keys << QApplication::translate("VBoxGlobal", "Storage", "DetailsElementType"); values << DetailsElementType_Storage; 757 keys << QApplication::translate("VBoxGlobal", "Audio", "DetailsElementType"); values << DetailsElementType_Audio; 758 keys << QApplication::translate("VBoxGlobal", "Network", "DetailsElementType"); values << DetailsElementType_Network; 759 keys << QApplication::translate("VBoxGlobal", "Serial ports", "DetailsElementType"); values << DetailsElementType_Serial; 758 760 #ifdef VBOX_WITH_PARALLEL_PORTS 759 list.insert(QApplication::translate("VBoxGlobal", "Parallel ports", "DetailsElementType"), DetailsElementType_Parallel);761 keys << QApplication::translate("VBoxGlobal", "Parallel ports", "DetailsElementType"); values << DetailsElementType_Parallel; 760 762 #endif /* VBOX_WITH_PARALLEL_PORTS */ 761 list.insert(QApplication::translate("VBoxGlobal", "USB", "DetailsElementType"), DetailsElementType_USB);762 list.insert(QApplication::translate("VBoxGlobal", "Shared folders", "DetailsElementType"), DetailsElementType_SF);763 list.insert(QApplication::translate("VBoxGlobal", "Description", "DetailsElementType"), DetailsElementType_Description);764 if (!list.contains(strDetailsElementType))765 {766 AssertMsgFailed(("No value for '%s'", strDetailsElementType.toAscii().constData()));767 }768 return list.value(strDetailsElementType);763 keys << QApplication::translate("VBoxGlobal", "USB", "DetailsElementType"); values << DetailsElementType_USB; 764 keys << QApplication::translate("VBoxGlobal", "Shared folders", "DetailsElementType"); values << DetailsElementType_SF; 765 keys << QApplication::translate("VBoxGlobal", "Description", "DetailsElementType"); values << DetailsElementType_Description; 766 /* Invalid type for unknown words: */ 767 if (!keys.contains(strDetailsElementType, Qt::CaseInsensitive)) 768 return DetailsElementType_Invalid; 769 /* Corresponding type for known words: */ 770 return values.at(keys.indexOf(QRegExp(strDetailsElementType, Qt::CaseInsensitive))); 769 771 } 770 772 … … 801 803 template<> DetailsElementType fromInternalString<DetailsElementType>(const QString &strDetailsElementType) 802 804 { 803 QHash<QString, DetailsElementType> list; 804 list.insert("general", DetailsElementType_General); 805 list.insert("preview", DetailsElementType_Preview); 806 list.insert("system", DetailsElementType_System); 807 list.insert("display", DetailsElementType_Display); 808 list.insert("storage", DetailsElementType_Storage); 809 list.insert("audio", DetailsElementType_Audio); 810 list.insert("network", DetailsElementType_Network); 811 list.insert("serialPorts", DetailsElementType_Serial); 805 /* Here we have some fancy stuff allowing us 806 * to search through the keys using 'case-insensitive' rule: */ 807 QStringList keys; QList<DetailsElementType> values; 808 keys << "general"; values << DetailsElementType_General; 809 keys << "preview"; values << DetailsElementType_Preview; 810 keys << "system"; values << DetailsElementType_System; 811 keys << "display"; values << DetailsElementType_Display; 812 keys << "storage"; values << DetailsElementType_Storage; 813 keys << "audio"; values << DetailsElementType_Audio; 814 keys << "network"; values << DetailsElementType_Network; 815 keys << "serialPorts"; values << DetailsElementType_Serial; 812 816 #ifdef VBOX_WITH_PARALLEL_PORTS 813 list.insert("parallelPorts", DetailsElementType_Parallel);817 keys << "parallelPorts"; values << DetailsElementType_Parallel; 814 818 #endif /* VBOX_WITH_PARALLEL_PORTS */ 815 list.insert("usb", DetailsElementType_USB);816 list.insert("sharedFolders", DetailsElementType_SF);817 list.insert("description", DetailsElementType_Description);818 if (!list.contains(strDetailsElementType))819 {820 AssertMsgFailed(("No value for '%s'", strDetailsElementType.toAscii().constData()));821 }822 return list.value(strDetailsElementType);819 keys << "usb"; values << DetailsElementType_USB; 820 keys << "sharedFolders"; values << DetailsElementType_SF; 821 keys << "description"; values << DetailsElementType_Description; 822 /* Invalid type for unknown words: */ 823 if (!keys.contains(strDetailsElementType, Qt::CaseInsensitive)) 824 return DetailsElementType_Invalid; 825 /* Corresponding type for known words: */ 826 return values.at(keys.indexOf(QRegExp(strDetailsElementType, Qt::CaseInsensitive))); 823 827 } 824 828 -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h
r51531 r51532 210 210 enum DetailsElementType 211 211 { 212 DetailsElementType_Invalid, 212 213 DetailsElementType_General, 213 214 DetailsElementType_System, -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp
r51531 r51532 427 427 } 428 428 429 QMap<DetailsElementType, bool> UIExtraDataManager::selectorWindowDetailsElements() 430 { 431 /* Load corresponding extra-data: */ 432 const QStringList data = extraDataStringList(GUI_DetailsPageBoxes); 433 434 /* Prepare elements: */ 435 QMap<DetailsElementType, bool> elements; 436 /* Enumerate all the data items: */ 437 foreach (QString strItem, data) 438 { 439 bool fOpened = true; 440 if (strItem.endsWith("Closed", Qt::CaseInsensitive)) 441 { 442 fOpened = false; 443 strItem.remove("Closed"); 444 } 445 DetailsElementType type = gpConverter->fromInternalString<DetailsElementType>(strItem); 446 if (type != DetailsElementType_Invalid) 447 elements[type] = fOpened; 448 } 449 450 /* Return elements: */ 451 return elements; 452 } 453 454 void UIExtraDataManager::setSelectorWindowDetailsElements(const QMap<DetailsElementType, bool> &elements) 455 { 456 /* Prepare corresponding extra-data: */ 457 QStringList data; 458 459 /* Searialize passed elements: */ 460 foreach (DetailsElementType type, elements.keys()) 461 { 462 QString strValue = gpConverter->toInternalString(type); 463 if (!elements[type]) 464 strValue += "Closed"; 465 data << strValue; 466 } 467 468 /* Save corresponding extra-data: */ 469 setExtraDataStringList(GUI_DetailsPageBoxes, data); 470 } 471 429 472 PreviewUpdateIntervalType UIExtraDataManager::selectorWindowPreviewUpdateInterval() const 430 473 { -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h
r51531 r51532 151 151 /** Defines whether selector-window status-bar @a fVisible. */ 152 152 void setSelectorWindowStatusBarVisible(bool fVisible); 153 154 /** Returns selector-window details-pane elements. */ 155 QMap<DetailsElementType, bool> selectorWindowDetailsElements(); 156 /** Defines selector-window details-pane @a elements. */ 157 void setSelectorWindowDetailsElements(const QMap<DetailsElementType, bool> &elements); 153 158 154 159 /** Returns selector-window preview update interval. */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsGroup.cpp
r50041 r51532 25 25 #include "UIGDetailsSet.h" 26 26 #include "UIGDetailsModel.h" 27 #include "UI Converter.h"27 #include "UIExtraDataManager.h" 28 28 #include "VBoxGlobal.h" 29 29 #include "UIVMItem.h" … … 196 196 { 197 197 /* Load settings: */ 198 m_settings = vboxGlobal().virtualBox().GetExtraDataStringList(GUI_DetailsPageBoxes);198 m_settings = gEDataManager->selectorWindowDetailsElements(); 199 199 /* If settings are empty: */ 200 200 if (m_settings.isEmpty()) 201 201 { 202 202 /* Propose the defaults: */ 203 m_settings << gpConverter->toInternalString(DetailsElementType_General);204 m_settings << gpConverter->toInternalString(DetailsElementType_Preview);205 m_settings << gpConverter->toInternalString(DetailsElementType_System);206 m_settings << gpConverter->toInternalString(DetailsElementType_Display);207 m_settings << gpConverter->toInternalString(DetailsElementType_Storage);208 m_settings << gpConverter->toInternalString(DetailsElementType_Audio);209 m_settings << gpConverter->toInternalString(DetailsElementType_Network);210 m_settings << gpConverter->toInternalString(DetailsElementType_USB);211 m_settings << gpConverter->toInternalString(DetailsElementType_SF);212 m_settings << gpConverter->toInternalString(DetailsElementType_Description);213 vboxGlobal().virtualBox().SetExtraDataStringList(GUI_DetailsPageBoxes,m_settings);203 m_settings[DetailsElementType_General] = true; 204 m_settings[DetailsElementType_Preview] = true; 205 m_settings[DetailsElementType_System] = true; 206 m_settings[DetailsElementType_Display] = true; 207 m_settings[DetailsElementType_Storage] = true; 208 m_settings[DetailsElementType_Audio] = true; 209 m_settings[DetailsElementType_Network] = true; 210 m_settings[DetailsElementType_USB] = true; 211 m_settings[DetailsElementType_SF] = true; 212 m_settings[DetailsElementType_Description] = true; 213 gEDataManager->setSelectorWindowDetailsElements(m_settings); 214 214 } 215 215 } -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsGroup.h
r50041 r51532 22 22 /* GUI includes: */ 23 23 #include "UIGDetailsItem.h" 24 #include "UIExtraDataDefs.h" 24 25 25 26 /* Forward declarations: */ … … 96 97 UIBuildStep *m_pBuildStep; 97 98 QString m_strGroupId; 98 Q StringListm_settings;99 QMap<DetailsElementType, bool> m_settings; 99 100 100 101 /* Friends: */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsModel.cpp
r50041 r51532 27 27 #include "UIGDetailsGroup.h" 28 28 #include "UIGDetailsElement.h" 29 #include "UIExtraDataManager.h" 29 30 #include "VBoxGlobal.h" 30 31 #include "UIConverter.h" … … 156 157 updateLayout(); 157 158 158 /* Update details settings: */ 159 QStringList detailsSettings = vboxGlobal().virtualBox().GetExtraDataStringList(GUI_DetailsPageBoxes); 160 QString strOldElementName = gpConverter->toInternalString(type); 161 QString strNewElementName = strOldElementName; 162 if (fToggled) 163 strOldElementName += "Closed"; 164 else 165 strNewElementName += "Closed"; 166 int iIndex = detailsSettings.indexOf(strOldElementName); 167 if (iIndex != -1) 168 { 169 detailsSettings[iIndex] = strNewElementName; 170 vboxGlobal().virtualBox().SetExtraDataStringList(GUI_DetailsPageBoxes, detailsSettings); 159 /* Load elements settings to modify: */ 160 QMap<DetailsElementType, bool> settings = gEDataManager->selectorWindowDetailsElements(); 161 /* If setting for corresponding element type exists: */ 162 if (settings.contains(type)) 163 { 164 /* Update element open/close status: */ 165 settings[type] = fToggled; 166 /* Save elements settings back: */ 167 gEDataManager->setSelectorWindowDetailsElements(settings); 171 168 } 172 169 } … … 176 173 /* Which item was toggled? */ 177 174 QAction *pAction = qobject_cast<QAction*>(sender()); 178 DetailsElementType elementType = pAction->data().value<DetailsElementType>(); 179 QString strElementTypeOpened = gpConverter->toInternalString(elementType); 180 QString strElementTypeClosed = strElementTypeOpened + "Closed"; 181 QStringList detailsSettings = vboxGlobal().virtualBox().GetExtraDataStringList(GUI_DetailsPageBoxes); 182 /* Update details settings: */ 183 bool fElementExists = detailsSettings.contains(strElementTypeOpened) || 184 detailsSettings.contains(strElementTypeClosed); 185 if (fElementExists) 186 { 187 detailsSettings.removeAll(strElementTypeOpened); 188 detailsSettings.removeAll(strElementTypeClosed); 189 } 175 DetailsElementType type = pAction->data().value<DetailsElementType>(); 176 177 /* Load elements settings to modify: */ 178 QMap<DetailsElementType, bool> settings = gEDataManager->selectorWindowDetailsElements(); 179 /* Toggle element visibility setting: */ 180 if (settings.contains(type)) 181 settings.remove(type); 190 182 else 191 { 192 detailsSettings.append(strElementTypeOpened); 193 } 194 vboxGlobal().virtualBox().SetExtraDataStringList(GUI_DetailsPageBoxes, detailsSettings); 183 settings[type] = true; 184 /* Save elements settings back: */ 185 gEDataManager->setSelectorWindowDetailsElements(settings); 186 187 /* Rebuild group: */ 195 188 m_pRoot->rebuildGroup(); 196 189 } … … 267 260 /* Prepare context-menu: */ 268 261 QMenu contextMenu; 269 QStringList detailsSettings = vboxGlobal().virtualBox().GetExtraDataStringList(GUI_DetailsPageBoxes); 262 /* Load elements settings: */ 263 QMap<DetailsElementType, bool> settings = gEDataManager->selectorWindowDetailsElements(); 270 264 for (int iType = DetailsElementType_General; iType <= DetailsElementType_Description; ++iType) 271 265 { … … 273 267 QAction *pAction = contextMenu.addAction(gpConverter->toString(currentElementType), this, SLOT(sltElementTypeToggled())); 274 268 pAction->setCheckable(true); 275 QString strTypeIdOpened = gpConverter->toInternalString(currentElementType); 276 QString strTypeIdClosed = strTypeIdOpened + "Closed"; 277 pAction->setChecked(detailsSettings.contains(strTypeIdOpened) || detailsSettings.contains(strTypeIdClosed)); 269 pAction->setChecked(settings.contains(currentElementType)); 278 270 pAction->setData(QVariant::fromValue(currentElementType)); 279 271 } -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsSet.cpp
r50907 r51532 23 23 #include "UIGDetailsElements.h" 24 24 #include "UIVMItem.h" 25 #include "UIConverter.h"26 25 #include "UIVirtualBoxEventHandler.h" 27 26 #include "VBoxGlobal.h" … … 59 58 } 60 59 61 void UIGDetailsSet::buildSet(UIVMItem *pMachineItem, bool fFullSet, const Q StringList&settings)60 void UIGDetailsSet::buildSet(UIVMItem *pMachineItem, bool fFullSet, const QMap<DetailsElementType, bool> &settings) 62 61 { 63 62 /* Remember passed arguments: */ … … 100 99 const CUSBDeviceFilters &filters = m_machine.GetUSBDeviceFilters(); 101 100 if (filters.isNull() || !m_machine.GetUSBProxyAvailable()) 102 { 103 QString strElementTypeOpened = gpConverter->toInternalString(DetailsElementType_USB); 104 QString strElementTypeClosed = strElementTypeOpened + "Closed"; 105 m_settings.removeAll(strElementTypeOpened); 106 m_settings.removeAll(strElementTypeClosed); 107 } 101 m_settings.remove(DetailsElementType_USB); 108 102 109 103 /* Start building set: */ … … 126 120 /* Load details settings: */ 127 121 DetailsElementType elementType = (DetailsElementType)iStepNumber; 128 QString strElementTypeOpened = gpConverter->toInternalString(elementType);129 QString strElementTypeClosed = strElementTypeOpened + "Closed";130 122 /* Should the element be visible? */ 131 bool fVisible = m_settings.contains( strElementTypeOpened) || m_settings.contains(strElementTypeClosed);123 bool fVisible = m_settings.contains(elementType); 132 124 /* Should the element be opened? */ 133 bool fOpen = m_settings.contains(strElementTypeOpened);125 bool fOpen = fVisible && m_settings[elementType]; 134 126 135 127 /* Check if element is present already: */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsSet.h
r51187 r51532 52 52 53 53 /* API: Build stuff: */ 54 void buildSet(UIVMItem *pMachineItem, bool fFullSet, const Q StringList&settings);54 void buildSet(UIVMItem *pMachineItem, bool fFullSet, const QMap<DetailsElementType, bool> &settings); 55 55 56 56 /* API: Machine stuff: */ … … 123 123 int m_iLastStepNumber; 124 124 QString m_strSetId; 125 Q StringListm_settings;125 QMap<DetailsElementType, bool> m_settings; 126 126 }; 127 127
Note:
See TracChangeset
for help on using the changeset viewer.