Do not trigger resize if section is collapsed

This commit is contained in:
WarmUpTill 2021-05-30 08:36:19 +02:00 committed by WarmUpTill
parent 7fda5e3820
commit fdb72629db
2 changed files with 3 additions and 1 deletions

View File

@ -38,6 +38,7 @@ private:
QWidget *_content = nullptr;
int _animationDuration;
std::atomic_bool _transitioning = {false};
std::atomic_bool _collapsed = {false};
int _headerHeight = 0;
int _contentHeight = 0;
};

View File

@ -49,6 +49,7 @@ void Section::Collapse(bool collapse)
? QAbstractAnimation::Forward
: QAbstractAnimation::Backward);
_transitioning = true;
_collapsed = collapse;
_toggleAnimation->start();
}
@ -93,7 +94,7 @@ void Section::AddHeaderWidget(QWidget *w)
bool Section::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::Resize && !_transitioning) {
if (event->type() == QEvent::Resize && !_transitioning && !_collapsed) {
_contentHeight = _content->sizeHint().height();
setMaximumHeight(_headerHeight + _contentHeight);
setMinimumHeight(_headerHeight + _contentHeight);