qskinny/src/controls/QskRadioBox.h

71 lines
1.9 KiB
C
Raw Normal View History

2023-02-26 17:04:47 +01:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
2023-04-06 09:23:37 +02:00
* SPDX-License-Identifier: BSD-3-Clause
2023-02-26 17:04:47 +01:00
*****************************************************************************/
2023-02-08 21:49:04 +01:00
#ifndef QSK_RADIO_BOX_H
#define QSK_RADIO_BOX_H
#include "QskControl.h"
2023-02-26 17:04:47 +01:00
#include <qstringlist.h>
2023-02-08 21:49:04 +01:00
class QSK_EXPORT QskRadioBox : public QskControl
{
Q_OBJECT
2023-02-26 17:04:47 +01:00
Q_PROPERTY( int selectedIndex READ selectedIndex
WRITE setSelectedIndex NOTIFY selectedIndexChanged FINAL )
2023-02-08 21:49:04 +01:00
Q_PROPERTY( QStringList options READ options
WRITE setOptions NOTIFY optionsChanged FINAL )
2023-02-08 21:49:04 +01:00
using Inherited = QskControl;
public:
QSK_SUBCONTROLS( Panel, Button, CheckIndicatorPanel, CheckIndicator, Text, Ripple )
QSK_STATES( Selected, Pressed )
2023-02-08 21:49:04 +01:00
QskRadioBox( QQuickItem* parent = nullptr );
QskRadioBox( const QStringList&, QQuickItem* parent = nullptr );
QskRadioBox( const QStringList&, int, QQuickItem* parent = nullptr );
2023-02-15 00:20:19 +01:00
2023-02-26 17:04:47 +01:00
~QskRadioBox() override;
2023-02-15 00:20:19 +01:00
QRectF focusIndicatorRect() const override;
2023-02-25 23:31:29 +01:00
QStringList options() const;
QString optionAt( int ) const;
2023-02-26 17:04:47 +01:00
int selectedIndex() const;
int pressedIndex() const;
2023-02-08 21:49:04 +01:00
public Q_SLOTS:
void setSelectedIndex( int );
void setOptions( const QStringList& );
2023-02-08 21:49:04 +01:00
Q_SIGNALS:
void selectedIndexChanged( int );
void optionsChanged( const QStringList& );
2023-02-08 21:49:04 +01:00
2023-02-25 23:31:29 +01:00
protected:
2023-02-08 21:49:04 +01:00
void keyPressEvent( QKeyEvent* ) override;
void keyReleaseEvent( QKeyEvent* ) override;
void mousePressEvent( QMouseEvent* ) override;
void mouseReleaseEvent( QMouseEvent* ) override;
2023-03-05 16:54:22 +01:00
void mouseUngrabEvent() override;
2023-02-08 21:49:04 +01:00
void focusInEvent( QFocusEvent* ) override;
void focusOutEvent( QFocusEvent* ) override;
int indexAt( const QPointF& ) const;
private:
2023-02-15 00:20:19 +01:00
void setFocusedIndex( int index );
2023-02-26 17:04:47 +01:00
2023-02-08 21:49:04 +01:00
class PrivateData;
std::unique_ptr< PrivateData > m_data;
};
#endif