Qt: Add dialog geometry restore

Add GeometryStateDialog class to handle load and save dialog geometry.
The QDialog class name will be used as window name.  For shared
classes the UAT name or the statistics title or abbr will be used.

Change-Id: I5a019598307fb3861518f41e733de834788184d8
Reviewed-on: https://code.wireshark.org/review/14139
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
This commit is contained in:
Stig Bjørlykke 2016-02-28 19:23:20 +01:00
parent f0425e83a1
commit 1a716800e3
69 changed files with 279 additions and 145 deletions

View File

@ -72,6 +72,7 @@ set(WIRESHARK_QT_HEADERS
funnel_string_dialog.h
funnel_text_dialog.h
funnel_statistics.h
geometry_state_dialog.h
gsm_map_summary_dialog.h
iax2_analysis_dialog.h
import_text_dialog.h
@ -222,6 +223,7 @@ set(WIRESHARK_QT_SRC
font_color_preferences_frame.cpp
funnel_string_dialog.cpp
funnel_text_dialog.cpp
geometry_state_dialog.cpp
iax2_analysis_dialog.cpp
import_text_dialog.cpp
interface_tree.cpp

View File

@ -196,6 +196,7 @@ MOC_HDRS = \
funnel_string_dialog.h \
funnel_text_dialog.h \
funnel_statistics.h \
geometry_state_dialog.h \
gsm_map_summary_dialog.h \
iax2_analysis_dialog.h \
import_text_dialog.h \
@ -459,6 +460,7 @@ WIRESHARK_QT_SRC = \
font_color_preferences_frame.cpp \
funnel_string_dialog.cpp \
funnel_text_dialog.cpp \
geometry_state_dialog.cpp \
iax2_analysis_dialog.cpp \
import_text_dialog.cpp \
interface_tree.cpp \

View File

@ -65,7 +65,7 @@ BluetoothAttServerAttributesDialog::BluetoothAttServerAttributesDialog(QWidget &
ui(new Ui::BluetoothAttServerAttributesDialog)
{
ui->setupUi(this);
resize(parent.width() * 4 / 5, parent.height() * 2 / 3);
loadGeometry(parent.width() * 4 / 5, parent.height() * 2 / 3);
connect(ui->tableTreeWidget, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(tableContextMenu(const QPoint &)));
connect(ui->interfaceComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(interfaceCurrentIndexChanged(int)));

View File

@ -80,7 +80,7 @@ BluetoothDevicesDialog::BluetoothDevicesDialog(QWidget &parent, CaptureFile &cf)
ui(new Ui::BluetoothDevicesDialog)
{
ui->setupUi(this);
resize(parent.width() * 4 / 5, parent.height() * 2 / 3);
loadGeometry(parent.width() * 4 / 5, parent.height() * 2 / 3);
connect(ui->tableTreeWidget, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(tableContextMenu(const QPoint &)));
connect(ui->interfaceComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(interfaceCurrentIndexChanged(int)));

View File

@ -101,7 +101,7 @@ BluetoothHciSummaryDialog::BluetoothHciSummaryDialog(QWidget &parent, CaptureFil
ui(new Ui::BluetoothHciSummaryDialog)
{
ui->setupUi(this);
resize(parent.width() * 4 / 5, parent.height() * 2 / 3);
loadGeometry(parent.width() * 4 / 5, parent.height() * 2 / 3);
connect(ui->tableTreeWidget, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(tableContextMenu(const QPoint &)));
connect(ui->tableTreeWidget, SIGNAL(itemExpanded(QTreeWidgetItem *)), this, SLOT(tableItemExpanded(QTreeWidgetItem *)));

View File

@ -45,9 +45,7 @@ CaptureFilePropertiesDialog::CaptureFilePropertiesDialog(QWidget &parent, Captur
ui(new Ui::CaptureFilePropertiesDialog)
{
ui->setupUi(this);
// XXX Use recent settings instead
resize(parent.width() * 2 / 3, parent.height());
loadGeometry(parent.width() * 2 / 3, parent.height());
ui->detailsTextEdit->setAcceptRichText(true);

View File

@ -113,10 +113,11 @@ public:
};
CaptureInterfacesDialog::CaptureInterfacesDialog(QWidget *parent) :
QDialog(parent),
GeometryStateDialog(parent),
ui(new Ui::CaptureInterfacesDialog)
{
ui->setupUi(this);
loadGeometry();
setWindowTitle(wsApp->windowTitleString(tr("Capture Interfaces")));
stat_timer_ = NULL;

View File

@ -27,7 +27,7 @@
#ifdef HAVE_LIBPCAP
#include <QDialog>
#include "geometry_state_dialog.h"
#include <QPushButton>
typedef struct if_stat_cache_s if_stat_cache_t;
@ -68,7 +68,7 @@ private slots:
void buffer_changed(int value);
};
class CaptureInterfacesDialog : public QDialog
class CaptureInterfacesDialog : public GeometryStateDialog
{
Q_OBJECT

View File

@ -71,15 +71,14 @@ enum {
static const QString new_rule_name_ = QObject::tr("New coloring rule");
ColoringRulesDialog::ColoringRulesDialog(QWidget *parent, QString add_filter) :
QDialog(parent),
GeometryStateDialog(parent),
ui(new Ui::ColoringRulesDialog),
conversation_colors_(NULL)
{
ui->setupUi(this);
setWindowTitle(wsApp->windowTitleString(QStringList() << tr("Coloring Rules") << get_profile_name()));
if (parent) loadGeometry(parent->width() * 2 / 3, parent->height() * 4 / 5);
// XXX Use recent settings instead
resize(parent->width() * 2 / 3, parent->height() * 4 / 5);
setWindowTitle(wsApp->windowTitleString(QStringList() << tr("Coloring Rules") << get_profile_name()));
ui->coloringRulesTreeWidget->setDragEnabled(true);
ui->coloringRulesTreeWidget->viewport()->setAcceptDrops(true);

View File

@ -22,7 +22,7 @@
#ifndef COLORING_RULES_DIALOG_H
#define COLORING_RULES_DIALOG_H
#include <QDialog>
#include "geometry_state_dialog.h"
class QAbstractButton;
class QTreeWidget;
@ -54,7 +54,7 @@ private slots:
void ruleNameChanged(const QString name);
};
class ColoringRulesDialog : public QDialog
class ColoringRulesDialog : public GeometryStateDialog
{
Q_OBJECT

View File

@ -35,12 +35,13 @@
#include <QPushButton>
CompiledFilterOutput::CompiledFilterOutput(QWidget *parent, QStringList &intList, QString &compile_filter) :
QDialog(parent),
GeometryStateDialog(parent),
intList_(intList),
compile_filter_(compile_filter),
ui(new Ui::CompiledFilterOutput)
{
ui->setupUi(this);
loadGeometry();
setAttribute(Qt::WA_DeleteOnClose, true);
ui->filterList->setCurrentFont(wsApp->monospaceFont());

View File

@ -22,8 +22,9 @@
#ifndef COMPILEDFILTEROUTPUT_H
#define COMPILEDFILTEROUTPUT_H
#include "geometry_state_dialog.h"
#include <config.h>
#include <QDialog>
#include <QList>
#include <QHash>
#include <QListWidgetItem>
@ -34,7 +35,7 @@ namespace Ui {
class CompiledFilterOutput;
}
class CompiledFilterOutput : public QDialog
class CompiledFilterOutput : public GeometryStateDialog
{
Q_OBJECT

View File

@ -33,16 +33,14 @@
#include "wireshark_application.h"
ConversationHashTablesDialog::ConversationHashTablesDialog(QWidget *parent) :
QDialog(parent),
GeometryStateDialog(parent),
ui(new Ui::ConversationHashTablesDialog)
{
ui->setupUi(this);
if (parent) loadGeometry(parent->width() * 3 / 4, parent->height() * 3 / 4);
setWindowTitle(wsApp->windowTitleString(tr("Dissector Tables")));
// XXX Use recent settings instead
if (parent) resize(parent->width() * 3 / 4, parent->height() * 3 / 4);
QString html;
html += "<h3>Conversation Hash Tables</h3>\n";

View File

@ -22,13 +22,13 @@
#ifndef CONVERSATION_HASH_TABLES_DIALOG_H
#define CONVERSATION_HASH_TABLES_DIALOG_H
#include <QDialog>
#include "geometry_state_dialog.h"
namespace Ui {
class ConversationHashTablesDialog;
}
class ConversationHashTablesDialog : public QDialog
class ConversationHashTablesDialog : public GeometryStateDialog
{
Q_OBJECT

View File

@ -71,7 +71,7 @@ typedef struct _table_item_t {
Q_DECLARE_METATYPE(table_item_t)
DecodeAsDialog::DecodeAsDialog(QWidget *parent, capture_file *cf, bool create_new) :
QDialog(parent),
GeometryStateDialog(parent),
ui(new Ui::DecodeAsDialog),
cap_file_(cf),
table_names_combo_box_(NULL),
@ -79,6 +79,8 @@ DecodeAsDialog::DecodeAsDialog(QWidget *parent, capture_file *cf, bool create_ne
cur_proto_combo_box_(NULL)
{
ui->setupUi(this);
loadGeometry();
setWindowTitle(wsApp->windowTitleString(tr("Decode As" UTF8_HORIZONTAL_ELLIPSIS)));
ui->deleteToolButton->setEnabled(false);

View File

@ -28,7 +28,7 @@
#include "cfile.h"
#include <QDialog>
#include "geometry_state_dialog.h"
#include <QMap>
#include <QAbstractButton>
@ -39,7 +39,7 @@ namespace Ui {
class DecodeAsDialog;
}
class DecodeAsDialog : public QDialog
class DecodeAsDialog : public GeometryStateDialog
{
Q_OBJECT

View File

@ -61,18 +61,17 @@ enum {
Q_DECLARE_METATYPE(header_field_info *)
DisplayFilterExpressionDialog::DisplayFilterExpressionDialog(QWidget *parent) :
QDialog(parent),
GeometryStateDialog(parent),
ui(new Ui::DisplayFilterExpressionDialog),
ftype_(FT_NONE),
field_(NULL)
{
ui->setupUi(this);
if (parent) loadGeometry(parent->width() * 2 / 3, parent->height());
setWindowTitle(wsApp->windowTitleString(tr("Display Filter Expression")));
setWindowIcon(wsApp->normalIcon());
// XXX Use recent settings instead
resize(parent->width() * 2 / 3, parent->height());
ui->fieldTreeWidget->setToolTip(ui->fieldLabel->toolTip());
ui->searchLineEdit->setToolTip(ui->searchLabel->toolTip());
ui->relationListWidget->setToolTip(ui->relationLabel->toolTip());

View File

@ -26,7 +26,7 @@
#include <epan/ftypes/ftypes.h>
#include <QDialog>
#include "geometry_state_dialog.h"
class QTreeWidgetItem;
struct true_false_string;
@ -37,7 +37,7 @@ namespace Ui {
class DisplayFilterExpressionDialog;
}
class DisplayFilterExpressionDialog : public QDialog
class DisplayFilterExpressionDialog : public GeometryStateDialog
{
Q_OBJECT

View File

@ -78,14 +78,13 @@ private:
};
DissectorTablesDialog::DissectorTablesDialog(QWidget *parent) :
QDialog(parent),
GeometryStateDialog(parent),
ui(new Ui::DissectorTablesDialog)
{
ui->setupUi(this);
setWindowTitle(wsApp->windowTitleString(tr("Dissector Tables")));
if (parent) loadGeometry(parent->width() * 3 / 4, parent->height() * 3 / 4);
// XXX Use recent settings instead
if (parent) resize(parent->width() * 3 / 4, parent->height() * 3 / 4);
setWindowTitle(wsApp->windowTitleString(tr("Dissector Tables")));
on_tableTreeWidget_itemSelectionChanged();

View File

@ -26,7 +26,7 @@
#include <epan/ftypes/ftypes.h>
#include <QDialog>
#include "geometry_state_dialog.h"
namespace Ui {
class DissectorTablesDialog;
@ -34,7 +34,7 @@ class DissectorTablesDialog;
class QTreeWidgetItem;
class DissectorTablesDialog : public QDialog
class DissectorTablesDialog : public GeometryStateDialog
{
Q_OBJECT

View File

@ -123,10 +123,11 @@ private:
};
EnabledProtocolsDialog::EnabledProtocolsDialog(QWidget *parent) :
QDialog(parent),
GeometryStateDialog(parent),
ui(new Ui::EnabledProtocolsDialog)
{
ui->setupUi(this);
loadGeometry();
setWindowTitle(wsApp->windowTitleString(tr("Enabled Protocols")));
void *cookie;

View File

@ -22,6 +22,7 @@
#ifndef ENABLED_PROTOCOLS_DIALOG_H
#define ENABLED_PROTOCOLS_DIALOG_H
#include "geometry_state_dialog.h"
#include "wireshark_dialog.h"
namespace Ui {
@ -32,7 +33,7 @@ struct _protocol;
class QAbstractButton;
class EnabledProtocolsDialog : public QDialog
class EnabledProtocolsDialog : public GeometryStateDialog
{
Q_OBJECT

View File

@ -143,10 +143,9 @@ ExpertInfoDialog::ExpertInfoDialog(QWidget &parent, CaptureFile &capture_file) :
// Clicking on an item jumps to its associated packet. Make the dialog
// narrow so that we avoid obscuring the packet list.
// XXX Use recent settings instead
int dlg_width = parent.width() * 3 / 5;
if (dlg_width < width()) dlg_width = width();
resize(dlg_width, parent.height());
loadGeometry(dlg_width, parent.height());
int one_em = fontMetrics().height();
ui->expertInfoTreeWidget->setColumnWidth(severity_col_, one_em * 25); // Arbitrary

View File

@ -53,11 +53,12 @@ fileset_dlg_add_file(fileset_entry *entry, void *window) {
}
FileSetDialog::FileSetDialog(QWidget *parent) :
QDialog(parent),
GeometryStateDialog(parent),
fs_ui_(new Ui::FileSetDialog),
close_button_(NULL)
{
fs_ui_->setupUi(this);
loadGeometry ();
fs_ui_->fileSetTree->headerItem();

View File

@ -29,7 +29,7 @@
#include "file.h"
#include "fileset.h"
#include <QDialog>
#include "geometry_state_dialog.h"
class QTreeWidgetItem;
@ -37,7 +37,7 @@ namespace Ui {
class FileSetDialog;
}
class FileSetDialog : public QDialog
class FileSetDialog : public GeometryStateDialog
{
Q_OBJECT

View File

@ -52,7 +52,7 @@ enum {
};
FilterDialog::FilterDialog(QWidget *parent, FilterType filter_type, const QString new_filter) :
QDialog(parent),
GeometryStateDialog(parent),
ui(new Ui::FilterDialog),
filter_type_(filter_type),
// syntax_worker_(NULL),
@ -60,11 +60,9 @@ FilterDialog::FilterDialog(QWidget *parent, FilterType filter_type, const QStrin
new_filter_(new_filter)
{
ui->setupUi(this);
if (parent) loadGeometry(parent->width() * 2 / 3, parent->height() * 2 / 3);
setWindowIcon(wsApp->normalIcon());
// XXX Use recent settings instead
resize(parent->width() * 2 / 3, parent->height() * 2 / 3);
ui->filterTreeWidget->setDragEnabled(true);
ui->filterTreeWidget->viewport()->setAcceptDrops(true);
ui->filterTreeWidget->setDropIndicatorShown(true);

View File

@ -22,7 +22,7 @@
#ifndef FILTER_DIALOG_H
#define FILTER_DIALOG_H
#include <QDialog>
#include "geometry_state_dialog.h"
//class CaptureFilterSyntaxWorker;
class FilterTreeDelegate;
@ -31,7 +31,7 @@ namespace Ui {
class FilterDialog;
}
class FilterDialog : public QDialog
class FilterDialog : public GeometryStateDialog
{
Q_OBJECT

View File

@ -76,6 +76,7 @@ FollowStreamDialog::FollowStreamDialog(QWidget &parent, CaptureFile &cf, follow_
use_regex_find_(false)
{
ui->setupUi(this);
loadGeometry(parent.width() * 2 / 3, parent.height());
switch(type)
{
@ -102,9 +103,6 @@ FollowStreamDialog::FollowStreamDialog(QWidget &parent, CaptureFile &cf, follow_
connect(ui->leFind, SIGNAL(useRegexFind(bool)), this, SLOT(useRegexFind(bool)));
// XXX Use recent settings instead
resize(parent.width() * 2 / 3, parent.height());
QComboBox *cbcs = ui->cbCharset;
cbcs->blockSignals(true);
cbcs->addItem(tr("ASCII"), SHOW_ASCII);

View File

@ -0,0 +1,101 @@
/* geometry_state_dialog.cpp
*
* 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 "geometry_state_dialog.h"
#include "qt_ui_utils.h"
#include "ui/recent.h"
#include "ui/ui_util.h"
GeometryStateDialog::GeometryStateDialog(QWidget *parent, Qt::WindowFlags f) :
QDialog(parent, f)
{
}
GeometryStateDialog::~GeometryStateDialog()
{
saveGeometry();
}
void GeometryStateDialog::loadGeometry(int width, int height, const QString &dialog_name)
{
window_geometry_t geom;
dialog_name_ = dialog_name.isEmpty() ? objectName() : dialog_name;
if (!dialog_name_.isEmpty() && window_geom_load(dialog_name_.toUtf8().constData(), &geom)) {
QRect recent_geom(geom.x, geom.y, geom.width, geom.height);
// Check if the dialog is visible on any screen
if (rect_on_screen(recent_geom)) {
move(recent_geom.topLeft());
resize(recent_geom.size());
} else {
// Not visible, move within a reasonable area and try size only
recent_geom.moveTopLeft(QPoint(50, 50));
if (rect_on_screen(recent_geom)) {
resize(recent_geom.size());
} else if (width > 0 && height > 0) {
// We're not visible on any screens, use defaults
resize(width, height);
}
}
if (geom.maximized) {
showFullScreen();
}
} else if (width > 0 && height > 0) {
// No saved geometry found, use defaults
resize(width, height);
}
}
void GeometryStateDialog::saveGeometry()
{
if (dialog_name_.isEmpty())
return;
window_geometry_t geom;
geom.key = NULL;
geom.set_pos = TRUE;
geom.x = pos().x();
geom.y = pos().y();
geom.set_size = TRUE;
geom.width = size().width();
geom.height = size().height();
geom.set_maximized = TRUE;
geom.maximized = isFullScreen();
window_geom_save(dialog_name_.toUtf8().constData(), &geom);
}
/*
* 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:
*/

View File

@ -0,0 +1,57 @@
/* geometry_state_dialog.h
*
* 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 GEOMETRY_STATE_DIALOG_H
#define GEOMETRY_STATE_DIALOG_H
#include <QDialog>
class GeometryStateDialog : public QDialog
{
Q_OBJECT
public:
explicit GeometryStateDialog(QWidget *parent, Qt::WindowFlags f = 0);
~GeometryStateDialog();
protected:
void loadGeometry(int width = 0, int height = 0, const QString &dialog_name = QString());
private:
void saveGeometry();
QString dialog_name_;
};
#endif // GEOMETRY_STATE_DIALOG_H
/*
* 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:
*/

View File

@ -212,10 +212,9 @@ Iax2AnalysisDialog::Iax2AnalysisDialog(QWidget &parent, CaptureFile &cf) :
port_dst_rev_(0)
{
ui->setupUi(this);
loadGeometry(parent.width() * 4 / 5, parent.height() * 4 / 5);
setWindowSubtitle(tr("IAX2 Stream Analysis"));
// XXX Use recent settings instead
resize(parent.width() * 4 / 5, parent.height() * 4 / 5);
ui->progressFrame->hide();
stream_ctx_menu_.addAction(ui->actionGoToPacket);

View File

@ -190,6 +190,8 @@ IOGraphDialog::IOGraphDialog(QWidget &parent, CaptureFile &cf) :
colors_(ColorUtils::graphColors())
{
ui->setupUi(this);
loadGeometry();
setWindowSubtitle(tr("IO Graphs"));
setAttribute(Qt::WA_DeleteOnClose, true);
QCustomPlot *iop = ui->ioPlot;

View File

@ -209,7 +209,7 @@ static void lbm_uimflow_get_analysis(capture_file * cfile, seq_analysis_info_t *
// - Help button and text
LBMUIMFlowDialog::LBMUIMFlowDialog(QWidget * parent, capture_file * cfile) :
QDialog(parent),
GeometryStateDialog(parent),
m_ui(new Ui::LBMUIMFlowDialog),
m_capture_file(cfile),
m_num_items(0),
@ -217,6 +217,8 @@ LBMUIMFlowDialog::LBMUIMFlowDialog(QWidget * parent, capture_file * cfile) :
m_node_label_width(20)
{
m_ui->setupUi(this);
if (parent) loadGeometry(parent->width(), parent->height() * 4 / 5);
QCustomPlot * sp = m_ui->sequencePlot;
m_sequence_diagram = new SequenceDiagram(sp->yAxis, sp->xAxis2, sp->yAxis2);
@ -263,12 +265,6 @@ LBMUIMFlowDialog::LBMUIMFlowDialog(QWidget * parent, capture_file * cfile) :
QPushButton * save_bt = m_ui->buttonBox->button(QDialogButtonBox::Save);
save_bt->setText(tr("Save As" UTF8_HORIZONTAL_ELLIPSIS));
// XXX Use recent settings instead
if (parent)
{
resize(parent->width(), parent->height() * 4 / 5);
}
connect(m_ui->horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(hScrollBarChanged(int)));
connect(m_ui->verticalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(vScrollBarChanged(int)));
connect(sp->xAxis2, SIGNAL(rangeChanged(QCPRange)), this, SLOT(xAxisChanged(QCPRange)));

View File

@ -34,9 +34,9 @@
#include "ui/tap-sequence-analysis.h"
#include "geometry_state_dialog.h"
#include "sequence_diagram.h"
#include <QDialog>
#include <QMenu>
namespace Ui
@ -44,7 +44,7 @@ namespace Ui
class LBMUIMFlowDialog;
}
class LBMUIMFlowDialog : public QDialog
class LBMUIMFlowDialog : public GeometryStateDialog
{
Q_OBJECT

View File

@ -469,6 +469,7 @@ LteMacStatisticsDialog::LteMacStatisticsDialog(QWidget &parent, CaptureFile &cf,
commonStatsCurrent_(false)
{
setWindowSubtitle(tr("LTE Mac Statistics"));
loadGeometry(parent.width() * 1, parent.height() * 3 / 4, "LTEMacStatisticsDialog");
clearCommonStats();
@ -507,10 +508,6 @@ LteMacStatisticsDialog::LteMacStatisticsDialog(QWidget &parent, CaptureFile &cf,
showRACHFilterCheckBox_ = new QCheckBox(tr("Include RACH frames in filter"));
filter_controls_grid->addWidget(showRACHFilterCheckBox_);
// XXX Use recent settings instead
resize(parent.width() * 1, parent.height() * 3 / 4);
// Will set whole-UE headings originally.
updateHeaderLabels();

View File

@ -64,9 +64,7 @@ LteRlcGraphDialog::LteRlcGraphDialog(QWidget &parent, CaptureFile &cf, bool chan
packet_num_(0)
{
ui->setupUi(this);
// XXX Use recent settings instead
resize(parent.width() * 4 / 5, parent.height() * 3 / 4);
loadGeometry(parent.width() * 4 / 5, parent.height() * 3 / 4);
QCustomPlot *rp = ui->rlcPlot;
rp->xAxis->setLabel(tr("Time"));

View File

@ -643,9 +643,7 @@ LteRlcStatisticsDialog::LteRlcStatisticsDialog(QWidget &parent, CaptureFile &cf,
packet_count_(0)
{
setWindowSubtitle(tr("LTE RLC Statistics"));
// XXX Use recent settings instead
resize((parent.width() * 5) / 5, (parent.height() * 3) / 4);
loadGeometry((parent.width() * 5) / 5, (parent.height() * 3) / 4, "LTERLCStatisticsDialog");
// Create a grid for filtering-related widgetsto also appear in layout.
int filter_controls_layout_idx = verticalLayout()->indexOf(filterLayout()->widget());

View File

@ -84,10 +84,11 @@ enum {
};
ManageInterfacesDialog::ManageInterfacesDialog(QWidget *parent) :
QDialog(parent),
GeometryStateDialog(parent),
ui(new Ui::ManageInterfacesDialog)
{
ui->setupUi(this);
loadGeometry();
#ifdef Q_OS_MAC
ui->addPipe->setAttribute(Qt::WA_MacSmallSize, true);

View File

@ -27,7 +27,7 @@
#include <glib.h>
#include "capture_opts.h"
#include <QDialog>
#include "geometry_state_dialog.h"
#include <QStyledItemDelegate>
class QTreeWidget;
@ -66,7 +66,7 @@ namespace Ui {
class ManageInterfacesDialog;
}
class ManageInterfacesDialog : public QDialog
class ManageInterfacesDialog : public GeometryStateDialog
{
Q_OBJECT

View File

@ -169,9 +169,7 @@ MulticastStatisticsDialog::MulticastStatisticsDialog(QWidget &parent, CaptureFil
TapParameterDialog(parent, cf)
{
setWindowSubtitle(tr("UDP Multicast Streams"));
// XXX Use recent settings instead
resize(parent.width() * 4 / 5, parent.height() * 3 / 4);
loadGeometry(parent.width() * 4 / 5, parent.height() * 3 / 4, "MulticastStatisticsDialog");
tapinfo_ = new mcaststream_tapinfo_t();
tapinfo_->user_data = this;

View File

@ -25,10 +25,11 @@
#include "wireshark_application.h"
PacketCommentDialog::PacketCommentDialog(QWidget *parent, QString comment) :
QDialog(parent),
GeometryStateDialog(parent),
pc_ui_(new Ui::PacketCommentDialog)
{
pc_ui_->setupUi(this);
loadGeometry();
setWindowTitle(wsApp->windowTitleString(tr("Packet Comment")));
pc_ui_->commentTextEdit->setPlainText(comment);

View File

@ -22,13 +22,13 @@
#ifndef PACKET_COMMENT_DIALOG_H
#define PACKET_COMMENT_DIALOG_H
#include <QDialog>
#include "geometry_state_dialog.h"
namespace Ui {
class PacketCommentDialog;
}
class PacketCommentDialog : public QDialog
class PacketCommentDialog : public GeometryStateDialog
{
Q_OBJECT

View File

@ -49,11 +49,9 @@ PacketDialog::PacketDialog(QWidget &parent, CaptureFile &cf, frame_data *fdata)
packet_data_(NULL)
{
ui->setupUi(this);
loadGeometry(parent.width() * 4 / 5, parent.height() * 4 / 5);
ui->hintLabel->setSmallText();
// XXX Use recent settings instead
resize(parent.width() * 4 / 5, parent.height() * 4 / 5);
setWindowSubtitle(tr("Packet %1").arg(fdata->num));
phdr_ = cap_file_.capFile()->phdr;

View File

@ -255,7 +255,7 @@ const int capture_item_ = 1;
const int pref_ptr_col_ = 0;
PreferencesDialog::PreferencesDialog(QWidget *parent) :
QDialog(parent),
GeometryStateDialog(parent),
pd_ui_(new Ui::PreferencesDialog),
cur_line_edit_(NULL),
cur_combo_box_(NULL)
@ -266,6 +266,8 @@ PreferencesDialog::PreferencesDialog(QWidget *parent) :
// Some classes depend on pref_ptr_to_pref_ so this MUST be called after
// fill_advanced_prefs.
pd_ui_->setupUi(this);
loadGeometry();
setWindowTitle(wsApp->windowTitleString(tr("Preferences")));
pd_ui_->advancedTree->invisibleRootItem()->addChildren(tmp_item.takeChildren());
QTreeWidgetItemIterator pref_it(pd_ui_->advancedTree, QTreeWidgetItemIterator::NoChildren);

View File

@ -30,7 +30,7 @@
#include "wireshark_application.h"
#include <QDialog>
#include "geometry_state_dialog.h"
#include <QTreeWidgetItem>
class QComboBox;
@ -42,7 +42,7 @@ namespace Ui {
class PreferencesDialog;
}
class PreferencesDialog : public QDialog
class PreferencesDialog : public GeometryStateDialog
{
Q_OBJECT

View File

@ -45,7 +45,7 @@
Q_DECLARE_METATYPE(GList *)
ProfileDialog::ProfileDialog(QWidget *parent) :
QDialog(parent),
GeometryStateDialog(parent),
pd_ui_(new Ui::ProfileDialog),
ok_button_(NULL)
{
@ -54,6 +54,7 @@ ProfileDialog::ProfileDialog(QWidget *parent) :
const gchar *profile_name = get_profile_name();
pd_ui_->setupUi(this);
loadGeometry();
setWindowTitle(wsApp->windowTitleString(tr("Configuration Profiles")));
ok_button_ = pd_ui_->buttonBox->button(QDialogButtonBox::Ok);

View File

@ -22,7 +22,7 @@
#ifndef PROFILE_DIALOG_H
#define PROFILE_DIALOG_H
#include <QDialog>
#include "geometry_state_dialog.h"
class QPushButton;
class QTreeWidgetItem;
@ -31,7 +31,7 @@ namespace Ui {
class ProfileDialog;
}
class ProfileDialog : public QDialog
class ProfileDialog : public GeometryStateDialog
{
Q_OBJECT

View File

@ -175,11 +175,9 @@ ProtocolHierarchyDialog::ProtocolHierarchyDialog(QWidget &parent, CaptureFile &c
ui(new Ui::ProtocolHierarchyDialog)
{
ui->setupUi(this);
loadGeometry(parent.width() * 4 / 5, parent.height() * 4 / 5);
setWindowSubtitle(tr("Protocol Hierarchy Statistics"));
// XXX Use recent settings instead
resize(parent.width() * 4 / 5, parent.height() * 4 / 5);
ui->hierStatsTreeWidget->setItemDelegateForColumn(pct_packets_col_, &percent_bar_delegate_);
ui->hierStatsTreeWidget->setItemDelegateForColumn(pct_bytes_col_, &percent_bar_delegate_);
ph_stats_t *ph_stats = ph_stats_new(cap_file_.capFile());

View File

@ -172,11 +172,12 @@ const QString no_entries_ = QObject::tr("No entries.");
const QString entry_count_ = QObject::tr("%1 entries.");
ResolvedAddressesDialog::ResolvedAddressesDialog(QWidget *parent, CaptureFile *capture_file) :
QDialog(NULL),
GeometryStateDialog(NULL),
ui(new Ui::ResolvedAddressesDialog),
file_name_(tr("[no file]"))
{
ui->setupUi(this);
if (parent) loadGeometry(parent->width() * 2 / 3, parent->height());
setAttribute(Qt::WA_DeleteOnClose, true);
QStringList title_parts = QStringList() << tr("Resolved Addresses");
@ -187,9 +188,6 @@ ResolvedAddressesDialog::ResolvedAddressesDialog(QWidget *parent, CaptureFile *c
}
setWindowTitle(wsApp->windowTitleString(title_parts));
// XXX Use recent settings instead
resize(parent->width() * 2 / 3, parent->height());
ui->plainTextEdit->setFont(wsApp->monospaceFont());
ui->plainTextEdit->setReadOnly(true);
ui->plainTextEdit->setWordWrapMode(QTextOption::NoWrap);

View File

@ -22,7 +22,7 @@
#ifndef RESOLVED_ADDRESSES_DIALOG_H
#define RESOLVED_ADDRESSES_DIALOG_H
#include <QDialog>
#include "geometry_state_dialog.h"
class CaptureFile;
class QTextBlock;
@ -31,7 +31,7 @@ namespace Ui {
class ResolvedAddressesDialog;
}
class ResolvedAddressesDialog : public QDialog
class ResolvedAddressesDialog : public GeometryStateDialog
{
Q_OBJECT

View File

@ -164,6 +164,7 @@ ResponseTimeDelayDialog::ResponseTimeDelayDialog(QWidget &parent, CaptureFile &c
QString subtitle = tr("%1 Response Time Delay Statistics")
.arg(proto_get_protocol_short_name(find_protocol_by_id(get_rtd_proto_id(rtd))));
setWindowSubtitle(subtitle);
loadGeometry(0, 0, "ResponseTimeDelayDialog");
QStringList header_names = QStringList()
<< tr("Type") << tr("Messages")

View File

@ -258,10 +258,9 @@ RtpAnalysisDialog::RtpAnalysisDialog(QWidget &parent, CaptureFile &cf, struct _r
num_streams_(0)
{
ui->setupUi(this);
loadGeometry(parent.width() * 4 / 5, parent.height() * 4 / 5);
setWindowSubtitle(tr("RTP Stream Analysis"));
// XXX Use recent settings instead
resize(parent.width() * 4 / 5, parent.height() * 4 / 5);
ui->progressFrame->hide();
player_button_ = RtpPlayerDialog::addPlayerButton(ui->buttonBox);

View File

@ -109,7 +109,7 @@ RtpPlayerDialog::RtpPlayerDialog(QWidget &parent, CaptureFile &cf) :
{
ui->setupUi(this);
setWindowTitle(wsApp->windowTitleString(tr("RTP Player")));
resize(parent.size());
loadGeometry(parent.width(), parent.height());
#ifdef QT_MULTIMEDIA_LIB
ui->splitter->setStretchFactor(0, 3);

View File

@ -221,12 +221,10 @@ RtpStreamDialog::RtpStreamDialog(QWidget &parent, CaptureFile &cf) :
need_redraw_(false)
{
ui->setupUi(this);
loadGeometry(parent.width() * 4 / 5, parent.height() * 2 / 3);
setWindowSubtitle(tr("RTP Streams"));
ui->streamTreeWidget->installEventFilter(this);
// XXX Use recent settings instead
resize(parent.width() * 4 / 5, parent.height() * 2 / 3);
ctx_menu_.addAction(ui->actionSelectNone);
ctx_menu_.addAction(ui->actionFindReverse);
ctx_menu_.addAction(ui->actionGoToSetup);

View File

@ -58,6 +58,8 @@ SequenceDialog::SequenceDialog(QWidget &parent, CaptureFile &cf, SequenceInfo *i
node_label_w_(20)
{
ui->setupUi(this);
loadGeometry(parent.width(), parent.height() * 4 / 5);
QCustomPlot *sp = ui->sequencePlot;
setWindowSubtitle(info_ ? tr("Call Flow") : tr("Flow"));
@ -120,9 +122,6 @@ SequenceDialog::SequenceDialog(QWidget &parent, CaptureFile &cf, SequenceInfo *i
QPushButton *save_bt = ui->buttonBox->button(QDialogButtonBox::Save);
save_bt->setText(tr("Save As" UTF8_HORIZONTAL_ELLIPSIS));
// XXX Use recent settings instead
resize(parent.width(), parent.height() * 4 / 5);
ProgressFrame::addToButtonBox(ui->buttonBox, &parent);
connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(hScrollBarChanged(int)));

View File

@ -180,6 +180,7 @@ ServiceResponseTimeDialog::ServiceResponseTimeDialog(QWidget &parent, CaptureFil
QString subtitle = QString("%1 Service Response Time Statistics")
.arg(proto_get_protocol_short_name(find_protocol_by_id(get_srt_proto_id(srt))));
setWindowSubtitle(subtitle);
loadGeometry(0, 0, "ServiceResponseTimeDialog");
// Add number of columns for this stats_tree
QStringList header_labels;

View File

@ -51,6 +51,7 @@ ShowPacketBytesDialog::ShowPacketBytesDialog(QWidget &parent, CaptureFile &cf) :
use_regex_find_(false)
{
ui->setupUi(this);
loadGeometry(parent.width() * 2 / 3, parent.height() * 3 / 4);
QString field_name = QString("%1 (%2)").arg(finfo_->hfinfo->name, finfo_->hfinfo->abbrev);
setWindowSubtitle (field_name);
@ -64,9 +65,6 @@ ShowPacketBytesDialog::ShowPacketBytesDialog(QWidget &parent, CaptureFile &cf) :
connect(ui->tePacketBytes, SIGNAL(showSelected(int,int)), this, SLOT(showSelected(int,int)));
connect(ui->leFind, SIGNAL(useRegexFind(bool)), this, SLOT(useRegexFind(bool)));
// XXX Use recent settings instead
resize(parent.width() * 2 / 3, parent.height());
ui->cbDecodeAs->blockSignals(true);
ui->cbDecodeAs->addItem(tr("None"), DecodeAsNone);
ui->cbDecodeAs->addItem(tr("Base64"), DecodeAsBASE64);

View File

@ -159,6 +159,7 @@ SimpleStatisticsDialog::SimpleStatisticsDialog(QWidget &parent, CaptureFile &cf,
stu_(stu)
{
setWindowSubtitle(stu_->title);
loadGeometry(0, 0, stu_->title);
QStringList header_labels;
for (int col = 0; col < (int) stu_->nfields; col++) {

View File

@ -67,6 +67,7 @@ StatsTreeDialog::StatsTreeDialog(QWidget &parent, CaptureFile &cf, const char *c
st_(NULL),
st_cfg_(NULL)
{
loadGeometry(800, height(), cfg_abbr);
st_cfg_ = stats_tree_get_cfg_by_abbr(cfg_abbr);
memset(&cfg_pr_, 0, sizeof(struct _tree_cfg_pres));
@ -135,7 +136,6 @@ void StatsTreeDialog::fillTree()
}
statsTreeWidget()->setColumnCount(header_labels.count());
statsTreeWidget()->setHeaderLabels(header_labels);
resize(st_->num_columns*80+80, height());
statsTreeWidget()->setSortingEnabled(false);
if (!registerTapListener(st_cfg_->tapname,

View File

@ -47,16 +47,14 @@
enum { name_col_, filter_col_, type_col_, descr_col_ };
SupportedProtocolsDialog::SupportedProtocolsDialog(QWidget *parent) :
QDialog(parent),
GeometryStateDialog(parent),
ui(new Ui::SupportedProtocolsDialog),
field_count_(0)
{
ui->setupUi(this);
if (parent) loadGeometry(parent->width() * 3 / 4, parent->height());
setWindowTitle(wsApp->windowTitleString(tr("Supported Protocols")));
// XXX Use recent settings instead
if (parent) resize(parent->width() * 3 / 4, parent->height());
// Some of our names are unreasonably long.
int one_em = fontMetrics().height();
ui->protoTreeWidget->setColumnWidth(name_col_, one_em * 15);

View File

@ -22,13 +22,13 @@
#ifndef SUPPORTED_PROTOCOLS_DIALOG_H
#define SUPPORTED_PROTOCOLS_DIALOG_H
#include <QDialog>
#include "geometry_state_dialog.h"
namespace Ui {
class SupportedProtocolsDialog;
}
class SupportedProtocolsDialog : public QDialog
class SupportedProtocolsDialog : public GeometryStateDialog
{
Q_OBJECT

View File

@ -80,9 +80,6 @@ TapParameterDialog::TapParameterDialog(QWidget &parent, CaptureFile &cf, int hel
{
ui->setupUi(this);
// XXX Use recent settings instead
resize(parent.width() * 2 / 3, parent.height() * 3 / 4);
// Only show a hint label if a subclass provides a hint.
ui->hintLabel->hide();

View File

@ -62,13 +62,11 @@ TrafficTableDialog::TrafficTableDialog(QWidget &parent, CaptureFile &cf, const c
filter_(filter)
{
ui->setupUi(this);
loadGeometry(parent.width(), parent.height() * 3 / 4);
ui->enabledTypesPushButton->setText(tr("%1 Types").arg(table_name));
setWindowSubtitle(QString("%1s").arg(table_name));
// XXX Use recent settings instead
resize(parent.width(), parent.height() * 3 / 4);
QMenu *copy_menu = new QMenu();
QAction *ca;
copy_bt_ = ui->buttonBox->addButton(tr("Copy"), QDialogButtonBox::ActionRole);

View File

@ -45,13 +45,14 @@
#include <QDebug>
UatDialog::UatDialog(QWidget *parent, epan_uat *uat) :
QDialog(parent),
GeometryStateDialog(parent),
ui(new Ui::UatDialog),
uat_(NULL),
cur_line_edit_(NULL),
cur_combo_box_(NULL)
{
ui->setupUi(this);
if (uat) loadGeometry(0, 0, uat->name);
ui->deleteToolButton->setEnabled(false);
ui->copyToolButton->setEnabled(false);

View File

@ -27,8 +27,7 @@
#include <glib.h>
#include "syntax_line_edit.h"
#include <QDialog>
#include "geometry_state_dialog.h"
class QComboBox;
class QPushButton;
@ -40,7 +39,7 @@ namespace Ui {
class UatDialog;
}
class UatDialog : public QDialog
class UatDialog : public GeometryStateDialog
{
Q_OBJECT

View File

@ -178,6 +178,8 @@ VoipCallsDialog::VoipCallsDialog(QWidget &parent, CaptureFile &cf, bool all_flow
parent_(parent)
{
ui->setupUi(this);
loadGeometry(parent.width() * 4 / 5, parent.height() * 2 / 3);
ui->callTreeWidget->sortByColumn(start_time_col_, Qt::AscendingOrder);
setWindowSubtitle(all_flows ? tr("SIP Flows") : tr("VoIP Calls"));
@ -187,9 +189,6 @@ VoipCallsDialog::VoipCallsDialog(QWidget &parent, CaptureFile &cf, bool all_flow
sequence_button_ = ui->buttonBox->addButton(tr("Flow Sequence"), QDialogButtonBox::ApplyRole);
player_button_ = RtpPlayerDialog::addPlayerButton(ui->buttonBox);
// XXX Use recent settings instead
resize(parent.width() * 4 / 5, parent.height() * 2 / 3);
memset (&tapinfo_, 0, sizeof(tapinfo_));
tapinfo_.tap_packet = tapPacket;
tapinfo_.tap_draw = tapDraw;

View File

@ -28,19 +28,21 @@
#include <epan/packet.h>
#include <epan/tap.h>
#include "wireshark_application.h"
#include "wireshark_dialog.h"
#include "qt_ui_utils.h"
#include "ui/recent.h"
#include "ui/ui_util.h"
#include <QMessageBox>
#include "wireshark_application.h"
// To do:
// - Use a dynamic property + Q_PROPERTY for the subtitle.
// - Save and load recent geometry.
// - Make our nested event loop more robust. See tryDeleteLater for details.
WiresharkDialog::WiresharkDialog(QWidget &, CaptureFile &capture_file) :
QDialog(NULL, Qt::Window),
GeometryStateDialog(NULL, Qt::Window),
cap_file_(capture_file),
file_closed_(false),
retap_depth_(0),

View File

@ -1,4 +1,4 @@
/* wireshark_dialog.cpp
/* wireshark_dialog.h
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
@ -39,10 +39,9 @@
// TapDialog might make sense as well.
#include "capture_file.h"
#include "geometry_state_dialog.h"
#include <QDialog>
class WiresharkDialog : public QDialog
class WiresharkDialog : public GeometryStateDialog
{
Q_OBJECT
@ -134,6 +133,7 @@ protected slots:
private:
void setWindowTitleFromSubtitle();
void tryDeleteLater();
QString subtitle_;

View File

@ -467,9 +467,7 @@ WlanStatisticsDialog::WlanStatisticsDialog(QWidget &parent, CaptureFile &cf, con
packet_count_(0)
{
setWindowSubtitle(tr("Wireless LAN Statistics"));
// XXX Use recent settings instead
resize(parent.width() * 4 / 5, parent.height() * 3 / 4);
loadGeometry(parent.width() * 4 / 5, parent.height() * 3 / 4, "WlanStatisticsDialog");
QStringList header_labels = QStringList()
<< "" << tr("Channel") << tr("SSID") << tr("Percent Packets") << "" << ""