mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 23:25:53 +08:00
Function for getKeyStrings() and replace without key (just adding)
This commit is contained in:
committed by
Mat Sutcliffe
parent
94b53cef6c
commit
21acef505c
@@ -42,8 +42,11 @@ namespace BlackMisc
|
||||
|
||||
void CHotkeyCombination::replaceKey(CKeyboardKey oldKey, CKeyboardKey newKey)
|
||||
{
|
||||
Q_ASSERT(!oldKey.isUnknown());
|
||||
m_keyboardKeys.remove(oldKey);
|
||||
if (oldKey.hasKey())
|
||||
{
|
||||
Q_ASSERT(!oldKey.isUnknown());
|
||||
m_keyboardKeys.remove(oldKey);
|
||||
}
|
||||
if (!newKey.isUnknown()) { m_keyboardKeys.push_back(newKey); }
|
||||
m_keyboardKeys.sortBy(&CKeyboardKey::getKey);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "blackmisc/valueobject.h"
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -46,6 +46,9 @@ namespace BlackMisc
|
||||
//! Get keyboard keys
|
||||
CKeyboardKeyList getKeyboardKeys() const { return m_keyboardKeys; }
|
||||
|
||||
//! As keyboard key strings
|
||||
QStringList getKeyStrings() const { return m_keyboardKeys.getKeyStrings(); }
|
||||
|
||||
//! Set joystick buttons
|
||||
void setJoystickButtons(const CJoystickButtonList &list) { m_joystickButtons = list; }
|
||||
|
||||
|
||||
@@ -25,6 +25,16 @@ namespace BlackMisc
|
||||
CSequence<CKeyboardKey>(baseClass)
|
||||
{ }
|
||||
|
||||
QStringList CKeyboardKeyList::getKeyStrings() const
|
||||
{
|
||||
QStringList keys;
|
||||
for (const CKeyboardKey &k : *this)
|
||||
{
|
||||
if (k.hasKey()) { keys.push_back(k.getKeyAsString()); }
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
const CKeyboardKeyList &CKeyboardKeyList::allSupportedKeys()
|
||||
{
|
||||
static const CKeyboardKeyList allKeys =
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "blackmisc/sequence.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
#include <QStringList>
|
||||
#include <QMetaType>
|
||||
#include <initializer_list>
|
||||
#include <tuple>
|
||||
@@ -46,6 +47,9 @@ namespace BlackMisc
|
||||
//! Initializer list constructor.
|
||||
CKeyboardKeyList(std::initializer_list<CKeyboardKey> il) : CSequence<CKeyboardKey>(il) {}
|
||||
|
||||
//! All key strings
|
||||
QStringList getKeyStrings() const;
|
||||
|
||||
//! Get all supported keys
|
||||
static const CKeyboardKeyList &allSupportedKeys();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user