From 30b266622c9457a825d38ba084c9391437a2c87a Mon Sep 17 00:00:00 2001 From: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> Date: Sat, 22 Oct 2022 15:39:53 +0300 Subject: [PATCH 01/33] Add 'Create shortcut' button to instance toolbar Implemented on Windows only rn! Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> --- launcher/ui/MainWindow.cpp | 86 ++++++++++++++++++++++++++++++++++++++ launcher/ui/MainWindow.h | 2 + 2 files changed, 88 insertions(+) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 85b00b67..419bb9bd 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -237,6 +237,7 @@ public: TranslatedAction actionLaunchInstanceOffline; TranslatedAction actionLaunchInstanceDemo; TranslatedAction actionExportInstance; + TranslatedAction actionCreateInstanceShortcut; QVector all_actions; LabeledToolButton *renameButton = nullptr; @@ -597,6 +598,7 @@ public: actionExportInstance->setEnabled(enabled); actionDeleteInstance->setEnabled(enabled); actionCopyInstance->setEnabled(enabled); + actionCreateInstanceShortcut->setEnabled(enabled); } void createStatusBar(QMainWindow *MainWindow) @@ -735,6 +737,14 @@ public: actionCopyInstance->setIcon(APPLICATION->getThemedIcon("copy")); all_actions.append(&actionCopyInstance); + actionCreateInstanceShortcut = TranslatedAction(MainWindow); + actionCreateInstanceShortcut->setObjectName(QStringLiteral("actionCreateInstanceShortcut")); + actionCreateInstanceShortcut.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Create shortcut")); + actionCreateInstanceShortcut.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Creates a shortcut on your desktop to launch the selected instance.")); + actionCreateInstanceShortcut->setShortcut(QKeySequence(tr("Ctrl+D"))); + //actionCreateInstanceShortcut->setIcon(APPLICATION->getThemedIcon("copy")); // TODO + all_actions.append(&actionCreateInstanceShortcut); + setInstanceActionsEnabled(false); } @@ -783,6 +793,8 @@ public: } } + instanceToolBar->addAction(actionCreateInstanceShortcut); + all_toolbars.append(&instanceToolBar); MainWindow->addToolBar(Qt::RightToolBarArea, instanceToolBar); } @@ -2075,6 +2087,80 @@ void MainWindow::on_actionKillInstance_triggered() } } +#ifdef Q_OS_WIN +#define WIN32_LEAN_AND_MEAN +#include "windows.h" +#include "winnls.h" +#include "shobjidl.h" +#include "objbase.h" +#include "objidl.h" +#include "shlguid.h" +#endif + +void MainWindow::on_actionCreateInstanceShortcut_triggered() +{ + if (m_selectedInstance) + { + auto desktopDir = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); + if (desktopDir.isEmpty()) { + // TODO come up with an alternative solution (open "save file" dialog) + QMessageBox::critical(this, tr("Create instance shortcut"), tr("Couldn't find desktop!")); + return; + } + +#if defined(Q_OS_WIN) + // Windows + WCHAR wsz[MAX_PATH]; + + // ...yes, you need to initialize the entire COM stack to make a shortcut in Windows. + // I hate it. + CoInitialize(nullptr); + + HRESULT hres; + IShellLink* psl; + + hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl); + if (SUCCEEDED(hres)) + { + IPersistFile* ppf; + + QApplication::applicationFilePath().left(MAX_PATH - 1).toWCharArray(wsz); + psl->SetPath(wsz); + + wmemset(wsz, 0, MAX_PATH); + QStringLiteral("--launch %1").arg(m_selectedInstance->id()).left(MAX_PATH - 1).toWCharArray(wsz); + psl->SetArguments(wsz); + + // TODO set icon + + hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf); + + if (SUCCEEDED(hres)) + { + wmemset(wsz, 0, MAX_PATH); + + desktopDir + .append('/') + .append(QStringLiteral("%1.lnk").arg(m_selectedInstance->name())) + .left(MAX_PATH - 1).toWCharArray(wsz); + + hres = ppf->Save(wsz, TRUE); + ppf->Release(); + } + psl->Release(); + } + + CoUninitialize(); +#elif defined(Q_OS_LINUX) + // Linux +#elif defined(Q_OS_MACOS) + // macOSX + // TODO actually write this path + QMessageBox::critical(this, tr("Create instance shortcut"), tr("Not supported on macOSX yet!")); +#endif + } +} + void MainWindow::taskEnd() { QObject *sender = QObject::sender(); diff --git a/launcher/ui/MainWindow.h b/launcher/ui/MainWindow.h index f9d1f1c7..b23ba146 100644 --- a/launcher/ui/MainWindow.h +++ b/launcher/ui/MainWindow.h @@ -157,6 +157,8 @@ private slots: void on_actionEditInstance_triggered(); + void on_actionCreateInstanceShortcut_triggered(); + void taskEnd(); /** From 70768189bae0f4d5cfb24b57347cf7207dfc5496 Mon Sep 17 00:00:00 2001 From: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> Date: Sat, 22 Oct 2022 17:56:27 +0300 Subject: [PATCH 02/33] Windows: implement FS::createShortcut Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> --- launcher/FileSystem.cpp | 145 +++++++++++++++++++++++++++++++------ launcher/FileSystem.h | 5 ++ launcher/ui/MainWindow.cpp | 88 +++++++--------------- 3 files changed, 154 insertions(+), 84 deletions(-) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 4a8f4bd3..90f0313f 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -49,6 +49,7 @@ #include "StringUtils.h" #if defined Q_OS_WIN32 +#define WIN32_LEAN_AND_MEAN #include #include #include @@ -339,12 +340,12 @@ QString getDesktopDir() } // Cross-platform Shortcut creation -bool createShortCut(QString location, QString dest, 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) - location = PathCombine(location, name + ".desktop"); + destination = PathCombine(destination, name + ".desktop"); - QFile f(location); + QFile f(destination); f.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream stream(&f); @@ -356,10 +357,13 @@ bool createShortCut(QString location, QString dest, QStringList args, QString na << "\n"; stream << "Type=Application" << "\n"; - stream << "TryExec=" << dest.toLocal8Bit() << "\n"; - stream << "Exec=" << dest.toLocal8Bit() << argstring.toLocal8Bit() << "\n"; + stream << "TryExec=" << target.toLocal8Bit() << "\n"; + stream << "Exec=" << target.toLocal8Bit() << argstring.toLocal8Bit() << "\n"; stream << "Name=" << name.toLocal8Bit() << "\n"; - stream << "Icon=" << icon.toLocal8Bit() << "\n"; + if (!icon.isEmpty()) + { + stream << "Icon=" << icon.toLocal8Bit() << "\n"; + } stream.flush(); f.close(); @@ -368,24 +372,121 @@ bool createShortCut(QString location, QString dest, QStringList args, QString na return true; #elif defined Q_OS_WIN - // TODO: Fix - // QFile file(PathCombine(location, name + ".lnk")); - // WCHAR *file_w; - // WCHAR *dest_w; - // WCHAR *args_w; - // file.fileName().toWCharArray(file_w); - // dest.toWCharArray(dest_w); + QFileInfo targetInfo(target); - // QString argStr; - // for (int i = 0; i < args.count(); i++) - // { - // argStr.append(args[i]); - // argStr.append(" "); - // } - // argStr.toWCharArray(args_w); + if (!targetInfo.exists()) + { + qWarning() << "Target file does not exist!"; + return false; + } - // return SUCCEEDED(CreateLink(file_w, dest_w, args_w)); - return false; + target = targetInfo.absoluteFilePath(); + + if (target.length() >= MAX_PATH) + { + qWarning() << "Target file path is too long!"; + return false; + } + + if (!icon.isEmpty() && icon.length() >= MAX_PATH) + { + qWarning() << "Icon path is too long!"; + return false; + } + + destination += ".lnk"; + + if (destination.length() >= MAX_PATH) + { + qWarning() << "Destination path is too long!"; + return false; + } + + QString argStr; + int argCount = args.count(); + for (int i = 0; i < argCount; i++) + { + if (args[i].contains(' ')) + { + argStr.append('"').append(args[i]).append('"'); + } + else + { + argStr.append(args[i]); + } + + if (i < argCount - 1) + { + argStr.append(" "); + } + } + + if (argStr.length() >= MAX_PATH) + { + qWarning() << "Arguments string is too long!"; + return false; + } + + WCHAR wsz[MAX_PATH]; + + // ...yes, you need to initialize the entire COM stack to make a shortcut in Windows + CoInitialize(nullptr); + + HRESULT hres; + IShellLink* psl; + + hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl); + if (SUCCEEDED(hres)) + { + wmemset(wsz, 0, MAX_PATH); + target.toWCharArray(wsz); + psl->SetPath(wsz); + + wmemset(wsz, 0, MAX_PATH); + argStr.toWCharArray(wsz); + psl->SetArguments(wsz); + + wmemset(wsz, 0, MAX_PATH); + targetInfo.absolutePath().toWCharArray(wsz); + psl->SetWorkingDirectory(wsz); + + if (!icon.isEmpty()) + { + wmemset(wsz, 0, MAX_PATH); + icon.toWCharArray(wsz); + psl->SetIconLocation(wsz, 0); + } + + IPersistFile* ppf; + hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf); + if (SUCCEEDED(hres)) + { + wmemset(wsz, 0, MAX_PATH); + destination.toWCharArray(wsz); + hres = ppf->Save(wsz, TRUE); + if (FAILED(hres)) + { + qWarning() << "IPresistFile->Save() failed"; + qWarning() << "hres = " << hres; + } + ppf->Release(); + } + else + { + qWarning() << "Failed to query IPersistFile interface from IShellLink instance"; + qWarning() << "hres = " << hres; + } + psl->Release(); + } + else + { + qWarning() << "Failed to create IShellLink instance"; + qWarning() << "hres = " << hres; + } + + CoUninitialize(); + + return SUCCEEDED(hres); #else qWarning("Desktop Shortcuts not supported on your platform!"); return false; diff --git a/launcher/FileSystem.h b/launcher/FileSystem.h index b7e175fd..23cc575b 100644 --- a/launcher/FileSystem.h +++ b/launcher/FileSystem.h @@ -156,4 +156,9 @@ QString getDesktopDir(); // Overrides one folder with the contents of another, preserving items exclusive to the first folder // Equivalent to doing QDir::rename, but allowing for overrides bool overrideFolder(QString overwritten_path, QString override_path); + +/** + * Creates a shortcut to the specified target file at the specified destination path. + */ +bool createShortcut(QString destination, QString target, QStringList args, QString name, QString icon); } diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 419bb9bd..1ad9713a 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -39,6 +39,7 @@ #include "Application.h" #include "BuildConfig.h" +#include "FileSystem.h" #include "MainWindow.h" @@ -739,9 +740,9 @@ public: actionCreateInstanceShortcut = TranslatedAction(MainWindow); actionCreateInstanceShortcut->setObjectName(QStringLiteral("actionCreateInstanceShortcut")); - actionCreateInstanceShortcut.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Create shortcut")); + actionCreateInstanceShortcut.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Create Shortcut")); actionCreateInstanceShortcut.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Creates a shortcut on your desktop to launch the selected instance.")); - actionCreateInstanceShortcut->setShortcut(QKeySequence(tr("Ctrl+D"))); + //actionCreateInstanceShortcut->setShortcut(QKeySequence(tr("Ctrl+D"))); // TODO //actionCreateInstanceShortcut->setIcon(APPLICATION->getThemedIcon("copy")); // TODO all_actions.append(&actionCreateInstanceShortcut); @@ -793,7 +794,7 @@ public: } } - instanceToolBar->addAction(actionCreateInstanceShortcut); + instanceToolBar->addAction(actionCreateInstanceShortcut); // TODO find better position for this all_toolbars.append(&instanceToolBar); MainWindow->addToolBar(Qt::RightToolBarArea, instanceToolBar); @@ -2087,76 +2088,39 @@ void MainWindow::on_actionKillInstance_triggered() } } -#ifdef Q_OS_WIN -#define WIN32_LEAN_AND_MEAN -#include "windows.h" -#include "winnls.h" -#include "shobjidl.h" -#include "objbase.h" -#include "objidl.h" -#include "shlguid.h" -#endif - void MainWindow::on_actionCreateInstanceShortcut_triggered() { if (m_selectedInstance) { - auto desktopDir = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); - if (desktopDir.isEmpty()) { + auto desktopPath = FS::getDesktopDir(); + if (desktopPath.isEmpty()) { // TODO come up with an alternative solution (open "save file" dialog) - QMessageBox::critical(this, tr("Create instance shortcut"), tr("Couldn't find desktop!")); + QMessageBox::critical(this, tr("Create instance shortcut"), tr("Couldn't find desktop?!")); return; } -#if defined(Q_OS_WIN) - // Windows - WCHAR wsz[MAX_PATH]; - - // ...yes, you need to initialize the entire COM stack to make a shortcut in Windows. - // I hate it. - CoInitialize(nullptr); - - HRESULT hres; - IShellLink* psl; - - hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl); - if (SUCCEEDED(hres)) - { - IPersistFile* ppf; - - QApplication::applicationFilePath().left(MAX_PATH - 1).toWCharArray(wsz); - psl->SetPath(wsz); - - wmemset(wsz, 0, MAX_PATH); - QStringLiteral("--launch %1").arg(m_selectedInstance->id()).left(MAX_PATH - 1).toWCharArray(wsz); - psl->SetArguments(wsz); - - // TODO set icon - - hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf); - - if (SUCCEEDED(hres)) - { - wmemset(wsz, 0, MAX_PATH); - - desktopDir - .append('/') - .append(QStringLiteral("%1.lnk").arg(m_selectedInstance->name())) - .left(MAX_PATH - 1).toWCharArray(wsz); - - hres = ppf->Save(wsz, TRUE); - ppf->Release(); - } - psl->Release(); - } - - CoUninitialize(); -#elif defined(Q_OS_LINUX) - // Linux -#elif defined(Q_OS_MACOS) +#if defined(Q_OS_MACOS) // macOSX // TODO actually write this path QMessageBox::critical(this, tr("Create instance shortcut"), tr("Not supported on macOSX yet!")); +#else + QString iconPath; + +#if defined(Q_OS_WIN) + // TODO + // need to convert icon to ICO format and save it somewhere... + iconPath = ""; +#elif defined(Q_OS_UNIX) + iconPath = ""; // TODO get instance icon path +#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 + { + QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!")); + } #endif } } From f12117c532de4bdbf74968cf173d1c288a7e426a Mon Sep 17 00:00:00 2001 From: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> Date: Tue, 25 Oct 2022 17:37:30 +0300 Subject: [PATCH 03/33] [UNTESTED] Linux: add icons to shortcuts Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> --- launcher/ui/MainWindow.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 1ad9713a..8f2196f2 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -2104,6 +2104,8 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered() // TODO actually write this path QMessageBox::critical(this, tr("Create instance shortcut"), tr("Not supported on macOSX yet!")); #else + auto icon = APPLICATION->icons()->icon(m_selectedInstance->iconKey()); + QString iconPath; #if defined(Q_OS_WIN) @@ -2111,7 +2113,7 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered() // need to convert icon to ICO format and save it somewhere... iconPath = ""; #elif defined(Q_OS_UNIX) - iconPath = ""; // TODO get instance icon path + iconPath = icon->getFilePath(); #endif if (FS::createShortcut(FS::PathCombine(desktopPath, m_selectedInstance->name()), QApplication::applicationFilePath(), { "--launch", m_selectedInstance->id() }, m_selectedInstance->name(), iconPath)) { From 6ae3b183fdb1f6e4887617fc7230d52c803e63fd Mon Sep 17 00:00:00 2001 From: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> Date: Tue, 25 Oct 2022 21:18:53 +0300 Subject: [PATCH 04/33] Remove unnessecary "is defined" check Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> --- launcher/ui/MainWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 8f2196f2..34c51ec6 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -2112,7 +2112,7 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered() // TODO // need to convert icon to ICO format and save it somewhere... iconPath = ""; -#elif defined(Q_OS_UNIX) +#else iconPath = icon->getFilePath(); #endif if (FS::createShortcut(FS::PathCombine(desktopPath, m_selectedInstance->name()), From b83f9be1bd65f784bbed603e550fbe9f650b0367 Mon Sep 17 00:00:00 2001 From: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> Date: Fri, 28 Oct 2022 15:46:54 +0300 Subject: [PATCH 05/33] Add missing fail check for CoInitialize Add a few comments Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> --- launcher/FileSystem.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 90f0313f..587753a0 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -427,14 +427,21 @@ bool createShortcut(QString destination, QString target, QStringList args, QStri return false; } + HRESULT hres; + + // ...yes, you need to initialize the entire COM stack just to make a shortcut + hres = CoInitialize(nullptr); + if (FAILED(hres)) + { + qWarning() << "Failed to initialize COM!"; + return false; + } + WCHAR wsz[MAX_PATH]; - // ...yes, you need to initialize the entire COM stack to make a shortcut in Windows - CoInitialize(nullptr); - - HRESULT hres; IShellLink* psl; + // create an IShellLink instance - this stores the shortcut's attributes hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl); if (SUCCEEDED(hres)) { @@ -448,7 +455,7 @@ bool createShortcut(QString destination, QString target, QStringList args, QStri wmemset(wsz, 0, MAX_PATH); targetInfo.absolutePath().toWCharArray(wsz); - psl->SetWorkingDirectory(wsz); + psl->SetWorkingDirectory(wsz); // "Starts in" attribute if (!icon.isEmpty()) { @@ -457,6 +464,8 @@ bool createShortcut(QString destination, QString target, QStringList args, QStri psl->SetIconLocation(wsz, 0); } + // query an IPersistFile interface from our IShellLink instance + // this is the interface that will actually let us save the shortcut to disk! IPersistFile* ppf; hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf); if (SUCCEEDED(hres)) @@ -484,6 +493,7 @@ bool createShortcut(QString destination, QString target, QStringList args, QStri qWarning() << "hres = " << hres; } + // go away COM, nobody likes you CoUninitialize(); return SUCCEEDED(hres); From 4d4dfab38869bca82626e171336cbe8f7c89a1a1 Mon Sep 17 00:00:00 2001 From: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> Date: Fri, 28 Oct 2022 17:42:29 +0300 Subject: [PATCH 06/33] Windows: add instance icon to shortcut Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> --- launcher/ui/MainWindow.cpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 34c51ec6..9743c822 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -2107,11 +2107,28 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered() auto icon = APPLICATION->icons()->icon(m_selectedInstance->iconKey()); QString iconPath; + bool iconGenerated = false; #if defined(Q_OS_WIN) - // TODO - // need to convert icon to ICO format and save it somewhere... - iconPath = ""; + iconPath = FS::PathCombine(m_selectedInstance->instanceRoot(), "icon.ico"); + + QFile iconFile(iconPath); + if (!iconFile.open(QFile::WriteOnly)) + { + QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!")); + return; + } + + if (!icon->icon().pixmap(64, 64).save(&iconFile, "ICO")) + { + iconFile.close(); + iconFile.remove(); + QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!")); + return; + } + + iconFile.close(); + iconGenerated = true; #else iconPath = icon->getFilePath(); #endif @@ -2121,6 +2138,10 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered() } else { + if (iconGenerated) + { + QFile::remove(iconPath); + } QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!")); } #endif From cc5f82bfac162becf55dfcb015f55be3c833bc32 Mon Sep 17 00:00:00 2001 From: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> Date: Fri, 28 Oct 2022 21:11:51 +0300 Subject: [PATCH 07/33] Windows: fix window icon being replaced Dunno why it happens but the fix was literally 2 lines, so whatever I guess Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> --- launcher/ui/MainWindow.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 9743c822..a87da362 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -2112,6 +2112,10 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered() #if defined(Q_OS_WIN) 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 = QGuiApplication::windowIcon(); + QFile iconFile(iconPath); if (!iconFile.open(QFile::WriteOnly)) { @@ -2129,6 +2133,9 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered() iconFile.close(); iconGenerated = true; + + // restore original window icon + QGuiApplication::setWindowIcon(appIcon); #else iconPath = icon->getFilePath(); #endif From 487e352642c4430f57643b53a8e9cd3d04edfeb8 Mon Sep 17 00:00:00 2001 From: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> Date: Fri, 4 Nov 2022 22:04:42 +0200 Subject: [PATCH 08/33] Fix nested #if directive Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> --- launcher/ui/MainWindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index a87da362..15fdd6f2 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -2103,7 +2103,8 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered() // macOSX // TODO actually write this path QMessageBox::critical(this, tr("Create instance shortcut"), tr("Not supported on macOSX yet!")); -#else + return; +#endif auto icon = APPLICATION->icons()->icon(m_selectedInstance->iconKey()); QString iconPath; @@ -2151,7 +2152,6 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered() } QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!")); } -#endif } } From 6043444e4e11801e45ad888182c99d6f4e4e5ddc Mon Sep 17 00:00:00 2001 From: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> Date: Wed, 9 Nov 2022 21:02:40 +0200 Subject: [PATCH 09/33] Apply suggestions from code review Co-authored-by: Sefa Eyeoglu Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> --- launcher/FileSystem.cpp | 2 +- launcher/ui/MainWindow.cpp | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 587753a0..5a539093 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -342,7 +342,7 @@ QString getDesktopDir() // Cross-platform Shortcut creation bool createShortcut(QString destination, QString target, QStringList args, QString name, QString icon) { -#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) +#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD) destination = PathCombine(destination, name + ".desktop"); QFile f(destination); diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 15fdd6f2..cd3c1b5b 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -2099,23 +2099,21 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered() return; } -#if defined(Q_OS_MACOS) - // macOSX - // TODO actually write this path - QMessageBox::critical(this, tr("Create instance shortcut"), tr("Not supported on macOSX yet!")); - return; +#ifdef Q_OS_MACOS + QMessageBox::critical(this, tr("Create instance shortcut"), tr("Not supported on macOS yet!")); + return; #endif auto icon = APPLICATION->icons()->icon(m_selectedInstance->iconKey()); QString iconPath; bool iconGenerated = false; -#if defined(Q_OS_WIN) +#ifdef Q_OS_WIN 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 = QGuiApplication::windowIcon(); + auto appIcon = Application::getThemedIcon("logo"); QFile iconFile(iconPath); if (!iconFile.open(QFile::WriteOnly)) From 9be48f1dc44dc764d2131c559780624908ff636d Mon Sep 17 00:00:00 2001 From: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> Date: Wed, 9 Nov 2022 21:55:13 +0200 Subject: [PATCH 10/33] this ain't static, falco Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> --- launcher/ui/MainWindow.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index cd3c1b5b..ff1982ce 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -2113,7 +2113,7 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered() // 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"); + auto appIcon = APPLICATION->getThemedIcon("logo"); QFile iconFile(iconPath); if (!iconFile.open(QFile::WriteOnly)) @@ -2121,20 +2121,22 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered() QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!")); return; } + bool success = icon->icon().pixmap(64, 64).save(&iconFile, "ICO"); + iconFile.close(); - if (!icon->icon().pixmap(64, 64).save(&iconFile, "ICO")) + // restore original window icon + QGuiApplication::setWindowIcon(appIcon); + + if (success) + { + iconGenerated = true; + } + else { - iconFile.close(); iconFile.remove(); QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!")); return; } - - iconFile.close(); - iconGenerated = true; - - // restore original window icon - QGuiApplication::setWindowIcon(appIcon); #else iconPath = icon->getFilePath(); #endif From dbe0553b4a6100d8269f749cc4eb372e5a30cb3b Mon Sep 17 00:00:00 2001 From: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> Date: Wed, 9 Nov 2022 21:56:46 +0200 Subject: [PATCH 11/33] Move addAction call above left-align loop Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> --- launcher/ui/MainWindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index ff1982ce..0a846b59 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -784,6 +784,8 @@ public: instanceToolBar->addAction(actionCopyInstance); instanceToolBar->addAction(actionDeleteInstance); + instanceToolBar->addAction(actionCreateInstanceShortcut); // TODO find better position for this + QLayout * lay = instanceToolBar->layout(); for(int i = 0; i < lay->count(); i++) { @@ -794,8 +796,6 @@ public: } } - instanceToolBar->addAction(actionCreateInstanceShortcut); // TODO find better position for this - all_toolbars.append(&instanceToolBar); MainWindow->addToolBar(Qt::RightToolBarArea, instanceToolBar); } From 7e5076b06891f28c1b2e27befd33005d400c49c9 Mon Sep 17 00:00:00 2001 From: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> Date: Sat, 12 Nov 2022 20:13:59 +0200 Subject: [PATCH 12/33] Linux: fix path shortcut is written to Co-authored-by: flow Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> --- launcher/FileSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 5a539093..ddd1a6e5 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -343,7 +343,7 @@ QString getDesktopDir() 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) - destination = PathCombine(destination, name + ".desktop"); + destination += ".desktop"; QFile f(destination); f.open(QIODevice::WriteOnly | QIODevice::Text); From f7d7d76ee879c3bdd539e5c8c956cbd2c7328bf0 Mon Sep 17 00:00:00 2001 From: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> Date: Sat, 12 Nov 2022 20:36:49 +0200 Subject: [PATCH 13/33] Mac: now supported! [UNTESTED] Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> --- launcher/FileSystem.cpp | 26 +++++++++++++++++++++++++- launcher/ui/MainWindow.cpp | 15 ++++++++++++++- libraries/tomlplusplus | 2 +- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index ddd1a6e5..221395be 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -342,7 +342,31 @@ QString getDesktopDir() // Cross-platform Shortcut creation 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"; QFile f(destination); diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 0a846b59..02f60233 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -2100,7 +2100,20 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered() } #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; #endif auto icon = APPLICATION->icons()->icon(m_selectedInstance->iconKey()); diff --git a/libraries/tomlplusplus b/libraries/tomlplusplus index cc741c9f..4b166b69 160000 --- a/libraries/tomlplusplus +++ b/libraries/tomlplusplus @@ -1 +1 @@ -Subproject commit cc741c9f5f2a62856a2a2e9e275f61eb0591c09c +Subproject commit 4b166b69f28e70a416a1a04a98f365d2aeb90de8 From b813c867b505f0c1ec8125fde9916d6252cd4485 Mon Sep 17 00:00:00 2001 From: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> Date: Sat, 12 Nov 2022 20:41:52 +0200 Subject: [PATCH 14/33] refactor #if checks Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> --- launcher/FileSystem.cpp | 2 +- launcher/ui/MainWindow.cpp | 46 ++++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 221395be..7a1861e7 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -395,7 +395,7 @@ bool createShortcut(QString destination, QString target, QStringList args, QStri f.setPermissions(f.permissions() | QFileDevice::ExeOwner | QFileDevice::ExeGroup | QFileDevice::ExeOther); return true; -#elif defined Q_OS_WIN +#elif defined(Q_OS_WIN) QFileInfo targetInfo(target); if (!targetInfo.exists()) 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 } } From 45ce72593ac29e54311219e71d47b044eda14b14 Mon Sep 17 00:00:00 2001 From: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> Date: Sat, 12 Nov 2022 20:43:58 +0200 Subject: [PATCH 15/33] Windows: remove icon if shortcut creation fails Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> --- launcher/ui/MainWindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 8e8a7c56..3f99ac99 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -2158,6 +2158,7 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered() } else { + iconFile.remove(); QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!")); } #else From 5322155b19e68b44e879512cf46ee152045dc1b1 Mon Sep 17 00:00:00 2001 From: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> Date: Sat, 12 Nov 2022 20:48:21 +0200 Subject: [PATCH 16/33] Mac: fix build Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> --- launcher/ui/MainWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 3f99ac99..aedd9e4f 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -2101,7 +2101,7 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered() #if defined(Q_OS_MACOS) // handle macOS bundle weirdness - QFileInfo appFileInfo(QApplication::applicationFilePath())); + QFileInfo appFileInfo(QApplication::applicationFilePath()); QString appName = appFileInfo.baseName(); QString exeName = FS::PathCombine(appFileInfo.filePath(), "Contents/MacOS/" + appName); From 69bbb2932848fe7509f91623bac2a648ce594ad7 Mon Sep 17 00:00:00 2001 From: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> Date: Sun, 13 Nov 2022 15:47:37 +0200 Subject: [PATCH 17/33] Mac: attempt 2 - create .command files instead of .sh - fix shortcuts not working if path to Prism Launcher contains spaces - fix path to executable in shortcutss - add check for running from extracted folder (prevents creating shortcuts) Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> --- launcher/FileSystem.cpp | 7 ++++--- launcher/ui/MainWindow.cpp | 11 ++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 7a1861e7..80715498 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -343,7 +343,7 @@ QString getDesktopDir() bool createShortcut(QString destination, QString target, QStringList args, QString name, QString icon) { #if defined(Q_OS_MACOS) - destination += ".sh"; + destination += ".command"; QFile f(destination); f.open(QIODevice::WriteOnly | QIODevice::Text); @@ -355,8 +355,9 @@ bool createShortcut(QString destination, QString target, QStringList args, QStri stream << "#!/bin/bash" << "\n"; - stream << target - << " " + stream << "\"" + << target + << "\" " << argstring << "\n"; diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index aedd9e4f..17371149 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -2100,13 +2100,14 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered() } #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); + QString appPath = QApplication::applicationFilePath(); + if (appPath.startsWith("/private/var")) { + QMessageBox::critical(this, tr("Create instance shortcut"), tr("The launcher is in the folder it was extracted from, therefore it cannot create shortcuts.")); + return; + } if (FS::createShortcut(FS::PathCombine(desktopPath, m_selectedInstance->name()), - exeName, { "--launch", m_selectedInstance->id() }, m_selectedInstance->name(), "")) { + appPath, { "--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 From 43b9d9484da280fc209a0c9f195b0ca338eacdb9 Mon Sep 17 00:00:00 2001 From: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> Date: Sun, 13 Nov 2022 15:49:28 +0200 Subject: [PATCH 18/33] tabs -> spaces Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> --- launcher/ui/MainWindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 17371149..c7de46c7 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -2101,10 +2101,10 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered() #if defined(Q_OS_MACOS) QString appPath = QApplication::applicationFilePath(); - if (appPath.startsWith("/private/var")) { + if (appPath.startsWith("/private/var")) { QMessageBox::critical(this, tr("Create instance shortcut"), tr("The launcher is in the folder it was extracted from, therefore it cannot create shortcuts.")); return; - } + } if (FS::createShortcut(FS::PathCombine(desktopPath, m_selectedInstance->name()), appPath, { "--launch", m_selectedInstance->id() }, m_selectedInstance->name(), "")) { From b0269e6dfc685cd002340e95e80942410f1b1fc5 Mon Sep 17 00:00:00 2001 From: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> Date: Sun, 13 Nov 2022 17:51:29 +0200 Subject: [PATCH 19/33] Linux: fixes - Fix shortcut icons - Possibly fix shortcut creation on AppImages - Fix shortcut not working if path to launcher contains spaces Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> --- launcher/FileSystem.cpp | 4 ++-- launcher/ui/MainWindow.cpp | 48 +++++++++++++++++++++++++++++++++----- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 80715498..e1059ca9 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -382,8 +382,8 @@ bool createShortcut(QString destination, QString target, QStringList args, QStri << "\n"; stream << "Type=Application" << "\n"; - stream << "TryExec=" << target.toLocal8Bit() << "\n"; - stream << "Exec=" << target.toLocal8Bit() << argstring.toLocal8Bit() << "\n"; + stream << "TryExec=\"" << target.toLocal8Bit() << "\"\n"; + stream << "Exec=\"" << target.toLocal8Bit() << "\"" << argstring.toLocal8Bit() << "\n"; stream << "Name=" << name.toLocal8Bit() << "\n"; if (!icon.isEmpty()) { diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index c7de46c7..4dbac967 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -2101,13 +2101,14 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered() #if defined(Q_OS_MACOS) QString appPath = QApplication::applicationFilePath(); - if (appPath.startsWith("/private/var")) { + if (appPath.startsWith("/private/var/")) { QMessageBox::critical(this, tr("Create instance shortcut"), tr("The launcher is in the folder it was extracted from, therefore it cannot create shortcuts.")); return; } if (FS::createShortcut(FS::PathCombine(desktopPath, m_selectedInstance->name()), - appPath, { "--launch", m_selectedInstance->id() }, m_selectedInstance->name(), "")) { + appPath, { "--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 @@ -2115,14 +2116,48 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered() 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) + QString appPath = QApplication::applicationFilePath(); + if (appPath.startsWith("/tmp/.mount_")) { + // AppImage! + appPath = QProcessEnvironment::systemEnvironment().value(QStringLiteral("APPIMAGE")); + if (appPath.isEmpty()) + { + QMessageBox::critical(this, tr("Create instance shortcut"), tr("Launcher is running as misconfigured AppImage? ($APPIMAGE environment variable is missing)")); + } + else if (appPath.endsWith("/")) + { + appPath.chop(1); + } + } + auto icon = APPLICATION->icons()->icon(m_selectedInstance->iconKey()); + QString iconPath = FS::PathCombine(m_selectedInstance->instanceRoot(), "icon.png"); + + QFile iconFile(iconPath); + if (!iconFile.open(QFile::WriteOnly)) + { + QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create icon for shortcut.")); + return; + } + bool success = icon->icon().pixmap(64, 64).save(&iconFile, "PNG"); + iconFile.close(); + + if (!success) + { + iconFile.remove(); + QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create icon for shortcut.")); + return; + } + if (FS::createShortcut(FS::PathCombine(desktopPath, m_selectedInstance->name()), - QApplication::applicationFilePath(), { "--launch", m_selectedInstance->id() }, m_selectedInstance->name(), icon->getFilePath())) { + appPath, { "--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 { + iconFile.remove(); QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!")); } #elif defined(Q_OS_WIN) @@ -2137,7 +2172,7 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered() QFile iconFile(iconPath); if (!iconFile.open(QFile::WriteOnly)) { - QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!")); + QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create icon for shortcut.")); return; } bool success = icon->icon().pixmap(64, 64).save(&iconFile, "ICO"); @@ -2149,12 +2184,13 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered() if (!success) { 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 icon for shortcut.")); return; } 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!")); } else From c4cfec1e94d1665dc3c1ccd44966a34f349698ea Mon Sep 17 00:00:00 2001 From: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> Date: Sun, 13 Nov 2022 18:00:18 +0200 Subject: [PATCH 20/33] Undo accidental tomlplusplus downgrade Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> --- libraries/tomlplusplus | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/tomlplusplus b/libraries/tomlplusplus index 4b166b69..cc741c9f 160000 --- a/libraries/tomlplusplus +++ b/libraries/tomlplusplus @@ -1 +1 @@ -Subproject commit 4b166b69f28e70a416a1a04a98f365d2aeb90de8 +Subproject commit cc741c9f5f2a62856a2a2e9e275f61eb0591c09c From acd50969e0fcb172cf5f62e5ced4d10c6a9cbbe6 Mon Sep 17 00:00:00 2001 From: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> Date: Sun, 13 Nov 2022 19:50:27 +0200 Subject: [PATCH 21/33] Linux: remove TryExec entry from .desktop files Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> --- launcher/FileSystem.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index e1059ca9..9d911fa0 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -382,7 +382,6 @@ bool createShortcut(QString destination, QString target, QStringList args, QStri << "\n"; stream << "Type=Application" << "\n"; - stream << "TryExec=\"" << target.toLocal8Bit() << "\"\n"; stream << "Exec=\"" << target.toLocal8Bit() << "\"" << argstring.toLocal8Bit() << "\n"; stream << "Name=" << name.toLocal8Bit() << "\n"; if (!icon.isEmpty()) From 5be8545edcf53cd410d0ea14168b5675150106fc Mon Sep 17 00:00:00 2001 From: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> Date: Sun, 13 Nov 2022 20:18:51 +0200 Subject: [PATCH 22/33] Windows, Linux: prevent segfault on missing icon Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> --- launcher/ui/MainWindow.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 4dbac967..4e6ce82c 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -2131,7 +2131,11 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered() } auto icon = APPLICATION->icons()->icon(m_selectedInstance->iconKey()); - + if (icon == nullptr) + { + icon = APPLICATION->icons()->icon("grass"); + } + QString iconPath = FS::PathCombine(m_selectedInstance->instanceRoot(), "icon.png"); QFile iconFile(iconPath); @@ -2162,7 +2166,11 @@ void MainWindow::on_actionCreateInstanceShortcut_triggered() } #elif defined(Q_OS_WIN) auto icon = APPLICATION->icons()->icon(m_selectedInstance->iconKey()); - + if (icon == nullptr) + { + icon = APPLICATION->icons()->icon("grass"); + } + QString iconPath = FS::PathCombine(m_selectedInstance->instanceRoot(), "icon.ico"); // part of fix for weird bug involving the window icon being replaced From ce892c9e777f13de6e6298806d9fdb5c92f77af6 Mon Sep 17 00:00:00 2001 From: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> Date: Mon, 14 Nov 2022 21:02:31 +0200 Subject: [PATCH 23/33] Add icon NOTE: Currently missing on Legacy, Flat and Flat (White) Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> --- launcher/resources/OSX/OSX.qrc | 4 +- launcher/resources/OSX/scalable/shortcut.svg | 14 +++++++ launcher/resources/iOS/iOS.qrc | 4 +- launcher/resources/iOS/scalable/shortcut.svg | 13 ++++++ launcher/resources/pe_blue/pe_blue.qrc | 4 +- .../resources/pe_blue/scalable/shortcut.svg | 41 +++++++++++++++++++ launcher/resources/pe_colored/pe_colored.qrc | 4 +- .../pe_colored/scalable/shortcut.svg | 13 ++++++ launcher/resources/pe_dark/pe_dark.qrc | 4 +- .../resources/pe_dark/scalable/shortcut.svg | 41 +++++++++++++++++++ launcher/resources/pe_light/pe_light.qrc | 4 +- .../resources/pe_light/scalable/shortcut.svg | 41 +++++++++++++++++++ launcher/ui/MainWindow.cpp | 3 +- 13 files changed, 177 insertions(+), 13 deletions(-) create mode 100644 launcher/resources/OSX/scalable/shortcut.svg create mode 100644 launcher/resources/iOS/scalable/shortcut.svg create mode 100644 launcher/resources/pe_blue/scalable/shortcut.svg create mode 100644 launcher/resources/pe_colored/scalable/shortcut.svg create mode 100644 launcher/resources/pe_dark/scalable/shortcut.svg create mode 100644 launcher/resources/pe_light/scalable/shortcut.svg diff --git a/launcher/resources/OSX/OSX.qrc b/launcher/resources/OSX/OSX.qrc index 19fe312b..3f50d6cf 100644 --- a/launcher/resources/OSX/OSX.qrc +++ b/launcher/resources/OSX/OSX.qrc @@ -1,5 +1,4 @@ - - + index.theme scalable/about.svg @@ -39,5 +38,6 @@ scalable/export.svg scalable/rename.svg scalable/launch.svg + scalable/shortcut.svg diff --git a/launcher/resources/OSX/scalable/shortcut.svg b/launcher/resources/OSX/scalable/shortcut.svg new file mode 100644 index 00000000..a2b7488e --- /dev/null +++ b/launcher/resources/OSX/scalable/shortcut.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + diff --git a/launcher/resources/iOS/iOS.qrc b/launcher/resources/iOS/iOS.qrc index aa08d811..d7044fbb 100644 --- a/launcher/resources/iOS/iOS.qrc +++ b/launcher/resources/iOS/iOS.qrc @@ -1,5 +1,4 @@ - - + index.theme scalable/about.svg @@ -39,5 +38,6 @@ scalable/export.svg scalable/rename.svg scalable/launch.svg + scalable/shortcut.svg diff --git a/launcher/resources/iOS/scalable/shortcut.svg b/launcher/resources/iOS/scalable/shortcut.svg new file mode 100644 index 00000000..16e9fa48 --- /dev/null +++ b/launcher/resources/iOS/scalable/shortcut.svg @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/launcher/resources/pe_blue/pe_blue.qrc b/launcher/resources/pe_blue/pe_blue.qrc index 3121ffe6..dc40103a 100644 --- a/launcher/resources/pe_blue/pe_blue.qrc +++ b/launcher/resources/pe_blue/pe_blue.qrc @@ -1,5 +1,4 @@ - - + index.theme scalable/about.svg @@ -39,5 +38,6 @@ scalable/export.svg scalable/rename.svg scalable/launch.svg + scalable/shortcut.svg diff --git a/launcher/resources/pe_blue/scalable/shortcut.svg b/launcher/resources/pe_blue/scalable/shortcut.svg new file mode 100644 index 00000000..45b73496 --- /dev/null +++ b/launcher/resources/pe_blue/scalable/shortcut.svg @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/pe_colored/pe_colored.qrc b/launcher/resources/pe_colored/pe_colored.qrc index ce5ad8e2..bd1af6ff 100644 --- a/launcher/resources/pe_colored/pe_colored.qrc +++ b/launcher/resources/pe_colored/pe_colored.qrc @@ -1,5 +1,4 @@ - - + index.theme scalable/about.svg @@ -39,5 +38,6 @@ scalable/export.svg scalable/rename.svg scalable/launch.svg + scalable/shortcut.svg diff --git a/launcher/resources/pe_colored/scalable/shortcut.svg b/launcher/resources/pe_colored/scalable/shortcut.svg new file mode 100644 index 00000000..1469674f --- /dev/null +++ b/launcher/resources/pe_colored/scalable/shortcut.svg @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/launcher/resources/pe_dark/pe_dark.qrc b/launcher/resources/pe_dark/pe_dark.qrc index 156d8f8b..05ef7e93 100644 --- a/launcher/resources/pe_dark/pe_dark.qrc +++ b/launcher/resources/pe_dark/pe_dark.qrc @@ -1,5 +1,4 @@ - - + index.theme scalable/about.svg @@ -39,5 +38,6 @@ scalable/export.svg scalable/rename.svg scalable/launch.svg + scalable/shortcut.svg diff --git a/launcher/resources/pe_dark/scalable/shortcut.svg b/launcher/resources/pe_dark/scalable/shortcut.svg new file mode 100644 index 00000000..29b45f26 --- /dev/null +++ b/launcher/resources/pe_dark/scalable/shortcut.svg @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/pe_light/pe_light.qrc b/launcher/resources/pe_light/pe_light.qrc index d8e4a1bd..6acca230 100644 --- a/launcher/resources/pe_light/pe_light.qrc +++ b/launcher/resources/pe_light/pe_light.qrc @@ -1,5 +1,4 @@ - - + index.theme scalable/about.svg @@ -39,5 +38,6 @@ scalable/export.svg scalable/rename.svg scalable/launch.svg + scalable/shortcut.svg diff --git a/launcher/resources/pe_light/scalable/shortcut.svg b/launcher/resources/pe_light/scalable/shortcut.svg new file mode 100644 index 00000000..4d232bcf --- /dev/null +++ b/launcher/resources/pe_light/scalable/shortcut.svg @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 4e6ce82c..0c606660 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -743,7 +743,8 @@ public: actionCreateInstanceShortcut.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Create Shortcut")); actionCreateInstanceShortcut.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Creates a shortcut on your desktop to launch the selected instance.")); //actionCreateInstanceShortcut->setShortcut(QKeySequence(tr("Ctrl+D"))); // TODO - //actionCreateInstanceShortcut->setIcon(APPLICATION->getThemedIcon("copy")); // TODO + // FIXME missing on Legacy, Flat and Flat (White) + actionCreateInstanceShortcut->setIcon(APPLICATION->getThemedIcon("shortcut")); all_actions.append(&actionCreateInstanceShortcut); setInstanceActionsEnabled(false); From 8d6aecd9447f0740d70f7397a176bb744605c2e3 Mon Sep 17 00:00:00 2001 From: leo78913 Date: Sun, 6 Nov 2022 12:25:11 -0300 Subject: [PATCH 24/33] add the missing icons to the legacy icon theme Signed-off-by: leo78913 --- launcher/resources/multimc/multimc.qrc | 8 + .../resources/multimc/scalable/delete.svg | 282 +++++++++++ .../resources/multimc/scalable/export.svg | 466 ++++++++++++++++++ .../resources/multimc/scalable/launch.svg | 96 ++++ .../resources/multimc/scalable/rename.svg | 437 ++++++++++++++++ launcher/resources/multimc/scalable/tag.svg | 398 +++++++++++++++ 6 files changed, 1687 insertions(+) create mode 100644 launcher/resources/multimc/scalable/delete.svg create mode 100644 launcher/resources/multimc/scalable/export.svg create mode 100644 launcher/resources/multimc/scalable/launch.svg create mode 100644 launcher/resources/multimc/scalable/rename.svg create mode 100644 launcher/resources/multimc/scalable/tag.svg diff --git a/launcher/resources/multimc/multimc.qrc b/launcher/resources/multimc/multimc.qrc index 3f3d22fc..270dd009 100644 --- a/launcher/resources/multimc/multimc.qrc +++ b/launcher/resources/multimc/multimc.qrc @@ -312,5 +312,13 @@ scalable/instances/fox.svg scalable/instances/bee.svg scalable/instances/prismlauncher.svg + + + scalable/delete.svg + scalable/tag.svg + scalable/rename.svg + + scalable/export.svg + scalable/launch.svg diff --git a/launcher/resources/multimc/scalable/delete.svg b/launcher/resources/multimc/scalable/delete.svg new file mode 100644 index 00000000..414cbd5c --- /dev/null +++ b/launcher/resources/multimc/scalable/delete.svg @@ -0,0 +1,282 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/multimc/scalable/export.svg b/launcher/resources/multimc/scalable/export.svg new file mode 100644 index 00000000..2605de14 --- /dev/null +++ b/launcher/resources/multimc/scalable/export.svg @@ -0,0 +1,466 @@ + + + + + + + + + + + unsorted + + + + + Open Clip Art Library, Source: Oxygen Icons, Source: Oxygen Icons, Source: Oxygen Icons, Source: Oxygen Icons + + + + + + + + + + + + + + image/svg+xml + + + en + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/multimc/scalable/launch.svg b/launcher/resources/multimc/scalable/launch.svg new file mode 100644 index 00000000..321647a0 --- /dev/null +++ b/launcher/resources/multimc/scalable/launch.svg @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/multimc/scalable/rename.svg b/launcher/resources/multimc/scalable/rename.svg new file mode 100644 index 00000000..a585e264 --- /dev/null +++ b/launcher/resources/multimc/scalable/rename.svg @@ -0,0 +1,437 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/multimc/scalable/tag.svg b/launcher/resources/multimc/scalable/tag.svg new file mode 100644 index 00000000..81b5d545 --- /dev/null +++ b/launcher/resources/multimc/scalable/tag.svg @@ -0,0 +1,398 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From cca052ccc9d644c84384ceefe97bbce45381a9e2 Mon Sep 17 00:00:00 2001 From: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> Date: Mon, 14 Nov 2022 22:46:41 +0200 Subject: [PATCH 25/33] Restore QRC headers Signed-off-by: ADudeCalledLeo <7997354+Leo40Git@users.noreply.github.com> --- launcher/resources/OSX/OSX.qrc | 3 ++- launcher/resources/iOS/iOS.qrc | 3 ++- launcher/resources/pe_blue/pe_blue.qrc | 3 ++- launcher/resources/pe_colored/pe_colored.qrc | 3 ++- launcher/resources/pe_dark/pe_dark.qrc | 3 ++- launcher/resources/pe_light/pe_light.qrc | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/launcher/resources/OSX/OSX.qrc b/launcher/resources/OSX/OSX.qrc index 3f50d6cf..9d4511d1 100644 --- a/launcher/resources/OSX/OSX.qrc +++ b/launcher/resources/OSX/OSX.qrc @@ -1,4 +1,5 @@ - + + index.theme scalable/about.svg diff --git a/launcher/resources/iOS/iOS.qrc b/launcher/resources/iOS/iOS.qrc index d7044fbb..0b79efb2 100644 --- a/launcher/resources/iOS/iOS.qrc +++ b/launcher/resources/iOS/iOS.qrc @@ -1,4 +1,5 @@ - + + index.theme scalable/about.svg diff --git a/launcher/resources/pe_blue/pe_blue.qrc b/launcher/resources/pe_blue/pe_blue.qrc index dc40103a..639675f0 100644 --- a/launcher/resources/pe_blue/pe_blue.qrc +++ b/launcher/resources/pe_blue/pe_blue.qrc @@ -1,4 +1,5 @@ - + + index.theme scalable/about.svg diff --git a/launcher/resources/pe_colored/pe_colored.qrc b/launcher/resources/pe_colored/pe_colored.qrc index bd1af6ff..fac58da8 100644 --- a/launcher/resources/pe_colored/pe_colored.qrc +++ b/launcher/resources/pe_colored/pe_colored.qrc @@ -1,4 +1,5 @@ - + + index.theme scalable/about.svg diff --git a/launcher/resources/pe_dark/pe_dark.qrc b/launcher/resources/pe_dark/pe_dark.qrc index 05ef7e93..c0c6ee6c 100644 --- a/launcher/resources/pe_dark/pe_dark.qrc +++ b/launcher/resources/pe_dark/pe_dark.qrc @@ -1,4 +1,5 @@ - + + index.theme scalable/about.svg diff --git a/launcher/resources/pe_light/pe_light.qrc b/launcher/resources/pe_light/pe_light.qrc index 6acca230..bd6a2496 100644 --- a/launcher/resources/pe_light/pe_light.qrc +++ b/launcher/resources/pe_light/pe_light.qrc @@ -1,4 +1,5 @@ - + + index.theme scalable/about.svg From f601135cc0154236e3b26b2850f0cf633bcef2f8 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sun, 20 Nov 2022 23:49:11 +0100 Subject: [PATCH 26/33] refactor(nix): synchronize changes from nixpkgs Signed-off-by: Sefa Eyeoglu --- flake.nix | 4 +-- nix/default.nix | 95 ++++++++++++++++++++++++------------------------- 2 files changed, 49 insertions(+), 50 deletions(-) diff --git a/flake.nix b/flake.nix index d4a25338..b1e07c91 100644 --- a/flake.nix +++ b/flake.nix @@ -23,8 +23,8 @@ pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system}); packagesFn = pkgs: rec { - prismlauncher = pkgs.libsForQt5.callPackage ./nix { inherit version self libnbtplusplus tomlplusplus; }; - prismlauncher-qt6 = pkgs.qt6Packages.callPackage ./nix { inherit version self libnbtplusplus tomlplusplus; }; + prismlauncher-qt5 = pkgs.libsForQt5.callPackage ./nix { inherit version self libnbtplusplus tomlplusplus; }; + prismlauncher = pkgs.qt6Packages.callPackage ./nix { inherit version self libnbtplusplus tomlplusplus; }; }; in { diff --git a/nix/default.nix b/nix/default.nix index c7fc7576..6050fd37 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -1,100 +1,99 @@ -{ stdenv -, lib -, fetchFromGitHub +{ lib +, stdenv , cmake -, ninja , jdk8 , jdk -, ghc_filesystem , zlib , file , wrapQtAppsHook , xorg , libpulseaudio , qtbase -, quazip +, qtsvg +, qtwayland , libGL -, msaClientID ? "" -, extraJDKs ? [ ] +, quazip +, glfw +, openal , extra-cmake-modules +, ghc_filesystem +, msaClientID ? "" +, jdks ? [ jdk jdk8 ] # flake , self , version , libnbtplusplus , tomlplusplus -, enableLTO ? false }: -let - # Libraries required to run Minecraft - libpath = with xorg; lib.makeLibraryPath [ - libX11 - libXext - libXcursor - libXrandr - libXxf86vm - libpulseaudio - libGL - ]; - - # This variable will be passed to Minecraft by Prism Launcher - gameLibraryPath = libpath + ":/run/opengl-driver/lib"; - - javaPaths = lib.makeSearchPath "bin/java" ([ jdk jdk8 ] ++ extraJDKs); -in - stdenv.mkDerivation rec { pname = "prismlauncher"; inherit version; src = lib.cleanSource self; - nativeBuildInputs = [ cmake extra-cmake-modules ninja jdk ghc_filesystem file wrapQtAppsHook ]; - buildInputs = [ qtbase quazip zlib ]; + nativeBuildInputs = [ extra-cmake-modules cmake file jdk wrapQtAppsHook ]; + buildInputs = [ + qtbase + qtsvg + zlib + quazip + ghc_filesystem + ] ++ lib.optional (lib.versionAtLeast qtbase.version "6") qtwayland; + cmakeFlags = lib.optionals (msaClientID != "") [ "-DLauncher_MSA_CLIENT_ID=${msaClientID}" ] + ++ lib.optionals (lib.versionAtLeast qtbase.version "6") [ "-DLauncher_QT_VERSION_MAJOR=6" ]; dontWrapQtApps = true; postUnpack = '' - # Copy libnbtplusplus rm -rf source/libraries/libnbtplusplus mkdir source/libraries/libnbtplusplus ln -s ${libnbtplusplus}/* source/libraries/libnbtplusplus chmod -R +r+w source/libraries/libnbtplusplus - # Copy tomlplusplus + chown -R $USER: source/libraries/libnbtplusplus rm -rf source/libraries/tomlplusplus mkdir source/libraries/tomlplusplus ln -s ${tomlplusplus}/* source/libraries/tomlplusplus chmod -R +r+w source/libraries/tomlplusplus + chown -R $USER: source/libraries/tomlplusplus ''; - cmakeFlags = [ - "-GNinja" - "-DLauncher_QT_VERSION_MAJOR=${lib.versions.major qtbase.version}" - ] ++ lib.optionals enableLTO [ "-DENABLE_LTO=on" ] - ++ lib.optionals (msaClientID != "") [ "-DLauncher_MSA_CLIENT_ID=${msaClientID}" ]; + postInstall = + let + libpath = with xorg; + lib.makeLibraryPath [ + libX11 + libXext + libXcursor + libXrandr + libXxf86vm + libpulseaudio + libGL + glfw + openal + stdenv.cc.cc.lib + ]; + in + '' + # xorg.xrandr needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128 + wrapQtApp $out/bin/prismlauncher \ + --set LD_LIBRARY_PATH /run/opengl-driver/lib:${libpath} \ + --prefix PRISMLAUNCHER_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks} \ + --prefix PATH : ${lib.makeBinPath [xorg.xrandr]} + ''; - # we have to check if the system is NixOS before adding stdenv.cc.cc.lib (#923) - postInstall = '' - # xorg.xrandr needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128 - wrapQtApp $out/bin/prismlauncher \ - --run '[ -f /etc/NIXOS ] && export LD_LIBRARY_PATH="${stdenv.cc.cc.lib}/lib:$LD_LIBRARY_PATH"' \ - --prefix LD_LIBRARY_PATH : ${gameLibraryPath} \ - --prefix PRISMLAUNCHER_JAVA_PATHS : ${javaPaths} \ - --prefix PATH : ${lib.makeBinPath [ xorg.xrandr ]} - ''; meta = with lib; { homepage = "https://prismlauncher.org/"; - downloadPage = "https://prismlauncher.org/download/"; - changelog = "https://github.com/PrismLauncher/PrismLauncher/releases"; description = "A free, open source launcher for Minecraft"; longDescription = '' Allows you to have multiple, separate instances of Minecraft (each with their own mods, texture packs, saves, etc) and helps you manage them and their associated options with a simple interface. ''; - platforms = platforms.unix; + platforms = platforms.linux; + changelog = "https://github.com/PrismLauncher/PrismLauncher/releases/tag/${version}"; license = licenses.gpl3Only; maintainers = with maintainers; [ minion3665 Scrumplex ]; }; From 70a11935a85325f0cf896eb301bbc342a6d3e3c8 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Mon, 21 Nov 2022 00:02:41 +0100 Subject: [PATCH 27/33] feat(actions): add Nix build Signed-off-by: Sefa Eyeoglu --- .github/workflows/build.yml | 33 ++++++++++++++++++++++++++++ .github/workflows/trigger_builds.yml | 1 + 2 files changed, 34 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c0e5b50a..d41dfdc2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,6 +15,9 @@ on: SPARKLE_ED25519_KEY: description: Private key for signing Sparkle updates required: false + CACHIX_AUTH_TOKEN: + description: Private token for authenticating against Cachix cache + required: false jobs: build: @@ -526,3 +529,33 @@ jobs: bundle: "Prism Launcher.flatpak" manifest-path: flatpak/org.prismlauncher.PrismLauncher.yml cache-key: flatpak-${{ github.sha }}-x86_64 + + nix: + runs-on: ubuntu-latest + strategy: + matrix: + package: + - prismlauncher + - prismlauncher-qt5 + steps: + - name: Clone repository + if: inputs.build_type == 'Debug' + uses: actions/checkout@v3 + with: + submodules: 'true' + - name: Install nix + if: inputs.build_type == 'Debug' + uses: cachix/install-nix-action@v18 + with: + install_url: https://nixos.org/nix/install + extra_nix_config: | + auto-optimise-store = true + experimental-features = nix-command flakes + - uses: cachix/cachix-action@v12 + if: inputs.build_type == 'Debug' + with: + name: prismlauncher + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + - name: Build + if: inputs.build_type == 'Debug' + run: nix build .#${{ matrix.package }} --print-build-logs diff --git a/.github/workflows/trigger_builds.yml b/.github/workflows/trigger_builds.yml index 44751fbc..cf299744 100644 --- a/.github/workflows/trigger_builds.yml +++ b/.github/workflows/trigger_builds.yml @@ -33,3 +33,4 @@ jobs: is_qt_cached: true secrets: SPARKLE_ED25519_KEY: ${{ secrets.SPARKLE_ED25519_KEY }} + CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }} From c1b3a3adb4be8b31c23ded08f51a477bfc36d9a3 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Mon, 21 Nov 2022 11:43:46 +0100 Subject: [PATCH 28/33] fix(actions): don't ignore nix files Signed-off-by: Sefa Eyeoglu --- .github/workflows/trigger_builds.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/trigger_builds.yml b/.github/workflows/trigger_builds.yml index cf299744..a08193a0 100644 --- a/.github/workflows/trigger_builds.yml +++ b/.github/workflows/trigger_builds.yml @@ -8,7 +8,6 @@ on: - '**.md' - '**/LICENSE' - 'flake.lock' - - '**.nix' - 'packages/**' - '.github/ISSUE_TEMPLATE/**' - '.markdownlint**' @@ -17,7 +16,6 @@ on: - '**.md' - '**/LICENSE' - 'flake.lock' - - '**.nix' - 'packages/**' - '.github/ISSUE_TEMPLATE/**' - '.markdownlint**' From 4208c2c72a160896f63f44148c74cf24fc30d4b9 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Mon, 21 Nov 2022 15:47:15 +0100 Subject: [PATCH 29/33] fix: actually emit fileCopied Signed-off-by: Sefa Eyeoglu --- launcher/FileSystem.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 0c6527b1..987f4e74 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -188,6 +188,8 @@ bool copy::operator()(const QString& offset, bool dryRun) qDebug() << "Source file:" << src_path; qDebug() << "Destination file:" << dst_path; } + m_copied++; + emit fileCopied(relative_dst_path); }; // We can't use copy_opts::recursive because we need to take into account the From 980f03dd206d9e15ceb111839ebc615a493c790f Mon Sep 17 00:00:00 2001 From: TheLastRar Date: Tue, 22 Nov 2022 19:17:16 +0000 Subject: [PATCH 30/33] Fix: Launcher_FORCE_BUNDLED_LIBS Failing to find bundled zlib Signed-off-by: TheLastRar --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8fc0d326..f04b733b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -368,11 +368,11 @@ if(NOT ZLIB_FOUND) set(SKIP_INSTALL_ALL ON) add_subdirectory(libraries/zlib EXCLUDE_FROM_ALL) - set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libraries/zlib" "${CMAKE_CURRENT_BINARY_DIR}/libraries/zlib") + set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libraries/zlib" "${CMAKE_CURRENT_BINARY_DIR}/libraries/zlib" CACHE STRING "") set_target_properties(zlibstatic PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIR}") add_library(ZLIB::ZLIB ALIAS zlibstatic) - set(ZLIB_LIBRARY ZLIB::ZLIB) - set(ZLIB_FOUND true) + set(ZLIB_LIBRARY ZLIB::ZLIB CACHE STRING "zlib library name") + find_package(ZLIB REQUIRED) else() message(STATUS "Using system zlib") From 6a51eda36171d58cff9d66f4c7a2172f32fa2314 Mon Sep 17 00:00:00 2001 From: DioEgizio <83089242+DioEgizio@users.noreply.github.com> Date: Wed, 23 Nov 2022 19:53:55 +0100 Subject: [PATCH 31/33] fix: force bundled libs on win msvc Signed-off-by: DioEgizio <83089242+DioEgizio@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c0e5b50a..4dfb45d4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -230,7 +230,7 @@ jobs: - name: Configure CMake (Windows MSVC) if: runner.os == 'Windows' && matrix.msystem == '' run: | - cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DLauncher_BUILD_PLATFORM=${{ matrix.name }} -DLauncher_QT_VERSION_MAJOR=${{ matrix.qt_ver }} -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreadedDLL" -A${{ matrix.architecture}} + cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DLauncher_BUILD_PLATFORM=${{ matrix.name }} -DLauncher_QT_VERSION_MAJOR=${{ matrix.qt_ver }} -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreadedDLL" -A${{ matrix.architecture}} -DLauncher_FORCE_BUNDLED_LIBS=ON # https://github.com/ccache/ccache/wiki/MS-Visual-Studio (I coudn't figure out the compiler prefix) if ("${{ env.CCACHE_VAR }}") { From cbf4159c7e21c0dc70e36db5bbcc4162c72f31b5 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Fri, 25 Nov 2022 13:54:13 +0100 Subject: [PATCH 32/33] fix: add missing shortcut icons Signed-off-by: Sefa Eyeoglu --- .../resources/breeze_dark/breeze_dark.qrc | 1 + .../breeze_dark/scalable/shortcut.svg | 15 ++ .../resources/breeze_light/breeze_light.qrc | 1 + .../breeze_light/scalable/shortcut.svg | 15 ++ launcher/resources/flat/flat.qrc | 1 + launcher/resources/flat/scalable/shortcut.svg | 3 + launcher/resources/flat_white/flat_white.qrc | 1 + .../flat_white/scalable/shortcut.svg | 3 + launcher/resources/multimc/multimc.qrc | 3 +- .../resources/multimc/scalable/shortcut.svg | 157 ++++++++++++++++++ 10 files changed, 199 insertions(+), 1 deletion(-) create mode 100644 launcher/resources/breeze_dark/scalable/shortcut.svg create mode 100644 launcher/resources/breeze_light/scalable/shortcut.svg create mode 100644 launcher/resources/flat/scalable/shortcut.svg create mode 100644 launcher/resources/flat_white/scalable/shortcut.svg create mode 100644 launcher/resources/multimc/scalable/shortcut.svg diff --git a/launcher/resources/breeze_dark/breeze_dark.qrc b/launcher/resources/breeze_dark/breeze_dark.qrc index 4d7a69b2..97434abc 100644 --- a/launcher/resources/breeze_dark/breeze_dark.qrc +++ b/launcher/resources/breeze_dark/breeze_dark.qrc @@ -27,6 +27,7 @@ scalable/refresh.svg scalable/resourcepacks.svg scalable/shaderpacks.svg + scalable/shortcut.svg scalable/screenshots.svg scalable/settings.svg scalable/status-bad.svg diff --git a/launcher/resources/breeze_dark/scalable/shortcut.svg b/launcher/resources/breeze_dark/scalable/shortcut.svg new file mode 100644 index 00000000..2f24b8c0 --- /dev/null +++ b/launcher/resources/breeze_dark/scalable/shortcut.svg @@ -0,0 +1,15 @@ + + + + + + + + + diff --git a/launcher/resources/breeze_light/breeze_light.qrc b/launcher/resources/breeze_light/breeze_light.qrc index 7d9d99f5..6d868b18 100644 --- a/launcher/resources/breeze_light/breeze_light.qrc +++ b/launcher/resources/breeze_light/breeze_light.qrc @@ -27,6 +27,7 @@ scalable/refresh.svg scalable/resourcepacks.svg scalable/shaderpacks.svg + scalable/shortcut.svg scalable/screenshots.svg scalable/settings.svg scalable/status-bad.svg diff --git a/launcher/resources/breeze_light/scalable/shortcut.svg b/launcher/resources/breeze_light/scalable/shortcut.svg new file mode 100644 index 00000000..96def1f8 --- /dev/null +++ b/launcher/resources/breeze_light/scalable/shortcut.svg @@ -0,0 +1,15 @@ + + + + + + + + + diff --git a/launcher/resources/flat/flat.qrc b/launcher/resources/flat/flat.qrc index 508e0a9f..a846bd2d 100644 --- a/launcher/resources/flat/flat.qrc +++ b/launcher/resources/flat/flat.qrc @@ -35,6 +35,7 @@ scalable/screenshot-placeholder.svg scalable/screenshots.svg scalable/settings.svg + scalable/shortcut.svg scalable/star.svg scalable/status-bad.svg scalable/status-good.svg diff --git a/launcher/resources/flat/scalable/shortcut.svg b/launcher/resources/flat/scalable/shortcut.svg new file mode 100644 index 00000000..83878d19 --- /dev/null +++ b/launcher/resources/flat/scalable/shortcut.svg @@ -0,0 +1,3 @@ + + + diff --git a/launcher/resources/flat_white/flat_white.qrc b/launcher/resources/flat_white/flat_white.qrc index e11d6316..b0759d8f 100644 --- a/launcher/resources/flat_white/flat_white.qrc +++ b/launcher/resources/flat_white/flat_white.qrc @@ -35,6 +35,7 @@ scalable/screenshot-placeholder.svg scalable/screenshots.svg scalable/settings.svg + scalable/shortcut.svg scalable/star.svg scalable/status-bad.svg scalable/status-good.svg diff --git a/launcher/resources/flat_white/scalable/shortcut.svg b/launcher/resources/flat_white/scalable/shortcut.svg new file mode 100644 index 00000000..b419a77d --- /dev/null +++ b/launcher/resources/flat_white/scalable/shortcut.svg @@ -0,0 +1,3 @@ + + + diff --git a/launcher/resources/multimc/multimc.qrc b/launcher/resources/multimc/multimc.qrc index 270dd009..9741267c 100644 --- a/launcher/resources/multimc/multimc.qrc +++ b/launcher/resources/multimc/multimc.qrc @@ -313,10 +313,11 @@ scalable/instances/bee.svg scalable/instances/prismlauncher.svg - + scalable/delete.svg scalable/tag.svg scalable/rename.svg + scalable/shortcut.svg scalable/export.svg scalable/launch.svg diff --git a/launcher/resources/multimc/scalable/shortcut.svg b/launcher/resources/multimc/scalable/shortcut.svg new file mode 100644 index 00000000..549c3724 --- /dev/null +++ b/launcher/resources/multimc/scalable/shortcut.svg @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + From c90f2c3ac6d12624ac596a68cf5a9f4da92eb3f6 Mon Sep 17 00:00:00 2001 From: DioEgizio <83089242+DioEgizio@users.noreply.github.com> Date: Sat, 26 Nov 2022 15:05:08 +0100 Subject: [PATCH 33/33] fix: use monochrome icon for breeze Signed-off-by: DioEgizio <83089242+DioEgizio@users.noreply.github.com> --- .../breeze_dark/scalable/shortcut.svg | 31 ++++++++++--------- .../breeze_light/scalable/shortcut.svg | 31 ++++++++++--------- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/launcher/resources/breeze_dark/scalable/shortcut.svg b/launcher/resources/breeze_dark/scalable/shortcut.svg index 2f24b8c0..5559be1d 100644 --- a/launcher/resources/breeze_dark/scalable/shortcut.svg +++ b/launcher/resources/breeze_dark/scalable/shortcut.svg @@ -1,15 +1,18 @@ - - - - - - - - + + + + + + + diff --git a/launcher/resources/breeze_light/scalable/shortcut.svg b/launcher/resources/breeze_light/scalable/shortcut.svg index 96def1f8..426769d1 100644 --- a/launcher/resources/breeze_light/scalable/shortcut.svg +++ b/launcher/resources/breeze_light/scalable/shortcut.svg @@ -1,15 +1,18 @@ - - - - - - - - + + + + + + +