diff --git a/code/nel/src/misc/path.cpp b/code/nel/src/misc/path.cpp
index 061c938a5..9737589f7 100644
--- a/code/nel/src/misc/path.cpp
+++ b/code/nel/src/misc/path.cpp
@@ -1784,7 +1784,9 @@ std::string CPath::getApplicationDirectory(const std::string &appName, bool loca
std::string CFileContainer::getApplicationDirectory(const std::string &appName, bool local)
{
static std::string appPaths[2];
+
std::string &appPath = appPaths[local ? 1 : 0];
+
if (appPath.empty())
{
#ifdef NL_OS_WINDOWS
@@ -1800,26 +1802,21 @@ std::string CFileContainer::getApplicationDirectory(const std::string &appName,
SHGetSpecialFolderPathW(NULL, buffer, CSIDL_APPDATA, TRUE);
}
appPath = CPath::standardizePath(wideToUtf8(buffer));
-#elif defined(NL_OS_MAC)
- appPath = CPath::standardizePath(getenv("HOME"));
- appPath += "/Library/Application Support/";
#else
- appPath = CPath::standardizePath(getenv("HOME"));
+ // get user home directory from HOME environment variable
+ const char* homePath = getenv("HOME");
+ appPath = CPath::standardizePath(homePath ? homePath : ".");
+
+#if defined(NL_OS_MAC)
+ appPath += "Library/Application Support/";
+#else
+ // recommended for applications data that are owned by user
+ appPath += ".local/share/";
+#endif
#endif
}
- std::string path = appPath;
-#ifdef NL_OS_WINDOWS
- if (!appName.empty())
- path = CPath::standardizePath(path + appName);
-#elif defined(NL_OS_MAC)
- path = CPath::standardizePath(path + appName);
-#else
- if (!appName.empty())
- path = CPath::standardizePath(path + "." + toLower(appName));
-#endif
-
- return path;
+ return CPath::standardizePath(appPath + appName);
}
std::string CPath::getTemporaryDirectory()
diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp
index 4cb77cfff..594bf9d1c 100644
--- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp
+++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp
@@ -45,7 +45,7 @@ CConfigFile::CConfigFile(QObject *parent):QObject(parent), m_defaultServerIndex(
m_language = QLocale::system().name().left(2); // only keep language ISO 639 code
m_defaultConfigPath = QApplication::applicationDirPath() + "/installer.ini";
- m_configPath = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/installer.ini";
+ m_configPath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/installer.ini";
}
CConfigFile::~CConfigFile()
@@ -608,9 +608,24 @@ bool CConfigFile::foundTemporaryFiles(const QString &directory) const
bool CConfigFile::shouldCreateDesktopShortcut() const
{
+#ifdef Q_OS_WIN32
const CProfile &profile = getProfile();
- return profile.desktopShortcut && !QFile::exists(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/Ryzom.lnk");
+ return profile.desktopShortcut && !NLMISC::CFile::isExists(qToUtf8(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/Ryzom.lnk"));
+#else
+ return false;
+#endif
+}
+
+bool CConfigFile::shouldCreateMenuShortcut() const
+{
+#ifdef Q_OS_WIN32
+ const CProfile &profile = getProfile();
+
+ return profile.menuShortcut && !NLMISC::CFile::isExists(qToUtf8(QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation) + "/Ryzom/Ryzom.lnk"));
+#else
+ return false;
+#endif
}
QString CConfigFile::getProfileClientFullPath(int profileIndex) const
@@ -704,7 +719,7 @@ OperationStep CConfigFile::getInstallNextStep() const
// downloaded files are kept in server directory
QString dataFile = getInstallationDirectory() + "/" + server.dataDownloadFilename;
- QString clientFile = getInstallationDirectory() + "/" + server.clientDownloadFilename;
+ QString clientFile = getInstallationDirectory() + "/" + expandVariables(server.clientDownloadFilename);
// data are not copied
if (!areRyzomDataInstalledIn(serverDirectory))
@@ -760,7 +775,7 @@ OperationStep CConfigFile::getInstallNextStep() const
return ExtractBnpClient;
}
- QString clientFile = getInstallationDirectory() + "/" + server.clientDownloadFilename;
+ QString clientFile = getInstallationDirectory() + "/" + expandVariables(server.clientDownloadFilename);
// when file is not finished, it has .part extension
if (!QFile::exists(clientFile))
@@ -799,8 +814,12 @@ OperationStep CConfigFile::getInstallNextStep() const
if (shouldCreateDesktopShortcut())
{
- // TODO: check they point to getClientFullPath()
- return CreateShortcuts;
+ return CreateDesktopShortcut;
+ }
+
+ if (shouldCreateMenuShortcut())
+ {
+ return CreateMenuShortcut;
}
#ifdef Q_OS_WIN
diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.h b/code/ryzom/tools/client/ryzom_installer/src/configfile.h
index 2ecd3e211..dd00b94e8 100644
--- a/code/ryzom/tools/client/ryzom_installer/src/configfile.h
+++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.h
@@ -153,6 +153,7 @@ public:
bool foundTemporaryFiles(const QString &directory) const;
bool shouldCreateDesktopShortcut() const;
+ bool shouldCreateMenuShortcut() const;
// installation choices
bool use64BitsClient() const;
diff --git a/code/ryzom/tools/client/ryzom_installer/src/downloader.cpp b/code/ryzom/tools/client/ryzom_installer/src/downloader.cpp
index 3c85a8031..ba49a8842 100644
--- a/code/ryzom/tools/client/ryzom_installer/src/downloader.cpp
+++ b/code/ryzom/tools/client/ryzom_installer/src/downloader.cpp
@@ -147,6 +147,8 @@ void CDownloader::getFileHead()
{
// file is already downloaded
if (m_listener) m_listener->operationSuccess(m_size);
+
+ emit downloadDone();
}
else
{
@@ -339,6 +341,10 @@ void CDownloader::onHeadFinished()
downloadFile();
}
}
+ else
+ {
+ emit downloadPrepared();
+ }
}
void CDownloader::onDownloadFinished()
@@ -357,6 +363,8 @@ void CDownloader::onDownloadFinished()
bool ok = NLMISC::CFile::setFileModificationDate(m_fullPath.toUtf8().constData(), m_lastModified.toTime_t());
if (m_listener) m_listener->operationSuccess(m_size);
+
+ emit downloadDone();
}
}
@@ -380,7 +388,7 @@ void CDownloader::onDownloadProgress(qint64 current, qint64 total)
if (!m_listener) return;
- m_listener->operationProgress(m_offset + current, ""); // TODO: put file
+ m_listener->operationProgress(m_offset + current, m_url);
// abort download
if (m_listener->operationShouldStop() && m_reply) m_reply->abort();
diff --git a/code/ryzom/tools/client/ryzom_installer/src/downloader.h b/code/ryzom/tools/client/ryzom_installer/src/downloader.h
index 4d3163723..585e4d59a 100644
--- a/code/ryzom/tools/client/ryzom_installer/src/downloader.h
+++ b/code/ryzom/tools/client/ryzom_installer/src/downloader.h
@@ -42,7 +42,11 @@ public:
bool isDownloading() const { return m_file != NULL; }
+ QString getFileFullPath() const { return m_fullPath; }
+
signals:
+ void downloadPrepared();
+ void downloadDone();
void htmlPageContent(const QString &html);
private slots:
diff --git a/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp b/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp
index 52109f703..27bd38a32 100644
--- a/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp
+++ b/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp
@@ -92,6 +92,7 @@ void CMainWindow::onPlayClicked()
CConfigFile *config = CConfigFile::getInstance();
const CProfile &profile = config->getProfile(profileIndex);
+ const CServer &server = config->getServer(profile.server);
// get full path of client executable
QString executable = config->getProfileClientFullPath(profileIndex);
@@ -104,8 +105,8 @@ void CMainWindow::onPlayClicked()
arguments << profile.id;
arguments << profile.arguments.split(' ');
- // launch the game with all arguments
- bool started = QProcess::startDetached(executable, arguments);
+ // launch the game with all arguments and from server root directory (to use right data)
+ bool started = QProcess::startDetached(executable, arguments, server.getDirectory());
// define this profile as default one
CConfigFile::getInstance()->setDefaultProfileIndex(profileIndex);
diff --git a/code/ryzom/tools/client/ryzom_installer/src/operation.h b/code/ryzom/tools/client/ryzom_installer/src/operation.h
index e8e0af678..4c3a88c07 100644
--- a/code/ryzom/tools/client/ryzom_installer/src/operation.h
+++ b/code/ryzom/tools/client/ryzom_installer/src/operation.h
@@ -62,7 +62,8 @@ enum OperationStep
CopyInstaller,
UninstallOldClient,
CreateProfile,
- CreateShortcuts,
+ CreateDesktopShortcut,
+ CreateMenuShortcut,
CreateAddRemoveEntry,
Done
};
diff --git a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp
index 667dad6f4..fe5c8f372 100644
--- a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp
+++ b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp
@@ -21,6 +21,7 @@
#include "configfile.h"
#include "config.h"
#include "profilesmodel.h"
+#include "utils.h"
#include "filescopier.h"
#include "filesextractor.h"
@@ -54,6 +55,9 @@ COperationDialog::COperationDialog(QWidget *parent):QDialog(parent), m_aborting(
// downloader
m_downloader = new CDownloader(this, this);
+ connect(m_downloader, SIGNAL(downloadPrepared()), SLOT(onDownloadPrepared()));
+ connect(m_downloader, SIGNAL(downloadDone()), SLOT(onDownloadDone()));
+
connect(operationButtonBox, SIGNAL(clicked(QAbstractButton*)), SLOT(onAbortClicked()));
// operations
@@ -164,8 +168,12 @@ void COperationDialog::processInstallNextStep()
createDefaultProfile();
break;
- case CreateShortcuts:
- createDefaultShortcuts();
+ case CreateDesktopShortcut:
+ createClientDesktopShortcut(0);
+ break;
+
+ case CreateMenuShortcut:
+ createClientMenuShortcut(0);
break;
case CreateAddRemoveEntry:
@@ -278,7 +286,7 @@ void COperationDialog::processUpdateProfilesNextStep()
}
else
{
- QString clientFile = config->getInstallationDirectory() + "/" + server.clientDownloadFilename;
+ QString clientFile = config->getInstallationDirectory() + "/" + config->expandVariables(server.clientDownloadFilename);
}
}
}
@@ -343,6 +351,19 @@ void COperationDialog::onAbortClicked()
m_aborting = true;
}
+void COperationDialog::onDownloadPrepared()
+{
+ // actually download the file
+ m_downloader->getFile();
+}
+
+void COperationDialog::onDownloadDone()
+{
+ renamePartFile();
+
+ emit done();
+}
+
void COperationDialog::onProgressPrepare()
{
operationProgressBar->setFormat(tr("%p% (%v/%m KiB)"));
@@ -419,15 +440,33 @@ void COperationDialog::downloadData()
const CServer &server = config->getServer(m_currentServerId);
- m_currentOperation = QApplication::tr("Download data required by server %1").arg(server.name);
- m_currentOperationProgressFormat = QApplication::tr("Downloading %1...");
+ m_currentOperation = tr("Download data required by server %1").arg(server.name);
+ m_currentOperationProgressFormat = tr("Downloading %1...");
m_downloader->prepareFile(config->expandVariables(server.dataDownloadUrl), config->getInstallationDirectory() + "/" + config->expandVariables(server.dataDownloadFilename) + ".part");
}
void COperationDialog::extractDownloadedData()
{
- // TODO: implement
+ CConfigFile *config = CConfigFile::getInstance();
+
+ const CServer &server = config->getServer(m_currentServerId);
+
+ m_currentOperation = tr("Extract data files required by server %1").arg(server.name);
+ m_currentOperationProgressFormat = tr("Extracting %1...");
+
+ CFilesExtractor extractor(this);
+ extractor.setSourceFile(config->getInstallationDirectory() + "/" + server.dataDownloadFilename);
+ extractor.setDestinationDirectory(server.getDirectory());
+
+ if (extractor.exec())
+ {
+ }
+ else
+ {
+ }
+
+ emit done();
}
void COperationDialog::downloadClient()
@@ -436,8 +475,8 @@ void COperationDialog::downloadClient()
const CServer &server = config->getServer(m_currentServerId);
- m_currentOperation = QApplication::tr("Download client required by server %1").arg(server.name);
- m_currentOperationProgressFormat = QApplication::tr("Downloading %1...");
+ m_currentOperation = tr("Download client required by server %1").arg(server.name);
+ m_currentOperationProgressFormat = tr("Downloading %1...");
m_downloader->prepareFile(config->expandVariables(server.clientDownloadUrl), config->getInstallationDirectory() + "/" + config->expandVariables(server.clientDownloadFilename) + ".part");
}
@@ -448,11 +487,11 @@ void COperationDialog::extractDownloadedClient()
const CServer &server = config->getServer(m_currentServerId);
- m_currentOperation = QApplication::tr("Extract data files required by server %1").arg(server.name);
- m_currentOperationProgressFormat = QApplication::tr("Extracting %1...");
+ m_currentOperation = tr("Extract client files required by server %1").arg(server.name);
+ m_currentOperationProgressFormat = tr("Extracting %1...");
CFilesExtractor extractor(this);
- extractor.setSourceFile(config->getInstallationDirectory() + "/" + server.clientDownloadFilename);
+ extractor.setSourceFile(config->getInstallationDirectory() + "/" + config->expandVariables(server.clientDownloadFilename));
extractor.setDestinationDirectory(server.getDirectory());
if (extractor.exec())
@@ -472,8 +511,8 @@ void COperationDialog::copyDataFiles()
// default server
const CServer &server = config->getServer(m_currentServerId);
- m_currentOperation = QApplication::tr("Copy data files required by server %1").arg(server.name);
- m_currentOperationProgressFormat = QApplication::tr("Copying %1...");
+ m_currentOperation = tr("Copy data files required by server %1").arg(server.name);
+ m_currentOperationProgressFormat = tr("Copying %1...");
QStringList serverFiles;
serverFiles << "cfg";
@@ -507,8 +546,8 @@ void COperationDialog::copyProfileFiles()
// default profile
const CProfile &profile = config->getProfile();
- m_currentOperation = QApplication::tr("Copy old profile to new location");
- m_currentOperationProgressFormat = QApplication::tr("Copying %1...");
+ m_currentOperation = tr("Copy old profile to new location");
+ m_currentOperationProgressFormat = tr("Copying %1...");
QStringList profileFiles;
profileFiles << "cache";
@@ -540,8 +579,8 @@ void COperationDialog::extractBnpClient()
// default server
const CServer &server = config->getServer();
- m_currentOperation = QApplication::tr("Extract client to new location");
- m_currentOperationProgressFormat = QApplication::tr("Extracting %1...");
+ m_currentOperation = tr("Extract client to new location");
+ m_currentOperationProgressFormat = tr("Extracting %1...");
QString destinationDirectory = server.getDirectory();
@@ -602,8 +641,8 @@ void COperationDialog::copyInstaller()
// default server
const CServer &server = config->getServer();
- m_currentOperation = QApplication::tr("Copy installer to new location");
- m_currentOperationProgressFormat = QApplication::tr("Copying %1...");
+ m_currentOperation = tr("Copy installer to new location");
+ m_currentOperationProgressFormat = tr("Copying %1...");
QString destinationDirectory = config->getInstallationDirectory();
@@ -624,7 +663,7 @@ void COperationDialog::copyInstaller()
CFilesCopier copier(this);
copier.setIncludeFilter(filter);
copier.addFile(oldInstallerFullPath);
- copier.setSourceDirectory(config->getSrcServerDirectory());
+ copier.setSourceDirectory(config->getSrcServerDirectory().isEmpty() ? QApplication::applicationDirPath():config->getSrcServerDirectory());
copier.setDestinationDirectory(config->getInstallationDirectory());
copier.exec();
@@ -639,6 +678,8 @@ void COperationDialog::copyInstaller()
}
}
+ // TODO: create shortcuts for installer
+
emit done();
}
@@ -687,8 +728,8 @@ void COperationDialog::cleanFiles()
// default server
const CServer &server = config->getServer();
- m_currentOperation = QApplication::tr("Clean obsolete files");
- m_currentOperationProgressFormat = QApplication::tr("Deleting %1...");
+ m_currentOperation = tr("Clean obsolete files");
+ m_currentOperationProgressFormat = tr("Deleting %1...");
CFilesCleaner cleaner(this);
cleaner.setDirectory(server.getDirectory());
@@ -703,7 +744,7 @@ bool COperationDialog::createDefaultProfile()
CServer server = config->getServer();
- m_currentOperation = QApplication::tr("Create default profile");
+ m_currentOperation = tr("Create default profile");
CProfile profile;
@@ -711,14 +752,42 @@ bool COperationDialog::createDefaultProfile()
profile.name = QString("Ryzom (%1)").arg(server.name);
profile.server = server.id;
profile.comments = "Default profile created by Ryzom Installer";
+ profile.desktopShortcut = false;
+ profile.menuShortcut = false;
#ifdef Q_OS_WIN32
-// C:\Users\Public\Desktop
- profile.desktopShortcut = QFile::exists(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/Ryzom.lnk");
-#endif
+ QStringList paths;
- // TODO
- // profile.menuShortcut
+ // desktop
+
+ // Windows XP
+ paths << "C:/Documents and Settings/All Users/Desktop";
+ // since Windows Vista
+ paths << "C:/Users/Public/Desktop";
+ // new location
+ paths << QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
+
+ foreach(const QString &path, paths)
+ {
+ if (QFile::exists(path + "/Ryzom.lnk")) profile.desktopShortcut = true;
+ }
+
+ paths.clear();
+
+ // start menu
+
+ // Windows XP
+ paths << "C:/Documents and Settings/All Users/Start Menu/Programs";
+ // since Windows Vista
+ paths << "C:/ProgramData/Microsoft/Windows/Start Menu/Programs";
+ // new location
+ paths << QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation);
+
+ foreach(const QString &path, paths)
+ {
+ if (QFile::exists(path + "/Ryzom/Ryzom.lnk")) profile.menuShortcut = true;
+ }
+#endif
config->addProfile(profile);
config->save();
@@ -728,11 +797,51 @@ bool COperationDialog::createDefaultProfile()
return true;
}
-bool COperationDialog::createDefaultShortcuts()
+bool COperationDialog::createClientDesktopShortcut(int profileIndex)
{
CConfigFile *config = CConfigFile::getInstance();
- CServer server = config->getServer();
+ const CProfile &profile = config->getProfile(profileIndex);
+ const CServer &server = config->getServer(profile.server);
+
+ m_currentOperation = tr("Create desktop shortcut for profile %1").arg(profile.id);
+
+#ifdef Q_OS_WIN32
+ if (profile.desktopShortcut)
+ {
+ QString shortcut = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/Ryzom.lnk";
+ CreateLink(config->getProfileClientFullPath(), shortcut, QString("--profile %1 %2").arg(profile.id).arg(profile.arguments), server.getDirectory(), "Default Ryzom client");
+ }
+#endif
+
+ emit done();
+
+ return true;
+}
+
+bool COperationDialog::createClientMenuShortcut(int profileIndex)
+{
+ CConfigFile *config = CConfigFile::getInstance();
+
+ const CProfile &profile = config->getProfile(profileIndex);
+ const CServer &server = config->getServer(profile.server);
+
+ m_currentOperation = tr("Create menu shortcut for profile %1").arg(profile.id);
+
+#ifdef Q_OS_WIN32
+ if (profile.menuShortcut)
+ {
+ QString path = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation) + "/Ryzom";
+
+ QDir dir;
+
+ if (dir.mkpath(path))
+ {
+ QString shortcut = path + "/Ryzom.lnk";
+ CreateLink(config->getProfileClientFullPath(), shortcut, QString("--profile %1 %2").arg(profile.id).arg(profile.arguments), server.getDirectory(), "Default Ryzom client");
+ }
+ }
+#endif
emit done();
@@ -803,8 +912,8 @@ bool COperationDialog::deleteAddRemoveEntry()
void COperationDialog::deleteComponentsServers()
{
- m_currentOperation = QApplication::tr("Delete client files");
- m_currentOperationProgressFormat = QApplication::tr("Deleting %1...");
+ m_currentOperation = tr("Delete client files");
+ m_currentOperationProgressFormat = tr("Deleting %1...");
emit prepare();
emit init(0, m_components.servers.size());
@@ -846,8 +955,8 @@ void COperationDialog::deleteComponentsServers()
void COperationDialog::deleteComponentsProfiles()
{
- m_currentOperation = QApplication::tr("Delete profiles");
- m_currentOperationProgressFormat = QApplication::tr("Deleting profile %1...");
+ m_currentOperation = tr("Delete profiles");
+ m_currentOperationProgressFormat = tr("Deleting profile %1...");
emit prepare();
emit init(0, m_components.servers.size());
@@ -894,8 +1003,8 @@ void COperationDialog::deleteComponentsProfiles()
void COperationDialog::deleteComponentsInstaller()
{
- m_currentOperation = QApplication::tr("Delete installer");
- m_currentOperationProgressFormat = QApplication::tr("Deleting %1...");
+ m_currentOperation = tr("Delete installer");
+ m_currentOperationProgressFormat = tr("Deleting %1...");
CConfigFile *config = CConfigFile::getInstance();
@@ -948,3 +1057,16 @@ bool COperationDialog::operationShouldStop()
return m_aborting;
}
+
+void COperationDialog::renamePartFile()
+{
+ QString partFile = m_downloader->getFileFullPath();
+
+ QString finalFile = partFile;
+ finalFile.remove(".part");
+
+ if (partFile != finalFile)
+ {
+ QFile::rename(partFile, finalFile);
+ }
+}
diff --git a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.h b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.h
index c37f08e42..a170c30a0 100644
--- a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.h
+++ b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.h
@@ -44,6 +44,9 @@ public:
public slots:
void onAbortClicked();
+ void onDownloadPrepared();
+ void onDownloadDone();
+
void onProgressPrepare();
void onProgressInit(qint64 current, qint64 total);
void onProgressStart();
@@ -99,7 +102,8 @@ protected:
void copyInstaller();
void uninstallOldClient();
bool createDefaultProfile();
- bool createDefaultShortcuts();
+ bool createClientDesktopShortcut(int profileIndex);
+ bool createClientMenuShortcut(int profileIndex);
bool createAddRemoveEntry();
bool deleteAddRemoveEntry();
void deleteComponentsServers();
@@ -117,6 +121,8 @@ protected:
virtual bool operationShouldStop();
+ void renamePartFile();
+
QWinTaskbarButton *m_button;
CDownloader *m_downloader;
diff --git a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp
index 85c176219..cbfcacaf8 100644
--- a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp
+++ b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp
@@ -31,6 +31,7 @@ CProfilesDialog::CProfilesDialog(QWidget *parent):QDialog(parent), m_currentProf
connect(addButton, SIGNAL(clicked()), SLOT(onAddProfile()));
connect(deleteButton, SIGNAL(clicked()), SLOT(onDeleteProfile()));
connect(profilesListView, SIGNAL(clicked(QModelIndex)), SLOT(onProfileClicked(QModelIndex)));
+ connect(executableDefaultButton, SIGNAL(clicked()), SLOT(onExecutableDefaultClicked()));
connect(executableBrowseButton, SIGNAL(clicked()), SLOT(onExecutableBrowseClicked()));
connect(directoryButton, SIGNAL(clicked()), SLOT(onProfileDirectoryClicked()));
@@ -241,10 +242,21 @@ void CProfilesDialog::updateExecutableVersion(int index)
if (reg.indexIn(versionString) > -1)
{
- executableVersionLabel->setText(reg.cap(2));
+ executablePathLabel->setText(QString("%1 (%2)").arg(QFileInfo(executable).fileName()).arg(reg.cap(2)));
}
}
+void CProfilesDialog::onExecutableDefaultClicked()
+{
+ if (m_currentProfileIndex < 0) return;
+
+ CProfile &profile = m_model->getProfiles()[m_currentProfileIndex];
+
+ profile.executable.clear();
+
+ updateExecutableVersion(m_currentProfileIndex);
+}
+
void CProfilesDialog::onExecutableBrowseClicked()
{
if (m_currentProfileIndex < 0) return;
diff --git a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.h b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.h
index 268525fd6..9f364f4ae 100644
--- a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.h
+++ b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.h
@@ -51,6 +51,7 @@ private slots:
void updateExecutableVersion(int index);
+ void onExecutableDefaultClicked();
void onExecutableBrowseClicked();
private:
diff --git a/code/ryzom/tools/client/ryzom_installer/src/utils.cpp b/code/ryzom/tools/client/ryzom_installer/src/utils.cpp
index 5ab73f298..d9ebda4c0 100644
--- a/code/ryzom/tools/client/ryzom_installer/src/utils.cpp
+++ b/code/ryzom/tools/client/ryzom_installer/src/utils.cpp
@@ -111,22 +111,22 @@ wchar_t* qToWide(const QString &str)
// Shell link, stored in the Comment field of the link
// properties.
-HRESULT CreateLink(const QString &pathObj, const QString &pathLink, const QString &desc)
+bool CreateLink(const QString &pathObj, const QString &pathLink, const QString &arguments, const QString &workingDir, const QString &desc)
{
IShellLinkW* psl;
// Get a pointer to the IShellLink interface. It is assumed that CoInitialize
// has already been called.
- HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl);
+ HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLinkW, (LPVOID*)&psl);
if (SUCCEEDED(hres))
{
IPersistFile* ppf;
// Set the path to the shortcut target and add the description.
- psl->SetPath(qToWide(pathObj));
+ psl->SetPath(qToWide(QDir::toNativeSeparators(pathObj)));
psl->SetDescription(qToWide(desc));
- psl->SetArguments(L"--profil ");
- psl->SetWorkingDirectory(L"");
+ psl->SetArguments(qToWide(arguments));
+ psl->SetWorkingDirectory(qToWide(QDir::toNativeSeparators(workingDir)));
// Query IShellLink for the IPersistFile interface, used for saving the
// shortcut in persistent storage.
@@ -138,12 +138,12 @@ HRESULT CreateLink(const QString &pathObj, const QString &pathLink, const QStrin
// for success.
// Save the link by calling IPersistFile::Save.
- hres = ppf->Save(qToWide(pathLink), TRUE);
+ hres = ppf->Save(qToWide(QDir::toNativeSeparators(pathLink)), TRUE);
ppf->Release();
}
psl->Release();
}
- return hres;
+ return SUCCEEDED(hres);
}
// ResolveIt - Uses the Shell's IShellLink and IPersistFile interfaces
@@ -163,7 +163,7 @@ HRESULT CreateLink(const QString &pathObj, const QString &pathLink, const QStrin
// Shell link, stored in the Comment field of the link
// properties.
-HRESULT ResolveIt(HWND hwnd, const QString &linkFile, QString &path)
+bool ResolveLink(const QWidget &window, const QString &linkFile, QString &path)
{
IShellLinkW* psl;
WIN32_FIND_DATAW wfd;
@@ -186,12 +186,12 @@ HRESULT ResolveIt(HWND hwnd, const QString &linkFile, QString &path)
// for success.
// Load the shortcut.
- hres = ppf->Load(qToWide(linkFile), STGM_READ);
+ hres = ppf->Load(qToWide(QDir::toNativeSeparators(linkFile)), STGM_READ);
if (SUCCEEDED(hres))
{
// Resolve the link.
- hres = psl->Resolve(hwnd, 0);
+ hres = psl->Resolve((HWND)window.winId(), 0);
if (SUCCEEDED(hres))
{
@@ -210,7 +210,7 @@ HRESULT ResolveIt(HWND hwnd, const QString &linkFile, QString &path)
if (SUCCEEDED(hres))
{
// Handle success
- path = qFromWide(szGotPath);
+ path = QDir::fromNativeSeparators(qFromWide(szGotPath));
}
else
{
@@ -227,7 +227,19 @@ HRESULT ResolveIt(HWND hwnd, const QString &linkFile, QString &path)
psl->Release();
}
- return hres;
+ return SUCCEEDED(hres);
+}
+
+#else
+
+bool CreateLink(const QString &pathObj, const QString &pathLink, const QString &arguments, const QString &workingDir, const QString &desc)
+{
+ return false;
+}
+
+bool ResolveLink(const QWidget &window, const QString &pathLink, QString &pathObj)
+{
+ return false;
}
#endif
diff --git a/code/ryzom/tools/client/ryzom_installer/src/utils.h b/code/ryzom/tools/client/ryzom_installer/src/utils.h
index 8e760b400..6c2533076 100644
--- a/code/ryzom/tools/client/ryzom_installer/src/utils.h
+++ b/code/ryzom/tools/client/ryzom_installer/src/utils.h
@@ -48,4 +48,7 @@ QString qFromWide(const wchar_t *str);
wchar_t* qToWide(const QString &str);
+bool CreateLink(const QString &pathObj, const QString &pathLink, const QString &arguments, const QString &workingDir, const QString &desc);
+bool ResolveLink(const QWidget &window, const QString &pathLink, QString &pathObj);
+
#endif
diff --git a/code/ryzom/tools/client/ryzom_installer/ui/profilesdialog.ui b/code/ryzom/tools/client/ryzom_installer/ui/profilesdialog.ui
index c0c12bab2..670845482 100644
--- a/code/ryzom/tools/client/ryzom_installer/ui/profilesdialog.ui
+++ b/code/ryzom/tools/client/ryzom_installer/ui/profilesdialog.ui
@@ -7,7 +7,7 @@
0
0
583
- 348
+ 329
@@ -119,7 +119,7 @@
-
-
+
-
@@ -127,6 +127,13 @@
+ -
+
+
+ Default
+
+
+
-
@@ -137,37 +144,23 @@
-
-
-
- Client version:
-
-
-
- -
-
-
- FV 3.0.0
-
-
-
- -
Arguments:
- -
+
-
- -
+
-
Comments:
- -
+
-
@@ -177,14 +170,14 @@
- -
+
-
Directory:
- -
+
-
-
@@ -202,14 +195,14 @@
- -
+
-
Create shortcuts:
- -
+
-
-