Merge with develop

--HG--
branch : compatibility-develop
hg/compatibility-develop
kervala 6 years ago
commit 265c42cc50

@ -264,6 +264,16 @@ const CServer& CConfigFile::getServer(const QString &id) const
return getServer(); return getServer();
} }
CProfile CConfigFile::getBackupProfile(const QString &id) const
{
for (int i = 0; i < m_backupProfiles.size(); ++i)
{
if (m_backupProfiles[i].id == id) return m_backupProfiles[i];
}
return NoProfile;
}
void CConfigFile::backupProfiles() void CConfigFile::backupProfiles()
{ {
m_backupProfiles = m_profiles; m_backupProfiles = m_profiles;
@ -290,8 +300,8 @@ CProfile CConfigFile::getProfile(const QString &id) const
if (m_profiles[i].id == id) return m_profiles[i]; if (m_profiles[i].id == id) return m_profiles[i];
} }
// default profile // no profile
return getProfile(); return NoProfile;
} }
void CConfigFile::setProfile(int i, const CProfile &profile) void CConfigFile::setProfile(int i, const CProfile &profile)

@ -53,6 +53,7 @@ public:
void setProfiles(const CProfiles &profiles) { m_profiles = profiles; } void setProfiles(const CProfiles &profiles) { m_profiles = profiles; }
CProfiles getBackupProfiles() const { return m_backupProfiles; } CProfiles getBackupProfiles() const { return m_backupProfiles; }
CProfile getBackupProfile(const QString &id) const;
void backupProfiles(); void backupProfiles();
QString getLanguage() const { return m_language; } QString getLanguage() const { return m_language; }

@ -103,6 +103,10 @@ void CMainWindow::updateButtons()
CConfigFile *config = CConfigFile::getInstance(); CConfigFile *config = CConfigFile::getInstance();
const CProfile &profile = config->getProfile(profileIndex); const CProfile &profile = config->getProfile(profileIndex);
// wrong profile
if (profile.id.isEmpty()) return;
const CServer &server = config->getServer(profile.server); const CServer &server = config->getServer(profile.server);
// get full path of client executable // get full path of client executable
@ -125,6 +129,10 @@ void CMainWindow::onPlayClicked()
CConfigFile *config = CConfigFile::getInstance(); CConfigFile *config = CConfigFile::getInstance();
const CProfile &profile = config->getProfile(profileIndex); const CProfile &profile = config->getProfile(profileIndex);
// wrong profile
if (profile.id.isEmpty()) return;
const CServer &server = config->getServer(profile.server); const CServer &server = config->getServer(profile.server);
// get full path of client executable // get full path of client executable
@ -162,6 +170,10 @@ void CMainWindow::onConfigureClicked()
CConfigFile *config = CConfigFile::getInstance(); CConfigFile *config = CConfigFile::getInstance();
const CProfile &profile = config->getProfile(profileIndex); const CProfile &profile = config->getProfile(profileIndex);
// wrong profile
if (profile.id.isEmpty()) return;
const CServer &server = config->getServer(profile.server); const CServer &server = config->getServer(profile.server);
// get full path of configuration executable // get full path of configuration executable
@ -310,6 +322,10 @@ void CMainWindow::onProfileChanged(int profileIndex)
CConfigFile *config = CConfigFile::getInstance(); CConfigFile *config = CConfigFile::getInstance();
CProfile profile = config->getProfile(profileIndex); CProfile profile = config->getProfile(profileIndex);
// wrong profile
if (profile.id.isEmpty()) return;
CServer server = config->getServer(profile.server); CServer server = config->getServer(profile.server);
// load changelog // load changelog

@ -926,6 +926,9 @@ bool COperationDialog::createProfileShortcuts(const QString &profileId)
const CProfile &profile = config->getProfile(profileId); const CProfile &profile = config->getProfile(profileId);
// wrong profile
if (profile.id.isEmpty()) return false;
m_currentOperation = tr("Creating shortcuts for profile %1...").arg(profile.id); m_currentOperation = tr("Creating shortcuts for profile %1...").arg(profile.id);
profile.createShortcuts(); profile.createShortcuts();
@ -1080,6 +1083,9 @@ void COperationDialog::addComponentsProfiles()
{ {
const CProfile &profile = config->getProfile(profileId); const CProfile &profile = config->getProfile(profileId);
// wrong profile
if (profile.id.isEmpty()) continue;
profile.createShortcuts(); profile.createShortcuts();
profile.createClientConfig(); profile.createClientConfig();
} }
@ -1099,6 +1105,9 @@ void COperationDialog::deleteComponentsProfiles()
CConfigFile *config = CConfigFile::getInstance(); CConfigFile *config = CConfigFile::getInstance();
// some profiles have been removed, use backup profiles
bool useBackup = !config->getBackupProfiles().isEmpty();
int i = 0; int i = 0;
foreach(const QString &profileId, m_removeComponents.profiles) foreach(const QString &profileId, m_removeComponents.profiles)
@ -1109,7 +1118,11 @@ void COperationDialog::deleteComponentsProfiles()
return; return;
} }
const CProfile &profile = config->getProfile(profileId); // only search in backup profiles, because they are already deleted in profiles
const CProfile &profile = useBackup ? config->getBackupProfile(profileId):config->getProfile(profileId);
// already deleted profile
if (profile.id.isEmpty()) continue;
emit progress(i++, profile.name); emit progress(i++, profile.name);
@ -1128,8 +1141,8 @@ void COperationDialog::deleteComponentsProfiles()
profile.deleteShortcuts(); profile.deleteShortcuts();
// delete profile // delete profile if still used
config->removeProfile(profileId); if (!useBackup) config->removeProfile(profileId);
} }
emit success(m_removeComponents.profiles.size()); emit success(m_removeComponents.profiles.size());

@ -257,6 +257,9 @@ void CUninstallDialog::updateSizes()
{ {
const CProfile &profile = config->getProfile(it.key()); const CProfile &profile = config->getProfile(it.key());
// wrong profile
if (profile.id.isEmpty()) continue;
qint64 bytes = getDirectorySize(profile.getDirectory(), true); qint64 bytes = getDirectorySize(profile.getDirectory(), true);
emit updateSize(it.value(), qBytesToHumanReadable(bytes)); emit updateSize(it.value(), qBytesToHumanReadable(bytes));

Loading…
Cancel
Save