Add an AccordionFrame class which can animate showing and hiding (except

when we detect a remote connection). Use it for the "go to" and search
frames. Properly detect remote connections in the splash overlay.

svn path=/trunk/; revision=46591
This commit is contained in:
Gerald Combs 2012-12-18 17:21:20 +00:00
parent ed87fa9e3b
commit 7cf5334332
11 changed files with 185 additions and 37 deletions

View File

@ -24,6 +24,7 @@
# All .h files which inherit from QObject aka which use the Q_OBJECT macro
# need to go here.
set(QTSHARK_H_SRC
accordion_frame.h
byte_view_tab.h
byte_view_text.h
capture_file_dialog.h
@ -53,6 +54,7 @@ set(QTSHARK_H_SRC
recent_file_status.h
simple_dialog_qt.h
search_frame.h
sparkline_delegate.h
splash_overlay.h
syntax_line_edit.h
wireshark_application.h
@ -63,6 +65,7 @@ set(QTSHARK_H_SRC
)
set(QTSHARK_CPP_SRC
accordion_frame.cpp
byte_view_tab.cpp
byte_view_text.cpp
capture_file_dialog.cpp

View File

@ -75,6 +75,7 @@ GENERATOR_FILES =
# Headers that have to be run through moc.
#
MOC_HDRS = \
accordion_frame.h \
byte_view_tab.h \
byte_view_text.h \
capture_file_dialog.h \
@ -152,6 +153,7 @@ QM_FILES = \
QRC_SRC = $(QRC_FILES:.qrc=.rcc.cpp)
WIRESHARK_QT_SRC = \
accordion_frame.cpp \
byte_view_tab.cpp \
byte_view_text.cpp \
capture_file_dialog.cpp \

View File

@ -217,7 +217,8 @@ HEADERS += $$HEADERS_WS_C \
export_object_dialog.h \
print_dialog.h \
splash_overlay.h \
search_frame.h
search_frame.h \
accordion_frame.h
win32 {
OBJECTS_WS_C = $$SOURCES_WS_C
@ -394,6 +395,7 @@ HEADERS += \
wireshark_application.h
SOURCES += \
accordion_frame.cpp \
byte_view_tab.cpp \
byte_view_text.cpp \
capture_file_dialog.cpp \
@ -425,9 +427,9 @@ SOURCES += \
proto_tree.cpp \
qt_ui_utils.cpp \
recent_file_status.cpp \
search_frame.cpp \
simple_dialog_qt.cpp \
sparkline_delegate.cpp \
splash_overlay.cpp \
syntax_line_edit.cpp \
wireshark_application.cpp \
search_frame.cpp
wireshark_application.cpp

96
ui/qt/accordion_frame.cpp Normal file
View File

@ -0,0 +1,96 @@
/* accordion_frame.cpp
*
* $Id: splash_overlay.cpp 45941 2012-11-05 22:43:15Z gerald $
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include <glib.h>
#include "accordion_frame.h"
#include "ui/util.h"
const int duration_ = 150;
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);"
"}"
"QLineEdit#goToLineEdit {"
" max-width: 5em;"
"}"
);
setStyleSheet(subframe_style);
frame_height_ = height();
animation_ = new QPropertyAnimation(this, "maximumHeight");
animation_->setDuration(duration_);
animation_->setEasingCurve(QEasingCurve::InOutQuad);
connect(animation_, SIGNAL(finished()), this, SLOT(animationFinished()));
}
void AccordionFrame::animatedShow()
{
if (strlen (get_conn_cfilter()) < 1) {
animation_->setStartValue(0);
animation_->setEndValue(frame_height_);
animation_->start();
}
show();
}
void AccordionFrame::animatedHide()
{
if (strlen (get_conn_cfilter()) < 1) {
animation_->setStartValue(frame_height_);
animation_->setEndValue(0);
animation_->start();
} else {
hide();
}
}
void AccordionFrame::animationFinished()
{
if (animation_->currentValue().toInt() < 1) {
hide();
setMaximumHeight(frame_height_);
}
}
/*
* Editor modelines
*
* Local Variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/

51
ui/qt/accordion_frame.h Normal file
View File

@ -0,0 +1,51 @@
/* accordion_frame.cpp
*
* $Id: splash_overlay.cpp 45941 2012-11-05 22:43:15Z gerald $
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef ACCORDION_FRAME_H
#define ACCORDION_FRAME_H
#include <QFrame>
#include <QPropertyAnimation>
class AccordionFrame : public QFrame
{
Q_OBJECT
public:
explicit AccordionFrame(QWidget *parent = 0);
void animatedShow();
void animatedHide();
signals:
public slots:
private:
int frame_height_;
QPropertyAnimation *animation_;
private slots:
void animationFinished();
};
#endif // ACCORDION_FRAME_H

View File

@ -115,24 +115,11 @@ MainWindow::MainWindow(QWidget *parent) :
// This property is obsolete in Qt5 so this issue may be fixed in that version.
main_ui_->displayFilterToolBar->addWidget(df_combo_box_);
QString subframe_style(
".QFrame {"
" background: palette(window);"
" padding-top: 0.1em;"
" padding-bottom: 0.1em;"
" border-bottom: 1px solid palette(shadow);"
"}"
"QLineEdit#goToLineEdit {"
" max-width: 5em;"
"}"
);
main_ui_->goToFrame->hide();
// XXX For some reason the cursor is drawn funny with an input mask set
// https://bugreports.qt-project.org/browse/QTBUG-7174
main_ui_->goToFrame->setStyleSheet(subframe_style);
main_ui_->searchFrame->hide();
main_ui_->searchFrame->setStyleSheet(subframe_style);
connect(main_ui_->searchFrame, SIGNAL(pushFilterSyntaxStatus(QString&)),
main_ui_->statusBar, SLOT(pushTemporaryStatus(QString&)));

View File

@ -31,7 +31,7 @@
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="goToFrame">
<widget class="AccordionFrame" name="goToFrame">
<layout class="QHBoxLayout" name="goToHB">
<property name="topMargin">
<number>0</number>
@ -1133,6 +1133,12 @@
<extends>QWidget</extends>
<header>search_frame.h</header>
</customwidget>
<customwidget>
<class>AccordionFrame</class>
<extends>QFrame</extends>
<header>accordion_frame.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../image/toolbar.qrc"/>

View File

@ -321,7 +321,7 @@ void MainWindow::captureFileClosing(const capture_file *cf) {
// Reset expert info indicator
main_ui_->statusBar->hideExpert();
main_ui_->searchFrame->hide();
main_ui_->searchFrame->animatedHide();
// gtk_widget_show(expert_info_none);
emit setCaptureFile(NULL);
}
@ -1179,11 +1179,11 @@ void MainWindow::on_actionEditFindPacket_triggered()
}
previous_focus_ = wsApp->focusWidget();
connect(previous_focus_, SIGNAL(destroyed()), this, SLOT(resetPreviousFocus()));
main_ui_->goToFrame->hide();
main_ui_->goToFrame->animatedHide();
if (main_ui_->searchFrame->isVisible()) {
main_ui_->searchFrame->hide();
main_ui_->searchFrame->animatedHide();
} else {
main_ui_->searchFrame->show();
main_ui_->searchFrame->animatedShow();
}
}
@ -1489,11 +1489,11 @@ void MainWindow::on_actionGoGoToPacket_triggered() {
previous_focus_ = wsApp->focusWidget();
connect(previous_focus_, SIGNAL(destroyed()), this, SLOT(resetPreviousFocus()));
main_ui_->searchFrame->hide();
main_ui_->searchFrame->animatedHide();
if (main_ui_->goToFrame->isVisible()) {
main_ui_->goToFrame->hide();
main_ui_->goToFrame->animatedHide();
} else {
main_ui_->goToFrame->show();
main_ui_->goToFrame->animatedShow();
}
main_ui_->goToLineEdit->setFocus();
}
@ -1504,7 +1504,7 @@ void MainWindow::resetPreviousFocus() {
void MainWindow::on_goToCancel_clicked()
{
main_ui_->goToFrame->hide();
main_ui_->goToFrame->animatedHide();
if (previous_focus_) {
disconnect(previous_focus_, SIGNAL(destroyed()), this, SLOT(resetPreviousFocus()));
previous_focus_->setFocus();

View File

@ -44,7 +44,7 @@ const int narrow_chars = 1;
const int wide_chars = 2;
SearchFrame::SearchFrame(QWidget *parent) :
QFrame(parent),
AccordionFrame(parent),
sf_ui_(new Ui::SearchFrame),
cap_file_(NULL)
{
@ -64,10 +64,11 @@ SearchFrame::~SearchFrame()
delete sf_ui_;
}
void SearchFrame::show()
void SearchFrame::animatedShow()
{
sf_ui_->searchLineEdit->setFocus();
QFrame::show();
AccordionFrame::animatedShow();
}
void SearchFrame::findNext()
@ -76,7 +77,7 @@ void SearchFrame::findNext()
cap_file_->dir = SD_FORWARD;
if (isHidden()) {
show();
animatedShow();
return;
}
on_findButton_clicked();
@ -88,7 +89,7 @@ void SearchFrame::findPrevious()
cap_file_->dir = SD_BACKWARD;
if (isHidden()) {
show();
animatedShow();
return;
}
on_findButton_clicked();
@ -98,14 +99,14 @@ void SearchFrame::setCaptureFile(capture_file *cf)
{
cap_file_ = cf;
if (!cf && isVisible()) {
hide();
animatedHide();
}
enableWidgets();
}
void SearchFrame::findFrameWithFilter(QString &filter)
{
show();
animatedShow();
sf_ui_->searchLineEdit->setText(filter);
sf_ui_->searchTypeComboBox->setCurrentIndex(0);
enableWidgets();
@ -356,7 +357,7 @@ void SearchFrame::on_findButton_clicked()
void SearchFrame::on_cancelButton_clicked()
{
hide();
animatedHide();
}
/*

View File

@ -26,7 +26,7 @@
#include <config.h>
#include <QFrame>
#include "accordion_frame.h"
#include "cfile.h"
@ -34,14 +34,14 @@ namespace Ui {
class SearchFrame;
}
class SearchFrame : public QFrame
class SearchFrame : public AccordionFrame
{
Q_OBJECT
public:
explicit SearchFrame(QWidget *parent = 0);
~SearchFrame();
void show();
void animatedShow();
void findNext();
void findPrevious();

View File

@ -89,7 +89,7 @@ SplashOverlay::SplashOverlay(QWidget *parent) :
));
// Check for a remote connection
if (get_conn_cfilter() != NULL)
if (strlen (get_conn_cfilter()) > 0)
info_update_freq_ = 1000;
connect(wsApp, SIGNAL(splashUpdate(register_action_e,const char*)),