Mac: now supported! [UNTESTED]
Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com>
This commit is contained in:
parent
7e5076b068
commit
f7d7d76ee8
@ -342,7 +342,31 @@ QString getDesktopDir()
|
|||||||
// Cross-platform Shortcut creation
|
// Cross-platform Shortcut creation
|
||||||
bool createShortcut(QString destination, QString target, QStringList args, QString name, QString icon)
|
bool createShortcut(QString destination, QString target, QStringList args, QString name, QString icon)
|
||||||
{
|
{
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
|
#if defined(Q_OS_MACOS)
|
||||||
|
destination += ".sh";
|
||||||
|
|
||||||
|
QFile f(destination);
|
||||||
|
f.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||||
|
QTextStream stream(&f);
|
||||||
|
|
||||||
|
QString argstring;
|
||||||
|
if (!args.empty())
|
||||||
|
argstring = " \"" + args.join("\" \"") + "\"";
|
||||||
|
|
||||||
|
stream << "#!/bin/bash"
|
||||||
|
<< "\n";
|
||||||
|
stream << target
|
||||||
|
<< " "
|
||||||
|
<< argstring
|
||||||
|
<< "\n";
|
||||||
|
|
||||||
|
stream.flush();
|
||||||
|
f.close();
|
||||||
|
|
||||||
|
f.setPermissions(f.permissions() | QFileDevice::ExeOwner | QFileDevice::ExeGroup | QFileDevice::ExeOther);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
#elif defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
|
||||||
destination += ".desktop";
|
destination += ".desktop";
|
||||||
|
|
||||||
QFile f(destination);
|
QFile f(destination);
|
||||||
|
@ -2100,7 +2100,20 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
QMessageBox::critical(this, tr("Create instance shortcut"), tr("Not supported on macOS yet!"));
|
// handle macOS bundle weirdness
|
||||||
|
QFileInfo appFileInfo(QApplication::applicationFilePath()));
|
||||||
|
QString appName = appFileInfo.baseName();
|
||||||
|
QString exeName = FS::PathCombine(appFileInfo.filePath(), "Contents/MacOS/" + appName);
|
||||||
|
|
||||||
|
if (FS::createShortcut(FS::PathCombine(desktopPath, m_selectedInstance->name()),
|
||||||
|
exeName, { "--launch", m_selectedInstance->id() }, m_selectedInstance->name(), "")) {
|
||||||
|
QMessageBox::information(this, tr("Create instance shortcut"), tr("Created a shortcut to this instance on your desktop!"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!"));
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
auto icon = APPLICATION->icons()->icon(m_selectedInstance->iconKey());
|
auto icon = APPLICATION->icons()->icon(m_selectedInstance->iconKey());
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit cc741c9f5f2a62856a2a2e9e275f61eb0591c09c
|
Subproject commit 4b166b69f28e70a416a1a04a98f365d2aeb90de8
|
Loading…
Reference in New Issue
Block a user