refactor #if checks
Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com>
This commit is contained in:
parent
f7d7d76ee8
commit
b813c867b5
@ -395,7 +395,7 @@ bool createShortcut(QString destination, QString target, QStringList args, QStri
|
|||||||
f.setPermissions(f.permissions() | QFileDevice::ExeOwner | QFileDevice::ExeGroup | QFileDevice::ExeOther);
|
f.setPermissions(f.permissions() | QFileDevice::ExeOwner | QFileDevice::ExeGroup | QFileDevice::ExeOther);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
#elif defined Q_OS_WIN
|
#elif defined(Q_OS_WIN)
|
||||||
QFileInfo targetInfo(target);
|
QFileInfo targetInfo(target);
|
||||||
|
|
||||||
if (!targetInfo.exists())
|
if (!targetInfo.exists())
|
||||||
|
@ -2099,13 +2099,13 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_MACOS
|
#if defined(Q_OS_MACOS)
|
||||||
// handle macOS bundle weirdness
|
// handle macOS bundle weirdness
|
||||||
QFileInfo appFileInfo(QApplication::applicationFilePath()));
|
QFileInfo appFileInfo(QApplication::applicationFilePath()));
|
||||||
QString appName = appFileInfo.baseName();
|
QString appName = appFileInfo.baseName();
|
||||||
QString exeName = FS::PathCombine(appFileInfo.filePath(), "Contents/MacOS/" + appName);
|
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(), "")) {
|
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!"));
|
QMessageBox::information(this, tr("Create instance shortcut"), tr("Created a shortcut to this instance on your desktop!"));
|
||||||
}
|
}
|
||||||
@ -2113,16 +2113,21 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered()
|
|||||||
{
|
{
|
||||||
QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!"));
|
QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!"));
|
||||||
}
|
}
|
||||||
|
#elif defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
auto icon = APPLICATION->icons()->icon(m_selectedInstance->iconKey());
|
auto icon = APPLICATION->icons()->icon(m_selectedInstance->iconKey());
|
||||||
|
|
||||||
QString iconPath;
|
if (FS::createShortcut(FS::PathCombine(desktopPath, m_selectedInstance->name()),
|
||||||
bool iconGenerated = false;
|
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());
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
QString iconPath = FS::PathCombine(m_selectedInstance->instanceRoot(), "icon.ico");
|
||||||
iconPath = FS::PathCombine(m_selectedInstance->instanceRoot(), "icon.ico");
|
|
||||||
|
|
||||||
// part of fix for weird bug involving the window icon being replaced
|
// 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
|
// dunno why it happens, but this 2-line fix seems to be enough, so w/e
|
||||||
@ -2140,31 +2145,24 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered()
|
|||||||
// restore original window icon
|
// restore original window icon
|
||||||
QGuiApplication::setWindowIcon(appIcon);
|
QGuiApplication::setWindowIcon(appIcon);
|
||||||
|
|
||||||
if (success)
|
if (!success)
|
||||||
{
|
|
||||||
iconGenerated = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
iconFile.remove();
|
iconFile.remove();
|
||||||
QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!"));
|
QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
iconPath = icon->getFilePath();
|
|
||||||
#endif
|
|
||||||
if (FS::createShortcut(FS::PathCombine(desktopPath, m_selectedInstance->name()),
|
if (FS::createShortcut(FS::PathCombine(desktopPath, m_selectedInstance->name()),
|
||||||
QApplication::applicationFilePath(), { "--launch", m_selectedInstance->id() }, m_selectedInstance->name(), iconPath)) {
|
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!"));
|
QMessageBox::information(this, tr("Create instance shortcut"), tr("Created a shortcut to this instance on your desktop!"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (iconGenerated)
|
|
||||||
{
|
|
||||||
QFile::remove(iconPath);
|
|
||||||
}
|
|
||||||
QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!"));
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user