QskTextOptions improved
This commit is contained in:
parent
f21bed63c7
commit
609bd9aac7
|
@ -109,15 +109,15 @@ bool QskTextOptions::operator==( const QskTextOptions& other ) const
|
||||||
&& ( m_maximumLineCount == other.m_maximumLineCount );
|
&& ( m_maximumLineCount == other.m_maximumLineCount );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QskTextOptions::isPlainText( const QString& text ) const
|
QskTextOptions::TextFormat QskTextOptions::effectiveFormat( const QString& text ) const
|
||||||
{
|
{
|
||||||
if ( text.isEmpty() )
|
if ( text.isEmpty() )
|
||||||
return true;
|
return PlainText;
|
||||||
|
|
||||||
if ( m_format == QskTextOptions::AutoText )
|
if ( m_format == QskTextOptions::AutoText )
|
||||||
return !Qt::mightBeRichText( text );
|
return Qt::mightBeRichText( text ) ? RichText : PlainText;
|
||||||
|
else
|
||||||
return m_format == QskTextOptions::PlainText;
|
return m_format;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint qHash( const QskTextOptions &options, uint seed ) noexcept
|
uint qHash( const QskTextOptions &options, uint seed ) noexcept
|
||||||
|
|
|
@ -55,6 +55,8 @@ public:
|
||||||
TextFormat format() const;
|
TextFormat format() const;
|
||||||
void setFormat( TextFormat );
|
void setFormat( TextFormat );
|
||||||
|
|
||||||
|
TextFormat effectiveFormat( const QString& text ) const;
|
||||||
|
|
||||||
Qt::TextElideMode elideMode() const;
|
Qt::TextElideMode elideMode() const;
|
||||||
void setElideMode( Qt::TextElideMode );
|
void setElideMode( Qt::TextElideMode );
|
||||||
|
|
||||||
|
@ -70,8 +72,6 @@ public:
|
||||||
bool operator==( const QskTextOptions& other ) const;
|
bool operator==( const QskTextOptions& other ) const;
|
||||||
bool operator!=( const QskTextOptions& other ) const;
|
bool operator!=( const QskTextOptions& other ) const;
|
||||||
|
|
||||||
bool isPlainText( const QString& text ) const;
|
|
||||||
|
|
||||||
int textFlags() const;
|
int textFlags() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -74,7 +74,7 @@ bool QskListView::alternatingRowColors() const
|
||||||
return m_data->alternatingRowColors;
|
return m_data->alternatingRowColors;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskListView::setTextOptions(const QskTextOptions& textOptions )
|
void QskListView::setTextOptions( const QskTextOptions& textOptions )
|
||||||
{
|
{
|
||||||
if ( textOptions != m_data->textOptions )
|
if ( textOptions != m_data->textOptions )
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,7 +21,7 @@ QSizeF QskSkinRenderer::textSize( const QskSkinnable* skinnable,
|
||||||
|
|
||||||
auto font = skinnable->effectiveFont( subControl );
|
auto font = skinnable->effectiveFont( subControl );
|
||||||
|
|
||||||
if ( options.isPlainText( text ) )
|
if ( options.effectiveFormat( text ) == QskTextOptions::PlainText )
|
||||||
{
|
{
|
||||||
QskPlainTextRenderer renderer;
|
QskPlainTextRenderer renderer;
|
||||||
renderer.setFont( font );
|
renderer.setFont( font );
|
||||||
|
@ -45,7 +45,7 @@ QSizeF QskSkinRenderer::textSize( const QskSkinnable* skinnable,
|
||||||
{
|
{
|
||||||
const auto font = skinnable->effectiveFont( subControl );
|
const auto font = skinnable->effectiveFont( subControl );
|
||||||
|
|
||||||
if ( options.isPlainText( text ) )
|
if ( options.effectiveFormat( text ) == QskTextOptions::PlainText )
|
||||||
{
|
{
|
||||||
QskPlainTextRenderer renderer;
|
QskPlainTextRenderer renderer;
|
||||||
renderer.setFont( font );
|
renderer.setFont( font );
|
||||||
|
@ -90,7 +90,7 @@ void QskSkinRenderer::updateText( const QskSkinnable* skinnable,
|
||||||
subControl | Style, Qsk::Normal );
|
subControl | Style, Qsk::Normal );
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto isPlainText = options.isPlainText( text );
|
const auto isPlainText = options.effectiveFormat( text ) == QskTextOptions::PlainText;
|
||||||
|
|
||||||
// doesn't work - we end up with a black rectangle TODO ...
|
// doesn't work - we end up with a black rectangle TODO ...
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
@ -28,10 +28,7 @@ public:
|
||||||
return textOptions;
|
return textOptions;
|
||||||
|
|
||||||
if ( effectiveTextFormat == QskTextOptions::AutoText )
|
if ( effectiveTextFormat == QskTextOptions::AutoText )
|
||||||
{
|
effectiveTextFormat = textOptions.effectiveFormat( text );
|
||||||
effectiveTextFormat = textOptions.isPlainText( text )
|
|
||||||
? QskTextOptions::PlainText : QskTextOptions::RichText;
|
|
||||||
}
|
|
||||||
|
|
||||||
QskTextOptions options = textOptions;
|
QskTextOptions options = textOptions;
|
||||||
options.setFormat( effectiveTextFormat );
|
options.setFormat( effectiveTextFormat );
|
||||||
|
|
Loading…
Reference in New Issue