aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/tcp_stream_dialog.cpp
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2013-08-30 23:01:03 +0000
committerGerald Combs <gerald@wireshark.org>2013-08-30 23:01:03 +0000
commit01f7a0425b20dc7b635226ea0d4cb1f803e376a9 (patch)
tree4dd67564cc4ac37f293592918ac443e5e58738d3 /ui/qt/tcp_stream_dialog.cpp
parent17cbb2c36e7e512afb18677bb1412afb5d5778a3 (diff)
Implement "Save As..." in the TCP stream graph dialog. We currently
support PDF, PNG, BMP, and JPEG. svn path=/trunk/; revision=51607
Diffstat (limited to 'ui/qt/tcp_stream_dialog.cpp')
-rw-r--r--ui/qt/tcp_stream_dialog.cpp49
1 files changed, 48 insertions, 1 deletions
diff --git a/ui/qt/tcp_stream_dialog.cpp b/ui/qt/tcp_stream_dialog.cpp
index 04a45a6cd5..5eec0faca9 100644
--- a/ui/qt/tcp_stream_dialog.cpp
+++ b/ui/qt/tcp_stream_dialog.cpp
@@ -28,8 +28,13 @@
#include "ui/utf8_entities.h"
+#include "wireshark_application.h"
#include "tango_colors.h"
+#include <QDir>
+#include <QFileDialog>
+#include <QPushButton>
+
#include <QDebug>
TCPStreamDialog::TCPStreamDialog(QWidget *parent, capture_file *cf, tcp_graph_type graph_type) :
@@ -85,6 +90,8 @@ TCPStreamDialog::TCPStreamDialog(QWidget *parent, capture_file *cf, tcp_graph_ty
}
QCustomPlot *sp = ui->streamPlot;
+ sp->plotLayout()->insertRow(0);
+ sp->plotLayout()->addElement(0, 0, new QCPPlotTitle(sp, dlg_title));
sp->addGraph();
sp->graph(0)->setData(rel_time, seq);
sp->setInteractions(
@@ -118,9 +125,12 @@ TCPStreamDialog::TCPStreamDialog(QWidget *parent, capture_file *cf, tcp_graph_ty
// XXX - QCustomPlot doesn't seem to draw any sort of focus indicator.
sp->setFocus();
+ QPushButton *save_bt = ui->buttonBox->button(QDialogButtonBox::Save);
+ save_bt->setText(tr("Save As..."));
+
connect(sp, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(graphClicked(QMouseEvent*)));
connect(sp, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoved(QMouseEvent*)));
-// connect(sp, SIGNAL(mou))
+ disconnect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
}
TCPStreamDialog::~TCPStreamDialog()
@@ -284,6 +294,43 @@ void TCPStreamDialog::mouseMoved(QMouseEvent *event)
ui->streamPlot->replot();
}
+void TCPStreamDialog::on_buttonBox_accepted()
+{
+ QString file_name, extension;
+ QDir path(wsApp->lastOpenDir());
+ QString pdf_filter = tr("Portable Document Format (*.pdf)");
+ QString png_filter = tr("Portable Network Graphics (*.png)");
+ QString bmp_filter = tr("Windows Bitmap (*.bmp)");
+ // Gaze upon my beautiful graph with lossy artifacts!
+ QString jpeg_filter = tr("JPEG File Interchange Format (*.jpeg *.jpg)");
+ QString filter = QString("%1;;%2;;%3;;%4")
+ .arg(pdf_filter)
+ .arg(png_filter)
+ .arg(bmp_filter)
+ .arg(jpeg_filter);
+
+ file_name = QFileDialog::getSaveFileName(this, tr("Wireshark: Save Graph As..."),
+ path.canonicalPath(), filter, &extension);
+
+ if (file_name.length() > 0) {
+ bool save_ok = false;
+ if (extension.compare(pdf_filter) == 0) {
+ save_ok = ui->streamPlot->savePdf(file_name);
+ } else if (extension.compare(png_filter) == 0) {
+ save_ok = ui->streamPlot->savePng(file_name);
+ } else if (extension.compare(bmp_filter) == 0) {
+ save_ok = ui->streamPlot->saveBmp(file_name);
+ } else if (extension.compare(jpeg_filter) == 0) {
+ save_ok = ui->streamPlot->saveJpg(file_name);
+ }
+ // else error dialog?
+ if (save_ok) {
+ path = QDir(file_name);
+ wsApp->setLastOpenDir(path.canonicalPath().toUtf8().constData());
+ }
+ }
+}
+
/*
* Editor modelines
*