2023-02-17 12:01:56 +01:00
|
|
|
/******************************************************************************
|
2023-02-17 14:05:05 +01:00
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
2023-04-06 09:23:37 +02:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
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
|
|
|
|
2023-02-17 14:57:33 +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 )
|
|
|
|
|
2023-02-27 09:56:41 +01:00
|
|
|
Q_PROPERTY( Decoration decoration READ decoration
|
|
|
|
WRITE setDecoration RESET resetDecoration NOTIFY decorationChanged )
|
2023-02-23 14:37:49 +01:00
|
|
|
|
2023-02-24 08:24:32 +01:00
|
|
|
Q_PROPERTY( int decimals READ decimals
|
|
|
|
WRITE setDecimals NOTIFY decimalsChanged )
|
|
|
|
|
2023-02-27 09:56:41 +01:00
|
|
|
Q_PROPERTY( Qt::Alignment textAlignment READ textAlignment
|
|
|
|
WRITE setTextAlignment RESET textAlignment NOTIFY textAlignmentChanged )
|
|
|
|
|
2023-02-24 08:24:32 +01:00
|
|
|
Q_PROPERTY( QString text READ text NOTIFY textChanged )
|
|
|
|
|
2023-02-23 14:37:49 +01:00
|
|
|
public:
|
2023-02-19 14:24:09 +01:00
|
|
|
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
|
|
|
|
2023-02-27 09:56:41 +01:00
|
|
|
enum Decoration
|
|
|
|
{
|
|
|
|
NoDecoration,
|
|
|
|
|
|
|
|
Buttons,
|
|
|
|
UpDownControl
|
|
|
|
};
|
|
|
|
Q_ENUM( Decoration )
|
|
|
|
|
2023-02-19 14:24:09 +01:00
|
|
|
QskSpinBox( QQuickItem* parent = nullptr );
|
2023-02-28 15:49:42 +01:00
|
|
|
QskSpinBox( qreal min, qreal max,
|
|
|
|
qreal stepSize, QQuickItem* parent = nullptr );
|
2023-02-27 09:56:41 +01:00
|
|
|
|
2023-02-17 15:22:40 +01:00
|
|
|
~QskSpinBox() override;
|
2023-02-17 17:46:52 +01:00
|
|
|
|
2023-02-27 09:56:41 +01:00
|
|
|
void setDecoration( Decoration );
|
|
|
|
void resetDecoration();
|
|
|
|
Decoration decoration() const;
|
|
|
|
|
|
|
|
// Qt::AlignLeft, Qt::AlignRight or Qt::AlignHCenter.
|
|
|
|
void setTextAlignment( Qt::Alignment );
|
|
|
|
void resetTextAlignment();
|
|
|
|
Qt::Alignment textAlignment() const;
|
2023-02-23 14:37:49 +01:00
|
|
|
|
|
|
|
void setWrapping( bool );
|
|
|
|
bool isWrapping() const;
|
|
|
|
|
2023-02-24 08:24:32 +01:00
|
|
|
void setDecimals( int );
|
|
|
|
int decimals() const;
|
|
|
|
|
|
|
|
QString text() const;
|
2023-02-27 09:56:41 +01:00
|
|
|
virtual QString textFromValue( qreal ) const;
|
2023-02-24 08:24:32 +01:00
|
|
|
|
2023-03-01 13:58:10 +01:00
|
|
|
void increment( qreal ) override;
|
|
|
|
|
2023-02-23 14:37:49 +01:00
|
|
|
Q_SIGNALS:
|
2023-02-27 09:56:41 +01:00
|
|
|
void decorationChanged( Decoration );
|
|
|
|
void textAlignmentChanged( Qt::Alignment );
|
2023-02-24 08:24:32 +01:00
|
|
|
|
2023-02-23 14:37:49 +01:00
|
|
|
void wrappingChanged( bool );
|
2023-02-24 08:24:32 +01:00
|
|
|
|
|
|
|
void decimalsChanged( int );
|
|
|
|
void textChanged();
|
|
|
|
|
2023-03-01 16:09:17 +01:00
|
|
|
protected:
|
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;
|
2023-03-01 14:22:40 +01:00
|
|
|
void mouseMoveEvent( QMouseEvent* ) override;
|
2023-02-23 14:37:49 +01:00
|
|
|
void mousePressEvent( QMouseEvent* ) override;
|
2023-03-01 14:22:40 +01:00
|
|
|
void mouseUngrabEvent() 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
|
|
|
|
2023-03-01 16:09:17 +01:00
|
|
|
private:
|
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
|