minor code rearrangements
This commit is contained in:
parent
36bea57477
commit
23a7859de6
|
@ -203,11 +203,15 @@ QSizeF QskMaterial3TextFieldSkinlet::sizeHint( const QskSkinnable* skinnable,
|
|||
|
||||
if ( isOutlined( textField ) )
|
||||
{
|
||||
const QFontMetrics fm( textField->effectiveFont( Q::Header ) );
|
||||
hint.rheight() += 0.5 * fm.height();
|
||||
hint.rheight() += 0.5 * textField->effectiveFontHeight( Q::Header );
|
||||
}
|
||||
|
||||
if ( hasCharacterCount( textField )
|
||||
|| !effectiveText( textField, Q::Footer ).isEmpty() )
|
||||
{
|
||||
hint.rheight() += textHeight( textField, Q::Footer );
|
||||
}
|
||||
|
||||
hint.rheight() += effectiveFooterHeight( textField );
|
||||
hint = hint.expandedTo( skinnable->strutSizeHint( Q::Panel ) );
|
||||
|
||||
return hint;
|
||||
|
@ -241,18 +245,4 @@ QString QskMaterial3TextFieldSkinlet::effectiveText(
|
|||
return Inherited::effectiveText( textField, subControl );
|
||||
}
|
||||
|
||||
qreal QskMaterial3TextFieldSkinlet::effectiveFooterHeight(
|
||||
const QskTextField* textField ) const
|
||||
{
|
||||
if ( hasCharacterCount( textField ) )
|
||||
{
|
||||
const auto h = textField->effectiveFontHeight( Q::Footer );
|
||||
const auto margins = textField->marginHint( Q::Footer );
|
||||
|
||||
return h + margins.top() + margins.bottom();
|
||||
}
|
||||
|
||||
return Inherited::effectiveFooterHeight( textField );
|
||||
}
|
||||
|
||||
#include "moc_QskMaterial3TextFieldSkinlet.cpp"
|
||||
|
|
|
@ -36,8 +36,6 @@ class QSK_MATERIAL3_EXPORT QskMaterial3TextFieldSkinlet : public QskTextFieldSki
|
|||
|
||||
QString effectiveText( const QskTextField*,
|
||||
QskAspect::Subcontrol ) const override;
|
||||
|
||||
qreal effectiveFooterHeight( const QskTextField* ) const override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -9,19 +9,6 @@
|
|||
|
||||
using Q = QskTextField;
|
||||
|
||||
static qreal qskEffectiveTextHeight( const QskTextField* textField,
|
||||
QskAspect::Subcontrol subControl )
|
||||
{
|
||||
auto h = textField->effectiveFontHeight( subControl );
|
||||
|
||||
const auto margins = textField->marginHint( subControl );
|
||||
h += margins.top() + margins.bottom();
|
||||
|
||||
const auto sz = textField->strutSizeHint( subControl );
|
||||
|
||||
return qMax( h, sz.height() );
|
||||
}
|
||||
|
||||
QskTextFieldSkinlet::QskTextFieldSkinlet( QskSkin* skin )
|
||||
: Inherited( skin )
|
||||
{
|
||||
|
@ -221,8 +208,8 @@ QRectF QskTextFieldSkinlet::inputPanelRect(
|
|||
Q::Header/Q::Footer being available.
|
||||
*/
|
||||
|
||||
auto top = qskEffectiveTextHeight( textField, Q::Header );
|
||||
auto bottom = qskEffectiveTextHeight( textField, Q::Footer );
|
||||
auto top = textHeight( textField, Q::Header );
|
||||
auto bottom = textHeight( textField, Q::Footer );
|
||||
|
||||
if ( rect.height() < top + h + bottom )
|
||||
{
|
||||
|
@ -270,6 +257,19 @@ QSizeF QskTextFieldSkinlet::sizeHint( const QskSkinnable* skinnable,
|
|||
return hint;
|
||||
}
|
||||
|
||||
qreal QskTextFieldSkinlet::textHeight( const QskTextField* textField,
|
||||
QskAspect::Subcontrol subControl ) const
|
||||
{
|
||||
auto h = textField->effectiveFontHeight( subControl );
|
||||
|
||||
const auto margins = textField->marginHint( subControl );
|
||||
h += margins.top() + margins.bottom();
|
||||
|
||||
const auto sz = textField->strutSizeHint( subControl );
|
||||
|
||||
return qMax( h, sz.height() );
|
||||
}
|
||||
|
||||
QString QskTextFieldSkinlet::effectiveText(
|
||||
const QskTextField* textField, QskAspect::Subcontrol subcontrol ) const
|
||||
{
|
||||
|
@ -299,13 +299,13 @@ QString QskTextFieldSkinlet::effectiveText(
|
|||
qreal QskTextFieldSkinlet::effectiveHeaderHeight( const QskTextField* textField ) const
|
||||
{
|
||||
const auto text = effectiveText( textField, Q::Header );
|
||||
return text.isEmpty() ? 0.0 : qskEffectiveTextHeight( textField, Q::Header );
|
||||
return text.isEmpty() ? 0.0 : textHeight( textField, Q::Header );
|
||||
}
|
||||
|
||||
qreal QskTextFieldSkinlet::effectiveFooterHeight( const QskTextField* textField ) const
|
||||
{
|
||||
const auto text = effectiveText( textField, Q::Footer );
|
||||
return text.isEmpty() ? 0.0 : qskEffectiveTextHeight( textField, Q::Footer );
|
||||
return text.isEmpty() ? 0.0 : textHeight( textField, Q::Footer );
|
||||
}
|
||||
|
||||
#include "moc_QskTextFieldSkinlet.cpp"
|
||||
|
|
|
@ -47,11 +47,14 @@ class QSK_EXPORT QskTextFieldSkinlet : public QskSkinlet
|
|||
virtual QString effectiveText( const QskTextField*,
|
||||
QskAspect::Subcontrol ) const;
|
||||
|
||||
qreal effectiveHeaderHeight( const QskTextField* ) const;
|
||||
virtual qreal effectiveFooterHeight( const QskTextField* ) const;
|
||||
qreal textHeight( const QskTextField*, QskAspect::Subcontrol ) const;
|
||||
|
||||
private:
|
||||
QRectF inputPanelRect( const QskTextField*, const QRectF& ) const;
|
||||
|
||||
qreal effectiveFooterHeight( const QskTextField* ) const;
|
||||
qreal effectiveHeaderHeight( const QskTextField* ) const;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue