Changed: Use ID instead of index for profile and server

--HG--
branch : develop
This commit is contained in:
kervala 2016-06-19 21:07:51 +02:00
parent cb9acedb72
commit 7b6dd8f031
2 changed files with 26 additions and 15 deletions

View file

@ -865,11 +865,11 @@ bool COperationDialog::createDefaultProfile()
return true; return true;
} }
bool COperationDialog::createClientDesktopShortcut(int profileIndex) bool COperationDialog::createClientDesktopShortcut(const QString &profileId)
{ {
CConfigFile *config = CConfigFile::getInstance(); CConfigFile *config = CConfigFile::getInstance();
const CProfile &profile = config->getProfile(profileIndex); const CProfile &profile = config->getProfile(profileId);
const CServer &server = config->getServer(profile.server); const CServer &server = config->getServer(profile.server);
m_currentOperation = tr("Create desktop shortcut for profile %1").arg(profile.id); m_currentOperation = tr("Create desktop shortcut for profile %1").arg(profile.id);
@ -877,8 +877,16 @@ bool COperationDialog::createClientDesktopShortcut(int profileIndex)
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
if (profile.desktopShortcut) if (profile.desktopShortcut)
{ {
QString shortcut = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/Ryzom.lnk"; QString executable = profile.getClientFullPath();
CreateLink(config->getProfileClientFullPath(), shortcut, QString("--profile %1 %2").arg(profile.id).arg(profile.arguments), server.getDirectory(), "Default Ryzom client"); QString shortcut = profile.getClientDesktopLinkFullPath();
QString workingDir = server.getDirectory();
QString arguments = QString("--profile %1").arg(profile.id);
// append custom arguments
if (!profile.arguments.isEmpty()) arguments += QString(" %1").arg(profile.arguments);
createLink(executable, shortcut, arguments, workingDir, profile.comments);
} }
#endif #endif
@ -887,11 +895,11 @@ bool COperationDialog::createClientDesktopShortcut(int profileIndex)
return true; return true;
} }
bool COperationDialog::createClientMenuShortcut(int profileIndex) bool COperationDialog::createClientMenuShortcut(const QString &profileId)
{ {
CConfigFile *config = CConfigFile::getInstance(); CConfigFile *config = CConfigFile::getInstance();
const CProfile &profile = config->getProfile(profileIndex); const CProfile &profile = config->getProfile(profileId);
const CServer &server = config->getServer(profile.server); const CServer &server = config->getServer(profile.server);
m_currentOperation = tr("Create menu shortcut for profile %1").arg(profile.id); m_currentOperation = tr("Create menu shortcut for profile %1").arg(profile.id);
@ -899,15 +907,16 @@ bool COperationDialog::createClientMenuShortcut(int profileIndex)
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
if (profile.menuShortcut) if (profile.menuShortcut)
{ {
QString path = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation) + "/Ryzom"; QString executable = profile.getClientFullPath();
QString shortcut = profile.getClientMenuLinkFullPath();
QString workingDir = server.getDirectory();
QDir dir; QString arguments = QString("--profile %1").arg(profile.id);
if (dir.mkpath(path)) // append custom arguments
{ if (!profile.arguments.isEmpty()) arguments += QString(" %1").arg(profile.arguments);
QString shortcut = path + "/Ryzom.lnk";
CreateLink(config->getProfileClientFullPath(), shortcut, QString("--profile %1 %2").arg(profile.id).arg(profile.arguments), server.getDirectory(), "Default Ryzom client"); createLink(executable, shortcut, arguments, workingDir, profile.comments);
}
} }
#endif #endif

View file

@ -102,8 +102,10 @@ protected:
void copyInstaller(); void copyInstaller();
void uninstallOldClient(); void uninstallOldClient();
bool createDefaultProfile(); bool createDefaultProfile();
bool createClientDesktopShortcut(int profileIndex);
bool createClientMenuShortcut(int profileIndex); bool createClientDesktopShortcut(const QString &profileId);
bool createClientMenuShortcut(const QString &profileId);
bool createAddRemoveEntry(); bool createAddRemoveEntry();
bool deleteAddRemoveEntry(); bool deleteAddRemoveEntry();