diff options
author | Ameer J <52414509+ameerj@users.noreply.github.com> | 2023-11-26 21:08:53 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-26 21:08:53 -0500 |
commit | 1d11fe00a3000efbf6a0a4bb690e0d544a1b7b4a (patch) | |
tree | c219aacab776c0a1e3956614b60a01fa2f6164cb /src/yuzu/util/util.cpp | |
parent | 75c5be55af3e0db249cb1bb0c0dd1de6e326849d (diff) | |
parent | f21340f7aa60296c7b56e293b5f870b7efd3807d (diff) |
Merge branch 'master' into ssbo-align
Diffstat (limited to 'src/yuzu/util/util.cpp')
-rw-r--r-- | src/yuzu/util/util.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/yuzu/util/util.cpp b/src/yuzu/util/util.cpp index f2854c8ec..e22cf84bf 100644 --- a/src/yuzu/util/util.cpp +++ b/src/yuzu/util/util.cpp @@ -4,7 +4,10 @@ #include <array> #include <cmath> #include <QPainter> + +#include "common/logging/log.h" #include "yuzu/util/util.h" + #ifdef _WIN32 #include <windows.h> #include "common/fs/file.h" @@ -42,7 +45,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 +76,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 +138,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 |