2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-03 08:05:12 +00:00

Allow to set custom app icon on macOS.

This commit is contained in:
John Preston
2022-02-08 00:23:26 +03:00
parent d89d8b09da
commit 666251f23e
2 changed files with 25 additions and 1 deletions

View File

@@ -31,6 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "settings/settings_common.h"
#include "api/api_updates.h"
#include "base/qt/qt_common_adapters.h"
#include "base/custom_app_icon.h"
#include "zlib.h"
@@ -283,6 +284,29 @@ auto GenerateCodes() {
Ui::Toast::Show(now ? "Testing chat theme colors!" : "Not testing..");
});
#ifdef Q_OS_MAC
codes.emplace(qsl("customicon"), [](SessionController *window) {
const auto iconFilters = qsl("Icon files (*.icns *.png);;") + FileDialog::AllFilesFilter();
const auto change = [](const QString &path) {
const auto success = path.isEmpty()
? base::ClearCustomAppIcon()
: base::SetCustomAppIcon(path);
Ui::Toast::Show(success
? (path.isEmpty()
? "Icon cleared. Restarting the Dock."
: "Icon updated. Restarting the Dock.")
: (path.isEmpty()
? "Icon clear failed. See log.txt for details."
: "Icon update failed. See log.txt for details."));
};
FileDialog::GetOpenPath(Core::App().getFileDialogParent(), "Choose custom icon", iconFilters, [=](const FileDialog::OpenResult &result) {
change(result.paths.isEmpty() ? QString() : result.paths.front());
}, [=] {
change(QString());
});
});
#endif // Q_OS_MAC
return codes;
}