diff options
author | Gerald Combs <gerald@wireshark.org> | 2013-09-12 23:46:56 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2013-09-12 23:46:56 +0000 |
commit | 1ad683594d1cdd751cf3a81e71f3eb1091742a64 (patch) | |
tree | 9b196f844d79d00a14ba5b2767c2e39236f826f5 /ui | |
parent | e3ef5ac9fb84c407e72e6fde0325653cabf06737 (diff) |
Add a context menu to the TCP stream graph which includes all of our
keyboard shortcuts.
svn path=/trunk/; revision=51996
Diffstat (limited to 'ui')
-rw-r--r-- | ui/qt/tcp_stream_dialog.cpp | 220 | ||||
-rw-r--r-- | ui/qt/tcp_stream_dialog.h | 22 | ||||
-rw-r--r-- | ui/qt/tcp_stream_dialog.ui | 209 |
3 files changed, 403 insertions, 48 deletions
diff --git a/ui/qt/tcp_stream_dialog.cpp b/ui/qt/tcp_stream_dialog.cpp index c7ae4d8ae4..8e171c468f 100644 --- a/ui/qt/tcp_stream_dialog.cpp +++ b/ui/qt/tcp_stream_dialog.cpp @@ -105,6 +105,28 @@ TCPStreamDialog::TCPStreamDialog(QWidget *parent, capture_file *cf, tcp_graph_ty ui->dragRadioButton->setChecked(mouse_drags_); + ctx_menu_.addAction(ui->actionZoomIn); + ctx_menu_.addAction(ui->actionZoomOut); + ctx_menu_.addAction(ui->actionReset); + ctx_menu_.addSeparator(); + ctx_menu_.addAction(ui->actionMoveRight10); + ctx_menu_.addAction(ui->actionMoveLeft10); + ctx_menu_.addAction(ui->actionMoveUp10); + ctx_menu_.addAction(ui->actionMoveDown10); + ctx_menu_.addAction(ui->actionMoveRight1); + ctx_menu_.addAction(ui->actionMoveLeft1); + ctx_menu_.addAction(ui->actionMoveUp1); + ctx_menu_.addAction(ui->actionMoveDown1); + ctx_menu_.addSeparator(); + ctx_menu_.addAction(ui->actionNextStream); + ctx_menu_.addAction(ui->actionPreviousStream); + ctx_menu_.addAction(ui->actionSwitchDirection); + ctx_menu_.addAction(ui->actionGoToPacket); + ctx_menu_.addSeparator(); + ctx_menu_.addAction(ui->actionDragZoom); + ctx_menu_.addAction(ui->actionToggleSequenceNumbers); + ctx_menu_.addAction(ui->actionToggleTimeOrigin); + memset (&graph_, 0, sizeof(graph_)); graph_.type = graph_type; COPY_ADDRESS(&graph_.src_address, ¤t.ip_src); @@ -169,45 +191,37 @@ void TCPStreamDialog::showEvent(QShowEvent *event) void TCPStreamDialog::keyPressEvent(QKeyEvent *event) { - QCustomPlot *sp = ui->streamPlot; - double h_factor = sp->axisRect()->rangeZoomFactor(Qt::Horizontal); - double v_factor = sp->axisRect()->rangeZoomFactor(Qt::Vertical); - bool scale_range = false; + int pan_pixels = event->modifiers() & Qt::ShiftModifier ? 1 : 10; - double h_pan = 0.0; - double v_pan = 0.0; // XXX - This differs from the main window but matches other applications (e.g. Mozilla and Safari) switch(event->key()) { case Qt::Key_Minus: case Qt::Key_Underscore: // Shifted minus on U.S. keyboards case Qt::Key_O: // GTK+ - h_factor = pow(h_factor, -1); - v_factor = pow(v_factor, -1); - scale_range = true; + zoomAxes(false); break; case Qt::Key_Plus: case Qt::Key_Equal: // Unshifted plus on U.S. keyboards case Qt::Key_I: // GTK+ - scale_range = true; + zoomAxes(true); break; - // XXX Use pixel sizes instead case Qt::Key_Right: case Qt::Key_L: - h_pan = sp->xAxis->range().size() * 10.0 / sp->xAxis->axisRect()->width(); + panAxes(pan_pixels, 0); break; case Qt::Key_Left: case Qt::Key_H: - h_pan = sp->xAxis->range().size() * -10.0 / sp->xAxis->axisRect()->width(); + panAxes(-1 * pan_pixels, 0); break; case Qt::Key_Up: case Qt::Key_K: - v_pan = sp->yAxis->range().size() * 10.0 / sp->yAxis->axisRect()->height(); + panAxes(0, pan_pixels); break; case Qt::Key_Down: case Qt::Key_J: - v_pan = sp->yAxis->range().size() * -10.0 / sp->yAxis->axisRect()->height(); + panAxes(0, -1 * pan_pixels); break; case Qt::Key_Space: @@ -232,46 +246,21 @@ void TCPStreamDialog::keyPressEvent(QKeyEvent *event) on_otherDirectionButton_clicked(); break; case Qt::Key_G: - if (tracer_->visible() && cap_file_ && packet_num_ > 0) { - emit goToPacket(packet_num_); - } + on_actionGoToPacket_triggered(); break; case Qt::Key_S: - seq_origin_zero_ = seq_origin_zero_ ? false : true; - fillGraph(); + on_actionSwitchDirection_triggered(); break; case Qt::Key_T: - ts_origin_conn_ = ts_origin_conn_ ? false : true; - fillGraph(); + on_actionToggleTimeOrigin_triggered(); break; case Qt::Key_Z: - if (mouse_drags_) { - ui->selectRadioButton->toggle(); - } else { - ui->dragRadioButton->toggle(); - } + on_actionDragZoom_triggered(); break; // Alas, there is no Blade Runner-style Qt::Key_Enhance } - if (scale_range) { - sp->xAxis->scaleRange(h_factor, sp->xAxis->range().center()); - sp->yAxis->scaleRange(v_factor, sp->yAxis->range().center()); - sp->replot(); - } - - double pan_mul = event->modifiers() & Qt::ShiftModifier ? 0.1 : 1.0; - - // The GTK+ version won't pan unless we're zoomed. Should we do the same here? - if (h_pan) { - sp->xAxis->moveRange(h_pan * pan_mul); - sp->replot(); - } - if (v_pan) { - sp->yAxis->moveRange(v_pan * pan_mul); - sp->replot(); - } QDialog::keyPressEvent(event); // GTK+ Shortcuts: @@ -402,6 +391,41 @@ void TCPStreamDialog::fillGraph() tracer_->setGraph(sp->graph(0)); } +void TCPStreamDialog::zoomAxes(bool in) +{ + QCustomPlot *sp = ui->streamPlot; + double h_factor = sp->axisRect()->rangeZoomFactor(Qt::Horizontal); + double v_factor = sp->axisRect()->rangeZoomFactor(Qt::Vertical); + + if (!in) { + h_factor = pow(h_factor, -1); + v_factor = pow(v_factor, -1); + } + + sp->xAxis->scaleRange(h_factor, sp->xAxis->range().center()); + sp->yAxis->scaleRange(v_factor, sp->yAxis->range().center()); + sp->replot(); +} + +void TCPStreamDialog::panAxes(int x_pixels, int y_pixels) +{ + QCustomPlot *sp = ui->streamPlot; + double h_pan = 0.0; + double v_pan = 0.0; + + h_pan = sp->xAxis->range().size() * x_pixels / sp->xAxis->axisRect()->width(); + v_pan = sp->yAxis->range().size() * y_pixels / sp->yAxis->axisRect()->height(); + // The GTK+ version won't pan unless we're zoomed. Should we do the same here? + if (h_pan) { + sp->xAxis->moveRange(h_pan); + sp->replot(); + } + if (v_pan) { + sp->yAxis->moveRange(v_pan); + sp->replot(); + } +} + void TCPStreamDialog::resetAxes() { QCustomPlot *sp = ui->streamPlot; @@ -682,13 +706,15 @@ void TCPStreamDialog::graphClicked(QMouseEvent *event) Q_UNUSED(event) QCustomPlot *sp = ui->streamPlot; - if (mouse_drags_) { + if (event->button() == Qt::RightButton) { + // XXX We should find some way to get streamPlot to handle a + // contextMenuEvent instead. + ctx_menu_.exec(event->globalPos()); + } else if (mouse_drags_) { if (sp->axisRect()->rect().contains(event->pos())) { sp->setCursor(QCursor(Qt::ClosedHandCursor)); } - if (tracer_->visible() && cap_file_ && packet_num_ > 0) { - emit goToPacket(packet_num_); - } + on_actionGoToPacket_triggered(); } else { if (!rubber_band_) { rubber_band_ = new QRubberBand(QRubberBand::Rectangle, ui->streamPlot); @@ -956,6 +982,104 @@ void TCPStreamDialog::on_selectRadioButton_toggled(bool checked) ui->streamPlot->setInteractions(0); } +void TCPStreamDialog::on_actionZoomIn_triggered() +{ + zoomAxes(true); +} + +void TCPStreamDialog::on_actionZoomOut_triggered() +{ + zoomAxes(false); +} + +void TCPStreamDialog::on_actionReset_triggered() +{ + on_resetButton_clicked(); +} + +void TCPStreamDialog::on_actionMoveRight10_triggered() +{ + panAxes(10, 0); +} + +void TCPStreamDialog::on_actionMoveLeft10_triggered() +{ + panAxes(-10, 0); +} + +void TCPStreamDialog::on_actionMoveUp10_triggered() +{ + panAxes(0, 10); +} + +void TCPStreamDialog::on_actionMoveDown10_triggered() +{ + panAxes(0, -10); +} + +void TCPStreamDialog::on_actionMoveRight1_triggered() +{ + panAxes(1, 0); +} + +void TCPStreamDialog::on_actionMoveLeft1_triggered() +{ + panAxes(-1, 0); +} + +void TCPStreamDialog::on_actionMoveUp1_triggered() +{ + panAxes(0, 1); +} + +void TCPStreamDialog::on_actionMoveDown1_triggered() +{ + panAxes(0, -1); +} + +void TCPStreamDialog::on_actionNextStream_triggered() +{ + on_nextStreamPushButton_clicked(); +} + +void TCPStreamDialog::on_actionPreviousStream_triggered() +{ + on_prevStreamPushButton_clicked(); +} + +void TCPStreamDialog::on_actionSwitchDirection_triggered() +{ + on_otherDirectionButton_clicked(); +} + +void TCPStreamDialog::on_actionGoToPacket_triggered() +{ + if (tracer_->visible() && cap_file_ && packet_num_ > 0) { + emit goToPacket(packet_num_); + } +} + +void TCPStreamDialog::on_actionDragZoom_triggered() +{ + if (mouse_drags_) { + ui->selectRadioButton->toggle(); + } else { + ui->dragRadioButton->toggle(); + } +} + +void TCPStreamDialog::on_actionToggleSequenceNumbers_triggered() +{ + seq_origin_zero_ = seq_origin_zero_ ? false : true; + fillGraph(); +} + +void TCPStreamDialog::on_actionToggleTimeOrigin_triggered() +{ + ts_origin_conn_ = ts_origin_conn_ ? false : true; + fillGraph(); +} + /* * Editor modelines * diff --git a/ui/qt/tcp_stream_dialog.h b/ui/qt/tcp_stream_dialog.h index 7be1e2fc07..49c603239a 100644 --- a/ui/qt/tcp_stream_dialog.h +++ b/ui/qt/tcp_stream_dialog.h @@ -36,6 +36,7 @@ #include "qcustomplot.h" #include <QDialog> +#include <QMenu> #include <QRubberBand> namespace Ui { @@ -79,12 +80,15 @@ private: bool mouse_drags_; QRubberBand *rubber_band_; QPoint rb_origin_; + QMenu ctx_menu_; int num_dsegs_; int num_acks_; int num_sack_ranges_; void fillGraph(); + void zoomAxes(bool in); + void panAxes(int x_pixels, int y_pixels); void resetAxes(); void fillStevens(); void fillThroughput(); @@ -109,6 +113,24 @@ private slots: void on_otherDirectionButton_clicked(); void on_dragRadioButton_toggled(bool checked); void on_selectRadioButton_toggled(bool checked); + void on_actionZoomIn_triggered(); + void on_actionZoomOut_triggered(); + void on_actionReset_triggered(); + void on_actionMoveRight10_triggered(); + void on_actionMoveLeft10_triggered(); + void on_actionMoveUp10_triggered(); + void on_actionMoveDown10_triggered(); + void on_actionMoveRight1_triggered(); + void on_actionMoveLeft1_triggered(); + void on_actionMoveUp1_triggered(); + void on_actionMoveDown1_triggered(); + void on_actionNextStream_triggered(); + void on_actionPreviousStream_triggered(); + void on_actionSwitchDirection_triggered(); + void on_actionGoToPacket_triggered(); + void on_actionDragZoom_triggered(); + void on_actionToggleSequenceNumbers_triggered(); + void on_actionToggleTimeOrigin_triggered(); }; #endif // TCP_STREAM_DIALOG_H diff --git a/ui/qt/tcp_stream_dialog.ui b/ui/qt/tcp_stream_dialog.ui index 844b577ac0..3197aed6ae 100644 --- a/ui/qt/tcp_stream_dialog.ui +++ b/ui/qt/tcp_stream_dialog.ui @@ -202,6 +202,215 @@ </widget> </item> </layout> + <action name="actionReset"> + <property name="text"> + <string>Reset Graph</string> + </property> + <property name="toolTip"> + <string>Reset the graph to its initial state.</string> + </property> + <property name="shortcut"> + <string>0</string> + </property> + </action> + <action name="actionZoomIn"> + <property name="text"> + <string>Zoom In</string> + </property> + <property name="toolTip"> + <string>Zoom in</string> + </property> + <property name="shortcut"> + <string>+</string> + </property> + </action> + <action name="actionZoomOut"> + <property name="text"> + <string>Zoom Out</string> + </property> + <property name="toolTip"> + <string>Zoom out</string> + </property> + <property name="shortcut"> + <string>-</string> + </property> + </action> + <action name="actionMoveUp10"> + <property name="text"> + <string>Move Up 10 Pixels</string> + </property> + <property name="toolTip"> + <string>Move up 10 pixels</string> + </property> + <property name="shortcut"> + <string>Up</string> + </property> + </action> + <action name="actionMoveLeft10"> + <property name="text"> + <string>Move Left 10 Pixels</string> + </property> + <property name="toolTip"> + <string>Move left 10 pixels</string> + </property> + <property name="shortcut"> + <string>Left</string> + </property> + </action> + <action name="actionMoveRight10"> + <property name="text"> + <string>Move Right 10 Pixels</string> + </property> + <property name="toolTip"> + <string>Move right 10 pixels</string> + </property> + <property name="shortcut"> + <string>Right</string> + </property> + </action> + <action name="actionMoveDown10"> + <property name="text"> + <string>Move Down 10 Pixels</string> + </property> + <property name="toolTip"> + <string>Move down 10 pixels</string> + </property> + <property name="shortcut"> + <string>Down</string> + </property> + </action> + <action name="actionMoveUp1"> + <property name="text"> + <string>Move Up 1 Pixel</string> + </property> + <property name="toolTip"> + <string>Move up 1 pixel</string> + </property> + <property name="shortcut"> + <string>Shift+Up</string> + </property> + </action> + <action name="actionMoveLeft1"> + <property name="text"> + <string>Move Left 1 Pixel</string> + </property> + <property name="toolTip"> + <string>Move left 1 pixel</string> + </property> + <property name="shortcut"> + <string>Shift+Left</string> + </property> + </action> + <action name="actionMoveRight1"> + <property name="text"> + <string>Move Right 1 Pixel</string> + </property> + <property name="toolTip"> + <string>Move right 1 pixel</string> + </property> + <property name="shortcut"> + <string>Shift+Right</string> + </property> + </action> + <action name="actionMoveDown1"> + <property name="text"> + <string>Move Down 1 Pixel</string> + </property> + <property name="toolTip"> + <string>Move down 1 pixel</string> + </property> + <property name="shortcut"> + <string>Shift+Down</string> + </property> + </action> + <action name="actionNextStream"> + <property name="text"> + <string>Next Stream</string> + </property> + <property name="toolTip"> + <string>Go to the next stream in the capture</string> + </property> + <property name="shortcut"> + <string>PgUp</string> + </property> + </action> + <action name="actionPreviousStream"> + <property name="text"> + <string>Previous Stream</string> + </property> + <property name="toolTip"> + <string>Go to the previous stream in the capture</string> + </property> + <property name="shortcut"> + <string>PgDown</string> + </property> + </action> + <action name="actionSwitchDirection"> + <property name="text"> + <string>Switch Direction</string> + </property> + <property name="toolTip"> + <string>Switch direction (swap TCP endpoints)</string> + </property> + <property name="shortcut"> + <string>D</string> + </property> + </action> + <action name="actionGoToPacket"> + <property name="text"> + <string>Go To Packet Under Cursor</string> + </property> + <property name="toolTip"> + <string>Go to packet currently under the cursor</string> + </property> + <property name="shortcut"> + <string>G</string> + </property> + </action> + <action name="actionDragZoom"> + <property name="text"> + <string>Drag / Zoom</string> + </property> + <property name="toolTip"> + <string>Toggle mouse drag / zoom behavior</string> + </property> + <property name="shortcut"> + <string>Z</string> + </property> + </action> + <action name="actionToggleSequenceNumbers"> + <property name="text"> + <string>Relative / Absolute Sequence Numbers</string> + </property> + <property name="toolTip"> + <string>Toggle relative / absolute sequence numbers</string> + </property> + <property name="shortcut"> + <string>S</string> + </property> + </action> + <action name="actionToggleTimeOrigin"> + <property name="text"> + <string>Capture / Session Time Origin</string> + </property> + <property name="toolTip"> + <string>Toggle capture / session time origin</string> + </property> + <property name="shortcut"> + <string>T</string> + </property> + </action> + <action name="actionCrosshairs"> + <property name="text"> + <string>Crosshairs</string> + </property> + <property name="toolTip"> + <string>Toggle crosshairs</string> + </property> + <property name="shortcut"> + <string>Space</string> + </property> + </action> </widget> <customwidgets> <customwidget> |