elide mode for QskTextField::PlaceholderText added
This commit is contained in:
parent
0038f6d3b3
commit
0d86454774
@ -676,24 +676,34 @@ QSGNode* QskSkinlet::updateTextNode(
|
|||||||
const QskSkinnable* skinnable, QSGNode* node,
|
const QskSkinnable* skinnable, QSGNode* node,
|
||||||
const QRectF& rect, Qt::Alignment alignment,
|
const QRectF& rect, Qt::Alignment alignment,
|
||||||
const QString& text, QskAspect::Subcontrol subControl )
|
const QString& text, QskAspect::Subcontrol subControl )
|
||||||
|
{
|
||||||
|
const auto textOptions = skinnable->textOptionsHint( subControl );
|
||||||
|
|
||||||
|
return updateTextNode( skinnable, node, rect, alignment,
|
||||||
|
textOptions, text, subControl );
|
||||||
|
}
|
||||||
|
|
||||||
|
QSGNode* QskSkinlet::updateTextNode( const QskSkinnable* skinnable,
|
||||||
|
QSGNode* node, const QRectF& rect,
|
||||||
|
Qt::Alignment alignment, const QskTextOptions& textOptions,
|
||||||
|
const QString& text, QskAspect::Subcontrol subControl )
|
||||||
{
|
{
|
||||||
if ( text.isEmpty() || rect.isEmpty() )
|
if ( text.isEmpty() || rect.isEmpty() )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const auto textColors = qskTextColors( skinnable, subControl );
|
const auto colors = qskTextColors( skinnable, subControl );
|
||||||
const auto textOptions = skinnable->textOptionsHint( subControl );
|
|
||||||
|
|
||||||
auto textStyle = Qsk::Normal;
|
auto style = Qsk::Normal;
|
||||||
if ( textColors.styleColor().alpha() == 0 )
|
if ( colors.styleColor().isValid() )
|
||||||
{
|
{
|
||||||
textStyle = skinnable->flagHint< Qsk::TextStyle >(
|
style = skinnable->flagHint< Qsk::TextStyle >(
|
||||||
subControl | QskAspect::Style, Qsk::Normal );
|
subControl | QskAspect::Style, Qsk::Normal );
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto font = skinnable->effectiveFont( subControl );
|
const auto font = skinnable->effectiveFont( subControl );
|
||||||
|
|
||||||
return qskUpdateTextNode( skinnable, node, rect, alignment,
|
return qskUpdateTextNode( skinnable, node, rect, alignment,
|
||||||
text, font, textOptions, textColors, textStyle );
|
text, font, textOptions, colors, style );
|
||||||
}
|
}
|
||||||
|
|
||||||
QSGNode* QskSkinlet::updateTextNode(
|
QSGNode* QskSkinlet::updateTextNode(
|
||||||
|
@ -110,7 +110,7 @@ class QSK_EXPORT QskSkinlet
|
|||||||
static QSGNode* updateLineNode( const QskSkinnable*, QSGNode*,
|
static QSGNode* updateLineNode( const QskSkinnable*, QSGNode*,
|
||||||
const QLineF&, QskAspect::Subcontrol );
|
const QLineF&, QskAspect::Subcontrol );
|
||||||
|
|
||||||
static QSGNode* updateLinesNode( const QskSkinnable*,
|
static QSGNode* updateLinesNode( const QskSkinnable*,
|
||||||
QSGNode*, const QVector< QLineF >&, QskAspect::Subcontrol );
|
QSGNode*, const QVector< QLineF >&, QskAspect::Subcontrol );
|
||||||
|
|
||||||
static QSGNode* updateTextNode( const QskSkinnable*, QSGNode*,
|
static QSGNode* updateTextNode( const QskSkinnable*, QSGNode*,
|
||||||
@ -120,6 +120,10 @@ class QSK_EXPORT QskSkinlet
|
|||||||
const QRectF&, Qt::Alignment, const QString&, const QFont&,
|
const QRectF&, Qt::Alignment, const QString&, const QFont&,
|
||||||
const QskTextOptions&, const QskTextColors&, Qsk::TextStyle );
|
const QskTextOptions&, const QskTextColors&, Qsk::TextStyle );
|
||||||
|
|
||||||
|
static QSGNode* updateTextNode( const QskSkinnable*, QSGNode*,
|
||||||
|
const QRectF&, Qt::Alignment, const QskTextOptions&,
|
||||||
|
const QString&, QskAspect::Subcontrol );
|
||||||
|
|
||||||
// keeping the aspect ratio
|
// keeping the aspect ratio
|
||||||
static QSGNode* updateGraphicNode( const QskSkinnable*, QSGNode*,
|
static QSGNode* updateGraphicNode( const QskSkinnable*, QSGNode*,
|
||||||
const QskGraphic&, const QskColorFilter&, const QRectF&,
|
const QskGraphic&, const QskColorFilter&, const QRectF&,
|
||||||
|
@ -61,10 +61,21 @@ QSGNode* QskTextFieldSkinlet::updateSubNode(
|
|||||||
}
|
}
|
||||||
case PlaceholderTextRole:
|
case PlaceholderTextRole:
|
||||||
{
|
{
|
||||||
if ( textField->text().isEmpty() )
|
if ( textField->text().isEmpty()
|
||||||
|
&& !textField->placeholderText().isEmpty() )
|
||||||
{
|
{
|
||||||
|
const auto subControl = Q::PlaceholderText;
|
||||||
|
|
||||||
|
QskSkinHintStatus status;
|
||||||
|
|
||||||
|
auto options = skinnable->textOptionsHint( subControl, &status );
|
||||||
|
if ( !status.isValid() )
|
||||||
|
options.setElideMode( Qt::ElideRight );
|
||||||
|
|
||||||
return updateTextNode( skinnable, node,
|
return updateTextNode( skinnable, node,
|
||||||
textField->placeholderText(), Q::PlaceholderText );
|
textField->subControlRect( subControl ),
|
||||||
|
textField->alignmentHint( subControl, Qt::AlignLeft ),
|
||||||
|
options, textField->placeholderText(), subControl );
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -43,6 +43,9 @@ void QskTextNode::setTextData(
|
|||||||
const QFont& font, const QskTextOptions& options, const QskTextColors& colors,
|
const QFont& font, const QskTextOptions& options, const QskTextColors& colors,
|
||||||
Qt::Alignment alignment, Qsk::TextStyle textStyle )
|
Qt::Alignment alignment, Qsk::TextStyle textStyle )
|
||||||
{
|
{
|
||||||
|
if ( !colors.styleColor().isValid() )
|
||||||
|
textStyle = Qsk::Normal;
|
||||||
|
|
||||||
QMatrix4x4 matrix;
|
QMatrix4x4 matrix;
|
||||||
matrix.translate( rect.left(), rect.top() );
|
matrix.translate( rect.left(), rect.top() );
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user