clean: deprecated QKeySequence[]->int; answer ikm's question from 2009
Some checks are pending
SonarCloud / Build and analyze (push) Waiting to run

This commit is contained in:
shenleban tongying 2024-11-06 06:11:48 -05:00 committed by GitHub
parent 8d0859b932
commit 8ad7291147
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 21 deletions

View file

@ -102,31 +102,23 @@ AnkiConnectServer::AnkiConnectServer():
{
}
HotKey::HotKey():
modifiers( 0 ),
key1( 0 ),
key2( 0 )
{
}
// Does anyone know how to separate modifiers from the keycode? We'll
// use our own mask.
uint32_t const keyMask = 0x01FFFFFF;
HotKey::HotKey( QKeySequence const & seq ):
modifiers( seq[ 0 ] & ~keyMask ),
key1( seq[ 0 ] & keyMask ),
key2( seq[ 1 ] & keyMask )
modifiers( seq[ 0 ].keyboardModifiers() ),
key1( seq[ 0 ].key() ),
key2( seq[ 1 ].key() )
{
}
QKeySequence HotKey::toKeySequence() const
{
int v2 = key2 ? ( key2 | modifiers ) : 0;
return QKeySequence( key1 | modifiers, v2 );
if ( key2 != 0 || key2 != Qt::Key::Key_unknown ) {
return { QKeyCombination( modifiers, static_cast< Qt::Key >( key1 ) ),
QKeyCombination( modifiers, static_cast< Qt::Key >( key2 ) ) };
}
return { QKeyCombination( modifiers, static_cast< Qt::Key >( key1 ) ) };
;
}
bool InternalPlayerBackend::anyAvailable()
{

View file

@ -192,14 +192,11 @@ struct HotKey
Qt::KeyboardModifiers modifiers;
int key1, key2;
HotKey();
/// Hotkey's constructor, take a QKeySequence's first two keys
/// 1st key's modifier will be the `modifiers` above
/// 1st key without modifier will becomes `key1`
/// 2nd key without modifier will becomes `key2`
/// The relation between the int and qt's KeyCode should consult qt's doc
HotKey( QKeySequence const & );
QKeySequence toKeySequence() const;