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