diff options
| author | liamwhite <liamwhite@users.noreply.github.com> | 2023-11-19 09:50:49 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-19 09:50:49 -0500 |
| commit | c08da2d6add4f8e6770d408ad8c3361886e55469 (patch) | |
| tree | 3a6fa7b115e9b2cd3ade1075ae5023b43c5b833b /src/yuzu/util | |
| parent | 445892079935d225be5eb08e326339c033c786a2 (diff) | |
| parent | c9038af29e05458bd2f647158cc2903132c4c560 (diff) | |
Merge pull request #11792 from boludoz/new-shortcut
Improved shortcut: add games in applist for Windows, question for sta…
Diffstat (limited to 'src/yuzu/util')
| -rw-r--r-- | src/yuzu/util/util.cpp | 12 | ||||
| -rw-r--r-- | src/yuzu/util/util.h | 3 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/yuzu/util/util.cpp b/src/yuzu/util/util.cpp index f2854c8ec..7b2a47496 100644 --- a/src/yuzu/util/util.cpp +++ b/src/yuzu/util/util.cpp @@ -42,7 +42,7 @@ QPixmap CreateCirclePixmapFromColor(const QColor& color) { return circle_pixmap; } -bool SaveIconToFile(const std::string_view path, const QImage& image) { +bool SaveIconToFile(const std::filesystem::path& icon_path, const QImage& image) { #if defined(WIN32) #pragma pack(push, 2) struct IconDir { @@ -73,7 +73,7 @@ bool SaveIconToFile(const std::string_view path, const QImage& image) { .id_count = static_cast<WORD>(scale_sizes.size()), }; - Common::FS::IOFile icon_file(path, Common::FS::FileAccessMode::Write, + Common::FS::IOFile icon_file(icon_path.string(), Common::FS::FileAccessMode::Write, Common::FS::FileType::BinaryFile); if (!icon_file.IsOpen()) { return false; @@ -135,6 +135,14 @@ bool SaveIconToFile(const std::string_view path, const QImage& image) { icon_file.Close(); return true; +#elif defined(__linux__) || defined(__FreeBSD__) + // Convert and write the icon as a PNG + if (!image.save(QString::fromStdString(icon_path.string()))) { + LOG_ERROR(Frontend, "Could not write icon as PNG to file"); + } else { + LOG_INFO(Frontend, "Wrote an icon to {}", icon_path.string()); + } + return true; #else return false; #endif diff --git a/src/yuzu/util/util.h b/src/yuzu/util/util.h index 09c14ce3f..4094cf6c2 100644 --- a/src/yuzu/util/util.h +++ b/src/yuzu/util/util.h @@ -3,6 +3,7 @@ #pragma once +#include <filesystem> #include <QFont> #include <QString> @@ -25,4 +26,4 @@ * @param image The image to save * @return bool If the operation succeeded */ -[[nodiscard]] bool SaveIconToFile(const std::string_view path, const QImage& image); +[[nodiscard]] bool SaveIconToFile(const std::filesystem::path& icon_path, const QImage& image); |
