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;
}

@ -1 +1 @@
Subproject commit eb631e9f8cd36d2e969ed490e34560e5d87f5a83
Subproject commit 2aebd29afcad5929bde456dfcd3bf71a7bf25760