sizeHints renamed to explicitSizeHints, widthForHeight/heightForWidth
moved to QskControl
This commit is contained in:
parent
e859075f6a
commit
c46b105879
@ -206,7 +206,7 @@ public:
|
||||
inline void implicitSizeChanged()
|
||||
{
|
||||
Q_Q( QskControl );
|
||||
if ( !q->QskResizable::sizeHint( Qt::PreferredSize ).isValid() )
|
||||
if ( !q->explicitSizeHint( Qt::PreferredSize ).isValid() )
|
||||
{
|
||||
// when we have no PreferredSize we fall back
|
||||
// to the implicit size
|
||||
@ -924,15 +924,16 @@ void qskResolveLocale( QskControl* control )
|
||||
}
|
||||
}
|
||||
|
||||
QSizeF QskControl::effectiveConstraint( Qt::SizeHint whichHint ) const
|
||||
QSizeF QskControl::effectiveSizeHint( Qt::SizeHint whichHint ) const
|
||||
{
|
||||
if ( whichHint < Qt::MinimumSize || whichHint > Qt::MaximumSize )
|
||||
return QSizeF( 0, 0 );
|
||||
|
||||
QSizeF constraint = QskResizable::sizeHint( whichHint );
|
||||
if ( whichHint == Qt::PreferredSize && !constraint.isValid() )
|
||||
QSizeF size = explicitSizeHint( whichHint );
|
||||
|
||||
if ( whichHint == Qt::PreferredSize && !size.isValid() )
|
||||
{
|
||||
// in most cases we don't have a preferred width or height
|
||||
// in most cases we don't have a preferred width/height
|
||||
// and fall back to the implicit size.
|
||||
|
||||
if ( d_func()->blockedImplicitSize )
|
||||
@ -941,14 +942,14 @@ QSizeF QskControl::effectiveConstraint( Qt::SizeHint whichHint ) const
|
||||
that->updateImplicitSize();
|
||||
}
|
||||
|
||||
if ( constraint.width() < 0 )
|
||||
constraint.setWidth( implicitWidth() );
|
||||
if ( size.width() < 0 )
|
||||
size.setWidth( implicitWidth() );
|
||||
|
||||
if ( constraint.height() < 0 )
|
||||
constraint.setHeight( implicitHeight() );
|
||||
if ( size.height() < 0 )
|
||||
size.setHeight( implicitHeight() );
|
||||
}
|
||||
|
||||
return constraint;
|
||||
return size;
|
||||
}
|
||||
|
||||
void QskControl::resetImplicitSize()
|
||||
@ -974,6 +975,18 @@ void QskControl::resetImplicitSize()
|
||||
}
|
||||
}
|
||||
|
||||
qreal QskControl::heightForWidth( qreal width ) const
|
||||
{
|
||||
Q_UNUSED( width )
|
||||
return -1;
|
||||
}
|
||||
|
||||
qreal QskControl::widthForHeight( qreal height ) const
|
||||
{
|
||||
Q_UNUSED( height )
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool QskControl::event( QEvent* event )
|
||||
{
|
||||
const int eventType = event->type();
|
||||
|
@ -143,7 +143,10 @@ public:
|
||||
Q_INVOKABLE bool testControlFlag( Flag ) const;
|
||||
|
||||
QSizeF sizeHint() const;
|
||||
QSizeF effectiveConstraint( Qt::SizeHint ) const;
|
||||
QSizeF effectiveSizeHint( Qt::SizeHint ) const;
|
||||
|
||||
virtual qreal heightForWidth( qreal width ) const;
|
||||
virtual qreal widthForHeight( qreal height ) const;
|
||||
|
||||
virtual QSizeF contentsSizeHint() const;
|
||||
|
||||
@ -246,7 +249,7 @@ inline QSizeF QskControl::implicitSize() const
|
||||
|
||||
inline QSizeF QskControl::sizeHint() const
|
||||
{
|
||||
return effectiveConstraint( Qt::PreferredSize );
|
||||
return effectiveSizeHint( Qt::PreferredSize );
|
||||
}
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QskControl::Flags )
|
||||
|
@ -71,12 +71,12 @@ QskSizePolicy::Policy QskResizable::sizePolicy( Qt::Orientation orientation ) co
|
||||
|
||||
QSizeF QskResizable::preferredSize() const
|
||||
{
|
||||
return sizeHint( Qt::PreferredSize );
|
||||
return explicitSizeHint( Qt::PreferredSize );
|
||||
}
|
||||
|
||||
void QskResizable::setPreferredSize( const QSizeF& size )
|
||||
{
|
||||
setSizeHint( Qt::PreferredSize, size );
|
||||
setExplicitSizeHint( Qt::PreferredSize, size );
|
||||
}
|
||||
|
||||
void QskResizable::setPreferredSize( qreal width, qreal height )
|
||||
@ -96,12 +96,12 @@ void QskResizable::setPreferredHeight( qreal height )
|
||||
|
||||
QSizeF QskResizable::minimumSize() const
|
||||
{
|
||||
return sizeHint( Qt::MinimumSize );
|
||||
return explicitSizeHint( Qt::MinimumSize );
|
||||
}
|
||||
|
||||
void QskResizable::setMinimumSize( const QSizeF& size )
|
||||
{
|
||||
setSizeHint( Qt::MinimumSize, size );
|
||||
setExplicitSizeHint( Qt::MinimumSize, size );
|
||||
}
|
||||
|
||||
void QskResizable::setMinimumSize( qreal width, qreal height )
|
||||
@ -121,12 +121,12 @@ void QskResizable::setMinimumHeight( qreal height )
|
||||
|
||||
QSizeF QskResizable::maximumSize() const
|
||||
{
|
||||
return sizeHint( Qt::MaximumSize );
|
||||
return explicitSizeHint( Qt::MaximumSize );
|
||||
}
|
||||
|
||||
void QskResizable::setMaximumSize( const QSizeF& size )
|
||||
{
|
||||
setSizeHint( Qt::MaximumSize, size );
|
||||
setExplicitSizeHint( Qt::MaximumSize, size );
|
||||
}
|
||||
|
||||
void QskResizable::setMaximumSize( qreal width, qreal height )
|
||||
@ -194,7 +194,7 @@ void QskResizable::setFixedHeight( qreal height )
|
||||
}
|
||||
}
|
||||
|
||||
void QskResizable::resetSizeHint( Qt::SizeHint whichHint )
|
||||
void QskResizable::resetExplicitSizeHint( Qt::SizeHint whichHint )
|
||||
{
|
||||
QSizeF hint;
|
||||
|
||||
@ -226,7 +226,7 @@ void QskResizable::resetSizeHint( Qt::SizeHint whichHint )
|
||||
}
|
||||
}
|
||||
|
||||
void QskResizable::setSizeHint( Qt::SizeHint whichHint, const QSizeF& size )
|
||||
void QskResizable::setExplicitSizeHint( Qt::SizeHint whichHint, const QSizeF& size )
|
||||
{
|
||||
if ( whichHint >= Qt::MinimumSize && whichHint <= Qt::MaximumSize )
|
||||
{
|
||||
@ -241,12 +241,12 @@ void QskResizable::setSizeHint( Qt::SizeHint whichHint, const QSizeF& size )
|
||||
}
|
||||
}
|
||||
|
||||
void QskResizable::setSizeHint( Qt::SizeHint whichHint, qreal width, qreal height )
|
||||
void QskResizable::setExplicitSizeHint( Qt::SizeHint whichHint, qreal width, qreal height )
|
||||
{
|
||||
setSizeHint( whichHint, QSizeF( width, height ) );
|
||||
setExplicitSizeHint( whichHint, QSizeF( width, height ) );
|
||||
}
|
||||
|
||||
QSizeF QskResizable::sizeHint( Qt::SizeHint whichHint ) const
|
||||
QSizeF QskResizable::explicitSizeHint( Qt::SizeHint whichHint ) const
|
||||
{
|
||||
if ( whichHint >= Qt::MinimumSize && whichHint <= Qt::MaximumSize )
|
||||
return m_sizeHints[whichHint];
|
||||
@ -255,18 +255,6 @@ QSizeF QskResizable::sizeHint( Qt::SizeHint whichHint ) const
|
||||
return QSizeF( -1, -1 );
|
||||
}
|
||||
|
||||
qreal QskResizable::heightForWidth( qreal width ) const
|
||||
{
|
||||
Q_UNUSED( width )
|
||||
return -1;
|
||||
}
|
||||
|
||||
qreal QskResizable::widthForHeight( qreal height ) const
|
||||
{
|
||||
Q_UNUSED( height )
|
||||
return -1;
|
||||
}
|
||||
|
||||
void QskResizable::layoutConstraintChanged()
|
||||
{
|
||||
}
|
||||
|
@ -43,18 +43,15 @@ public:
|
||||
void setFixedWidth( qreal width );
|
||||
void setFixedHeight( qreal height );
|
||||
|
||||
void setSizeHint( Qt::SizeHint, const QSizeF& );
|
||||
void setSizeHint( Qt::SizeHint, qreal width, qreal height );
|
||||
void resetSizeHint( Qt::SizeHint );
|
||||
void setExplicitSizeHint( Qt::SizeHint, const QSizeF& );
|
||||
void setExplicitSizeHint( Qt::SizeHint, qreal width, qreal height );
|
||||
void resetExplicitSizeHint( Qt::SizeHint );
|
||||
|
||||
QSizeF minimumSize() const;
|
||||
QSizeF maximumSize() const;
|
||||
QSizeF preferredSize() const;
|
||||
|
||||
QSizeF sizeHint( Qt::SizeHint ) const;
|
||||
|
||||
virtual qreal heightForWidth( qreal width ) const;
|
||||
virtual qreal widthForHeight( qreal height ) const;
|
||||
QSizeF explicitSizeHint( Qt::SizeHint ) const;
|
||||
|
||||
protected:
|
||||
void initSizePolicy( QskSizePolicy::Policy, QskSizePolicy::Policy );
|
||||
|
@ -183,8 +183,8 @@ QSizeF QskTabView::contentsSizeHint() const
|
||||
if ( m_data->tabBar == nullptr || m_data->tabBar->count() == 0 )
|
||||
return Inherited::contentsSizeHint();
|
||||
|
||||
const QSizeF barHint = m_data->tabBar->effectiveConstraint( Qt::PreferredSize );
|
||||
const QSizeF itemHint = m_data->stackBox->effectiveConstraint( Qt::PreferredSize );
|
||||
const QSizeF barHint = m_data->tabBar->sizeHint();
|
||||
const QSizeF itemHint = m_data->stackBox->sizeHint();
|
||||
|
||||
const qreal w = qMax( barHint.width(), itemHint.width() );
|
||||
const qreal h = barHint.height() + itemHint.height();
|
||||
|
@ -395,7 +395,7 @@ QSize QskWindow::effectivePreferredSize() const
|
||||
{
|
||||
if ( QskControl* control = qobject_cast< QskControl* >( child ) )
|
||||
{
|
||||
const QSizeF itemConstraint = control->effectiveConstraint( Qt::PreferredSize );
|
||||
const QSizeF itemConstraint = control->sizeHint();
|
||||
if ( doWidth )
|
||||
constraint.setWidth( qMax( constraint.width(), itemConstraint.width() ) );
|
||||
|
||||
|
@ -74,7 +74,7 @@ QSizeF QskLayoutConstraint::effectiveConstraint(
|
||||
const QQuickItem* item, Qt::SizeHint whichHint )
|
||||
{
|
||||
if ( const QskControl* control = qobject_cast< const QskControl* >( item ) )
|
||||
return control->effectiveConstraint( whichHint );
|
||||
return control->effectiveSizeHint( whichHint );
|
||||
|
||||
QSizeF constraint( -1.0, -1.0 ); // no hint
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user