Changeset 21833 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jul 28, 2009 12:28:02 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 50460
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h
r21481 r21833 610 610 #endif 611 611 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); } 616 615 617 616 CSession openSession (const QString &aId, bool aExisting = false); -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h
r21777 r21833 324 324 bool remindAboutPausedVMInput(); 325 325 326 int warnAboutAutoConvertedSettings (const QString &aFormatVersion, 327 const QString &aFileList, 328 bool aAfterRefresh); 326 int warnAboutSettingsAutoConversion (const QString &aFileList, bool aAfterRefresh); 329 327 330 328 bool remindAboutInaccessibleMedia(); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp
r21520 r21833 38 38 39 39 /* Qt includes */ 40 #include <QProgressDialog> 40 41 #include <QLibraryInfo> 41 42 #include <QFileDialog> … … 2106 2107 * button. Used when calling after the VM refresh. 2107 2108 */ 2108 bool VBoxGlobal::checkForAutoConvertedSettings (bool aAfterRefresh /*= false*/) 2109 { 2110 QString formatVersion = mVBox.GetSettingsFormatVersion(); 2111 2112 bool isGlobalConverted = false; 2109 bool VBoxGlobal::checkForSettingsAutoConversion (bool aAfterRefresh /* = false */) 2110 { 2111 QString currentVersion = mVBox.GetSettingsFormatVersion(); 2113 2112 QList <CMachine> machines; 2113 bool isGlobalToBeConverted = false; 2114 2114 QString fileList; 2115 QString version; 2116 2115 int maxIndex = 0; 2116 2117 /* Check if VM files need to be converted */ 2117 2118 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) 2120 2120 { 2121 2121 if (!m->GetAccessible()) 2122 2122 continue; 2123 2123 2124 version = m->GetSettingsFileVersion(); 2125 if (version != formatVersion) 2126 { 2124 QString version = m->GetSettingsFileVersion(); 2125 if (version != currentVersion) 2126 { 2127 ++ maxIndex; 2127 2128 machines.append (*m); 2128 2129 fileList += QString ("<tr><td><nobr>%1</nobr></td><td> </td>" … … 2133 2134 } 2134 2135 2136 /* Check if global file need to be converted */ 2135 2137 if (!aAfterRefresh) 2136 2138 { 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; 2141 2144 fileList += QString ("<tr><td><nobr>%1</nobr></td><td> </td>" 2142 2145 "</td><td><nobr><i>%2</i></nobr></td></tr>") … … 2151 2154 .arg (fileList); 2152 2155 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) 2158 2160 return false; 2159 2161 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 */ 2165 2172 foreach (CMachine m, machines) 2166 2173 { 2174 dlg.setValue (machines.indexOf (m)); 2175 dlg.setLabelText (tr ("Converting file... (%1/%2)") 2176 .arg (machines.indexOf (m) + 1).arg (maxIndex)); 2177 2167 2178 CSession session = openSession (m.GetId()); 2168 2179 if (!session.isNull()) 2169 2180 { 2170 2181 CMachine sm = session.GetMachine(); 2171 if (rc == QIMessageBox::No) 2172 sm.SaveSettingsWithBackup(); 2173 else 2174 sm.SaveSettings(); 2175 2182 sm.SaveSettingsWithBackup(); 2176 2183 if (!sm.isOk()) 2177 2184 vboxProblem().cannotSaveMachineSettings (sm); … … 2180 2187 } 2181 2188 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(); 2189 2197 if (!mVBox.isOk()) 2190 2198 vboxProblem().cannotSaveGlobalSettings (mVBox); 2191 2199 } 2200 2201 dlg.setValue (maxIndex); 2202 dlg.setLabelText (tr ("Conversion finished!")); 2192 2203 } 2193 2204 … … 4467 4478 * that may unconditionally overwrite settings files in the new format (like 4468 4479 * SetExtraData()). But after loading the proper the language. */ 4469 if (!checkFor AutoConvertedSettings())4480 if (!checkForSettingsAutoConversion()) 4470 4481 return; 4471 4482 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp
r21777 r21833 1751 1751 1752 1752 /** 1753 * Shows a list of auto-converted files and asks the user to either Save, Backup1754 * 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. 1755 1755 * 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. 1759 1758 * 1760 * @return QIMessageBox::Yes (Save), QIMessageBox::No (Backup), 1761 * QIMessageBox::Cancel (Exit) 1759 * @return QIMessageBox::Ok (Save + Backup), QIMessageBox::Cancel (Exit) 1762 1760 */ 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. */ 1761 int VBoxProblemReporter::warnAboutSettingsAutoConversion (const QString &aFileList, 1762 bool aAfterRefresh) 1763 { 1770 1764 if (!aAfterRefresh) 1771 1765 { 1772 int rc = message (mainWindowShown(), Info, 1766 /* Common variant for all VMs */ 1767 return message (mainWindowShown(), Info, 1773 1768 tr ("<p>Your existing VirtualBox settings files will be automatically " 1774 1769 "converted from the old format to a new format necessary for the " … … 1782 1777 0, 1783 1778 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 " 1795 1786 "converted from the old format to a new format necessary for the " 1796 1787 "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), 1803 1792 NULL /* aAutoConfirmId */, 1804 1793 QIMessageBox::Ok | QIMessageBox::Default, 1805 QIMessageBox::No,1806 1794 QIMessageBox::Cancel | QIMessageBox::Escape, 1807 1795 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 } 1854 1799 } 1855 1800 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp
r21034 r21833 1115 1115 true /* aDescription */); 1116 1116 1117 if (!oldAccessible && item->accessible()) 1118 vboxGlobal().checkForAutoConvertedSettingsAfterRefresh(); 1117 if (!oldAccessible && item->accessible() && 1118 !vboxGlobal().checkForSettingsAutoConversionAfterRefresh()) 1119 fileExit(); 1119 1120 } 1120 1121
Note:
See TracChangeset
for help on using the changeset viewer.