mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2025-03-25 23:37:58 +00:00
NOISSUE shortcut creation: set working directory in other shortcut types
This commit is contained in:
parent
7217e3991a
commit
75b8765604
@ -125,7 +125,9 @@ void CreateShortcutDialog::createShortcut()
|
|||||||
// Unix shell script
|
// Unix shell script
|
||||||
if (ui->createScriptCheckBox->isChecked())
|
if (ui->createScriptCheckBox->isChecked())
|
||||||
{
|
{
|
||||||
shortcutText = "#!/bin/sh\n" + getLaunchCommand() + " &\n";
|
shortcutText = "#!/bin/sh\n"
|
||||||
|
+ "cd " + QCoreApplication::applicationDirPath() + "\n"
|
||||||
|
+ getLaunchCommand() + " &\n";
|
||||||
} else
|
} else
|
||||||
// freedesktop.org desktop entry
|
// freedesktop.org desktop entry
|
||||||
{
|
{
|
||||||
@ -148,6 +150,7 @@ void CreateShortcutDialog::createShortcut()
|
|||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
// Windows batch script implementation
|
// Windows batch script implementation
|
||||||
shortcutText = "@ECHO OFF\r\n"
|
shortcutText = "@ECHO OFF\r\n"
|
||||||
|
"CD " + QDir::toNativeSeparators(QCoreApplication::applicationDirPath()) + "\r\n"
|
||||||
"START /B " + getLaunchCommand() + "\r\n";
|
"START /B " + getLaunchCommand() + "\r\n";
|
||||||
#endif
|
#endif
|
||||||
QFile shortcutFile(ui->shortcutPath->text());
|
QFile shortcutFile(ui->shortcutPath->text());
|
||||||
@ -170,6 +173,7 @@ void CreateShortcutDialog::createShortcut()
|
|||||||
}
|
}
|
||||||
|
|
||||||
createWindowsLink(QDir::toNativeSeparators(QCoreApplication::applicationFilePath()).toStdString().c_str(),
|
createWindowsLink(QDir::toNativeSeparators(QCoreApplication::applicationFilePath()).toStdString().c_str(),
|
||||||
|
QDir::toNativeSeparators(QCoreApplication::applicationFilePath()).toStdString().c_str(),
|
||||||
getLaunchArgs().toStdString().c_str(),
|
getLaunchArgs().toStdString().c_str(),
|
||||||
ui->shortcutPath->text().toStdString().c_str(),
|
ui->shortcutPath->text().toStdString().c_str(),
|
||||||
(m_instance->name() + " - " + BuildConfig.LAUNCHER_DISPLAYNAME).toStdString().c_str(),
|
(m_instance->name() + " - " + BuildConfig.LAUNCHER_DISPLAYNAME).toStdString().c_str(),
|
||||||
@ -180,7 +184,8 @@ void CreateShortcutDialog::createShortcut()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
void CreateShortcutDialog::createWindowsLink(LPCSTR target, LPCSTR args, LPCSTR filename, LPCSTR desc, LPCSTR iconPath)
|
void CreateShortcutDialog::createWindowsLink(LPCSTR target, LPCSTR workingDir, LPCSTR args, LPCSTR filename,
|
||||||
|
LPCSTR desc, LPCSTR iconPath)
|
||||||
{
|
{
|
||||||
HRESULT result;
|
HRESULT result;
|
||||||
IShellLink *link;
|
IShellLink *link;
|
||||||
@ -192,6 +197,7 @@ void CreateShortcutDialog::createWindowsLink(LPCSTR target, LPCSTR args, LPCSTR
|
|||||||
IPersistFile *file;
|
IPersistFile *file;
|
||||||
|
|
||||||
link->SetPath(target);
|
link->SetPath(target);
|
||||||
|
link->SetWorkingDirectory(workingDir);
|
||||||
link->SetArguments(args);
|
link->SetArguments(args);
|
||||||
link->SetDescription(desc);
|
link->SetDescription(desc);
|
||||||
link->SetIconLocation(iconPath, 0);
|
link->SetIconLocation(iconPath, 0);
|
||||||
|
@ -44,6 +44,6 @@ private:
|
|||||||
void createShortcut();
|
void createShortcut();
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
void createWindowsLink(LPCSTR target, LPCSTR args, LPCSTR filename, LPCSTR desc, LPCSTR iconPath);
|
void createWindowsLink(LPCSTR target, LPCSTR workingDir, LPCSTR args, LPCSTR filename, LPCSTR desc, LPCSTR iconPath);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
Loading…
x
Reference in New Issue
Block a user