summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoamenu.mm
Commit message (Collapse)AuthorAgeFilesLines
...
* QCocoaMenu: Queue 'activated' signal emissionGabriel de Dietrich2015-03-301-1/+3
| | | | | | | | | | | | | Allows catching exceptions without quitting the application. The behavior change should be unnoticeable since we can't activate the menu item from within the Qt application. Tested that the keyboard modifiers are still set when we get to the action signal handler. Change-Id: I43d0c377834450344bd3a3678e07b6631ba0b768 Task-number: QTBUG-15197 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
* Fixed compilation on Mac OS X (qt namespace and preprocessor issues))Sergei Kulik2015-03-201-0/+4
| | | | | | | | Configured with -qtnamespace <...> -no-opengl -D QT_NO_PRINTER Change-Id: I1c959a89afda08d29a854f21e6e51732d136753c Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
* QShortCut: Check whether the menu is QPA-disabledGabriel de Dietrich2015-03-111-0/+5
| | | | | | | | | | | | When climbing the menu hierarchy, it's sounder to check whether the actual QPA menu is enabled. This way we can trigger modifier-less shortcuts even in submenus. Task-number: QTBUG-38256 Task-number: QTBUG-42584 Change-Id: I13a27027306bce0f0732b05bf9469f3b77028f73 Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
* OSX: fix leaks due to missing NSAutoreleasePoolErik Verbruggen2015-02-261-0/+2
| | | | | | | env OBJC_DEBUG_MISSING_POOLS=YES qtcreator Change-Id: Ibbe5f42af5b94a439be3f0dd0f2b6e34bb1afd3f Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-111-21/+13
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Revert "OS X: rename special menu items instead of duplicating"Timur Pocheptsov2014-12-221-7/+2
| | | | | | | | | | | | This reverts commit 8c538d10da618add00aba1acbc8d8dc2f24445b4. This patch, unfortunately, do not combine well with another problematic code producing, as a result, a serious regression. While the proper/better fix in Cocoa menu not found, I'm reverting this patch. Change-Id: I1ff03dbe12805da447cb3cfe3e2f231528bf1a16 Task-number: QTBUG-43471 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
* OS X: rename special menu items instead of duplicatingTimur Pocheptsov2014-10-101-2/+7
| | | | | | | | | | | | | | | | Two-part fix: QCocoaMenu::syncMenuItem, when selecting the "old" menu, if an item was merged, 'applicationMenu' was always selected, but this is wrong for any item with a role >= CutRole (such an item still can be "merged", but it's not in the application menu). QCocoaMenuItem::sync - item can be merged with itself: after item's role detected, the search for an item to merge with can find exactly the same item we've just detected the role for (since a data-member is modified) - try to avoid this. Task-number: QTBUG-39934 Change-Id: Ibe1df9e92973380652101143067e14922afdfb9e Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
* Merge remote-tracking branch 'origin/5.3' into 5.4Oswald Buddenhagen2014-10-061-1/+16
|\ | | | | | | Change-Id: I132bb6cce68e9f8413200f7ee75586bd1cada38c
| * QCocoaMenu: Keep a reference to the containing menu itemGabriel de Dietrich2014-09-291-1/+16
| | | | | | | | | | | | | | | | | | | | | | This allows the menu to tell its containing item the menu got deleted. This removes the need to reset the COCOA_MENU_ANCESTOR property value, which would crash since QCocoaMenuItem::m_menu would be a dangling pointer. Task-number: QTBUG-41587 Change-Id: Ia3408ef85cf823bfddbc2c41d6534e43bf14ed29 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
* | cocoa: override new QPlatformMenu::popup() functionRichard Moe Gustavsen2014-09-291-1/+2
|/ | | | | | | | | | | | | | | | Having two versions of popup, one that takes a point and one that takes a target rect, causes problems for client code if they use the 'target rect' version since not all platforms override that function. So this patch will change the remaining platform that override QPlatformmenu into using the new 'target rect' version. Calling the old version that takes a point will still work, since the base version will then convert the point into a zero-sized rect, and forward the call to the 'target rect' version instead. Change-Id: Icc8531d79270a4f24ec08b8ed95b18ed3db1ad4d Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
* OS X: Fix positioning of popup menus in case of native NSWindowsEike Ziller2014-09-161-3/+2
| | | | | | | | | | | | | | | The code transformed the coordinates from the view to the window's content view, and since that content view is flipped in the pure Qt world (content view == QNSView), it manually flipped the coordinates to transform from that to window coordinates. Instead just directly transform the view coordinates to window coordinates using standard Cocoa methods, which then works with any kind of content view and NSWindow configuration. Task-number: QTBUG-40958 Change-Id: Idddd327fe9cff3309606379d0e04ee8b4bd5eece Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
* Merge remote-tracking branch 'origin/release' into stableFrederik Gladhorn2014-05-031-0/+4
|\ | | | | | | | | | | | | Manually fixed up: isES -> isOpenGLES src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp Change-Id: I57d2ef26c3d4a7b40ace09f4e8560b7686650ea5
| * Cocoa QPA Menu: Clear menu items' Cocoa ancestor on destructionGabriel de Dietrich2014-05-021-0/+4
| | | | | | | | | | | | | | | | Valid for both the item and the menu destructions. Task-number: QTBUG-38685 Change-Id: I024b93c8bb8facefeaad5e8b6c7be6bf049898ea Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
* | QPA: Adding API to support QWidgetAction on MacGabriel de Dietrich2014-04-171-0/+5
|/ | | | | | | | | Includes the Cocoa implementation. Task-number: QTBUG-19840 Change-Id: Id33bc8053b82116cf76ed591b6df823df3aef9bc Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
* Cocoa: Set the COCOA_MENU_ANCESTOR() also when sync'ingGabriel de Dietrich2014-04-101-1/+1
| | | | | | | | Task-number: QTBUG-38044 Change-Id: I2769bf2f4beec058c15ba1d126e59106f41dab37 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
* Cocoa Menus: Give platform menu ownership back to QWidgetsGabriel de Dietrich2014-02-261-4/+4
| | | | | | | | | | | | | | | | We don't want to be in the situation where a QCocoaMenuItem owns a QCocoaMenu (because that item is a submenu), and then the actual QMenu "sees" that same QCocoaMenu being deleted. Instead, since all the QCocoaMenu* classes inherit QObject, we rely on meta-object properties to set the hierarchy and climb the hierarchy when guessing the menu item's role. This ammends most of commit 370e89f06465a4d61c7b. Task-number: QTBUG-36785 Change-Id: I0e03acb593e93061c8c6c1fdd161669cf0d2a293 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
* Cocoa Menu: Set keyboard modifiers when item is activatedGabriel de Dietrich2014-02-261-0/+1
| | | | | | | | | | Seems to be a regression from 4.8, which is not surprising since everything was rewritten for QPA. Task-number: QTBUG-36851 Change-Id: If89f8c9e6897fd1e02800f49e51baeb1ea181238 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com> Reviewed-by: James Turner <james.turner@kdab.com>
* Different native Cocoa menu fixes.Christoph Schleifenbaum2013-10-291-11/+15
| | | | | | | | - Fix location of NSMenu when no NSView is given. - Fix shortcut when given in text with tab. Change-Id: Iec21cf3d12084db1e70c1a8779d5482c78285796 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
* Fix compile warnings on 10.6Morten Johan Sorvig2013-10-251-0/+1
| | | | | | | | Apple clang 3.0 complains about missing function declarations. Add them. Change-Id: Ib9c3c238c94e8649844cf3e67a659875ad549ecb Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
* Merge remote-tracking branch 'origin/stable' into devSergio Ahumada2013-09-071-0/+2
|\ | | | | | | Change-Id: I9ee4176f0a0078908d49896508826154c9f71530
| * Cocoa: Fix NSMenu popup coordinatesGabriel de Dietrich2013-09-041-0/+2
| | | | | | | | | | | | | | | | | | Those should be in window coordinates (or rather, its content view) not view coordinates. Task-number: QTBUG-32826 Change-Id: I52dddeccf17b359163ad477ce4299b934633b4fa Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
* | Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2013-08-141-0/+2
|\| | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: configure mkspecs/macx-xcode/Info.plist.app mkspecs/macx-xcode/Info.plist.lib qmake/doc/qmake.qdocconf src/corelib/global/qglobal.h tests/auto/other/exceptionsafety/exceptionsafety.pro tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp Change-Id: I3c769a4a82dc2e99a12c69123fbf17613fd2ac2a
| * Cocoa: Allow to hide menu items in menubarGabriel de Dietrich2013-08-131-0/+2
| | | | | | | | | | | | | | Task-number: QTBUG-32899 Change-Id: I423ac2d636306303d39e973f19032c9004957095 Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
* | Merge branch 'stable' into devSergio Ahumada2013-07-111-0/+2
|\| | | | | | | | | | | | | | | | | | | Conflicts: qmake/generators/mac/pbuilder_pbx.cpp src/corelib/json/qjsonwriter.cpp src/corelib/kernel/qeventdispatcher_blackberry.cpp src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm Change-Id: I24df576c4cbd18fa51b03122f71e32bb83b9028f
| * Cocoa: Re-establish platform menu QObject hierarchyGabriel de Dietrich2013-07-021-0/+2
| | | | | | | | | | | | | | | | This amends commit 119882714f87ffeb6945fdb2d02997ae125ff50c. Change-Id: Ifb105596af5b00b04344cb665b3e68292c9187ae Reviewed-by: Romain Perier <romain.perier@gmail.com> Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
* | Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2013-06-121-1/+12
|\| | | | | | | | | | | | | Conflicts: src/plugins/platforms/cocoa/qcocoamenubar.mm Change-Id: I4a699fc8a7f30b2af9de8e496c3d5f027b7495bb
| * Cocoa:Fixed crash when sharing QMenu between two QMenuBar instancesRomain Perier2013-06-071-1/+12
| | | | | | | | | | | | | | | | | | | | | | Don't insert a NSMenuItem into a NSMenu if this one already belongs to another NSMenu, this is forbidden in the Cocoa framework and raises an Exception. The solution consists in tagging the menu as sharable and moving it from one menubar to another when the window gets focus. Task-number: QTBUG-31342 Change-Id: Ic3bfadd4704f363ac26122ae15547543a0f6d44d Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
* | Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2013-06-041-1/+1
|\| | | | | | | | | | | | | | | Conflicts: src/corelib/global/qglobal.h src/plugins/platforms/cocoa/qnsview.mm Change-Id: I6fe345df5c417cb7a55a3f91285d9b47a22c04fa
| * Cocoa: Use actual modifiers when sending ShortcutOverride eventGabriel de Dietrich2013-05-281-1/+1
| | | | | | | | | | | | | | Probably a typo since keyCode clearly has no modifiers encoded. Change-Id: I1c7908b06a759baf7b2c3462861a5d61f8c52b9f Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
* | Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2013-05-231-0/+10
|\| | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qdatastream.cpp src/corelib/io/qdatastream.h src/corelib/json/qjsonwriter.cpp src/plugins/platforms/cocoa/qcocoawindow.mm src/plugins/platforms/xcb/qxcbkeyboard.cpp Change-Id: I46fef1455f5a9f2ce1ec394a3c65881093c51b62
| * Ensure the hovered signal is emitted for the action and menu for CocoaAndy Shaw2013-05-131-0/+10
| | | | | | | | | | | | | | | | | | | | In the Cocoa platform plugin the hovered signal() was not being emitted for the corresponding QMenu. This now ensures it is emitted for the action itself and its QMenu. Task-number: QTBUG-30841 Change-Id: I3cfe634a71de7b55550e2561eb1c6a939536216d Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
* | Improve Qt-in-namespace implementation in the Cocoa platform pluginRomain Perier2013-05-161-4/+6
|/ | | | | | | | | | | | | Objective-C++ does not support namespaces. In order to make this work, we decorate each symbol with suffix using the macro QT_MANGLE_NAMESPACE. However, with such a technic each public symbol needs to be explicitly exported through this macro. The use of @compatibility_alias allows to define alias to use it automatically and transparently. Task-number: QTBUG-23946 Change-Id: Id521b8160bab126fda40a9d960277b1c04cc8b66 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
* Don't crash on null QCoocaMenuItem.Morten Johan Sørvig2013-04-261-2/+4
| | | | | Change-Id: Ia70f616983141134afe874b69a5957e31f6f5ed9 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
* Increase the loopLevel when activating menu items.Morten Johan Sørvig2013-04-261-0/+3
| | | | | | | | | | | | | | | | | Apply 0293aff5c44202e5c62e229b74d8bd0bf9206185 from Qt 4. Without this, calls to deleteLater() may create delete later events with a loopLevel of 1. Those events will not be processed until QApplication::exec() returns. Add a QScopedLoopLevelCounter that increases the loopLevel for the duration of the activated() call. Task-number: QTBUG-30660 Change-Id: I7ab3bb3a53243691b8f7f64e025150e5cc7da2c8 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
* Fix shortcut override for menusFrederik Gladhorn2013-04-261-0/+95
| | | | | | | | | | | | | | | | | | Since we use native Cocoa menus, we cannot rely on the normal shortcut handling. Shortcuts can be overridden by the currently focused object in Qt. In order to make that possible we need to send a QShortcutOverride event before accepting any key event. For menus the key event goes from the NSApp directly to the menu, so the shortcutOverride would not work. This is mostly an adaptation of the Qt 4 code. Task-number: QTBUG-30695 Change-Id: Icb4979309d2d6f9606eb9c8abc4130dc79926593 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
* Cocoa: Improve text heuristic menu item syncing logicGabriel de Dietrich2013-04-251-2/+13
| | | | | | | | | | | | | | | Don't try anything after the original syncing, particularly after changing the menu item's text. Also, don't try anything if the menu item cannot be linked up to a menubar (see QTBUG-30756). This latter point requires extra syncing after adding a menu in the menubar. Finally, to be able to find the menubar, we need to clean the code for moc's eyes. Task-number: QTBUG-30756 Task-number: QTBUG-30812 Change-Id: I88fad663f1c35d03a0cb167d1723d16f590918c0 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
* Cocoa: Reflect menu hierarchy in QCocoaMenu* objectsGabriel de Dietrich2013-04-251-0/+5
| | | | | | | | | | | | | | QCocoaMenu is child of either a QCocoaMenuBar, a QCocoaMenuItem as a submenu, or nothing as a standalone menu. QCocoaMenuItem is child of its containing QCocoaMenu. The parent is set during insertion and cleared during removal. QMenu needs to be updated to avoid double deletion and leaking its own platform menu. Change-Id: Iadf60d8062d7466fa616f84f3761fe322fc9aa2e Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
* Cocoa: Remove dead code in QCocoaMenu*Gabriel de Dietrich2013-04-251-5/+0
| | | | | Change-Id: I56136594f073295ced645d06f657187a54e84384 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
* Mac: Fix various memory leaksGabriel de Dietrich2013-04-181-2/+2
| | | | | Change-Id: Id554be11ffcf9a506c217b0dc5b96cb37c4dd57c Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
* Cocoa: Fix menu popup, againGabriel de Dietrich2013-04-161-28/+38
| | | | | | | | This time, popUpContextMenu:withEvent:forView: wouldn't respect the menu's minimum width setting. Change-Id: I7731851f2cf45d596d45a24dab5abe7b9239f07f Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
* Add autorelease pools needed by Qt Creator.Morten Johan Sørvig2013-04-151-0/+2
| | | | | | | | With these Qt Creator startup is now warning-free on 10.6. Change-Id: Ie29d360611c0e516258920163e4e94d174217299 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
* Cocoa: Fix popup menus on modal windowsGabriel de Dietrich2013-04-151-3/+33
| | | | | | | | | Previously, we used -popUpMenuPositioningItem:atLocation:inView: but this turns out not to work with modal windows. This can actually be reproduced in Cocoa. Change-Id: I9b750d1f97637f0cc30329d3da3acf5200f62206 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
* Cocoa QPA: Make QCocoaMenu::menuItemAt() more robustGabriel de Dietrich2013-02-181-1/+4
| | | | | Change-Id: I2c68f87eb1a4926ca5bd0bfcc842ab9c56c99cd7 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
* QPA Cocoa Menu: Make sure mouse button state is clean after popupGabriel de Dietrich2013-02-111-12/+5
| | | | | | | | | | | Calling popUpMenuPositioningItem:atLocation:inView: will swallow any mouse up/released event, if we popup on mouse down/pressed. Since we cache the button state in QNSView, the safest way seems to be to clear this button state. Another option would be to send Cocoa mouse up events for each mouse button, but we prefer to keep things simple. Change-Id: I7f3f369c45e9f5ed9d2ab693bffd8be4a4596ae6 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
* Cocoa: Make QCocoaMenu::showPopup() more robustGabriel de Dietrich2013-01-211-2/+2
| | | | | Change-Id: Ie4ae5806ea2f23f16597578796be36f2123c05fa Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
* QPA, Cocoa: Add platform popup menusGabriel de Dietrich2013-01-111-0/+37
| | | | | | | | Also, allow to set menu-wide font (instead of per menu item), and minimum width. Change-Id: I5f83f260602f55b9409ad69abf670afb59b2d33a Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
* Cocoa: application menu items sometimes get duplicatedRichard Moe Gustavsen2012-11-141-3/+17
| | | | | | | | | | | | | | | | | | Under some circumstances, the same menu item appears several times in the application menu in the menu bar. This can be seen in Qt creator, where "About Qt Creator" appears twize. The reason is that QCocoaMenu::syncMenuItem does not take into account that merged items cannot be found in the QCocoaMenu that owns the menuItem, but rather inside the application menu. And because of this, it fails cleaning up the old item when it changes from e.g TextHeuristicRole to ApplicationRole. This patch will fix this. Change-Id: Ia84f552d1788d80d778c7dded3393412b9d2d8cb Reviewed-by: Chris Meyer <cmeyer1969@gmail.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
* Fix syncing of visibility and enabled for menus on CocoaAndy Shaw2012-10-261-0/+6
| | | | | | | | | | | Fixed menu handling on Cocoa so if a menu is enabled/disabled or made visible or not then it will keep this in sync with the appropriate native menu entry. Change-Id: If269185fcf065fb1b2f60d6ef8c27c107eb4509f Reviewed-by: Pasi Matilainen <pasi.matilainen@digia.com> Reviewed-by: James Turner <james.turner@kdab.com> Reviewed-by: Andy Shaw <andy.shaw@digia.com>
* Check if there is an old item before removing itAndy Shaw2012-10-161-3/+2
| | | | | | | | | | | If something had changed with the menu item before it had actually been originally added to the native menu then this would crash when trying to remove a null item from the native menu. This prevents that from happening. Change-Id: I8d78b5504759225364d5fd051a23c8d6dbd7d1eb Reviewed-by: James Turner <james.turner@kdab.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
* Change Q_ASSERT to warnings and returns for the menu classesAndy Shaw2012-10-031-6/+26
| | | | | | | | | | | On Mac usually release frameworks are used during development so asserts don't tend to get fired. Since the menu code did not crash in Qt 4.8, it was decided that we should ensure that the same code does not crash now so instead we warn instead of asserting for those cases. Change-Id: I923e5591202cb2ad801074ce3ad2a11d7190cee8 Reviewed-by: James Turner <james.turner@kdab.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>