diff --git a/src/qcocoa-qpa/README.ALT b/src/qcocoa-qpa/README.ALT index 0b1796f..434a447 100644 --- a/src/qcocoa-qpa/README.ALT +++ b/src/qcocoa-qpa/README.ALT @@ -1,375 +1,383 @@ +20171219 : upstream head (5.9): b0938cb6c1fa29ec2d2a4fb9273e515cd0d6c08e + src/plugins/platforms/cocoa/qcocoamenuloader.mm | 8 +- +patch: patches/26-sync-upstream-171219.diff +Changes: git log 6a9d076e87f0c8aa4fb49bbcc2f56eefd85af2e3..b0938cb6c1fa29ec2d2a4fb9273e515cd0d6c08e src/plugins/platforms/cocoa +commit 29104c85db53e7c0c0aaf3fe78f84b737fce4886 + Cocoa: Disable “Hide” menu item on open popups + + 20171126 : upstream head (5.9): 6a9d076e87f0c8aa4fb49bbcc2f56eefd85af2e3 / v5.9.3-43-g6a9d076 src/plugins/platforms/cocoa/qcocoamenu.h | 2 + src/plugins/platforms/cocoa/qcocoamenu.mm | 16 ++- src/plugins/platforms/cocoa/qcocoamenubar.h | 2 + src/plugins/platforms/cocoa/qcocoamenubar.mm | 11 +- src/plugins/platforms/cocoa/qcocoamenuitem.mm | 4 - src/plugins/platforms/cocoa/qcocoawindow.mm | 15 +++ src/plugins/platforms/cocoa/qnsview.mm | 1 + patch: patches/25-sync-upstream-171126.diff Changes: git log 01c7b474f5ad2c9fcf4b90c71048624070811618..6a9d076e87f0c8aa4fb49bbcc2f56eefd85af2e3 src/plugins/platforms/cocoa commit d0736e9d17d0b3ec2f7aa3f323a1edf70aa83e27 Cocoa: Make High DPI drag cursor work commit 3f519ffa150ce5a2d9e3ad3f147745b312d29afb QCocoaMenuItem: Don't clear NSMenuItem.action when setting submenu commit 5194817941985c766bbc7f80039a58e0cf504b55 Cocoa: optimize backingstore flush on 10-bit displays commit 385589ef458715fcaa533bbd01ca421dc1040eba QCocoaMenu: Attach menu items when updating the menubar 20171030 : upstream head (5.9): 01c7b474f5ad2c9fcf4b90c71048624070811618 src/plugins/platforms/cocoa/cocoa.pro | 11 +- src/plugins/platforms/cocoa/messages.cpp | 2 +- src/plugins/platforms/cocoa/messages.h | 11 + src/plugins/platforms/cocoa/qcocoamenuitem.mm | 10 +- src/plugins/platforms/cocoa/qcocoamenuloader.mm | 20 +- src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm | 31 --- src/plugins/platforms/cocoa/qcocoawindow.mm | 2 + patches: patches/24-sync-upstream-171030.diff patches/24b-patch-build-on-OSX109.diff Changes: git log e03b64c5b1eeebfbbb94d67eb9a9c1d35eaba0bb..01c7b474f5ad2c9fcf4b90c71048624070811618 commit 37a1478787d64b34a0716421c8a47f3246e41bfd Cocoa QPA: Code clean up, make some bits more readable commit c99d8532c892f72f897c9e686be75d1ebba67618 QCocoaSystemTrayIcon: Remove unused classes Both QNSMenu and QSystemTrayIconQMenu aren't referenced anywhere else, including within qcocoasystemtrayicon.mm, since the QPA backend was added. commit f13e75345d035ec906846aaa3540454787edbd3f Cocoa QPA: Remove usage of OBJECTIVE_SOURCES commit 8ac9addd946637401e4685c6e91d1a3cd5b2d768 QCocoaWindow: Toggle titlebar transparency to support unified toolbar This is need from macOS 10.13 onwards. See NSWindow related notes on https://developer.apple.com/library/content/releasenotes/AppKit/RN-AppKit/ NB: that NSWindow change required runtime checking for 10.9 support. 20171011 : upstream head (5.9): e03b64c5b1eeebfbbb94d67eb9a9c1d35eaba0bb src/plugins/platforms/cocoa/qnsview.mm | 4 + patch: patches/23-sync-upstream-171011.diff Changes: git log e0c2d328b11ab893538393fad66ad61d22d823c6..e03b64c5b1eeebfbbb94d67eb9a9c1d35eaba0bb src/plugins/platforms/cocoa/qnsview.mm | cat commit cbbf843e96de3067e4cb7c0a7b4e59a6c27b10f7 macOS: Bail out early when handling shortcut event results in closing window NB: this protection has been added to the contextmenu handling block just above, too. 20170920 : upstream head (5.9): e0c2d328b11ab893538393fad66ad61d22d823c6 src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm | 12 +- src/plugins/platforms/cocoa/qcocoainputcontext.mm | 17 +- src/plugins/platforms/cocoa/qcocoamenubar.mm | 10 +- src/plugins/platforms/cocoa/qnsview.h | 2 + src/plugins/platforms/cocoa/qnsview.mm | 41 ++- patch: patches/22-sync-upstream-170920.diff Changes: git log e81f430e30635f975dd4635ffb64d66fc1bce355..HEAD src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm src/plugins/platforms/cocoa/qcocoainputcontext.mm src/plugins/platforms/cocoa/qcocoamenubar.mm src/plugins/platforms/cocoa/qnsview.h src/plugins/platforms/cocoa/qnsview.mm commit 689606de91faecf91f1f92e8d355789d9be62d2f Cocoa: Update the known menu items when the QCocoaMenuBar is deleted Task-number: QTBUG-62193 commit 202d3ba3e6c9982608f41f5e7d836825c8664c93 Cocoa: Check if charactersIgnoringModifiers is not empty too Task-number: QTBUG-57933 commit 0adc14d8dbdd9e28ccb72c49d865009dd8df1b1c macOS: Don‚Äôt color convert the backing store Task-number: QTBUG-61384 commit 52bda430af2749da1a0467b71d9cca5208f22402 macOS: Reset composition when focus object changes inside window Task-number: QTBUG-59222 commit 0270651dda8e247164a8dccd71fb65712c7d1480 Cocoa integration: do not use released session Task-number: QTBUG-62589 20170829 : upstream head (5.9): e81f430e30635f975dd4635ffb64d66fc1bce355 touched: src/plugins/platforms/cocoa/qcocoamenu.h | 4 + src/plugins/platforms/cocoa/qcocoamenu.mm | 26 +- src/plugins/platforms/cocoa/qcocoamenubar.mm | 2 +- src/plugins/platforms/cocoa/qcocoaprintersupport.h | 2 +- src/plugins/platforms/cocoa/qcocoaprintersupport.mm | 4 +- src/plugins/platforms/cocoa/qcocoawindow.mm | 14 +- src/plugins/platforms/cocoa/qnsview.h | 2 + src/plugins/platforms/cocoa/qnsview.mm | 4 + src/plugins/platforms/cocoa/qprintengine_mac.mm | 8 +- src/plugins/platforms/cocoa/qprintengine_mac_p.h | 2 +- patch: patches/21-sync-upstream-170828.diff Changes: git log 0a5f71c6062d575602ff041fb1b88ec2d8ad92bc..HEAD src/plugins/platforms/cocoa commit 48784486a36f60dea882baabc6923f4b59d2bfe6 QCocoaMenu: Stop update timer commit dbaa4de28e5cdfa1787af77d236586833786ee61 Cocoa: Fix compile when using QT_NO_TABLETEVENT commit 8ebfe00f4ab79516a8276929a682c24f4c675b5f Initialize the print engine with the given printer name QAltCocoa: only on Qt >= 5.9.0 Task-number: QTBUG-62221 commit 306071e50eac8290d234caab90985ddf705a5fc6 QCocoaMenu: Sync menubar menu when adding items Task-number: QTBUG-62260 commit f27d1ccbb24ec2fd4098f2976503478831006cc8 QCocoaMenu: De-pessimize the number of calls to validateMenuItem: Task-number: QTBUG-62396 >>> change enabled for Qt >= 5.9.2 commit c35fc435950437d3d046b17d06593873d7b82011 macOS: Make alpha-based click-trough work again Restore 5.6 behavior by not modifying ignoresMouseEvent if we can. Toggling WindowTransparentForInput on and off again is still broken. Task-number: QTBUG-54830 20180801: upstream head (5.9): 0a5f71c6062d575602ff041fb1b88ec2d8ad92bc touched: src/plugins/platforms/cocoa/cocoa.pro | 7 +- src/plugins/platforms/cocoa/qcocoafontdialoghelper.h | 3 + src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm | 4 - src/plugins/platforms/cocoa/qcocoahelpers.h | 7 +- src/plugins/platforms/cocoa/qcocoahelpers.mm | 5 ++ src/plugins/platforms/cocoa/qcocoatheme.mm | 13 +-- src/plugins/platforms/cocoa/qnswindowdelegate.mm | 7 +- > patch: patches/20-sync-upstream-170801.diff Changes: Fix 32-bit build on macOS macOS: Don't assume the proposed fullscreen size matches the screen size Sometimes AppKit will pass in a proposed size that's smaller than the geometry of the screen. We don't know why, but shouldn't assert. Add missing #include for -no-widgets macOS: Fix unused variable in window:willUseFullScreenContentSize: Convert features.fontdialog to QT_[REQUIRE_]CONFIG Fix macOS build for -no-widgets, take 2 20170707: upstream head (5.9): 9d3cd2268ce3beafcf6fa886bb70d8463260d602 touched: src/plugins/platforms/cocoa/qcocoatheme.mm src/plugins/platforms/cocoa/qnswindowdelegate.mm > patch: patches/19.2-sync-upstream-170707.diff Changes: from git log 03b4838cb51513bd5d2edf76dccc4bc4a1181681..HEAD src/plugins/platforms/cocoa/{qcocoatheme.mm,qnswindowdelegate.mm} commit 9d3cd2268ce3beafcf6fa886bb70d8463260d602 Author: Tor Arne Vestb#c3#b8 Date: Thu Jul 6 17:03:41 2017 +0200 macOS: Account for fullscreen geometry bug in AppKit on OS X 10.10 commit 6a1046e17691c6e35c7384590ba241edb4082707 Author: Stephan Binner qq Date: Tue Jul 4 19:08:55 2017 +0200 Fix macOS build for -no-widgets 20170705: upstream head (5.9 branch): 03b4838cb51513bd5d2edf76dccc4bc4a1181681 touched: src/plugins/platforms/cocoa/cocoa.pro | 16 +++-- src/plugins/platforms/cocoa/qcocoacolordialoghelper.h | 4 ++ src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm | 4 -- src/plugins/platforms/cocoa/qcocoafiledialoghelper.h | 3 + src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm | 4 -- src/plugins/platforms/cocoa/qcocoaintegration.mm | 8 ++- src/plugins/platforms/cocoa/qcocoamenubar.mm | 18 ++++- src/plugins/platforms/cocoa/qcocoatheme.mm | 14 ++-- src/plugins/platforms/cocoa/qnsview.mm | 33 +++++---- > patch: patches/19-sync-upstream-170705.diff Main changes from `cd src/plugins/platforms/cocoa && git log b2cb83ecbb1eec29268852d1b230f37e4c8592e9..HEAD cocoa.pro qcocoacolordialoghelper.h qcocoacolordialoghelper.mm qcocoafiledialoghelper.h qcocoafiledialoghelper.mm qcocoaintegration.mm qcocoamenubar.mm qcocoatheme.mm qnsview.mm ` commit 3e8ebea95b634c7ded9ee0b884768155e9e7f686 Author: Andy Shaw Date: Fri Jun 23 09:08:19 2017 +0200 Cocoa: Reset the target + action for a menuitem after showing a dialog To make it more reliable and efficient we now do the reverse of what we are doing when redirecting the items. This will ensure that the actions are correctly reset to the original target and action. The original approach of updateMenubarImmediately() was not always doing this and it also does other unnecessary things as a result when all we need is to just reset the things we changed. commit 198b67d14bf3ca76d6bdf8901348da0838cf3b8d Author: Tor Arne Vestb#c3#b8 Date: Mon Jun 12 17:58:41 2017 +0200 macOS: Send text input and key events to focus object of window, not app The key events and input method callbacks coming from Cocoa are targeted at our specific NSView, so we should deliver them to the focus object of the corresponding QWindow, not the global application focus object. This means that we'll deliver key events to windows also when they are not key (active), but this is intentional, as we would otherwise fail to deliver input method events coming from e.g. the emoji/symbol picker, which steals the key window when active. Task-number: QTBUG-61359 commit 3851a8ff20c6aed0807bfdc4588ae108a2b108ec Author: Tor Arne Vestb#c3#b8 Date: Fri Jun 23 13:32:25 2017 +0200 macOS: Work around buildup of NSDisplayCycle objects during rapid painting Task-number: QTBUG-60012 commit e6ccc8e56fdaf402602130176064ffb1a0ce29bf Author: R.J.V. Bertin Date: Wed Jun 21 18:16:04 2017 +0200 sync with upstream Cocoa QPA changes in the 5.9 branch (qtbase v5.9.0-208-gb2cb83e) commit 12e9ff4bed9513fe8ed390a1f421d8f73c45960a Author: R.J.V. Bertin Date: Mon Jun 5 17:40:51 2017 +0200 sync with upstream Cocoa QPA changes in the 5.9 branch (qtbase v5.9.0-119-g934235e) commit 0ecceaf6d7871b fc42141909af210f6bb408ac61 Author: R.J.V. Bertin Date: Thu Apr 20 20:50:58 2017 +0200 15-patch-restore-legacy-fullscreen-mode.diff alternative fullscreen mode: simplified and restore window icons commit d4ce302e7c08dcf38a0f0f40b7e9183cab2fc2b1 Author: R.J.V. Bertin Date: Wed Apr 19 23:58:24 2017 +0200 AltCocoa QPA: add a legacy fullscreen mode When windows don't have the fullscreen titlebar button or the env. var. QT_LEGACY_FULLSCREEN is set, toggleFullScreen() adopts a legacy mode. Windows are then made fullscreen by converting them to frame-less and resizing them to the current screen size. This is faster (instantaneous) and preserves display content on other screens in multi-head set-ups. commit 85bb84969c6922667ff83e1483a7ef71628c046e Author: R.J.V. Bertin Date: Tue Apr 11 20:16:12 2017 +0200 qmacstyle : really build against Qt 5.8.0 commit 934afde2c352b401cfffed83cb0877462dc27787 Author: R.J.V. Bertin Date: Mon Apr 10 23:56:13 2017 +0200 modified (Alt) 5.9.0 commit c8dd86fd23c6787f949c2849ccb20eaf22e118ae Author: R.J.V. Bertin Date: Mon Apr 10 23:45:31 2017 +0200 13-themehint-add-aqua.diff commit cbf229875c49c2a57d7b62b641d866134e569a1a Author: R.J.V. Bertin Date: Thu Apr 6 21:57:00 2017 +0200 12-deactivate-menurole-heuristics.patch this patch deactivates the worst of the TextHeuristic menu role guessmatics that can lead to putting the wrong QAction under the Mac's About or Preferences menu items in the Application menu. Many KDE applications have more than 1 About and Configure menu actions and are thus especially at risk. KDE applications that use KStandardActions to create the standard menu items will see the appropriate actions assigned to the About and Preferences menu items because their roles are set explicitly. commit af7c4544d1883e9978609742b48dbb152e880c34 Author: R.J.V. Bertin Date: Thu Apr 6 21:50:46 2017 +0200 11-patch-keyboard-support-menukey.diff this patch introduces support for a Menu key. Macs don't normally have one but the SDKs do provide a special keysym (NSMenuFunctionKey) which might be used (generated) by 3rd party keyboard drivers or even a native event filter. The patch completes the pre-existing support and generates a ContextMenu event at an appropriate location when the keysym is received. commit c45430fc3c1827b44dd9002932b7b582da19729e Author: R.J.V. Bertin Date: Thu Apr 6 19:22:14 2017 +0200 10-patch-keyboard-mapping.diff From 3ee093b47109e2b24ab77ccdecde84437c5aced9 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 2 Nov 2016 14:19:26 +0100 Subject: [PATCH] WIP - Cocoa integration: fix incorrect keyboard mapping When switching between different input sources, we have to update layouts. Task-number: QTBUG-50865 Change-Id: I19ee45feabf014e61dfef7454b5468e596ce2786 Committed from host : Portia.local commit 65de5666d5574a08a2fe49b82f29fd0b8a6b3cbf Author: R.J.V. Bertin Date: Thu Apr 6 19:21:36 2017 +0200 09-patch-silence-setscreen-warning.diff Prevent an unnecessary warning commit 07527d713953a417b93393558cfb44475bc42d23 Author: R.J.V. Bertin Date: Thu Apr 6 19:20:56 2017 +0200 08-patch-freetype-gamma-cocoa.diff Adapt the font smoothing gamma when using the FreeType rendering engine. commit a7b0481d07c592c1a1810160e317d6792eeb7a5d Author: R.J.V. Bertin Date: Thu Apr 6 19:19:32 2017 +0200 06-patch-respect-DontSwapCtrlMeta.diff From ce953f011356257c1e1862d0353f785453559028 Mon Sep 17 00:00:00 2001 From: Dyami Caliri Date: Tue, 16 Sep 2014 17:32:22 -0700 Subject: [PATCH] OS X: Handle Qt::AA_MacDontSwapCtrlAndMeta for regular key events The flag Qt::AA_MacDontSwapCtrlAndMeta was only being used with shortcut detection. Now trying to incorporate flag in normal key events. Task-number: QTBUG-22775 Change-Id: I9edf97d0de93aa225435c9802372e33641cdac73 Committed from host : Portia.local commit 5ffc2fff1bd729ec9e54120e424fdfd51197f438 Author: R.J.V. Bertin Date: Thu Apr 6 19:18:46 2017 +0200 05-patch-improve-fontweight-support9.diff part of a more comprehensive patch improving support for less-common font weights. I'm not sure how much effect it has on its own but it should not have adverse effects when used without the companion modifications. commit 658f1d0e2fe5a9a678bdae712cc5a47878bc59de Author: R.J.V. Bertin Date: Thu Apr 6 19:16:29 2017 +0200 04-patch-qmenuAddSection.diff add support for named menu sections ("texted separators") in menus that are part of the native menubar. This requires the companion patch to the "native" Macintosh theme otherwise named sections won't appear when they are the 1st item in a menu. commit 42f58e14282bf4beae408f5440397dd5a6b30471 Author: R.J.V. Bertin Date: Thu Apr 6 19:14:00 2017 +0200 03-patch-better-menuitem-insert-warning.diff Provide a more helpful warning when adding an item to an additional menu or removing it from the wrong menu. commit f5bbcfc20e52dfcfa27eedb4a1240e2fccf5fb93 Author: R.J.V. Bertin Date: Thu Apr 6 19:12:01 2017 +0200 02-patch-enable-kde-theme.diff advertise the existence of support for the KDE platform theme plugin when KDE_SESSION_VERSION is set to at least 4 in the environment. commit f3707f1516f1393235c178d5829cf3f88d5844e1 Author: R.J.V. Bertin Date: Thu Apr 6 19:03:23 2017 +0200 01-patch-missing-autoreleasepools.diff Add autorelease pools to functions that (used to) need them. This is safe and comes at almost no cost. diff --git a/src/qcocoa-qpa/patches/26-sync-upstream-171219.diff b/src/qcocoa-qpa/patches/26-sync-upstream-171219.diff new file mode 100644 index 0000000..fcae6bc --- /dev/null +++ b/src/qcocoa-qpa/patches/26-sync-upstream-171219.diff @@ -0,0 +1,43 @@ +diff --git a/cocoa/README.ALT b/cocoa/README.ALT +index 0b1796f..56659ab 100644 +--- a/cocoa/README.ALT ++++ b/cocoa/README.ALT +@@ -1,3 +1,10 @@ ++20171219 : upstream head (5.9): b0938cb6c1fa29ec2d2a4fb9273e515cd0d6c08e ++ src/plugins/platforms/cocoa/qcocoamenuloader.mm | 8 +- ++Changes: git log 6a9d076e87f0c8aa4fb49bbcc2f56eefd85af2e3..b0938cb6c1fa29ec2d2a4fb9273e515cd0d6c08e src/plugins/platforms/cocoa ++commit 29104c85db53e7c0c0aaf3fe78f84b737fce4886 ++ Cocoa: Disable “Hide” menu item on open popups ++ ++ + 20171126 : upstream head (5.9): 6a9d076e87f0c8aa4fb49bbcc2f56eefd85af2e3 / v5.9.3-43-g6a9d076 + src/plugins/platforms/cocoa/qcocoamenu.h | 2 + + src/plugins/platforms/cocoa/qcocoamenu.mm | 16 ++- +diff --git a/cocoa/qcocoamenuloader.mm b/cocoa/qcocoamenuloader.mm +index 0d9bb50..b986833 100644 +--- a/cocoa/qcocoamenuloader.mm ++++ b/cocoa/qcocoamenuloader.mm +@@ -43,6 +43,7 @@ + #include "qcocoahelpers.h" + #include "qcocoamenubar.h" + #include "qcocoamenuitem.h" ++#include "qcocoaintegration.h" + + #include + #include +@@ -343,10 +344,13 @@ + + - (BOOL)validateMenuItem:(NSMenuItem*)menuItem + { +- if ([menuItem action] == @selector(hide:) +- || [menuItem action] == @selector(hideOtherApplications:) ++ if ([menuItem action] == @selector(hideOtherApplications:) + || [menuItem action] == @selector(unhideAllApplications:)) { + return [NSApp validateMenuItem:menuItem]; ++ } else if ([menuItem action] == @selector(hide:)) { ++ if (QCocoaIntegration::instance()->activePopupWindow()) ++ return NO; ++ return [NSApp validateMenuItem:menuItem]; + } else if ([menuItem tag]) { + QCocoaMenuItem *cocoaItem = reinterpret_cast([menuItem tag]); + return cocoaItem->isEnabled(); diff --git a/src/qcocoa-qpa/qcocoamenuloader.mm b/src/qcocoa-qpa/qcocoamenuloader.mm index 0d9bb50..b986833 100644 --- a/src/qcocoa-qpa/qcocoamenuloader.mm +++ b/src/qcocoa-qpa/qcocoamenuloader.mm @@ -1,364 +1,368 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL3 included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or (at your option) the GNU General ** Public license version 3 or any later version approved by the KDE Free ** Qt Foundation. The licenses are as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 ** included in the packaging of this file. Please review the following ** information to ensure the GNU General Public License requirements will ** be met: https://www.gnu.org/licenses/gpl-2.0.html and ** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "qcocoamenuloader.h" #include "messages.h" #include "qcocoahelpers.h" #include "qcocoamenubar.h" #include "qcocoamenuitem.h" +#include "qcocoaintegration.h" #include #include #include #include @implementation QCocoaMenuLoader + (instancetype)sharedMenuLoader { static QCocoaMenuLoader *shared = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ shared = [[self alloc] init]; }); return shared; } - (instancetype)init { if ((self = [super init])) { NSString *appName = qt_mac_applicationName().toNSString(); // Menubar as menu. Title as set in the NIB file theMenu = [[NSMenu alloc] initWithTitle:@"Main Menu"]; // Application menu. Since 10.6, the first menu // is always identified as the application menu. NSMenuItem *appItem = [[[NSMenuItem alloc] init] autorelease]; appItem.title = appName; [theMenu addItem:appItem]; appMenu = [[NSMenu alloc] initWithTitle:appName]; appItem.submenu = appMenu; // About Application aboutItem = [[NSMenuItem alloc] initWithTitle:[@"About " stringByAppendingString:appName] action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""]; aboutItem.target = self; // Disable until a QAction is associated aboutItem.enabled = NO; aboutItem.hidden = YES; [appMenu addItem:aboutItem]; // About Qt (shameless self-promotion) aboutQtItem = [[NSMenuItem alloc] init]; aboutQtItem.title = @"About Qt"; // Disable until a QAction is associated aboutQtItem.enabled = NO; aboutQtItem.hidden = YES; [appMenu addItem:aboutQtItem]; [appMenu addItem:[NSMenuItem separatorItem]]; // Preferences preferencesItem = [[NSMenuItem alloc] initWithTitle:@"Preferences…" action:@selector(qtDispatcherToQPAMenuItem:) keyEquivalent:@","]; preferencesItem.target = self; // Disable until a QAction is associated preferencesItem.enabled = NO; preferencesItem.hidden = YES; [appMenu addItem:preferencesItem]; [appMenu addItem:[NSMenuItem separatorItem]]; // Services item and menu servicesItem = [[NSMenuItem alloc] init]; servicesItem.title = @"Services"; NSMenu *servicesMenu = [[[NSMenu alloc] initWithTitle:@"Services"] autorelease]; servicesItem.submenu = servicesMenu; [NSApplication sharedApplication].servicesMenu = servicesMenu; [appMenu addItem:servicesItem]; [appMenu addItem:[NSMenuItem separatorItem]]; // Hide Application hideItem = [[NSMenuItem alloc] initWithTitle:[@"Hide " stringByAppendingString:appName] action:@selector(hide:) keyEquivalent:@"h"]; hideItem.target = self; [appMenu addItem:hideItem]; // Hide Others hideAllOthersItem = [[NSMenuItem alloc] initWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"]; hideAllOthersItem.target = self; hideAllOthersItem.keyEquivalentModifierMask = NSCommandKeyMask | NSAlternateKeyMask; [appMenu addItem:hideAllOthersItem]; // Show All showAllItem = [[NSMenuItem alloc] initWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""]; showAllItem.target = self; [appMenu addItem:showAllItem]; [appMenu addItem:[NSMenuItem separatorItem]]; // Quit Application quitItem = [[NSMenuItem alloc] initWithTitle:[@"Quit " stringByAppendingString:appName] action:@selector(terminate:) keyEquivalent:@"q"]; quitItem.target = self; [appMenu addItem:quitItem]; } return self; } - (void)dealloc { [theMenu release]; [appMenu release]; [aboutItem release]; [aboutQtItem release]; [preferencesItem release]; [servicesItem release]; [hideItem release]; [hideAllOthersItem release]; [showAllItem release]; [quitItem release]; [lastAppSpecificItem release]; [super dealloc]; } - (void)ensureAppMenuInMenu:(NSMenu *)menu { // The application menu is the menu in the menu bar that contains the // 'Quit' item. When changing menu bar (e.g when switching between // windows with different menu bars), we never recreate this menu, but // instead pull it out the current menu bar and place into the new one: NSMenu *mainMenu = [NSApp mainMenu]; if ([NSApp mainMenu] == menu) return; // nothing to do (menu is the current menu bar)! #ifndef QT_NAMESPACE Q_ASSERT(mainMenu); #endif // Grab the app menu out of the current menu. int numItems = [mainMenu numberOfItems]; NSMenuItem *oldAppMenuItem = 0; for (int i = 0; i < numItems; ++i) { NSMenuItem *item = [mainMenu itemAtIndex:i]; if ([item submenu] == appMenu) { oldAppMenuItem = item; [oldAppMenuItem retain]; [mainMenu removeItemAtIndex:i]; break; } } if (oldAppMenuItem) { [oldAppMenuItem setSubmenu:nil]; [oldAppMenuItem release]; NSMenuItem *appMenuItem = [[NSMenuItem alloc] initWithTitle:@"Apple" action:nil keyEquivalent:@""]; [appMenuItem setSubmenu:appMenu]; [menu insertItem:appMenuItem atIndex:0]; } } - (void)removeActionsFromAppMenu { for (NSMenuItem *item in [appMenu itemArray]) [item setTag:0]; } - (NSMenu *)menu { return [[theMenu retain] autorelease]; } - (NSMenu *)applicationMenu { return [[appMenu retain] autorelease]; } - (NSMenuItem *)quitMenuItem { return [[quitItem retain] autorelease]; } - (NSMenuItem *)preferencesMenuItem { return [[preferencesItem retain] autorelease]; } - (NSMenuItem *)aboutMenuItem { return [[aboutItem retain] autorelease]; } - (NSMenuItem *)aboutQtMenuItem { return [[aboutQtItem retain] autorelease]; } - (NSMenuItem *)hideMenuItem { return [[hideItem retain] autorelease]; } - (NSMenuItem *)appSpecificMenuItem:(NSInteger)tag { NSMenuItem *item = [appMenu itemWithTag:tag]; // No reason to create the item if it already exists. See QTBUG-27202. if (item) return [[item retain] autorelease]; // Create an App-Specific menu item, insert it into the menu and return // it as an autorelease item. item = [[NSMenuItem alloc] init]; NSInteger location; if (lastAppSpecificItem == nil) { location = [appMenu indexOfItem:aboutQtItem]; } else { location = [appMenu indexOfItem:lastAppSpecificItem]; [lastAppSpecificItem release]; } lastAppSpecificItem = item; // Keep track of this for later (i.e., don't release it) [appMenu insertItem:item atIndex:location + 1]; return [[item retain] autorelease]; } - (BOOL) acceptsFirstResponder { return YES; } - (void)terminate:(id)sender { [NSApp terminate:sender]; } - (void)orderFrontStandardAboutPanel:(id)sender { [NSApp orderFrontStandardAboutPanel:sender]; } - (void)hideOtherApplications:(id)sender { [NSApp hideOtherApplications:sender]; } - (void)unhideAllApplications:(id)sender { [NSApp unhideAllApplications:sender]; } - (void)hide:(id)sender { [NSApp hide:sender]; } - (void)qtTranslateApplicationMenu { #ifndef QT_NO_TRANSLATION [servicesItem setTitle:qt_mac_applicationmenu_string(ServicesAppMenuItem).toNSString()]; [hideItem setTitle:qt_mac_applicationmenu_string(HideAppMenuItem).arg(qt_mac_applicationName()).toNSString()]; [hideAllOthersItem setTitle:qt_mac_applicationmenu_string(HideOthersAppMenuItem).toNSString()]; [showAllItem setTitle:qt_mac_applicationmenu_string(ShowAllAppMenuItem).toNSString()]; [preferencesItem setTitle:qt_mac_applicationmenu_string(PreferencesAppMenuItem).toNSString()]; [quitItem setTitle:qt_mac_applicationmenu_string(QuitAppMenuItem).arg(qt_mac_applicationName()).toNSString()]; [aboutItem setTitle:qt_mac_applicationmenu_string(AboutAppMenuItem).arg(qt_mac_applicationName()).toNSString()]; #endif } - (IBAction)qtDispatcherToQPAMenuItem:(id)sender { NSMenuItem *item = static_cast(sender); if (item == quitItem) { // We got here because someone was once the quitItem, but it has been // abandoned (e.g., the menubar was deleted). In the meantime, just do // normal QApplication::quit(). qApp->quit(); return; } if ([item tag]) { QCocoaMenuItem *cocoaItem = reinterpret_cast([item tag]); QScopedScopeLevelCounter scopeLevelCounter(QGuiApplicationPrivate::instance()->threadData); cocoaItem->activated(); } } - (void)orderFrontCharacterPalette:(id)sender { [NSApp orderFrontCharacterPalette:sender]; } - (BOOL)validateMenuItem:(NSMenuItem*)menuItem { - if ([menuItem action] == @selector(hide:) - || [menuItem action] == @selector(hideOtherApplications:) + if ([menuItem action] == @selector(hideOtherApplications:) || [menuItem action] == @selector(unhideAllApplications:)) { return [NSApp validateMenuItem:menuItem]; + } else if ([menuItem action] == @selector(hide:)) { + if (QCocoaIntegration::instance()->activePopupWindow()) + return NO; + return [NSApp validateMenuItem:menuItem]; } else if ([menuItem tag]) { QCocoaMenuItem *cocoaItem = reinterpret_cast([menuItem tag]); return cocoaItem->isEnabled(); } else { return [menuItem isEnabled]; } } - (NSArray*) mergeable { // don't include the quitItem here, since we want it always visible and enabled regardless return [NSArray arrayWithObjects:preferencesItem, aboutItem, aboutQtItem, lastAppSpecificItem, nil]; } @end