summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qkeysequence.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Teach QKeySequence::toString(Native) about C0 Control PicturesTor Arne Vestbø2025-10-151-1/+4
| | | | | | | | | | | | | | | | | | | | | The Unicode C0 control codes correspond to the 32 control characters in ASCII from 0x00 and 0x1f. Since these are unprintable in their basic form, it makes sense to represent them as something printable via toString(). The Unicode Control Pictures block provides exactly that. We skip 0x0 (Null) as we don't distinguish between a missing key and the null character in Qt. Although there are also Control Pictures for space (0x20), del (0x7f), and others, we ignore these as they are not in C0. [ChangeLog][QtCore] QKeySequence::toString() now maps the C0 control characters to their equivialent in the Unicode Control Pictures block, if using QKeySequence::SequenceFormat::NativeText. Change-Id: I4525d08478ebeb2a321b035c96029a22fa5ed749 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Use u' ' instead of QLatin1Char(' ') in qkeysequence.cppDavid Faure2025-03-281-4/+4
| | | | | | | | | | Easier on the eye. Amends ada885dfd55d5c386d04039babee43e49ccab5c5. Pick-to: 6.9 6.8 Change-Id: Id218288ccc4556abb7c9a199f27b7dcb6a3ba73e Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QKeySequence: tolerate spaces when parsing a key sequence stringDavid Faure2025-03-121-13/+35
| | | | | | | | Fixes: QTBUG-130063 Pick-to: 6.9 6.8 Change-Id: I0f0aff0ca0824cd1c9297cd18a1f5cf9a2a44951 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Add Qt::Key_KeyboardKai Uwe Broulik2025-02-171-0/+2
| | | | | | | | | Adds a "media key" for the "Keyboard settings" key found on some laptops. Change-Id: Id041a551844f095f1d7d2fd25d37346da30407a3 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: David Edmundson <davidedmundson@kde.org>
* doc: QKeySequence cannot be cast to a QString any longerJan Arve Sæther2025-02-071-5/+2
| | | | | | | | | | | | | | | | | | bf805455d40b4445f61321439d529cd85cb6bc65 deprecated the QString() operator in Qt5. Later dccf28b7c344822b7459635099ebe3abdf5fd107 and 2eee9e6fcf9b70681c5d9202d1509d176e48fc31 attempted to remove it entirely, but a reference to it still remained. This change also removes the detailed documentation for toString() in the same paragraph, which previously stated that it generates strings for use in menus. However, this is not always the case due to toString(QKeySequence::PortableText). The differences between the two serialization methods are already well-documented in the toString() documentation. Pick-to: 6.9 Change-Id: I42dbb353bc56354f37b8fc22170f8e588eb97176 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Create qdoc macros for C++ class docs 2.1: qHash()Marc Mutz2024-11-271-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Add a family of qdoc macros to document the various qHash() overloads we have. This patch does not change the \relates of the qHash() functions, they remain as inconsistent as they have been. Created QTBUG-129815 to clean things up. Since this author expects the \relates to change in the future, there are different \qhash commands, and all except \qhashbuiltin take the class name as an argument, for use in a centrally-choreographed fix for QTBUG-129815. As drive-by's, fix: - missing documentation about Key having to support qHash() in the associative Qt containers - drop noexcept and default arguments from \fn lines that needed to have their argument names changed - move the QStringView overload from qhash.cpp to qstringview.cpp (as it \relates to the former) Fixes: QTBUG-129574 Pick-to: 6.8 6.5 Change-Id: I8e8c2edc27422cbe5823f56baf3a24d7f7050836 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Jaishree Vyas <jaishree.vyas@qt.io>
* Create qdoc macros for C++ class docs 1.1: member-swap(), traditional phrasingMarc Mutz2024-11-051-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | We have some patterns for how to document certain functions, but we also vary the sentences a lot, and you have to look up one documentation piece and copy it, essentially. If we ever want to change them, we end up with shotgun surgery. So apply DRY to the documentation and start a collection of macros to help with repetitive C++ class documentation tasks. The first macro is for member-swap(), and the first patch is for documentation that used the traditional phrasing ("Swaps the X \a other with this X."). This doesn't change the documentation, except as follows: * adds the "very fast and never fails" blurb, if it was missing * changes the function's argument name to `other`, as required by the macro. Task-number: QTBUG-129573 Pick-to: 6.8 6.7 6.5 6.2 Change-Id: Ib494bd218334724b3b43796ba6f71fb52b83aa94 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Add Ctrl+Shift+Comma preferences shortcut for KDEKai Uwe Broulik2024-10-241-1/+1
| | | | | | | | | This has been the default for a while. Having it in Qt ensures the shortcut also works when an application did not load KDE's Plasma integration plug-in. Change-Id: Ic4568a40644334b6442071da91ca895506bfa703 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Apple: Make Qt::Key_Backspace primary sequence for StandardKey::BackspaceTor Arne Vestbø2024-02-091-2/+2
| | | | | | | | | | | This will show up in menus as ⌫, instead of ^H, which is a better fit with the native behavior. Task-number: QTBUG-122042 Task-number: QDS-11733 Pick-to: 6.7 6.6 6.5 Change-Id: I224971421a13baec2a0f65be8ae4a5791dabafdd Reviewed-by: Doris Verria <doris.verria@qt.io>
* Use Ctrl+Shift+S for Save As... shortcut on every platformShawn Rutledge2023-12-091-1/+1
| | | | | | | | | [ChangeLog][QtGui][QKeySequence] Ctrl+Shift+S is now the standard shortcut for Save As... on every platform. Fixes: QTBUG-72916 Change-Id: Ic1815646651573c07994c4cd9df8f658e4a806b6 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QKeySequence::toString(): Treat Modifier+Qt::Key_Unknown as empty stringTor Arne Vestbø2023-10-091-3/+3
| | | | | | | | | | | | We were already doing this for a key combination without modifiers, but now we do the same for e.g. Control+Unknown. This matches the behavior we have for QKeySequencePrivate::decodeString(), where we return Qt::Key_Unknown if we can't resolve the key, even if we have resolved some valid modifiers, e.g. "Meta+Trolls" as in the tst_QKeySequence::parseString() test. Change-Id: I238e29276e6ce356ae60c67585739587fa388f07 Reviewed-by: Liang Qi <liang.qi@qt.io>
* Teach QKeySequencePrivate about QKeyCombinationTor Arne Vestbø2023-10-091-16/+19
| | | | | | | | | | Being explicit about whether we're dealing with QKeyCombination or a plain Qt::Key helps understand the code. Keys are still stored as ints though. Change-Id: I2cb7bf2c5fabcecbd4dd3e99ba6240fb1910dcc7 Reviewed-by: Liang Qi <liang.qi@qt.io>
* QKeySequence: Remove unused private helper methodsTor Arne Vestbø2023-10-091-18/+0
| | | | | | | The functionality is available in QKeySequencepPrivate still, if needed. Change-Id: Iefa2e5b31a550fd2a419d2aee028ce4c1ddfb7a2 Reviewed-by: Liang Qi <liang.qi@qt.io>
* gui: use const methods moreAnton Kudryavtsev2023-09-091-2/+2
| | | | | | | to avoid implicit detach Change-Id: I2c7ae56e0866941e0f0b040129bfc40a9a961f3c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Align QKeySequence behavior between macOS and iOSTor Arne Vestbø2023-06-081-43/+43
| | | | | | | | | | | | | | | | | | External keyboards for iOS/iPad devices have the same Macintosh based keyboard as Macs have, with Command (or Cmd) ⌘; Option (or Alt) ⌥; and Control (or Ctrl) ⌃ keys. We were already declaring the QPlatformTheme::KeyboardScheme as MacKeyboardScheme on iOS. [ChangeLog][iOS] Keyboard shortcuts now follow the same scheme as on macOS, with their native representation expressed via the ⌘, ⌥, and ⌃ modifiers. Use Qt::AA_MacDontSwapCtrlAndMeta to override this. Pick-to: 6.6 Fixes: QTBUG-113165 Change-Id: Ia1856ee1718dab9f2f2512ffffc8b4d3cc5adecc Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Misc.: Fix some narrowing integral conversion warningsAhmad Samir2023-04-251-5/+5
| | | | | | | Drive-by change: use QByteArrayView instead of allocating a QByteArray. Change-Id: Iaf7acbbdb4efbb101b73b30061ce38dd1fa99ca3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Use \relates for functions in the global scopeTopi Reinio2023-03-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | This addresses the recent warnings introduced by a change to QDoc: qkeysequence.h:32: (qdoc) warning: No documentation generated for function 'qHash' in global scope. qmap.h:1557: (qdoc) warning: No documentation generated for function 'operator+' in global scope. qmap.h:1565: (qdoc) warning: No documentation generated for function 'operator+=' in global scope. qvariant.h:582: (qdoc) warning: No documentation generated for function 'operator>>' in global scope. qvariant.h:590: (qdoc) warning: No documentation generated for function 'operator<<' in global scope. Also, mark qt_win_hasPackageIdentity() declared in qfunctions_win_p.h as \internal. Pick-to: 6.5 Change-Id: Idc9c813370ff3133ac9dc3bf809976b0ece88811 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Doc: we no longer provide a list of common mnemonicsVolker Hilsheimer2023-03-011-5/+0
| | | | | | | | | | | Remove the claim from the QKeySequence documentation, fixing the respective qdoc warning. Amends f10ae4b887f6652dcad95516ded43f2e2994e88f. Pick-to: 6.5 Change-Id: If234cfb0a6b7dc20fb10e623cc3ee2ec167f22c9 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Port from container::count() and length() to size() - V5Marc Mutz2022-11-031-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that the on() matcher has been replaced by one that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache, to avoid porting calls that explicitly test count(). Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Replace usages of Q_CLANG_QDOC with Q_QDOCLuca Di Sera2022-10-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | To allow the user to customize the C++ code that QDoc sees, so as to be able to work-around some limitations on QDoc itself, QDoc defines two symbols: Q_QDOC and Q_CLANG_QDOC, both of which are "true" during an entire execution of QDoc. At a certain point in time, QDoc allowed the user the choice between a custom C++ parser and a Clang based one. The Q_QDOC symbol would always be defined while the Q_CLANG_QDOC symbol would be defined only when the Clang based parser was chosen. In more recent times, QDoc always uses a Clang based parser, such that both Q_CLANG_QDOC and Q_QDOC are always defined, making them equivalent. To avoid using different symbols, and the possible confusion and fragmentation that derives from it, all usages of Q_CLANG_QDOC are now replaced by the equivalent usages of Q_QDOC. Change-Id: I5810abb9ad1016a4c5bbea99acd03381b8514b3f Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* QtGui: Fix mismatches between string types and string literalsMate Barany2022-09-211-10/+10
| | | | | | | | | | | | This commit addresses some comments from the review of QTBUG-98434. Some strings were initialized with incorrect literal types - fix the mismatches between the string types and string literals. Task-number: QTBUG-103100 Change-Id: I5f9f8a2c1583c21711f7b9ff177917f20690b5a3 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QKeySequence: Update the doc to KeyboardModifiersLaszlo Papp2022-07-121-5/+6
| | | | | Change-Id: I38411d0240f13488bc37bf4c17964ec9cb07d5d6 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QKeySequence: constinit ALL the thingsMarc Mutz2022-06-021-3/+3
| | | | | | | | | | | | C++20 constinit acts as a static_assertion that the initialiation of the object doesn't incur runtime initialization overhead. Task-number: QTBUG-100486 Change-Id: I818f5ca9703273cd41e44e5ce7085cb5c643ca8e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QKeySequence: statically assert the sortedness of the MacSpecialKey arrayMarc Mutz2022-06-011-0/+7
| | | | | | | | | This array has, in the past, silently failed this test (cf. 5d8f815e101da3ae9cd6a666cc097853f52b21da). Make sure it doesn't happen again. Change-Id: I26192749d43de4a7add9d14c7ca04391c1799525 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QKeySequence: Add missing modifier namesLaszlo Papp2022-05-251-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The issue is that when someone is trying to use the following code: QKeySequence keySequence(Qt::Key_Shift); qDebug() << keySequence.toString(); This will print seemingly gibberish output. It is unicode in practice. For Qt::Key_Shift, this would be: "�_@\uDC20" The reason why this is happening is because we have platform-specific ways to handle this due to Mac glyphs which are not available on Linux or Windows. This works fine on Mac. But for the Linux and Windows codepaths, there is not really any mapping like for other keys. It seems that modifiers were left out. The solution is to simply amend the list of mapping from these modifier key codes to raw strings for Linux and Windows like it is done for other key codes. So, now, modifiers will also be included in the list. So, the expected output will be generated for the above code, as: "Shift". [ChangeLog][QtGui][QKeySequence] Added missing modifier names Fixes: QTBUG-69715 Fixes: QTBUG-40030 Change-Id: I460d54bc8e593b350ff95894f23c5b4a7c819a44 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QKeySequence: constexpr ALL the thingsMarc Mutz2022-05-201-14/+14
| | | | | | | | | | | | | | Constexpr acts as a static assertion that these objects don't incur runtime initialization overhead. Also mark some functions constexpr that can be. As a drive-by, rename relational operator arguments to the usual lhs, rhs. Task-number: QTBUG-100485 Change-Id: I73d2595ccb123f28459edf79ae8dc208f26cc364 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QKeySequence: Add support for Eject and Clear glyphs on macOSLaszlo Papp2022-05-181-0/+2
| | | | | | | | | Presumably, these glyphs have not been needed thus far, hence missing from the corresponding list. Pick-to: 6.2 6.3 Change-Id: I72cb8811f087c40229105f65d52a9c1048d9f9eb Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QKeySequence/Mac: remove NumEntries variableMarc Mutz2022-05-171-6/+3
| | | | | | | | | | | Keep it DRY. Just let the compiler figure out the size. Pick-to: 6.3 6.2 Change-Id: I2bf1c44d4e2060a9398700d16ab98d67c849814c Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* 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>
* QKeySequence: Fix the one-off error in the mac glyph array sizeLaszlo Papp2022-05-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | It seems that the size of the corresponding array in the code has a one-off error. This is now fixed. The end of the array passed to lower_bound is wrong because the hard-coded size is size + 1. However, the end is array + size. This is what lower_bound expects from an array. Or any other algorithm for that matter expecting the end of a container as an argument. This can cause issues with something like lower_bound because a potential "empty" fill is not sorted as lower_bound would expect the data structure. It could have been fixed by decreasing the size by one, however it is a more future-proof solution to avoid hard-coding the size and just use std::size(array) instead. Pick-to: 5.15 6.2 6.3 Change-Id: I1d25a5b1a80a3b2634b229e0718108ad5e7808a0 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QtGui: includemocsMarc Mutz2022-04-291-0/+2
| | | | | | | | | | | Including moc files directly into their classes' TU tends to improve codegen and enables extended compiler warnings, e.g. about unused private functions or fields. Pick-to: 6.3 6.2 5.15 Task-number: QTBUG-102886 Change-Id: I1945741794c25679a9d94c0d68c8642e2c823502 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QtGui: use _L1 for for creating Latin-1 string literalsSona Kurazyan2022-04-281-13/+15
| | | | | | Task-number: QTBUG-98434 Change-Id: Idcb71c1d27125333a53b6bdd3e1af0d4c66617fa Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QtGui: stop using QLatin1Char constructor for creating char literalsSona Kurazyan2022-04-131-15/+15
| | | | | | | | | Required for porting away from QLatin1Char/QLatin1String in scope of QTBUG-98434. Change-Id: I308d86cefcbfd126929b68f9a853d420840c965f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Fix deprecated use of QBA/Q*String::countMårten Nordheim2022-03-151-1/+1
| | | | | | | 'Use size() or length() instead' Change-Id: I284fce29727c4c1ec9ea38a4e8ea13a9e0af5390 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* gui: Fix typos in source code commentsJonas Kvinge2021-10-121-1/+1
| | | | | | Pick-to: 5.15 6.2 Change-Id: Ie53e5542a8f93856470982939ecd8ec90b323d69 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@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>
* Adjust code format, add space after 'if'Zhang Sheng2020-11-161-2/+2
| | | | | | Change-Id: Ice081c891ff7f4b766f49dd4bd5cf18c30237acf Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: hjk <hjk@qt.io>
* Long live QKeyCombination!Giuseppe D'Angelo2020-09-031-7/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Remove QVariant(int type, void *data, ...) constructorLars Knoll2020-08-151-1/+1
| | | | | | | | It was marked internal anyway. Use the constructor taking a QMetaType instead. Change-Id: I15b9cd0911aac063a0f0fe0352fa2c84b7f7c691 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Replace Qt CONSTEXPR defines with constexprAllan Sandfeld Jensen2020-08-141-1/+1
| | | | | | | | Both normal and relaxed constexpr are required by our new minimum of C++17. Change-Id: Ic028b88a2e7a6cb7d5925f3133b9d54859a81744 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Replace use of deprecated Q_OS_MACX in favor of Q_OS_MACOSTor Arne Vestbø2020-07-081-7/+7
| | | | | Change-Id: I1059d56f67be28a4cc1a66b744e81df6d0b5d00d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use QList instead of QVector in gui implementationJarek Kobus2020-07-071-4/+4
| | | | | | | 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>
* Port Q_STATIC_ASSERT(_X) to static_assertGiuseppe D'Angelo2020-06-191-3/+3
| | | | | | | | | | | | | | | | | There is no reason for keep using our macro now that we have C++17. The macro itself is left in for the moment being, as well as its detection logic, because it's needed for C code (not everything supports C11 yet). A few more cleanups will arrive in the next few patches. Note that this is a mere search/replace; some places were using double braces to work around the presence of commas in a macro, no attempt has been done to fix those. tst_qglobal had just some minor changes to keep testing the macro. Change-Id: I1c1c397d9f3e63db3338842bf350c9069ea57639 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Port QtGui from QStringRef to QStringViewLars Knoll2020-06-111-2/+2
| | | | | | Task-number: QTBUG-84319 Change-Id: I1761096fbcc9421a013cf73f831a2a2ba0c18006 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* QtGui: fix deprecated QChar conversionsMarc Mutz2020-05-111-2/+2
| | | | | | | | | Conversions from non-char-types to QChar are going to be deprecated. Use QChar::fromUcs2(), fromUcs4(), QLatin1Char(), or convert the constructor argument to char16_t. Change-Id: Ib45ebd5560aa3a2bc460037ab09773607485c6e2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QKeySequence: remove docs of methods recently removedGiuseppe D'Angelo2020-05-051-19/+0
| | | | | | | | Amends dccf28b7c344822b7459635099ebe3abdf5fd107. Change-Id: Ic4eeda8706b58fdff716e8f86a2bf7cc77ec0c7a Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Change qHash() to work with size_t instead of uintLars Knoll2020-04-091-1/+1
| | | | | | | | | | | This is required, so that QHash and QSet can hold more than 2^32 items on 64 bit platforms. The actual hashing functions for strings are still 32bit, this will be changed in a follow-up commit. Change-Id: I4372125252486075ff3a0b45ecfa818359fe103b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-04-081-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/opengl/doc/src/cube.qdoc src/corelib/global/qlibraryinfo.cpp src/corelib/text/qbytearray_p.h src/corelib/text/qlocale_data_p.h src/corelib/time/qhijricalendar_data_p.h src/corelib/time/qjalalicalendar_data_p.h src/corelib/time/qromancalendar_data_p.h src/network/ssl/qsslcertificate.h src/widgets/doc/src/graphicsview.qdoc src/widgets/widgets/qcombobox.cpp src/widgets/widgets/qcombobox.h tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro tests/manual/diaglib/debugproxystyle.cpp tests/manual/diaglib/qwidgetdump.cpp tests/manual/diaglib/qwindowdump.cpp tests/manual/diaglib/textdump.cpp util/locale_database/cldr2qlocalexml.py util/locale_database/qlocalexml.py util/locale_database/qlocalexml2cpp.py Resolution of util/locale_database/ are based on: https://codereview.qt-project.org/c/qt/qtbase/+/294250 and src/corelib/{text,time}/*_data_p.h were then regenerated by running those scripts. Updated CMakeLists.txt in each of tests/auto/corelib/serialization/qcborstreamreader/ tests/auto/corelib/serialization/qcborvalue/ tests/auto/gui/kernel/ and generated new ones in each of tests/auto/gui/kernel/qaddpostroutine/ tests/auto/gui/kernel/qhighdpiscaling/ tests/libfuzzer/corelib/text/qregularexpression/optimize/ tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/ tests/libfuzzer/gui/text/qtextdocument/sethtml/ tests/libfuzzer/gui/text/qtextdocument/setmarkdown/ tests/libfuzzer/gui/text/qtextlayout/beginlayout/ by running util/cmake/pro2cmake.py on their changed .pro files. Changed target name in tests/auto/gui/kernel/qaction/qaction.pro tests/auto/gui/kernel/qaction/qactiongroup.pro tests/auto/gui/kernel/qshortcut/qshortcut.pro to ensure unique target names for CMake Changed tst_QComboBox::currentIndex to not test the currentIndexChanged(QString), as that one does not exist in Qt 6 anymore. Change-Id: I9a85705484855ae1dc874a81f49d27a50b0dcff7
| * macOS: Remove all use of deprecated Q_OS_OSX defineTor Arne Vestbø2020-04-031-1/+1
| | | | | | | | | | Change-Id: I49c285604694c93d37c9d1c7cd6d3b1509858319 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>