3#include "qml_material/control/button_control.hpp"
4#include "qml_material/util/qt.hpp"
8class QML_MATERIAL_API SelectionButton :
public ButtonControl {
10 QML_NAMED_ELEMENT(SelectionButtonBase)
11 Q_PROPERTY(
bool selected READ isSelected WRITE setSelected NOTIFY selectedChanged FINAL)
13 explicit SelectionButton(QQuickItem* parent =
nullptr): ButtonControl(parent) {
14 m_selectedNotifier = m_selected.addNotifier([
this] {
15 Q_EMIT selectedChanged();
18 bool isSelected()
const {
return m_selected; }
19 void setSelected(
bool value) { utils::updateBoundValue(m_selected, value); }
20 QBindable<bool> bindableSelected() {
return &m_selected; }
21 Q_INVOKABLE
void requestSelection() {
22 if (canActivate()) Q_EMIT selectionRequested();
24 Q_SIGNAL
void selectedChanged();
25 Q_SIGNAL
void selectionRequested();
28 void activate()
override { requestSelection(); }
31 Q_OBJECT_BINDABLE_PROPERTY(SelectionButton,
bool, m_selected)
32 QPropertyNotifier m_selectedNotifier;