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