mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-05-25 19:32:16 +02:00
add macos support for shortcuts
Signed-off-by: sshcrack <34072808+sshcrack@users.noreply.github.com>
This commit is contained in:
parent
7c60f375f3
commit
8bb35f5b0b
@ -931,16 +931,7 @@ bool createShortcut(QString destination, QString target, QStringList args, QStri
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#if defined(Q_OS_MACOS)
|
#if defined(Q_OS_MACOS)
|
||||||
// Create the Application
|
QDir application = destination + ".app/";
|
||||||
QDir applicationDirectory =
|
|
||||||
QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation) + "/" + BuildConfig.LAUNCHER_NAME + " Instances/";
|
|
||||||
|
|
||||||
if (!applicationDirectory.mkpath(".")) {
|
|
||||||
qWarning() << "Couldn't create application directory";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDir application = applicationDirectory.path() + "/" + name + ".app/";
|
|
||||||
|
|
||||||
if (application.exists()) {
|
if (application.exists()) {
|
||||||
qWarning() << "Application already exists!";
|
qWarning() << "Application already exists!";
|
||||||
|
@ -1658,6 +1658,8 @@ void MainWindow::on_actionCreateInstanceShortcutOther_triggered()
|
|||||||
if (shortcutFilePath.isEmpty())
|
if (shortcutFilePath.isEmpty())
|
||||||
return; // file dialog canceled by user
|
return; // file dialog canceled by user
|
||||||
|
|
||||||
|
if(shortcutFilePath.endsWith(extension))
|
||||||
|
shortcutFilePath = shortcutFilePath.mid(0, shortcutFilePath.length() - extension.length());
|
||||||
createInstanceShortcut(shortcutFilePath);
|
createInstanceShortcut(shortcutFilePath);
|
||||||
QMessageBox::information(this, tr("Create instance shortcut"), tr("Created a shortcut to this instance!"));
|
QMessageBox::information(this, tr("Create instance shortcut"), tr("Created a shortcut to this instance!"));
|
||||||
}
|
}
|
||||||
@ -1700,6 +1702,16 @@ void MainWindow::on_actionCreateInstanceShortcutApplications_triggered()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
|
||||||
|
applicationsDir = FS::PathCombine(applicationsDir, BuildConfig.LAUNCHER_DISPLAYNAME + " Instances");
|
||||||
|
|
||||||
|
QDir applicationsDirQ(applicationsDir);
|
||||||
|
if (!applicationsDirQ.mkpath(".")) {
|
||||||
|
QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instances folder in applications folder!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
QString shortcutFilePath = FS::PathCombine(applicationsDir, FS::RemoveInvalidFilenameChars(m_selectedInstance->name()));
|
QString shortcutFilePath = FS::PathCombine(applicationsDir, FS::RemoveInvalidFilenameChars(m_selectedInstance->name()));
|
||||||
createInstanceShortcut(shortcutFilePath);
|
createInstanceShortcut(shortcutFilePath);
|
||||||
QMessageBox::information(this, tr("Create instance shortcut"), tr("Created a shortcut to this instance in your applications folder!"));
|
QMessageBox::information(this, tr("Create instance shortcut"), tr("Created a shortcut to this instance in your applications folder!"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user