Skip to content

Commit

Permalink
QKeyCombination: code tidies
Browse files Browse the repository at this point in the history
* Use the new QFlags::toInt() instead of an explicit cast.

* Don't apply ~ to an enumerator and then convert the result to an
int; instead, convert the enumerator to int and then bitwise negate it.
The former is going to break in an upcoming commit.

Change-Id: I3a798d61452891d2f61f84e2d8e17237f47c5659
Reviewed-by: Volker Hilsheimer <[email protected]>
  • Loading branch information
dangelog committed May 19, 2021
1 parent d95e39a commit 9c89743
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/corelib/global/qnamespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -1874,11 +1874,11 @@ class QKeyCombination
{}

constexpr explicit QKeyCombination(Qt::Modifiers modifiers, Qt::Key key = Qt::Key_unknown) noexcept
: combination(int(modifiers) | int(key))
: combination(modifiers.toInt() | int(key))
{}

constexpr explicit QKeyCombination(Qt::KeyboardModifiers modifiers, Qt::Key key = Qt::Key_unknown) noexcept
: combination(int(modifiers) | int(key))
: combination(modifiers.toInt() | int(key))
{}

constexpr Qt::KeyboardModifiers keyboardModifiers() const noexcept
Expand All @@ -1888,7 +1888,7 @@ class QKeyCombination

constexpr Qt::Key key() const noexcept
{
return Qt::Key(combination & ~Qt::KeyboardModifierMask);
return Qt::Key(combination & ~int(Qt::KeyboardModifierMask));
}

static constexpr QKeyCombination fromCombined(int combined)
Expand Down

0 comments on commit 9c89743

Please sign in to comment.