summaryrefslogtreecommitdiffstats
path: root/depends/util/src/userutils.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-11-04 02:53:05 +0100
committerPetr Mrázek <peterix@gmail.com>2013-11-04 02:53:05 +0100
commitbb7e8985f6d189de0acac6a1c3033cb16378c1fb (patch)
tree7c2e88c7184a7f5acf5e7a03be5c5f0bf6904113 /depends/util/src/userutils.cpp
parentd6e4fb29713d6ce55b092c0e22412f6121e7f516 (diff)
downloadMultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.tar
MultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.tar.gz
MultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.tar.lz
MultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.tar.xz
MultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.zip
Reformat and (slightly) decruft all the things.
Diffstat (limited to 'depends/util/src/userutils.cpp')
-rw-r--r--depends/util/src/userutils.cpp82
1 files changed, 43 insertions, 39 deletions
diff --git a/depends/util/src/userutils.cpp b/depends/util/src/userutils.cpp
index b70841ed..060a58e9 100644
--- a/depends/util/src/userutils.cpp
+++ b/depends/util/src/userutils.cpp
@@ -23,37 +23,37 @@ bool called_coinit = false;
HRESULT CreateLink(LPCSTR linkPath, LPCSTR targetPath, LPCSTR args)
{
HRESULT hres;
-
+
if (!called_coinit)
{
hres = CoInitialize(NULL);
called_coinit = true;
-
+
if (!SUCCEEDED(hres))
{
qWarning("Failed to initialize COM. Error 0x%08X", hres);
return hres;
}
}
-
-
- IShellLink* link;
- hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&link);
-
+
+ IShellLink *link;
+ hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink,
+ (LPVOID *)&link);
+
if (SUCCEEDED(hres))
{
- IPersistFile* persistFile;
-
+ IPersistFile *persistFile;
+
link->SetPath(targetPath);
link->SetArguments(args);
-
- hres = link->QueryInterface(IID_IPersistFile, (LPVOID*)&persistFile);
+
+ hres = link->QueryInterface(IID_IPersistFile, (LPVOID *)&persistFile);
if (SUCCEEDED(hres))
{
WCHAR wstr[MAX_PATH];
-
+
MultiByteToWideChar(CP_ACP, 0, linkPath, -1, wstr, MAX_PATH);
-
+
hres = persistFile->Save(wstr, TRUE);
persistFile->Release();
}
@@ -70,51 +70,55 @@ QString Util::getDesktopDir()
}
// Cross-platform Shortcut creation
-bool Util::createShortCut(QString location, QString dest, QStringList args, QString name, QString icon)
+bool Util::createShortCut(QString location, QString dest, QStringList args, QString name,
+ QString icon)
{
#if LINUX
location = PathCombine(location, name + ".desktop");
qDebug("location: %s", qPrintable(location));
-
+
QFile f(location);
f.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream stream(&f);
-
+
QString argstring;
if (!args.empty())
argstring = " '" + args.join("' '") + "'";
-
- stream << "[Desktop Entry]" << "\n";
- stream << "Type=Application" << "\n";
+
+ stream << "[Desktop Entry]"
+ << "\n";
+ stream << "Type=Application"
+ << "\n";
stream << "TryExec=" << dest.toLocal8Bit() << "\n";
stream << "Exec=" << dest.toLocal8Bit() << argstring.toLocal8Bit() << "\n";
stream << "Name=" << name.toLocal8Bit() << "\n";
stream << "Icon=" << icon.toLocal8Bit() << "\n";
-
+
stream.flush();
f.close();
-
- f.setPermissions(f.permissions() | QFileDevice::ExeOwner | QFileDevice::ExeGroup | QFileDevice::ExeOther);
-
+
+ f.setPermissions(f.permissions() | QFileDevice::ExeOwner | QFileDevice::ExeGroup |
+ QFileDevice::ExeOther);
+
return true;
#elif WINDOWS
// TODO: Fix
-// QFile file(PathCombine(location, name + ".lnk"));
-// WCHAR *file_w;
-// WCHAR *dest_w;
-// WCHAR *args_w;
-// file.fileName().toWCharArray(file_w);
-// dest.toWCharArray(dest_w);
-
-// QString argStr;
-// for (int i = 0; i < args.count(); i++)
-// {
-// argStr.append(args[i]);
-// argStr.append(" ");
-// }
-// argStr.toWCharArray(args_w);
-
-// return SUCCEEDED(CreateLink(file_w, dest_w, args_w));
+ // QFile file(PathCombine(location, name + ".lnk"));
+ // WCHAR *file_w;
+ // WCHAR *dest_w;
+ // WCHAR *args_w;
+ // file.fileName().toWCharArray(file_w);
+ // dest.toWCharArray(dest_w);
+
+ // QString argStr;
+ // for (int i = 0; i < args.count(); i++)
+ // {
+ // argStr.append(args[i]);
+ // argStr.append(" ");
+ // }
+ // argStr.toWCharArray(args_w);
+
+ // return SUCCEEDED(CreateLink(file_w, dest_w, args_w));
return false;
#else
qWarning("Desktop Shortcuts not supported on your platform!");