mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-27 01:26:30 +00:00
Merge with develop
--HG-- branch : compatibility-develop
This commit is contained in:
commit
20f0092e63
8 changed files with 90 additions and 44 deletions
|
@ -18,8 +18,6 @@
|
|||
#include "configfile.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include "nel/misc/path.h"
|
||||
|
||||
#ifdef DEBUG_NEW
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
@ -674,9 +672,7 @@ bool CConfigFile::shouldCreateDesktopShortcut() const
|
|||
|
||||
if (!profile.desktopShortcut) return false;
|
||||
|
||||
QString shortcut = profile.getClientDesktopShortcutFullPath();
|
||||
|
||||
return !shortcut.isEmpty() && !NLMISC::CFile::isExists(qToUtf8(appendLinkExtension(shortcut)));
|
||||
return !shortcutExists(profile.getClientDesktopShortcutFullPath());
|
||||
}
|
||||
|
||||
bool CConfigFile::shouldCreateMenuShortcut() const
|
||||
|
@ -685,9 +681,7 @@ bool CConfigFile::shouldCreateMenuShortcut() const
|
|||
|
||||
if (!profile.menuShortcut) return false;
|
||||
|
||||
QString shortcut = profile.getClientMenuShortcutFullPath();
|
||||
|
||||
return !shortcut.isEmpty() && !NLMISC::CFile::isExists(qToUtf8(appendLinkExtension(shortcut)));
|
||||
return !shortcutExists(profile.getClientMenuShortcutFullPath());
|
||||
}
|
||||
|
||||
bool CConfigFile::shouldCopyInstaller() const
|
||||
|
@ -732,10 +726,16 @@ QString CConfigFile::getInstallerOriginalDirPath() const
|
|||
return m_installationDirectory;
|
||||
}
|
||||
|
||||
QString CConfigFile::getInstallerMenuLinkFullPath() const
|
||||
QString CConfigFile::getInstallerMenuShortcutFullPath() const
|
||||
{
|
||||
// don't put extension
|
||||
return QString("%1/%2/%2 Installer").arg(QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation)).arg(QApplication::applicationName());
|
||||
return QString("%1/%2 Installer").arg(CConfigFile::getInstance()->getMenuDirectory()).arg(QApplication::applicationName());
|
||||
}
|
||||
|
||||
QString CConfigFile::getInstallerDesktopShortcutFullPath() const
|
||||
{
|
||||
// don't put extension
|
||||
return QString("%1/%2 Installer").arg(CConfigFile::getInstance()->getDesktopDirectory()).arg(QApplication::applicationName());
|
||||
}
|
||||
|
||||
QStringList CConfigFile::getInstallerRequiredFiles() const
|
||||
|
|
|
@ -125,7 +125,8 @@ public:
|
|||
QString getInstallerOriginalFilePath() const;
|
||||
QString getInstallerOriginalDirPath() const;
|
||||
|
||||
QString getInstallerMenuLinkFullPath() const;
|
||||
QString getInstallerMenuShortcutFullPath() const;
|
||||
QString getInstallerDesktopShortcutFullPath() const;
|
||||
|
||||
QStringList getInstallerRequiredFiles() const;
|
||||
|
||||
|
|
|
@ -43,7 +43,8 @@
|
|||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
COperationDialog::COperationDialog(QWidget *parent):QDialog(parent), m_aborting(false), m_operation(OperationNone)
|
||||
COperationDialog::COperationDialog(QWidget *parent):QDialog(parent), m_aborting(false), m_operation(OperationNone),
|
||||
m_operationStep(DisplayNoServerError), m_operationStepCounter(0)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
|
@ -134,6 +135,21 @@ void COperationDialog::processInstallNextStep()
|
|||
// long operations are done in a thread
|
||||
OperationStep step = config->getInstallNextStep();
|
||||
|
||||
if (step == m_operationStep)
|
||||
{
|
||||
++m_operationStepCounter;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_operationStep = step;
|
||||
m_operationStepCounter = 0;
|
||||
}
|
||||
|
||||
if (m_operationStepCounter > 10)
|
||||
{
|
||||
qDebug() << "possible infinite loop" << m_operationStep << m_operationStepCounter;
|
||||
}
|
||||
|
||||
switch(step)
|
||||
{
|
||||
case DownloadData:
|
||||
|
@ -770,7 +786,7 @@ void COperationDialog::copyInstaller()
|
|||
|
||||
// create installer link in menu
|
||||
QString executable = newInstallerFullPath;
|
||||
QString shortcut = config->getInstallerMenuLinkFullPath();
|
||||
QString shortcut = config->getInstallerMenuShortcutFullPath();
|
||||
QString name = "Ryzom Installer";
|
||||
QString icon;
|
||||
|
||||
|
@ -782,7 +798,7 @@ void COperationDialog::copyInstaller()
|
|||
icon = config->getInstallationDirectory() + "/ryzom_installer.png";
|
||||
#endif
|
||||
|
||||
createLink(shortcut, name, executable, "", icon, "");
|
||||
createShortcut(shortcut, name, executable, "", icon, "");
|
||||
}
|
||||
|
||||
emit done();
|
||||
|
@ -1179,6 +1195,10 @@ void COperationDialog::deleteComponentsInstaller()
|
|||
}
|
||||
}
|
||||
|
||||
// delete installer shortcuts
|
||||
removeShortcut(config->getInstallerMenuShortcutFullPath());
|
||||
removeShortcut(config->getInstallerDesktopShortcutFullPath());
|
||||
|
||||
// delete configuration file
|
||||
config->remove();
|
||||
|
||||
|
|
|
@ -147,6 +147,8 @@ protected:
|
|||
bool m_aborting;
|
||||
|
||||
OperationType m_operation;
|
||||
OperationStep m_operationStep;
|
||||
int m_operationStepCounter;
|
||||
SComponents m_addComponents;
|
||||
SComponents m_removeComponents;
|
||||
QString m_currentServerId;
|
||||
|
|
|
@ -100,7 +100,7 @@ void CProfile::createShortcuts() const
|
|||
QString shortcut = getClientDesktopShortcutFullPath();
|
||||
|
||||
// create desktop shortcut
|
||||
createLink(shortcut, name, exe, profileArguments, icon, workingDir);
|
||||
createShortcut(shortcut, name, exe, profileArguments, icon, workingDir);
|
||||
}
|
||||
|
||||
if (menuShortcut)
|
||||
|
@ -108,21 +108,17 @@ void CProfile::createShortcuts() const
|
|||
QString shortcut = getClientMenuShortcutFullPath();
|
||||
|
||||
// create menu shortcut
|
||||
createLink(shortcut, name, exe, profileArguments, icon, workingDir);
|
||||
createShortcut(shortcut, name, exe, profileArguments, icon, workingDir);
|
||||
}
|
||||
}
|
||||
|
||||
void CProfile::deleteShortcuts() const
|
||||
{
|
||||
// delete desktop shortcut
|
||||
QString link = getClientDesktopShortcutFullPath();
|
||||
|
||||
if (QFile::exists(link)) QFile::remove(link);
|
||||
removeShortcut(getClientDesktopShortcutFullPath());
|
||||
|
||||
// delete menu shortcut
|
||||
link = getClientMenuShortcutFullPath();
|
||||
|
||||
if (QFile::exists(link)) QFile::remove(link);
|
||||
removeShortcut(getClientMenuShortcutFullPath());
|
||||
}
|
||||
|
||||
void CProfile::updateShortcuts() const
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include "stdpch.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include "nel/misc/path.h"
|
||||
|
||||
#ifdef DEBUG_NEW
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
@ -130,9 +132,14 @@ wchar_t* qToWide(const QString &str)
|
|||
return (wchar_t*)str.utf16();
|
||||
}
|
||||
|
||||
bool shortcutExists(const QString &shortcut)
|
||||
{
|
||||
return !shortcut.isEmpty() && NLMISC::CFile::isExists(qToUtf8(appendShortcutExtension(shortcut)));
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
|
||||
bool createLink(const QString &link, const QString &name, const QString &executable, const QString &arguments, const QString &icon, const QString &workingDir)
|
||||
bool createShortcut(const QString &shortcut, const QString &name, const QString &executable, const QString &arguments, const QString &icon, const QString &workingDir)
|
||||
{
|
||||
CCOMHelper comHelper;
|
||||
|
||||
|
@ -141,9 +148,10 @@ bool createLink(const QString &link, const QString &name, const QString &executa
|
|||
// 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_IShellLinkW, (LPVOID*)&psl);
|
||||
|
||||
if (SUCCEEDED(hres))
|
||||
{
|
||||
IPersistFile* ppf;
|
||||
IPersistFile* ppf = NULL;
|
||||
|
||||
// Set the path to the shortcut target and add the description.
|
||||
psl->SetPath(qToWide(QDir::toNativeSeparators(executable)));
|
||||
|
@ -157,18 +165,20 @@ bool createLink(const QString &link, const QString &name, const QString &executa
|
|||
|
||||
if (SUCCEEDED(hres))
|
||||
{
|
||||
QString path(link + ".lnk");
|
||||
QString path(shortcut + ".lnk");
|
||||
|
||||
// Save the link by calling IPersistFile::Save.
|
||||
hres = ppf->Save(qToWide(QDir::toNativeSeparators(path)), TRUE);
|
||||
ppf->Release();
|
||||
}
|
||||
|
||||
psl->Release();
|
||||
}
|
||||
|
||||
return SUCCEEDED(hres);
|
||||
}
|
||||
|
||||
bool resolveLink(const QWidget &window, const QString &linkFile, QString &path)
|
||||
bool resolveShortcut(const QWidget &window, const QString &shortcut, QString &path)
|
||||
{
|
||||
CCOMHelper comHelper;
|
||||
|
||||
|
@ -193,7 +203,7 @@ bool resolveLink(const QWidget &window, const QString &linkFile, QString &path)
|
|||
// for success.
|
||||
|
||||
// Load the shortcut.
|
||||
hres = ppf->Load(qToWide(QDir::toNativeSeparators(linkFile)), STGM_READ);
|
||||
hres = ppf->Load(qToWide(QDir::toNativeSeparators(shortcut)), STGM_READ);
|
||||
|
||||
if (SUCCEEDED(hres))
|
||||
{
|
||||
|
@ -239,7 +249,7 @@ bool resolveLink(const QWidget &window, const QString &linkFile, QString &path)
|
|||
|
||||
#else
|
||||
|
||||
bool createLink(const QString &link, const QString &name, const QString &executable, const QString &arguments, const QString &icon, const QString &workingDir)
|
||||
bool createShortcut(const QString &shortcut, const QString &name, const QString &executable, const QString &arguments, const QString &icon, const QString &workingDir)
|
||||
{
|
||||
// open template
|
||||
QFile file(":/templates/template.desktop");
|
||||
|
@ -259,7 +269,7 @@ bool createLink(const QString &link, const QString &name, const QString &executa
|
|||
data.replace("$COMMAND", command);
|
||||
data.replace("$ICON", icon);
|
||||
|
||||
QString path(link + ".desktop");
|
||||
QString path(shortcut + ".desktop");
|
||||
|
||||
// write file
|
||||
file.setFileName(path);
|
||||
|
@ -275,14 +285,29 @@ bool createLink(const QString &link, const QString &name, const QString &executa
|
|||
return true;
|
||||
}
|
||||
|
||||
bool resolveLink(const QWidget &window, const QString &pathLink, QString &pathObj)
|
||||
bool resolveShortcut(const QWidget &window, const QString &pathLink, QString &pathObj)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
QString appendLinkExtension(const QString &link)
|
||||
bool removeShortcut(const QString &shortcut)
|
||||
{
|
||||
// empty links are invalid
|
||||
if (shortcut.isEmpty()) return false;
|
||||
|
||||
// append extension if missing
|
||||
QString fullPath = appendShortcutExtension(shortcut);
|
||||
|
||||
// link doesn't exist
|
||||
if (!NLMISC::CFile::isExists(qToUtf8(fullPath))) return false;
|
||||
|
||||
// remove it
|
||||
return QFile::remove(fullPath);
|
||||
}
|
||||
|
||||
QString appendShortcutExtension(const QString &shortcut)
|
||||
{
|
||||
QString extension;
|
||||
|
||||
|
@ -295,9 +320,9 @@ QString appendLinkExtension(const QString &link)
|
|||
#endif
|
||||
|
||||
// already the good extension
|
||||
if (link.indexOf(extension) > -1) return link;
|
||||
if (shortcut.indexOf(extension) > -1) return shortcut;
|
||||
|
||||
return link + extension;
|
||||
return shortcut + extension;
|
||||
}
|
||||
|
||||
QString getVersionFromExecutable(const QString &path)
|
||||
|
|
|
@ -50,9 +50,11 @@ QString qFromWide(const wchar_t *str);
|
|||
|
||||
wchar_t* qToWide(const QString &str);
|
||||
|
||||
bool createLink(const QString &link, const QString &name, const QString &executable, const QString &arguments, const QString &icon, const QString &workingDir);
|
||||
bool resolveLink(const QWidget &window, const QString &pathLink, QString &pathObj);
|
||||
QString appendLinkExtension(const QString &link);
|
||||
bool shortcutExists(const QString &shortcut);
|
||||
bool createShortcut(const QString &shortcut, const QString &name, const QString &executable, const QString &arguments, const QString &icon, const QString &workingDir);
|
||||
bool removeShortcut(const QString &shortcut);
|
||||
bool resolveShortcut(const QWidget &window, const QString &shortcut, QString &pathObj);
|
||||
QString appendShortcutExtension(const QString &shortcut);
|
||||
|
||||
QString getVersionFromExecutable(const QString &path);
|
||||
|
||||
|
|
|
@ -104,22 +104,22 @@
|
|||
<message>
|
||||
<location filename="../src/installdialog.cpp" line="185"/>
|
||||
<source>Unable to write in directory</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Невозможно осуществить запись в директорию</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/installdialog.cpp" line="185"/>
|
||||
<source>You don't have the permission to write in this directory with your current user account, please choose another directory.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>У вашего текущего пользоввателя нет права записи в эту директорию, пожалуйста, выберите другую директорию.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/installdialog.cpp" line="191"/>
|
||||
<source>Directory not empty</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Директория не является пустой</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/installdialog.cpp" line="191"/>
|
||||
<source>This directory is not empty, please choose another one.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Эта директория не является пустой, пожалуйста, выберите другую.</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -175,22 +175,22 @@
|
|||
<message>
|
||||
<location filename="../src/migratedialog.cpp" line="154"/>
|
||||
<source>Unable to write in directory</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Невозможно осуществить запись в директорию</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/migratedialog.cpp" line="154"/>
|
||||
<source>You don't have the permission to write in this directory with your current user account, please choose another directory.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>У вашего текущего пользоввателя нет права записи в эту директорию, пожалуйста, выберите другую директорию.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/migratedialog.cpp" line="160"/>
|
||||
<source>Directory not empty</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Директория не является пустой</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/migratedialog.cpp" line="160"/>
|
||||
<source>This directory is not empty, please choose another one.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Эта директория не является пустой, пожалуйста, выберите другую.</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
|
Loading…
Reference in a new issue