diff options
author | Gerald Combs <gerald@zing.org> | 2014-12-21 10:13:00 -0800 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2014-12-21 18:47:42 +0000 |
commit | bcaf1f4ca600152f2f267623d881d8f12233a03b (patch) | |
tree | 47fbd20350ea8605f82fa7b13e3bcc0079b885fa /ui/qt/accordion_frame.cpp | |
parent | bd19532bfb83fc24f3aa19ee097a48f22ef9097a (diff) |
Qt: Better accordion frame layout.
Calling invalidate + activate on the parent layout has better results
than calling adjustSize on the parent widget.
Change-Id: I844bee49b868d988b0fc93a72687407adf232ef9
Reviewed-on: https://code.wireshark.org/review/5951
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/qt/accordion_frame.cpp')
-rw-r--r-- | ui/qt/accordion_frame.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/ui/qt/accordion_frame.cpp b/ui/qt/accordion_frame.cpp index cbeb11ca06..61ea101117 100644 --- a/ui/qt/accordion_frame.cpp +++ b/ui/qt/accordion_frame.cpp @@ -26,10 +26,13 @@ #include "ui/util.h" +#include <QLayout> + const int duration_ = 150; AccordionFrame::AccordionFrame(QWidget *parent) : - QFrame(parent) + QFrame(parent), + frame_height_(0) { QString subframe_style( // ".QFrame {" @@ -43,7 +46,6 @@ AccordionFrame::AccordionFrame(QWidget *parent) : "}" ); setStyleSheet(subframe_style); - frame_height_ = height(); animation_ = new QPropertyAnimation(this, "maximumHeight"); animation_->setDuration(duration_); animation_->setEasingCurve(QEasingCurve::InOutQuad); @@ -61,14 +63,12 @@ void AccordionFrame::animatedShow() QWidget *parent = parentWidget(); if (parent && parent->layout()) { - // Show this widget, tell our parent to calculate our size, and hide - // ourselves. We might need to call - // parent->layout()->update(); parent->layout()->activate(); - // or - // parent->layout()->invalidate(); - // as well + // Force our parent layout to update its geometry. There are a number + // of ways of doing this. Calling invalidate + activate seems to + // be the best. show(); - parent->adjustSize(); + parent->layout()->invalidate(); // Calls parent->layout()->update() + parent->layout()->activate(); // Calculates sizes then calls parent->updateGeometry() frame_height_ = height(); hide(); } |