Commit Graph

36136 Commits

Author SHA1 Message Date
Nico Vertriest
b1bbce2609 Doc: Update doc for Dir View Example
Task-number: QTBUG-60635
Change-Id: I4a23f4866c76b9f5c29653ca30e44c3b844a9aa8
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
2018-04-25 09:02:02 +00:00
Nico Vertriest
5155942a0d Doc: Update Gradients Example
modify to latest syntax for connect statements

Task-number: QTBUG-60635
Change-Id: Ie0f8f6bdbd5aec7379f7572e978adf65b9a96bdc
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2018-04-25 09:01:47 +00:00
Friedemann Kleint
1b1fd81a81 Windows QPA: Add missing calls to keyboard initialization
Add calls to changeKeyboard() to the QWindowsKeyMapper constructor
and the handling of WM_INPUTLANGCHANGE so that the locale is
correctly initialized and changes are processed.

Change-Id: Ia30d8c6434ca85165e4882240ae16f9a75dcf4ff
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-04-25 07:42:55 +00:00
Friedemann Kleint
f7980f4eda Windows QPA: Fix handling of VK_DECIMAL/VK_SEPARATOR
Remove the hardcoded mapping from the key table for fallback keys
since the keys are locale-dependent.

Task-number: QTBUG-57992
Change-Id: I016ab5f7f7e8abfd30f6416d2e7597db7deecb9b
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-04-25 07:42:43 +00:00
Allan Sandfeld Jensen
18db0b49c6 Don't crash on <br> following a <table>
A <br> has a new-line but no text, so be able to handle no lines.

Task-number: QTBUG-60853
Change-Id: I3d4dbd529114bbe8afe760c3622b52446202ec7c
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2018-04-25 07:08:50 +00:00
Kari Oikarinen
73031ebb99 tests/auto/widgets/{effects,styles}: Avoid unconditional qWait()s
Task-number: QTBUG-63992
Change-Id: I1af537bae705d4627880c5ae50669b1ef72562f2
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2018-04-25 05:47:01 +00:00
Johan Klokkhammer Helsing
8ac0e6592b Skip flaky tst_QWindow::childWindowPositioning on Wayland
Sometimes causes protocol errors (i.e. termination) on Wayland with xdg-shell
v6.

Task-number: QTBUG-67648
Change-Id: I6c855affb145590f47a425d233c5fd6b7e1e8914
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-04-25 04:51:34 +00:00
Morten Johan Sørvig
0f6a6b2bff Cocoa: Don’t starve the event loop on requestUpdate()
Some of our examples, and perhaps also some applications,
call requestUpdate() immediately after producing a
frame. This can cause Cocoa to immediately start
(trying to) draw a new frame without processing e.g.
input events.

This should (and will) be handled by rate limiting
updates with CVDisplayLink. In the mean time fall back
to using the base class QPlatformWindow implementation,
which is implemented using a timer, which will allow
for input event processing.

Change-Id: Ic2541f344b2f4018d785404a06274959a7bad2df
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
2018-04-24 19:48:50 +00:00
Gabriel de Dietrich
c7eb2c173e QCocoaFontDialogHelper: Fix NSFontManager delegate warning
According to Apple's documentation, there's no delegate
in NSFontManager. We set its target instead. The action
is changeFont: by default.

Change-Id: I8c01bfa97c78dd8097f38c27353748d13f51489f
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2018-04-24 19:46:14 +00:00
Gabriel de Dietrich
a4e6117c53 Style sheets: detect and use font set on QHeaderViews
We also ask the parent style to draw the header label
instead of the base style which is more likely to respect
other text related parameters.

Change-Id: I6dd658fa4d016a76d7c450478dc42f07e4b807c4
Task-number: QTBUG-33855
Task-number: QTBUG-37153
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2018-04-24 18:27:34 +00:00
Allan Sandfeld Jensen
e413874467 Fix division by zero in radial gradiants with NEON
The NEON implementation uses rsqrt and thus can not be taken on 0, so
replace the minimum with something close to zero instead of zero.

Task-number: QTBUG-59961
Change-Id: Ia39e45be675b056c1e22900495ce9ba4e8b70e5f
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2018-04-24 18:16:54 +00:00
Gabriel de Dietrich
143cf9e467 QCocoaWindow: Fix handleMouseEvent() compilation warning
qtbase/src/plugins/platforms/cocoa/qcocoawindow.mm:408:53: warning:
      'handleMouseEvent<QWindowSystemInterface::DefaultDelivery>' is deprecated [-Wdeprecated-declarations]
                            QWindowSystemInterface::handleMouseEvent(window(), window()->mapFromGlobal(localPoint.toPoint()), localPoint,

Change-Id: Ifbf8c46e31a1de2089ce0e16cec087fdd9adb64e
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2018-04-24 17:42:53 +00:00
Thiago Macieira
309dacedac Atomics: remove requirement for alignment equality with plain types
This was originally added so that you could replace a T with
QAtomicInteger<T> in the same class and still keep ABI. However, for
legacy reasons, on 32-bit x86, types larger than 4 bytes keep an old
1990s alignment of only 4 bytes, but modern std::atomic<T> for those 8-
byte types enforces an alignment of 8 bytes. Therefore, the requirement
to keep alignment is not possible to guarantee.

In other words: you may not replace T with QAtomicInteger<T> or
std::atomic<T> and assume no ABI breakages in all platforms.

This is a requirement to implement atomicity. An 8-byte type aligned to
only a 4-byte boundary could cross a 16-byte boundary or, worse, cross a
cacheline boundary. Crossing the 16-byte boundary could be bad on some
processors, but crossing the cacheline boundary (addresses ending in
0x3C, 0x7C, 0xCC and 0xFC, or 4 out of 64 possible addresses or 6.25%)
is always bad: the CPUs cannot guarantee an atomic load or store
operation.

See also <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71660>.

Task-number: QTBUG-67858
Change-Id: If90a92b041d3442fa0a4fffd15283e4615474582
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2018-04-24 17:36:42 +00:00
Kari Oikarinen
15ada2b917 tests/auto/widgets/kernel: Avoid unconditional qWait()s
Task-number: QTBUG-63992
Change-Id: Icb32b516002c3bb2841c8e7a29624e54cfcbbcac
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
2018-04-24 05:01:57 +00:00
Qt Forward Merge Bot
02268b8496 Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: If950406391f79d99f0101f0b6755395accb26f34
2018-04-24 01:00:19 +02:00
Simon Hausmann
be9a56e5e3 Make it easier to use resources in plugins when using static linking
RCC generates code that registers resources automatically on program
startup via global constructors. When linking statically and nothing
references the symbols in the .o file compiled from the RCC generated
code, then the linker will discard the embedded resources and they will
not get initialized. That is why for static linking it is necessary to
explicitly initialize resources using the Q_INIT_RESOURCE macro.

We can avoid the need for the explicit initialization in the context of
plugins that are statically linked into the application. resources.prf
can generate a .cpp file with a helper function that contains all the
Q_INIT_RESOURCE calls for all resources in the plugin. That helper
function in turn is injected into the plugin entry point, which in turn
is guaranteed to be included in the final binary.

Change-Id: If1abf9c85ef92935020af073b989c58c1ae6ca63
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2018-04-23 13:56:07 +00:00
Lars Knoll
c579f49e2a Fix QML integration of widgets
We need to mark the object as deleted before destroying
it's declarative data, otherwise all sorts of bad things
can happen.

This fixes the qwidgetsinqml autotest in qtdeclarative.

Change-Id: I05a645ebe1ca7a50c8927e3dbd9ebb5aaf369a71
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
(cherry picked from commit 3e91625b58)
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-04-23 13:46:55 +00:00
Martin Smith
b458cb312c doc: Make both qEnvironmentVariable() functions visible in the docs
There had been a fake declaration for qEnvironmentVariable() in qglobal.h
thaqt was only visible to QDoc. It was removed in favor of documenting
both the actual declarations of qEnvironmentVariable(), one with a 2nd
parameter for passing a defualt value and one without that parameter.
But the one without the default value parameter was marked internal, so
it didn't appear in the docs.

When both functions were documented with a shared comment, a bug in
QDoc was revealed, because these functions are global, while the shared
comment functionality had only been implemented for class member functions.
Now the shared comment functionality has been implemented for global
functions, so these two functions are now documented with a shared
comment. We can, of course, reintroduce the #ifdef QCLANG_QDOC trick, if
that is pre3ferred.

Change-Id: I41d85def5daa3215a995d7697d064dfae37e8b2a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-04-23 13:28:51 +00:00
Friedemann Kleint
994e0e4c36 Windows QPA: Fix Korean IME removing words when using CTRL shortcuts
Ignore the WM_IME_ENDCOMPOSITION message in that case.

Done-with: Tobias Koenig <tobias.koenig@kdab.com>
Task-number: QTBUG-58300
Change-Id: I9506754a149905222a324b85634964fce398d3ac
Reviewed-by: Liang Qi <liang.qi@qt.io>
2018-04-23 12:57:43 +00:00
Mårten Nordheim
72bb1d95fd Introduce QPasswordDigestor functions
Added a few functions to derive keys from passwords. Currently it
supports PBKDF1 and PBKDF2 as defined in
RFC 8018 ( https://tools.ietf.org/html/rfc8018 ).

[ChangeLog][QtNetwork][QPasswordDigestor] Added QPasswordDigestor

Task-number: QTBUG-30550
Change-Id: I2166b518bd8b54e3486514166e76fd9ba2f219c8
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2018-04-23 12:55:45 +00:00
Mårten Nordheim
c45802e33a QSslKey: Implement PKCS#8 support for the generic backend
This patch adds the ability to decode keys which are encoded with PKCS#8
using the generic back-end (used in winrt and secure transport).

It works on both WinRT and macOS; however QSslKey seems unused in the
WinRT backend and it seems only RSA keys can be used for certificates
on macOS. Meaning that DSA and Ec, which in theory* should represent
their unencrypted versions, can't currently be tested properly.

* Can also be confirmed by loading the key using the ST or WinRT
backend, calling toPem(), writing the output to a file and then loading
the unencrypted key using openssl.

[ChangeLog][QtNetwork][QSslKey] Added support for PKCS#8-encoded keys
in the generic SSL back-end (used for SecureTransport on macOS and for
WinRT). Note that it does not support keys encrypted with a PKCS#12
algorithm.

Task-number: QTBUG-59068
Change-Id: Ib27338edc7dbcb5c5e4b02addfdb4b62ac93a4c3
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2018-04-23 12:55:38 +00:00
Tor Arne Vestbø
79d900bee4 iOS: Document why we're using a runloop mode tracker in our event dispatcher
Change-Id: I71093ca05988c3e1ad6d51be7363952dd3f0518e
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2018-04-23 12:55:32 +00:00
Kari Oikarinen
12559058b0 tst_QFile: Don't expect Windows HANDLE equality in nativeHandleLeaks()
That check is flaky on Windows. It doesn't seem to be testing Qt functionality.
I also don't see CreateFile2() documentation mentioning any guarantees that
opening the same file twice would give the same HANDLE each time.

Change-Id: Ica2e60571ae9fc39bf822803a2a9dd6add8323d7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2018-04-23 12:45:32 +00:00
David Faure
46ec170d2b Speed up QTimeZone::isTimeZoneIdAvailable by a factor 43
Creating and sorting a list of bytearrays just to check if one entry is
present, is really overkill. By adding a new virtual method
isTimeZoneIdAvailable() in the backend classes, we can do this much more
efficiently.

Implemented for Utc and Tz backends, the others fall back to the
slow way.

The new benchmark shows, in release mode:
Before: 43 msecs per iteration (total: 86, iterations: 2)
After: 1.1 msecs per iteration (total: 73, iterations: 64)

Change-Id: Ic0d79a41d74e2ce6aa088fa7986c41d33902c36b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-04-23 06:48:12 +00:00
Kai Koehne
7b87bdff1a Doc: Mark local functions in qlogging.cpp as internal
This fixes qdoc warnings introduced by 67d5f79fe6.

Change-Id: I4b199e6243d9a7706befe4bc9549c78c11026d9e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-04-23 06:27:57 +00:00
Kai Koehne
a69a3594e2 Doc: Advocate use of std::initializer_list constructor in Q[String]List
We're relying on C++11 since a while, so lets not advertise creating
lists of strings with operator<<() anymore.

Change-Id: I14a3442ff852ac2c106d90c63504eb9ebb737609
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2018-04-23 06:27:40 +00:00
Christian Ehrlicher
c782ed3c48 QHeaderView: emit geometriesChanged() when the header is resized
When the QHeaderView is resized (e.g. due to setFixedWidth), the views
are not notified about it and the layout is not updated which leads to
a wrong painting. Therefore we have to listen for QEvent::Resize the
same way as when the font or style changes.

Task-number: QTBUG-67532
Task-number: QTBUG-34095
Change-Id: Id70daf083e0dddc2500d8e5aad47513266887a2c
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
2018-04-22 19:30:28 +00:00
Peng Wu
e555c03a42 Style sheets: Include margin while calculating QHeaderview section size
Align with QCommonstyle QHeaderview section size calculation.

Change-Id: I4c11e1881f48850ace3bdbb3c96f999cc298c91e
Task-number: QTBUG-56457
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2018-04-22 19:30:20 +00:00
Tor Arne Vestbø
070aec28e6 qmake: Fix prl lookup for suffixed frameworks on Apple platforms
We need to take into account the presence of a possible ',_debug' suffix.

Change-Id: I5655394b78723bbc6cc32e56849acc2366d288e2
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2018-04-22 17:10:23 +00:00
Daniel Savi
84eb9b5e30 Add image quality handling to QTextImageFormat
This patch enhances QTextImageFormat with a property for image quality.
Default will be quality of 100. The user may set different values with
setQuality(int). QTextODFexport will export images as png if quality is
set to 100 and as jpg with the compression quality set to the given value
if smaller than 100.

[ChangeLog][QtGui][QTextImageFormat] Adds two new functions to the class:
setQuality(int=100) and quality(). Is currently used by QTextODFWriter to
determine the image type and quality when exporting images to ODT files.

Change-Id: Iaa8ec0246aaba004d98c9e8c66609795101519a9
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-04-22 12:47:26 +00:00
Christian Ehrlicher
b3bbba7b87 Examples: fix wrong QRegExp in Custom Sort/Filter Model Example
Fix wrong QRegExp in Custom Sort/Filter Model Example and replace it
with QRegularExpression.

Task-number: QTBUG-61129
Change-Id: I515474ee6985d36195d90dcd93876ba28a83bccc
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Samuel Gaist <samuel.gaist@edeltech.ch>
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2018-04-22 12:46:45 +00:00
Qt Forward Merge Bot
999ba23946 Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: Id32f0ae002772444c0b61cd132ef81f96fe3b895
2018-04-22 01:00:14 +02:00
Mårten Nordheim
2fe80ed203 QSslSocket: Call transmit when encrypted on WinRT
Once connection is established the socket emits 'connected', and then
you can start writing. But it will end up in the write-buffer and won't
get sent until 'transmit' is called. Some code (e.g. QWebSocket) relies
on QSslSocket transmitting once it's encrypted. This is done in the
OpenSSL backend but was not done in the WinRT backend.

Task-number: QTBUG-56558
Change-Id: I8cf5d3257f3597a4bb80f35369490a3816506a34
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2018-04-21 12:16:16 +00:00
Allan Sandfeld Jensen
591edbb11c Detect C standard and try using the most recent one (take 2)
Fixes the default C version used with gcc < 5

Change-Id: I948dece961caed8e6b181e1c6e6b9dc43c46583e
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2018-04-21 09:05:14 +00:00
Andre Hartmann
9aced25ab5 QByteArray: Use nullptr for "Safe and portable C string functions"
Change the documentation to use nullptr and modify the related code
also while at it.

Change-Id: I6264a254828159cda54e90393835ea04e131350b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-04-21 06:07:31 +00:00
Andre Hartmann
bca1d8c382 QByteArray: Add a note regarding overlapping pointers to qstr(n)cpy
Stated e.g. in http://en.cppreference.com/w/c/string/byte/strcpy

Change-Id: I42fd5a5fa6a63b67a7105aa56e93e3d3f2193cf7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-04-21 06:04:22 +00:00
Michael Weghorn
17ae9305af q{cocoa,ppd}printdevice: Fix string comparison
'QPrint::Color' should be returned in case 'ColorModel'
is NOT set to 'Gray'. However, the logic was inverted
before, since 'qstrcmp()' returns 0 if the two strings
match.

Also, eliminate a redundant condition:
The left-hand side of the '||' already makes sure that
'colorModel' is non-null, so there's no need to check again.
(Corresponding cppcheck warning: "Redundant condition: colorModel.
'!A || (A && B)' is equivalent to '!A || B'")

Change-Id: I965c29e8c020bc9c47a53678e23d94f05be3fd53
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
2018-04-20 22:05:46 +00:00
Friedemann Kleint
a38c46ad85 Windows QPA: Fix ambiguous shortcut overload warnings for ALT-keys
Use the match with the least modifiers (prefer Shift+9 over
Alt + Shift + 9) resulting in more missing modifiers.

Task-number: QTBUG-67200
Change-Id: I90463c0dfaadda29dcd24a08ba35c91fac8bd04c
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-04-20 21:37:39 +00:00
Friedemann Kleint
a0a22037cd Windows QPA: Fix duplicate/missing native events
Add utility functions to QWindowsContext input messages sent to
native event filters (event dispatcher and window system interface).

Do not send input and similar events to the event dispatcher since
QEventDispatcherWin32::processEvents() also sends them.

Note though that QEventDispatcherWin32 does not receive all windows
messages.

In QWindowsKeyMapper, send the WM_CHAR/WM_IMECHAR events from
where the messages are removed.

Task-number: QTBUG-67095
Change-Id: I5f61294fcb3aee7e0eacd840a2010d128cd02a5d
Reviewed-by: Andre de la Rocha <andre.rocha@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2018-04-20 21:37:27 +00:00
Qt Forward Merge Bot
100ebf1c97 Merge "Merge remote-tracking branch 'origin/5.11' into dev" into refs/staging/dev 2018-04-20 20:06:18 +00:00
Qt Forward Merge Bot
6f45fda50b Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: I0bea38585382b5d9c8d7a013bf6bcb3a6008d159
2018-04-20 21:22:53 +02:00
Gabriel de Dietrich
f35f282c4f Cocoa Helpers: Add qt_objc_cast() function
This generalizes what qnsview_cast() does to any Objective-C class.

Notice that this is a loose cast, using isKindOfClass: instead
of isMemberOfClass:.

Change-Id: I745f548e474f2f9eef89f370d7d45496f0c51434
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2018-04-20 17:45:23 +00:00
Tor Arne Vestbø
2b40af7177 tst_qimagereader: Make sure to include all image resources in test
The manually maintained qrc file was missing corrupt_clut.bmp among
others.

Change-Id: I8916ba76a63950de03f25814d893306d046d273d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-04-20 15:05:01 +00:00
Anton Kudryavtsev
ab6cc41968 QTabWidget: clarify ownership after insertTab() and addTab()
Change-Id: I7cd3aa5c092c99bbafd09c4bea7c6824d0b6740a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2018-04-20 10:40:37 +00:00
Mirko Vogt
a8f73a1624 configure: mention -libudev in help output
amends 684a1559f.

Change-Id: I25fd5f096e99937382048e2eb763715b9578a8fb
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2018-04-20 10:38:03 +00:00
Andy Shaw
7c532891e0 Send ShortcutOverride event when receiving a non-spontaneous key press
When a key press is received which is not spontaneous then it needs to
be manually sent as a shortcut override event to ensure that any
matching shortcut is triggered first. This enables emulation/playback
of recorded events to still have the same effect.

[ChangeLog][QtWidgets] Sending a key press event with sendEvent() now
sends a ShortCutOverride event first to the widget to trigger any
shortcuts set first.

Task-number: QTBUG-48325
Change-Id: Iafcc2cdb1773bffe89edaeb0abc44cd5a51088e6
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2018-04-20 10:18:49 +00:00
Gabriel de Dietrich
7ee44dcb9c Cocoa QPA: Clean up 0 as pointer
We use nil for Objective-C null pointers and nullptr everywhere
else, including CoreFoundation and similar opaque types.

Change-Id: Id75c59413dec54bf4d8e83cf7ed0ff7f3d8bb480
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2018-04-19 22:20:12 +00:00
Gabriel de Dietrich
48defe41e1 Cocoa Menus: Allow separators in app menu
We extend QCocoaNSMenuItem with separator items capabilities
and use it as any other custom item in the app menu.

Addition and removal of items in the app menu remains very
basic because that menu doesn't exist as such. Instead, it's
hinted through the QAction's menu role.

Change-Id: Ia13bfcc008c75e49fd21705d2528da5a85ed1c73
Task-number: QTBUG-63756
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2018-04-19 22:20:05 +00:00
Gabriel de Dietrich
99290faa66 QCocoaMenuLoader: Add app specific items after Preferences
This is in accordance with the macOS HIG which state that, "in general,
a Preferences menu item should be the first app-specific menu item." See
https://developer.apple.com/macos/human-interface-guidelines/menus/menu-bar-menus/

Change-Id: Ie2b6ce274995a7d0b0e934c6a68241500a39f7aa
Task-number: QTBUG-63756
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2018-04-19 22:19:59 +00:00
Gabriel de Dietrich
b7be91b5f2 Cocoa Menus: Use the responder chain for menu items target/action
We start by setting the menu item target to nil.

Then, -[qt_itemFired:] action is now in QNSView, which itself is
naturally inserted in the responder chain. This removes the need
to track and change the menu item's target/action when we're
displaying a native dialog. Part of this is possible because we
now derive our own QCocoaNSMenuItem class from NSMenuItem.

We use -[respondsToSelector:] to decide whether the QNSView in
the responder chain should respond to cut:, copy:, etc. And we
only return YES when the view is first responder. The invocation
to these action is forwarded to the same views' -[qt_itemFired:].

Message forwarding is done via forwardInvocation:, but experiments
have shown that it can be done by the sole means of respondsToSelector:
and direct invocation from cut:, copy:, etc. See the usage of the
macro QT_COCOA_DYNAMIC_MENU_ITEM_ACTION.

Menu validation also happens in QNSView and looks for modal windows.
Therefore, -[worksWhenModal] is no longer necessary. Also, since the
target is no longer set, the logic as documented in NSMenuItem.target
won't work anymore.

Most items from QCocoaMenuLoader also become QCocoaNSMenuItem and
get the same target/action, which removes a bit of duplicated (and
outdated) code. A particular case is the Quit item, which gets the
terminate: action set until an actual menu item is added.

Tested with texedit and standard dialogs examples together with
menus, menurama and bigmenucreator manual tests.

We also renamed some functions and variables to reflect common
naming practices.

Change-Id: I9b51d3be3467a666d8c3dcf8585edbc821e0282e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2018-04-19 22:19:46 +00:00