Changeset 78353 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Apr 29, 2019 5:19:02 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/medium
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDetailsWidget.cpp
r76606 r78353 83 83 } 84 84 85 void UIMediumDetailsWidget::enableDisableMediumModificationWidgets(bool fMediumIsModifiable) 86 { 87 if (m_pComboBoxType) 88 m_pComboBoxType->setEnabled(fMediumIsModifiable); 89 if (m_pEditorLocation) 90 m_pEditorLocation->setEnabled(fMediumIsModifiable); 91 if (m_pEditorSize) 92 m_pEditorSize->setEnabled(fMediumIsModifiable); 93 } 94 85 95 void UIMediumDetailsWidget::setOptionsEnabled(bool fEnabled) 86 96 { … … 134 144 void UIMediumDetailsWidget::sltTypeIndexChanged(int iIndex) 135 145 { 136 m_newData.m_options.m_enm Type = m_pComboBoxType->itemData(iIndex).value<KMediumType>();146 m_newData.m_options.m_enmMediumType = m_pComboBoxType->itemData(iIndex).value<KMediumType>(); 137 147 revalidate(m_pErrorPaneType); 138 148 updateButtonStates(); … … 620 630 { 621 631 /* Populate type combo-box: */ 622 switch (m_newData.m_enm Type)632 switch (m_newData.m_enmDeviceType) 623 633 { 624 634 case UIMediumDeviceType_HardDisk: … … 626 636 /* No type changes for differencing disks: */ 627 637 if (m_oldData.m_enmVariant & KMediumVariant_Diff) 628 m_pComboBoxType->addItem(QString(), m_oldData.m_options.m_enm Type);638 m_pComboBoxType->addItem(QString(), m_oldData.m_options.m_enmMediumType); 629 639 else 630 640 { … … 664 674 /* Choose the item with required type to be the current one: */ 665 675 for (int i = 0; i < m_pComboBoxType->count(); ++i) 666 if (m_pComboBoxType->itemData(i).value<KMediumType>() == m_newData.m_options.m_enm Type)676 if (m_pComboBoxType->itemData(i).value<KMediumType>() == m_newData.m_options.m_enmMediumType) 667 677 m_pComboBoxType->setCurrentIndex(i); 668 678 sltTypeIndexChanged(m_pComboBoxType->currentIndex()); … … 681 691 /* Load size: */ 682 692 const bool fEnableResize = m_newData.m_fValid 683 && m_newData.m_enm Type == UIMediumDeviceType_HardDisk693 && m_newData.m_enmDeviceType == UIMediumDeviceType_HardDisk 684 694 && !(m_newData.m_enmVariant & KMediumVariant_Fixed); 685 695 m_pLabelSize->setEnabled(fEnableResize); … … 695 705 { 696 706 /* Get information-labels just to acquire their number: */ 697 const QList<QLabel*> aLabels = m_aLabels.value(m_newData.m_enm Type, QList<QLabel*>());707 const QList<QLabel*> aLabels = m_aLabels.value(m_newData.m_enmDeviceType, QList<QLabel*>()); 698 708 /* Get information-fields just to acquire their number: */ 699 const QList<QILabel*> aFields = m_aFields.value(m_newData.m_enm Type, QList<QILabel*>());709 const QList<QILabel*> aFields = m_aFields.value(m_newData.m_enmDeviceType, QList<QILabel*>()); 700 710 /* For each the label => update contents: */ 701 711 for (int i = 0; i < aLabels.size(); ++i) 702 infoLabel(m_newData.m_enm Type, i)->setText(m_newData.m_details.m_aLabels.value(i, QString()));712 infoLabel(m_newData.m_enmDeviceType, i)->setText(m_newData.m_details.m_aLabels.value(i, QString())); 703 713 /* For each the field => update contents: */ 704 714 for (int i = 0; i < aFields.size(); ++i) 705 715 { 706 infoField(m_newData.m_enm Type, i)->setText(m_newData.m_details.m_aFields.value(i, QString()));707 infoField(m_newData.m_enm Type, i)->setEnabled(!infoField(m_newData.m_enmType, i)->text().trimmed().isEmpty());716 infoField(m_newData.m_enmDeviceType, i)->setText(m_newData.m_details.m_aFields.value(i, QString())); 717 infoField(m_newData.m_enmDeviceType, i)->setEnabled(!infoField(m_newData.m_enmDeviceType, i)->text().trimmed().isEmpty()); 708 718 } 709 719 } … … 846 856 return aFields.value(iIndex, 0); 847 857 } 848 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDetailsWidget.h
r76581 r78353 54 54 /** Constructs data. */ 55 55 UIDataMediumOptions() 56 : m_enm Type(KMediumType_Normal)56 : m_enmMediumType(KMediumType_Normal) 57 57 , m_strLocation(QString()) 58 58 , m_strDescription(QString()) … … 64 64 { 65 65 return true 66 && (m_enm Type == other.m_enmType)66 && (m_enmMediumType == other.m_enmMediumType) 67 67 && (m_strLocation == other.m_strLocation) 68 68 && (m_strDescription == other.m_strDescription) … … 76 76 bool operator!=(const UIDataMediumOptions &other) const { return !equal(other); } 77 77 78 /** Holds the type. */79 KMediumType m_enm Type;78 /** Holds the medium type. */ 79 KMediumType m_enmMediumType; 80 80 /** Holds the location. */ 81 81 QString m_strLocation; … … 123 123 UIDataMedium() 124 124 : m_fValid(false) 125 , m_enm Type(UIMediumDeviceType_Invalid)125 , m_enmDeviceType(UIMediumDeviceType_Invalid) 126 126 , m_enmVariant(KMediumVariant_Max) 127 127 , m_fHasChildren(false) … … 133 133 UIDataMedium(UIMediumDeviceType enmType) 134 134 : m_fValid(false) 135 , m_enm Type(enmType)135 , m_enmDeviceType(enmType) 136 136 , m_enmVariant(KMediumVariant_Max) 137 137 , m_fHasChildren(false) … … 145 145 return true 146 146 && (m_fValid == other.m_fValid) 147 && (m_enm Type == other.m_enmType)147 && (m_enmDeviceType == other.m_enmDeviceType) 148 148 && (m_enmVariant == other.m_enmVariant) 149 149 && (m_fHasChildren == other.m_fHasChildren) … … 161 161 bool m_fValid; 162 162 /** Holds the medium type. */ 163 UIMediumDeviceType m_enm Type;163 UIMediumDeviceType m_enmDeviceType; 164 164 /** Holds the medium variant. */ 165 165 KMediumVariant m_enmVariant; … … 204 204 /** Defines the @a data for passed @a enmType. */ 205 205 void setData(const UIDataMedium &data); 206 /** Enables/disables some of the medium editing widgets of the details tab. */ 207 void enableDisableMediumModificationWidgets(bool fMediumIsModifiable); 208 206 209 207 210 public slots: … … 355 358 356 359 #endif /* !FEQT_INCLUDED_SRC_medium_UIMediumDetailsWidget_h */ 357 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumItem.cpp
r76606 r78353 174 174 } 175 175 176 bool UIMediumItem::isMediumModifiable() const 177 { 178 if (medium().isNull()) 179 return false; 180 foreach (const QUuid &uMachineId, medium().curStateMachineIds()) 181 { 182 CMachine comMachine = vboxGlobal().virtualBox().FindMachine(uMachineId.toString()); 183 if (comMachine.isNull()) 184 continue; 185 if (comMachine.GetState() != KMachineState_PoweredOff && 186 comMachine.GetState() != KMachineState_Aborted) 187 return false; 188 } 189 return true; 190 } 191 192 bool UIMediumItem::isMediumAttachedTo(QUuid uId) 193 { 194 if (medium().isNull()) 195 return false; 196 return medium().curStateMachineIds().contains(uId); 197 } 198 176 199 QString UIMediumItem::defaultText() const 177 200 { … … 197 220 m_fValid = !m_guiMedium.isNull() 198 221 && m_guiMedium.state() != KMediumState_Inaccessible; 199 m_enm Type = m_guiMedium.type();222 m_enmDeviceType = m_guiMedium.type(); 200 223 m_enmVariant = m_guiMedium.mediumVariant(); 201 224 m_fHasChildren = m_guiMedium.hasChildren(); 202 225 /* Gather medium options data: */ 203 m_options.m_enm Type = m_guiMedium.mediumType();226 m_options.m_enmMediumType = m_guiMedium.mediumType(); 204 227 m_options.m_strLocation = m_guiMedium.location(); 205 228 m_options.m_uLogicalSize = m_guiMedium.logicalSizeInBytes(); … … 207 230 /* Gather medium details data: */ 208 231 m_details.m_aFields.clear(); 209 switch (m_enm Type)232 switch (m_enmDeviceType) 210 233 { 211 234 case UIMediumDeviceType_HardDisk: -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumItem.h
r76998 r78353 104 104 /** Returns whether <i>this</i> item is less than @a other one. */ 105 105 bool operator<(const QTreeWidgetItem &other) const; 106 /** Returns whether the medium can be modified. For 107 * simplicity's sake this returns false if one of the attached vms is not 108 * in PoweredOff or Aborted state. */ 109 bool isMediumModifiable() const; 110 /** Returns true if the medium is attached to the vm with @p uId. */ 111 bool isMediumAttachedTo(QUuid uId); 106 112 107 113 protected: -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp
r77359 r78353 43 43 #include "UIIconPool.h" 44 44 #include "UIMedium.h" 45 #include "UIVirtualBoxEventHandler.h" 45 46 46 47 /* COM includes: */ … … 271 272 /* Try to assign new medium type: */ 272 273 if ( comMedium.isOk() 273 && newData.m_options.m_enm Type != oldData.m_options.m_enmType)274 && newData.m_options.m_enmMediumType != oldData.m_options.m_enmMediumType) 274 275 { 275 276 /* Check if we need to release medium first: */ 276 277 bool fDo = true; 277 278 if ( pMediumItem->machineIds().size() > 1 278 || ( ( newData.m_options.m_enm Type == KMediumType_Immutable279 || newData.m_options.m_enm Type == KMediumType_MultiAttach)279 || ( ( newData.m_options.m_enmMediumType == KMediumType_Immutable 280 || newData.m_options.m_enmMediumType == KMediumType_MultiAttach) 280 281 && pMediumItem->machineIds().size() > 0)) 281 282 fDo = pMediumItem->release(true); … … 283 284 if (fDo) 284 285 { 285 comMedium.SetType(newData.m_options.m_enm Type);286 comMedium.SetType(newData.m_options.m_enmMediumType); 286 287 287 288 /* Show error message if necessary: */ 288 289 if (!comMedium.isOk()) 289 msgCenter().cannotChangeMediumType(comMedium, oldData.m_options.m_enm Type, newData.m_options.m_enmType, this);290 msgCenter().cannotChangeMediumType(comMedium, oldData.m_options.m_enmMediumType, newData.m_options.m_enmMediumType, this); 290 291 } 291 292 } … … 486 487 } 487 488 489 void UIMediumManagerWidget::sltHandleMachineStateChange(const QUuid &uId, const KMachineState state) 490 { 491 UIMediumItem *pCurrentItem = currentMediumItem(); 492 if (!pCurrentItem) 493 return; 494 /* If this machine is not using the current medium then we don't care about its state: */ 495 if (!pCurrentItem->isMediumAttachedTo(uId)) 496 return; 497 bool fMediumIsModifiable = true; 498 if (state != KMachineState_Aborted && state != KMachineState_PoweredOff) 499 fMediumIsModifiable = false; 500 m_pDetailsWidget->enableDisableMediumModificationWidgets(fMediumIsModifiable); 501 } 502 488 503 void UIMediumManagerWidget::sltAddMedium() 489 504 { … … 719 734 void UIMediumManagerWidget::prepareConnections() 720 735 { 736 /* Listen to vm state changed event so that we can disable/enable widgets related to the current medium if neds be: */ 737 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineStateChange, 738 this, &UIMediumManagerWidget::sltHandleMachineStateChange); 739 721 740 /* Configure medium-processing connections: */ 722 741 connect(&vboxGlobal(), &VBoxGlobal::sigMediumCreated, … … 1040 1059 /* Update details-widget: */ 1041 1060 if (m_pDetailsWidget) 1061 { 1042 1062 m_pDetailsWidget->setData(pMediumItem ? *pMediumItem : UIDataMedium(type)); 1063 if (pMediumItem) 1064 m_pDetailsWidget->enableDisableMediumModificationWidgets(currentMediumItem()->isMediumModifiable()); 1065 } 1043 1066 } 1044 1067 … … 1594 1617 1595 1618 /********************************************************************************************************************************* 1596 * Class UIMediumManager Factoryimplementation. *1619 * Class UIMediumManager implementation. * 1597 1620 *********************************************************************************************************************************/ 1598 1621 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.h
r77255 r78353 162 162 /** Handles VBoxGlobal::sigMediumEnumerationFinished signal. */ 163 163 void sltHandleMediumEnumerationFinish(); 164 void sltHandleMachineStateChange(const QUuid &uId, const KMachineState state); 164 165 /** @} */ 165 166
Note:
See TracChangeset
for help on using the changeset viewer.