QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskAbstractButton.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_ABSTRACT_BUTTON_H
7#define QSK_ABSTRACT_BUTTON_H
8
9#include "QskControl.h"
10
11class QSK_EXPORT QskAbstractButton : public QskControl
12{
13 Q_OBJECT
14
15 Q_PROPERTY( bool autoRepeat READ autoRepeat
16 WRITE setAutoRepeat NOTIFY autoRepeatChanged FINAL )
17
18 Q_PROPERTY( int autoRepeatDelay READ autoRepeatDelay
19 WRITE setAutoRepeatDelay NOTIFY autoRepeatDelayChanged FINAL )
20
21 Q_PROPERTY( int autoRepeatInterval READ autoRepeatInterval
22 WRITE setAutoRepeatInterval NOTIFY autoRepeatIntervalChanged FINAL )
23
24 Q_PROPERTY( bool exclusive READ exclusive
25 WRITE setExclusive NOTIFY exclusiveChanged FINAL )
26
27 Q_PROPERTY( bool pressed READ isPressed
28 WRITE setPressed NOTIFY pressedChanged FINAL )
29
30 Q_PROPERTY( bool checked READ isChecked
31 WRITE setChecked NOTIFY checkedChanged USER true FINAL )
32
33 using Inherited = QskControl;
34
35 public:
36 QSK_STATES( Checked, Pressed )
37
38 QskAbstractButton( QQuickItem* parent = nullptr );
39 ~QskAbstractButton() override;
40
41 virtual bool isCheckable() const;
42 bool isChecked() const;
43
44 void setPressed( bool on );
45 bool isPressed() const;
46
47 void setAutoRepeat( bool );
48 bool autoRepeat() const;
49
50 void setAutoRepeatDelay( int ms );
51 int autoRepeatDelay() const;
52
53 void setAutoRepeatInterval( int ms );
54 int autoRepeatInterval() const;
55
56 void setExclusive( bool );
57 bool exclusive() const;
58
59 public Q_SLOTS:
60 void toggle();
61 void click();
62 void setChecked( bool );
63
64 Q_SIGNALS:
65 void pressed();
66 void released();
67 void canceled();
68 void clicked();
69 void toggled( bool );
70
71 void pressedChanged( bool );
72 void checkedChanged( bool );
73
74 void autoRepeatChanged( bool );
75 void autoRepeatDelayChanged();
76 void autoRepeatIntervalChanged();
77
78 void exclusiveChanged( bool );
79
80 protected:
81 bool event( QEvent* ) override;
82
83 void keyPressEvent( QKeyEvent* ) override;
84 void keyReleaseEvent( QKeyEvent* ) override;
85
86 void mouseMoveEvent( QMouseEvent* ) override;
87 void mousePressEvent( QMouseEvent* ) override;
88 void mouseReleaseEvent( QMouseEvent* ) override;
89 void mouseUngrabEvent() override;
90
91 void focusInEvent( QFocusEvent* ) override;
92 void focusOutEvent( QFocusEvent* ) override;
93
94 void timerEvent( QTimerEvent* ) override;
95
96 virtual void setCheckedState( bool on );
97
98 private:
99 void releaseButton();
100
101 class PrivateData;
102 std::unique_ptr< PrivateData > m_data;
103};
104
105#endif
Base class of all controls.
Definition QskControl.h:23
void mouseUngrabEvent() override
Definition QskItem.cpp:1044