QskTextOptions as skin hints
This commit is contained in:
parent
45be53c08a
commit
896145ac11
@ -177,17 +177,17 @@ QSGNode* LightDisplaySkinlet::updateSubNode(
|
||||
{
|
||||
const QString valueText = QString::number( display->value(), 'f', 0 )
|
||||
+ QStringLiteral( " %" );
|
||||
return updateTextNode( skinnable, node, valueText, {},
|
||||
return updateTextNode( skinnable, node, valueText,
|
||||
LightDisplay::ValueText );
|
||||
}
|
||||
case LeftLabelRole:
|
||||
{
|
||||
return updateTextNode( skinnable, node, QStringLiteral( "0 " ), {},
|
||||
return updateTextNode( skinnable, node, QStringLiteral( "0 " ),
|
||||
LightDisplay::LeftLabel );
|
||||
}
|
||||
case RightLabelRole:
|
||||
{
|
||||
return updateTextNode( skinnable, node, QStringLiteral( " 100" ), {},
|
||||
return updateTextNode( skinnable, node, QStringLiteral( " 100" ),
|
||||
LightDisplay::RightLabel );
|
||||
}
|
||||
case KnobRole:
|
||||
|
@ -97,15 +97,13 @@ QSGNode* MyToggleButtonSkinlet::updateSubNode(
|
||||
case CheckedLabelRole:
|
||||
{
|
||||
return updateTextNode(
|
||||
button, node, button->text( true ),
|
||||
button->textOptions(), Q::CheckedText );
|
||||
button, node, button->text( true ), Q::CheckedText );
|
||||
}
|
||||
|
||||
case UncheckedLabelRole:
|
||||
{
|
||||
return updateTextNode(
|
||||
button, node, button->text( false ),
|
||||
button->textOptions(), Q::UncheckedText );
|
||||
button, node, button->text( false ), Q::UncheckedText );
|
||||
}
|
||||
|
||||
case CheckedGraphicRole:
|
||||
|
@ -216,6 +216,7 @@ void Editor::setupCheckBox()
|
||||
setColor( Q::Indicator | Q::Checked | Q::Disabled, m_pal.onSurface38 );
|
||||
|
||||
setColor( Q::Text, m_pal.onBackground );
|
||||
setTextOptions( Q::Text, Qt::ElideMiddle, QskTextOptions::NoWrap );
|
||||
}
|
||||
|
||||
void Editor::setupBox()
|
||||
@ -422,11 +423,13 @@ void Editor::setupSegmentedBar()
|
||||
// Text
|
||||
|
||||
setFontRole( Q::Text, QskMaterial3Skin::M3LabelLarge );
|
||||
setTextOptions( Q::Text, Qt::ElideMiddle, QskTextOptions::NoWrap );
|
||||
|
||||
setColor( Q::Text, m_pal.onSurface );
|
||||
setColor( Q::Text | Q::Selected, m_pal.onSecondaryContainer );
|
||||
|
||||
setColor( Q::Text | Q::Disabled, m_pal.onSurface38 );
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
@ -519,6 +522,8 @@ void Editor::setupPushButton()
|
||||
setColor( Q::Text, m_pal.onPrimary );
|
||||
setColor( Q::Text | Q::Disabled, m_pal.onSurface38 );
|
||||
|
||||
setTextOptions( Q::Text, Qt::ElideMiddle, QskTextOptions::NoWrap );
|
||||
|
||||
setAnimation( Q::Panel | A::Color, qskDuration );
|
||||
setAnimation( Q::Panel | A::Metric, qskDuration );
|
||||
setAnimation( Q::Ripple | A::Color, qskDuration );
|
||||
@ -875,6 +880,8 @@ void Editor::setupSubWindow()
|
||||
setColor( Q::TitleBarText, m_pal.onSurface );
|
||||
setAlignment( Q::TitleBarText, Qt::AlignCenter );
|
||||
|
||||
setTextOptions( Q::TitleBarText, Qt::ElideRight, QskTextOptions::NoWrap );
|
||||
|
||||
for ( auto subControl : { Q::Panel, Q::TitleBarPanel, Q::TitleBarText } )
|
||||
setAnimation( subControl | A::Color, qskDuration );
|
||||
|
||||
|
@ -323,6 +323,8 @@ void Editor::setupCheckBox()
|
||||
setColor( Q::Indicator, m_pal.darker200 );
|
||||
setColor( Q::Indicator | Q::Checked, m_pal.lighter135 );
|
||||
|
||||
setTextOptions( Q::Text, Qt::ElideMiddle, QskTextOptions::NoWrap );
|
||||
|
||||
setFlagHint( Q::Text | Q::Disabled | A::Style, Qsk::Sunken );
|
||||
setColor( Q::Text, m_pal.themeForeground );
|
||||
setColor( Q::Text | Q::Disabled, m_pal.darker200 );
|
||||
@ -531,6 +533,8 @@ void Editor::setupSegmentedBar()
|
||||
{
|
||||
// Text
|
||||
|
||||
setTextOptions( Q::Text, Qt::ElideMiddle, QskTextOptions::NoWrap );
|
||||
|
||||
setColor( Q::Text, m_pal.themeForeground );
|
||||
setColor( Q::Text | Q::Selected, m_pal.highlightedText );
|
||||
|
||||
@ -599,6 +603,9 @@ void Editor::setupPushButton()
|
||||
setAnimation( Q::Panel | A::Metric, qskDuration );
|
||||
|
||||
// Text
|
||||
|
||||
setTextOptions( Q::Text, Qt::ElideMiddle, QskTextOptions::NoWrap );
|
||||
|
||||
setFlagHint( Q::Text | Q::Disabled | A::Style, Qsk::Sunken );
|
||||
setAlignment( Q::Text, Qt::AlignCenter );
|
||||
|
||||
@ -989,6 +996,9 @@ void Editor::setupSubWindow()
|
||||
setBoxShape( Q::TitleBarPanel, radius, radius, 0, 0, Qt::AbsoluteSize );
|
||||
|
||||
// TitleBarText
|
||||
|
||||
setTextOptions( Q::TitleBarText, Qt::ElideRight, QskTextOptions::NoWrap );
|
||||
|
||||
setFontRole( Q::TitleBarText, QskSkin::SmallFont );
|
||||
setColor( Q::TitleBarText | Q::Focused, m_pal.highlightedText );
|
||||
setColor( Q::TitleBarText, m_pal.themeForeground );
|
||||
|
@ -46,6 +46,8 @@ class QSK_EXPORT QskAspect
|
||||
Alignment,
|
||||
Direction,
|
||||
Style,
|
||||
Option,
|
||||
|
||||
GraphicRole,
|
||||
FontRole,
|
||||
|
||||
|
@ -6,6 +6,13 @@
|
||||
#include "QskTextOptions.h"
|
||||
#include <qtextdocument.h>
|
||||
|
||||
static void qskRegisterTextOptions()
|
||||
{
|
||||
qRegisterMetaType< QskTextOptions >();
|
||||
}
|
||||
|
||||
Q_CONSTRUCTOR_FUNCTION( qskRegisterTextOptions )
|
||||
|
||||
int QskTextOptions::textFlags() const noexcept
|
||||
{
|
||||
int flags = 0;
|
||||
|
@ -146,11 +146,8 @@ QSGNode* QskCheckBoxSkinlet::updateTextNode(
|
||||
const auto rect = checkBox->subControlRect( Q::Text );
|
||||
const auto alignH = checkBox->layoutMirroring() ? Qt::AlignRight : Qt::AlignLeft;
|
||||
|
||||
QskTextOptions textOptions;
|
||||
textOptions.setElideMode( Qt::ElideMiddle );
|
||||
|
||||
return QskSkinlet::updateTextNode( checkBox, node, rect, alignH | Qt::AlignVCenter,
|
||||
checkBox->text(), textOptions, QskCheckBox::Text );
|
||||
checkBox->text(), QskCheckBox::Text );
|
||||
}
|
||||
|
||||
QSizeF QskCheckBoxSkinlet::sizeHint( const QskSkinnable* skinnable,
|
||||
|
@ -29,7 +29,6 @@ class QskListView::PrivateData
|
||||
{
|
||||
}
|
||||
|
||||
QskTextOptions textOptions;
|
||||
bool preferredWidthFromColumns : 1;
|
||||
bool alternatingRowColors : 1;
|
||||
SelectionMode selectionMode : 4;
|
||||
@ -81,18 +80,16 @@ bool QskListView::alternatingRowColors() const
|
||||
|
||||
void QskListView::setTextOptions( const QskTextOptions& textOptions )
|
||||
{
|
||||
if ( textOptions != m_data->textOptions )
|
||||
if ( setTextOptionsHint( Text, textOptions ) )
|
||||
{
|
||||
m_data->textOptions = textOptions;
|
||||
updateScrollableSize();
|
||||
|
||||
Q_EMIT textOptionsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QskTextOptions QskListView::textOptions() const
|
||||
{
|
||||
return m_data->textOptions;
|
||||
return textOptionsHint( Text );
|
||||
}
|
||||
|
||||
void QskListView::setSelectedRow( int row )
|
||||
|
@ -476,7 +476,7 @@ QSGNode* QskListViewSkinlet::updateCellNode( const QskListView* listView,
|
||||
newNode = contentNode;
|
||||
|
||||
newNode = updateTextNode( listView, newNode, rect, alignment,
|
||||
value.toString(), listView->textOptions(), QskListView::Text );
|
||||
value.toString(), QskListView::Text );
|
||||
|
||||
if ( newNode )
|
||||
setNodeRole( newNode, TextRole );
|
||||
|
@ -60,7 +60,6 @@ class QskMenu::PrivateData
|
||||
QVector< Option > options;
|
||||
QVector< int > separators;
|
||||
|
||||
QskTextOptions textOptions;
|
||||
QPointF origin;
|
||||
|
||||
// current/selected are not well defined yet, TODO ...
|
||||
@ -188,16 +187,12 @@ QVariantList QskMenu::optionAt( int index ) const
|
||||
|
||||
void QskMenu::setTextOptions( const QskTextOptions& textOptions )
|
||||
{
|
||||
if( textOptions != m_data->textOptions )
|
||||
{
|
||||
m_data->textOptions = textOptions;
|
||||
update();
|
||||
}
|
||||
setTextOptionsHint( Text, textOptions );
|
||||
}
|
||||
|
||||
QskTextOptions QskMenu::textOptions() const
|
||||
{
|
||||
return m_data->textOptions;
|
||||
return textOptionsHint( Text );
|
||||
}
|
||||
|
||||
void QskMenu::setCurrentIndex( int index )
|
||||
|
@ -525,8 +525,8 @@ QSGNode* QskMenuSkinlet::updateSampleNode( const QskSkinnable* skinnable,
|
||||
const auto alignment = menu->alignmentHint(
|
||||
subControl, Qt::AlignVCenter | Qt::AlignLeft );
|
||||
|
||||
return QskSkinlet::updateTextNode( menu, node, rect, alignment,
|
||||
text, menu->textOptions(), Q::Text );
|
||||
return QskSkinlet::updateTextNode( menu, node, rect,
|
||||
alignment, text, Q::Text );
|
||||
}
|
||||
|
||||
if ( subControl == Q::Separator )
|
||||
|
@ -29,7 +29,6 @@ class QskPushButton::PrivateData
|
||||
, isCheckable( false )
|
||||
, isGraphicSourceDirty( false )
|
||||
{
|
||||
textOptions.setElideMode( Qt::ElideMiddle );
|
||||
}
|
||||
|
||||
void ensureGraphic( const QskPushButton* button )
|
||||
@ -44,7 +43,6 @@ class QskPushButton::PrivateData
|
||||
}
|
||||
|
||||
QString text;
|
||||
QskTextOptions textOptions;
|
||||
|
||||
QUrl graphicSource;
|
||||
QskGraphic graphic;
|
||||
@ -118,22 +116,21 @@ QString QskPushButton::text() const
|
||||
return m_data->text;
|
||||
}
|
||||
|
||||
void QskPushButton::setTextOptions( const QskTextOptions& options )
|
||||
void QskPushButton::setTextOptions( const QskTextOptions& textOptions )
|
||||
{
|
||||
if ( options != m_data->textOptions )
|
||||
{
|
||||
m_data->textOptions = options;
|
||||
|
||||
resetImplicitSize();
|
||||
update();
|
||||
|
||||
if ( setTextOptionsHint( Text, textOptions ) )
|
||||
Q_EMIT textOptionsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QskTextOptions QskPushButton::textOptions() const
|
||||
{
|
||||
return m_data->textOptions;
|
||||
return textOptionsHint( Text );
|
||||
}
|
||||
|
||||
void QskPushButton::resetTextOptions()
|
||||
{
|
||||
if ( resetTextOptionsHint( Text ) )
|
||||
Q_EMIT textOptionsChanged();
|
||||
}
|
||||
|
||||
QFont QskPushButton::font() const
|
||||
|
@ -21,7 +21,7 @@ class QSK_EXPORT QskPushButton : public QskAbstractButton
|
||||
Q_PROPERTY( QFont font READ font )
|
||||
|
||||
Q_PROPERTY( QskTextOptions textOptions READ textOptions
|
||||
WRITE setTextOptions NOTIFY textOptionsChanged )
|
||||
WRITE setTextOptions RESET resetTextOptions NOTIFY textOptionsChanged )
|
||||
|
||||
Q_PROPERTY( QUrl graphicSource READ graphicSource
|
||||
WRITE setGraphicSource NOTIFY graphicSourceChanged FINAL )
|
||||
@ -60,6 +60,7 @@ class QSK_EXPORT QskPushButton : public QskAbstractButton
|
||||
|
||||
void setTextOptions( const QskTextOptions& );
|
||||
QskTextOptions textOptions() const;
|
||||
void resetTextOptions();
|
||||
|
||||
void setGraphicStrutSize( const QSizeF& );
|
||||
QSizeF graphicStrutSize() const;
|
||||
|
@ -243,8 +243,8 @@ QSGNode* QskPushButtonSkinlet::updateTextNode(
|
||||
|
||||
const auto alignment = button->alignmentHint( Q::Text, Qt::AlignCenter );
|
||||
|
||||
return QskSkinlet::updateTextNode( button, node, rect, alignment,
|
||||
button->text(), button->textOptions(), Q::Text );
|
||||
return QskSkinlet::updateTextNode( button, node, rect,
|
||||
alignment, button->text(), Q::Text );
|
||||
}
|
||||
|
||||
QSGNode* QskPushButtonSkinlet::updateRippleNode(
|
||||
|
@ -60,7 +60,6 @@ class QskSegmentedBar::PrivateData
|
||||
PrivateData( Qt::Orientation orientation )
|
||||
: orientation( orientation )
|
||||
{
|
||||
textOptions.setElideMode( Qt::ElideMiddle );
|
||||
}
|
||||
|
||||
void addOption( QskSegmentedBar* bar, const Option& option )
|
||||
@ -78,8 +77,6 @@ class QskSegmentedBar::PrivateData
|
||||
|
||||
QVector< Option > options;
|
||||
|
||||
QskTextOptions textOptions;
|
||||
|
||||
int selectedIndex = -1;
|
||||
int currentIndex = -1;
|
||||
|
||||
@ -132,16 +129,12 @@ Qt::Orientation QskSegmentedBar::orientation() const
|
||||
|
||||
void QskSegmentedBar::setTextOptions( const QskTextOptions& textOptions )
|
||||
{
|
||||
if( textOptions != m_data->textOptions )
|
||||
{
|
||||
m_data->textOptions = textOptions;
|
||||
update();
|
||||
}
|
||||
setTextOptionsHint( Text, textOptions );
|
||||
}
|
||||
|
||||
QskTextOptions QskSegmentedBar::textOptions() const
|
||||
{
|
||||
return m_data->textOptions;
|
||||
return textOptionsHint( Text );
|
||||
}
|
||||
|
||||
int QskSegmentedBar::addText( const QString& text )
|
||||
|
@ -331,7 +331,7 @@ QSGNode* QskSegmentedBarSkinlet::updateSampleNode( const QskSkinnable* skinnable
|
||||
const auto text = value.value< QString >();
|
||||
|
||||
return QskSkinlet::updateTextNode( bar, node,
|
||||
rect, alignment, text, bar->textOptions(), Q::Text );
|
||||
rect, alignment, text, Q::Text );
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
@ -120,6 +120,11 @@ namespace
|
||||
{
|
||||
return aspect | QskAspect::Shadow;
|
||||
}
|
||||
|
||||
inline QskAspect aspectOption( QskAspect aspect )
|
||||
{
|
||||
return aspect | QskAspect::Option;
|
||||
}
|
||||
}
|
||||
|
||||
QskSkinHintTableEditor::QskSkinHintTableEditor( QskSkinHintTable* table )
|
||||
@ -572,3 +577,31 @@ QskArcMetrics QskSkinHintTableEditor::arcMetrics( QskAspect aspect ) const
|
||||
{
|
||||
return metricHint< QskArcMetrics >( aspectShape( aspect ) );
|
||||
}
|
||||
|
||||
void QskSkinHintTableEditor::setTextOptions( QskAspect aspect,
|
||||
Qt::TextElideMode elideMode, QskTextOptions::WrapMode wrapMode,
|
||||
QskStateCombination combination )
|
||||
{
|
||||
QskTextOptions options;
|
||||
options.setElideMode( elideMode );
|
||||
options.setWrapMode( wrapMode );
|
||||
|
||||
setTextOptions( aspect, options, combination );
|
||||
}
|
||||
|
||||
void QskSkinHintTableEditor::setTextOptions( QskAspect aspect,
|
||||
const QskTextOptions& textOptions, QskStateCombination combination )
|
||||
{
|
||||
setFlagHint( aspectOption( aspect ), textOptions, combination );
|
||||
}
|
||||
|
||||
bool QskSkinHintTableEditor::removeTextOptions(
|
||||
QskAspect aspect, QskStateCombination combination )
|
||||
{
|
||||
return removeFlagHint( aspectOption( aspect ), combination );
|
||||
}
|
||||
|
||||
QskTextOptions QskSkinHintTableEditor::textOptions( QskAspect aspect ) const
|
||||
{
|
||||
return flagHint< QskTextOptions >( aspectOption( aspect ) );
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "QskSkinHintTable.h"
|
||||
#include "QskAnimationHint.h"
|
||||
#include "QskStateCombination.h"
|
||||
#include "QskTextOptions.h"
|
||||
|
||||
#include <qcolor.h>
|
||||
#include <qvariant.h>
|
||||
@ -272,6 +273,18 @@ class QSK_EXPORT QskSkinHintTableEditor
|
||||
|
||||
QskArcMetrics arcMetrics( QskAspect ) const;
|
||||
|
||||
// text options flag
|
||||
|
||||
void setTextOptions( QskAspect,
|
||||
Qt::TextElideMode, QskTextOptions::WrapMode,
|
||||
QskStateCombination = QskStateCombination() );
|
||||
|
||||
void setTextOptions( QskAspect,
|
||||
const QskTextOptions&, QskStateCombination = QskStateCombination() );
|
||||
|
||||
bool removeTextOptions( QskAspect, QskStateCombination = QskStateCombination() );
|
||||
QskTextOptions textOptions( QskAspect ) const;
|
||||
|
||||
private:
|
||||
QskSkinHintTable* m_table = nullptr;
|
||||
};
|
||||
|
@ -587,13 +587,13 @@ QSGNode* QskSkinlet::updateTextNode( const QskSkinnable* skinnable,
|
||||
QSGNode* QskSkinlet::updateTextNode(
|
||||
const QskSkinnable* skinnable, QSGNode* node,
|
||||
const QRectF& rect, Qt::Alignment alignment,
|
||||
const QString& text, const QskTextOptions& textOptions,
|
||||
QskAspect::Subcontrol subControl )
|
||||
const QString& text, QskAspect::Subcontrol subControl )
|
||||
{
|
||||
if ( text.isEmpty() || rect.isEmpty() )
|
||||
return nullptr;
|
||||
|
||||
const auto textColors = qskTextColors( skinnable, subControl );
|
||||
const auto textOptions = skinnable->textOptionsHint( subControl );
|
||||
|
||||
auto textStyle = Qsk::Normal;
|
||||
if ( textColors.styleColor.alpha() == 0 )
|
||||
@ -610,14 +610,13 @@ QSGNode* QskSkinlet::updateTextNode(
|
||||
|
||||
QSGNode* QskSkinlet::updateTextNode(
|
||||
const QskSkinnable* skinnable, QSGNode* node,
|
||||
const QString& text, const QskTextOptions& textOptions,
|
||||
QskAspect::Subcontrol subControl ) const
|
||||
const QString& text, QskAspect::Subcontrol subControl ) const
|
||||
{
|
||||
const auto rect = qskSubControlRect( this, skinnable, subControl );
|
||||
const auto alignment = skinnable->alignmentHint( subControl, Qt::AlignLeft );
|
||||
|
||||
return updateTextNode( skinnable, node,
|
||||
rect, alignment, text, textOptions, subControl );
|
||||
rect, alignment, text, subControl );
|
||||
}
|
||||
|
||||
QSGNode* QskSkinlet::updateGraphicNode(
|
||||
|
@ -107,8 +107,7 @@ class QSK_EXPORT QskSkinlet
|
||||
QskAspect::Subcontrol );
|
||||
|
||||
static QSGNode* updateTextNode( const QskSkinnable*, QSGNode*,
|
||||
const QRectF&, Qt::Alignment, const QString&, const QskTextOptions&,
|
||||
QskAspect::Subcontrol );
|
||||
const QRectF&, Qt::Alignment, const QString&, QskAspect::Subcontrol );
|
||||
|
||||
static QSGNode* updateTextNode( const QskSkinnable*, QSGNode*,
|
||||
const QRectF&, Qt::Alignment, const QString&, const QFont&,
|
||||
@ -154,7 +153,7 @@ class QSK_EXPORT QskSkinlet
|
||||
QskAspect::Subcontrol ) const;
|
||||
|
||||
QSGNode* updateTextNode( const QskSkinnable*, QSGNode*,
|
||||
const QString&, const QskTextOptions&, QskAspect::Subcontrol ) const;
|
||||
const QString&, QskAspect::Subcontrol ) const;
|
||||
|
||||
QSGNode* updateGraphicNode( const QskSkinnable*, QSGNode*,
|
||||
const QskGraphic&, QskAspect::Subcontrol,
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "QskShadowMetrics.h"
|
||||
#include "QskBoxHints.h"
|
||||
#include "QskGradient.h"
|
||||
#include "QskTextOptions.h"
|
||||
|
||||
#include <qfont.h>
|
||||
#include <qfontmetrics.h>
|
||||
@ -651,6 +652,25 @@ qreal QskSkinnable::spacingHint(
|
||||
return qskMetric< qreal >( this, aspect | QskAspect::Spacing, status );
|
||||
}
|
||||
|
||||
bool QskSkinnable::setTextOptionsHint(
|
||||
const QskAspect aspect, const QskTextOptions& options )
|
||||
{
|
||||
return setSkinHint( aspect | QskAspect::Flag | QskAspect::Option,
|
||||
QVariant::fromValue( options ) );
|
||||
}
|
||||
|
||||
bool QskSkinnable::resetTextOptionsHint( const QskAspect aspect )
|
||||
{
|
||||
return resetFlagHint( aspect | QskAspect::Option );
|
||||
}
|
||||
|
||||
QskTextOptions QskSkinnable::textOptionsHint(
|
||||
const QskAspect aspect, QskSkinHintStatus* status ) const
|
||||
{
|
||||
return effectiveSkinHint(
|
||||
aspect | QskAspect::Flag | QskAspect::Option, status ).value< QskTextOptions >();
|
||||
}
|
||||
|
||||
bool QskSkinnable::setFontRoleHint( const QskAspect aspect, int role )
|
||||
{
|
||||
return qskSetFlag( this, aspect | QskAspect::FontRole, role );
|
||||
|
@ -29,6 +29,7 @@ class QskBoxShapeMetrics;
|
||||
class QskBoxBorderMetrics;
|
||||
class QskBoxBorderColors;
|
||||
class QskShadowMetrics;
|
||||
class QskTextOptions;
|
||||
class QskBoxHints;
|
||||
class QskGradient;
|
||||
|
||||
@ -233,6 +234,10 @@ class QSK_EXPORT QskSkinnable
|
||||
bool resetAlignmentHint( QskAspect );
|
||||
Qt::Alignment alignmentHint( QskAspect, Qt::Alignment = Qt::Alignment() ) const;
|
||||
|
||||
bool setTextOptionsHint( QskAspect, const QskTextOptions& );
|
||||
bool resetTextOptionsHint( QskAspect );
|
||||
QskTextOptions textOptionsHint( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
||||
|
||||
bool setFontRoleHint( QskAspect, int role );
|
||||
bool resetFontRoleHint( QskAspect );
|
||||
int fontRoleHint( QskAspect, QskSkinHintStatus* = nullptr ) const;
|
||||
|
@ -32,11 +32,9 @@ class QskSubWindow::PrivateData
|
||||
PrivateData()
|
||||
: isWindowIconSourceDirty( false )
|
||||
{
|
||||
windowTitleTextOptions.setElideMode( Qt::ElideRight );
|
||||
}
|
||||
|
||||
QString windowTitle;
|
||||
QskTextOptions windowTitleTextOptions;
|
||||
|
||||
QUrl windowIconSource;
|
||||
QskGraphic windowIcon;
|
||||
@ -110,18 +108,13 @@ QString QskSubWindow::windowTitle() const
|
||||
|
||||
void QskSubWindow::setWindowTitleTextOptions( const QskTextOptions& options )
|
||||
{
|
||||
if ( options != m_data->windowTitleTextOptions )
|
||||
{
|
||||
m_data->windowTitleTextOptions = options;
|
||||
|
||||
update();
|
||||
if ( setTextOptionsHint( TitleBarText, options ) )
|
||||
Q_EMIT windowTitleTextOptionsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QskTextOptions QskSubWindow::windowTitleTextOptions() const
|
||||
{
|
||||
return m_data->windowTitleTextOptions;
|
||||
return textOptionsHint( TitleBarText );
|
||||
}
|
||||
|
||||
void QskSubWindow::setWindowIconSource( const QString& url )
|
||||
|
@ -88,8 +88,8 @@ QSGNode* QskSubWindowSkinlet::updateSubNode(
|
||||
|
||||
if ( ( decorations & Q::TitleBar ) && ( decorations & Q::Title ) )
|
||||
{
|
||||
return updateTextNode( subWindow, node, subWindow->windowTitle(),
|
||||
subWindow->windowTitleTextOptions(), Q::TitleBarText );
|
||||
return updateTextNode( subWindow, node,
|
||||
subWindow->windowTitle(), Q::TitleBarText );
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
@ -29,7 +29,6 @@ class QskTabButton::PrivateData
|
||||
}
|
||||
|
||||
QString text;
|
||||
QskTextOptions textOptions;
|
||||
QPointer< QskTabBar > tabBar;
|
||||
};
|
||||
|
||||
@ -77,18 +76,21 @@ QString QskTabButton::text() const
|
||||
return m_data->text;
|
||||
}
|
||||
|
||||
void QskTabButton::setTextOptions( const QskTextOptions& options )
|
||||
void QskTabButton::setTextOptions( const QskTextOptions& textOptions )
|
||||
{
|
||||
if ( options != m_data->textOptions )
|
||||
{
|
||||
m_data->textOptions = options;
|
||||
if ( setTextOptionsHint( Text, textOptions ) )
|
||||
Q_EMIT textOptionsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QskTextOptions QskTabButton::textOptions() const
|
||||
{
|
||||
return m_data->textOptions;
|
||||
return textOptionsHint( Text );
|
||||
}
|
||||
|
||||
void QskTabButton::resetTextOptions()
|
||||
{
|
||||
if ( resetTextOptionsHint( Text ) )
|
||||
Q_EMIT textOptionsChanged();
|
||||
}
|
||||
|
||||
QRectF QskTabButton::layoutRectForSize( const QSizeF& size ) const
|
||||
|
@ -18,7 +18,7 @@ class QSK_EXPORT QskTabButton : public QskAbstractButton
|
||||
Q_PROPERTY( QString text READ text WRITE setText NOTIFY textChanged FINAL )
|
||||
|
||||
Q_PROPERTY( QskTextOptions textOptions READ textOptions
|
||||
WRITE setTextOptions NOTIFY textOptionsChanged )
|
||||
WRITE setTextOptions RESET resetTextOptions NOTIFY textOptionsChanged )
|
||||
|
||||
using Inherited = QskAbstractButton;
|
||||
|
||||
@ -37,6 +37,7 @@ class QSK_EXPORT QskTabButton : public QskAbstractButton
|
||||
|
||||
void setTextOptions( const QskTextOptions& );
|
||||
QskTextOptions textOptions() const;
|
||||
void resetTextOptions();
|
||||
|
||||
QRectF layoutRectForSize( const QSizeF& ) const override;
|
||||
|
||||
|
@ -46,8 +46,8 @@ QSGNode* QskTabButtonSkinlet::updateSubNode(
|
||||
|
||||
case TextRole:
|
||||
{
|
||||
return updateTextNode( tabButton, node, tabButton->text(),
|
||||
tabButton->textOptions(), QskTabButton::Text );
|
||||
return updateTextNode( tabButton, node,
|
||||
tabButton->text(), QskTabButton::Text );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,27 +13,15 @@ QSK_SUBCONTROL( QskTextLabel, Text )
|
||||
class QskTextLabel::PrivateData
|
||||
{
|
||||
public:
|
||||
PrivateData( const QString& txt )
|
||||
PrivateData( const QString& txt, QskTextOptions::TextFormat textFormat )
|
||||
: text( txt )
|
||||
, effectiveTextFormat( textFormat )
|
||||
, hasPanel( false )
|
||||
{
|
||||
effectiveTextFormat = textOptions.format();
|
||||
}
|
||||
|
||||
inline QskTextOptions::TextFormat effectiveFormat() const
|
||||
{
|
||||
if ( textOptions.format() != QskTextOptions::AutoText )
|
||||
return textOptions.format();
|
||||
|
||||
if ( effectiveTextFormat == QskTextOptions::AutoText )
|
||||
effectiveTextFormat = textOptions.effectiveFormat( text );
|
||||
|
||||
return effectiveTextFormat;
|
||||
}
|
||||
|
||||
QString text;
|
||||
|
||||
QskTextOptions textOptions;
|
||||
mutable QskTextOptions::TextFormat effectiveTextFormat;
|
||||
|
||||
bool hasPanel : 1;
|
||||
@ -46,7 +34,7 @@ QskTextLabel::QskTextLabel( QQuickItem* parent )
|
||||
|
||||
QskTextLabel::QskTextLabel( const QString& text, QQuickItem* parent )
|
||||
: Inherited( parent )
|
||||
, m_data( new PrivateData( text ) )
|
||||
, m_data( new PrivateData( text, textOptions().format() ) )
|
||||
{
|
||||
initSizePolicy( QskSizePolicy::Minimum, QskSizePolicy::Fixed );
|
||||
}
|
||||
@ -79,7 +67,7 @@ void QskTextLabel::setText( const QString& text )
|
||||
return;
|
||||
|
||||
m_data->text = text;
|
||||
m_data->effectiveTextFormat = m_data->textOptions.format();
|
||||
m_data->effectiveTextFormat = textOptions().format();
|
||||
|
||||
resetImplicitSize();
|
||||
update();
|
||||
@ -92,11 +80,10 @@ QString QskTextLabel::text() const
|
||||
return m_data->text;
|
||||
}
|
||||
|
||||
void QskTextLabel::setTextOptions( const QskTextOptions& options )
|
||||
void QskTextLabel::setTextOptions( const QskTextOptions& textOptions )
|
||||
{
|
||||
if ( setTextOptionsHint( Text, textOptions ) )
|
||||
{
|
||||
if ( options == m_data->textOptions )
|
||||
return;
|
||||
|
||||
#if 0
|
||||
// we are killing user settings of the policy this way ??
|
||||
|
||||
@ -106,23 +93,25 @@ void QskTextLabel::setTextOptions( const QskTextOptions& options )
|
||||
setSizePolicy( policy, sizePolicy().verticalPolicy() );
|
||||
#endif
|
||||
|
||||
m_data->effectiveTextFormat = options.format();
|
||||
m_data->textOptions = options;
|
||||
|
||||
resetImplicitSize();
|
||||
update();
|
||||
|
||||
Q_EMIT textOptionsChanged( options );
|
||||
m_data->effectiveTextFormat = textOptions.format();
|
||||
Q_EMIT textOptionsChanged( textOptions );
|
||||
}
|
||||
}
|
||||
|
||||
QskTextOptions QskTextLabel::textOptions() const
|
||||
{
|
||||
return m_data->textOptions;
|
||||
return textOptionsHint( Text );
|
||||
}
|
||||
|
||||
void QskTextLabel::resetTextOptions()
|
||||
{
|
||||
if ( resetTextOptionsHint( Text ) )
|
||||
Q_EMIT textOptionsChanged( textOptions() );
|
||||
}
|
||||
|
||||
void QskTextLabel::setTextFormat( QskTextOptions::TextFormat format )
|
||||
{
|
||||
auto options = m_data->textOptions;
|
||||
auto options = textOptions();
|
||||
options.setFormat( format );
|
||||
|
||||
setTextOptions( options );
|
||||
@ -130,31 +119,38 @@ void QskTextLabel::setTextFormat( QskTextOptions::TextFormat format )
|
||||
|
||||
QskTextOptions::TextFormat QskTextLabel::textFormat() const
|
||||
{
|
||||
return m_data->textOptions.format();
|
||||
return textOptions().format();
|
||||
}
|
||||
|
||||
QskTextOptions::TextFormat QskTextLabel::effectiveTextFormat() const
|
||||
{
|
||||
return m_data->effectiveFormat();
|
||||
const auto options = textOptions();
|
||||
|
||||
if ( options.format() != QskTextOptions::AutoText )
|
||||
return options.format();
|
||||
|
||||
if ( m_data->effectiveTextFormat == QskTextOptions::AutoText )
|
||||
m_data->effectiveTextFormat = options.effectiveFormat( m_data->text );
|
||||
|
||||
return m_data->effectiveTextFormat;
|
||||
}
|
||||
|
||||
void QskTextLabel::setWrapMode( QskTextOptions::WrapMode wrapMode )
|
||||
{
|
||||
auto options = m_data->textOptions;
|
||||
auto options = textOptions();
|
||||
options.setWrapMode( wrapMode );
|
||||
|
||||
setTextOptions( options );
|
||||
|
||||
}
|
||||
|
||||
QskTextOptions::WrapMode QskTextLabel::wrapMode() const
|
||||
{
|
||||
return m_data->textOptions.wrapMode();
|
||||
return textOptions().wrapMode();
|
||||
}
|
||||
|
||||
void QskTextLabel::setElideMode( Qt::TextElideMode elideMode )
|
||||
{
|
||||
auto options = m_data->textOptions;
|
||||
auto options = textOptions();
|
||||
options.setElideMode( elideMode );
|
||||
|
||||
setTextOptions( options );
|
||||
@ -162,7 +158,7 @@ void QskTextLabel::setElideMode( Qt::TextElideMode elideMode )
|
||||
|
||||
Qt::TextElideMode QskTextLabel::elideMode() const
|
||||
{
|
||||
return m_data->textOptions.elideMode();
|
||||
return textOptions().elideMode();
|
||||
}
|
||||
|
||||
void QskTextLabel::setFontRole( int role )
|
||||
|
@ -24,7 +24,7 @@ class QSK_EXPORT QskTextLabel : public QskControl
|
||||
WRITE setTextColor RESET resetTextColor NOTIFY textColorChanged )
|
||||
|
||||
Q_PROPERTY( QskTextOptions textOptions READ textOptions
|
||||
WRITE setTextOptions NOTIFY textOptionsChanged )
|
||||
WRITE setTextOptions RESET resetTextOptions NOTIFY textOptionsChanged )
|
||||
|
||||
Q_PROPERTY( Qt::Alignment alignment READ alignment
|
||||
WRITE setAlignment NOTIFY alignmentChanged )
|
||||
@ -54,6 +54,7 @@ class QSK_EXPORT QskTextLabel : public QskControl
|
||||
|
||||
void setTextOptions( const QskTextOptions& );
|
||||
QskTextOptions textOptions() const;
|
||||
void resetTextOptions();
|
||||
|
||||
void setTextFormat( QskTextOptions::TextFormat );
|
||||
QskTextOptions::TextFormat textFormat() const;
|
||||
|
@ -60,7 +60,7 @@ QSGNode* QskTextLabelSkinlet::updateSubNode(
|
||||
case TextRole:
|
||||
{
|
||||
return updateTextNode( label, node,
|
||||
label->text(), label->textOptions(), QskTextLabel::Text );
|
||||
label->text(), QskTextLabel::Text );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user