Changeset 51531 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jun 4, 2014 1:08:25 PM (11 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverter.h
r50041 r51531 88 88 } 89 89 90 /* int <= template class: */ 91 template<class T> int toInternalInteger(const T &data) const 92 { 93 if (canConvert<T>()) 94 return ::toInternalInteger(data); 95 Assert(0); return 0; 96 } 97 /* Template class <= int: */ 98 template<class T> T fromInternalInteger(const int &iData) const 99 { 100 if (canConvert<T>()) 101 return ::fromInternalInteger<T>(iData); 102 Assert(0); return T(); 103 } 104 90 105 private: 91 106 -
trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackend.h
r51484 r51531 58 58 template<class X> X fromInternalString(const QString & /* strData */) { Assert(0); return X(); } 59 59 60 /* Converts passed 'Object of type X' to abstract integer. 61 * This function returns 0 for any object type until re-determined for specific one. */ 62 template<class X> int toInternalInteger(const X & /* xobject */) { Assert(0); return 0; } 63 /* Converts passed abstract integer to 'Object of type X'. 64 * This function returns default constructed object for any object type until re-determined for specific one. */ 65 template<class X> X fromInternalInteger(const int & /* iData */) { Assert(0); return X(); } 66 60 67 /* Declare global canConvert specializations: */ 61 68 template<> bool canConvert<SizeSuffix>(); … … 74 81 template<> bool canConvert<UIVisualStateType>(); 75 82 template<> bool canConvert<DetailsElementType>(); 83 template<> bool canConvert<PreviewUpdateIntervalType>(); 76 84 template<> bool canConvert<GlobalSettingsPageType>(); 77 85 template<> bool canConvert<MachineSettingsPageType>(); … … 134 142 template<> QString toInternalString(const DetailsElementType &detailsElementType); 135 143 template<> DetailsElementType fromInternalString<DetailsElementType>(const QString &strDetailsElementType); 144 template<> QString toInternalString(const PreviewUpdateIntervalType &previewUpdateIntervalType); 145 template<> PreviewUpdateIntervalType fromInternalString<PreviewUpdateIntervalType>(const QString &strPreviewUpdateIntervalType); 146 template<> int toInternalInteger(const PreviewUpdateIntervalType &previewUpdateIntervalType); 147 template<> PreviewUpdateIntervalType fromInternalInteger<PreviewUpdateIntervalType>(const int &iPreviewUpdateIntervalType); 136 148 template<> QString toInternalString(const GlobalSettingsPageType &globalSettingsPageType); 137 149 template<> GlobalSettingsPageType fromInternalString<GlobalSettingsPageType>(const QString &strGlobalSettingsPageType); -
trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp
r51484 r51531 47 47 template<> bool canConvert<UIVisualStateType>() { return true; } 48 48 template<> bool canConvert<DetailsElementType>() { return true; } 49 template<> bool canConvert<PreviewUpdateIntervalType>() { return true; } 49 50 template<> bool canConvert<GlobalSettingsPageType>() { return true; } 50 51 template<> bool canConvert<MachineSettingsPageType>() { return true; } … … 822 823 } 823 824 825 /* QString <= PreviewUpdateIntervalType: */ 826 template<> QString toInternalString(const PreviewUpdateIntervalType &previewUpdateIntervalType) 827 { 828 /* Return corresponding QString representation for passed enum value: */ 829 switch (previewUpdateIntervalType) 830 { 831 case PreviewUpdateIntervalType_Disabled: return "disabled"; 832 case PreviewUpdateIntervalType_500ms: return "500"; 833 case PreviewUpdateIntervalType_1000ms: return "1000"; 834 case PreviewUpdateIntervalType_2000ms: return "2000"; 835 case PreviewUpdateIntervalType_5000ms: return "5000"; 836 case PreviewUpdateIntervalType_10000ms: return "10000"; 837 default: AssertMsgFailed(("No text for '%d'", previewUpdateIntervalType)); break; 838 } 839 /* Return QString() by default: */ 840 return QString(); 841 } 842 843 /* PreviewUpdateIntervalType <= QString: */ 844 template<> PreviewUpdateIntervalType fromInternalString<PreviewUpdateIntervalType>(const QString &strPreviewUpdateIntervalType) 845 { 846 /* Here we have some fancy stuff allowing us 847 * to search through the keys using 'case-insensitive' rule: */ 848 QStringList keys; QList<PreviewUpdateIntervalType> values; 849 keys << "disabled"; values << PreviewUpdateIntervalType_Disabled; 850 keys << "500"; values << PreviewUpdateIntervalType_500ms; 851 keys << "1000"; values << PreviewUpdateIntervalType_1000ms; 852 keys << "2000"; values << PreviewUpdateIntervalType_2000ms; 853 keys << "5000"; values << PreviewUpdateIntervalType_5000ms; 854 keys << "10000"; values << PreviewUpdateIntervalType_10000ms; 855 /* 1000ms type for unknown words: */ 856 if (!keys.contains(strPreviewUpdateIntervalType, Qt::CaseInsensitive)) 857 return PreviewUpdateIntervalType_1000ms; 858 /* Corresponding type for known words: */ 859 return values.at(keys.indexOf(QRegExp(strPreviewUpdateIntervalType, Qt::CaseInsensitive))); 860 } 861 862 /* int <= PreviewUpdateIntervalType: */ 863 template<> int toInternalInteger(const PreviewUpdateIntervalType &previewUpdateIntervalType) 864 { 865 /* Return corresponding integer representation for passed enum value: */ 866 switch (previewUpdateIntervalType) 867 { 868 case PreviewUpdateIntervalType_Disabled: return 0; 869 case PreviewUpdateIntervalType_500ms: return 500; 870 case PreviewUpdateIntervalType_1000ms: return 1000; 871 case PreviewUpdateIntervalType_2000ms: return 2000; 872 case PreviewUpdateIntervalType_5000ms: return 5000; 873 case PreviewUpdateIntervalType_10000ms: return 10000; 874 default: AssertMsgFailed(("No value for '%d'", previewUpdateIntervalType)); break; 875 } 876 /* Return 0 by default: */ 877 return 0; 878 } 879 880 /* PreviewUpdateIntervalType <= int: */ 881 template<> PreviewUpdateIntervalType fromInternalInteger<PreviewUpdateIntervalType>(const int &iPreviewUpdateIntervalType) 882 { 883 /* Add all the enum values into the hash: */ 884 QHash<int, PreviewUpdateIntervalType> hash; 885 hash.insert(0, PreviewUpdateIntervalType_Disabled); 886 hash.insert(500, PreviewUpdateIntervalType_500ms); 887 hash.insert(1000, PreviewUpdateIntervalType_1000ms); 888 hash.insert(2000, PreviewUpdateIntervalType_2000ms); 889 hash.insert(5000, PreviewUpdateIntervalType_5000ms); 890 hash.insert(10000, PreviewUpdateIntervalType_10000ms); 891 /* Make sure hash contains incoming integer representation: */ 892 if (!hash.contains(iPreviewUpdateIntervalType)) 893 AssertMsgFailed(("No value for '%d'", iPreviewUpdateIntervalType)); 894 /* Return corresponding enum value for passed integer representation: */ 895 return hash.value(iPreviewUpdateIntervalType); 896 } 897 824 898 /* QString <= GlobalSettingsPageType: */ 825 899 template<> QString toInternalString(const GlobalSettingsPageType &globalSettingsPageType) -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h
r51484 r51531 227 227 Q_DECLARE_METATYPE(DetailsElementType); 228 228 229 /** Selector UI: Preview update interval types. */ 230 enum PreviewUpdateIntervalType 231 { 232 PreviewUpdateIntervalType_Disabled, 233 PreviewUpdateIntervalType_500ms, 234 PreviewUpdateIntervalType_1000ms, 235 PreviewUpdateIntervalType_2000ms, 236 PreviewUpdateIntervalType_5000ms, 237 PreviewUpdateIntervalType_10000ms, 238 PreviewUpdateIntervalType_Max 239 }; 240 229 241 230 242 /** Runtime UI: Menu types. */ -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp
r51515 r51531 427 427 } 428 428 429 PreviewUpdateIntervalType UIExtraDataManager::selectorWindowPreviewUpdateInterval() const 430 { 431 return gpConverter->fromInternalString<PreviewUpdateIntervalType>(extraDataString(GUI_PreviewUpdate)); 432 } 433 434 void UIExtraDataManager::setSelectorWindowPreviewUpdateInterval(PreviewUpdateIntervalType interval) 435 { 436 setExtraDataString(GUI_PreviewUpdate, gpConverter->toInternalString(interval)); 437 } 438 429 439 bool UIExtraDataManager::isFirstRun(const QString &strId) const 430 440 { -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h
r51515 r51531 151 151 /** Defines whether selector-window status-bar @a fVisible. */ 152 152 void setSelectorWindowStatusBarVisible(bool fVisible); 153 154 /** Returns selector-window preview update interval. */ 155 PreviewUpdateIntervalType selectorWindowPreviewUpdateInterval() const; 156 /** Defines selector-window preview update @a interval. */ 157 void setSelectorWindowPreviewUpdateInterval(PreviewUpdateIntervalType interval); 153 158 154 159 /** Returns whether this machine started for the first time. */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGMachinePreview.cpp
r51411 r51531 27 27 #include "UIGMachinePreview.h" 28 28 #include "UIVirtualBoxEventHandler.h" 29 #include "UIExtraData Defs.h"29 #include "UIExtraDataManager.h" 30 30 #include "UIImageTools.h" 31 #include "UIConverter.h" 31 32 #include "UIIconPool.h" 32 33 #include "VBoxGlobal.h" … … 35 36 #include "CConsole.h" 36 37 #include "CDisplay.h" 37 38 UpdateIntervalMap CreateUpdateIntervalMap()39 {40 UpdateIntervalMap map;41 map[UpdateInterval_Disabled] = "disabled";42 map[UpdateInterval_500ms] = "500";43 map[UpdateInterval_1000ms] = "1000";44 map[UpdateInterval_2000ms] = "2000";45 map[UpdateInterval_5000ms] = "5000";46 map[UpdateInterval_10000ms] = "10000";47 return map;48 }49 UpdateIntervalMap UIGMachinePreview::m_intervals = CreateUpdateIntervalMap();50 38 51 39 UIGMachinePreview::UIGMachinePreview(QIGraphicsWidget *pParent) … … 72 60 QActionGroup *pUpdateTimeG = new QActionGroup(this); 73 61 pUpdateTimeG->setExclusive(true); 74 for(int i = 0; i < UpdateInterval_Max; ++i)62 for(int i = 0; i < PreviewUpdateIntervalType_Max; ++i) 75 63 { 76 64 QAction *pUpdateTime = new QAction(pUpdateTimeG); … … 79 67 pUpdateTimeG->addAction(pUpdateTime); 80 68 m_pUpdateTimerMenu->addAction(pUpdateTime); 81 m_actions[static_cast<UpdateInterval>(i)] = pUpdateTime; 82 } 83 m_pUpdateTimerMenu->insertSeparator(m_actions[static_cast<UpdateInterval>(UpdateInterval_500ms)]); 84 85 /* Load preview update interval: */ 86 QString strInterval = vboxGlobal().virtualBox().GetExtraData(GUI_PreviewUpdate); 87 /* Parse loaded value: */ 88 UpdateInterval interval = m_intervals.key(strInterval, UpdateInterval_1000ms); 69 m_actions[static_cast<PreviewUpdateIntervalType>(i)] = pUpdateTime; 70 } 71 m_pUpdateTimerMenu->insertSeparator(m_actions[static_cast<PreviewUpdateIntervalType>(PreviewUpdateIntervalType_500ms)]); 72 89 73 /* Initialize with the new update interval: */ 90 setUpdateInterval( interval, false);74 setUpdateInterval(gEDataManager->selectorWindowPreviewUpdateInterval(), false); 91 75 92 76 /* Setup connections: */ … … 267 251 if (pReturn) 268 252 { 269 UpdateInterval interval = static_cast<UpdateInterval>(pReturn->data().toInt());253 PreviewUpdateIntervalType interval = static_cast<PreviewUpdateIntervalType>(pReturn->data().toInt()); 270 254 setUpdateInterval(interval, true); 271 255 restart(); … … 275 259 void UIGMachinePreview::retranslateUi() 276 260 { 277 m_actions.value( UpdateInterval_Disabled)->setText(tr("Update disabled"));278 m_actions.value( UpdateInterval_500ms)->setText(tr("Every 0.5 s"));279 m_actions.value( UpdateInterval_1000ms)->setText(tr("Every 1 s"));280 m_actions.value( UpdateInterval_2000ms)->setText(tr("Every 2 s"));281 m_actions.value( UpdateInterval_5000ms)->setText(tr("Every 5 s"));282 m_actions.value( UpdateInterval_10000ms)->setText(tr("Every 10 s"));261 m_actions.value(PreviewUpdateIntervalType_Disabled)->setText(tr("Update disabled")); 262 m_actions.value(PreviewUpdateIntervalType_500ms)->setText(tr("Every 0.5 s")); 263 m_actions.value(PreviewUpdateIntervalType_1000ms)->setText(tr("Every 1 s")); 264 m_actions.value(PreviewUpdateIntervalType_2000ms)->setText(tr("Every 2 s")); 265 m_actions.value(PreviewUpdateIntervalType_5000ms)->setText(tr("Every 5 s")); 266 m_actions.value(PreviewUpdateIntervalType_10000ms)->setText(tr("Every 10 s")); 283 267 } 284 268 … … 334 318 } 335 319 336 void UIGMachinePreview::setUpdateInterval( UpdateIntervalinterval, bool fSave)320 void UIGMachinePreview::setUpdateInterval(PreviewUpdateIntervalType interval, bool fSave) 337 321 { 338 322 switch (interval) 339 323 { 340 case UpdateInterval_Disabled:324 case PreviewUpdateIntervalType_Disabled: 341 325 { 342 m_pUpdateTimer->setInterval(0);326 /* Stop the timer: */ 343 327 m_pUpdateTimer->stop(); 328 /* And continue with other cases: */ 329 } 330 case PreviewUpdateIntervalType_500ms: 331 case PreviewUpdateIntervalType_1000ms: 332 case PreviewUpdateIntervalType_2000ms: 333 case PreviewUpdateIntervalType_5000ms: 334 case PreviewUpdateIntervalType_10000ms: 335 { 336 /* Set the timer interval: */ 337 m_pUpdateTimer->setInterval(gpConverter->toInternalInteger(interval)); 338 /* Check corresponding action: */ 344 339 m_actions[interval]->setChecked(true); 345 340 break; 346 341 } 347 case UpdateInterval_500ms: 348 { 349 m_pUpdateTimer->setInterval(500); 350 m_actions[interval]->setChecked(true); 342 case PreviewUpdateIntervalType_Max: 351 343 break; 352 } 353 case UpdateInterval_1000ms: 354 { 355 m_pUpdateTimer->setInterval(1000); 356 m_actions[interval]->setChecked(true); 357 break; 358 } 359 case UpdateInterval_2000ms: 360 { 361 m_pUpdateTimer->setInterval(2000); 362 m_actions[interval]->setChecked(true); 363 break; 364 } 365 case UpdateInterval_5000ms: 366 { 367 m_pUpdateTimer->setInterval(5000); 368 m_actions[interval]->setChecked(true); 369 break; 370 } 371 case UpdateInterval_10000ms: 372 { 373 m_pUpdateTimer->setInterval(10000); 374 m_actions[interval]->setChecked(true); 375 break; 376 } 377 case UpdateInterval_Max: break; 378 } 379 if (fSave && m_intervals.contains(interval)) 380 vboxGlobal().virtualBox().SetExtraData(GUI_PreviewUpdate, m_intervals[interval]); 344 } 345 if (fSave) 346 gEDataManager->setSelectorWindowPreviewUpdateInterval(interval); 381 347 } 382 348 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGMachinePreview.h
r50924 r51531 24 24 25 25 /* GUI includes: */ 26 #include "QIWithRetranslateUI.h" 26 27 #include "UIGDetailsItem.h" 27 #include " QIWithRetranslateUI.h"28 #include "UIExtraDataDefs.h" 28 29 29 30 /* COM includes: */ … … 38 39 class QMenu; 39 40 class QTimer; 40 41 /* Update interval type: */42 enum UpdateInterval43 {44 UpdateInterval_Disabled,45 UpdateInterval_500ms,46 UpdateInterval_1000ms,47 UpdateInterval_2000ms,48 UpdateInterval_5000ms,49 UpdateInterval_10000ms,50 UpdateInterval_Max51 };52 typedef QMap<UpdateInterval, QString> UpdateIntervalMap;53 41 54 42 /* Preview window class: */ … … 97 85 98 86 /* Helpers: Update stuff: */ 99 void setUpdateInterval( UpdateIntervalinterval, bool fSave);87 void setUpdateInterval(PreviewUpdateIntervalType interval, bool fSave); 100 88 void recalculatePreviewRectangle(); 101 89 void restart(); … … 107 95 QTimer *m_pUpdateTimer; 108 96 QMenu *m_pUpdateTimerMenu; 109 QHash< UpdateInterval, QAction*> m_actions;97 QHash<PreviewUpdateIntervalType, QAction*> m_actions; 110 98 const int m_iMargin; 111 99 QRect m_vRect; … … 114 102 QImage *m_pPreviewImg; 115 103 QString m_strPreviewName; 116 static UpdateIntervalMap m_intervals;117 104 }; 118 105
Note:
See TracChangeset
for help on using the changeset viewer.