Changeset 50906 in vbox for trunk/src/VBox
- Timestamp:
- Mar 27, 2014 2:37:16 PM (11 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDefs.cpp
r44529 r50906 1 1 /* $Id$ */ 2 2 /** @file 3 * 4 * VBox frontends: Qt GUI ("VirtualBox"): 5 * UISettingsDefs implementation 3 * VBox Qt GUI - UISettingsDefs implementation 6 4 */ 7 5 8 6 /* 9 * Copyright (C) 2011-201 2Oracle Corporation7 * Copyright (C) 2011-2014 Oracle Corporation 10 8 * 11 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 18 16 */ 19 17 20 /* VBoxincludes: */18 /* GUI includes: */ 21 19 #include "UISettingsDefs.h" 22 20 … … 24 22 using namespace UISettingsDefs; 25 23 26 /* Machine state => Settings dialog type converter: */ 27 SettingsDialogType UISettingsDefs::determineSettingsDialogType(KSessionState sessionState, KMachineState machineState) 24 ConfigurationAccessLevel UISettingsDefs::configurationAccessLevel(KSessionState sessionState, KMachineState machineState) 28 25 { 29 SettingsDialogType result = SettingsDialogType_Wrong;26 /* Depending on passed arguments: */ 30 27 switch (machineState) 31 28 { 32 29 case KMachineState_PoweredOff: 33 30 case KMachineState_Teleported: 34 case KMachineState_Aborted: 35 result = sessionState == KSessionState_Unlocked ? SettingsDialogType_Offline : 36 SettingsDialogType_Online; 37 break; 38 case KMachineState_Saved: 39 result = SettingsDialogType_Saved; 40 break; 31 case KMachineState_Aborted: return sessionState == KSessionState_Unlocked ? ConfigurationAccessLevel_Full : ConfigurationAccessLevel_Runtime; 32 case KMachineState_Saved: return ConfigurationAccessLevel_Saved; 41 33 case KMachineState_Running: 42 case KMachineState_Paused: 43 result = SettingsDialogType_Online; 44 break; 45 default: 46 break; 34 case KMachineState_Paused: return ConfigurationAccessLevel_Runtime; 35 default: break; 47 36 } 48 return result; 37 /* Null by default: */ 38 return ConfigurationAccessLevel_Null; 49 39 } 50 40 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDefs.h
r48577 r50906 1 1 /** @file 2 * 3 * VBox frontends: Qt GUI ("VirtualBox"): 4 * Header with definitions and functions related to settings window 2 * VBox Qt GUI - Header with definitions and functions related to settings configuration. 5 3 */ 6 4 7 5 /* 8 * Copyright (C) 2011-201 2Oracle Corporation6 * Copyright (C) 2011-2014 Oracle Corporation 9 7 * 10 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 15 */ 18 16 19 #ifndef __ UISettingsDefs_h__20 #define __ UISettingsDefs_h__17 #ifndef ___UISettingsDefs_h___ 18 #define ___UISettingsDefs_h___ 21 19 22 20 /* Qt includes: */ … … 27 25 #include "COMEnums.h" 28 26 29 /* Settings dialognamespace: */27 /** Settings configuration namespace: */ 30 28 namespace UISettingsDefs 31 29 { 32 /* Settings dialog types: */33 enum SettingsDialogType30 /** Configuration access levels: */ 31 enum ConfigurationAccessLevel 34 32 { 35 SettingsDialogType_Wrong,36 SettingsDialogType_Offline,37 SettingsDialogType_Saved,38 SettingsDialogType_Online33 ConfigurationAccessLevel_Null, 34 ConfigurationAccessLevel_Saved, 35 ConfigurationAccessLevel_Runtime, 36 ConfigurationAccessLevel_Full 39 37 }; 40 38 41 /* Machine state => Settings dialog type converter:*/42 SettingsDialogType determineSettingsDialogType(KSessionState sessionState, KMachineState machineState);39 /** Determines configuration access level for passed @a sessionState and @a machineState. */ 40 ConfigurationAccessLevel configurationAccessLevel(KSessionState sessionState, KMachineState machineState); 43 41 } 44 42 … … 164 162 }; 165 163 166 #endif /* __UISettingsDefs_h__ */ 167 164 #endif /* !___UISettingsDefs_h___ */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.cpp
r50890 r50906 52 52 , m_pStack(0) 53 53 /* Common variables: */ 54 , m_ dialogType(SettingsDialogType_Wrong)54 , m_configurationAccessLevel(ConfigurationAccessLevel_Null) 55 55 , m_fPolished(false) 56 56 /* Loading/saving stuff: */ … … 246 246 } 247 247 248 void UISettingsDialog::setDialogType(SettingsDialogType settingsDialogType) 249 { 250 /* Remember new dialog-type: */ 251 m_dialogType = settingsDialogType; 252 253 /* Propagate it to settings-page(s): */ 248 void UISettingsDialog::setConfigurationAccessLevel(ConfigurationAccessLevel newConfigurationAccessLevel) 249 { 250 /* Make sure something changed: */ 251 if (m_configurationAccessLevel == newConfigurationAccessLevel) 252 return; 253 254 /* Apply new configuration access level: */ 255 m_configurationAccessLevel = newConfigurationAccessLevel; 256 257 /* And propagate it to settings-page(s): */ 254 258 foreach (UISettingsPage *pPage, m_pSelector->settingPages()) 255 pPage->set DialogType(dialogType());259 pPage->setConfigurationAccessLevel(configurationAccessLevel()); 256 260 } 257 261 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.h
r50890 r50906 75 75 virtual void retranslateUi(); 76 76 77 /* Dialog type: */ 78 SettingsDialogType dialogType() { return m_dialogType; } 79 void setDialogType(SettingsDialogType settingsDialogType); 77 /** Returns configuration access level. */ 78 ConfigurationAccessLevel configurationAccessLevel() { return m_configurationAccessLevel; } 79 /** Defines configuration access level. */ 80 void setConfigurationAccessLevel(ConfigurationAccessLevel newConfigurationAccessLevel); 81 80 82 /* Dialog title: */ 81 83 virtual QString title() const = 0; … … 119 121 void assignValidator(UISettingsPage *pPage); 120 122 123 /** Holds configuration access level. */ 124 ConfigurationAccessLevel m_configurationAccessLevel; 125 121 126 /* Global Flags: */ 122 SettingsDialogType m_dialogType;123 127 bool m_fPolished; 124 128 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialogSpecific.cpp
r50890 r50906 323 323 #endif /* !Q_WS_MAC */ 324 324 325 /* Assign default dialog type: */326 setDialogType(SettingsDialogType_Offline);327 328 325 /* Creating settings pages: */ 329 326 CVirtualBox vbox = vboxGlobal().virtualBox(); … … 412 409 break; 413 410 } 414 if (pSettingsPage) 415 pSettingsPage->setDialogType(dialogType()); 416 } 417 } 411 } 412 } 413 414 /* Assign default (full) configuration access level: */ 415 setConfigurationAccessLevel(ConfigurationAccessLevel_Full); 418 416 419 417 /* Retranslate UI: */ … … 564 562 m_sessionState = m_machine.GetSessionState(); 565 563 m_machineState = m_machine.GetState(); 566 /* Recalculate current dialog-type: */567 updateDialogType();568 564 569 565 /* Creating settings pages: */ … … 672 668 break; 673 669 } 674 if (pSettingsPage) 675 pSettingsPage->setDialogType(dialogType()); 676 } 677 } 670 } 671 } 672 673 /* Recalculate configuration access level: */ 674 updateConfigurationAccessLevel(); 678 675 679 676 /* Retranslate UI: */ … … 734 731 735 732 /* Prepare session: */ 736 m_session = dialogType() == SettingsDialogType_Wrong? CSession() : vboxGlobal().openExistingSession(m_strMachineId);733 m_session = configurationAccessLevel() == ConfigurationAccessLevel_Null ? CSession() : vboxGlobal().openExistingSession(m_strMachineId); 737 734 /* Check that session was created: */ 738 735 if (m_session.isNull()) … … 742 739 m_machine = m_session.GetMachine(); 743 740 /* Get console from session: */ 744 m_console = dialogType() == SettingsDialogType_Offline? CConsole() : m_session.GetConsole();741 m_console = configurationAccessLevel() == ConfigurationAccessLevel_Full ? CConsole() : m_session.GetConsole(); 745 742 746 743 /* Prepare machine data: */ … … 773 770 774 771 /* Prepare session: */ 775 if ( dialogType() == SettingsDialogType_Wrong)772 if (configurationAccessLevel() == ConfigurationAccessLevel_Null) 776 773 m_session = CSession(); 777 else if ( dialogType() != SettingsDialogType_Offline)774 else if (configurationAccessLevel() != ConfigurationAccessLevel_Full) 778 775 m_session = vboxGlobal().openExistingSession(m_strMachineId); 779 776 else … … 786 783 m_machine = m_session.GetMachine(); 787 784 /* Get console from session: */ 788 m_console = dialogType() == SettingsDialogType_Offline? CConsole() : m_session.GetConsole();785 m_console = configurationAccessLevel() == ConfigurationAccessLevel_Full ? CConsole() : m_session.GetConsole(); 789 786 790 787 /* Prepare machine data: */ … … 1011 1008 m_sessionState = sessionState; 1012 1009 1013 /* Update dialog-type if necessary: */1014 update DialogType();1010 /* Recalculate configuration access level: */ 1011 updateConfigurationAccessLevel(); 1015 1012 } 1016 1013 … … 1028 1025 m_machineState = machineState; 1029 1026 1030 /* Update dialog-type if necessary: */1031 update DialogType();1027 /* Recalculate configuration access level: */ 1028 updateConfigurationAccessLevel(); 1032 1029 } 1033 1030 … … 1127 1124 } 1128 1125 1129 void UISettingsDialogMachine::update DialogType()1130 { 1131 /* Get new dialog type: */1132 SettingsDialogType newDialogType = determineSettingsDialogType(m_sessionState, m_machineState);1133 1134 /* Ignore if dialog type was NOT actuallychanged: */1135 if ( dialogType() == newDialogType)1126 void UISettingsDialogMachine::updateConfigurationAccessLevel() 1127 { 1128 /* Determine new configuration access level: */ 1129 ConfigurationAccessLevel newConfigurationAccessLevel = ::configurationAccessLevel(m_sessionState, m_machineState); 1130 1131 /* Make sure someting changed: */ 1132 if (configurationAccessLevel() == newConfigurationAccessLevel) 1136 1133 return; 1137 1134 1138 /* Should we show a warning about leaving 'offline' state? */1139 bool fShouldWe = dialogType() == SettingsDialogType_Offline;1140 1141 /* Update current dialog type: */1142 set DialogType(newDialogType);1143 1144 /* Show a warning about leaving 'offline' state if we should: */1145 if (isSettingsChanged() && fShouldWe )1135 /* Should we warn a user about access level decrease? */ 1136 bool fShouldWeWarn = configurationAccessLevel() == ConfigurationAccessLevel_Full; 1137 1138 /* Apply new configuration access level: */ 1139 setConfigurationAccessLevel(newConfigurationAccessLevel); 1140 1141 /* Show a warning about access level decrease if we should: */ 1142 if (isSettingsChanged() && fShouldWeWarn) 1146 1143 msgCenter().warnAboutStateChange(this); 1147 1144 } -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialogSpecific.h
r46759 r50906 91 91 bool isPageAvailable(int iPageId); 92 92 bool isSettingsChanged(); 93 void updateDialogType(); 93 94 /* Recalculates configuration access level. */ 95 void updateConfigurationAccessLevel(); 94 96 95 97 QString m_strMachineId; -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsPage.cpp
r47595 r50906 26 26 UISettingsPage::UISettingsPage(UISettingsPageType pageType) 27 27 : m_pageType(pageType) 28 , m_ dialogType(SettingsDialogType_Wrong)28 , m_configurationAccessLevel(ConfigurationAccessLevel_Null) 29 29 , m_cId(-1) 30 30 , m_fProcessed(false) -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsPage.h
r47944 r50906 108 108 UISettingsPageType pageType() const { return m_pageType; } 109 109 110 /* Settings dialog typestuff: */111 SettingsDialogType dialogType() const { return m_dialogType; }112 virtual void set DialogType(SettingsDialogType settingsDialogType) { m_dialogType = settingsDialogType; polishPage(); }113 bool isMachineOffline() const { return dialogType() == SettingsDialogType_Offline; }114 bool isMachineSaved() const { return dialogType() == SettingsDialogType_Saved; }115 bool isMachineOnline() const { return dialogType() == SettingsDialogType_Online; }110 /* Configuration access level stuff: */ 111 ConfigurationAccessLevel configurationAccessLevel() const { return m_configurationAccessLevel; } 112 virtual void setConfigurationAccessLevel(ConfigurationAccessLevel newConfigurationAccessLevel) { m_configurationAccessLevel = newConfigurationAccessLevel; polishPage(); } 113 bool isMachineOffline() const { return configurationAccessLevel() == ConfigurationAccessLevel_Full; } 114 bool isMachineSaved() const { return configurationAccessLevel() == ConfigurationAccessLevel_Saved; } 115 bool isMachineOnline() const { return configurationAccessLevel() == ConfigurationAccessLevel_Runtime; } 116 116 bool isMachineInValidMode() const { return isMachineOffline() || isMachineSaved() || isMachineOnline(); } 117 117 … … 154 154 /* Variables: */ 155 155 UISettingsPageType m_pageType; 156 SettingsDialogType m_dialogType;156 ConfigurationAccessLevel m_configurationAccessLevel; 157 157 int m_cId; 158 158 bool m_fProcessed; -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp
r50897 r50906 864 864 , mToolTipType (DefaultToolTip) 865 865 , m_chipsetType(KChipsetType_PIIX3) 866 , m_ dialogType(SettingsDialogType_Wrong)866 , m_configurationAccessLevel(ConfigurationAccessLevel_Null) 867 867 { 868 868 } … … 1034 1034 case R_IsMoreIDEControllersPossible: 1035 1035 { 1036 return (m_ dialogType == SettingsDialogType_Offline) &&1036 return (m_configurationAccessLevel == ConfigurationAccessLevel_Full) && 1037 1037 (static_cast<RootItem*>(mRootItem)->childCount(KStorageBus_IDE) < 1038 1038 vboxGlobal().virtualBox().GetSystemProperties().GetMaxInstancesOfStorageBus(chipsetType(), KStorageBus_IDE)); … … 1040 1040 case R_IsMoreSATAControllersPossible: 1041 1041 { 1042 return (m_ dialogType == SettingsDialogType_Offline) &&1042 return (m_configurationAccessLevel == ConfigurationAccessLevel_Full) && 1043 1043 (static_cast<RootItem*>(mRootItem)->childCount(KStorageBus_SATA) < 1044 1044 vboxGlobal().virtualBox().GetSystemProperties().GetMaxInstancesOfStorageBus(chipsetType(), KStorageBus_SATA)); … … 1046 1046 case R_IsMoreSCSIControllersPossible: 1047 1047 { 1048 return (m_ dialogType == SettingsDialogType_Offline) &&1048 return (m_configurationAccessLevel == ConfigurationAccessLevel_Full) && 1049 1049 (static_cast<RootItem*>(mRootItem)->childCount(KStorageBus_SCSI) < 1050 1050 vboxGlobal().virtualBox().GetSystemProperties().GetMaxInstancesOfStorageBus(chipsetType(), KStorageBus_SCSI)); … … 1052 1052 case R_IsMoreFloppyControllersPossible: 1053 1053 { 1054 return (m_ dialogType == SettingsDialogType_Offline) &&1054 return (m_configurationAccessLevel == ConfigurationAccessLevel_Full) && 1055 1055 (static_cast<RootItem*>(mRootItem)->childCount(KStorageBus_Floppy) < 1056 1056 vboxGlobal().virtualBox().GetSystemProperties().GetMaxInstancesOfStorageBus(chipsetType(), KStorageBus_Floppy)); … … 1058 1058 case R_IsMoreSASControllersPossible: 1059 1059 { 1060 return (m_ dialogType == SettingsDialogType_Offline) &&1060 return (m_configurationAccessLevel == ConfigurationAccessLevel_Full) && 1061 1061 (static_cast<RootItem*>(mRootItem)->childCount(KStorageBus_SAS) < 1062 1062 vboxGlobal().virtualBox().GetSystemProperties().GetMaxInstancesOfStorageBus(chipsetType(), KStorageBus_SAS)); … … 1064 1064 case R_IsMoreUSBControllersPossible: 1065 1065 { 1066 return (m_ dialogType == SettingsDialogType_Offline) &&1066 return (m_configurationAccessLevel == ConfigurationAccessLevel_Full) && 1067 1067 (static_cast<RootItem*>(mRootItem)->childCount(KStorageBus_USB) < 1068 1068 vboxGlobal().virtualBox().GetSystemProperties().GetMaxInstancesOfStorageBus(chipsetType(), KStorageBus_USB)); … … 1076 1076 ControllerItem *ctr = static_cast <ControllerItem*> (item); 1077 1077 CSystemProperties sp = vboxGlobal().virtualBox().GetSystemProperties(); 1078 switch (m_ dialogType)1078 switch (m_configurationAccessLevel) 1079 1079 { 1080 case SettingsDialogType_Offline: return ((uint)rowCount(aIndex) < sp.GetMaxPortCountForStorageBus(ctr->ctrBusType()) *1081 sp.GetMaxDevicesPerPortForStorageBus(ctr->ctrBusType()));1082 case SettingsDialogType_Online: return (ctr->ctrBusType() == KStorageBus_SATA) &&1083 ((uint)rowCount(aIndex) < ctr->portCount());1080 case ConfigurationAccessLevel_Full: return ((uint)rowCount(aIndex) < sp.GetMaxPortCountForStorageBus(ctr->ctrBusType()) * 1081 sp.GetMaxDevicesPerPortForStorageBus(ctr->ctrBusType())); 1082 case ConfigurationAccessLevel_Runtime: return (ctr->ctrBusType() == KStorageBus_SATA) && 1083 ((uint)rowCount(aIndex) < ctr->portCount()); 1084 1084 default: break; 1085 1085 } … … 1504 1504 beginInsertRows (parentIndex, parent->childCount(), parent->childCount()); 1505 1505 AttachmentItem *pItem = new AttachmentItem (parent, aDeviceType); 1506 pItem->setAttIsHotPluggable(m_ dialogType != SettingsDialogType_Offline);1506 pItem->setAttIsHotPluggable(m_configurationAccessLevel != ConfigurationAccessLevel_Full); 1507 1507 pItem->setAttMediumId(strMediumId); 1508 1508 endInsertRows(); … … 1617 1617 } 1618 1618 1619 void StorageModel::set DialogType(SettingsDialogType dialogType)1620 { 1621 m_ dialogType = dialogType;1619 void StorageModel::setConfigurationAccessLevel(ConfigurationAccessLevel newConfigurationAccessLevel) 1620 { 1621 m_configurationAccessLevel = newConfigurationAccessLevel; 1622 1622 } 1623 1623 … … 3812 3812 } 3813 3813 3814 void UIMachineSettingsStorage::set DialogType(SettingsDialogType settingsDialogType)3815 { 3816 /* Update model ' settings window type': */3817 mStorageModel->set DialogType(settingsDialogType);3818 /* Update ' settings window type' of base class: */3819 UISettingsPageMachine::set DialogType(settingsDialogType);3814 void UIMachineSettingsStorage::setConfigurationAccessLevel(ConfigurationAccessLevel newConfigurationAccessLevel) 3815 { 3816 /* Update model 'configuration access level': */ 3817 mStorageModel->setConfigurationAccessLevel(newConfigurationAccessLevel); 3818 /* Update 'configuration access level' of base class: */ 3819 UISettingsPageMachine::setConfigurationAccessLevel(newConfigurationAccessLevel); 3820 3820 } 3821 3821 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.h
r50885 r50906 542 542 void setChipsetType(KChipsetType type); 543 543 544 void setDialogType(SettingsDialogType settingsDialogType); 544 /** Defines configuration access level. */ 545 void setConfigurationAccessLevel(ConfigurationAccessLevel newConfigurationAccessLevel); 545 546 546 547 void clear(); … … 564 565 565 566 KChipsetType m_chipsetType; 566 SettingsDialogType m_dialogType; 567 568 /** Holds configuration access level. */ 569 ConfigurationAccessLevel m_configurationAccessLevel; 567 570 }; 568 571 Q_DECLARE_METATYPE (StorageModel::ToolTipType); … … 784 787 bool isAttachmentCouldBeUpdated(const UICacheSettingsMachineStorageAttachment &attachmentCache) const; 785 788 786 void setDialogType(SettingsDialogType settingsDialogType); 789 /** Defines configuration access level. */ 790 void setConfigurationAccessLevel(ConfigurationAccessLevel configurationAccessLevel); 791 787 792 void polishPage(); 788 793
Note:
See TracChangeset
for help on using the changeset viewer.