diff options
author | Gerald Combs <gerald@zing.org> | 2016-06-05 14:33:06 -0700 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2016-06-06 15:24:16 +0000 |
commit | d3b5e922c257f234f096e161da819c1ed579efe9 (patch) | |
tree | 9ae029f387f85d8c54286edb3f693d7772b519b0 | |
parent | 89896f83d8d215e34037b1f323e93a8204f59af4 (diff) |
Qt: Add zoom to the flow / sequence dialog.
Add zoom in and zoom out actions. Changes only affect the X axis (the
spacing between the dashed lines).
Bug: 10693
Change-Id: I145e8501239f26e1be6135bffabdebec14f262c1
Reviewed-on: https://code.wireshark.org/review/15746
Reviewed-by: Gerald Combs <gerald@wireshark.org>
-rw-r--r-- | ui/qt/sequence_dialog.cpp | 39 | ||||
-rw-r--r-- | ui/qt/sequence_dialog.h | 3 | ||||
-rw-r--r-- | ui/qt/sequence_dialog.ui | 24 |
3 files changed, 63 insertions, 3 deletions
diff --git a/ui/qt/sequence_dialog.cpp b/ui/qt/sequence_dialog.cpp index 732e551b4b..28a8bb3b8c 100644 --- a/ui/qt/sequence_dialog.cpp +++ b/ui/qt/sequence_dialog.cpp @@ -53,7 +53,6 @@ // - Fake a splitter widget by catching mouse events in the plot area. // Drawing a QCPItemLine or QCPItemPixmap over each Y axis might make // this easier. -// - Add zoom controls. // - Add UTF8 to text dump // - Save to XMI? http://www.umlgraph.org/ // - Time: abs vs delta @@ -135,6 +134,8 @@ SequenceDialog::SequenceDialog(QWidget &parent, CaptureFile &cf, SequenceInfo *i ui->gridLayout->setSpacing(0); connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), sp->yAxis2, SLOT(setRange(QCPRange))); + ctx_menu_.addAction(ui->actionZoomIn); + ctx_menu_.addAction(ui->actionZoomOut); ctx_menu_.addAction(ui->actionReset); ctx_menu_.addSeparator(); ctx_menu_.addAction(ui->actionMoveRight10); @@ -208,6 +209,15 @@ void SequenceDialog::keyPressEvent(QKeyEvent *event) // XXX - Copy some shortcuts from tcp_stream_dialog.cpp switch(event->key()) { + case Qt::Key_Minus: + case Qt::Key_Underscore: // Shifted minus on U.S. keyboards + on_actionZoomOut_triggered(); + break; + case Qt::Key_Plus: + case Qt::Key_Equal: // Unshifted plus on U.S. keyboards + on_actionZoomIn_triggered(); + break; + case Qt::Key_Right: case Qt::Key_L: panAxes(pan_pixels, 0); @@ -402,7 +412,7 @@ void SequenceDialog::fillDiagram() seq_diagram_->setData(info_->sainfo()); } - sequence_w_ = one_em_ * 15 ; // Arbitrary + sequence_w_ = one_em_ * 15; // Arbitrary mouseMoved(NULL); resetAxes(); @@ -457,7 +467,7 @@ void SequenceDialog::resetAxes(bool keep_lower) left_pos = sp->xAxis2->range().lower; } - double range_span = sp->viewport().width() / sequence_w_; + double range_span = sp->viewport().width() / sequence_w_ * sp->axisRect()->rangeZoomFactor(Qt::Horizontal); sp->xAxis2->setRange(left_pos, range_span + left_pos); range_span = sp->axisRect()->height() / (one_em_ * 1.5); @@ -635,6 +645,29 @@ void SequenceDialog::on_actionMoveDown1_triggered() panAxes(0, -1); } +void SequenceDialog::on_actionZoomIn_triggered() +{ + zoomXAxis(true); +} + +void SequenceDialog::on_actionZoomOut_triggered() +{ + zoomXAxis(false); +} + +void SequenceDialog::zoomXAxis(bool in) +{ + QCustomPlot *sp = ui->sequencePlot; + double h_factor = sp->axisRect()->rangeZoomFactor(Qt::Horizontal); + + if (!in) { + h_factor = pow(h_factor, -1); + } + + sp->xAxis2->scaleRange(h_factor, sp->xAxis->range().lower); + sp->replot(); +} + SequenceInfo::SequenceInfo(seq_analysis_info_t *sainfo) : sainfo_(sainfo), count_(1) diff --git a/ui/qt/sequence_dialog.h b/ui/qt/sequence_dialog.h index 7113319959..52ce6e6e88 100644 --- a/ui/qt/sequence_dialog.h +++ b/ui/qt/sequence_dialog.h @@ -101,6 +101,8 @@ private slots: void on_actionMoveLeft1_triggered(); void on_actionMoveUp1_triggered(); void on_actionMoveDown1_triggered(); + void on_actionZoomIn_triggered(); + void on_actionZoomOut_triggered(); private: Ui::SequenceDialog *ui; @@ -114,6 +116,7 @@ private: QCPItemText *key_text_; QCPItemText *comment_text_; + void zoomXAxis(bool in); void panAxes(int x_pixels, int y_pixels); void resetAxes(bool keep_lower = false); void goToAdjacentPacket(bool next); diff --git a/ui/qt/sequence_dialog.ui b/ui/qt/sequence_dialog.ui index dcca122502..c4d59a4dbc 100644 --- a/ui/qt/sequence_dialog.ui +++ b/ui/qt/sequence_dialog.ui @@ -50,6 +50,8 @@ <h3>Valuable and amazing time-saving keyboard shortcuts</h3> <table><tbody> +<tr><th>+</th><td>Zoom in</td></th> +<tr><th>-</th><td>Zoom out</td></th> <tr><th>0</th><td>Reset graph to its initial state</td></th> <tr><th>→</th><td>Move right 10 pixels</td></th> @@ -228,6 +230,28 @@ <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> |