VirtualBox

Changeset 33702 in vbox


Ignore:
Timestamp:
Nov 2, 2010 5:52:06 PM (14 years ago)
Author:
vboxsync
Message:

FE/Qt4: warn when exporting machines which are in save state

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_en.ts

    r29735 r33702  
    55    <name>VBoxGlobal</name>
    66    <message numerus="yes">
    7         <location filename="../src/globals/VBoxGlobal.h" line="377"/>
     7        <location filename="../src/globals/VBoxGlobal.h" line="201"/>
    88        <source>%n year(s)</source>
    99        <translation>
     
    1313    </message>
    1414    <message numerus="yes">
    15         <location filename="../src/globals/VBoxGlobal.h" line="382"/>
     15        <location filename="../src/globals/VBoxGlobal.h" line="206"/>
    1616        <source>%n month(s)</source>
    1717        <translation>
     
    2121    </message>
    2222    <message numerus="yes">
    23         <location filename="../src/globals/VBoxGlobal.h" line="387"/>
     23        <location filename="../src/globals/VBoxGlobal.h" line="211"/>
    2424        <source>%n day(s)</source>
    2525        <translation>
     
    2929    </message>
    3030    <message numerus="yes">
    31         <location filename="../src/globals/VBoxGlobal.h" line="392"/>
     31        <location filename="../src/globals/VBoxGlobal.h" line="216"/>
    3232        <source>%n hour(s)</source>
    3333        <translation>
     
    3737    </message>
    3838    <message numerus="yes">
    39         <location filename="../src/globals/VBoxGlobal.h" line="402"/>
     39        <location filename="../src/globals/VBoxGlobal.h" line="226"/>
    4040        <source>%n second(s)</source>
    4141        <translation>
     
    4545    </message>
    4646    <message numerus="yes">
    47         <location filename="../src/globals/VBoxGlobal.h" line="397"/>
     47        <location filename="../src/globals/VBoxGlobal.h" line="221"/>
    4848        <source>%n minute(s)</source>
    4949        <translation>
     
    5454</context>
    5555<context>
     56    <name>VBoxProblemReporter</name>
     57    <message numerus="yes">
     58        <location filename="../src/globals/VBoxProblemReporter.cpp" line="2340"/>
     59        <source>&lt;p&gt;The virtual machine(s) &lt;b&gt;%1&lt;/b&gt; are currently in a saved state.&lt;/p&gt;&lt;p&gt;If you continue the runtime state of the exported machine(s) will be discarded. Note that the existing machine(s) are not changed.&lt;/p&gt;</source>
     60        <translation>
     61            <numerusform>&lt;p&gt;The virtual machine &lt;b&gt;%1&lt;/b&gt; is currently in a saved state.&lt;/p&gt;&lt;p&gt;If you continue the runtime state of the exported machine will be discarded. Note that the existing machine is not changed.&lt;/p&gt;</numerusform>
     62            <numerusform>&lt;p&gt;The virtual machines &lt;b&gt;%1&lt;/b&gt; are currently in a saved state.&lt;/p&gt;&lt;p&gt;If you continue the runtime state of the exported machines will be discarded. Note that the existing machines are not changed.&lt;/p&gt;</numerusform>
     63        </translation>
     64    </message>
     65</context>
     66<context>
    5667    <name>VBoxTakeSnapshotDlg</name>
    5768    <message numerus="yes">
    58         <location filename="../src/VBoxTakeSnapshotDlg.cpp" line="87"/>
     69        <location filename="../src/VBoxTakeSnapshotDlg.cpp" line="74"/>
    5970        <source>Warning: You are taking a snapshot of a running machine which has %n immutable image(s) attached to it. As long as you are working from this snapshot the immutable image(s) will not be reset to avoid loss of data.</source>
    6071        <translation>
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r33631 r33702  
    33993399            .arg (tr ("PB", "size suffix PBytes=1024 TBytes"));
    34003400    return regexp;
     3401}
     3402
     3403/* static */
     3404QString VBoxGlobal::toHumanReadableList(const QStringList &list)
     3405{
     3406    QString strList;
     3407    if (list.size() == 1)
     3408        strList = list.at(0);
     3409    else if (list.size() > 1)
     3410    {
     3411        for (int i = 0; i < list.size() - 1; ++i)
     3412        {
     3413            strList += list.at(i);
     3414            if (i < list.size() - 2)
     3415                strList += + ", ";
     3416        }
     3417        strList += " " + tr("and") + " " + list.at(list.size() - 1);
     3418    }else
     3419    return strList;
    34013420}
    34023421
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r33631 r33702  
    617617    static QString sizeRegexp();
    618618
     619    static QString toHumanReadableList(const QStringList &list);
     620
    619621    static quint64 parseSize (const QString &);
    620622    static QString formatSize (quint64 aSize, uint aDecimal = 2,
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp

    r33670 r33702  
    23352335}
    23362336
     2337bool VBoxProblemReporter::confirmExportMachinesInSaveState(const QStringList &machineNames, QWidget * /* aParent  = NULL */) const
     2338{
     2339    return messageOkCancel(mainWindowShown(), Warning,
     2340        tr("<p>The virtual machine(s) <b>%1</b> are currently in a saved state.</p>"
     2341           "<p>If you "
     2342           "continue the runtime state of the exported machine(s) will be "
     2343           "discarded. Note that the existing machine(s) are not "
     2344           "changed.</p>", "", machineNames.size()).arg(VBoxGlobal::toHumanReadableList(machineNames)),
     2345        0 /* aAutoConfirmId */,
     2346        tr("Continue"), tr("Cancel"));
     2347}
     2348
    23372349void VBoxProblemReporter::cannotExportAppliance (CAppliance *aAppliance, QWidget *aParent /* = NULL */) const
    23382350{
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.h

    r33670 r33702  
    368368    void cannotRemoveFiles (const CProgress &aProgress, QWidget *aParent = NULL) const;
    369369
     370    bool confirmExportMachinesInSaveState(const QStringList &machineNames, QWidget *aParent = NULL) const;
    370371    void cannotExportAppliance (CAppliance *aAppliance, QWidget *aParent = NULL) const;
    371372    void cannotExportAppliance (const CMachine &aMachine, CAppliance *aAppliance, QWidget *aParent = NULL) const;
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIExportApplianceWzd.cpp

    r33540 r33702  
    3030public:
    3131
    32     VMListWidgetItems(QPixmap &pixIcon, QString &strText, QListWidget *pParent)
     32    VMListWidgetItems(QPixmap &pixIcon, QString &strText, QString strUuid, bool fInSaveState, QListWidget *pParent)
    3333        : QListWidgetItem(pixIcon, strText, pParent)
     34        , m_strUuid(strUuid)
     35        , m_fInSaveState(fInSaveState)
    3436    {
    3537    }
     
    4042        return text().toLower() < other.text().toLower();
    4143    }
     44
     45    QString uuid() { return m_strUuid; }
     46    bool isInSaveState() { return m_fInSaveState; }
     47
     48private:
     49    QString m_strUuid;
     50    bool m_fInSaveState;
    4251};
    4352
     
    152161}
    153162
     163bool UIExportApplianceWzdPage1::validatePage()
     164{
     165    /* Ask user about disk-less machine */
     166    QStringList savedMachines;
     167    QList<QListWidgetItem*> pItems = m_pVMSelector->selectedItems();
     168    for (int i=0; i < pItems.size(); ++i)
     169    {
     170        if (static_cast<VMListWidgetItems*>(pItems.at(i))->isInSaveState())
     171            savedMachines << pItems.at(i)->text();
     172    }
     173
     174    if (!savedMachines.isEmpty())
     175        return vboxProblem().confirmExportMachinesInSaveState(savedMachines, this);
     176
     177    return true;
     178}
     179
    154180int UIExportApplianceWzdPage1::nextId() const
    155181{
     
    167193    {
    168194        m_MachineNames << item->text();
    169         m_MachineIDs << item->data(Qt::UserRole).toString();
     195        m_MachineIDs << static_cast<VMListWidgetItems*>(item)->uuid();
    170196    }
    171197    /* Revalidate page */
     
    181207        QString strName;
    182208        QString strUuid;
    183         bool bEnabled;
     209        bool fInSaveState = false;
     210        bool fEnabled = false;
    184211        if (m.GetAccessible())
    185212        {
     
    187214            strName = m.GetName();
    188215            strUuid = m.GetId();
    189             bEnabled = m.GetSessionState() == KSessionState_Unlocked;
     216            fEnabled = m.GetSessionState() == KSessionState_Unlocked;
     217            fInSaveState = m.GetState() == KMachineState_Saved;
    190218        }
    191219        else
     
    193221            QString settingsFile = m.GetSettingsFilePath();
    194222            QFileInfo fi(settingsFile);
    195             strName = fi.completeSuffix().toLower() == "xml" ? fi.completeBaseName() : fi.fileName();
     223            strName = (fi.completeSuffix().toLower() == "xml" || fi.completeSuffix().toLower() == "vbox") ? fi.completeBaseName() : fi.fileName();
    196224            pixIcon = QPixmap(":/os_other.png").scaled(16, 16, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
    197             bEnabled = false;
    198         }
    199         QListWidgetItem *item = new VMListWidgetItems(pixIcon, strName, m_pVMSelector);
    200         item->setData(Qt::UserRole, strUuid);
    201         if (!bEnabled)
     225        }
     226        QListWidgetItem *item = new VMListWidgetItems(pixIcon, strName, strUuid, fInSaveState, m_pVMSelector);
     227        if (!fEnabled)
    202228            item->setFlags(0);
    203229        m_pVMSelector->addItem(item);
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIExportApplianceWzd.h

    r33438 r33702  
    7777
    7878    bool isComplete() const;
     79    bool validatePage();
    7980
    8081    int nextId() const;
Note: See TracChangeset for help on using the changeset viewer.

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