Qt: Fix accordion frame height calculation.

Change-Id: I32d2ea2ff34544e285b52e4e35e035306c33d3aa
Reviewed-on: https://code.wireshark.org/review/5935
Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
Gerald Combs 2014-12-20 20:06:43 -08:00 committed by Gerald Combs
parent 2b006ad30e
commit 35571f850f
3 changed files with 41 additions and 12 deletions

View File

@ -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);

View File

@ -35,8 +35,6 @@ public:
signals:
public slots:
private:
int frame_height_;
QPropertyAnimation *animation_;

View File

@ -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) {