Changeset 31385 in vbox for trunk/src/VBox
- Timestamp:
- Aug 5, 2010 9:29:59 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 64444
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp
r30997 r31385 1051 1051 } 1052 1052 1053 bool VBoxProblemReporter::confirmMachineDeletion(const CMachine &machine)1053 int VBoxProblemReporter::confirmMachineDeletion(const CMachine &machine) 1054 1054 { 1055 1055 QString msg; … … 1059 1059 if (machine.GetAccessible()) 1060 1060 { 1061 name = machine.GetName(); 1062 msg = tr ("<p>Are you sure you want to permanently delete " 1063 "the virtual machine <b>%1</b>?</p>" 1064 "<p>This operation cannot be undone.</p>") 1065 .arg (name); 1066 button = tr ("Delete", "machine"); 1061 return message(&vboxGlobal().selectorWnd(), Question, 1062 tr("<p>Are you sure you want to permanently delete the virtual " 1063 "machine <b>%1</b>?</p>" 1064 "<p>This operation <i>cannot</i> be undone.</p>" 1065 "<p>If you select <b>Delete All</b> everything gets removed. This " 1066 "includes the machine itself, but also all virtual disks attached " 1067 "to it. If you want preserve the virtual disks for later use, " 1068 "select <b>Keep Harddisks</b>.</p>") 1069 .arg(machine.GetName()), 1070 0, /* aAutoConfirmId */ 1071 QIMessageBox::No, 1072 QIMessageBox::Yes, 1073 QIMessageBox::Cancel | QIMessageBox::Escape | QIMessageBox::Default, 1074 tr("Keep Harddisks", "machine"), 1075 tr("Delete All", "machine")); 1067 1076 } 1068 1077 else -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.h
r30996 r31385 236 236 int cannotEnterSeamlessMode(); 237 237 238 bool confirmMachineDeletion(const CMachine &machine);238 int confirmMachineDeletion(const CMachine &machine); 239 239 bool confirmDiscardSavedState (const CMachine &machine); 240 240 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.cpp
r31333 r31385 638 638 AssertMsgReturnVoid (item, ("Item must be always selected here")); 639 639 640 if (vboxProblem().confirmMachineDeletion (item->machine())) 641 { 642 CVirtualBox vbox = vboxGlobal().virtualBox(); 643 QString id = item->id(); 644 bool ok = false; 645 if (item->accessible()) 646 { 647 /* Open a direct session to modify VM settings */ 648 CSession session = vboxGlobal().openSession (id); 649 if (session.isNull()) 650 return; 651 CMachine machine = session.GetMachine(); 652 /* Detach all attached Hard Disks */ 653 CMediumAttachmentVector vec = machine.GetMediumAttachments(); 654 for (int i = 0; i < vec.size(); ++ i) 640 int rc = vboxProblem().confirmMachineDeletion(item->machine()); 641 if (rc != QIMessageBox::Cancel) 642 { 643 CMachine machine = item->machine(); 644 QVector<CMedium> aMedia = machine.Unregister(KCleanupMode_DetachAllReturnHardDisksOnly); // @todo replace with DetachAllReturnHardDisksOnly once a progress dialog is in place below 645 if (machine.isOk() && item->accessible()) 646 { 647 /* If not Yes, we don't want touch the harddisks */ 648 if (rc == QIMessageBox::No) 649 aMedia.clear(); 650 /* delete machine settings */ 651 CProgress progress = machine.Delete(aMedia); 652 if (machine.isOk()) 655 653 { 656 CMediumAttachment hda = vec [i]; 657 const QString ctlName = hda.GetController(); 658 659 machine.DetachDevice(ctlName, hda.GetPort(), hda.GetDevice()); 660 if (!machine.isOk()) 661 { 662 CStorageController ctl = machine.GetStorageControllerByName(ctlName); 663 vboxProblem().cannotDetachDevice (this, machine, VBoxDefs::MediumType_HardDisk, 664 vboxGlobal().getMedium (CMedium (hda.GetMedium())).location(), 665 ctl.GetBus(), hda.GetPort(), hda.GetDevice()); 666 } 654 vboxProblem().showModalProgressDialog(progress, item->name(), 0, 0); 655 if (progress.GetResultCode() != 0) 656 vboxProblem().cannotDeleteMachine(machine); 667 657 } 668 /* Commit changes */ 669 machine.SaveSettings(); 670 if (!machine.isOk()) 671 vboxProblem().cannotSaveMachineSettings (machine); 672 else 673 ok = true; 674 session.UnlockMachine(); 675 } 676 else 677 ok = true; 678 679 if (ok) 680 { 681 CMachine machine = item->machine(); 682 QVector<CMedium> aMedia = machine.Unregister(KCleanupMode_UnregisterOnly); // @todo replace with DetachAllReturnHardDisksOnly once a progress dialog is in place below 683 if (machine.isOk() && item->accessible()) 684 { 685 /* delete machine settings */ 686 CProgress progress = machine.Delete(aMedia); 687 progress.WaitForCompletion(-1); // @todo do this nicely with a progress dialog, this can delete many files! 688 689 /* remove the item shortly: cmachine it refers to is no longer valid! */ 690 int row = mVMModel->rowById (item->id()); 691 mVMModel->removeItem (item); 692 delete item; 693 mVMListView->ensureSomeRowSelected (row); 694 } 695 if (!machine.isOk()) 696 vboxProblem().cannotDeleteMachine(machine); 697 } 658 } 659 if (!machine.isOk()) 660 vboxProblem().cannotDeleteMachine(machine); 698 661 } 699 662 } … … 1205 1168 /* enable/disable modify actions */ 1206 1169 mVmConfigAction->setEnabled (modifyEnabled); 1207 mVmDeleteAction->setEnabled ( modifyEnabled);1170 mVmDeleteAction->setEnabled (!running); 1208 1171 mVmDiscardAction->setEnabled (state == KMachineState_Saved && !running); 1209 1172 mVmPauseAction->setEnabled ( state == KMachineState_Running … … 1627 1590 1628 1591 /* Delete */ 1629 mVmDeleteAction->setEnabled ( modifyEnabled);1592 mVmDeleteAction->setEnabled (!running); 1630 1593 1631 1594 /* Discard */
Note:
See TracChangeset
for help on using the changeset viewer.