mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-26 09:06:19 +00:00
Changed: Create .desktop file under Linux, see #279
--HG-- branch : develop
This commit is contained in:
parent
0f772c8605
commit
b5512d8311
4 changed files with 46 additions and 39 deletions
|
@ -5,4 +5,7 @@
|
|||
<qresource prefix="/icons">
|
||||
<file>ryzom.ico</file>
|
||||
</qresource>
|
||||
<qresource prefix="/templates">
|
||||
<file>template.desktop</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
10
code/ryzom/tools/client/ryzom_installer/res/template.desktop
Normal file
10
code/ryzom/tools/client/ryzom_installer/res/template.desktop
Normal file
|
@ -0,0 +1,10 @@
|
|||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Name=$NAME
|
||||
Type=Application
|
||||
GenericName=MMORPG
|
||||
Exec=$COMMAND
|
||||
Icon=$ICON
|
||||
Terminal=false
|
||||
Hidden=false
|
||||
Categories=Game;RolePlaying;
|
|
@ -97,21 +97,7 @@ wchar_t* qToWide(const QString &str)
|
|||
|
||||
#ifdef Q_OS_WIN32
|
||||
|
||||
// CreateLink - Uses the Shell's IShellLink and IPersistFile interfaces
|
||||
// to create and store a shortcut to the specified object.
|
||||
//
|
||||
// Returns the result of calling the member functions of the interfaces.
|
||||
//
|
||||
// Parameters:
|
||||
// lpszPathObj - Address of a buffer that contains the path of the object,
|
||||
// including the file name.
|
||||
// lpszPathLink - Address of a buffer that contains the path where the
|
||||
// Shell link is to be stored, including the file name.
|
||||
// lpszDesc - Address of a buffer that contains a description of the
|
||||
// Shell link, stored in the Comment field of the link
|
||||
// properties.
|
||||
|
||||
bool createLink(const QString &pathObj, const QString &pathLink, const QString &arguments, const QString &workingDir, const QString &desc)
|
||||
bool createLink(const QString &link, const QString &name, const QString &executable, const QString &arguments, const QString &icon, const QString &workingDir)
|
||||
{
|
||||
IShellLinkW* psl;
|
||||
|
||||
|
@ -123,8 +109,9 @@ bool createLink(const QString &pathObj, const QString &pathLink, const QString &
|
|||
IPersistFile* ppf;
|
||||
|
||||
// Set the path to the shortcut target and add the description.
|
||||
psl->SetPath(qToWide(QDir::toNativeSeparators(pathObj)));
|
||||
psl->SetDescription(qToWide(desc));
|
||||
psl->SetPath(qToWide(QDir::toNativeSeparators(executable)));
|
||||
psl->SetIconLocation(qToWide(QDir::toNativeSeparators(icon)), 0);
|
||||
psl->SetDescription(qToWide(name));
|
||||
psl->SetArguments(qToWide(arguments));
|
||||
psl->SetWorkingDirectory(qToWide(QDir::toNativeSeparators(workingDir)));
|
||||
|
||||
|
@ -138,7 +125,7 @@ bool createLink(const QString &pathObj, const QString &pathLink, const QString &
|
|||
// for success.
|
||||
|
||||
// Save the link by calling IPersistFile::Save.
|
||||
hres = ppf->Save(qToWide(QDir::toNativeSeparators(pathLink)), TRUE);
|
||||
hres = ppf->Save(qToWide(QDir::toNativeSeparators(link)), TRUE);
|
||||
ppf->Release();
|
||||
}
|
||||
psl->Release();
|
||||
|
@ -146,23 +133,6 @@ bool createLink(const QString &pathObj, const QString &pathLink, const QString &
|
|||
return SUCCEEDED(hres);
|
||||
}
|
||||
|
||||
// ResolveIt - Uses the Shell's IShellLink and IPersistFile interfaces
|
||||
// to retrieve the path and description from an existing shortcut.
|
||||
//
|
||||
// Returns the result of calling the member functions of the interfaces.
|
||||
//
|
||||
// Parameters:
|
||||
// hwnd - A handle to the parent window. The Shell uses this window to
|
||||
// display a dialog box if it needs to prompt the user for more
|
||||
// information while resolving the link.
|
||||
// lpszLinkFile - Address of a buffer that contains the path of the link,
|
||||
// including the file name.
|
||||
// lpszPath - Address of a buffer that receives the path of the link
|
||||
// target, including the file name.
|
||||
// lpszDesc - Address of a buffer that receives the description of the
|
||||
// Shell link, stored in the Comment field of the link
|
||||
// properties.
|
||||
|
||||
bool resolveLink(const QWidget &window, const QString &linkFile, QString &path)
|
||||
{
|
||||
IShellLinkW* psl;
|
||||
|
@ -232,11 +202,35 @@ bool resolveLink(const QWidget &window, const QString &linkFile, QString &path)
|
|||
|
||||
#else
|
||||
|
||||
bool createLink(const QString &pathObj, const QString &pathLink, const QString &arguments, const QString &workingDir, const QString &desc)
|
||||
bool createLink(const QString &link, const QString &name, const QString &executable, const QString &arguments, const QString &icon, const QString &workingDir)
|
||||
{
|
||||
// TODO: create .desktop file under Linux
|
||||
// open template
|
||||
QFile file(":/templates/template.desktop");
|
||||
|
||||
return false;
|
||||
if (!file.open(QFile::ReadOnly)) return false;
|
||||
|
||||
QString data = QString::fromUtf8(file.readAll());
|
||||
|
||||
file.close();
|
||||
|
||||
// build command
|
||||
QString command = executable;
|
||||
if (!arguments.isEmpty()) command += " " + arguments;
|
||||
|
||||
// replace strings
|
||||
data.replace("$NAME", name);
|
||||
data.replace("$COMMAND", command);
|
||||
data.replace("$ICON", icon);
|
||||
|
||||
// write file
|
||||
file.setFileName(link);
|
||||
|
||||
if (!file.open(QFile::WriteOnly)) return false;
|
||||
|
||||
file.write(data.toUtf8());
|
||||
file.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool resolveLink(const QWidget &window, const QString &pathLink, QString &pathObj)
|
||||
|
|
|
@ -48,7 +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 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);
|
||||
|
||||
bool copyInstallerExecutable(const QString &destination);
|
||||
|
|
Loading…
Reference in a new issue