VirtualBox

Changeset 21833 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jul 28, 2009 12:28:02 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
50460
Message:

FE/Qt4: 2705: Auto-convert settings files: Progress-bar for auto-conversion process implemented.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h

    r21481 r21833  
    610610#endif
    611611
    612     bool checkForAutoConvertedSettings (bool aAfterRefresh = false);
    613 
    614     void checkForAutoConvertedSettingsAfterRefresh()
    615     { checkForAutoConvertedSettings (true); }
     612    bool checkForSettingsAutoConversion (bool aAfterRefresh = false);
     613
     614    bool checkForSettingsAutoConversionAfterRefresh() { return checkForSettingsAutoConversion (true); }
    616615
    617616    CSession openSession (const QString &aId, bool aExisting = false);
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h

    r21777 r21833  
    324324    bool remindAboutPausedVMInput();
    325325
    326     int warnAboutAutoConvertedSettings (const QString &aFormatVersion,
    327                                         const QString &aFileList,
    328                                         bool aAfterRefresh);
     326    int warnAboutSettingsAutoConversion (const QString &aFileList, bool aAfterRefresh);
    329327
    330328    bool remindAboutInaccessibleMedia();
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp

    r21520 r21833  
    3838
    3939/* Qt includes */
     40#include <QProgressDialog>
    4041#include <QLibraryInfo>
    4142#include <QFileDialog>
     
    21062107 *                      button. Used when calling after the VM refresh.
    21072108 */
    2108 bool VBoxGlobal::checkForAutoConvertedSettings (bool aAfterRefresh /*= false*/)
    2109 {
    2110     QString formatVersion = mVBox.GetSettingsFormatVersion();
    2111 
    2112     bool isGlobalConverted = false;
     2109bool VBoxGlobal::checkForSettingsAutoConversion (bool aAfterRefresh /* = false */)
     2110{
     2111    QString currentVersion = mVBox.GetSettingsFormatVersion();
    21132112    QList <CMachine> machines;
     2113    bool isGlobalToBeConverted = false;
    21142114    QString fileList;
    2115     QString version;
    2116 
     2115    int maxIndex = 0;
     2116
     2117    /* Check if VM files need to be converted */
    21172118    CMachineVector vec = mVBox.GetMachines();
    2118     for (CMachineVector::ConstIterator m = vec.begin();
    2119          m != vec.end(); ++ m)
     2119    for (CMachineVector::ConstIterator m = vec.begin(); m != vec.end(); ++ m)
    21202120    {
    21212121        if (!m->GetAccessible())
    21222122            continue;
    21232123
    2124         version = m->GetSettingsFileVersion();
    2125         if (version != formatVersion)
    2126         {
     2124        QString version = m->GetSettingsFileVersion();
     2125        if (version != currentVersion)
     2126        {
     2127            ++ maxIndex;
    21272128            machines.append (*m);
    21282129            fileList += QString ("<tr><td><nobr>%1</nobr></td><td>&nbsp;&nbsp;</td>"
     
    21332134    }
    21342135
     2136    /* Check if global file need to be converted */
    21352137    if (!aAfterRefresh)
    21362138    {
    2137         version = mVBox.GetSettingsFileVersion();
    2138         if (version != formatVersion)
    2139         {
    2140             isGlobalConverted = true;
     2139        QString version = mVBox.GetSettingsFileVersion();
     2140        if (version != currentVersion)
     2141        {
     2142            ++ maxIndex;
     2143            isGlobalToBeConverted = true;
    21412144            fileList += QString ("<tr><td><nobr>%1</nobr></td><td>&nbsp;&nbsp;</td>"
    21422145                                 "</td><td><nobr><i>%2</i></nobr></td></tr>")
     
    21512154                            .arg (fileList);
    21522155
    2153         int rc = vboxProblem()
    2154             .warnAboutAutoConvertedSettings (formatVersion, fileList,
    2155                                              aAfterRefresh);
    2156 
    2157         if (rc == QIMessageBox::Cancel)
     2156        /* Asking the user about he wants to convert the
     2157         * configuration files or leave it as already is. */
     2158        if (vboxProblem().warnAboutSettingsAutoConversion (
     2159            fileList, aAfterRefresh) == QIMessageBox::Cancel)
    21582160            return false;
    21592161
    2160         Assert (rc == QIMessageBox::No || rc == QIMessageBox::Yes);
    2161 
    2162         /* backup (optionally) and save all settings files
    2163          * (QIMessageBox::No = Backup, QIMessageBox::Yes = Save) */
    2164 
     2162        /* Composing progress dialog */
     2163        QProgressDialog dlg (mainWindow());
     2164        dlg.setCancelButton (0);
     2165        dlg.setWindowModality (Qt::WindowModal);
     2166        dlg.setMinimum (0);
     2167        dlg.setMaximum (maxIndex);
     2168        dlg.setMinimumDuration (2000);
     2169        dlg.setAutoReset (false);
     2170
     2171        /* Converting VM configuration files */
    21652172        foreach (CMachine m, machines)
    21662173        {
     2174            dlg.setValue (machines.indexOf (m));
     2175            dlg.setLabelText (tr ("Converting file... (%1/%2)")
     2176                              .arg (machines.indexOf (m) + 1).arg (maxIndex));
     2177
    21672178            CSession session = openSession (m.GetId());
    21682179            if (!session.isNull())
    21692180            {
    21702181                CMachine sm = session.GetMachine();
    2171                 if (rc == QIMessageBox::No)
    2172                     sm.SaveSettingsWithBackup();
    2173                 else
    2174                     sm.SaveSettings();
    2175 
     2182                sm.SaveSettingsWithBackup();
    21762183                if (!sm.isOk())
    21772184                    vboxProblem().cannotSaveMachineSettings (sm);
     
    21802187        }
    21812188
    2182         if (isGlobalConverted)
    2183         {
    2184             if (rc == QIMessageBox::No)
    2185                 mVBox.SaveSettingsWithBackup();
    2186             else
    2187                 mVBox.SaveSettings();
    2188 
     2189        /* Converting global configuration file */
     2190        if (isGlobalToBeConverted)
     2191        {
     2192            dlg.setValue (machines.size());
     2193            dlg.setLabelText (tr ("Converting file... (%1/%2)")
     2194                              .arg (machines.size() + 1).arg (maxIndex));
     2195
     2196            mVBox.SaveSettingsWithBackup();
    21892197            if (!mVBox.isOk())
    21902198                vboxProblem().cannotSaveGlobalSettings (mVBox);
    21912199        }
     2200
     2201        dlg.setValue (maxIndex);
     2202        dlg.setLabelText (tr ("Conversion finished!"));
    21922203    }
    21932204
     
    44674478     * that may unconditionally overwrite settings files in the new format (like
    44684479     * SetExtraData()). But after loading the proper the language. */
    4469     if (!checkForAutoConvertedSettings())
     4480    if (!checkForSettingsAutoConversion())
    44704481        return;
    44714482
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp

    r21777 r21833  
    17511751
    17521752/**
    1753  * Shows a list of auto-converted files and asks the user to either Save, Backup
    1754  * or Cancel to leave them as is and exit VirtualBox.
     1753 * Shows user a proposal to either convert configuration files or
     1754 * Exit the application leaving all as already is.
    17551755 *
    1756  * @param aFormatVersion    Recent settings file format version.
    1757  * @param aFileList         List of auto-converted files (may use Qt HTML).
    1758  * @param aAfterRefresh     @true when called after the VM refresh.
     1756 * @param aFileList      List of files for auto-convertion (may use Qt HTML).
     1757 * @param aAfterRefresh  @true when called after the VM refresh.
    17591758 *
    1760  * @return QIMessageBox::Yes (Save), QIMessageBox::No (Backup),
    1761  *         QIMessageBox::Cancel (Exit)
     1759 * @return QIMessageBox::Ok (Save + Backup), QIMessageBox::Cancel (Exit)
    17621760 */
    1763 int VBoxProblemReporter::warnAboutAutoConvertedSettings (const QString &aFormatVersion,
    1764                                                          const QString &aFileList,
    1765                                                          bool aAfterRefresh)
    1766 {
    1767     /* The aAfterRefresh parameter says if an item which was inaccessible is
    1768        become accessible after a refresh. For the time beeing we present the
    1769        old message dialog. This case should be rather unlikly. */
     1761int VBoxProblemReporter::warnAboutSettingsAutoConversion (const QString &aFileList,
     1762                                                          bool aAfterRefresh)
     1763{
    17701764    if (!aAfterRefresh)
    17711765    {
    1772         int rc = message (mainWindowShown(), Info,
     1766        /* Common variant for all VMs */
     1767        return message (mainWindowShown(), Info,
    17731768            tr ("<p>Your existing VirtualBox settings files will be automatically "
    17741769                "converted from the old format to a new format necessary for the "
     
    17821777            0,
    17831778            0,
    1784             tr ("E&xit", "warnAboutAutoConvertedSettings message box"));
    1785 
    1786         if (rc == QIMessageBox::Cancel)
    1787             return QIMessageBox::Cancel;
    1788 
    1789         /* We backup in any case */
    1790         return QIMessageBox::No;
    1791 
    1792 #if 0
    1793         int rc = message (mainWindowShown(), Info,
    1794             tr ("<p>Your existing VirtualBox settings files were automatically "
     1779            tr ("E&xit", "warnAboutSettingsAutoConversion message box"));
     1780    }
     1781    else
     1782    {
     1783        /* Particular VM variant */
     1784        return message (mainWindowShown(), Info,
     1785            tr ("<p>The following VirtualBox settings files will be automatically "
    17951786                "converted from the old format to a new format necessary for the "
    17961787                "new version of VirtualBox.</p>"
    1797                 "<p>Press <b>OK</b> to start VirtualBox now or press <b>More</b> if "
    1798                 "you want to get more information about what files were converted "
    1799                 "and access additional actions.</p>"
    1800                 "<p>Press <b>Exit</b> to terminate the VirtualBox "
    1801                 "application without saving the results of the conversion to "
    1802                 "disk.</p>"),
     1788                "<p>Press <b>OK</b> to start VirtualBox now or press <b>Exit</b> if "
     1789                "you want to terminate the VirtualBox "
     1790                "application without any further actions.</p>"),
     1791            QString ("<!--EOM-->%1").arg (aFileList),
    18031792            NULL /* aAutoConfirmId */,
    18041793            QIMessageBox::Ok | QIMessageBox::Default,
    1805             QIMessageBox::No,
    18061794            QIMessageBox::Cancel | QIMessageBox::Escape,
    18071795            0,
    1808             tr ("&More", "warnAboutAutoConvertedSettings message box"),
    1809             tr ("E&xit", "warnAboutAutoConvertedSettings message box"));
    1810 
    1811         /* in the simplest case we backup */
    1812         if (rc == QIMessageBox::Ok)
    1813             return QIMessageBox::No;
    1814 
    1815         if (rc == QIMessageBox::Cancel)
    1816             return QIMessageBox::Cancel;
    1817 #endif
    1818     }
    1819 
    1820     return message (mainWindowShown(), Info,
    1821         tr ("<p>The following VirtualBox settings files have been "
    1822             "automatically converted to the new settings file format "
    1823             "version <b>%1</b>.</p>"
    1824             "<p>However, the results of the conversion were not saved back "
    1825             "to disk yet. Please press:</p>"
    1826             "<ul>"
    1827             "<li><b>Backup</b> to create backup copies of the settings files in "
    1828             "the old format before saving them in the new format;</li>"
    1829             "<li><b>Overwrite</b> to save all auto-converted files without "
    1830             "creating backup copies (it will not be possible to use these "
    1831             "settings files with an older version of VirtualBox "
    1832             "afterwards);</li>"
    1833             "%2"
    1834             "</ul>"
    1835             "<p>It is recommended to always select <b>Backup</b> because in "
    1836             "this case it will be possible to go back to the previous "
    1837             "version of VirtualBox (if necessary) without losing your current "
    1838             "settings. See the VirtualBox Manual for more information about "
    1839             "downgrading.</p>")
    1840             .arg (aFormatVersion)
    1841             .arg (aAfterRefresh ? QString::null :
    1842                   tr ("<li><b>Exit</b> to terminate VirtualBox without saving "
    1843                       "the results of the conversion to disk.</li>")),
    1844         QString ("<!--EOM-->%1").arg (aFileList),
    1845         NULL /* aAutoConfirmId */,
    1846         QIMessageBox::Yes,
    1847         aAfterRefresh ? (QIMessageBox::No | QIMessageBox::Default | QIMessageBox::Escape) :
    1848                         (QIMessageBox::No | QIMessageBox::Default),
    1849         aAfterRefresh ? 0 : (QIMessageBox::Cancel | QIMessageBox::Escape),
    1850         tr ("O&verwrite", "warnAboutAutoConvertedSettings message box"),
    1851         tr ("&Backup", "warnAboutAutoConvertedSettings message box"),
    1852         aAfterRefresh ? QString::null :
    1853             tr ("E&xit", "warnAboutAutoConvertedSettings message box"));
     1796            0,
     1797            tr ("E&xit", "warnAboutSettingsAutoConversion message box"));
     1798    }
    18541799}
    18551800
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp

    r21034 r21833  
    11151115                   true /* aDescription */);
    11161116
    1117     if (!oldAccessible && item->accessible())
    1118         vboxGlobal().checkForAutoConvertedSettingsAfterRefresh();
     1117    if (!oldAccessible && item->accessible() &&
     1118        !vboxGlobal().checkForSettingsAutoConversionAfterRefresh())
     1119        fileExit();
    11191120}
    11201121
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