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_TEXT_LABEL_H
|
|
|
|
#define QSK_TEXT_LABEL_H
|
|
|
|
|
|
|
|
#include "QskControl.h"
|
2018-10-19 12:53:45 +02:00
|
|
|
#include "QskTextOptions.h"
|
2017-07-21 18:21:34 +02:00
|
|
|
|
|
|
|
class QSK_EXPORT QskTextLabel : public QskControl
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
Q_PROPERTY( QString text READ text WRITE setText NOTIFY textChanged )
|
|
|
|
|
2017-08-22 20:15:11 +02:00
|
|
|
Q_PROPERTY( int fontRole READ fontRole
|
|
|
|
WRITE setFontRole NOTIFY fontRoleChanged )
|
|
|
|
|
|
|
|
Q_PROPERTY( QColor textColor READ textColor
|
|
|
|
WRITE setTextColor NOTIFY textColorChanged )
|
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
Q_PROPERTY( QskTextOptions textOptions READ textOptions
|
|
|
|
WRITE setTextOptions NOTIFY textOptionsChanged )
|
|
|
|
|
|
|
|
Q_PROPERTY( Qt::Alignment alignment READ alignment
|
|
|
|
WRITE setAlignment NOTIFY alignmentChanged )
|
|
|
|
|
|
|
|
using Inherited = QskControl;
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
public:
|
2017-07-21 18:21:34 +02:00
|
|
|
QSK_SUBCONTROLS( Text )
|
|
|
|
|
|
|
|
QskTextLabel( QQuickItem* parent = nullptr );
|
|
|
|
QskTextLabel( const QString& text, QQuickItem* parent = nullptr );
|
|
|
|
|
2018-07-31 17:32:25 +02:00
|
|
|
~QskTextLabel() override;
|
2017-07-21 18:21:34 +02:00
|
|
|
|
|
|
|
QString text() const;
|
|
|
|
|
2017-08-22 20:15:11 +02:00
|
|
|
void setFontRole( int role );
|
|
|
|
int fontRole() const;
|
|
|
|
|
|
|
|
void setTextColor( const QColor& );
|
|
|
|
QColor textColor() const;
|
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
void setTextOptions( const QskTextOptions& );
|
|
|
|
QskTextOptions textOptions() const;
|
|
|
|
|
2018-10-19 12:53:45 +02:00
|
|
|
void setTextFormat( QskTextOptions::TextFormat );
|
|
|
|
QskTextOptions::TextFormat textFormat() const;
|
|
|
|
|
|
|
|
void setWrapMode( QskTextOptions::WrapMode );
|
|
|
|
QskTextOptions::WrapMode wrapMode() const;
|
|
|
|
|
|
|
|
void setElideMode( Qt::TextElideMode );
|
|
|
|
Qt::TextElideMode elideMode() const;
|
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
void setAlignment( Qt::Alignment );
|
|
|
|
Qt::Alignment alignment() const;
|
|
|
|
|
|
|
|
QFont font() const;
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
Q_SIGNALS:
|
2017-07-21 18:21:34 +02:00
|
|
|
void textChanged( const QString& );
|
2018-11-06 18:47:30 +01:00
|
|
|
void textColorChanged( const QColor& );
|
|
|
|
void textOptionsChanged( const QskTextOptions& );
|
2017-08-22 20:15:11 +02:00
|
|
|
void fontRoleChanged();
|
2017-07-21 18:21:34 +02:00
|
|
|
void alignmentChanged();
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
public Q_SLOTS:
|
2017-07-21 18:21:34 +02:00
|
|
|
void setText( const QString& );
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
protected:
|
2018-07-31 17:32:25 +02:00
|
|
|
void changeEvent( QEvent* ) override;
|
2019-09-10 17:01:47 +02:00
|
|
|
QSizeF contentsSizeHint( Qt::SizeHint, const QSizeF& ) const override;
|
2017-07-21 18:21:34 +02:00
|
|
|
|
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
|