3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * SPDX-License-Identifier: GPL-2.0-or-later
12 #include "accordion_frame.h"
15 #include <ui/qt/utils/color_utils.h>
18 #include <QPropertyAnimation>
20 const int duration_
= 150;
22 AccordionFrame::AccordionFrame(QWidget
*parent
) :
28 animation_
= new QPropertyAnimation(this, "maximumHeight", this);
29 animation_
->setDuration(duration_
);
30 animation_
->setEasingCurve(QEasingCurve::InOutQuad
);
31 connect(animation_
, &QPropertyAnimation::finished
, this, &AccordionFrame::animationFinished
);
34 void AccordionFrame::animatedShow()
41 if (!display_is_remote()) {
42 QWidget
*parent
= parentWidget();
44 if (parent
&& parent
->layout()) {
45 // Force our parent layout to update its geometry. There are a number
46 // of ways of doing this. Calling invalidate + activate seems to
49 parent
->layout()->invalidate(); // Calls parent->layout()->update()
50 parent
->layout()->activate(); // Calculates sizes then calls parent->updateGeometry()
51 frame_height_
= height();
54 if (frame_height_
> 0) {
55 animation_
->setStartValue(0);
56 animation_
->setEndValue(frame_height_
);
63 void AccordionFrame::animatedHide()
70 if (!display_is_remote()) {
71 animation_
->setStartValue(frame_height_
);
72 animation_
->setEndValue(0);
79 void AccordionFrame::animationFinished()
81 if (animation_
->currentValue().toInt() < 1) {
83 setMaximumHeight(frame_height_
);
87 void AccordionFrame::updateStyleSheet()
90 "QLineEdit#goToLineEdit {"
96 style_sheet
+= QString(
98 " border: 1px solid palette(%1);"
99 " border-radius: 3px;"
102 ).arg(ColorUtils::themeIsDark() ? QStringLiteral("light") : QStringLiteral("dark"));
105 setStyleSheet(style_sheet
);