Changeset 35079 in vbox
- Timestamp:
- Dec 14, 2010 1:44:16 PM (14 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp
r35014 r35079 2177 2177 } 2178 2178 2179 bool VBoxProblemReporter::confirmReplacePackage(const QString &strPackName, const QString &strPackVersionNew, 2180 const QString &strPackVersionOld, const QString &strPackDescription, 2181 QWidget *pParent /* = 0 */) 2182 { 2183 if (!pParent) 2184 pParent = pParent ? pParent : mainWindowShown(); /* this is boring stuff that messageOkCancel should do! */ 2185 2186 QString strBelehrung = tr("Extension packs complement the functionality of VirtualBox and can contain " 2187 "system level software that could be potentially harmful to your system. " 2188 "Please review the description below and only proceed if you have obtained " 2189 "the extension pack from a trusted source."); 2190 2191 QByteArray ba1 = strPackVersionNew.toUtf8(); 2192 QByteArray ba2 = strPackVersionOld.toUtf8(); 2193 int iVerCmp = RTStrVersionCompare(ba1.constData(), ba2.constData()); 2194 2195 bool fRc; 2196 if (iVerCmp > 0) 2197 fRc = messageOkCancel(pParent, 2198 Question, 2199 tr("<p>An older version of the extension pack is already installed, would you like to upgrade? " 2200 "<p>%1</p>" 2201 "<p><table cellpadding=0 cellspacing=0>" 2202 "<tr><td><b>Name: </b></td><td>%2</td></tr>" 2203 "<tr><td><b>New Version: </b></td><td>%3</td></tr>" 2204 "<tr><td><b>Current Version: </b></td><td>%4</td></tr>" 2205 "<tr><td><b>Description: </b></td><td>%5</td></tr>" 2206 "</table></p>") 2207 .arg(strBelehrung).arg(strPackName).arg(strPackVersionNew).arg(strPackVersionOld).arg(strPackDescription), 2208 0, 2209 tr("&Upgrade")); 2210 else if (iVerCmp < 0) 2211 fRc = messageOkCancel(pParent, 2212 Question, 2213 tr("<p>An newer version of the extension pack is already installed, would you like to downgrade? " 2214 "<p>%1</p>" 2215 "<p><table cellpadding=0 cellspacing=0>" 2216 "<tr><td><b>Name: </b></td><td>%2</td></tr>" 2217 "<tr><td><b>New Version: </b></td><td>%3</td></tr>" 2218 "<tr><td><b>Current Version: </b></td><td>%4</td></tr>" 2219 "<tr><td><b>Description: </b></td><td>%5</td></tr>" 2220 "</table></p>") 2221 .arg(strBelehrung).arg(strPackName).arg(strPackVersionNew).arg(strPackVersionOld).arg(strPackDescription), 2222 0, 2223 tr("&Downgrade")); 2224 else 2225 fRc = messageOkCancel(pParent, 2226 Question, 2227 tr("<p>The extension pack is already installed with the same version, would you like reinstall it? " 2228 "<p>%1</p>" 2229 "<p><table cellpadding=0 cellspacing=0>" 2230 "<tr><td><b>Name: </b></td><td>%2</td></tr>" 2231 "<tr><td><b>Version: </b></td><td>%3</td></tr>" 2232 "<tr><td><b>Description: </b></td><td>%4</td></tr>" 2233 "</table></p>") 2234 .arg(strBelehrung).arg(strPackName).arg(strPackVersionOld).arg(strPackDescription), 2235 0, 2236 tr("&Reinstall")); 2237 return fRc; 2238 } 2239 2179 2240 bool VBoxProblemReporter::confirmRemovingPackage(const QString &strPackName, QWidget *pParent /* = 0 */) 2180 2241 { -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.h
r34984 r35079 135 135 { 136 136 return messageOkCancel (aParent, aType, aMessage, QString::null, 137 aAutoConfirmId, aOkText, aCancelText); } 137 aAutoConfirmId, aOkText, aCancelText); 138 } 138 139 139 140 bool showModalProgressDialog(CProgress &progress, const QString &strTitle, … … 344 345 void cannotUninstallExtPack(const QString &strPackName, const CExtPackManager &extPackManager, QWidget *pParent = 0); 345 346 bool confirmInstallingPackage(const QString &strPackName, const QString &strPackVersion, const QString &strPackDescription, QWidget *pParent = 0); 347 bool confirmReplacePackage(const QString &strPackName, const QString &strPackVersionNew, const QString &strPackVersionOld, 348 const QString &strPackDescription, QWidget *pParent = 0); 346 349 bool confirmRemovingPackage(const QString &strPackName, QWidget *pParent = 0); 347 350 void notifyAboutExtPackInstalled(const QString &strPackName, QWidget *pParent = 0); -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsExtension.cpp
r34978 r35079 110 110 * This code is shared by UIGlobalSettingsExtension::sltInstallPackage and 111 111 * VBoxSelectorWnd::sltOpenUrls. 112 * @todo Is there perhaps a better home for this method?113 112 * 114 * @returns true if successfully installed, false if not.115 113 * @param strFilePath The path to the tarball. 116 114 * @param pParent The parent widget. 117 115 * @param pstrExtPackName Where to return the extension pack name. Optional. 118 116 */ 119 /*static*/ boolUIGlobalSettingsExtension::doInstallation(QString const &strFilePath, QWidget *pParent, QString *pstrExtPackName)120 { 121 bool fInstalled = false;122 123 /* Open the extpack tarball via IExtPackManager:*/117 /*static*/ void UIGlobalSettingsExtension::doInstallation(QString const &strFilePath, QWidget *pParent, QString *pstrExtPackName) 118 { 119 /* 120 * Open the extpack tarball via IExtPackManager. 121 */ 124 122 CExtPackManager manager = vboxGlobal().virtualBox().GetExtensionPackManager(); 125 123 CExtPackFile extPackFile = manager.OpenExtPackFile(strFilePath); 126 if (manager.isOk()) 127 { 128 if (pstrExtPackName) 129 *pstrExtPackName = extPackFile.GetName(); 130 if (extPackFile.GetUsable()) 124 if (!manager.isOk()) 125 { 126 vboxProblem().cannotOpenExtPack(strFilePath, manager, pParent); 127 return; 128 } 129 130 if (!extPackFile.GetUsable()) 131 { 132 vboxProblem().badExtPackFile(strFilePath, extPackFile, pParent); 133 return; 134 } 135 136 QString strPackName = extPackFile.GetName(); 137 QString strPackDescription = extPackFile.GetDescription(); 138 QString strPackVersion = QString("%1r%2").arg(extPackFile.GetVersion()).arg(extPackFile.GetRevision()); 139 140 /* 141 * Check if there is a version of the extension pack already 142 * installed on the system and let the user decide what to do about 143 * it. 144 */ 145 CExtPack extPackCur = manager.Find(strPackName); 146 bool fUninstallIt = extPackCur.isOk(); 147 if (fUninstallIt) 148 { 149 QString strPackVersionCur = QString("%1r%2").arg(extPackCur.GetVersion()).arg(extPackCur.GetRevision()); 150 if (!vboxProblem().confirmReplacePackage(strPackName, strPackVersion, strPackVersionCur, strPackDescription)) 151 return; 152 } 153 /* 154 * If it's a new package just ask for general confirmation. 155 */ 156 else 157 { 158 if (!vboxProblem().confirmInstallingPackage(strPackName, strPackVersion, strPackDescription)) 159 return; 160 } 161 162 /* 163 * Display the license dialog if required by the extension pack. 164 */ 165 if (extPackFile.GetShowLicense()) 166 { 167 QString strLicense = extPackFile.GetLicense(); 168 VBoxLicenseViewer licenseViewer; 169 if (licenseViewer.showLicenseFromString(strLicense) != QDialog::Accepted) 170 return; 171 } 172 173 /* 174 * Perform uninstallation of any pervious package. Set the package name 175 * return value before doing this as the caller should do a refresh even 176 * on failure. 177 */ 178 if (pstrExtPackName) 179 *pstrExtPackName = strPackName; 180 if (fUninstallIt) 181 { 182 manager.Uninstall(strPackName, false /*aForcedRemoval*/); 183 if (!extPackFile.isOk()) 131 184 { 132 /* Ask user to confirm installation: */ 133 QString strPackName = extPackFile.GetName(); 134 QString strPackVersion = QString("%1r%2").arg(extPackFile.GetVersion()).arg(extPackFile.GetRevision()); 135 QString strPackDescription = extPackFile.GetDescription(); 136 if (vboxProblem().confirmInstallingPackage(strPackName, strPackVersion, strPackDescription)) 137 { 138 /* Display license if necessary: */ 139 bool fShouldBeLicenseShown = extPackFile.GetShowLicense(); 140 QString strLicense = extPackFile.GetLicense(); 141 VBoxLicenseViewer licenseViewer; 142 if (!fShouldBeLicenseShown || licenseViewer.showLicenseFromString(strLicense) == QDialog::Accepted) 143 { 144 /* Install package: */ 145 extPackFile.Install(); 146 if (extPackFile.isOk()) 147 { 148 vboxProblem().notifyAboutExtPackInstalled(strPackName, pParent); 149 fInstalled = true; 150 } 151 else 152 vboxProblem().cannotInstallExtPack(strFilePath, extPackFile, pParent); 153 } 154 } 185 vboxProblem().cannotUninstallExtPack(strFilePath, manager, pParent); 186 return; 155 187 } 156 else 157 vboxProblem().badExtPackFile(strFilePath, extPackFile, pParent); 158 } 188 } 189 190 /* 191 * Install the selected package. 192 */ 193 extPackFile.Install(); 194 if (extPackFile.isOk()) 195 vboxProblem().notifyAboutExtPackInstalled(strPackName, pParent); 159 196 else 160 vboxProblem().cannotOpenExtPack(strFilePath, manager, pParent); 161 162 return fInstalled; 163 } 164 165 /* Load data to cashe from corresponding external object(s), 197 vboxProblem().cannotInstallExtPack(strFilePath, extPackFile, pParent); 198 } 199 200 /* Load data to cache from corresponding external object(s), 166 201 * this task COULD be performed in other than GUI thread: */ 167 202 void UIGlobalSettingsExtension::loadToCacheFrom(QVariant &data) … … 259 294 void UIGlobalSettingsExtension::sltInstallPackage() 260 295 { 261 /* Open file-open window to let user to choose package file: */ 262 QString strFilePath; 263 QString strBaseFolder = vboxGlobal().virtualBox().GetHomeFolder(); 296 /* 297 * Open file-open window to let user to choose package file. 298 * 299 * The default location is the user's Download or Downloads directory with 300 * the user's home directory as a fallback. ExtPacks are downloaded. 301 */ 302 QString strBaseFolder = QDir::homePath() + "/Downloads"; 303 if (!QDir(strBaseFolder).exists()) 304 { 305 strBaseFolder = QDir::homePath() + "/Download"; 306 if (!QDir(strBaseFolder).exists()) 307 strBaseFolder = QDir::homePath(); 308 } 264 309 QString strTitle = tr("Select an extension package file"); 265 310 QStringList extensions; … … 268 313 QString strFilter = tr("Extension package files (%1)").arg(extensions.join(" ")); 269 314 270 /* Create open file dialog: */271 315 QStringList fileNames = QIFileDialog::getOpenFileNames(strBaseFolder, strFilter, this, strTitle, 0, true, true); 316 317 QString strFilePath; 272 318 if (!fileNames.isEmpty()) 273 319 strFilePath = fileNames.at(0); 274 320 275 321 /* 276 * Install chosen package.322 * Install the chosen package. 277 323 */ 278 324 if (!strFilePath.isEmpty()) 279 325 { 280 326 QString strExtPackName; 281 if (doInstallation(strFilePath, this, &strExtPackName)) 327 doInstallation(strFilePath, this, &strExtPackName); 328 329 /* 330 * Since we might be reinstalling an existing package, we have to 331 * do a little refreshing regardless of what the user chose. 332 */ 333 if (!strExtPackName.isNull()) 282 334 { 283 /* Insert the fresly installed extension pack, mark it as 284 * current in the tree and sort by name (col 1): */ 335 /* Remove it from the cache. */ 336 for (int i = 0; i < m_cache.m_items.size(); i++) 337 if (!strExtPackName.compare(m_cache.m_items[i].m_strName, Qt::CaseInsensitive)) 338 { 339 m_cache.m_items.removeAt(i); 340 break; 341 } 342 343 /* Remove it from the tree. */ 344 const int cItems = m_pPackagesTree->topLevelItemCount(); 345 for (int i = 0; i < cItems; i++) 346 { 347 UIExtensionPackageItem *pItem = static_cast<UIExtensionPackageItem*>(m_pPackagesTree->topLevelItem(i)); 348 if (!strExtPackName.compare(pItem->name(), Qt::CaseInsensitive)) 349 { 350 delete pItem; 351 break; 352 } 353 } 354 355 /* Reinsert it into the cache and tree. */ 285 356 CExtPackManager manager = vboxGlobal().virtualBox().GetExtensionPackManager(); 286 357 const CExtPack &package = manager.Find(strExtPackName); 287 m_cache.m_items << fetchData(package); 288 UIExtensionPackageItem *pItem = new UIExtensionPackageItem(m_pPackagesTree, m_cache.m_items.last()); 289 m_pPackagesTree->setCurrentItem(pItem); 290 m_pPackagesTree->sortByColumn(1, Qt::AscendingOrder); 358 if (package.isOk()) 359 { 360 m_cache.m_items << fetchData(package); 361 362 UIExtensionPackageItem *pItem = new UIExtensionPackageItem(m_pPackagesTree, m_cache.m_items.last()); 363 m_pPackagesTree->setCurrentItem(pItem); 364 m_pPackagesTree->sortByColumn(1, Qt::AscendingOrder); 365 } 291 366 } 292 367 } … … 319 394 for (int i = 0; i < m_cache.m_items.size(); ++i) 320 395 { 321 if ( m_cache.m_items[i].m_strName == strSelectedPackageName)396 if (!strSelectedPackageName.compare(m_cache.m_items[i].m_strName, Qt::CaseInsensitive)) 322 397 { 323 398 m_cache.m_items.removeAt(i); -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsExtension.h
r34787 r35079 51 51 UIGlobalSettingsExtension(); 52 52 53 static booldoInstallation(QString const &strFilePath, QWidget *pParent, QString *pstrExtPackName);53 static void doInstallation(QString const &strFilePath, QWidget *pParent, QString *pstrExtPackName); 54 54 55 55 protected:
Note:
See TracChangeset
for help on using the changeset viewer.