using the placeholderText in the gallery
This commit is contained in:
parent
c331fd601a
commit
89cfd7bb4f
@ -70,24 +70,25 @@ namespace
|
|||||||
setSpacing( 20 );
|
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 );
|
auto field = new QskTextField( this );
|
||||||
textField->setReadOnly( true );
|
field->setReadOnly( true );
|
||||||
textField->setSizePolicy( Qt::Horizontal, QskSizePolicy::MinimumExpanding );
|
field->setText( "Read Only" );
|
||||||
}
|
field->setSizePolicy( Qt::Horizontal, QskSizePolicy::MinimumExpanding );
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto textField = new QskTextField( "12345", this );
|
auto field = new QskTextField( this );
|
||||||
textField->setPlaceholderText( "<Password>" );
|
field->setMaxLength( 5 );
|
||||||
textField->setMaxLength( 5 );
|
field->setEchoMode( QskTextField::Password );
|
||||||
textField->setEchoMode( QskTextField::PasswordEchoOnEdit );
|
field->setPlaceholderText( "<password>" );
|
||||||
#if 1
|
}
|
||||||
textField->setFixedWidth( 100 );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -10,7 +10,18 @@
|
|||||||
|
|
||||||
using Q = QskTextField;
|
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 )
|
QskTextFieldSkinlet::QskTextFieldSkinlet( QskSkin* skin )
|
||||||
: Inherited( skin )
|
: Inherited( skin )
|
||||||
@ -61,24 +72,22 @@ QSGNode* QskTextFieldSkinlet::updateSubNode(
|
|||||||
}
|
}
|
||||||
case PlaceholderTextRole:
|
case PlaceholderTextRole:
|
||||||
{
|
{
|
||||||
if ( textField->text().isEmpty()
|
const auto text = qskEffectivePlaceholderText( textField );
|
||||||
&& !textField->placeholderText().isEmpty() )
|
if ( text.isEmpty() )
|
||||||
{
|
return nullptr;
|
||||||
const auto subControl = Q::PlaceholderText;
|
|
||||||
|
|
||||||
QskSkinHintStatus status;
|
const auto subControl = Q::PlaceholderText;
|
||||||
|
|
||||||
auto options = skinnable->textOptionsHint( subControl, &status );
|
QskSkinHintStatus status;
|
||||||
if ( !status.isValid() )
|
|
||||||
options.setElideMode( Qt::ElideRight );
|
|
||||||
|
|
||||||
return updateTextNode( skinnable, node,
|
auto options = skinnable->textOptionsHint( subControl, &status );
|
||||||
textField->subControlRect( subControl ),
|
if ( !status.isValid() )
|
||||||
textField->alignmentHint( subControl, Qt::AlignLeft ),
|
options.setElideMode( Qt::ElideRight );
|
||||||
options, textField->placeholderText(), subControl );
|
|
||||||
}
|
|
||||||
|
|
||||||
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