Changeset 22173 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Aug 11, 2009 3:38:59 PM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h
r22157 r22173 610 610 #endif 611 611 612 bool checkForSettingsAutoConversion (bool aAfterRefresh = false);613 614 bool checkForSettingsAutoConversionAfterRefresh() { return checkForSettingsAutoConversion (true); }615 616 612 CSession openSession (const QString &aId, bool aExisting = false); 617 613 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp
r22157 r22173 2111 2111 2112 2112 /** 2113 * Checks if any of the settings files were auto-converted and informs the user2114 * if so. Returns @c false if the user select to exit the application.2115 *2116 * @param aAfterRefresh @c true to suppress the first simple dialog aExit2117 * button. Used when calling after the VM refresh.2118 */2119 bool VBoxGlobal::checkForSettingsAutoConversion (bool aAfterRefresh /* = false */)2120 {2121 QString currentVersion = mVBox.GetSettingsFormatVersion();2122 QList <CMachine> machines;2123 bool isGlobalToBeConverted = false;2124 QString fileList;2125 int maxIndex = 0;2126 2127 /* Check if VM files need to be converted */2128 CMachineVector vec = mVBox.GetMachines();2129 for (CMachineVector::ConstIterator m = vec.begin(); m != vec.end(); ++ m)2130 {2131 if (!m->GetAccessible())2132 continue;2133 2134 QString version = m->GetSettingsFileVersion();2135 if (version != currentVersion)2136 {2137 ++ maxIndex;2138 machines.append (*m);2139 fileList += QString ("<tr><td><nobr>%1</nobr></td><td> </td>"2140 "</td><td><nobr><i>%2</i></nobr></td></tr>")2141 .arg (m->GetSettingsFilePath())2142 .arg (version);2143 }2144 }2145 2146 /* Check if global file need to be converted */2147 if (!aAfterRefresh)2148 {2149 QString version = mVBox.GetSettingsFileVersion();2150 if (version != currentVersion)2151 {2152 ++ maxIndex;2153 isGlobalToBeConverted = true;2154 fileList += QString ("<tr><td><nobr>%1</nobr></td><td> </td>"2155 "</td><td><nobr><i>%2</i></nobr></td></tr>")2156 .arg (mVBox.GetSettingsFilePath())2157 .arg (version);2158 }2159 }2160 2161 if (!fileList.isNull())2162 {2163 fileList = QString ("<table cellspacing=0 cellpadding=0>%1</table>")2164 .arg (fileList);2165 2166 /* Asking the user about he wants to convert the2167 * configuration files or leave it as already is. */2168 if (vboxProblem().warnAboutSettingsAutoConversion (2169 fileList, aAfterRefresh) == QIMessageBox::Cancel)2170 return false;2171 2172 /* Composing progress dialog */2173 QProgressDialog dlg (mainWindow());2174 dlg.setCancelButton (0);2175 dlg.setWindowModality (Qt::WindowModal);2176 dlg.setMinimum (0);2177 dlg.setMaximum (maxIndex);2178 dlg.setMinimumDuration (2000);2179 dlg.setAutoReset (false);2180 2181 /* Converting VM configuration files */2182 foreach (CMachine m, machines)2183 {2184 dlg.setValue (machines.indexOf (m));2185 dlg.setLabelText (tr ("Converting file... (%1/%2)")2186 .arg (machines.indexOf (m) + 1).arg (maxIndex));2187 2188 CSession session = openSession (m.GetId());2189 if (!session.isNull())2190 {2191 CMachine sm = session.GetMachine();2192 sm.SaveSettingsWithBackup();2193 if (!sm.isOk())2194 vboxProblem().cannotSaveMachineSettings (sm);2195 session.Close();2196 }2197 }2198 2199 /* Converting global configuration file */2200 if (isGlobalToBeConverted)2201 {2202 dlg.setValue (machines.size());2203 dlg.setLabelText (tr ("Converting file... (%1/%2)")2204 .arg (machines.size() + 1).arg (maxIndex));2205 2206 mVBox.SaveSettingsWithBackup();2207 if (!mVBox.isOk())2208 vboxProblem().cannotSaveGlobalSettings (mVBox);2209 }2210 2211 dlg.setValue (maxIndex);2212 dlg.setLabelText (tr ("Conversion finished!"));2213 }2214 2215 return true;2216 }2217 2218 /**2219 2113 * Opens a direct session for a machine with the given ID. 2220 2114 * This method does user-friendly error handling (display error messages, etc.). … … 4484 4378 4485 4379 retranslateUi(); 4486 4487 /* Note: the settings conversion check must be done before anything else4488 * that may unconditionally overwrite settings files in the new format (like4489 * SetExtraData()). But after loading the proper the language. */4490 if (!checkForSettingsAutoConversion())4491 return;4492 4380 4493 4381 #ifdef VBOX_GUI_WITH_SYSTRAY -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp
r21833 r22173 1115 1115 true /* aDescription */); 1116 1116 1117 if (!oldAccessible && item->accessible() && 1118 !vboxGlobal().checkForSettingsAutoConversionAfterRefresh()) 1117 if (!oldAccessible && item->accessible()) 1119 1118 fileExit(); 1120 1119 }
Note:
See TracChangeset
for help on using the changeset viewer.