QmlMaterial 0.1.0
Loading...
Searching...
No Matches
time_dial.hpp
1#pragma once
2
3#include <QQuickItem>
4#include <QPointer>
5#include "qml_material/input/time_state.hpp"
6#include "qml_material/input/input_host.hpp"
7
8namespace qml_material
9{
10class QML_MATERIAL_API TimeDial : public QQuickItem {
11 Q_OBJECT
12 QML_ELEMENT
13 Q_PROPERTY(qml_material::TimeState* time READ time WRITE setTime NOTIFY timeChanged FINAL)
14 Q_PROPERTY(qreal handAngle READ handAngle NOTIFY metricsChanged FINAL)
15 Q_PROPERTY(qreal handLength READ handLength NOTIFY metricsChanged FINAL)
16 Q_PROPERTY(QVariantList labels READ labels NOTIFY metricsChanged FINAL)
17 Q_PROPERTY(InteractionSource* interactionSource READ interactionSource WRITE
18 setInteractionSource NOTIFY interactionSourceChanged FINAL)
19public:
20 explicit TimeDial(QQuickItem* parent = nullptr);
21 ~TimeDial() override;
22 TimeState* time() const { return m_time; }
23 void setTime(TimeState*);
24 qreal handAngle() const;
25 qreal handLength() const;
26 QVariantList labels() const;
27 InteractionSource* interactionSource() { return m_input.source(); }
28 void setInteractionSource(InteractionSource* source) { m_input.setSource(source); }
29 Q_SIGNAL void timeChanged();
30 Q_SIGNAL void metricsChanged();
31 Q_SIGNAL void interactionSourceChanged();
32
33protected:
34 void geometryChange(const QRectF&, const QRectF&) override;
35 bool event(QEvent*) override;
36 void touchUngrabEvent() override;
37 void mouseUngrabEvent() override;
38 void keyPressEvent(QKeyEvent*) override;
39
40private:
41 qreal radius() const;
42 void update(const QPointF&, bool tap);
43 void select(int value, bool complete);
44 void cancel();
45 QPointer<TimeState> m_time;
46 QMetaObject::Connection m_changed, m_destroyed;
47 bool m_updating = false;
48 quint64 m_revision = 0;
49 InputHost m_input;
50};
51} // namespace qml_material
Definition time_state.hpp:13