QskTextField::placeholderText introduced, QskTextField::description
removed
This commit is contained in:
parent
77739d7734
commit
77e556fad2
@ -14,6 +14,7 @@ QSK_QT_PRIVATE_END
|
||||
|
||||
QSK_SUBCONTROL( QskTextField, Panel )
|
||||
QSK_SUBCONTROL( QskTextField, Text )
|
||||
QSK_SUBCONTROL( QskTextField, PlaceholderText )
|
||||
|
||||
#if 1
|
||||
// shouldn't this be a Selected state, TODO ...
|
||||
@ -289,7 +290,7 @@ class QskTextField::PrivateData
|
||||
{
|
||||
public:
|
||||
TextInput* textInput;
|
||||
QString description; // f.e. used as prompt in QskInputPanel
|
||||
QString placeholderText;
|
||||
|
||||
unsigned int activationModes : 3;
|
||||
bool hasPanel : 1;
|
||||
@ -538,18 +539,18 @@ void QskTextField::setText( const QString& text )
|
||||
m_data->textInput->setText( text );
|
||||
}
|
||||
|
||||
void QskTextField::setDescription( const QString& text )
|
||||
void QskTextField::setPlaceholderText( const QString& text )
|
||||
{
|
||||
if ( m_data->description != text )
|
||||
if ( m_data->placeholderText != text )
|
||||
{
|
||||
m_data->description = text;
|
||||
Q_EMIT descriptionChanged( text );
|
||||
m_data->placeholderText = text;
|
||||
Q_EMIT placeholderTextChanged( text );
|
||||
}
|
||||
}
|
||||
|
||||
QString QskTextField::description() const
|
||||
QString QskTextField::placeholderText() const
|
||||
{
|
||||
return m_data->description;
|
||||
return m_data->placeholderText;
|
||||
}
|
||||
|
||||
QskTextField::ActivationModes QskTextField::activationModes() const
|
||||
@ -618,7 +619,7 @@ Qt::Alignment QskTextField::alignment() const
|
||||
return alignmentHint( Text, Qt::AlignLeft | Qt::AlignTop );
|
||||
}
|
||||
|
||||
void QskTextField::setWrapMode( QskTextOptions::WrapMode wrapMode )
|
||||
void QskTextField::setWrapMode( QskTextOptions::WrapMode wrapMode )
|
||||
{
|
||||
m_data->textInput->setWrapMode(
|
||||
static_cast< QQuickTextInput::WrapMode >( wrapMode ) );
|
||||
|
@ -18,8 +18,8 @@ class QSK_EXPORT QskTextField : public QskControl
|
||||
|
||||
Q_PROPERTY( QString text READ text WRITE setText NOTIFY textChanged USER true)
|
||||
|
||||
Q_PROPERTY( QString description READ description
|
||||
WRITE setDescription NOTIFY descriptionChanged )
|
||||
Q_PROPERTY( QString placeholderText READ placeholderText
|
||||
WRITE setPlaceholderText NOTIFY placeholderTextChanged )
|
||||
|
||||
Q_PROPERTY( QskFontRole fontRole READ fontRole
|
||||
WRITE setFontRole RESET resetFontRole NOTIFY fontRoleChanged )
|
||||
@ -55,7 +55,7 @@ class QSK_EXPORT QskTextField : public QskControl
|
||||
using Inherited = QskControl;
|
||||
|
||||
public:
|
||||
QSK_SUBCONTROLS( Panel, Text, PanelSelected, TextSelected )
|
||||
QSK_SUBCONTROLS( Panel, Text, PlaceholderText, PanelSelected, TextSelected )
|
||||
QSK_STATES( ReadOnly, Editing )
|
||||
|
||||
enum ActivationMode
|
||||
@ -92,8 +92,8 @@ class QSK_EXPORT QskTextField : public QskControl
|
||||
|
||||
QString text() const;
|
||||
|
||||
void setDescription( const QString& );
|
||||
QString description() const;
|
||||
void setPlaceholderText( const QString& );
|
||||
QString placeholderText() const;
|
||||
|
||||
void setPanel( bool );
|
||||
bool hasPanel() const;
|
||||
@ -177,7 +177,7 @@ class QSK_EXPORT QskTextField : public QskControl
|
||||
void displayTextChanged( const QString& );
|
||||
|
||||
void textEdited( const QString& );
|
||||
void descriptionChanged( const QString& );
|
||||
void placeholderTextChanged( const QString& );
|
||||
|
||||
void fontRoleChanged();
|
||||
void alignmentChanged();
|
||||
|
@ -6,10 +6,12 @@
|
||||
#include "QskTextFieldSkinlet.h"
|
||||
#include "QskTextField.h"
|
||||
|
||||
using Q = QskTextField;
|
||||
|
||||
QskTextFieldSkinlet::QskTextFieldSkinlet( QskSkin* skin )
|
||||
: Inherited( skin )
|
||||
{
|
||||
setNodeRoles( { PanelRole } );
|
||||
setNodeRoles( { PanelRole, PlaceholderTextRole, } );
|
||||
}
|
||||
|
||||
QskTextFieldSkinlet::~QskTextFieldSkinlet()
|
||||
@ -19,13 +21,21 @@ QskTextFieldSkinlet::~QskTextFieldSkinlet()
|
||||
QRectF QskTextFieldSkinlet::subControlRect( const QskSkinnable* skinnable,
|
||||
const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const
|
||||
{
|
||||
if ( subControl == QskTextField::Panel )
|
||||
if ( subControl == Q::Panel )
|
||||
{
|
||||
return contentsRect;
|
||||
}
|
||||
else if ( subControl == QskTextField::Text )
|
||||
else if ( subControl == Q::Text )
|
||||
{
|
||||
return skinnable->subControlContentsRect( contentsRect, QskTextField::Panel );
|
||||
return skinnable->subControlContentsRect( contentsRect, Q::Panel );
|
||||
}
|
||||
else if ( subControl == Q::PlaceholderText )
|
||||
{
|
||||
const auto textField = static_cast< const QskTextField* >( skinnable );
|
||||
if( textField->text().isEmpty() )
|
||||
return subControlRect( skinnable, contentsRect, Q::Text );
|
||||
|
||||
return QRectF();
|
||||
}
|
||||
|
||||
return Inherited::subControlRect( skinnable, contentsRect, subControl );
|
||||
@ -34,15 +44,21 @@ QRectF QskTextFieldSkinlet::subControlRect( const QskSkinnable* skinnable,
|
||||
QSGNode* QskTextFieldSkinlet::updateSubNode(
|
||||
const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const
|
||||
{
|
||||
const auto textField = static_cast< const QskTextField* >( skinnable );
|
||||
|
||||
switch ( nodeRole )
|
||||
{
|
||||
case PanelRole:
|
||||
{
|
||||
const auto input = static_cast< const QskTextField* >( skinnable );
|
||||
if ( !input->hasPanel() )
|
||||
if ( !textField->hasPanel() )
|
||||
return nullptr;
|
||||
|
||||
return updateBoxNode( skinnable, node, QskTextField::Panel );
|
||||
return updateBoxNode( skinnable, node, Q::Panel );
|
||||
}
|
||||
case PlaceholderTextRole:
|
||||
{
|
||||
return updateTextNode( skinnable, node,
|
||||
textField->placeholderText(), Q::PlaceholderText );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ class QSK_EXPORT QskTextFieldSkinlet : public QskSkinlet
|
||||
enum NodeRole
|
||||
{
|
||||
PanelRole,
|
||||
PlaceholderTextRole,
|
||||
RoleCount
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user