Kerberos: add kerberos_inject_longterm_key() helper function
[wireshark-sm.git] / ui / qt / accordion_frame.cpp
blobe5cb977bb1d4ba471f7f81e9c8787a3b361abefc
1 /* accordion_frame.cpp
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
8 */
10 #include "config.h"
12 #include "accordion_frame.h"
14 #include "ui/util.h"
15 #include <ui/qt/utils/color_utils.h>
17 #include <QLayout>
18 #include <QPropertyAnimation>
20 const int duration_ = 150;
22 AccordionFrame::AccordionFrame(QWidget *parent) :
23 QFrame(parent),
24 frame_height_(0)
26 updateStyleSheet();
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()
36 if (isVisible()) {
37 show();
38 return;
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
47 // be the best.
48 show();
49 parent->layout()->invalidate(); // Calls parent->layout()->update()
50 parent->layout()->activate(); // Calculates sizes then calls parent->updateGeometry()
51 frame_height_ = height();
52 hide();
54 if (frame_height_ > 0) {
55 animation_->setStartValue(0);
56 animation_->setEndValue(frame_height_);
57 animation_->start();
60 show();
63 void AccordionFrame::animatedHide()
65 if (!isVisible()) {
66 hide();
67 return;
70 if (!display_is_remote()) {
71 animation_->setStartValue(frame_height_);
72 animation_->setEndValue(0);
73 animation_->start();
74 } else {
75 hide();
79 void AccordionFrame::animationFinished()
81 if (animation_->currentValue().toInt() < 1) {
82 hide();
83 setMaximumHeight(frame_height_);
87 void AccordionFrame::updateStyleSheet()
89 QString style_sheet(
90 "QLineEdit#goToLineEdit {"
91 " max-width: 5em;"
92 "}"
95 #ifdef Q_OS_MAC
96 style_sheet += QString(
97 "QLineEdit {"
98 " border: 1px solid palette(%1);"
99 " border-radius: 3px;"
100 " padding: 1px;"
102 ).arg(ColorUtils::themeIsDark() ? QStringLiteral("light") : QStringLiteral("dark"));
103 #endif
105 setStyleSheet(style_sheet);