VirtualBox

Ignore:
Timestamp:
Aug 9, 2010 5:16:10 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
64580
Message:

FE/Qt4: confirm based on the attached disks count

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp

    r31385 r31494  
    10591059    if (machine.GetAccessible())
    10601060    {
    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"));
     1061        int cDisks = 0;
     1062        const QVector<CMediumAttachment> &mediums = machine.GetMediumAttachments();
     1063        for (int i=0; i < mediums.size(); ++i)
     1064            if (mediums.at(i).GetType() == KDeviceType_HardDisk)
     1065                ++cDisks;
     1066        const QString strDeleteBtn = tr("Delete", "machine");
     1067        const QString strDeleteAllBtn = tr("Delete All", "machine");
     1068        const QString strKeepHarddisksBtn = tr("Keep Harddisks", "machine");
     1069        const QString strText  = tr("<p>Are you sure you want to permanently delete the virtual "
     1070                                    "machine <b>%1</b>?</p>"
     1071                                    "<p>This operation <i>cannot</i> be undone.</p>")
     1072                                   .arg(machine.GetName());
     1073        const QString strText1 = tr("<p>If you select <b>%1</b> everything gets removed. This "
     1074                                    "includes the machine itself, but also the virtual disks attached "
     1075                                    "to it. If you want preserve the virtual disks for later use, "
     1076                                    "select <b>%2</b>.</p>")
     1077                                   .arg(strDeleteAllBtn)
     1078                                   .arg(strKeepHarddisksBtn);
     1079        if (cDisks == 0)
     1080            return message(&vboxGlobal().selectorWnd(), Question,
     1081                           strText,
     1082                           0, /* aAutoConfirmId */
     1083                           QIMessageBox::Yes,
     1084                           QIMessageBox::Cancel | QIMessageBox::Escape | QIMessageBox::Default,
     1085                           0,
     1086                           strDeleteBtn);
     1087        else if (cDisks == 1)
     1088            return message(&vboxGlobal().selectorWnd(), Question,
     1089                           strText + strText1,
     1090                           0, /* aAutoConfirmId */
     1091                           QIMessageBox::No,
     1092                           QIMessageBox::Yes,
     1093                           QIMessageBox::Cancel | QIMessageBox::Escape | QIMessageBox::Default,
     1094                           strKeepHarddisksBtn,
     1095                           strDeleteAllBtn);
     1096        else
     1097            return message(&vboxGlobal().selectorWnd(), Question,
     1098                           strText +
     1099                           tr("<p>You have more than one virtual disk attached. Please make sure "
     1100                              "you didn't need any of them before deletion.</p>") +
     1101                           strText1,
     1102                           0, /* aAutoConfirmId */
     1103                           QIMessageBox::No,
     1104                           QIMessageBox::Yes,
     1105                           QIMessageBox::Cancel | QIMessageBox::Escape | QIMessageBox::Default,
     1106                           strKeepHarddisksBtn,
     1107                           strDeleteAllBtn);
    10761108    }
    10771109    else
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.cpp

    r31385 r31494  
    638638    AssertMsgReturnVoid (item, ("Item must be always selected here"));
    639639
    640     int rc = vboxProblem().confirmMachineDeletion(item->machine());
     640    CMachine machine = item->machine();
     641    int rc = vboxProblem().confirmMachineDeletion(machine);
    641642    if (rc != QIMessageBox::Cancel)
    642643    {
    643         CMachine machine = item->machine();
    644644        QVector<CMedium> aMedia = machine.Unregister(KCleanupMode_DetachAllReturnHardDisksOnly);          //  @todo replace with DetachAllReturnHardDisksOnly once a progress dialog is in place below
    645645        if (machine.isOk() && item->accessible())
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette