qskinny/src/controls/QskPushButton.h

103 lines
2.8 KiB
C
Raw Normal View History

2017-07-21 18:21:34 +02:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
#ifndef QSK_PUSH_BUTTON_H
#define QSK_PUSH_BUTTON_H
#include "QskAbstractButton.h"
class QskCorner;
class QskGraphic;
class QskTextOptions;
class QSK_EXPORT QskPushButton : public QskAbstractButton
{
Q_OBJECT
Q_PROPERTY( QString text READ text WRITE setText NOTIFY textChanged FINAL )
Q_PROPERTY( QskTextOptions textOptions READ textOptions
WRITE setTextOptions NOTIFY textOptionsChanged )
Q_PROPERTY( QUrl graphicSource READ graphicSource
WRITE setGraphicSource NOTIFY graphicSourceChanged FINAL )
Q_PROPERTY( QskGraphic graphic READ graphic
WRITE setGraphic NOTIFY graphicChanged FINAL )
Q_PROPERTY( QSizeF graphicSourceSize READ graphicSourceSize
WRITE setGraphicSourceSize RESET resetGraphicSourceSize
NOTIFY graphicSourceSizeChanged FINAL )
2017-07-21 18:21:34 +02:00
Q_PROPERTY( bool flat READ isFlat WRITE setFlat NOTIFY flatChanged FINAL )
Q_PROPERTY( QskCorner corner READ corner WRITE setCorner NOTIFY cornerChanged )
using Inherited = QskAbstractButton;
2018-08-03 08:15:28 +02:00
public:
2017-07-21 18:21:34 +02:00
QSK_SUBCONTROLS( Panel, Text, Graphic )
QskPushButton( QQuickItem* parent = nullptr );
QskPushButton( const QString& text, QQuickItem* parent = nullptr );
2018-07-31 17:32:25 +02:00
~QskPushButton() override;
2017-07-21 18:21:34 +02:00
void setCorner( const QskCorner& );
QskCorner corner() const;
QString text() const;
void setTextOptions( const QskTextOptions& );
QskTextOptions textOptions() const;
QUrl graphicSource() const;
QSizeF graphicSourceSize() const;
2017-07-21 18:21:34 +02:00
QskGraphic graphic() const;
bool hasGraphic() const;
void resetGraphicSourceSize();
2017-07-21 18:21:34 +02:00
void setFlat( bool );
bool isFlat() const;
QFont font() const;
QRectF layoutRectForSize( const QSizeF& ) const override;
2017-07-21 18:21:34 +02:00
2018-08-03 08:15:28 +02:00
public Q_SLOTS:
2019-01-04 13:42:16 +01:00
void setText( const QString& );
void setGraphicSource( const QUrl& );
void setGraphicSource( const QString& );
void setGraphic( const QskGraphic& );
2019-01-04 13:42:16 +01:00
void setGraphicSourceSize( const QSizeF& );
2018-04-03 10:46:55 +02:00
2018-08-03 08:15:28 +02:00
Q_SIGNALS:
2017-07-21 18:21:34 +02:00
void cornerChanged();
void borderWidthChanged();
void textChanged();
void textOptionsChanged();
void flatChanged();
void graphicChanged();
void graphicSourceChanged();
void graphicSourceSizeChanged();
2017-07-21 18:21:34 +02:00
void hovered( bool );
2018-08-03 08:15:28 +02:00
protected:
2018-07-31 17:32:25 +02:00
void hoverEnterEvent( QHoverEvent* ) override;
void hoverLeaveEvent( QHoverEvent* ) override;
void changeEvent( QEvent* ) override;
2017-07-21 18:21:34 +02:00
2018-07-31 17:32:25 +02:00
void updateLayout() override;
2019-09-05 15:16:33 +02:00
QSizeF contentsSizeHint() const override;
2017-07-21 18:21:34 +02:00
virtual QskGraphic loadGraphic( const QUrl& ) const;
2018-08-03 08:15:28 +02:00
private:
2017-07-21 18:21:34 +02:00
class PrivateData;
std::unique_ptr< PrivateData > m_data;
};
#endif