Merge with develop

--HG--
branch : compatibility-develop
hg/compatibility-develop
kervala 9 years ago
commit 3386ee874e

@ -1784,7 +1784,9 @@ std::string CPath::getApplicationDirectory(const std::string &appName, bool loca
std::string CFileContainer::getApplicationDirectory(const std::string &appName, bool local) std::string CFileContainer::getApplicationDirectory(const std::string &appName, bool local)
{ {
static std::string appPaths[2]; static std::string appPaths[2];
std::string &appPath = appPaths[local ? 1 : 0]; std::string &appPath = appPaths[local ? 1 : 0];
if (appPath.empty()) if (appPath.empty())
{ {
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
@ -1800,26 +1802,21 @@ std::string CFileContainer::getApplicationDirectory(const std::string &appName,
SHGetSpecialFolderPathW(NULL, buffer, CSIDL_APPDATA, TRUE); SHGetSpecialFolderPathW(NULL, buffer, CSIDL_APPDATA, TRUE);
} }
appPath = CPath::standardizePath(wideToUtf8(buffer)); appPath = CPath::standardizePath(wideToUtf8(buffer));
#elif defined(NL_OS_MAC)
appPath = CPath::standardizePath(getenv("HOME"));
appPath += "/Library/Application Support/";
#else #else
appPath = CPath::standardizePath(getenv("HOME")); // get user home directory from HOME environment variable
#endif const char* homePath = getenv("HOME");
} appPath = CPath::standardizePath(homePath ? homePath : ".");
std::string path = appPath; #if defined(NL_OS_MAC)
#ifdef NL_OS_WINDOWS appPath += "Library/Application Support/";
if (!appName.empty())
path = CPath::standardizePath(path + appName);
#elif defined(NL_OS_MAC)
path = CPath::standardizePath(path + appName);
#else #else
if (!appName.empty()) // recommended for applications data that are owned by user
path = CPath::standardizePath(path + "." + toLower(appName)); appPath += ".local/share/";
#endif
#endif #endif
}
return path; return CPath::standardizePath(appPath + appName);
} }
std::string CPath::getTemporaryDirectory() std::string CPath::getTemporaryDirectory()

@ -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_language = QLocale::system().name().left(2); // only keep language ISO 639 code
m_defaultConfigPath = QApplication::applicationDirPath() + "/installer.ini"; m_defaultConfigPath = QApplication::applicationDirPath() + "/installer.ini";
m_configPath = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/installer.ini"; m_configPath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/installer.ini";
} }
CConfigFile::~CConfigFile() CConfigFile::~CConfigFile()
@ -608,9 +608,24 @@ bool CConfigFile::foundTemporaryFiles(const QString &directory) const
bool CConfigFile::shouldCreateDesktopShortcut() const bool CConfigFile::shouldCreateDesktopShortcut() const
{ {
#ifdef Q_OS_WIN32
const CProfile &profile = getProfile(); 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 QString CConfigFile::getProfileClientFullPath(int profileIndex) const
@ -704,7 +719,7 @@ OperationStep CConfigFile::getInstallNextStep() const
// downloaded files are kept in server directory // downloaded files are kept in server directory
QString dataFile = getInstallationDirectory() + "/" + server.dataDownloadFilename; QString dataFile = getInstallationDirectory() + "/" + server.dataDownloadFilename;
QString clientFile = getInstallationDirectory() + "/" + server.clientDownloadFilename; QString clientFile = getInstallationDirectory() + "/" + expandVariables(server.clientDownloadFilename);
// data are not copied // data are not copied
if (!areRyzomDataInstalledIn(serverDirectory)) if (!areRyzomDataInstalledIn(serverDirectory))
@ -760,7 +775,7 @@ OperationStep CConfigFile::getInstallNextStep() const
return ExtractBnpClient; return ExtractBnpClient;
} }
QString clientFile = getInstallationDirectory() + "/" + server.clientDownloadFilename; QString clientFile = getInstallationDirectory() + "/" + expandVariables(server.clientDownloadFilename);
// when file is not finished, it has .part extension // when file is not finished, it has .part extension
if (!QFile::exists(clientFile)) if (!QFile::exists(clientFile))
@ -799,8 +814,12 @@ OperationStep CConfigFile::getInstallNextStep() const
if (shouldCreateDesktopShortcut()) if (shouldCreateDesktopShortcut())
{ {
// TODO: check they point to getClientFullPath() return CreateDesktopShortcut;
return CreateShortcuts; }
if (shouldCreateMenuShortcut())
{
return CreateMenuShortcut;
} }
#ifdef Q_OS_WIN #ifdef Q_OS_WIN

@ -153,6 +153,7 @@ public:
bool foundTemporaryFiles(const QString &directory) const; bool foundTemporaryFiles(const QString &directory) const;
bool shouldCreateDesktopShortcut() const; bool shouldCreateDesktopShortcut() const;
bool shouldCreateMenuShortcut() const;
// installation choices // installation choices
bool use64BitsClient() const; bool use64BitsClient() const;

@ -147,6 +147,8 @@ void CDownloader::getFileHead()
{ {
// file is already downloaded // file is already downloaded
if (m_listener) m_listener->operationSuccess(m_size); if (m_listener) m_listener->operationSuccess(m_size);
emit downloadDone();
} }
else else
{ {
@ -339,6 +341,10 @@ void CDownloader::onHeadFinished()
downloadFile(); downloadFile();
} }
} }
else
{
emit downloadPrepared();
}
} }
void CDownloader::onDownloadFinished() void CDownloader::onDownloadFinished()
@ -357,6 +363,8 @@ void CDownloader::onDownloadFinished()
bool ok = NLMISC::CFile::setFileModificationDate(m_fullPath.toUtf8().constData(), m_lastModified.toTime_t()); bool ok = NLMISC::CFile::setFileModificationDate(m_fullPath.toUtf8().constData(), m_lastModified.toTime_t());
if (m_listener) m_listener->operationSuccess(m_size); 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; if (!m_listener) return;
m_listener->operationProgress(m_offset + current, ""); // TODO: put file m_listener->operationProgress(m_offset + current, m_url);
// abort download // abort download
if (m_listener->operationShouldStop() && m_reply) m_reply->abort(); if (m_listener->operationShouldStop() && m_reply) m_reply->abort();

@ -42,7 +42,11 @@ public:
bool isDownloading() const { return m_file != NULL; } bool isDownloading() const { return m_file != NULL; }
QString getFileFullPath() const { return m_fullPath; }
signals: signals:
void downloadPrepared();
void downloadDone();
void htmlPageContent(const QString &html); void htmlPageContent(const QString &html);
private slots: private slots:

@ -92,6 +92,7 @@ void CMainWindow::onPlayClicked()
CConfigFile *config = CConfigFile::getInstance(); CConfigFile *config = CConfigFile::getInstance();
const CProfile &profile = config->getProfile(profileIndex); const CProfile &profile = config->getProfile(profileIndex);
const CServer &server = config->getServer(profile.server);
// get full path of client executable // get full path of client executable
QString executable = config->getProfileClientFullPath(profileIndex); QString executable = config->getProfileClientFullPath(profileIndex);
@ -104,8 +105,8 @@ void CMainWindow::onPlayClicked()
arguments << profile.id; arguments << profile.id;
arguments << profile.arguments.split(' '); arguments << profile.arguments.split(' ');
// launch the game with all arguments // launch the game with all arguments and from server root directory (to use right data)
bool started = QProcess::startDetached(executable, arguments); bool started = QProcess::startDetached(executable, arguments, server.getDirectory());
// define this profile as default one // define this profile as default one
CConfigFile::getInstance()->setDefaultProfileIndex(profileIndex); CConfigFile::getInstance()->setDefaultProfileIndex(profileIndex);

@ -62,7 +62,8 @@ enum OperationStep
CopyInstaller, CopyInstaller,
UninstallOldClient, UninstallOldClient,
CreateProfile, CreateProfile,
CreateShortcuts, CreateDesktopShortcut,
CreateMenuShortcut,
CreateAddRemoveEntry, CreateAddRemoveEntry,
Done Done
}; };

@ -21,6 +21,7 @@
#include "configfile.h" #include "configfile.h"
#include "config.h" #include "config.h"
#include "profilesmodel.h" #include "profilesmodel.h"
#include "utils.h"
#include "filescopier.h" #include "filescopier.h"
#include "filesextractor.h" #include "filesextractor.h"
@ -54,6 +55,9 @@ COperationDialog::COperationDialog(QWidget *parent):QDialog(parent), m_aborting(
// downloader // downloader
m_downloader = new CDownloader(this, this); 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())); connect(operationButtonBox, SIGNAL(clicked(QAbstractButton*)), SLOT(onAbortClicked()));
// operations // operations
@ -164,8 +168,12 @@ void COperationDialog::processInstallNextStep()
createDefaultProfile(); createDefaultProfile();
break; break;
case CreateShortcuts: case CreateDesktopShortcut:
createDefaultShortcuts(); createClientDesktopShortcut(0);
break;
case CreateMenuShortcut:
createClientMenuShortcut(0);
break; break;
case CreateAddRemoveEntry: case CreateAddRemoveEntry:
@ -278,7 +286,7 @@ void COperationDialog::processUpdateProfilesNextStep()
} }
else 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; m_aborting = true;
} }
void COperationDialog::onDownloadPrepared()
{
// actually download the file
m_downloader->getFile();
}
void COperationDialog::onDownloadDone()
{
renamePartFile();
emit done();
}
void COperationDialog::onProgressPrepare() void COperationDialog::onProgressPrepare()
{ {
operationProgressBar->setFormat(tr("%p% (%v/%m KiB)")); operationProgressBar->setFormat(tr("%p% (%v/%m KiB)"));
@ -419,15 +440,33 @@ void COperationDialog::downloadData()
const CServer &server = config->getServer(m_currentServerId); const CServer &server = config->getServer(m_currentServerId);
m_currentOperation = QApplication::tr("Download data required by server %1").arg(server.name); m_currentOperation = tr("Download data required by server %1").arg(server.name);
m_currentOperationProgressFormat = QApplication::tr("Downloading %1..."); m_currentOperationProgressFormat = tr("Downloading %1...");
m_downloader->prepareFile(config->expandVariables(server.dataDownloadUrl), config->getInstallationDirectory() + "/" + config->expandVariables(server.dataDownloadFilename) + ".part"); m_downloader->prepareFile(config->expandVariables(server.dataDownloadUrl), config->getInstallationDirectory() + "/" + config->expandVariables(server.dataDownloadFilename) + ".part");
} }
void COperationDialog::extractDownloadedData() 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() void COperationDialog::downloadClient()
@ -436,8 +475,8 @@ void COperationDialog::downloadClient()
const CServer &server = config->getServer(m_currentServerId); const CServer &server = config->getServer(m_currentServerId);
m_currentOperation = QApplication::tr("Download client required by server %1").arg(server.name); m_currentOperation = tr("Download client required by server %1").arg(server.name);
m_currentOperationProgressFormat = QApplication::tr("Downloading %1..."); m_currentOperationProgressFormat = tr("Downloading %1...");
m_downloader->prepareFile(config->expandVariables(server.clientDownloadUrl), config->getInstallationDirectory() + "/" + config->expandVariables(server.clientDownloadFilename) + ".part"); 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); const CServer &server = config->getServer(m_currentServerId);
m_currentOperation = QApplication::tr("Extract data files required by server %1").arg(server.name); m_currentOperation = tr("Extract client files required by server %1").arg(server.name);
m_currentOperationProgressFormat = QApplication::tr("Extracting %1..."); m_currentOperationProgressFormat = tr("Extracting %1...");
CFilesExtractor extractor(this); CFilesExtractor extractor(this);
extractor.setSourceFile(config->getInstallationDirectory() + "/" + server.clientDownloadFilename); extractor.setSourceFile(config->getInstallationDirectory() + "/" + config->expandVariables(server.clientDownloadFilename));
extractor.setDestinationDirectory(server.getDirectory()); extractor.setDestinationDirectory(server.getDirectory());
if (extractor.exec()) if (extractor.exec())
@ -472,8 +511,8 @@ void COperationDialog::copyDataFiles()
// default server // default server
const CServer &server = config->getServer(m_currentServerId); const CServer &server = config->getServer(m_currentServerId);
m_currentOperation = QApplication::tr("Copy data files required by server %1").arg(server.name); m_currentOperation = tr("Copy data files required by server %1").arg(server.name);
m_currentOperationProgressFormat = QApplication::tr("Copying %1..."); m_currentOperationProgressFormat = tr("Copying %1...");
QStringList serverFiles; QStringList serverFiles;
serverFiles << "cfg"; serverFiles << "cfg";
@ -507,8 +546,8 @@ void COperationDialog::copyProfileFiles()
// default profile // default profile
const CProfile &profile = config->getProfile(); const CProfile &profile = config->getProfile();
m_currentOperation = QApplication::tr("Copy old profile to new location"); m_currentOperation = tr("Copy old profile to new location");
m_currentOperationProgressFormat = QApplication::tr("Copying %1..."); m_currentOperationProgressFormat = tr("Copying %1...");
QStringList profileFiles; QStringList profileFiles;
profileFiles << "cache"; profileFiles << "cache";
@ -540,8 +579,8 @@ void COperationDialog::extractBnpClient()
// default server // default server
const CServer &server = config->getServer(); const CServer &server = config->getServer();
m_currentOperation = QApplication::tr("Extract client to new location"); m_currentOperation = tr("Extract client to new location");
m_currentOperationProgressFormat = QApplication::tr("Extracting %1..."); m_currentOperationProgressFormat = tr("Extracting %1...");
QString destinationDirectory = server.getDirectory(); QString destinationDirectory = server.getDirectory();
@ -602,8 +641,8 @@ void COperationDialog::copyInstaller()
// default server // default server
const CServer &server = config->getServer(); const CServer &server = config->getServer();
m_currentOperation = QApplication::tr("Copy installer to new location"); m_currentOperation = tr("Copy installer to new location");
m_currentOperationProgressFormat = QApplication::tr("Copying %1..."); m_currentOperationProgressFormat = tr("Copying %1...");
QString destinationDirectory = config->getInstallationDirectory(); QString destinationDirectory = config->getInstallationDirectory();
@ -624,7 +663,7 @@ void COperationDialog::copyInstaller()
CFilesCopier copier(this); CFilesCopier copier(this);
copier.setIncludeFilter(filter); copier.setIncludeFilter(filter);
copier.addFile(oldInstallerFullPath); copier.addFile(oldInstallerFullPath);
copier.setSourceDirectory(config->getSrcServerDirectory()); copier.setSourceDirectory(config->getSrcServerDirectory().isEmpty() ? QApplication::applicationDirPath():config->getSrcServerDirectory());
copier.setDestinationDirectory(config->getInstallationDirectory()); copier.setDestinationDirectory(config->getInstallationDirectory());
copier.exec(); copier.exec();
@ -639,6 +678,8 @@ void COperationDialog::copyInstaller()
} }
} }
// TODO: create shortcuts for installer
emit done(); emit done();
} }
@ -687,8 +728,8 @@ void COperationDialog::cleanFiles()
// default server // default server
const CServer &server = config->getServer(); const CServer &server = config->getServer();
m_currentOperation = QApplication::tr("Clean obsolete files"); m_currentOperation = tr("Clean obsolete files");
m_currentOperationProgressFormat = QApplication::tr("Deleting %1..."); m_currentOperationProgressFormat = tr("Deleting %1...");
CFilesCleaner cleaner(this); CFilesCleaner cleaner(this);
cleaner.setDirectory(server.getDirectory()); cleaner.setDirectory(server.getDirectory());
@ -703,7 +744,7 @@ bool COperationDialog::createDefaultProfile()
CServer server = config->getServer(); CServer server = config->getServer();
m_currentOperation = QApplication::tr("Create default profile"); m_currentOperation = tr("Create default profile");
CProfile profile; CProfile profile;
@ -711,14 +752,42 @@ bool COperationDialog::createDefaultProfile()
profile.name = QString("Ryzom (%1)").arg(server.name); profile.name = QString("Ryzom (%1)").arg(server.name);
profile.server = server.id; profile.server = server.id;
profile.comments = "Default profile created by Ryzom Installer"; profile.comments = "Default profile created by Ryzom Installer";
profile.desktopShortcut = false;
profile.menuShortcut = false;
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
// C:\Users\Public\Desktop QStringList paths;
profile.desktopShortcut = QFile::exists(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/Ryzom.lnk");
#endif // 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);
// TODO foreach(const QString &path, paths)
// profile.menuShortcut {
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->addProfile(profile);
config->save(); config->save();
@ -728,11 +797,51 @@ bool COperationDialog::createDefaultProfile()
return true; return true;
} }
bool COperationDialog::createDefaultShortcuts() bool COperationDialog::createClientDesktopShortcut(int profileIndex)
{ {
CConfigFile *config = CConfigFile::getInstance(); 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(); emit done();
@ -803,8 +912,8 @@ bool COperationDialog::deleteAddRemoveEntry()
void COperationDialog::deleteComponentsServers() void COperationDialog::deleteComponentsServers()
{ {
m_currentOperation = QApplication::tr("Delete client files"); m_currentOperation = tr("Delete client files");
m_currentOperationProgressFormat = QApplication::tr("Deleting %1..."); m_currentOperationProgressFormat = tr("Deleting %1...");
emit prepare(); emit prepare();
emit init(0, m_components.servers.size()); emit init(0, m_components.servers.size());
@ -846,8 +955,8 @@ void COperationDialog::deleteComponentsServers()
void COperationDialog::deleteComponentsProfiles() void COperationDialog::deleteComponentsProfiles()
{ {
m_currentOperation = QApplication::tr("Delete profiles"); m_currentOperation = tr("Delete profiles");
m_currentOperationProgressFormat = QApplication::tr("Deleting profile %1..."); m_currentOperationProgressFormat = tr("Deleting profile %1...");
emit prepare(); emit prepare();
emit init(0, m_components.servers.size()); emit init(0, m_components.servers.size());
@ -894,8 +1003,8 @@ void COperationDialog::deleteComponentsProfiles()
void COperationDialog::deleteComponentsInstaller() void COperationDialog::deleteComponentsInstaller()
{ {
m_currentOperation = QApplication::tr("Delete installer"); m_currentOperation = tr("Delete installer");
m_currentOperationProgressFormat = QApplication::tr("Deleting %1..."); m_currentOperationProgressFormat = tr("Deleting %1...");
CConfigFile *config = CConfigFile::getInstance(); CConfigFile *config = CConfigFile::getInstance();
@ -948,3 +1057,16 @@ bool COperationDialog::operationShouldStop()
return m_aborting; return m_aborting;
} }
void COperationDialog::renamePartFile()
{
QString partFile = m_downloader->getFileFullPath();
QString finalFile = partFile;
finalFile.remove(".part");
if (partFile != finalFile)
{
QFile::rename(partFile, finalFile);
}
}

@ -44,6 +44,9 @@ public:
public slots: public slots:
void onAbortClicked(); void onAbortClicked();
void onDownloadPrepared();
void onDownloadDone();
void onProgressPrepare(); void onProgressPrepare();
void onProgressInit(qint64 current, qint64 total); void onProgressInit(qint64 current, qint64 total);
void onProgressStart(); void onProgressStart();
@ -99,7 +102,8 @@ protected:
void copyInstaller(); void copyInstaller();
void uninstallOldClient(); void uninstallOldClient();
bool createDefaultProfile(); bool createDefaultProfile();
bool createDefaultShortcuts(); bool createClientDesktopShortcut(int profileIndex);
bool createClientMenuShortcut(int profileIndex);
bool createAddRemoveEntry(); bool createAddRemoveEntry();
bool deleteAddRemoveEntry(); bool deleteAddRemoveEntry();
void deleteComponentsServers(); void deleteComponentsServers();
@ -117,6 +121,8 @@ protected:
virtual bool operationShouldStop(); virtual bool operationShouldStop();
void renamePartFile();
QWinTaskbarButton *m_button; QWinTaskbarButton *m_button;
CDownloader *m_downloader; CDownloader *m_downloader;

@ -31,6 +31,7 @@ CProfilesDialog::CProfilesDialog(QWidget *parent):QDialog(parent), m_currentProf
connect(addButton, SIGNAL(clicked()), SLOT(onAddProfile())); connect(addButton, SIGNAL(clicked()), SLOT(onAddProfile()));
connect(deleteButton, SIGNAL(clicked()), SLOT(onDeleteProfile())); connect(deleteButton, SIGNAL(clicked()), SLOT(onDeleteProfile()));
connect(profilesListView, SIGNAL(clicked(QModelIndex)), SLOT(onProfileClicked(QModelIndex))); connect(profilesListView, SIGNAL(clicked(QModelIndex)), SLOT(onProfileClicked(QModelIndex)));
connect(executableDefaultButton, SIGNAL(clicked()), SLOT(onExecutableDefaultClicked()));
connect(executableBrowseButton, SIGNAL(clicked()), SLOT(onExecutableBrowseClicked())); connect(executableBrowseButton, SIGNAL(clicked()), SLOT(onExecutableBrowseClicked()));
connect(directoryButton, SIGNAL(clicked()), SLOT(onProfileDirectoryClicked())); connect(directoryButton, SIGNAL(clicked()), SLOT(onProfileDirectoryClicked()));
@ -241,10 +242,21 @@ void CProfilesDialog::updateExecutableVersion(int index)
if (reg.indexIn(versionString) > -1) 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() void CProfilesDialog::onExecutableBrowseClicked()
{ {
if (m_currentProfileIndex < 0) return; if (m_currentProfileIndex < 0) return;

@ -51,6 +51,7 @@ private slots:
void updateExecutableVersion(int index); void updateExecutableVersion(int index);
void onExecutableDefaultClicked();
void onExecutableBrowseClicked(); void onExecutableBrowseClicked();
private: private:

@ -111,22 +111,22 @@ wchar_t* qToWide(const QString &str)
// Shell link, stored in the Comment field of the link // Shell link, stored in the Comment field of the link
// properties. // 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; IShellLinkW* psl;
// Get a pointer to the IShellLink interface. It is assumed that CoInitialize // Get a pointer to the IShellLink interface. It is assumed that CoInitialize
// has already been called. // 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)) if (SUCCEEDED(hres))
{ {
IPersistFile* ppf; IPersistFile* ppf;
// Set the path to the shortcut target and add the description. // 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->SetDescription(qToWide(desc));
psl->SetArguments(L"--profil "); psl->SetArguments(qToWide(arguments));
psl->SetWorkingDirectory(L""); psl->SetWorkingDirectory(qToWide(QDir::toNativeSeparators(workingDir)));
// Query IShellLink for the IPersistFile interface, used for saving the // Query IShellLink for the IPersistFile interface, used for saving the
// shortcut in persistent storage. // shortcut in persistent storage.
@ -138,12 +138,12 @@ HRESULT CreateLink(const QString &pathObj, const QString &pathLink, const QStrin
// for success. // for success.
// Save the link by calling IPersistFile::Save. // Save the link by calling IPersistFile::Save.
hres = ppf->Save(qToWide(pathLink), TRUE); hres = ppf->Save(qToWide(QDir::toNativeSeparators(pathLink)), TRUE);
ppf->Release(); ppf->Release();
} }
psl->Release(); psl->Release();
} }
return hres; return SUCCEEDED(hres);
} }
// ResolveIt - Uses the Shell's IShellLink and IPersistFile interfaces // 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 // Shell link, stored in the Comment field of the link
// properties. // properties.
HRESULT ResolveIt(HWND hwnd, const QString &linkFile, QString &path) bool ResolveLink(const QWidget &window, const QString &linkFile, QString &path)
{ {
IShellLinkW* psl; IShellLinkW* psl;
WIN32_FIND_DATAW wfd; WIN32_FIND_DATAW wfd;
@ -186,12 +186,12 @@ HRESULT ResolveIt(HWND hwnd, const QString &linkFile, QString &path)
// for success. // for success.
// Load the shortcut. // Load the shortcut.
hres = ppf->Load(qToWide(linkFile), STGM_READ); hres = ppf->Load(qToWide(QDir::toNativeSeparators(linkFile)), STGM_READ);
if (SUCCEEDED(hres)) if (SUCCEEDED(hres))
{ {
// Resolve the link. // Resolve the link.
hres = psl->Resolve(hwnd, 0); hres = psl->Resolve((HWND)window.winId(), 0);
if (SUCCEEDED(hres)) if (SUCCEEDED(hres))
{ {
@ -210,7 +210,7 @@ HRESULT ResolveIt(HWND hwnd, const QString &linkFile, QString &path)
if (SUCCEEDED(hres)) if (SUCCEEDED(hres))
{ {
// Handle success // Handle success
path = qFromWide(szGotPath); path = QDir::fromNativeSeparators(qFromWide(szGotPath));
} }
else else
{ {
@ -227,7 +227,19 @@ HRESULT ResolveIt(HWND hwnd, const QString &linkFile, QString &path)
psl->Release(); 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 #endif

@ -48,4 +48,7 @@ QString qFromWide(const wchar_t *str);
wchar_t* qToWide(const QString &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 #endif

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>583</width> <width>583</width>
<height>348</height> <height>329</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -119,7 +119,7 @@
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="3" column="1">
<layout class="QHBoxLayout" name="executableLayout" stretch="1,0"> <layout class="QHBoxLayout" name="executableLayout" stretch="1,0,0">
<item> <item>
<widget class="QLabel" name="executablePathLabel"> <widget class="QLabel" name="executablePathLabel">
<property name="text"> <property name="text">
@ -127,6 +127,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="executableDefaultButton">
<property name="text">
<string>Default</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="executableBrowseButton"> <widget class="QPushButton" name="executableBrowseButton">
<property name="text"> <property name="text">
@ -137,37 +144,23 @@
</layout> </layout>
</item> </item>
<item row="4" column="0"> <item row="4" column="0">
<widget class="QLabel" name="clientVersionLabel">
<property name="text">
<string>Client version:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="executableVersionLabel">
<property name="text">
<string>FV 3.0.0</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="argumentsLabel"> <widget class="QLabel" name="argumentsLabel">
<property name="text"> <property name="text">
<string>Arguments:</string> <string>Arguments:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="1"> <item row="4" column="1">
<widget class="QLineEdit" name="argumentsEdit"/> <widget class="QLineEdit" name="argumentsEdit"/>
</item> </item>
<item row="6" column="0"> <item row="5" column="0">
<widget class="QLabel" name="commentsLabel"> <widget class="QLabel" name="commentsLabel">
<property name="text"> <property name="text">
<string>Comments:</string> <string>Comments:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="1"> <item row="5" column="1">
<widget class="QPlainTextEdit" name="commentsEdit"> <widget class="QPlainTextEdit" name="commentsEdit">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
@ -177,14 +170,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0"> <item row="6" column="0">
<widget class="QLabel" name="directoryLabel"> <widget class="QLabel" name="directoryLabel">
<property name="text"> <property name="text">
<string>Directory:</string> <string>Directory:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="1"> <item row="6" column="1">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0"> <layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0">
<item> <item>
<widget class="QLabel" name="directoryPathLabel"> <widget class="QLabel" name="directoryPathLabel">
@ -202,14 +195,14 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="8" column="0"> <item row="7" column="0">
<widget class="QLabel" name="shortcutsLabel"> <widget class="QLabel" name="shortcutsLabel">
<property name="text"> <property name="text">
<string>Create shortcuts:</string> <string>Create shortcuts:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="1"> <item row="7" column="1">
<layout class="QVBoxLayout" name="shortcutsLayout"> <layout class="QVBoxLayout" name="shortcutsLayout">
<item> <item>
<widget class="QCheckBox" name="desktopShortcutCheckBox"> <widget class="QCheckBox" name="desktopShortcutCheckBox">

Loading…
Cancel
Save