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( bool flat READ isFlat WRITE setFlat NOTIFY flatChanged FINAL )
|
|
|
|
Q_PROPERTY( QskCorner corner READ corner WRITE setCorner NOTIFY cornerChanged )
|
|
|
|
|
|
|
|
using Inherited = QskAbstractButton;
|
|
|
|
|
|
|
|
public:
|
|
|
|
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;
|
|
|
|
QskGraphic graphic() const;
|
|
|
|
bool hasGraphic() const;
|
|
|
|
|
|
|
|
void setFlat( bool );
|
|
|
|
bool isFlat() const;
|
|
|
|
|
|
|
|
QFont font() const;
|
|
|
|
|
2018-07-31 17:32:25 +02:00
|
|
|
QSizeF contentsSizeHint() const override;
|
|
|
|
QRectF layoutRect() const override;
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-11-21 18:10:10 +01:00
|
|
|
public Q_SLOTS:
|
|
|
|
void setText( const QString& text );
|
|
|
|
void setGraphicSource( const QUrl& url );
|
2018-06-07 07:24:34 +02:00
|
|
|
void setGraphicSource( const QString& source );
|
2017-11-21 18:10:10 +01:00
|
|
|
void setGraphic( const QskGraphic& );
|
2018-04-03 10:46:55 +02:00
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
Q_SIGNALS:
|
|
|
|
void cornerChanged();
|
|
|
|
void borderWidthChanged();
|
|
|
|
void textChanged();
|
|
|
|
void textOptionsChanged();
|
|
|
|
void flatChanged();
|
|
|
|
void graphicChanged();
|
|
|
|
void graphicSourceChanged();
|
|
|
|
|
|
|
|
void hovered( bool );
|
|
|
|
|
|
|
|
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;
|
2017-07-21 18:21:34 +02:00
|
|
|
virtual QskGraphic loadGraphic( const QUrl& ) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
class PrivateData;
|
|
|
|
std::unique_ptr< PrivateData > m_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|