3#include "qml_material/control/command_button.hpp"
8class QML_MATERIAL_API RepeatButton :
public CommandButton {
10 QML_NAMED_ELEMENT(RepeatButtonBase)
11 Q_PROPERTY(
int repeatDelay READ repeatDelay WRITE setRepeatDelay NOTIFY repeatChanged FINAL)
13 int repeatInterval READ repeatInterval WRITE setRepeatInterval NOTIFY repeatChanged FINAL)
15 explicit RepeatButton(QQuickItem* parent =
nullptr): CommandButton(parent) {
16 inputHost().click().repeat();
18 int repeatDelay() {
return inputHost().click().repeat().delay; }
19 int repeatInterval() {
return inputHost().click().repeat().interval; }
20 void setRepeatDelay(
int value) { configure(value, repeatInterval()); }
21 void setRepeatInterval(
int value) { configure(repeatDelay(), value); }
22 Q_SIGNAL
void repeatChanged();
25 void configure(
int delay,
int interval) {
26 delay = qMax(1, delay);
27 interval = qMax(1, interval);
28 if (delay == repeatDelay() && interval == repeatInterval())
return;
29 const QPointer<RepeatButton> guard(
this);
32 auto& repeat = inputHost().click().repeat();
34 repeat.interval = interval;
35 Q_EMIT repeatChanged();