Changed: Uninstall previous Ryzom version if detected
This commit is contained in:
parent
f538c6000a
commit
b0537df2e1
4 changed files with 65 additions and 4 deletions
|
@ -29,7 +29,7 @@ const CProfile NoProfile;
|
|||
|
||||
CConfigFile *CConfigFile::s_instance = NULL;
|
||||
|
||||
CConfigFile::CConfigFile(QObject *parent):QObject(parent), m_defaultServerIndex(0), m_defaultProfileIndex(0), m_use64BitsClient(false)
|
||||
CConfigFile::CConfigFile(QObject *parent):QObject(parent), m_defaultServerIndex(0), m_defaultProfileIndex(0), m_use64BitsClient(false), m_shouldUninstallOldClient(true)
|
||||
{
|
||||
s_instance = this;
|
||||
|
||||
|
@ -56,7 +56,8 @@ bool CConfigFile::load(const QString &filename)
|
|||
m_language = settings.value("language", m_language).toString();
|
||||
m_srcDirectory = settings.value("source_directory").toString();
|
||||
m_installationDirectory = settings.value("installation_directory").toString();
|
||||
m_use64BitsClient = settings.value("use_64bits_client").toBool();
|
||||
m_use64BitsClient = settings.value("use_64bits_client", true).toBool();
|
||||
m_shouldUninstallOldClient = settings.value("should_uninstall_old_client", true).toBool();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup("product");
|
||||
|
@ -149,6 +150,7 @@ bool CConfigFile::save() const
|
|||
settings.setValue("source_directory", m_srcDirectory);
|
||||
settings.setValue("installation_directory", m_installationDirectory);
|
||||
settings.setValue("use_64bits_client", m_use64BitsClient);
|
||||
settings.setValue("should_uninstall_old_client", m_shouldUninstallOldClient);
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup("product");
|
||||
|
@ -363,6 +365,16 @@ void CConfigFile::setUse64BitsClient(bool on)
|
|||
m_use64BitsClient = on;
|
||||
}
|
||||
|
||||
bool CConfigFile::shouldUninstallOldClient() const
|
||||
{
|
||||
return m_shouldUninstallOldClient;
|
||||
}
|
||||
|
||||
void CConfigFile::setShouldUninstallOldClient(bool on)
|
||||
{
|
||||
m_shouldUninstallOldClient = on;
|
||||
}
|
||||
|
||||
QString CConfigFile::expandVariables(const QString &str) const
|
||||
{
|
||||
QString res = str;
|
||||
|
@ -710,6 +722,11 @@ CConfigFile::InstallationStep CConfigFile::getNextStep() const
|
|||
return CopyInstaller;
|
||||
}
|
||||
|
||||
if (m_shouldUninstallOldClient && !getSrcServerDirectory().isEmpty() && QFile::exists(getSrcServerDirectory() + "/Uninstall.exe"))
|
||||
{
|
||||
return UninstallOldClient;
|
||||
}
|
||||
|
||||
// no default profile
|
||||
if (profile.id.isEmpty())
|
||||
{
|
||||
|
|
|
@ -93,6 +93,7 @@ public:
|
|||
CleanFiles,
|
||||
ExtractBnpClient,
|
||||
CopyInstaller,
|
||||
UninstallOldClient,
|
||||
CreateProfile,
|
||||
CreateShortcuts,
|
||||
CreateAddRemoveEntry,
|
||||
|
@ -164,6 +165,9 @@ public:
|
|||
bool use64BitsClient() const;
|
||||
void setUse64BitsClient(bool on);
|
||||
|
||||
bool shouldUninstallOldClient() const;
|
||||
void setShouldUninstallOldClient(bool on);
|
||||
|
||||
QString expandVariables(const QString &str) const;
|
||||
|
||||
QString getClientArch() const;
|
||||
|
@ -192,6 +196,7 @@ private:
|
|||
QString m_installationDirectory;
|
||||
QString m_srcDirectory;
|
||||
bool m_use64BitsClient;
|
||||
bool m_shouldUninstallOldClient;
|
||||
QString m_language;
|
||||
|
||||
QString m_defaultConfigPath;
|
||||
|
|
|
@ -462,6 +462,44 @@ void COperationDialog::copyIntaller()
|
|||
emit done();
|
||||
}
|
||||
|
||||
void COperationDialog::uninstallOldClient()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
|
||||
#ifdef Q_OS_WIN64
|
||||
// use WOW6432Node in 64 bits (64 bits OS and 64 bits Installer) because Ryzom old installer was in 32 bits
|
||||
QSettings settings("HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Ryzom", QSettings::NativeFormat);
|
||||
#else
|
||||
QSettings settings("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Ryzom", QSettings::NativeFormat);
|
||||
#endif
|
||||
|
||||
// check if Ryzom 2.1.0 is installed
|
||||
if (settings.contains("UninstallString"))
|
||||
{
|
||||
QString uninstaller = settings.value("UninstallString").toString();
|
||||
|
||||
if (!uninstaller.isEmpty() && QFile::exists(uninstaller))
|
||||
{
|
||||
QMessageBox::StandardButtons button = QMessageBox::question(this, tr("Uninstall old client"), tr("An old version of Ryzom has been detected on this system, would you like to uninstall it to save space disk?"));
|
||||
|
||||
if (button == QMessageBox::Yes)
|
||||
{
|
||||
CConfigFile::getInstance()->setShouldUninstallOldClient(true);
|
||||
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(uninstaller));
|
||||
}
|
||||
else
|
||||
{
|
||||
// don't ask this question anymore
|
||||
CConfigFile::getInstance()->setShouldUninstallOldClient(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
emit done();
|
||||
}
|
||||
|
||||
void COperationDialog::cleanFiles()
|
||||
{
|
||||
CConfigFile *config = CConfigFile::getInstance();
|
||||
|
|
|
@ -86,9 +86,10 @@ protected:
|
|||
void downloadClient();
|
||||
void copyServerFiles();
|
||||
void copyProfileFiles();
|
||||
void extractBnpClient();
|
||||
void copyIntaller();
|
||||
void cleanFiles();
|
||||
void extractBnpClient();
|
||||
void copyInstaller();
|
||||
void uninstallOldClient();
|
||||
bool createDefaultProfile();
|
||||
bool createDefaultShortcuts();
|
||||
bool createAddRemoveEntry();
|
||||
|
|
Loading…
Reference in a new issue