summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qshortcutmap.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Make QKeyMapper::possibleKeys() return list of QKeyCombinationsTor Arne Vestbø2023-10-111-2/+3
| | | | | | | | | Having the explicit type instead of the opaque int makes it clearer what we're dealing with. Task-number: QTBUG-116873 Change-Id: I19e42ed329e15ab25a958602ecfb99b1c9d52a99 Reviewed-by: Liang Qi <liang.qi@qt.io>
* Remove QShortcutMap::matches() and use QKeySequence::matches() insteadTor Arne Vestbø2023-09-211-36/+2
| | | | | | | | | | | | | | | | | | | | | | | | | The custom matching function was added in 4d4857027db3 with the rationale that people were mixing up Key_hyphen and Key_Minus all the time, and tried to solve it by treating the two as one and the same in the match function. Unfortunately this doesn't work in practice, as when a keyboard event comes in we resolve a set of possible key sequences from that, and then look those up in the list of sorted shortcut sequences. That lookup is just a binary search, and does not take into account the added logic of the custom matching function. So the binary search will fail to find the matching key sequence, and as a result we never get a chance to call matches() with a potentially malleable key sequence (for example Qt::Key_Minus when the shortcut is Qt::Key_hyphen or vice versa). The only case we do hit the matches function is if we by chance happen to land the binary search iterator on the "unmatched" shortcut, e.g. Qt::Key_hyphen, but this relies on there not being any other shortcuts that sort between Qt::Key_Minus and Qt::Key_hyphen. Task-number: QTBUG-116873 Change-Id: Iaa90991911f32276e29e37e8c7ae87643898bfc9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QShortcutMap: Rename variables to clarify their useTor Arne Vestbø2023-09-211-52/+53
| | | | | | | | | | | The state machinery of QShortcutMap is complicated enough as it is, so let's use better variable names. In particular, let's distinguish the registered shortcuts (QShortcutEntries), from the candidate QKeySequence sequences that we compute based on the incoming events. Task-number: QTBUG-116873 Change-Id: I9bd59097e786ecfb9d241c2eb7b871a4bba9b44f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QShortcutMap::find: Use plain for-loop instead of do-whileTor Arne Vestbø2023-09-201-19/+21
| | | | | | | | | | | | | | | | The logic was a bit convoluted, using a do-while loop when the base premise still was that we needed a valid iterator, and hiding the check of a QKeySequence::NoMatch to break out of the loop far from the match() that produced it. The tempRes (now match) variable no longer has to live outside the loop, and the oneKSResult variable has been renamed to clarify its use. Task-number: QTBUG-116873 Change-Id: I730e768eae2e9a653bf4e28ceece2fe7277ef45d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Andrey Butirsky <butirsky@gmail.com>
* Improve QShortcutMap debug loggingTor Arne Vestbø2023-09-201-5/+5
| | | | | | | Task-number: QTBUG-116873 Change-Id: I6a2b8c25d3da8c9cbcaeb0979b4be85267ba7856 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Andrey Butirsky <butirsky@gmail.com>
* Add more shortcutmap categorized logging outputMitch Curtis2023-04-271-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Show more detail about the checks made against each entry to show why a shortcut might not get delivered. Specifically, it's useful to know if the contextMatcher returned true. In the case of Qt Quick Controls, it can return false if the Shortcut is blocked by a modal popup, or a popup with a CloseOnEscape policy. With this patch, combining qt.gui.shortcutmap with qt.quick.controls.shortcutcontext.matcher makes it possible to see which popup blocks a shortcut. With only the former enabled, it's already quite useful: qt.gui.shortcutmap: Possible shortcut key sequences: QList(QKeySequence("Ctrl+N")) qt.gui.shortcutmap: - checking entry 0 QKeySequence("Ctrl+N") qt.gui.shortcutmap: - matches returned 2 for QKeySequence("Ctrl+N") QKeySequence("Ctrl+N") - correctContext()? false qt.gui.shortcutmap: - matches returned 0 for QKeySequence("Ctrl+N") QKeySequence("Ctrl+O") - correctContext()? false qt.gui.shortcutmap: Found better match ( QList(QKeySequence("Ctrl+N")) ), clearing key sequence list qt.gui.shortcutmap: Added ok key sequence QList(QKeySequence("Ctrl+N")) qt.gui.shortcutmap: Returning shortcut match == 0 qt.gui.shortcutmap: QShortcutMap::nextState(QKeyEvent(ShortcutOverride, Key_N, ControlModifier, text="N")) = 0 Change-Id: I6e96c94a8b62823553837eda3ef2764ca21775c4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Long live Q_UNREACHABLE_RETURN()!Marc Mutz2022-10-151-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a combination of Q_UNREACHABLE() with a return statement. ATM, the return statement is unconditionally included. If we notice that some compilers warn about return after __builtin_unreachable(), then we can map Q_UNREACHABLE_RETURN(...) to Q_UNREACHABLE() without having to touch all the code that uses explicit Q_UNREACHABLE() + return. The fact that Boost has BOOST_UNREACHABLE_RETURN() indicates that there are compilers that complain about a lack of return after Q_UNREACHABLE (we know that MSVC, ICC, and GHS are among them), as well as compilers that complained about a return being present (Coverity). Take this opportunity to properly adapt to Coverity, by leaving out the return statement on this compiler. Apply the macro around the code base, using a clang-tidy transformer rule: const std::string unr = "unr", val = "val", ret = "ret"; auto makeUnreachableReturn = cat("Q_UNREACHABLE_RETURN(", ifBound(val, cat(node(val)), cat("")), ")"); auto ignoringSwitchCases = [](auto stmt) { return anyOf(stmt, switchCase(subStmt(stmt))); }; makeRule( stmt(ignoringSwitchCases(stmt(isExpandedFromMacro("Q_UNREACHABLE")).bind(unr)), nextStmt(returnStmt(optionally(hasReturnValue(expr().bind(val)))).bind(ret))), {changeTo(node(unr), cat(makeUnreachableReturn, ";")), // TODO: why is the ; lost w/o this? changeTo(node(ret), cat(""))}, cat("use ", makeUnreachableReturn)) ); where nextStmt() is copied from some upstream clang-tidy check's private implementation and subStmt() is a private matcher that gives access to SwitchCase's SubStmt. A.k.a. qt-use-unreachable-return. There were some false positives, suppressed them with NOLINTNEXTLINE. They're not really false positiives, it's just that Clang sees the world in one way and if conditonal compilation (#if) differs for other compilers, Clang doesn't know better. This is an artifact of matching two consecutive statements. I haven't figured out how to remove the empty line left by the deletion of the return statement, if it, indeed, was on a separate line, so post-processed the patch to remove all the lines matching ^\+ *$ from the diff: git commit -am meep git reset --hard HEAD^ git diff HEAD..HEAD@{1} | sed '/^\+ *$/d' | recountdiff - | patch -p1 [ChangeLog][QtCore][QtAssert] Added Q_UNREACHABLE_RETURN() macro. Change-Id: I9782939f16091c964f25b7826e1c0dbd13a71305 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-111-1/+1
| | | | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace, with manual unstaging of the actual definition and documentation in dist/, src/corelib/doc/ and src/corelib/global/. Task-number: QTBUG-99313 Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* gui: Fix typos in documentationJonas Kvinge2021-10-121-1/+1
| | | | | | Pick-to: 5.15 6.2 Change-Id: I533f5a55cd0cd60a76990b552d7dab51a301ac1c Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Improve and expand QShortcutMap debug outputMitch Curtis2021-02-031-4/+8
| | | | | | | | | | - Replace vague symbols with descriptive words. - Use qScopeGuard() to ensure that removeShortcut prints the number of removed shortcuts for all execution paths. Change-Id: I4d36366445756b41b1dc40bbb1e987dce669a723 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* iOS: Handle keyboard events when using an external keyboardAndy Shaw2021-01-201-1/+42
| | | | | | | | | | | | | | | | | | This enables the two possible approaches for handling external keyboard events. While support still exists for before 13.4 then both approaches are needed. This ensures that all external keyboard events are handled as key events and passed on accordingly. Additionally, this accounts for possible shortcuts too, therefore a new function is added to QShortcutMap to aid that. As a result, code has now moved from QCocoaKeyMapper to be part of the gui/platforms/darwin part to make it easier to reuse this code elsewhere. Fixes: QTBUG-85727 Change-Id: I349af43468b03fd8dcb16adba02669974affe154 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Replace discouraged Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPEAndreas Buhr2020-11-301-1/+1
| | | | | | | | | | | | | | Q_MOVABLE_TYPE was conceived before C++ had move semantics. Now, with move semantics, its name is misleading. Q_RELOCATABLE_TYPE was introduced as a synonym to Q_MOVABLE_TYPE. Usage of Q_MOVABLE_TYPE is discouraged now. This patch replaces all usages of Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPE in QtBase. As the two are synonymous, this patch should have no impact on users. Pick-to: 6.0 Change-Id: Ie653984363198c1aeb1f70f8e0fa189aae38eb5c Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Exclude all modifiers as candidates for shortcutsTor Arne Vestbø2020-10-121-1/+1
| | | | | | | | | If we're going to limit shortcuts to non-modifiers, we should at least include all of the modifiers, otherwise we'll end up passing through e.g. Key_CapsLock. Change-Id: If11758f85d06f75e9b9c2d2a57d4a4915ff72317 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* Long live QKeyCombination!Giuseppe D'Angelo2020-09-031-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Use QList instead of QVector in gui implementationJarek Kobus2020-07-071-12/+12
| | | | | | | Task-number: QTBUG-84469 Change-Id: I366e845249203d80d640355a7780ac2f91a762f1 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix QShortcutMap::createNewSequences debug loggingTor Arne Vestbø2020-06-301-10/+2
| | | | | | | | We don't need to include the possible keys in the log output as that's handled by the call site in QShortcutMap::find. Change-Id: Ie0635f63a4304fde40a8b671385518dd1e42e2dc Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2019-12-091-6/+6
|\ | | | | | | Change-Id: Ia24cc8b86def0d9d9c17d6775cc519e491b860b1
| * Tidy nullptr usageAllan Sandfeld Jensen2019-12-061-6/+6
| | | | | | | | | | | | | | | | | | | | | | Move away from using 0 as pointer literal. Done using clang-tidy. This is not complete as run-clang-tidy can't handle all of qtbase in one go. Change-Id: I1076a21f32aac0dab078af6f175f7508145eece0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2019-11-291-53/+28
|\| | | | | | | Change-Id: Ib8357609b37b7cc22b51c27602ba60c69bf91da9
| * Improve QShortcutMap debug outputMitch Curtis2019-11-281-53/+28
| | | | | | | | | | | | | | | | | | Replace the macro with a logging category so that it's not necessary to patch Qt to get output about e.g. ambiguous shortcuts. Change-Id: I4d365aac5a5c0da8629447d93d3bc90c9c3076c2 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* | QShortcut: Properly port to the new configure systemFriedemann Kleint2019-10-251-4/+0
|/ | | | | | | | | | | | | | | Move the feature to corelib so that the QMetaType enumeration values can be properly excluded and there is no need for a dummy class. Use QT_REQUIRE_CONFIG in the headers of classes to be disabled. Add headers/source files in the .pro file depending on the configure feature in libraries and tests. Add the necessary exclusions and use QT_CONFIG. Task-number: QTBUG-76493 Change-Id: I02499ebee1a3d6d9a1e5afd02517beed5f4536b7 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QtGui/Network/OpenGl/Widgets/Xml: use \nullptr in documentationChristian Ehrlicher2019-02-201-3/+3
| | | | | | | Replace null and '\c nullptr' with \nullptr in the documentation. Change-Id: I58934eea06943309ba895833f1991629870ab45b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Merge remote-tracking branch 'origin/5.11' into devLiang Qi2018-05-081-0/+13
|\ | | | | | | | | | | | | | | Conflicts: src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp tests/auto/corelib/io/qresourceengine/qresourceengine_test.pro Change-Id: I3169f709cc2a1b75007cb23c02c4c79b74feeb04
| * QShortcutMap: print ambiguous shortcuts when DEBUG_QSHORTCUTMAP is definedMitch Curtis2018-05-071-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | This is useful to see why shortcuts (in Qt Widgets and Qt Quick) are not behaving as expected. For example: The following shortcuts are about to be activated ambiguously: - QKeySequence("Esc") (belonging to QQuickShortcut(0x7fcd4c8e6a70, name = "exploreViewBackOrCloseShortcut")) - QKeySequence("Esc") (belonging to QQuickPopupItem(0x7fcd4c8e5110)) Change-Id: Id20a3017d69cfe417c2286dccf46b3d5ff0b31b2 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | QShortcutMap::createNewSequences: Add some debug outputFriedemann Kleint2018-03-281-0/+13
|/ | | | | | | | Output the keys obtained from QPlatformIntegration::possibleKeys() which is often at the core of bugs in this area. Change-Id: I8c739a4c3251a7f6112a4032e0e1b9db9d2ca641 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Fix compiler warning about missing return statement in non-void functionThiago Macieira2016-06-171-2/+2
| | | | | | | | | | | Found by ICC 17 Beta on Windows. This commit also removes the "default" cause from the switch, which will make compilers let us know if we add another enum but don't handle it in the switch. Change-Id: Ib57b52598e2f452985e9fffd1458b5b39b238db7 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
* QVector: preserve capacity in clear()Marc Mutz2016-02-291-2/+2
| | | | | | | | | | | | | | | | | | | | | This is what std::vector implementations usually do, because it minimizes memory fragmentation and useless allocations since no user will call clear() unless she intends to append new data afterwards. Fix calls to resize(0) that show how existing code tried to work around the issue. Adjust test. Port from QVERIFY(==) to QCOMPARE as a drive-by. [ChangeLog][QtCore][QVector] clear() now preserves capacity. To shed capacity, call squeeze() or swap with a default-constructed QVector object, see the documentation for an example. Change-Id: I9cebe611a97e027a89e821e64408a4741b31f1f6 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* QShortcutMap: re-use an existing bool variableMarc Mutz2016-02-171-1/+1
| | | | | | | ... instead of re-evaluating its expression. More readable. Change-Id: I18c6ab3bbc4c5a14328f9910fab991f6cad5549d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
* QKeySequence: replace an inefficient QList with QVectorMarc Mutz2016-02-081-7/+7
| | | | | | | | | | | | | QShortcutEntry is larger than a void*, so holding it in QLists is needlessly inefficient. Worse, the code could come to depend on the fragile property of (inefficient) QLists that references to elements therein never are invalidated. Fix by marking it movable, and holding it in a QVector instead. Change-Id: I4ab3399a8036827631b7fbdfdc60b4206305e1c9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.6' into devLiang Qi2016-01-211-2/+6
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qiodevice_p.h src/corelib/kernel/qvariant_p.h src/corelib/tools/qsimd.cpp src/gui/kernel/qguiapplication.cpp tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp Change-Id: I742a093cbb231b282b43e463ec67173e0d29f57a
| * Fix reentrancy regression in QShortcutMap after c7e5e1d9eTor Arne Vestbø2016-01-121-2/+6
| | | | | | | | | | | | | | | | | | | | | | When closing a popup dialog using a shortcut, when the popup was originally opened using a shortcut, the closing-shortcut would interfere with the state of the first shortcut, and we ended up sending a key event for the original shortcut. Task-number: QTBUG-50360 Change-Id: I62e5ddb9ca43b28519ede629775bc0d7598dccc4 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Updated license headersJani Heikkinen2016-01-151-14/+20
|/ | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* QShortcutMap: enable extra debugging when Dump_QShortcutMap is definedRichard Moe Gustavsen2015-10-151-2/+2
| | | | | | | | | | Dump_QShortcutMap is already made available in qshortcutmap_p.h, and if set, "void dumpMap() const;" will be available to help debugging. But unless QDebug &operator<< in qshortcutmap.cpp is also defined, the dumpMap output will be pretty useless. Change-Id: If8d535998ec01686eca25da73c2220062820a927 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
* Move shortcut handling back into QPA and simplify deliveryTor Arne Vestbø2015-10-071-40/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 7f5b94b47 moved shortcut handling into QGuiApplication (for all platforms except OS X), due to crashes on Android where the events are delivered from another thread. Now that we have synchronous event delivery (also across threads) from QPA, this is no longer needed, and we can move the code back to QPA, where the platform has more control over when and how shortcut events are delivered in relation to normal key events. Handling shortcuts is as before a two step process. We first send a QKeyEvent::ShortcutOverride event to the active window, which allows clients (widgets e.g.) to signal that they want to handle the shortcut themselves. If the override event is accepted, we treat it as the shortcut not being handled as a regular shortcut, and send the event as a key press instead, allowing the widget to handle the shortcut. If nothing accepted the shortcut override event we pass it along to the global shortcut map, which will treat the event as handled if an exact or partial match is found. The QShortcutMap::tryShortcutEvent() and nextState() implementation has been simplified to not use the events accepted state for its internal operation, which removes the need for saving the state of the incoming event. The QKeyEvent::ShortcutOverride event was also always sent with the accepted state set to false, by calling ignore() on it before sending it. This is now explicit by having shortcut override events being ignored by default in their constructor, and the documentation has been updated accordingly. Change-Id: I9afa29dbc00bef09fd22ee6bf09661b06340d715 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com> Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
* Fix shortcuts with keypad keysAlexander Volkov2015-08-181-7/+5
| | | | | | | | | | | | | | | | | | | The way of searching a shortcut match for a key without the keypad modifier introduced in 547a1bea492954d828aa0798be93384669812489 is not correct. QKeyEvent::setModifiers() doesn't change native scan code so we get the incorrect QKeyEvent object which is eventually passed to the implementation of QPlatformIntegration::possibleKeys(). And then QPlatformIntegration::possibleKeys() returns the same result as for the original QKeyEvent object. So to fix it we have to remove Qt::KeypadModifier from keys after calling the implementation of QPlatformIntegration::possibleKeys(), as it was before 547a1bea492954d828aa0798be93384669812489. Task-number: QTBUG-33093 Task-number: QTBUG-44577 Change-Id: I5b33c9b6cf2c06b133166a31eba9aff9181c9483 Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
* Use QDebugStateSaver to restore space setting in stream operators.Friedemann Kleint2015-03-301-2/+4
| | | | | | | | Returning dbg.space() breaks formatting on streams that already have nospace() set. Change-Id: I55e38b018679a67eb40be6b4664505483a3a7d8e Reviewed-by: David Faure <david.faure@kdab.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | 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>
* Clean up ShortcutOverride handlingFrederik Gladhorn2014-10-301-0/+4
| | | | | | | | | | | | | | | Instead of sending the event from random places, send it from QWindowSystemInterface. This allows to send override events on OS X to menus before doing other key processing and reduces the number of ShortcutOverride events on all platforms to exactly one per key press event. Additional test by Friedemann Kleint. Task-number: QTBUG-38986 Change-Id: I6981bb776aba586ebc7c3daa5fd7a0d84c25bc3e Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* expand tabs and related whitespace fixes in *.{cpp,h,qdoc}Oswald Buddenhagen2014-01-131-1/+1
| | | | | | | | the diff -w for this commit is empty. Started-by: Thiago Macieira <thiago.macieira@intel.com> Change-Id: I77bb84e71c63ce75e0709e5b94bee18e3ce6ab9e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix the assert failure in QShortcutMap::findGatis Paeglis2013-05-081-0/+3
| | | | | | | | | | Don't send Qt::Key_unknown down the shortcut handling pipe, because unknown keys are not part of a shortcut sequence and results in an assert. Task-number: QTBUG-30871 Change-Id: Idd451fb793bd07124a96d75ed7b936f7ff584f28 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
* Fix typo.Frederik Gladhorn2013-02-261-1/+1
| | | | | Change-Id: Ia3fd460e77d8da5dca634872e3f786d5ad30289d Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Implicit conversion of shortcuts to string is gone.Frederik Gladhorn2012-12-141-1/+1
| | | | | | | | This only effects compilation with DEBUG_QSHORTCUTMAP. Change-Id: I184e644f2165049336cee8a6ac63a3301cf4c849 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Remove qUpperBound usages from qtbaseGiuseppe D'Angelo2012-09-191-1/+1
| | | | | | | | | Replace them with std::upper_bound; this allows for deprecation of qUpperBound. Change-Id: Idef01d2228b9a70eee3d52931d7aedb5bb6ba902 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
* Remove qLowerBound usages from qtbaseGiuseppe D'Angelo2012-09-191-2/+4
| | | | | | | | | Replace them with std::lower_bound; this allows for deprecation of qLowerBound. Change-Id: I536e7338eb85ea6c7c1a5bf23121292767927e0b Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
* Fix limitting shortcuts to keypad onlyJani Honkonen2012-08-271-2/+7
| | | | | | | | | | | | | | | | | The Qt::KeypadModifier modifier is internally masked away from all shortcuts. So it is not possible to set a keypad only shortcut. Changed the implementation so that first a full keysequence match is searched. Then if no match is found the same sequence is tried without the keypad modifer. Added a autotest for this also to cover the basic use cases relating to this. Task-number: QTBUG-20191 Change-Id: Ibe7740c705fd0ab1eece4809b9a0b48882172933 Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>