QcKeyControls Class
The player's key table for QML: the rows of the controls page, the key texts of hints, key tests for screens and rebinding. More...
| Header: | #include <clientcore/settings/QcKeyControls.h> |
| Inherits: | QObject |
Public Types
| enum class | Capture { Ignored, Waiting, Cancelled, Bound } |
| enum class | ClosingKey { EscOnly, InventoryKey, AdvancementsKey, HandbookKey } |
| enum class | ScreenKey { Unused, Close, Handbook } |
Properties
|
Public Functions
| QString | bind(const QString &action, int slot, int key) |
| const QcKeyBindings & | bindings() const |
| void | cancelCapture() |
| QString | captureAction() const |
| int | captureSlot() const |
| bool | capturing() const |
| void | clearCapture() |
| QcKeyControls::Capture | keyPressed(int key, bool autoRepeat) |
| QcKeyControls::Capture | keyReleased(int key, bool autoRepeat) |
| QVariantMap | labels() const |
| bool | matches(const QString &action, int key) const |
| QString | message() const |
| void | reset() |
| void | retranslate() |
| QVariantList | rows() const |
| QcKeyControls::ScreenKey | screenKey(int key, bool autoRepeat, QcKeyControls::ClosingKey closing) const |
| void | setBindings(const QcKeyBindings &bindings) |
| void | startCapture(const QString &action, int slot) |
Signals
| void | captureChanged() |
| void | changed() |
| void | edited() |
| void | messageChanged() |
Detailed Description
The controls page captures a key for a slot here: startCapture() waits, keyPressed() and keyReleased() take the keys (Esc cancels; a modifier is bound when it is released without another key, so Shift+7 binds the character it types), and message says what the last change did. The game controller loads and stores it with the settings; QML knows it as KeyControls (QcKeyControlsForeign).
Member Type Documentation
enum class QcKeyControls::Capture
What a key did to a capture.
| Constant | Value | Description |
|---|---|---|
QcKeyControls::Capture::Ignored | 0 | no slot waits for a key |
QcKeyControls::Capture::Waiting | 1 | the slot still waits (a modifier held, a repeated key, another key released) |
QcKeyControls::Capture::Cancelled | 2 | Esc ended the capture without a key |
QcKeyControls::Capture::Bound | 3 | the key was bound (or refused, see message); the capture ended |
enum class QcKeyControls::ClosingKey
The key that closes a screen besides Esc, as the key that opened it from the world.
| Constant | Value | Description |
|---|---|---|
QcKeyControls::ClosingKey::EscOnly | 0 | only Esc (the pause menu, the settings, the main menu) |
QcKeyControls::ClosingKey::InventoryKey | 1 | the inventory key (the screens with item slots) |
QcKeyControls::ClosingKey::AdvancementsKey | 2 | the advancements key (the advancements) |
QcKeyControls::ClosingKey::HandbookKey | 3 | the handbook key (the handbook) |
enum class QcKeyControls::ScreenKey
What a key pressed on a screen does (screenKey()).
| Constant | Value | Description |
|---|---|---|
QcKeyControls::ScreenKey::Unused | 0 | nothing of the screens' common rule; the screen may use the key itself |
QcKeyControls::ScreenKey::Close | 1 | the screen closes |
QcKeyControls::ScreenKey::Handbook | 2 | the handbook opens |
Property Documentation
[read-only] captureAction : QString
The id of the action whose slot waits for a key; empty without a capture.
Access functions:
| QString | captureAction() const |
Notifier signal:
| void | captureChanged() |
[read-only] captureSlot : int
The slot that waits for a key: 0 primary, 1 secondary, -1 without a capture.
Access functions:
| int | captureSlot() const |
Notifier signal:
| void | captureChanged() |
[read-only] capturing : bool
A slot waits for a key (startCapture()).
Access functions:
| bool | capturing() const |
Notifier signal:
| void | captureChanged() |
[read-only] labels : QVariantMap
Action id -> text of its primary key, e.g. {"cameraView": "V"}.
Access functions:
| QVariantMap | labels() const |
Notifier signal:
| void | changed() |
[read-only] message : QString
What the last change did: a refused key, a resolved conflict, a Mac caveat or the reset; empty when it needs no words.
Access functions:
| QString | message() const |
Notifier signal:
| void | messageChanged() |
[read-only] rows : QVariantList
[{action, label, primary, secondary, primaryBound, secondaryBound, fixed}] with the keys as display texts and whether each slot has a key.
Access functions:
| QVariantList | rows() const |
Notifier signal:
| void | changed() |
Member Function Documentation
[invokable] QString QcKeyControls::bind(const QString &action, int slot, int key)
Binds key (a Qt::Key) to slot (0 primary, 1 secondary) of the action with the id action; Backspace clears the slot. Returns a text describing a refused key, a resolved conflict or a Mac caveat, else "". edited follows once for every change.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
const QcKeyBindings &QcKeyControls::bindings() const
Returns the key table.
See also setBindings().
[invokable] void QcKeyControls::cancelCapture()
Ends a capture without a key.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
QString QcKeyControls::captureAction() const
Returns the id of the action whose slot waits for a key.
Note: Getter function for property captureAction.
[signal] void QcKeyControls::captureChanged()
A capture started or ended.
Note: Notifier signal for properties captureAction, captureSlot, and capturing.
int QcKeyControls::captureSlot() const
Returns the slot that waits for a key, -1 without a capture.
Note: Getter function for property captureSlot.
bool QcKeyControls::capturing() const
Returns whether a slot waits for a key.
Note: Getter function for property capturing.
[invokable] void QcKeyControls::clearCapture()
Ends a capture and clears message (the settings open).
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[signal] void QcKeyControls::edited()
The player changed a key; the settings should be stored.
[invokable] QcKeyControls::Capture QcKeyControls::keyPressed(int key, bool autoRepeat)
Takes key (a Qt::Key) pressed during a capture, autoRepeat when the system repeats it. Returns what it did.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[invokable] QcKeyControls::Capture QcKeyControls::keyReleased(int key, bool autoRepeat)
Takes key (a Qt::Key) released during a capture, autoRepeat when the system repeats it: binds a modifier pressed alone. Returns what it did.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
QVariantMap QcKeyControls::labels() const
Returns the first key of every action by its id, as the HUD names it; a function key on a Mac with "fn+".
Note: Getter function for property labels.
[invokable] bool QcKeyControls::matches(const QString &action, int key) const
Returns whether key (a Qt::Key) triggers the action with the id action ("handbook", "inventory", ...).
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
QString QcKeyControls::message() const
Returns what the last change did.
Note: Getter function for property message.
[signal] void QcKeyControls::messageChanged()
message changed.
Note: Notifier signal for property message.
[invokable] void QcKeyControls::reset()
Gives every action its default keys again; edited follows when that changed anything.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
void QcKeyControls::retranslate()
The texts follow the UI language.
[invokable] QcKeyControls::ScreenKey QcKeyControls::screenKey(int key, bool autoRepeat, QcKeyControls::ClosingKey closing) const
Returns what key (a Qt::Key) does on a screen whose own key is closing, the common rule of the screens as the world's keys have theirs in the game input: Esc closes the screen, and so does the closing key unless autoRepeat (it is still held from opening the screen); the handbook key opens the handbook on any other screen. An unknown closing is taken as EscOnly with a warning.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
void QcKeyControls::setBindings(const QcKeyBindings &bindings)
Takes the keys bindings loaded from the settings; does not ask for storing.
See also bindings().
[invokable] void QcKeyControls::startCapture(const QString &action, int slot)
Waits for a key for slot (0 primary, 1 secondary) of the action with the id action and clears message. An unknown or fixed action or another slot is ignored with a warning.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.