aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Mathieson <martin.r.mathieson@googlemail.com>2017-12-16 21:01:19 +0000
committerAnders Broman <a.broman58@gmail.com>2017-12-17 08:02:34 +0000
commitcd573915eafd49cd3cb41e40a0d59acab4f49583 (patch)
tree2fc4acbf71dc0a9be0cb11bd1c95783d58236817
parentb1f558ae278cb1b90f6e06a9cc4031227b47fd31 (diff)
LTE RLC graph: export graph as image, like TCP stream does
Change-Id: I8709f7c09528a44a9729a06ea2ba4d6f99dbeccb Reviewed-on: https://code.wireshark.org/review/24864 Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r--ui/qt/lte_rlc_graph_dialog.cpp49
-rw-r--r--ui/qt/lte_rlc_graph_dialog.h2
2 files changed, 49 insertions, 2 deletions
diff --git a/ui/qt/lte_rlc_graph_dialog.cpp b/ui/qt/lte_rlc_graph_dialog.cpp
index ed86aab..c565f05 100644
--- a/ui/qt/lte_rlc_graph_dialog.cpp
+++ b/ui/qt/lte_rlc_graph_dialog.cpp
@@ -36,6 +36,7 @@
#include <QMenu>
#include <QRubberBand>
+#include <wsutil/utf8_entities.h>
#include <ui/qt/utils/qt_ui_utils.h>
#include "wireshark_application.h"
#include "simple_dialog.h"
@@ -44,7 +45,6 @@
#include <ui/tap-rlc-graph.h>
-// TODO:
const QRgb graph_color_ack = tango_sky_blue_4; // Blue for ACK lines
const QRgb graph_color_nack = tango_scarlet_red_3; // Red for NACKs
@@ -112,7 +112,6 @@ LteRlcGraphDialog::LteRlcGraphDialog(QWidget &parent, CaptureFile &cf, bool chan
if (!channelKnown) {
completeGraph();
}
-
}
// Destructor
@@ -178,9 +177,15 @@ void LteRlcGraphDialog::completeGraph(bool may_be_empty)
tracer_->setVisible(false);
toggleTracerStyle(true);
+ // Change label on save/export button.
+ QPushButton *save_bt = ui->buttonBox->button(QDialogButtonBox::Save);
+ save_bt->setText(tr("Save As" UTF8_HORIZONTAL_ELLIPSIS));
+
connect(rp, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(graphClicked(QMouseEvent*)));
connect(rp, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoved(QMouseEvent*)));
connect(rp, SIGNAL(mouseRelease(QMouseEvent*)), this, SLOT(mouseReleased(QMouseEvent*)));
+ disconnect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
+ this->setResult(QDialog::Accepted);
// Extract the data that the graph can use.
fillGraph();
@@ -840,6 +845,46 @@ void LteRlcGraphDialog::on_otherDirectionButton_clicked()
on_actionSwitchDirection_triggered();
}
+// Prompt for filename/format to save graph to.
+// N.B. Copied from tcp_stream_dialog.cpp
+void LteRlcGraphDialog::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, wsApp->windowTitleString(tr("Save Graph As" UTF8_HORIZONTAL_ELLIPSIS)),
+ path.canonicalPath(), filter, &extension);
+
+ if (file_name.length() > 0) {
+ bool save_ok = false;
+ if (extension.compare(pdf_filter) == 0) {
+ save_ok = ui->rlcPlot->savePdf(file_name);
+ } else if (extension.compare(png_filter) == 0) {
+ save_ok = ui->rlcPlot->savePng(file_name);
+ } else if (extension.compare(bmp_filter) == 0) {
+ save_ok = ui->rlcPlot->saveBmp(file_name);
+ } else if (extension.compare(jpeg_filter) == 0) {
+ save_ok = ui->rlcPlot->saveJpg(file_name);
+ }
+ // else error dialog?
+ if (save_ok) {
+ path = QDir(file_name);
+ wsApp->setLastOpenDir(path.canonicalPath().toUtf8().constData());
+ }
+ }
+}
+
+
// No need to register tap listeners here. This is done
// in calls to the common functions in ui/tap-rlc-graph.c
diff --git a/ui/qt/lte_rlc_graph_dialog.h b/ui/qt/lte_rlc_graph_dialog.h
index 2929312..9d3d05e 100644
--- a/ui/qt/lte_rlc_graph_dialog.h
+++ b/ui/qt/lte_rlc_graph_dialog.h
@@ -121,6 +121,8 @@ private slots:
void on_actionGoToPacket_triggered();
void on_actionCrosshairs_triggered();
void on_actionSwitchDirection_triggered();
+
+ void on_buttonBox_accepted();
};
#endif // LTE_RLC_GRAPH_DIALOG_H