qskinny/src/controls/QskSpinBox.h

86 lines
2.2 KiB
C
Raw Normal View History

2023-02-17 12:01:56 +01:00
/******************************************************************************
2023-02-17 14:05:05 +01:00
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
2023-02-17 12:01:56 +01:00
*****************************************************************************/
2023-02-17 14:05:05 +01:00
#ifndef QSK_SPIN_BOX_H
#define QSK_SPIN_BOX_H
2023-02-17 12:01:56 +01:00
2023-02-17 15:22:40 +01:00
#include <QskBoundedValueInput.h>
2023-02-17 12:01:56 +01:00
class QSK_EXPORT QskSpinBox : public QskBoundedValueInput
2023-02-17 12:01:56 +01:00
{
2023-02-17 15:22:40 +01:00
Q_OBJECT
using Inherited = QskBoundedValueInput;
2023-02-23 14:37:49 +01:00
Q_PROPERTY( bool wrapping READ isWrapping
WRITE setWrapping NOTIFY wrappingChanged )
Q_PROPERTY( bool tracking READ isTracking
WRITE setTracking NOTIFY trackingChanged )
Q_PROPERTY( bool accelerating READ isAccelerating
WRITE setAccelerating NOTIFY acceleratingChanged )
2023-02-17 15:22:40 +01:00
2023-02-23 14:37:49 +01:00
Q_PROPERTY( bool buttons READ hasButtons
WRITE setButtons NOTIFY buttonsChanged )
2023-02-24 08:24:32 +01:00
Q_PROPERTY( int decimals READ decimals
WRITE setDecimals NOTIFY decimalsChanged )
Q_PROPERTY( QString text READ text NOTIFY textChanged )
2023-02-23 14:37:49 +01:00
public:
QSK_SUBCONTROLS( Panel, TextPanel, Text,
2023-02-23 14:37:49 +01:00
UpPanel, UpIndicator, DownPanel, DownIndicator )
2023-02-17 15:22:40 +01:00
2023-02-23 14:37:49 +01:00
QSK_STATES( Decreasing, Increasing )
2023-02-17 17:46:52 +01:00
QskSpinBox( QQuickItem* parent = nullptr );
2023-02-17 15:22:40 +01:00
~QskSpinBox() override;
2023-02-17 17:46:52 +01:00
2023-02-23 14:37:49 +01:00
void setButtons( bool );
bool hasButtons() const;
void setWrapping( bool );
bool isWrapping() const;
void setTracking( bool );
bool isTracking() const;
void setAccelerating( bool );
bool isAccelerating() const;
2023-02-24 08:24:32 +01:00
void setDecimals( int );
int decimals() const;
QString text() const;
2023-02-23 14:37:49 +01:00
Q_SIGNALS:
2023-02-24 08:24:32 +01:00
void buttonsChanged( bool );
2023-02-23 14:37:49 +01:00
void trackingChanged( bool );
void wrappingChanged( bool );
void acceleratingChanged( bool );
2023-02-24 08:24:32 +01:00
void decimalsChanged( int );
void textChanged();
protected:
virtual QString textFromValue( qreal ) const;
2023-02-17 15:22:40 +01:00
private:
2023-02-23 14:37:49 +01:00
void timerEvent( QTimerEvent* ) override;
2023-02-17 15:22:40 +01:00
2023-02-23 14:37:49 +01:00
void mouseReleaseEvent( QMouseEvent* ) override;
void mousePressEvent( QMouseEvent* ) override;
2023-02-17 15:22:40 +01:00
2023-02-23 14:37:49 +01:00
void keyPressEvent( QKeyEvent* ) override;
void keyReleaseEvent( QKeyEvent* ) override;
2023-02-17 15:22:40 +01:00
class PrivateData;
std::unique_ptr< PrivateData > m_data;
2023-02-17 12:01:56 +01:00
};
2023-02-17 14:05:05 +01:00
#endif