Qt::Modifier: do some cleanups
Qt::UNICODE_ACCEL had no effect since at least Qt 4.0. We can drop it in Qt 6. The whole Qt::Modifier enumeration is still widely used, so we can't drop it yet, but we should aim at doing so in Qt 7. Add a note. [ChangeLog][QtCore][Qt::Modifier] The Qt::UNICODE_ACCEL enumerator has been removed. It had no effect since Qt 4.0. [ChangeLog][QtCore][Qt::Modifier] Usage of the enumerators in the Qt::Modifier enumeration is discouraged. The enumeration will likely get removed in the next major version of Qt. Change-Id: If25f30d920878d32903b91a38044f5da042c7eab Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
89ecbf0978
commit
c023b025ee
@ -96,13 +96,13 @@ namespace Qt {
|
||||
// user-defined or third-party macros. More so when the identifiers are not
|
||||
// "namespace"-prefixed. This is considered bad practice and is why
|
||||
// KeypadModifier was not added to the Modifier enum.
|
||||
// ### Qt 7: consider deprecating in favor of KeyboardModifier.
|
||||
enum Modifier {
|
||||
META = Qt::MetaModifier,
|
||||
SHIFT = Qt::ShiftModifier,
|
||||
CTRL = Qt::ControlModifier,
|
||||
ALT = Qt::AltModifier,
|
||||
MODIFIER_MASK = KeyboardModifierMask,
|
||||
UNICODE_ACCEL = 0x00000000
|
||||
};
|
||||
|
||||
enum MouseButton {
|
||||
|
@ -416,8 +416,6 @@
|
||||
\value META The Meta keys.
|
||||
\value CTRL The Ctrl keys.
|
||||
\value ALT The normal Alt keys, but not keys like AltGr.
|
||||
\value UNICODE_ACCEL The shortcut is specified as a Unicode code
|
||||
point, not as a Qt Key.
|
||||
\omitvalue MODIFIER_MASK
|
||||
|
||||
\sa KeyboardModifier, MouseButton
|
||||
|
@ -99,7 +99,7 @@ static quint32 constructModifierMask(quint32 accel_key)
|
||||
// return an autoreleased string given a QKeySequence (currently only looks at the first one).
|
||||
NSString *keySequenceToKeyEqivalent(const QKeySequence &accel)
|
||||
{
|
||||
quint32 accel_key = (accel[0] & ~(Qt::MODIFIER_MASK | Qt::UNICODE_ACCEL));
|
||||
quint32 accel_key = (accel[0] & ~Qt::MODIFIER_MASK);
|
||||
QChar cocoa_key = QCocoaKeyMapper::toCocoaKey(Qt::Key(accel_key));
|
||||
if (cocoa_key.isNull())
|
||||
cocoa_key = QChar(accel_key).toLower().unicode();
|
||||
|
@ -196,26 +196,26 @@ void tst_QKeySequence::operatorQString_data()
|
||||
QTest::addColumn<int>("keycode");
|
||||
QTest::addColumn<QString>("keystring");
|
||||
|
||||
QTest::newRow( "No modifier" ) << 0 << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << QString::fromLatin1( "\x0c5" );
|
||||
QTest::newRow( "No modifier" ) << 0 << int(Qt::Key_Aring) << QString::fromLatin1( "\x0c5" );
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
QTest::newRow( "Ctrl+Left" ) << int(Qt::CTRL) << int(Qt::Key_Left) << QString( "Ctrl+Left" );
|
||||
QTest::newRow( "Ctrl+," ) << int(Qt::CTRL) << int(Qt::Key_Comma) << QString( "Ctrl+," );
|
||||
QTest::newRow( "Alt+Left" ) << int(Qt::ALT) << int(Qt::Key_Left) << QString( "Alt+Left" );
|
||||
QTest::newRow( "Alt+Shift+Left" ) << int(Qt::ALT | Qt::SHIFT) << int(Qt::Key_Left) << QString( "Alt+Shift+Left" );
|
||||
QTest::newRow( "Ctrl" ) << int(Qt::CTRL) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << QString::fromLatin1( "Ctrl+\x0c5" );
|
||||
QTest::newRow( "Alt" ) << int(Qt::ALT) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << QString::fromLatin1( "Alt+\x0c5" );
|
||||
QTest::newRow( "Shift" ) << int(Qt::SHIFT) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << QString::fromLatin1( "Shift+\x0c5" );
|
||||
QTest::newRow( "Meta" ) << int(Qt::META) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << QString::fromLatin1( "Meta+\x0c5" );
|
||||
QTest::newRow( "Ctrl" ) << int(Qt::CTRL) << int(Qt::Key_Aring) << QString::fromLatin1( "Ctrl+\x0c5" );
|
||||
QTest::newRow( "Alt" ) << int(Qt::ALT) << int(Qt::Key_Aring) << QString::fromLatin1( "Alt+\x0c5" );
|
||||
QTest::newRow( "Shift" ) << int(Qt::SHIFT) << int(Qt::Key_Aring) << QString::fromLatin1( "Shift+\x0c5" );
|
||||
QTest::newRow( "Meta" ) << int(Qt::META) << int(Qt::Key_Aring) << QString::fromLatin1( "Meta+\x0c5" );
|
||||
#else
|
||||
QTest::newRow( "Ctrl+Left" ) << int(Qt::CTRL) << int(Qt::Key_Left) << MacCtrl + macSymbolForQtKey(Qt::Key_Left);
|
||||
QTest::newRow( "Ctrl+," ) << int(Qt::CTRL) << int(Qt::Key_Comma) << MacCtrl + ",";
|
||||
QTest::newRow( "Alt+Left" ) << int(Qt::ALT) << int(Qt::Key_Left) << MacAlt + macSymbolForQtKey(Qt::Key_Left);
|
||||
QTest::newRow( "Alt+Shift+Left" ) << int(Qt::ALT | Qt::SHIFT) << int(Qt::Key_Left) << MacAlt + MacShift + macSymbolForQtKey(Qt::Key_Left);
|
||||
QTest::newRow( "Ctrl" ) << int(Qt::CTRL) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << MacCtrl + QLatin1String("\x0c5");
|
||||
QTest::newRow( "Alt" ) << int(Qt::ALT) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << MacAlt + QLatin1String("\x0c5");
|
||||
QTest::newRow( "Shift" ) << int(Qt::SHIFT) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << MacShift + QLatin1String("\x0c5");
|
||||
QTest::newRow( "Meta" ) << int(Qt::META) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL) << MacMeta + QLatin1String("\x0c5");
|
||||
QTest::newRow( "Ctrl" ) << int(Qt::CTRL) << int(Qt::Key_Aring) << MacCtrl + QLatin1String("\x0c5");
|
||||
QTest::newRow( "Alt" ) << int(Qt::ALT) << int(Qt::Key_Aring) << MacAlt + QLatin1String("\x0c5");
|
||||
QTest::newRow( "Shift" ) << int(Qt::SHIFT) << int(Qt::Key_Aring) << MacShift + QLatin1String("\x0c5");
|
||||
QTest::newRow( "Meta" ) << int(Qt::META) << int(Qt::Key_Aring) << MacMeta + QLatin1String("\x0c5");
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -224,11 +224,11 @@ void tst_QKeySequence::symetricConstructors_data()
|
||||
QTest::addColumn<int>("modifiers");
|
||||
QTest::addColumn<int>("keycode");
|
||||
|
||||
QTest::newRow( "No modifier" ) << 0 << int(Qt::Key_Aring | Qt::UNICODE_ACCEL);
|
||||
QTest::newRow( "Ctrl" ) << int(Qt::CTRL) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL);
|
||||
QTest::newRow( "Alt" ) << int(Qt::ALT) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL);
|
||||
QTest::newRow( "Shift" ) << int(Qt::SHIFT) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL);
|
||||
QTest::newRow( "Meta" ) << int(Qt::META) << int(Qt::Key_Aring | Qt::UNICODE_ACCEL);
|
||||
QTest::newRow( "No modifier" ) << 0 << int(Qt::Key_Aring);
|
||||
QTest::newRow( "Ctrl" ) << int(Qt::CTRL) << int(Qt::Key_Aring);
|
||||
QTest::newRow( "Alt" ) << int(Qt::ALT) << int(Qt::Key_Aring);
|
||||
QTest::newRow( "Shift" ) << int(Qt::SHIFT) << int(Qt::Key_Aring);
|
||||
QTest::newRow( "Meta" ) << int(Qt::META) << int(Qt::Key_Aring);
|
||||
}
|
||||
|
||||
void tst_QKeySequence::compareConstructors_data()
|
||||
|
@ -447,17 +447,17 @@ void tst_QShortcut::number_data()
|
||||
/* Testing Single Specialkeys
|
||||
Qt::Key_aring
|
||||
Qt::Key_Aring
|
||||
Qt::UNICODE_ACCEL + Qt::Key_K
|
||||
Qt::Key_K
|
||||
*/
|
||||
QTest::newRow("N06 - slot1") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
|
||||
QTest::newRow("N07 - slot2") << SetupAccel << TriggerSlot2 << QString() << int(Qt::SHIFT+Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
|
||||
QTest::newRow("N08 - slot2") << SetupAccel << TriggerSlot1 << QString() << int(Qt::UNICODE_ACCEL + Qt::Key_K) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
|
||||
QTest::newRow("N08 - slot2") << SetupAccel << TriggerSlot1 << QString() << int(Qt::Key_K) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
|
||||
|
||||
QTest::newRow("N:Qt::Key_aring") << TestAccel << NoWidget << QString() << int(Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
|
||||
QTest::newRow("N:Qt::Key_Aring") << TestAccel << NoWidget << QString() << int(Qt::SHIFT+Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
|
||||
QTest::newRow("N:Qt::Key_aring - Text Form") << TestAccel << NoWidget << QString() << 0 << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
|
||||
QTest::newRow("N:Qt::Key_Aring - Text Form") << TestAccel << NoWidget << QString() << int(Qt::SHIFT+0) << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
|
||||
QTest::newRow("N:Qt::UNICODE_ACCEL + Qt::Key_K")<< TestAccel << NoWidget << QString() << int(Qt::UNICODE_ACCEL + Qt::Key_K) << int('k') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
|
||||
QTest::newRow("N:Qt::Qt::Key_K") << TestAccel << NoWidget << QString() << int(Qt::Key_K) << int('k') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
|
||||
QTest::newRow("N09 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
|
||||
|
||||
/* Testing Multiple Sequences
|
||||
@ -592,7 +592,7 @@ void tst_QShortcut::text_data()
|
||||
/* Testing Single Specialkeys
|
||||
Qt::Key_aring
|
||||
Qt::Key_Aring
|
||||
Qt::UNICODE_ACCEL + Qt::Key_K
|
||||
Qt::Key_K
|
||||
*/
|
||||
/* see comments above on the #ifdef'ery */
|
||||
QTest::newRow("T06 - slot1") << SetupAccel << TriggerSlot1 << QString::fromLatin1("\x0C5")<< 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult;
|
||||
@ -602,7 +602,7 @@ void tst_QShortcut::text_data()
|
||||
QTest::newRow("T:Qt::Key_Aring") << TestAccel << NoWidget << QString() << int(Qt::SHIFT+Qt::Key_Aring) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
|
||||
QTest::newRow("T:Qt::Key_aring - Text Form") << TestAccel << NoWidget << QString() << 0 << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
|
||||
QTest::newRow("T:Qt::Key_Aring - Text Form") << TestAccel << NoWidget << QString() << int(Qt::SHIFT+0) << 0xC5 << 0 << 0 << 0 << 0 << 0 << 0 << Slot2Triggered;
|
||||
QTest::newRow("T:Qt::UNICODE_ACCEL + Qt::Key_K")<< TestAccel << NoWidget << QString() << int(Qt::UNICODE_ACCEL + Qt::Key_K) << int('k') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
|
||||
QTest::newRow("T:Qt::Key_K") << TestAccel << NoWidget << QString() << int(Qt::Key_K) << int('k') << 0 << 0 << 0 << 0 << 0 << 0 << Slot1Triggered;
|
||||
QTest::newRow("T09 - clear") << ClearAll << NoWidget << QString() << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << NoResult; // Clear all
|
||||
|
||||
/* Testing Multiple Sequences
|
||||
|
Loading…
x
Reference in New Issue
Block a user