51 lines
1.2 KiB
C
51 lines
1.2 KiB
C
|
#ifndef MNEMONICATTACHED_H
|
||
|
#define MNEMONICATTACHED_H
|
||
|
|
||
|
#include <QKeySequence>
|
||
|
#include <QObject>
|
||
|
#include <QString>
|
||
|
#include <QtQmlIntegration>
|
||
|
|
||
|
class MnemonicAttached : public QObject
|
||
|
{
|
||
|
Q_OBJECT
|
||
|
|
||
|
Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged FINAL)
|
||
|
Q_PROPERTY(QString richTextLabel READ richTextLabel NOTIFY richTextLabelChanged FINAL)
|
||
|
Q_PROPERTY(QKeySequence sequence READ sequence NOTIFY sequenceChanged FINAL)
|
||
|
|
||
|
QML_NAMED_ELEMENT(Mnemonic)
|
||
|
QML_UNCREATABLE("Mnemonic is only available via attached properties")
|
||
|
QML_ATTACHED(MnemonicAttached)
|
||
|
public:
|
||
|
explicit MnemonicAttached(QObject *parent = nullptr);
|
||
|
|
||
|
static MnemonicAttached *qmlAttachedProperties(QObject *object);
|
||
|
|
||
|
QString label() const;
|
||
|
void setLabel(const QString &label);
|
||
|
|
||
|
QString richTextLabel() const;
|
||
|
|
||
|
QKeySequence sequence() const;
|
||
|
|
||
|
signals:
|
||
|
void enabledChanged();
|
||
|
void labelChanged();
|
||
|
void richTextLabelChanged();
|
||
|
void sequenceChanged();
|
||
|
|
||
|
private slots:
|
||
|
void onAltPressed();
|
||
|
void onAltReleased();
|
||
|
|
||
|
private:
|
||
|
void updateRichText();
|
||
|
|
||
|
QString m_label;
|
||
|
QString m_richTextLabel;
|
||
|
bool m_active;
|
||
|
};
|
||
|
|
||
|
#endif // MNEMONICATTACHED_H
|