Outlined/Filled moved to gallery code
This commit is contained in:
parent
2c34318c00
commit
36bea57477
|
@ -483,8 +483,8 @@ void Editor::setupTextField()
|
|||
setFontRole( Q::Text, BodyLarge );
|
||||
setColor( Q::Text | Q::Disabled, m_pal.onSurface38 );
|
||||
|
||||
const auto Outlined = static_cast< A::Variation >( Q::OutlinedStyle );
|
||||
const auto Filled = static_cast< A::Variation >( Q::FilledStyle );
|
||||
const auto Outlined = A::NoVariation;
|
||||
const auto Filled = static_cast< A::Variation >( 1 );
|
||||
|
||||
const auto activeStates = Q::Focused | Q::Editing;
|
||||
|
||||
|
|
|
@ -15,6 +15,11 @@
|
|||
|
||||
using Q = QskTextField;
|
||||
|
||||
static inline bool isOutlined( const QskTextField* textField )
|
||||
{
|
||||
return textField->effectiveVariation() == QskAspect::NoVariation;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
const int spacingV = 0; // skin hint !
|
||||
|
@ -87,7 +92,7 @@ QRectF QskMaterial3TextFieldSkinlet::subControlRect( const QskSkinnable* skinnab
|
|||
const QFontMetrics fm( textField->effectiveFont( Q::Header ) );
|
||||
const auto textSize = fm.size( Qt::TextSingleLine | Qt::TextExpandTabs, text );
|
||||
|
||||
if ( textField->style() == QskTextField::OutlinedStyle )
|
||||
if ( isOutlined( textField ) )
|
||||
{
|
||||
const auto r = subControlRect( skinnable, contentsRect, Q::TextPanel );
|
||||
|
||||
|
@ -109,7 +114,7 @@ QRectF QskMaterial3TextFieldSkinlet::subControlRect( const QskSkinnable* skinnab
|
|||
{
|
||||
auto rect = skinnable->subControlRect( contentsRect, Q::Panel );
|
||||
|
||||
if ( textField->style() == QskTextField::OutlinedStyle )
|
||||
if ( isOutlined( textField ) )
|
||||
{
|
||||
const QFontMetrics fm( textField->effectiveFont( Q::Header ) );
|
||||
rect.setTop( rect.top() + 0.5 * fm.height() );
|
||||
|
@ -160,7 +165,7 @@ QSGNode* QskMaterial3TextFieldSkinlet::updateSubNode(
|
|||
|
||||
auto hints = textField->boxHints( Q::TextPanel );
|
||||
|
||||
if( textField->style() == QskTextField::OutlinedStyle )
|
||||
if ( isOutlined( textField ) )
|
||||
{
|
||||
const auto clipRect = textField->subControlRect( Q::Header );
|
||||
if ( !clipRect.isEmpty() )
|
||||
|
@ -196,7 +201,7 @@ QSizeF QskMaterial3TextFieldSkinlet::sizeHint( const QskSkinnable* skinnable,
|
|||
auto hint = textField->unwrappedTextSize();
|
||||
hint = hint.expandedTo( skinnable->strutSizeHint( Q::TextPanel ) );
|
||||
|
||||
if ( textField->style() == QskTextField::OutlinedStyle )
|
||||
if ( isOutlined( textField ) )
|
||||
{
|
||||
const QFontMetrics fm( textField->effectiveFont( Q::Header ) );
|
||||
hint.rheight() += 0.5 * fm.height();
|
||||
|
|
|
@ -68,6 +68,46 @@ namespace
|
|||
}
|
||||
};
|
||||
|
||||
class TextField : public QskTextField
|
||||
{
|
||||
public:
|
||||
enum Style
|
||||
{
|
||||
OutlinedStyle,
|
||||
FilledStyle
|
||||
};
|
||||
|
||||
TextField( QQuickItem* parent = nullptr )
|
||||
: QskTextField( parent )
|
||||
{
|
||||
}
|
||||
|
||||
void setStyle( Style style )
|
||||
{
|
||||
if ( style != m_style )
|
||||
{
|
||||
m_style = style;
|
||||
|
||||
resetImplicitSize();
|
||||
polish();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
Style style() const
|
||||
{
|
||||
return m_style;
|
||||
}
|
||||
|
||||
QskAspect::Variation effectiveVariation() const override
|
||||
{
|
||||
return static_cast< QskAspect::Variation >( m_style );
|
||||
}
|
||||
|
||||
private:
|
||||
Style m_style = OutlinedStyle;
|
||||
};
|
||||
|
||||
class TextInputBox : public QskLinearBox
|
||||
{
|
||||
public:
|
||||
|
@ -78,7 +118,7 @@ namespace
|
|||
setDefaultAlignment( Qt::AlignHCenter | Qt::AlignTop );
|
||||
|
||||
{
|
||||
auto field = new QskTextField( this );
|
||||
auto field = new TextField( this );
|
||||
field->setHeaderText( "Name" );
|
||||
field->setText( "John Doe" );
|
||||
field->setPlaceholderText( "<Name>" );
|
||||
|
@ -86,19 +126,19 @@ namespace
|
|||
}
|
||||
|
||||
{
|
||||
auto field = new QskTextField( this );
|
||||
auto field = new TextField( this );
|
||||
field->setHeaderText( "Nickname" );
|
||||
field->setPlaceholderText( "<Nickname>" );
|
||||
field->setFooterText( "Optional" );
|
||||
}
|
||||
{
|
||||
auto field = new QskTextField( this );
|
||||
auto field = new TextField( this );
|
||||
field->setIcon( {} );
|
||||
field->setPlaceholderText( "<no header>" );
|
||||
}
|
||||
|
||||
{
|
||||
auto field = new QskTextField( this );
|
||||
auto field = new TextField( this );
|
||||
field->setSkinStateFlag( QskTextField::Error );
|
||||
field->setText( "Error Text" );
|
||||
field->setHeaderText( "error" );
|
||||
|
@ -107,7 +147,7 @@ namespace
|
|||
}
|
||||
|
||||
{
|
||||
auto field = new QskTextField( this );
|
||||
auto field = new TextField( this );
|
||||
field->setReadOnly( true );
|
||||
field->setText( "Read Only" );
|
||||
field->setHeaderText( "read only" );
|
||||
|
@ -115,7 +155,7 @@ namespace
|
|||
}
|
||||
|
||||
{
|
||||
auto field = new QskTextField( this );
|
||||
auto field = new TextField( this );
|
||||
field->setMaxLength( 15 );
|
||||
field->setHeaderText( "password" );
|
||||
field->setEchoMode( QskTextField::Password );
|
||||
|
@ -123,11 +163,14 @@ namespace
|
|||
}
|
||||
}
|
||||
|
||||
void setStyle( int style )
|
||||
void setStyle( int value )
|
||||
{
|
||||
auto textFields = findChildren< QskTextField* >();
|
||||
for ( auto field : textFields )
|
||||
field->setStyle( static_cast< QskTextField::Style >( style ) );
|
||||
{
|
||||
const auto style = static_cast< TextField::Style >( value );
|
||||
dynamic_cast< TextField* >(field)->setStyle( style );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -158,8 +201,8 @@ namespace
|
|||
StyleComboBox( QQuickItem* parent = nullptr )
|
||||
: QskComboBox( parent )
|
||||
{
|
||||
addOption( QString(), "Filled" );
|
||||
addOption( QString(), "Outlined" );
|
||||
addOption( QString(), "Filled" );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -240,7 +283,7 @@ InputPage::InputPage( QQuickItem* parent )
|
|||
connect( styleBox, &QskComboBox::currentIndexChanged,
|
||||
textInputBox, &TextInputBox::setStyle );
|
||||
|
||||
styleBox->setCurrentIndex( QskTextField::OutlinedStyle );
|
||||
styleBox->setCurrentIndex( TextField::OutlinedStyle );
|
||||
}
|
||||
|
||||
void InputPage::syncValues( qreal value )
|
||||
|
|
|
@ -29,7 +29,6 @@ class QskTextField::PrivateData
|
|||
QString footerText;
|
||||
QString placeholderText;
|
||||
|
||||
Style style = FilledStyle;
|
||||
QskAspect::States buttonStates;
|
||||
};
|
||||
|
||||
|
@ -53,25 +52,6 @@ QskTextField::~QskTextField()
|
|||
{
|
||||
}
|
||||
|
||||
void QskTextField::setStyle( Style style )
|
||||
{
|
||||
if ( style != m_data->style )
|
||||
{
|
||||
m_data->style = style;
|
||||
|
||||
resetImplicitSize();
|
||||
polish();
|
||||
update();
|
||||
|
||||
Q_EMIT styleChanged( style );
|
||||
}
|
||||
}
|
||||
|
||||
QskTextField::Style QskTextField::style() const
|
||||
{
|
||||
return m_data->style;
|
||||
}
|
||||
|
||||
QString QskTextField::headerText() const
|
||||
{
|
||||
return m_data->headerText;
|
||||
|
@ -136,11 +116,6 @@ QString QskTextField::placeholderText() const
|
|||
return m_data->placeholderText;
|
||||
}
|
||||
|
||||
QskAspect::Variation QskTextField::effectiveVariation() const
|
||||
{
|
||||
return static_cast< QskAspect::Variation >( m_data->style );
|
||||
}
|
||||
|
||||
void QskTextField::handleButtonClick()
|
||||
{
|
||||
clear();
|
||||
|
|
|
@ -22,9 +22,6 @@ class QSK_EXPORT QskTextField : public QskTextInput
|
|||
Q_PROPERTY( QString placeholderText READ placeholderText
|
||||
WRITE setPlaceholderText NOTIFY placeholderTextChanged )
|
||||
|
||||
Q_PROPERTY( Style style READ style
|
||||
WRITE setStyle NOTIFY styleChanged )
|
||||
|
||||
using Inherited = QskTextInput;
|
||||
|
||||
public:
|
||||
|
@ -33,21 +30,11 @@ class QSK_EXPORT QskTextField : public QskTextInput
|
|||
QSK_SUBCONTROLS( Panel, Header, Footer, Placeholder,
|
||||
Icon, Button, ButtonPanel, CharacterCount )
|
||||
|
||||
enum Style : quint8
|
||||
{
|
||||
FilledStyle,
|
||||
OutlinedStyle
|
||||
};
|
||||
Q_ENUM( Style )
|
||||
|
||||
QskTextField( QQuickItem* parent = nullptr );
|
||||
QskTextField( const QString& text, QQuickItem* parent = nullptr );
|
||||
|
||||
~QskTextField() override;
|
||||
|
||||
void setStyle( Style );
|
||||
Style style() const;
|
||||
|
||||
void setHeaderText( const QString& );
|
||||
QString headerText() const;
|
||||
|
||||
|
@ -60,8 +47,6 @@ class QSK_EXPORT QskTextField : public QskTextInput
|
|||
void setPlaceholderText( const QString& );
|
||||
QString placeholderText() const;
|
||||
|
||||
QskAspect::Variation effectiveVariation() const override;
|
||||
|
||||
#if 1
|
||||
QskAspect::States buttonStates() const;
|
||||
#endif
|
||||
|
@ -70,7 +55,6 @@ class QSK_EXPORT QskTextField : public QskTextInput
|
|||
void headerTextChanged( const QString& );
|
||||
void footerTextChanged( const QString& );
|
||||
void placeholderTextChanged( const QString& );
|
||||
void styleChanged( Style );
|
||||
|
||||
protected:
|
||||
void hoverEnterEvent( QHoverEvent* ) override;
|
||||
|
|
Loading…
Reference in New Issue