mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 14:38:15 +00:00
Update icon on macOS, allow changing back.
This commit is contained in:
@@ -852,6 +852,10 @@ void NewVersionLaunched(int oldVersion) {
|
||||
}
|
||||
}
|
||||
|
||||
QImage DefaultApplicationIcon() {
|
||||
return Window::Logo();
|
||||
}
|
||||
|
||||
namespace ThirdParty {
|
||||
|
||||
void start() {
|
||||
|
@@ -36,6 +36,51 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include <mach-o/dyld.h>
|
||||
#include <AVFoundation/AVFoundation.h>
|
||||
|
||||
namespace {
|
||||
|
||||
[[nodiscard]] QImage ImageFromNS(NSImage *icon) {
|
||||
CGImageRef image = [icon CGImageForProposedRect:NULL context:nil hints:nil];
|
||||
|
||||
const int width = CGImageGetWidth(image);
|
||||
const int height = CGImageGetHeight(image);
|
||||
auto result = QImage(width, height, QImage::Format_ARGB32_Premultiplied);
|
||||
result.fill(Qt::transparent);
|
||||
|
||||
CGColorSpaceRef space = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
|
||||
CGBitmapInfo info = CGBitmapInfo(kCGImageAlphaPremultipliedFirst) | kCGBitmapByteOrder32Host;
|
||||
CGContextRef context = CGBitmapContextCreate(
|
||||
result.bits(),
|
||||
width,
|
||||
height,
|
||||
8,
|
||||
result.bytesPerLine(),
|
||||
space,
|
||||
info);
|
||||
|
||||
CGRect rect = CGRectMake(0, 0, width, height);
|
||||
CGContextDrawImage(context, rect, image);
|
||||
|
||||
CFRelease(space);
|
||||
CFRelease(context);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
[[nodiscard]] QImage ResolveBundleIconDefault() {
|
||||
NSString *path = [[NSBundle mainBundle] bundlePath];
|
||||
NSString *icon = [path stringByAppendingString:@"/Contents/Resources/Icon.icns"];
|
||||
NSImage *image = [[NSImage alloc] initWithContentsOfFile:icon];
|
||||
if (!image) {
|
||||
return Window::Logo();
|
||||
}
|
||||
|
||||
auto result = ImageFromNS(image);
|
||||
[image release];
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
QString psAppDataPath() {
|
||||
return objc_appDataPath();
|
||||
}
|
||||
@@ -188,6 +233,11 @@ bool AutostartSkip() {
|
||||
void NewVersionLaunched(int oldVersion) {
|
||||
}
|
||||
|
||||
QImage DefaultApplicationIcon() {
|
||||
static auto result = ResolveBundleIconDefault();
|
||||
return result;
|
||||
}
|
||||
|
||||
bool PreventsQuit(Core::QuitReason reason) {
|
||||
// Thanks Chromium, see
|
||||
// chromium.org/developers/design-documents/confirm-to-quit-experiment
|
||||
|
@@ -47,6 +47,8 @@ bool SkipTaskbarSupported();
|
||||
void WriteCrashDumpDetails();
|
||||
void NewVersionLaunched(int oldVersion);
|
||||
|
||||
[[nodiscard]] QImage DefaultApplicationIcon();
|
||||
|
||||
[[nodiscard]] bool PreventsQuit(Core::QuitReason reason);
|
||||
|
||||
[[nodiscard]] std::optional<bool> IsDarkMode();
|
||||
|
@@ -651,6 +651,10 @@ void NewVersionLaunched(int oldVersion) {
|
||||
}
|
||||
}
|
||||
|
||||
QImage DefaultApplicationIcon() {
|
||||
return Window::Logo();
|
||||
}
|
||||
|
||||
} // namespace Platform
|
||||
|
||||
void psSendToMenu(bool send, bool silent) {
|
||||
|
Reference in New Issue
Block a user