using the placeholderText in the gallery
This commit is contained in:
parent
c331fd601a
commit
89cfd7bb4f
@ -70,24 +70,25 @@ namespace
|
||||
setSpacing( 20 );
|
||||
|
||||
{
|
||||
auto textField = new QskTextField( "Joe", this );
|
||||
textField->setPlaceholderText( "<Name>" );
|
||||
}
|
||||
{
|
||||
auto field = new QskTextField( this );
|
||||
field->setText( "John Doe" );
|
||||
field->setPlaceholderText( "<Name>" );
|
||||
}
|
||||
|
||||
{
|
||||
auto textField = new QskTextField( "Only Read Me", this );
|
||||
textField->setReadOnly( true );
|
||||
textField->setSizePolicy( Qt::Horizontal, QskSizePolicy::MinimumExpanding );
|
||||
}
|
||||
{
|
||||
auto field = new QskTextField( this );
|
||||
field->setReadOnly( true );
|
||||
field->setText( "Read Only" );
|
||||
field->setSizePolicy( Qt::Horizontal, QskSizePolicy::MinimumExpanding );
|
||||
}
|
||||
|
||||
{
|
||||
auto textField = new QskTextField( "12345", this );
|
||||
textField->setPlaceholderText( "<Password>" );
|
||||
textField->setMaxLength( 5 );
|
||||
textField->setEchoMode( QskTextField::PasswordEchoOnEdit );
|
||||
#if 1
|
||||
textField->setFixedWidth( 100 );
|
||||
#endif
|
||||
{
|
||||
auto field = new QskTextField( this );
|
||||
field->setMaxLength( 5 );
|
||||
field->setEchoMode( QskTextField::Password );
|
||||
field->setPlaceholderText( "<password>" );
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -10,7 +10,18 @@
|
||||
|
||||
using Q = QskTextField;
|
||||
|
||||
QSK_SYSTEM_STATE( QskTextFieldSkinlet, Selected, QskAspect::FirstUserState >> 1 )
|
||||
QSK_SYSTEM_STATE( QskTextFieldSkinlet, Selected, QskAspect::FirstSystemState << 3 )
|
||||
|
||||
static QString qskEffectivePlaceholderText( const QskTextField* textField )
|
||||
{
|
||||
if ( textField->text().isEmpty() &&
|
||||
!( textField->isReadOnly() || textField->isEditing() ) )
|
||||
{
|
||||
return textField->placeholderText();
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
QskTextFieldSkinlet::QskTextFieldSkinlet( QskSkin* skin )
|
||||
: Inherited( skin )
|
||||
@ -61,24 +72,22 @@ QSGNode* QskTextFieldSkinlet::updateSubNode(
|
||||
}
|
||||
case PlaceholderTextRole:
|
||||
{
|
||||
if ( textField->text().isEmpty()
|
||||
&& !textField->placeholderText().isEmpty() )
|
||||
{
|
||||
const auto subControl = Q::PlaceholderText;
|
||||
const auto text = qskEffectivePlaceholderText( textField );
|
||||
if ( text.isEmpty() )
|
||||
return nullptr;
|
||||
|
||||
QskSkinHintStatus status;
|
||||
const auto subControl = Q::PlaceholderText;
|
||||
|
||||
auto options = skinnable->textOptionsHint( subControl, &status );
|
||||
if ( !status.isValid() )
|
||||
options.setElideMode( Qt::ElideRight );
|
||||
QskSkinHintStatus status;
|
||||
|
||||
return updateTextNode( skinnable, node,
|
||||
textField->subControlRect( subControl ),
|
||||
textField->alignmentHint( subControl, Qt::AlignLeft ),
|
||||
options, textField->placeholderText(), subControl );
|
||||
}
|
||||
auto options = skinnable->textOptionsHint( subControl, &status );
|
||||
if ( !status.isValid() )
|
||||
options.setElideMode( Qt::ElideRight );
|
||||
|
||||
return nullptr;
|
||||
return updateTextNode( skinnable, node,
|
||||
textField->subControlRect( subControl ),
|
||||
textField->alignmentHint( subControl, Qt::AlignLeft ),
|
||||
options, text, subControl );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user