From fdb72629db7aca21d32ca5243b5e46faa5c937a3 Mon Sep 17 00:00:00 2001 From: WarmUpTill Date: Sun, 30 May 2021 08:36:19 +0200 Subject: [PATCH] Do not trigger resize if section is collapsed --- src/headers/section.hpp | 1 + src/section.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/headers/section.hpp b/src/headers/section.hpp index 9dea41b2..b3a1ef2b 100644 --- a/src/headers/section.hpp +++ b/src/headers/section.hpp @@ -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; }; diff --git a/src/section.cpp b/src/section.cpp index c76b6800..c06a37dc 100644 --- a/src/section.cpp +++ b/src/section.cpp @@ -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);