code improved
This commit is contained in:
parent
f8e4117beb
commit
f257ad8f95
@ -123,29 +123,30 @@ namespace
|
|||||||
|
|
||||||
void updateLayout() override
|
void updateLayout() override
|
||||||
{
|
{
|
||||||
auto scrolledItem = this->scrolledItem();
|
auto box = buttonBox();
|
||||||
|
|
||||||
auto itemSize = viewContentsRect().size();
|
auto boxSize = viewContentsRect().size();
|
||||||
itemSize = qskConstrainedItemSize( scrolledItem, itemSize );
|
boxSize = qskConstrainedItemSize( box, boxSize );
|
||||||
|
|
||||||
scrolledItem->setSize( itemSize );
|
if ( auto box = buttonBox() )
|
||||||
|
box->setSize( boxSize );
|
||||||
|
|
||||||
enableAutoTranslation( false );
|
enableAutoTranslation( false );
|
||||||
|
|
||||||
setScrollableSize( itemSize );
|
setScrollableSize( boxSize );
|
||||||
setScrollPos( scrollPos() );
|
setScrollPos( scrollPos() );
|
||||||
|
|
||||||
enableAutoTranslation( true );
|
enableAutoTranslation( true );
|
||||||
|
|
||||||
translateItem();
|
translateButtonBox();
|
||||||
|
|
||||||
setClip( size().width() < itemSize.width()
|
setClip( size().width() < boxSize.width()
|
||||||
|| size().height() < itemSize.height() );
|
|| size().height() < boxSize.height() );
|
||||||
}
|
}
|
||||||
|
|
||||||
QSizeF layoutSizeHint( Qt::SizeHint which, const QSizeF& constraint ) const override
|
QSizeF layoutSizeHint( Qt::SizeHint which, const QSizeF& constraint ) const override
|
||||||
{
|
{
|
||||||
auto hint = scrolledItem()->sizeConstraint( which, constraint );
|
auto hint = buttonBox()->sizeConstraint( which, constraint );
|
||||||
|
|
||||||
if ( which == Qt::MinimumSize )
|
if ( which == Qt::MinimumSize )
|
||||||
{
|
{
|
||||||
@ -161,9 +162,9 @@ namespace
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
inline QskControl* scrolledItem() const
|
inline QskLinearBox* buttonBox() const
|
||||||
{
|
{
|
||||||
return qskControlCast( childItems().first() );
|
return qobject_cast< QskLinearBox* >( childItems().first() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void enableAutoTranslation( bool on )
|
void enableAutoTranslation( bool on )
|
||||||
@ -171,21 +172,21 @@ namespace
|
|||||||
if ( on )
|
if ( on )
|
||||||
{
|
{
|
||||||
connect( this, &QskScrollBox::scrollPosChanged,
|
connect( this, &QskScrollBox::scrollPosChanged,
|
||||||
this, &ScrollBox::translateItem );
|
this, &ScrollBox::translateButtonBox );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
disconnect( this, &QskScrollBox::scrollPosChanged,
|
disconnect( this, &QskScrollBox::scrollPosChanged,
|
||||||
this, &ScrollBox::translateItem );
|
this, &ScrollBox::translateButtonBox );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void translateItem()
|
void translateButtonBox()
|
||||||
{
|
{
|
||||||
if ( auto item = this->scrolledItem() )
|
if ( auto box = buttonBox() )
|
||||||
{
|
{
|
||||||
const QPointF pos = viewContentsRect().topLeft() - scrollPos();
|
const QPointF pos = viewContentsRect().topLeft() - scrollPos();
|
||||||
item->setPosition( pos );
|
box->setPosition( pos );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -266,9 +267,11 @@ void QskTabBar::setPosition( Qsk::Position position )
|
|||||||
m_data->position = position;
|
m_data->position = position;
|
||||||
|
|
||||||
const auto orientation = qskOrientation( position );
|
const auto orientation = qskOrientation( position );
|
||||||
|
|
||||||
if ( orientation != m_data->buttonBox->orientation() )
|
if ( orientation != m_data->buttonBox->orientation() )
|
||||||
{
|
{
|
||||||
setSizePolicy( sizePolicy( Qt::Vertical ), sizePolicy( Qt::Horizontal ) );
|
setSizePolicy( sizePolicy().transposed() );
|
||||||
|
|
||||||
m_data->buttonBox->setOrientation( orientation );
|
m_data->buttonBox->setOrientation( orientation );
|
||||||
m_data->scrollBox->setOrientation( orientation );
|
m_data->scrollBox->setOrientation( orientation );
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user