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
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef QSK_SHORTCUT_H
|
|
|
|
#define QSK_SHORTCUT_H
|
|
|
|
|
|
|
|
#include "QskGlobal.h"
|
|
|
|
|
2017-12-06 17:01:10 +01:00
|
|
|
#include <QObject>
|
|
|
|
#include <QQmlParserStatus>
|
|
|
|
#include <Qt>
|
|
|
|
#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
|
|
|
|
*/
|
|
|
|
class QSK_EXPORT QskShortcut : 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
|
|
|
|
2017-12-06 17:01:10 +01:00
|
|
|
public:
|
|
|
|
QskShortcut( QObject* parent = nullptr );
|
2017-12-05 17:40:21 +01:00
|
|
|
|
2017-12-06 17:01:10 +01:00
|
|
|
QskShortcut( const QKeySequence&, QObject* = nullptr );
|
|
|
|
QskShortcut( const QKeySequence&, Qt::ShortcutContext, QObject* = nullptr );
|
2017-12-05 17:40:21 +01:00
|
|
|
|
2017-12-06 17:01:10 +01:00
|
|
|
virtual ~QskShortcut();
|
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;
|
|
|
|
void setContext(Qt::ShortcutContext context);
|
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
|
|
|
|
2017-12-06 17:01:10 +01:00
|
|
|
Q_SIGNALS:
|
|
|
|
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
|
|
|
|
2017-12-06 17:01:10 +01:00
|
|
|
int shortcutIdChanged( int ) const;
|
2017-12-05 13:10:50 +01:00
|
|
|
|
2017-12-06 17:01:10 +01:00
|
|
|
protected:
|
|
|
|
virtual bool event( QEvent* ) override;
|
|
|
|
virtual void classBegin() override;
|
|
|
|
virtual void componentComplete() override;
|
2017-12-05 13:10:50 +01:00
|
|
|
|
2017-12-06 17:01:10 +01:00
|
|
|
private:
|
|
|
|
class PrivateData;
|
|
|
|
std::unique_ptr< PrivateData > m_data;
|
|
|
|
};
|
2017-07-21 18:21:34 +02:00
|
|
|
|
|
|
|
#endif
|