qt6-bb10/tests/auto/gui/kernel
Giuseppe D'Angelo 25351dcc54 Long live QKeyCombination!
C++20 via P1120 is deprecating arithmetic operations between
unrelated enumeration types, and GCC 10 is already complaining.
Hence, these operations might become illegal in C++23 or C++26 at
the latest.

A case of this that affects Qt is in key combinations: a
QKeySequence can be constructed by summing / ORing modifiers and a
key, for instance:

  Qt::CTRL + Qt::Key_A
  Qt::SHIFT | Qt::CTRL | Qt::Key_G (recommended, see below)

The problem is that the modifiers and the key belong to different
enumerations (and there's 2 enumerations for the modifier, and one
for the key).

To solve this: add a dedicated class to represent a combination of
keys, and operators between those enumerations to build instances
of this class.

I would've simply defined operator|, but again docs and pre-existing
code use operator+ as well, so added both to at least tackle simple
cases (modifier + key).

Multiple modifiers create a problem: operator+ between them yields
int, not the corresponding flags type (because operator+ is not
overloaded for this use case):

  Qt::CTRL + Qt::SHIFT + Qt::Key_A
  \__________________/      /
          int              /
           \______________/
                  int

Not only this loses track of the datatypes involved, but it would
also then "add" the key (with NO warnings, now its int + enum, so
it's not mixing enums!) and yielding int again.

I don't want to special-case this; the point of the class is
that int is the wrong datatype. Everything works just fine when
using operator| instead:

  Qt::CTRL | Qt::SHIFT | Qt::Key_A
  \__________________/      /
      Qt::Modifiers        /
           \______________/
            QKeyCombination

So I'm defining operator+ so that the simple cases still work,
but also deprecating it.

Port some code around Qt to the new class. In certain cases,
it's a huge win for clarity. In some others, I've just added
the necessary casts to make it still compile without warnings,
without attempting refactorings.

[ChangeLog][QtCore][QKeyCombination] New class to represent
a combination of a key and zero or more modifiers, to be used
when defining shortcuts or similar.

[ChangeLog][Potentially Source-Incompatible Changes] A keyboard
modifier (such as Qt::CTRL, Qt::AltModifier, etc.) should be
combined with a key (such as Qt::Key_A, Qt::Key_F1, etc.) by using
operator|, not operator+.  The result is now an object of type
QKeyCombination, that stores the key and the modifiers.

Change-Id: I657a3a328232f059023fff69c5031ee31cc91dd6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-03 07:00:31 +02:00
..
noqteventloop Deprecate and remove uses of AA_DisableHighDpiScaling 2020-08-31 19:14:55 +02:00
qaction Cover more properties in the QAction test 2020-07-17 08:26:56 +02:00
qactiongroup CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qaddpostroutine Merge remote-tracking branch 'origin/5.15' into dev 2020-04-08 20:11:39 +02:00
qbackingstore Introduce QWindow::paintEvent with QPA plumbing 2020-08-26 16:44:53 +02:00
qclipboard Windows QPA: Move mime-type related classes to the new interface 2020-07-28 13:20:23 +02:00
qcursor CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qdrag CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qevent CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qfileopenevent CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qguiapplication Rename confusingly named QFont/QPalette::resolve overloads 2020-08-25 17:59:10 +02:00
qguieventdispatcher CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qguieventloop CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qguimetatype Cleanup QTypeInfo 2020-08-26 01:03:22 +02:00
qguitimer CMake: Properly handle CONFIG += thread aka Threads::Threads 2020-08-06 19:15:39 +02:00
qguivariant Use OpenType font weights 2020-08-28 07:26:54 +02:00
qhighdpiscaling Fix tst_QHighDpiScaling::scale 2020-08-28 13:00:05 +02:00
qinputdevice CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qinputmethod CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qkeyevent CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qkeysequence Long live QKeyCombination! 2020-09-03 07:00:31 +02:00
qmouseevent Introduce QEvent::isPointerEvent() 2020-08-25 06:34:01 +02:00
qmouseevent_modal CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qopenglwindow CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qpalette Rename confusingly named QFont/QPalette::resolve overloads 2020-08-25 17:59:10 +02:00
qpixelformat CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qrasterwindow CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qscreen CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qshortcut CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qsurfaceformat CMake: Regenerate tests with new qt_ prefixed APIs 2020-07-09 09:38:35 +02:00
qtouchevent Introduce QEvent::isPointerEvent() 2020-08-25 06:34:01 +02:00
qwindow Introduce QWindow::paintEvent with QPA plumbing 2020-08-26 16:44:53 +02:00
.prev_CMakeLists.txt CMake: Skip / ignore failing tests on CMake platforms 2020-07-01 14:55:29 +02:00
CMakeLists.txt CMake: Skip / ignore failing tests on CMake platforms 2020-07-01 14:55:29 +02:00
kernel.pro Begin writing tst_QInputDevice autotest 2020-06-18 08:05:44 +02:00