Changeset 98779 in vbox
- Timestamp:
- Feb 28, 2023 11:48:37 AM (21 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/UITakeSnapshotDialog.cpp
r98103 r98779 42 42 #include "UITakeSnapshotDialog.h" 43 43 44 /* COM includes: */ 45 #include "COMEnums.h" 46 #include "CMachine.h" 47 #include "CMedium.h" 48 #include "CMediumAttachment.h" 49 50 51 UITakeSnapshotDialog::UITakeSnapshotDialog(QWidget *pParent, const CMachine &comMachine) 44 45 UITakeSnapshotDialog::UITakeSnapshotDialog(QWidget *pParent, ulong cImmutableMedia) 52 46 : QIWithRetranslateUI<QIDialog>(pParent) 53 , m_comMachine(comMachine) 54 , m_cImmutableMedia(0) 47 , m_cImmutableMedia(cImmutableMedia) 55 48 , m_pLabelIcon(0) 56 49 , m_pLabelName(0), m_pEditorName(0) … … 59 52 , m_pButtonBox(0) 60 53 { 61 /* Prepare: */62 54 prepare(); 63 55 } … … 289 281 m_pLabelInfo->useSizeHintForWidth(400); 290 282 291 /* Calculate the amount of immutable attachments: */292 if (m_comMachine.GetState() == KMachineState_Paused)293 {294 foreach (const CMediumAttachment &comAttachment, m_comMachine.GetMediumAttachments())295 {296 CMedium comMedium = comAttachment.GetMedium();297 if ( !comMedium.isNull()298 && !comMedium.GetParent().isNull()299 && comMedium.GetBase().GetType() == KMediumType_Immutable)300 ++m_cImmutableMedia;301 }302 }303 283 /* Hide if machine have no immutable attachments: */ 304 284 if (!m_cImmutableMedia) -
trunk/src/VBox/Frontends/VirtualBox/src/UITakeSnapshotDialog.h
r98103 r98779 46 46 class QIDialogButtonBox; 47 47 class QILabel; 48 class CMachine;49 48 50 49 /** QIDialog subclass for taking snapshot name/description. */ … … 56 55 57 56 /** Constructs take snapshot dialog passing @ pParent to the base-class. 58 * @param c omMachine Brings the machine to take snapshot for. */59 UITakeSnapshotDialog(QWidget *pParent, const CMachine &comMachine);57 * @param cImmutableMedia Brings the amount of immutable mediums. */ 58 UITakeSnapshotDialog(QWidget *pParent, ulong cImmutableMedia); 60 59 61 60 /** Defines snapshot @a icon. */ … … 93 92 void updatePixmap(); 94 93 95 /** Holds the wrapper of machine to take snapshot for. */96 const CMachine &m_comMachine;94 /** Holds the amount of immutable mediums. */ 95 const ulong m_cImmutableMedia; 97 96 98 97 /** Holds the snapshot icon. */ 99 98 QIcon m_icon; 100 101 /** Holds the amount of immutable attachments. */102 int m_cImmutableMedia;103 99 104 100 /** Holds the icon label instance. */ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp
r98682 r98779 2164 2164 } 2165 2165 2166 /* static */ 2167 bool UICommon::acquireAmountOfImmutableImages(const CMachine &comMachine, ulong &cAmount) 2168 { 2169 /* Acquire state: */ 2170 ulong cAmountOfImmutableImages = 0; 2171 const KMachineState enmState = comMachine.GetState(); 2172 bool fSuccess = comMachine.isOk(); 2173 if (!fSuccess) 2174 UINotificationMessage::cannotAcquireMachineParameter(comMachine); 2175 else 2176 { 2177 /// @todo Who knows why 13 years ago this condition was added .. 2178 if (enmState == KMachineState_Paused) 2179 { 2180 const CMediumAttachmentVector comAttachments = comMachine.GetMediumAttachments(); 2181 fSuccess = comMachine.isOk(); 2182 if (!fSuccess) 2183 UINotificationMessage::cannotAcquireMachineParameter(comMachine); 2184 else 2185 { 2186 /* Calculate the amount of immutable attachments: */ 2187 foreach (const CMediumAttachment &comAttachment, comAttachments) 2188 { 2189 /* Get the medium: */ 2190 const CMedium comMedium = comAttachment.GetMedium(); 2191 if ( comMedium.isNull() /* Null medium is valid case as well */ 2192 || comMedium.GetParent().isNull() /* Null parent is valid case as well */) 2193 continue; 2194 /* Get the base medium: */ 2195 const CMedium comBaseMedium = comMedium.GetBase(); 2196 fSuccess = comMedium.isOk(); 2197 if (!fSuccess) 2198 UINotificationMessage::cannotAcquireMediumParameter(comMedium); 2199 else 2200 { 2201 const KMediumType enmType = comBaseMedium.GetType(); 2202 fSuccess = comBaseMedium.isOk(); 2203 if (!fSuccess) 2204 UINotificationMessage::cannotAcquireMediumParameter(comBaseMedium); 2205 else if (enmType == KMediumType_Immutable) 2206 ++cAmountOfImmutableImages; 2207 } 2208 if (!fSuccess) 2209 break; 2210 } 2211 } 2212 } 2213 } 2214 if (fSuccess) 2215 cAmount = cAmountOfImmutableImages; 2216 return fSuccess; 2217 } 2218 2166 2219 #ifdef RT_OS_LINUX 2167 2220 /* static */ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h
r98682 r98779 441 441 * @param enmMediumType Passes the medium type. */ 442 442 QString defaultFolderPathForType(UIMediumDeviceType enmMediumType); 443 444 /** Calculates @a cAmount of immutable images used by @a comMachine specified. */ 445 static bool acquireAmountOfImmutableImages(const CMachine &comMachine, ulong &cAmount); 443 446 /** @} */ 444 447 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp
r98776 r98779 735 735 { 736 736 return uisession()->addEncryptionPassword(strId, strPassword, fClearOnSuspend); 737 } 738 739 bool UIMachine::acquireAmountOfImmutableImages(ulong &cAmount) 740 { 741 return uisession()->acquireAmountOfImmutableImages(cAmount); 737 742 } 738 743 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h
r98776 r98779 508 508 /** Adds encryption password. */ 509 509 bool addEncryptionPassword(const QString &strId, const QString &strPassword, bool fClearOnSuspend); 510 511 /** Calculates @a cAmount of immutable images. */ 512 bool acquireAmountOfImmutableImages(ulong &cAmount); 510 513 /** @} */ 511 514 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r98776 r98779 1587 1587 return; 1588 1588 1589 /* First of all, we should calculate amount of immutable images: */ 1590 ulong cAmountOfImmutableMediums = 0; 1591 uimachine()->acquireAmountOfImmutableImages(cAmountOfImmutableMediums); 1592 1589 1593 /* Create take-snapshot dialog: */ 1590 1594 QWidget *pDlgParent = windowManager().realParentWindow(activeMachineWindow()); 1591 QPointer<UITakeSnapshotDialog> pDlg = new UITakeSnapshotDialog(pDlgParent, machine());1595 QPointer<UITakeSnapshotDialog> pDlg = new UITakeSnapshotDialog(pDlgParent, cAmountOfImmutableMediums); 1592 1596 windowManager().registerNewParent(pDlg, pDlgParent); 1593 1597 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r98776 r98779 552 552 msgCenter().cannotAddDiskEncryptionPassword(comConsole); 553 553 return fSuccess; 554 } 555 556 bool UISession::acquireAmountOfImmutableImages(ulong &cAmount) 557 { 558 CMachine comMachine = machine(); 559 return UICommon::acquireAmountOfImmutableImages(comMachine, cAmount); 554 560 } 555 561 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r98776 r98779 325 325 /** Adds encryption password. */ 326 326 bool addEncryptionPassword(const QString &strId, const QString &strPassword, bool fClearOnSuspend); 327 328 /** Calculates @a cAmount of immutable images. */ 329 bool acquireAmountOfImmutableImages(ulong &cAmount); 327 330 /** @} */ 328 331 -
trunk/src/VBox/Frontends/VirtualBox/src/snapshots/UISnapshotPane.cpp
r98103 r98779 1621 1621 if (!fAutomatically) 1622 1622 { 1623 /* First of all, we should calculate amount of immutable images: */ 1624 ulong cAmountOfImmutableMediums = 0; 1625 UICommon::acquireAmountOfImmutableImages(comMachine, cAmountOfImmutableMediums); 1626 1623 1627 /* Create take-snapshot dialog: */ 1624 1628 QWidget *pDlgParent = windowManager().realParentWindow(this); 1625 QPointer<UITakeSnapshotDialog> pDlg = new UITakeSnapshotDialog(pDlgParent, c omMachine);1629 QPointer<UITakeSnapshotDialog> pDlg = new UITakeSnapshotDialog(pDlgParent, cAmountOfImmutableMediums); 1626 1630 windowManager().registerNewParent(pDlg, pDlgParent); 1627 1631
Note:
See TracChangeset
for help on using the changeset viewer.