Changeset 69553 in vbox for trunk/src/VBox
- Timestamp:
- Nov 2, 2017 3:11:26 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r69500 r69553 1220 1220 } 1221 1221 1222 bool UIMessageCenter::confirmMediumRelease(const UIMedium &medium, QWidget *pParent /* = 0*/) const1222 bool UIMessageCenter::confirmMediumRelease(const UIMedium &medium, bool fInduced, QWidget *pParent /* = 0 */) const 1223 1223 { 1224 1224 /* Prepare the usage: */ … … 1233 1233 } 1234 1234 /* Show the question: */ 1235 return questionBinary(pParent, MessageType_Question, 1236 tr("<p>Are you sure you want to release the disk image file <nobr><b>%1</b></nobr>?</p>" 1237 "<p>This will detach it from the following virtual machine(s): <b>%2</b>.</p>") 1238 .arg(medium.location(), usage.join(", ")), 1239 0 /* auto-confirm id */, 1240 tr("Release", "detach medium")); 1235 return !fInduced 1236 ? questionBinary(pParent, MessageType_Question, 1237 tr("<p>Are you sure you want to release the disk image file <nobr><b>%1</b></nobr>?</p>" 1238 "<p>This will detach it from the following virtual machine(s): <b>%2</b>.</p>") 1239 .arg(medium.location(), usage.join(", ")), 1240 0 /* auto-confirm id */, 1241 tr("Release", "detach medium")) 1242 : questionBinary(pParent, MessageType_Question, 1243 tr("<p>The changes you requested require this disk to " 1244 "be released from the machines it is attached to.</p>" 1245 "<p>Are you sure you want to release the disk image file <nobr><b>%1</b></nobr>?</p>" 1246 "<p>This will detach it from the following virtual machine(s): <b>%2</b>.</p>") 1247 .arg(medium.location(), usage.join(", ")), 1248 0 /* auto-confirm id */, 1249 tr("Release", "detach medium")); 1241 1250 } 1242 1251 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r69500 r69553 246 246 void cannotMoveMediumStorage(const CProgress &comProgress, const QString &strLocationOld, const QString &strLocationNew, QWidget *pParent = 0) const; 247 247 void cannotChangeMediumDescription(const CMedium &comMedium, const QString &strLocation, QWidget *pParent = 0) const; 248 bool confirmMediumRelease(const UIMedium &medium, QWidget *pParent = 0) const;248 bool confirmMediumRelease(const UIMedium &medium, bool fInduced, QWidget *pParent = 0) const; 249 249 bool confirmMediumRemoval(const UIMedium &medium, QWidget *pParent = 0) const; 250 250 int confirmDeleteHardDiskStorage(const QString &strLocation, QWidget *pParent = 0) const; -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp
r69548 r69553 78 78 /** Removes UIMedium wrapped by <i>this</i> item. */ 79 79 virtual bool remove() = 0; 80 /** Releases UIMedium wrapped by <i>this</i> item. */ 81 virtual bool release(); 80 /** Releases UIMedium wrapped by <i>this</i> item. 81 * @param fInduced Brings whether this action is caused by other user's action, 82 * not a direct order to release particularly selected medium. */ 83 virtual bool release(bool fInduced = false); 82 84 83 85 /** Refreshes item fully. */ … … 113 115 QString toolTip() const { return m_guiMedium.toolTip(); } 114 116 117 /** Returns a vector of IDs of all machines wrapped UIMedium is attached to. */ 118 const QList<QString> &machineIds() const { return m_guiMedium.machineIds(); } 115 119 /** Returns QString <i>usage</i> of the wrapped UIMedium. */ 116 120 QString usage() const { return m_guiMedium.usage(); } … … 328 332 } 329 333 330 bool UIMediumItem::release( )334 bool UIMediumItem::release(bool fInduced /* = false */) 331 335 { 332 336 /* Refresh medium and item: */ … … 339 343 340 344 /* Confirm release: */ 341 if (!msgCenter().confirmMediumRelease(medium(), treeWidget()))345 if (!msgCenter().confirmMediumRelease(medium(), fInduced, treeWidget())) 342 346 return false; 343 347 … … 979 983 && newData.m_options.m_enmType != oldData.m_options.m_enmType) 980 984 { 981 comMedium.SetType(newData.m_options.m_enmType); 982 983 /* Show error message if necessary: */ 984 if (!comMedium.isOk()) 985 msgCenter().cannotChangeMediumType(comMedium, oldData.m_options.m_enmType, newData.m_options.m_enmType, this); 985 /* Check if we need to release medium first: */ 986 bool fDo = true; 987 if ( pMediumItem->machineIds().size() > 1 988 || ( ( newData.m_options.m_enmType == KMediumType_Immutable 989 || newData.m_options.m_enmType == KMediumType_MultiAttach) 990 && pMediumItem->machineIds().size() > 0)) 991 fDo = pMediumItem->release(true); 992 993 if (fDo) 994 { 995 comMedium.SetType(newData.m_options.m_enmType); 996 997 /* Show error message if necessary: */ 998 if (!comMedium.isOk()) 999 msgCenter().cannotChangeMediumType(comMedium, oldData.m_options.m_enmType, newData.m_options.m_enmType, this); 1000 } 986 1001 } 987 1002
Note:
See TracChangeset
for help on using the changeset viewer.