qskinny/src/common/QskTextOptions.h

99 lines
2.5 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_TEXT_OPTIONS_H
#define QSK_TEXT_OPTIONS_H
#include "QskGlobal.h"
2018-07-19 14:10:48 +02:00
#include <qmetatype.h>
#include <qtextoption.h>
2017-07-21 18:21:34 +02:00
class QDebug;
class QSK_EXPORT QskTextOptions
{
Q_GADGET
Q_PROPERTY( TextFormat format READ format WRITE setFormat )
Q_PROPERTY( Qt::TextElideMode elideMode READ elideMode WRITE setElideMode )
Q_PROPERTY( WrapMode wrapMode READ wrapMode WRITE setWrapMode )
Q_PROPERTY( FontSizeMode fontSizeMode READ fontSizeMode WRITE setFontSizeMode )
Q_PROPERTY( int maximumLineCount READ maximumLineCount WRITE setMaximumLineCount )
2018-08-03 08:15:28 +02:00
public:
2017-07-21 18:21:34 +02:00
enum FontSizeMode
2018-08-03 08:15:28 +02:00
{
2017-07-21 18:21:34 +02:00
FixedSize,
HorizontalFit,
VerticalFit,
Fit
};
enum WrapMode
{
NoWrap = QTextOption::NoWrap,
WordWrap = QTextOption::WordWrap,
WrapAnywhere = QTextOption::WrapAnywhere,
Wrap = QTextOption::WrapAtWordBoundaryOrAnywhere
};
Q_ENUM( WrapMode )
QskTextOptions();
enum TextFormat
{
PlainText = Qt::PlainText,
RichText = Qt::RichText,
AutoText = Qt::AutoText,
StyledText = 4 // taken from QQuickText::StyledText
};
Q_ENUM( TextFormat )
TextFormat format() const;
void setFormat( TextFormat );
2017-10-20 13:31:55 +02:00
TextFormat effectiveFormat( const QString& text ) const;
2017-07-21 18:21:34 +02:00
Qt::TextElideMode elideMode() const;
void setElideMode( Qt::TextElideMode );
FontSizeMode fontSizeMode() const;
void setFontSizeMode( FontSizeMode );
WrapMode wrapMode() const;
void setWrapMode( WrapMode );
int maximumLineCount() const;
void setMaximumLineCount( int );
bool operator==( const QskTextOptions& other ) const;
bool operator!=( const QskTextOptions& other ) const;
int textFlags() const;
2018-08-03 08:15:28 +02:00
private:
2017-07-21 18:21:34 +02:00
int m_maximumLineCount;
FontSizeMode m_fontSizeMode : 2;
WrapMode m_wrapMode : 4;
TextFormat m_format : 3;
Qt::TextElideMode m_elideMode : 2;
};
inline bool QskTextOptions::operator!=( const QskTextOptions& other ) const
{
return !( *this == other );
}
2018-08-03 08:15:28 +02:00
QSK_EXPORT uint qHash( const QskTextOptions&, uint seed = 0 ) noexcept;
2017-07-21 18:21:34 +02:00
#ifndef QT_NO_DEBUG_STREAM
QSK_EXPORT QDebug operator<<( QDebug, const QskTextOptions& );
#endif
Q_DECLARE_TYPEINFO( QskTextOptions, Q_MOVABLE_TYPE );
Q_DECLARE_METATYPE( QskTextOptions )
#endif