mirror of
https://github.com/nextcloud/desktop.git
synced 2024-12-16 10:41:34 +03:00
115 lines
4.6 KiB
Diff
115 lines
4.6 KiB
Diff
From ee7fea33383726f0bb72e8082a357820e3ee3675 Mon Sep 17 00:00:00 2001
|
|
From: Jocelyn Turcotte <jturcotte@woboq.com>
|
|
Date: Tue, 24 Feb 2015 17:02:02 +0100
|
|
Subject: [PATCH] OSX Fix disapearing tray icon
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
It would happen together with an error:
|
|
QPainter::begin: Paint device returned engine == 0
|
|
and would be caused by the size provided to QIcon::pixmap being empty,
|
|
itself caused by the availableSizes list being empty for the Selected
|
|
mode.
|
|
|
|
This bug was most often hidden by the fact that the Selected icon mode
|
|
was not triggered properly since we usually only set menuVisible after
|
|
calling updateIcon, and most of the time when it did, we would overwrite
|
|
it right after with a Normal mode icon.
|
|
|
|
Fix the issue by disabling the broken feature completely since the
|
|
default Selected icon is grayed out while tray icons are now usually
|
|
black (or white when selected). To support the dark menu bar mode on
|
|
10.10 we'll need to use NSImage's setTemplate anyway and that
|
|
knowing in advance if we can invert the colors ourselves would also
|
|
better solve the menuVisible usecase.
|
|
|
|
Task-number: QTBUG-42910
|
|
Change-Id: If9ec9659af28ecceb841bfc2f11721e6029fe891
|
|
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
|
|
---
|
|
src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm | 17 +++--------------
|
|
1 file changed, 3 insertions(+), 14 deletions(-)
|
|
|
|
diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
|
|
index 8a35705..d366a3c 100755
|
|
--- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
|
|
+++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
|
|
@@ -102,7 +102,6 @@ QT_USE_NAMESPACE
|
|
QCocoaSystemTrayIcon *systray;
|
|
NSStatusItem *item;
|
|
QCocoaMenu *menu;
|
|
- bool menuVisible;
|
|
QIcon icon;
|
|
QT_MANGLE_NAMESPACE(QNSImageView) *imageCell;
|
|
}
|
|
@@ -202,8 +201,6 @@ void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon)
|
|
|
|
m_sys->item->icon = icon;
|
|
|
|
- const bool menuVisible = m_sys->item->menu && m_sys->item->menuVisible;
|
|
-
|
|
// The reccomended maximum title bar icon height is 18 points
|
|
// (device independent pixels). The menu height on past and
|
|
// current OS X versions is 22 points. Provide some future-proofing
|
|
@@ -218,9 +215,8 @@ void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon)
|
|
// devicePixelRatio for the "best" screen on the system.
|
|
qreal devicePixelRatio = qApp->devicePixelRatio();
|
|
const int maxPixmapHeight = maxImageHeight * devicePixelRatio;
|
|
- const QIcon::Mode mode = menuVisible ? QIcon::Selected : QIcon::Normal;
|
|
QSize selectedSize;
|
|
- Q_FOREACH (const QSize& size, sortByHeight(icon.availableSizes(mode))) {
|
|
+ Q_FOREACH (const QSize& size, sortByHeight(icon.availableSizes())) {
|
|
// Select a pixmap based on the height. We want the largest pixmap
|
|
// with a height smaller or equal to maxPixmapHeight. The pixmap
|
|
// may rectangular; assume it has a reasonable size. If there is
|
|
@@ -236,9 +232,9 @@ void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon)
|
|
|
|
// Handle SVG icons, which do not return anything for availableSizes().
|
|
if (!selectedSize.isValid())
|
|
- selectedSize = icon.actualSize(QSize(maxPixmapHeight, maxPixmapHeight), mode);
|
|
+ selectedSize = icon.actualSize(QSize(maxPixmapHeight, maxPixmapHeight));
|
|
|
|
- QPixmap pixmap = icon.pixmap(selectedSize, mode);
|
|
+ QPixmap pixmap = icon.pixmap(selectedSize);
|
|
|
|
// Draw a low-resolution icon if there is not enough pixels for a retina
|
|
// icon. This prevents showing a small icon on retina displays.
|
|
@@ -385,9 +381,6 @@ QT_END_NAMESPACE
|
|
Q_UNUSED(notification);
|
|
down = NO;
|
|
|
|
- parent->systray->updateIcon(parent->icon);
|
|
- parent->menuVisible = false;
|
|
-
|
|
[self setNeedsDisplay:YES];
|
|
}
|
|
|
|
@@ -397,8 +390,6 @@ QT_END_NAMESPACE
|
|
int clickCount = [mouseEvent clickCount];
|
|
[self setNeedsDisplay:YES];
|
|
|
|
- parent->systray->updateIcon(parent->icon);
|
|
-
|
|
if (clickCount == 2) {
|
|
[self menuTrackingDone:nil];
|
|
[parent doubleClickSelector:self];
|
|
@@ -454,7 +445,6 @@ QT_END_NAMESPACE
|
|
if (self) {
|
|
item = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] retain];
|
|
menu = 0;
|
|
- menuVisible = false;
|
|
systray = sys;
|
|
imageCell = [[QNSImageView alloc] initWithParent:self];
|
|
[item setView: imageCell];
|
|
@@ -498,7 +488,6 @@ QT_END_NAMESPACE
|
|
selector:@selector(menuTrackingDone:)
|
|
name:NSMenuDidEndTrackingNotification
|
|
object:m];
|
|
- menuVisible = true;
|
|
[item popUpStatusItemMenu: m];
|
|
}
|
|
}
|
|
--
|
|
1.9.1
|
|
|