aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/MainWindow.cpp
diff options
context:
space:
mode:
authorADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com>2022-11-12 20:41:52 +0200
committerADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com>2022-11-12 20:41:52 +0200
commitb813c867b505f0c1ec8125fde9916d6252cd4485 (patch)
treeee123af14b0701458f7899b4e802d25b359e34fe /launcher/ui/MainWindow.cpp
parentf7d7d76ee879c3bdd539e5c8c956cbd2c7328bf0 (diff)
downloadPrismLauncher-b813c867b505f0c1ec8125fde9916d6252cd4485.tar.gz
PrismLauncher-b813c867b505f0c1ec8125fde9916d6252cd4485.tar.bz2
PrismLauncher-b813c867b505f0c1ec8125fde9916d6252cd4485.zip
refactor #if checks
Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com>
Diffstat (limited to 'launcher/ui/MainWindow.cpp')
-rw-r--r--launcher/ui/MainWindow.cpp46
1 files changed, 22 insertions, 24 deletions
diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp
index 02f60233..8e8a7c56 100644
--- a/launcher/ui/MainWindow.cpp
+++ b/launcher/ui/MainWindow.cpp
@@ -2099,13 +2099,13 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered()
return;
}
-#ifdef Q_OS_MACOS
+#if defined(Q_OS_MACOS)
// 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()),
+ 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!"));
}
@@ -2113,17 +2113,22 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered()
{
QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!"));
}
-
- return;
-#endif
+#elif defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
auto icon = APPLICATION->icons()->icon(m_selectedInstance->iconKey());
-
- QString iconPath;
- bool iconGenerated = false;
-
-#ifdef Q_OS_WIN
- iconPath = FS::PathCombine(m_selectedInstance->instanceRoot(), "icon.ico");
-
+
+ if (FS::createShortcut(FS::PathCombine(desktopPath, m_selectedInstance->name()),
+ QApplication::applicationFilePath(), { "--launch", m_selectedInstance->id() }, m_selectedInstance->name(), icon->getFilePath())) {
+ 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!"));
+ }
+#elif defined(Q_OS_WIN)
+ auto icon = APPLICATION->icons()->icon(m_selectedInstance->iconKey());
+
+ QString iconPath = FS::PathCombine(m_selectedInstance->instanceRoot(), "icon.ico");
+
// part of fix for weird bug involving the window icon being replaced
// dunno why it happens, but this 2-line fix seems to be enough, so w/e
auto appIcon = APPLICATION->getThemedIcon("logo");
@@ -2140,31 +2145,24 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered()
// restore original window icon
QGuiApplication::setWindowIcon(appIcon);
- if (success)
- {
- iconGenerated = true;
- }
- else
+ if (!success)
{
iconFile.remove();
QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!"));
return;
}
-#else
- iconPath = icon->getFilePath();
-#endif
+
if (FS::createShortcut(FS::PathCombine(desktopPath, m_selectedInstance->name()),
QApplication::applicationFilePath(), { "--launch", m_selectedInstance->id() }, m_selectedInstance->name(), iconPath)) {
QMessageBox::information(this, tr("Create instance shortcut"), tr("Created a shortcut to this instance on your desktop!"));
}
else
{
- if (iconGenerated)
- {
- QFile::remove(iconPath);
- }
QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!"));
}
+#else
+ QMessageBox::critical(this, tr("Create instance shortcut"), tr("Not supported on your platform!"));
+#endif
}
}