From dd0c79ee5642695a39d5ff9d0e58e2f2b9f27534 Mon Sep 17 00:00:00 2001
From: John Preston <johnprestonmail@gmail.com>
Date: Sun, 7 Feb 2016 13:10:35 +0300
Subject: [PATCH] qt patch updated, os x tray icon fixed

---
 Telegram/_qtbase_5_5_1_patch.diff | 40 ++++++++++++++++++-------------
 1 file changed, 24 insertions(+), 16 deletions(-)

diff --git a/Telegram/_qtbase_5_5_1_patch.diff b/Telegram/_qtbase_5_5_1_patch.diff
index e8057f0b1..8447f44c4 100644
--- a/Telegram/_qtbase_5_5_1_patch.diff
+++ b/Telegram/_qtbase_5_5_1_patch.diff
@@ -282,7 +282,7 @@ index 112bb8e..45be6c6 100644
 +					}
 +				}
 +			}
-+
++			
 +			families << family;
          }
          populateFromPattern(pattern);
@@ -1149,7 +1149,7 @@ new file mode 100644
 index 0000000..b47d332
 --- /dev/null
 +++ b/src/plugins/platforminputcontexts/fcitx/fcitxqtinputcontextproxy.cpp
-@@ -0,0 +1,25 @@
+@@ -0,0 +1,26 @@
 +/*
 + * This file was generated by qdbusxml2cpp version 0.8
 + * Command line was: qdbusxml2cpp -N -p fcitxqtinputcontextproxy -c FcitxQtInputContextProxy interfaces/org.fcitx.Fcitx.InputContext.xml -i fcitxqtformattedpreedit.h -i fcitxqt_export.h
@@ -1175,6 +1175,7 @@ index 0000000..b47d332
 +FcitxQtInputContextProxy::~FcitxQtInputContextProxy()
 +{
 +}
++
 diff --git a/src/plugins/platforminputcontexts/fcitx/fcitxqtinputcontextproxy.h b/src/plugins/platforminputcontexts/fcitx/fcitxqtinputcontextproxy.h
 new file mode 100644
 index 0000000..19874dc
@@ -1493,7 +1494,7 @@ new file mode 100644
 index 0000000..068f4c2
 --- /dev/null
 +++ b/src/plugins/platforminputcontexts/fcitx/fcitxqtinputmethodproxy.cpp
-@@ -0,0 +1,25 @@
+@@ -0,0 +1,26 @@
 +/*
 + * This file was generated by qdbusxml2cpp version 0.8
 + * Command line was: qdbusxml2cpp -N -p fcitxqtinputmethodproxy -c FcitxQtInputMethodProxy interfaces/org.fcitx.Fcitx.InputMethod.xml -i fcitxqtinputmethoditem.h -i fcitxqt_export.h
@@ -1519,6 +1520,7 @@ index 0000000..068f4c2
 +FcitxQtInputMethodProxy::~FcitxQtInputMethodProxy()
 +{
 +}
++
 diff --git a/src/plugins/platforminputcontexts/fcitx/fcitxqtinputmethodproxy.h b/src/plugins/platforminputcontexts/fcitx/fcitxqtinputmethodproxy.h
 new file mode 100644
 index 0000000..7aa37e2
@@ -1917,7 +1919,7 @@ new file mode 100644
 index 0000000..7523a92
 --- /dev/null
 +++ b/src/plugins/platforminputcontexts/fcitx/fcitxqtkeyboardproxy.cpp
-@@ -0,0 +1,25 @@
+@@ -0,0 +1,26 @@
 +/*
 + * This file was generated by qdbusxml2cpp version 0.8
 + * Command line was: qdbusxml2cpp -N -p fcitxqtkeyboardproxy -c FcitxQtKeyboardProxy interfaces/org.fcitx.Fcitx.Keyboard.xml -i fcitxqtkeyboardlayout.h -i fcitxqt_export.h
@@ -1943,6 +1945,7 @@ index 0000000..7523a92
 +FcitxQtKeyboardProxy::~FcitxQtKeyboardProxy()
 +{
 +}
++
 diff --git a/src/plugins/platforminputcontexts/fcitx/fcitxqtkeyboardproxy.h b/src/plugins/platforminputcontexts/fcitx/fcitxqtkeyboardproxy.h
 new file mode 100644
 index 0000000..42a6561
@@ -11201,7 +11204,7 @@ index ca92103..f681b08 100644
          p.setCompositionMode(QPainter::CompositionMode_Source);
          const QVector<QRect> rects = region.rects();
 diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
-index 713758c..9a509b2 100755
+index 713758c..9b23ca2 100755
 --- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
 +++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
 @@ -94,6 +94,8 @@ QT_USE_NAMESPACE
@@ -11213,17 +11216,22 @@ index 713758c..9a509b2 100755
      QIcon icon;
      QT_MANGLE_NAMESPACE(QNSImageView) *imageCell;
  }
-@@ -197,7 +199,8 @@ void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon)
+@@ -197,8 +199,12 @@ void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon)
      // (device independent pixels). The menu height on past and
      // current OS X versions is 22 points. Provide some future-proofing
      // by deriving the icon height from the menu height.
 -    const int padding = 4;
+-    const int menuHeight = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
 +    // create a good os x tray icon
 +    const int padding = 0;
-     const int menuHeight = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
++    int menuHeight = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
++    if (menuHeight <= 0) {
++        menuHeight = 22;
++    }
      const int maxImageHeight = menuHeight - padding;
  
-@@ -207,8 +210,11 @@ void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon)
+     // Select pixmap based on the device pixel height. Ideally we would use
+@@ -207,8 +213,11 @@ void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon)
      // devicePixelRatio for the "best" screen on the system.
      qreal devicePixelRatio = qApp->devicePixelRatio();
      const int maxPixmapHeight = maxImageHeight * devicePixelRatio;
@@ -11236,7 +11244,7 @@ index 713758c..9a509b2 100755
          // 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
-@@ -224,9 +230,11 @@ void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon)
+@@ -224,9 +233,11 @@ void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon)
  
      // Handle SVG icons, which do not return anything for availableSizes().
      if (!selectedSize.isValid())
@@ -11250,7 +11258,7 @@ index 713758c..9a509b2 100755
  
      // Draw a low-resolution icon if there is not enough pixels for a retina
      // icon. This prevents showing a small icon on retina displays.
-@@ -373,6 +381,11 @@ QT_END_NAMESPACE
+@@ -373,6 +384,11 @@ QT_END_NAMESPACE
      Q_UNUSED(notification);
      down = NO;
  
@@ -11262,7 +11270,7 @@ index 713758c..9a509b2 100755
      [self setNeedsDisplay:YES];
  }
  
-@@ -382,6 +395,10 @@ QT_END_NAMESPACE
+@@ -382,6 +398,10 @@ QT_END_NAMESPACE
      int clickCount = [mouseEvent clickCount];
      [self setNeedsDisplay:YES];
  
@@ -11273,7 +11281,7 @@ index 713758c..9a509b2 100755
      if (clickCount == 2) {
          [self menuTrackingDone:nil];
          [parent doubleClickSelector:self];
-@@ -398,6 +415,11 @@ QT_END_NAMESPACE
+@@ -398,6 +418,11 @@ QT_END_NAMESPACE
  -(void)mouseUp:(NSEvent *)mouseEvent
  {
      Q_UNUSED(mouseEvent);
@@ -11285,7 +11293,7 @@ index 713758c..9a509b2 100755
      [self menuTrackingDone:nil];
  }
  
-@@ -409,6 +431,11 @@ QT_END_NAMESPACE
+@@ -409,6 +434,11 @@ QT_END_NAMESPACE
  -(void)rightMouseUp:(NSEvent *)mouseEvent
  {
      Q_UNUSED(mouseEvent);
@@ -11297,7 +11305,7 @@ index 713758c..9a509b2 100755
      [self menuTrackingDone:nil];
  }
  
-@@ -424,7 +451,8 @@ QT_END_NAMESPACE
+@@ -424,7 +454,8 @@ QT_END_NAMESPACE
  }
  
  -(void)drawRect:(NSRect)rect {
@@ -11307,7 +11315,7 @@ index 713758c..9a509b2 100755
      [super drawRect:rect];
  }
  @end
-@@ -436,7 +464,9 @@ QT_END_NAMESPACE
+@@ -436,7 +467,9 @@ QT_END_NAMESPACE
      self = [super init];
      if (self) {
          item = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] retain];
@@ -11317,7 +11325,7 @@ index 713758c..9a509b2 100755
          systray = sys;
          imageCell = [[QNSImageView alloc] initWithParent:self];
          [item setView: imageCell];
-@@ -481,6 +511,8 @@ QT_END_NAMESPACE
+@@ -481,6 +514,8 @@ QT_END_NAMESPACE
           selector:@selector(menuTrackingDone:)
               name:NSMenuDidEndTrackingNotification
                   object:m];