Changeset 46708 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jun 20, 2013 2:32:52 PM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp
r46703 r46708 400 400 template<> IndicatorType fromInternalString<IndicatorType>(const QString &strIndicatorType) 401 401 { 402 QHash<QString, IndicatorType> list; 403 list.insert("HardDisks", IndicatorType_HardDisks); 404 list.insert("OpticalDisks", IndicatorType_OpticalDisks); 405 list.insert("FloppyDisks", IndicatorType_FloppyDisks); 406 list.insert("Network", IndicatorType_Network); 407 list.insert("USB", IndicatorType_USB); 408 list.insert("SharedFolders", IndicatorType_SharedFolders); 409 list.insert("VideoCapture", IndicatorType_VideoCapture); 410 list.insert("Features", IndicatorType_Features); 411 list.insert("Mouse", IndicatorType_Mouse); 412 list.insert("Keyboard", IndicatorType_Keyboard); 413 if (!list.contains(strIndicatorType)) 414 { 415 AssertMsgFailed(("No value for '%s'", strIndicatorType.toAscii().constData())); 416 } 417 return list.value(strIndicatorType); 402 /* Here we have some fancy stuff allowing us 403 * to search through the keys using 'case-insensitive' rule: */ 404 QStringList keys; QList<IndicatorType> values; 405 keys << "HardDisks"; values << IndicatorType_HardDisks; 406 keys << "OpticalDisks"; values << IndicatorType_OpticalDisks; 407 keys << "FloppyDisks"; values << IndicatorType_FloppyDisks; 408 keys << "Network"; values << IndicatorType_Network; 409 keys << "USB"; values << IndicatorType_USB; 410 keys << "SharedFolders"; values << IndicatorType_SharedFolders; 411 keys << "VideoCapture"; values << IndicatorType_VideoCapture; 412 keys << "Features"; values << IndicatorType_Features; 413 keys << "Mouse"; values << IndicatorType_Mouse; 414 keys << "Keyboard"; values << IndicatorType_Keyboard; 415 /* Invalid type for unknown words: */ 416 if (!keys.contains(strIndicatorType, Qt::CaseInsensitive)) 417 return IndicatorType_Invalid; 418 /* Corresponding type for known words: */ 419 return values.at(keys.indexOf(QRegExp(strIndicatorType, Qt::CaseInsensitive))); 418 420 } 419 421 … … 440 442 template<> MachineCloseAction fromInternalString<MachineCloseAction>(const QString &strMachineCloseAction) 441 443 { 442 QHash<QString, MachineCloseAction> list; 443 list.insert("Save", MachineCloseAction_Save); 444 list.insert("Shutdown", MachineCloseAction_Shutdown); 445 list.insert("PowerOff", MachineCloseAction_PowerOff); 446 list.insert("PowerOffRestoringSnapshot", MachineCloseAction_PowerOff_RestoringSnapshot); 447 if (!list.contains(strMachineCloseAction)) 444 /* Here we have some fancy stuff allowing us 445 * to search through the keys using 'case-insensitive' rule: */ 446 QStringList keys; QList<MachineCloseAction> values; 447 keys << "Save"; values << MachineCloseAction_Save; 448 keys << "Shutdown"; values << MachineCloseAction_Shutdown; 449 keys << "PowerOff"; values << MachineCloseAction_PowerOff; 450 keys << "PowerOffRestoringSnapshot"; values << MachineCloseAction_PowerOff_RestoringSnapshot; 451 /* Invalid type for unknown words: */ 452 if (!keys.contains(strMachineCloseAction, Qt::CaseInsensitive)) 448 453 return MachineCloseAction_Invalid; 449 return list.value(strMachineCloseAction); 450 } 454 /* Corresponding type for known words: */ 455 return values.at(keys.indexOf(QRegExp(strMachineCloseAction, Qt::CaseInsensitive))); 456 } -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDefs.h
r46703 r46708 244 244 enum IndicatorType 245 245 { 246 IndicatorType_Invalid, 246 247 IndicatorType_HardDisks, 247 248 IndicatorType_OpticalDisks, -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r46686 r46708 3724 3724 3725 3725 /* static */ 3726 bool VBoxGlobal::isItemRestrictedByExtraData(CMachine &machine, 3727 const QString &strExtraDataKey, 3728 const QString &strItemName) 3729 { 3730 /* Load corresponding extra-data value: */ 3731 QString strExtraDataValue(machine.GetExtraData(strExtraDataKey)); 3732 3733 /* 'false' if value was not set: */ 3734 if (strExtraDataValue.isEmpty()) 3735 return false; 3736 3737 /* Check if value represented as *string-list* contains passed *string-item*: */ 3738 return strExtraDataValue.split(",").contains(strItemName, Qt::CaseInsensitive); 3739 } 3740 3741 /* static */ 3742 bool VBoxGlobal::shouldWeShowStatusBarIndicator(CMachine &machine, const QString &strStatusBarIndicatorName) 3743 { 3744 /* Check if list of restricted status-bar indicators contains passed status-bar indicator-name: */ 3745 return !isItemRestrictedByExtraData(machine, GUI_RestrictedStatusBarIndicators, strStatusBarIndicatorName); 3726 QList<IndicatorType> VBoxGlobal::restrictedStatusBarIndicators(CMachine &machine) 3727 { 3728 /* Prepare result: */ 3729 QList<IndicatorType> result; 3730 /* Load restricted status-bar-indicators: */ 3731 QString strList(machine.GetExtraData(GUI_RestrictedStatusBarIndicators)); 3732 QStringList list = strList.split(','); 3733 /* Convert list into appropriate values: */ 3734 foreach (const QString &strValue, list) 3735 { 3736 IndicatorType value = gpConverter->fromInternalString<IndicatorType>(strValue); 3737 if (value != IndicatorType_Invalid) 3738 result << value; 3739 } 3740 /* Return result: */ 3741 return result; 3742 } 3743 3744 /* static */ 3745 QList<MachineCloseAction> VBoxGlobal::restrictedMachineCloseActions(CMachine &machine) 3746 { 3747 /* Prepare result: */ 3748 QList<MachineCloseAction> result; 3749 /* Load restricted machine-close-actions: */ 3750 QString strList(machine.GetExtraData(GUI_RestrictedCloseActions)); 3751 QStringList list = strList.split(','); 3752 /* Convert list into appropriate values: */ 3753 foreach (const QString &strValue, list) 3754 { 3755 MachineCloseAction value = gpConverter->fromInternalString<MachineCloseAction>(strValue); 3756 if (value != MachineCloseAction_Invalid) 3757 result << value; 3758 } 3759 /* Return result: */ 3760 return result; 3746 3761 } 3747 3762 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r46686 r46708 383 383 bool fIncludingMachineGeneralCheck = false); 384 384 static bool shouldWeAutoMountGuestScreens(CMachine &machine, bool fIncludingSanityCheck = true); 385 386 static bool isItemRestrictedByExtraData(CMachine &machine, const QString &strExtraDataKey, const QString &strItemName); 387 static bool shouldWeShowStatusBarIndicator(CMachine &machine, const QString &strStatusBarIndicatorName); 385 static QList<IndicatorType> restrictedStatusBarIndicators(CMachine &machine); 386 static QList<MachineCloseAction> restrictedMachineCloseActions(CMachine &machine); 388 387 389 388 #ifdef RT_OS_LINUX -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp
r46686 r46708 757 757 void UIIndicatorsPool::prepare() 758 758 { 759 /* Access machine: */759 /* Get the list of restricted indicators: */ 760 760 CMachine machine = m_session.GetMachine(); 761 QList<IndicatorType> restrictedIndicators = vboxGlobal().restrictedStatusBarIndicators(machine); 761 762 762 763 /* Populate indicator-pool: */ … … 765 766 /* Make sure indicator presence is permitted: */ 766 767 IndicatorType index = static_cast<IndicatorType>(iIndex); 767 QString strIndicatorExtraDataName = gpConverter->toInternalString(static_cast<IndicatorType>(index)); 768 if (!vboxGlobal().shouldWeShowStatusBarIndicator(machine, strIndicatorExtraDataName)) 768 if (restrictedIndicators.contains(index)) 769 769 continue; 770 770 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.cpp
r46704 r46708 281 281 282 282 /* Check which close-actions are resticted: */ 283 Q StringList restictedActionsList = m_machine.GetExtraData(GUI_RestrictedCloseActions).split(',');284 bool fIsStateSavingAllowed = !resticted ActionsList.contains("SaveState", Qt::CaseInsensitive);285 bool fIsACPIShutdownAllowed = !resticted ActionsList.contains("Shutdown", Qt::CaseInsensitive);286 bool fIsPowerOffAllowed = !resticted ActionsList.contains("PowerOff", Qt::CaseInsensitive);287 bool fIsPowerOffAndRestoreAllowed = fIsPowerOffAllowed && !resticted ActionsList.contains("Restore", Qt::CaseInsensitive);283 QList<MachineCloseAction> restictedCloseActions = vboxGlobal().restrictedMachineCloseActions(m_machine); 284 bool fIsStateSavingAllowed = !restictedCloseActions.contains(MachineCloseAction_Save); 285 bool fIsACPIShutdownAllowed = !restictedCloseActions.contains(MachineCloseAction_Shutdown); 286 bool fIsPowerOffAllowed = !restictedCloseActions.contains(MachineCloseAction_PowerOff); 287 bool fIsPowerOffAndRestoreAllowed = fIsPowerOffAllowed && !restictedCloseActions.contains(MachineCloseAction_PowerOff_RestoringSnapshot); 288 288 289 289 /* Make 'Save state' button visible/hidden depending on restriction: */
Note:
See TracChangeset
for help on using the changeset viewer.