summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerald Combs <gerald@zing.org>2014-12-20 20:06:43 -0800
committerGerald Combs <gerald@wireshark.org>2014-12-21 04:52:04 +0000
commit35571f850ff7eeaa3e9940d0dc467cabbfbf13ac (patch)
tree5eb47097a9e2367669af51ee668b8b428799e220
parent2b006ad30e38b015cfd13c33b265e2f48ddf36b2 (diff)
downloadwireshark-35571f850ff7eeaa3e9940d0dc467cabbfbf13ac.tar.gz
Qt: Fix accordion frame height calculation.
Change-Id: I32d2ea2ff34544e285b52e4e35e035306c33d3aa Reviewed-on: https://code.wireshark.org/review/5935 Reviewed-by: Gerald Combs <gerald@wireshark.org>
-rw-r--r--ui/qt/accordion_frame.cpp44
-rw-r--r--ui/qt/accordion_frame.h2
-rw-r--r--ui/qt/main_welcome.cpp7
3 files changed, 41 insertions, 12 deletions
diff --git a/ui/qt/accordion_frame.cpp b/ui/qt/accordion_frame.cpp
index fe13c660f9..cbeb11ca06 100644
--- a/ui/qt/accordion_frame.cpp
+++ b/ui/qt/accordion_frame.cpp
@@ -32,12 +32,12 @@ AccordionFrame::AccordionFrame(QWidget *parent) :
QFrame(parent)
{
QString subframe_style(
- ".QFrame {"
- " background: palette(window);"
- " padding-top: 0.1em;"
- " padding-bottom: 0.1em;"
- " border-bottom: 1px solid palette(shadow);"
- "}"
+// ".QFrame {"
+// " background: palette(window);"
+// " padding-top: 0.1em;"
+// " padding-bottom: 0.1em;"
+// " border-bottom: 1px solid palette(shadow);"
+// "}"
"QLineEdit#goToLineEdit {"
" max-width: 5em;"
"}"
@@ -52,16 +52,42 @@ AccordionFrame::AccordionFrame(QWidget *parent) :
void AccordionFrame::animatedShow()
{
+ if (isVisible()) {
+ show();
+ return;
+ }
+
if (strlen (get_conn_cfilter()) < 1) {
- animation_->setStartValue(0);
- animation_->setEndValue(frame_height_);
- animation_->start();
+ 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
+ show();
+ parent->adjustSize();
+ frame_height_ = height();
+ hide();
+ }
+ if (frame_height_ > 0) {
+ animation_->setStartValue(0);
+ animation_->setEndValue(frame_height_);
+ animation_->start();
+ }
}
show();
}
void AccordionFrame::animatedHide()
{
+ if (!isVisible()) {
+ hide();
+ return;
+ }
+
if (strlen (get_conn_cfilter()) < 1) {
animation_->setStartValue(frame_height_);
animation_->setEndValue(0);
diff --git a/ui/qt/accordion_frame.h b/ui/qt/accordion_frame.h
index 59d9249a17..b205c6248f 100644
--- a/ui/qt/accordion_frame.h
+++ b/ui/qt/accordion_frame.h
@@ -35,8 +35,6 @@ public:
signals:
-public slots:
-
private:
int frame_height_;
QPropertyAnimation *animation_;
diff --git a/ui/qt/main_welcome.cpp b/ui/qt/main_welcome.cpp
index 58c023b42f..7aa41fe7c0 100644
--- a/ui/qt/main_welcome.cpp
+++ b/ui/qt/main_welcome.cpp
@@ -95,6 +95,7 @@ MainWelcome::MainWelcome(QWidget *parent) :
welcome_ui_->interfaceTree->setAttribute(Qt::WA_MacShowFocusRect, false);
#endif
+ welcome_ui_->openFrame->hide();
recent_files_->setStyleSheet(
"QListWidget::item {"
" padding-top: 0.2em;"
@@ -199,7 +200,11 @@ void MainWelcome::updateRecentFiles() {
while (recent_files_->count() > (int) prefs.gui_recent_files_count_max) {
recent_files_->takeItem(recent_files_->count());
}
- welcome_ui_->openFrame->setVisible(recent_files_->count() > 0);
+ if (recent_files_->count() > 0) {
+ welcome_ui_->openFrame->animatedShow();
+ } else {
+ welcome_ui_->openFrame->animatedHide();
+ }
}
void MainWelcome::openRecentItem(QListWidgetItem *item) {