2024-12-21 03:56:09 +00:00
|
|
|
#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)
|
2024-12-30 08:50:36 +00:00
|
|
|
Q_PROPERTY(QString plainLabel READ plainLabel NOTIFY plainLabelChanged FINAL)
|
2024-12-21 03:56:09 +00:00
|
|
|
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);
|
|
|
|
|
2024-12-30 08:50:36 +00:00
|
|
|
QString plainLabel() const;
|
|
|
|
|
2024-12-21 03:56:09 +00:00
|
|
|
QString richTextLabel() const;
|
|
|
|
|
|
|
|
QKeySequence sequence() const;
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void enabledChanged();
|
|
|
|
void labelChanged();
|
2024-12-30 08:50:36 +00:00
|
|
|
void plainLabelChanged();
|
2024-12-21 03:56:09 +00:00
|
|
|
void richTextLabelChanged();
|
|
|
|
void sequenceChanged();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void onAltPressed();
|
|
|
|
void onAltReleased();
|
|
|
|
|
|
|
|
private:
|
2024-12-30 08:50:36 +00:00
|
|
|
void setPlainLabel(const QString &plain);
|
2024-12-21 03:56:09 +00:00
|
|
|
void updateRichText();
|
|
|
|
|
|
|
|
QString m_label;
|
2024-12-30 08:50:36 +00:00
|
|
|
QString m_plainLabel;
|
2024-12-21 03:56:09 +00:00
|
|
|
QString m_richTextLabel;
|
|
|
|
bool m_active;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MNEMONICATTACHED_H
|