From 117de5a1f9e845489a563b3e9947dc8bbb2eed24 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 27 Oct 2020 13:32:09 +0300 Subject: [PATCH] Build macOS version with Qt 5.15.1. --- .../media/view/media_view_overlay_widget.cpp | 6 +++ .../platform/mac/notifications_manager_mac.mm | 4 +- .../platform/mac/specific_mac_p.mm | 5 +- .../mac/touchbar/items/mac_scrubber_item.mm | 50 ++++++++++--------- .../mac/touchbar/mac_touchbar_audio.mm | 1 - .../mac/touchbar/mac_touchbar_common.mm | 11 ++-- docs/building-xcode.md | 10 ++-- 7 files changed, 44 insertions(+), 43 deletions(-) diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index eff607fcb4..e3ce5df7b2 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -350,6 +350,12 @@ OverlayWidget::OverlayWidget() if (Platform::IsLinux()) { setWindowFlags(Qt::FramelessWindowHint | Qt::MaximizeUsingFullscreenGeometryHint); + } else if (Platform::IsMac()) { + // Without Qt::Tool starting with Qt 5.15.1 this widget + // when being opened from a fullscreen main window was + // opening not as overlay over the main window, but as + // a separate fullscreen window with a separate space. + setWindowFlags(Qt::FramelessWindowHint | Qt::Tool); } else { setWindowFlags(Qt::FramelessWindowHint); } diff --git a/Telegram/SourceFiles/platform/mac/notifications_manager_mac.mm b/Telegram/SourceFiles/platform/mac/notifications_manager_mac.mm index 1bda44df90..827954675c 100644 --- a/Telegram/SourceFiles/platform/mac/notifications_manager_mac.mm +++ b/Telegram/SourceFiles/platform/mac/notifications_manager_mac.mm @@ -47,8 +47,6 @@ using Manager = Platform::Notifications::Manager; } // namespace -NSImage *qt_mac_create_nsimage(const QPixmap &pm); - @interface NotificationDelegate : NSObject { } @@ -267,7 +265,7 @@ void Manager::Private::showNotification( : peer->isRepliesChat() ? Ui::EmptyUserpic::GenerateRepliesMessages(st::notifyMacPhotoSize) : peer->genUserpic(userpicView, st::notifyMacPhotoSize); - NSImage *img = [qt_mac_create_nsimage(userpic) autorelease]; + NSImage *img = Q2NSImage(userpic.toImage()); [notification setContentImage:img]; } diff --git a/Telegram/SourceFiles/platform/mac/specific_mac_p.mm b/Telegram/SourceFiles/platform/mac/specific_mac_p.mm index b4208a0427..e53afe4243 100644 --- a/Telegram/SourceFiles/platform/mac/specific_mac_p.mm +++ b/Telegram/SourceFiles/platform/mac/specific_mac_p.mm @@ -39,8 +39,6 @@ constexpr auto kIgnoreActivationTimeoutMs = 500; } // namespace -NSImage *qt_mac_create_nsimage(const QPixmap &pm); - using Platform::Q2NSString; using Platform::NS2QString; @@ -214,10 +212,9 @@ void SetApplicationIcon(const QIcon &icon) { if (!icon.isNull()) { auto pixmap = icon.pixmap(1024, 1024); pixmap.setDevicePixelRatio(cRetinaFactor()); - image = static_cast(qt_mac_create_nsimage(pixmap)); + image = Q2NSImage(pixmap.toImage()); } [[NSApplication sharedApplication] setApplicationIconImage:image]; - [image release]; } } // namespace Platform diff --git a/Telegram/SourceFiles/platform/mac/touchbar/items/mac_scrubber_item.mm b/Telegram/SourceFiles/platform/mac/touchbar/items/mac_scrubber_item.mm index 0d0395972b..95f6cdea0b 100644 --- a/Telegram/SourceFiles/platform/mac/touchbar/items/mac_scrubber_item.mm +++ b/Telegram/SourceFiles/platform/mac/touchbar/items/mac_scrubber_item.mm @@ -43,7 +43,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #import #import -NSImage *qt_mac_create_nsimage(const QPixmap &pm); using TouchBar::kCircleDiameter; using TouchBar::CreateNSImageFromStyleIcon; @@ -96,32 +95,32 @@ struct PickerScrubberItem { } void updateThumbnail() { - if (!document || !qpixmap.isNull()) { + if (!document || !image.isNull()) { return; } - const auto image = mediaView->getStickerSmall(); - if (!image) { + const auto sticker = mediaView->getStickerSmall(); + if (!sticker) { return; } - const auto size = image->size() + const auto size = sticker->size() .scaled(kCircleDiameter, kCircleDiameter, Qt::KeepAspectRatio); - qpixmap = image->pixSingle( + image = sticker->pixSingle( size.width(), size.height(), kCircleDiameter, kCircleDiameter, - ImageRoundRadius::None); + ImageRoundRadius::None).toImage(); } bool isStickerLoaded() const { - return !qpixmap.isNull(); + return !image.isNull(); } QString title = QString(); DocumentData *document = nullptr; std::shared_ptr mediaView = nullptr; - QPixmap qpixmap; + QImage image; EmojiPtr emoji = nullptr; }; @@ -140,21 +139,25 @@ struct PickerScrubberItemsHolder { }; using Platform::Q2NSString; +using Platform::Q2NSImage; NSImage *CreateNSImageFromEmoji(EmojiPtr emoji) { - const auto s = kIdealIconSize * cIntRetinaFactor(); - auto pixmap = QPixmap(s, s); - pixmap.setDevicePixelRatio(cRetinaFactor()); - pixmap.fill(Qt::black); - Painter paint(&pixmap); - PainterHighQualityEnabler hq(paint); - Ui::Emoji::Draw( - paint, - std::move(emoji), - Ui::Emoji::GetSizeTouchbar(), - 0, - 0); - return [qt_mac_create_nsimage(pixmap) autorelease]; + auto image = QImage( + QSize(kIdealIconSize, kIdealIconSize) * cIntRetinaFactor(), + QImage::Format_ARGB32_Premultiplied); + image.setDevicePixelRatio(cRetinaFactor()); + image.fill(Qt::black); + { + Painter paint(&image); + PainterHighQualityEnabler hq(paint); + Ui::Emoji::Draw( + paint, + emoji, + Ui::Emoji::GetSizeTouchbar(), + 0, + 0); + } + return Q2NSImage(image); } auto ActiveChat(not_null controller) { @@ -421,8 +424,7 @@ void AppendEmojiPacks( PickerScrubberItemView *itemView = [scrubber makeItemWithIdentifier:kStickerItemIdentifier owner:self]; - itemView.imageView.image = [qt_mac_create_nsimage(item.qpixmap) - autorelease]; + itemView.imageView.image = Q2NSImage(item.image); itemView->documentId = document->id; return itemView; } else if (const auto emoji = item.emoji) { diff --git a/Telegram/SourceFiles/platform/mac/touchbar/mac_touchbar_audio.mm b/Telegram/SourceFiles/platform/mac/touchbar/mac_touchbar_audio.mm index 3fde9b0c6a..decdef0ed6 100644 --- a/Telegram/SourceFiles/platform/mac/touchbar/mac_touchbar_audio.mm +++ b/Telegram/SourceFiles/platform/mac/touchbar/mac_touchbar_audio.mm @@ -20,7 +20,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #import #import -NSImage *qt_mac_create_nsimage(const QPixmap &pm); using TouchBar::kCircleDiameter; using TouchBar::CreateNSImageFromStyleIcon; diff --git a/Telegram/SourceFiles/platform/mac/touchbar/mac_touchbar_common.mm b/Telegram/SourceFiles/platform/mac/touchbar/mac_touchbar_common.mm index a7954218c7..7a30c4875a 100644 --- a/Telegram/SourceFiles/platform/mac/touchbar/mac_touchbar_common.mm +++ b/Telegram/SourceFiles/platform/mac/touchbar/mac_touchbar_common.mm @@ -9,9 +9,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #ifndef OS_OSX -#import +#include "base/platform/mac/base_utilities_mac.h" -NSImage *qt_mac_create_nsimage(const QPixmap &pm); +#import namespace TouchBar { @@ -21,10 +21,9 @@ int WidthFromString(NSString *s) { } NSImage *CreateNSImageFromStyleIcon(const style::icon &icon, int size) { - const auto instance = icon.instance(QColor(255, 255, 255, 255), 100); - auto pixmap = QPixmap::fromImage(instance); - pixmap.setDevicePixelRatio(cRetinaFactor()); - NSImage *image = [qt_mac_create_nsimage(pixmap) autorelease]; + auto instance = icon.instance(QColor(255, 255, 255, 255), 100); + instance.setDevicePixelRatio(cRetinaFactor()); + NSImage *image = Platform::Q2NSImage(instance); [image setSize:NSMakeSize(size, size)]; return image; } diff --git a/docs/building-xcode.md b/docs/building-xcode.md index f3a599b62a..f56d70158d 100644 --- a/docs/building-xcode.md +++ b/docs/building-xcode.md @@ -254,16 +254,16 @@ Go to ***BuildPath*** and run ninja -C out/Release cd .. - git clone git://code.qt.io/qt/qt5.git qt_5_12_8 - cd qt_5_12_8 + git clone git://code.qt.io/qt/qt5.git qt_5_15_1 + cd qt_5_15_1 perl init-repository --module-subset=qtbase,qtimageformats - git checkout v5.12.8 + git checkout v5.15.1 git submodule update qtbase qtimageformats cd qtbase - find ../../patches/qtbase_5_12_8 -type f -print0 | sort -z | xargs -0 git apply + find ../../patches/qtbase_5_15_1 -type f -print0 | sort -z | xargs -0 git apply cd .. - ./configure -prefix "/usr/local/desktop-app/Qt-5.12.8" \ + ./configure -prefix "/usr/local/desktop-app/Qt-5.15.1" \ -debug-and-release \ -force-debug-info \ -opensource \