2017-07-21 18:21:34 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
|
|
* This file may be used under the terms of the QSkinny License, Version 1.0
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2019-05-12 13:54:22 +02:00
|
|
|
#ifndef QSK_SHORTCUT_QML_H
|
|
|
|
#define QSK_SHORTCUT_QML_H
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2018-10-12 08:03:03 +02:00
|
|
|
#include "QskQmlGlobal.h"
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
#include <qnamespace.h>
|
2018-07-19 14:10:48 +02:00
|
|
|
#include <qobject.h>
|
|
|
|
#include <qqmlparserstatus.h>
|
|
|
|
|
2017-12-06 17:01:10 +01:00
|
|
|
#include <memory>
|
2017-12-05 17:40:21 +01:00
|
|
|
|
2017-12-06 17:01:10 +01:00
|
|
|
class QKeySequence;
|
2017-12-03 17:58:18 +01:00
|
|
|
|
2017-12-06 17:01:10 +01:00
|
|
|
/*
|
|
|
|
For QML, with C++ there is also QskShortcutMap that does
|
|
|
|
not need to create QObjects per shortcut
|
|
|
|
*/
|
2019-05-12 13:54:22 +02:00
|
|
|
class QskShortcutQml : public QObject, public QQmlParserStatus
|
2017-12-05 17:40:21 +01:00
|
|
|
{
|
2017-12-06 17:01:10 +01:00
|
|
|
Q_OBJECT
|
|
|
|
Q_INTERFACES( QQmlParserStatus )
|
2017-12-05 17:40:21 +01:00
|
|
|
|
2017-12-06 17:01:10 +01:00
|
|
|
Q_PROPERTY( QVariant sequence READ sequenceVariant
|
|
|
|
WRITE setSequenceVariant NOTIFY sequenceChanged FINAL)
|
2017-12-06 12:23:43 +01:00
|
|
|
|
2017-12-06 17:01:10 +01:00
|
|
|
Q_PROPERTY( Qt::ShortcutContext context READ context
|
|
|
|
WRITE setContext NOTIFY contextChanged )
|
2017-12-06 12:23:43 +01:00
|
|
|
|
2017-12-06 17:01:10 +01:00
|
|
|
Q_PROPERTY( bool enabled READ isEnabled
|
|
|
|
WRITE setEnabled NOTIFY enabledChanged )
|
2017-12-05 17:40:21 +01:00
|
|
|
|
2017-12-06 17:01:10 +01:00
|
|
|
Q_PROPERTY( bool autoRepeat READ autoRepeat
|
|
|
|
WRITE setAutoRepeat NOTIFY autoRepeatChanged )
|
2017-12-05 17:40:21 +01:00
|
|
|
|
2017-12-06 17:01:10 +01:00
|
|
|
Q_PROPERTY( int shortcutId READ shortcutId
|
|
|
|
NOTIFY shortcutIdChanged )
|
2017-12-05 17:40:21 +01:00
|
|
|
|
2017-12-06 17:01:10 +01:00
|
|
|
using Inherited = QObject;
|
2017-12-05 17:40:21 +01:00
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
public:
|
2019-05-12 13:54:22 +02:00
|
|
|
QskShortcutQml( QObject* parent = nullptr );
|
2017-12-05 17:40:21 +01:00
|
|
|
|
2019-05-12 13:54:22 +02:00
|
|
|
QskShortcutQml( const QKeySequence&, QObject* = nullptr );
|
|
|
|
QskShortcutQml( const QKeySequence&, Qt::ShortcutContext, QObject* = nullptr );
|
2017-12-05 17:40:21 +01:00
|
|
|
|
2019-05-12 13:54:22 +02:00
|
|
|
~QskShortcutQml() override;
|
2017-12-05 17:40:21 +01:00
|
|
|
|
2017-12-06 17:01:10 +01:00
|
|
|
int shortcutId() const;
|
2017-12-05 17:40:21 +01:00
|
|
|
|
2017-12-06 17:01:10 +01:00
|
|
|
void setSequence( const QKeySequence& );
|
|
|
|
QKeySequence sequence() const;
|
2017-12-05 17:40:21 +01:00
|
|
|
|
2017-12-06 17:01:10 +01:00
|
|
|
// for QML
|
|
|
|
void setSequenceVariant( const QVariant& );
|
|
|
|
QVariant sequenceVariant() const;
|
2017-12-05 17:40:21 +01:00
|
|
|
|
2017-12-06 17:01:10 +01:00
|
|
|
Qt::ShortcutContext context() const;
|
2018-08-03 08:15:28 +02:00
|
|
|
void setContext( Qt::ShortcutContext );
|
2017-12-05 17:40:21 +01:00
|
|
|
|
2017-12-06 17:01:10 +01:00
|
|
|
void setEnabled( bool );
|
|
|
|
bool isEnabled() const;
|
2017-12-05 17:40:21 +01:00
|
|
|
|
2017-12-06 17:01:10 +01:00
|
|
|
void setAutoRepeat( bool );
|
|
|
|
bool autoRepeat() const;
|
2017-12-05 13:10:50 +01:00
|
|
|
|
2017-12-06 17:01:10 +01:00
|
|
|
virtual bool isFocusInScope() const;
|
2017-12-06 12:23:43 +01:00
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
Q_SIGNALS:
|
2017-12-06 17:01:10 +01:00
|
|
|
void sequenceChanged();
|
|
|
|
void contextChanged();
|
|
|
|
void enabledChanged();
|
|
|
|
void autoRepeatChanged();
|
2017-12-05 13:10:50 +01:00
|
|
|
|
2017-12-06 17:01:10 +01:00
|
|
|
void activated();
|
|
|
|
void activatedAmbiguously();
|
2017-12-05 13:10:50 +01:00
|
|
|
|
2018-08-03 11:11:42 +02:00
|
|
|
int shortcutIdChanged( int );
|
2017-12-05 13:10:50 +01:00
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
protected:
|
2018-07-31 17:32:25 +02:00
|
|
|
bool event( QEvent* ) override;
|
|
|
|
void classBegin() override;
|
|
|
|
void componentComplete() override;
|
2017-12-05 13:10:50 +01:00
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
private:
|
2017-12-06 17:01:10 +01:00
|
|
|
class PrivateData;
|
|
|
|
std::unique_ptr< PrivateData > m_data;
|
|
|
|
};
|
2017-07-21 18:21:34 +02:00
|
|
|
|
|
|
|
#endif
|