@@ -70,7 +70,9 @@ void DDrawerPrivate::init()
7070 m_animation = new QPropertyAnimation (m_contentLoader, " height" , qq);
7171 m_animation->setDuration (400 );
7272 m_animation->setEasingCurve (QEasingCurve::InQuad);
73- qq->connect (m_animation, &QPropertyAnimation::valueChanged, qq, [qq] {
73+ qq->connect (m_animation, &QPropertyAnimation::valueChanged, qq, [this , qq] {
74+ if (!m_enableAnimation)
75+ return ;
7476 qq->setFixedHeight (qq->sizeHint ().height ());
7577 });
7678
@@ -82,6 +84,10 @@ void DDrawerPrivate::init()
8284 qq->setLayout (mainLayout);
8385
8486 qq->connect (m_boxWidget, &DBoxWidget::sizeChanged, qq, [this ] {
87+ if (!m_enableAnimation) {
88+ updateHeightDirect ();
89+ return ;
90+ }
8591 if (m_expand) {
8692 int endHeight = 0 ;
8793 endHeight = m_boxWidget->height ();
@@ -94,6 +100,13 @@ void DDrawerPrivate::init()
94100 });
95101}
96102
103+ void DDrawerPrivate::updateHeightDirect ()
104+ {
105+ D_Q (DDrawer);
106+ m_contentLoader->setFixedHeight (m_expand ? m_boxWidget->height () : 0 );
107+ q->setFixedHeight (q->sizeHint ().height ());
108+ }
109+
97110/* !
98111 \class Dtk::Widget::DDrawer
99112 \inmodule dtkwidget
@@ -210,6 +223,15 @@ void DDrawer::setExpand(bool value)
210223 d->m_expand = value;
211224 Q_EMIT expandChange (value);
212225
226+ // Disable animation to update height when widget is invisible by default.
227+ static const bool disableAnimation (qEnvironmentVariableIsSet (" D_DTK_DISABLE_ANIMATIONS" ));
228+ d->m_enableAnimation = !disableAnimation && isVisible ();
229+
230+ if (!d->m_enableAnimation ) {
231+ d->updateHeightDirect ();
232+ return ;
233+ }
234+
213235 if (value) {
214236 d->m_animation ->setStartValue (0 );
215237 d->m_animation ->setEndValue (d->m_boxWidget ->height ());
0 commit comments