From 583fe0b97e04ea50e3c69afab20c59fc9253c8d3 Mon Sep 17 00:00:00 2001 From: sdbbs Date: Thu, 29 Oct 2020 18:14:07 +0100 Subject: [PATCH 1/5] implemented Ctrl-M and Ctrl-N as keyboard shortcuts for "full page" (entire extents) scroll of view, right and left scroll respectively --- pv/views/trace/view.cpp | 39 +++++++++++++++++++++++++++++++++++++++ pv/views/trace/view.hpp | 6 ++++++ 2 files changed, 45 insertions(+) diff --git a/pv/views/trace/view.cpp b/pv/views/trace/view.cpp index 47cb96b2d..f9213d9ca 100644 --- a/pv/views/trace/view.cpp +++ b/pv/views/trace/view.cpp @@ -236,6 +236,14 @@ View::View(Session &session, bool is_main_view, QMainWindow *parent) : SLOT(on_scroll_to_end_shortcut_triggered()), nullptr, Qt::WidgetWithChildrenShortcut); end_shortcut_->setAutoRepeat(false); + scroll_view_left_ = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_N), this, + SLOT(on_h_scroll_view_left_triggered()), nullptr, Qt::WidgetWithChildrenShortcut); + scroll_view_left_->setAutoRepeat(false); + + scroll_view_right_ = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_M), this, + SLOT(on_h_scroll_view_right_triggered()), nullptr, Qt::WidgetWithChildrenShortcut); + scroll_view_right_->setAutoRepeat(false); + grab_ruler_left_shortcut_ = new QShortcut(QKeySequence(Qt::Key_1), this, nullptr, nullptr, Qt::WidgetWithChildrenShortcut); connect(grab_ruler_left_shortcut_, &QShortcut::activated, @@ -1397,6 +1405,27 @@ void View::set_scroll_default() set_v_offset(extents.first); } +void View::h_scroll_view_fullpage(int direction) +{ + if (updating_scroll_) + return; + + // Disable sticky scrolling when user moves the horizontal scroll bar + // during a running acquisition + if (sticky_scrolling_ && (session_.get_capture_state() == Session::Running)) { + sticky_scrolling_ = false; + sticky_scrolling_changed(false); + } + + const QSize areaSize = viewport_->size(); + double length = scale_ * areaSize.width(); + Timestamp new_offset = offset_ + direction*length; + set_offset(new_offset); + + ruler_->update(); + viewport_->update(); +} + void View::determine_if_header_was_shrunk() { const int header_pane_width = @@ -1738,6 +1767,16 @@ void View::on_scroll_to_end_shortcut_triggered() set_h_offset(get_h_scrollbar_maximum()); } +void View::on_h_scroll_view_left_triggered() +{ + h_scroll_view_fullpage(-1); +} + +void View::on_h_scroll_view_right_triggered() +{ + h_scroll_view_fullpage(1); +} + void View::h_scroll_value_changed(int value) { if (updating_scroll_) diff --git a/pv/views/trace/view.hpp b/pv/views/trace/view.hpp index f8506cf40..f0b163f69 100644 --- a/pv/views/trace/view.hpp +++ b/pv/views/trace/view.hpp @@ -423,6 +423,8 @@ public Q_SLOTS: void update_view_range_metaobject() const; void update_hover_point(); + void h_scroll_view_fullpage(int direction); + public: void row_item_appearance_changed(bool label, bool content); void time_item_appearance_changed(bool label, bool content); @@ -437,6 +439,8 @@ private Q_SLOTS: void on_zoom_out_shortcut_triggered(); void on_scroll_to_start_shortcut_triggered(); void on_scroll_to_end_shortcut_triggered(); + void on_h_scroll_view_left_triggered(); + void on_h_scroll_view_right_triggered(); void h_scroll_value_changed(int value); void v_scroll_value_changed(); @@ -509,6 +513,8 @@ private Q_SLOTS: QShortcut *home_shortcut_, *end_shortcut_; QShortcut *grab_ruler_left_shortcut_, *grab_ruler_right_shortcut_; QShortcut *cancel_grab_shortcut_; + QShortcut *scroll_view_left_; + QShortcut *scroll_view_right_; mutable mutex signal_mutex_; vector< shared_ptr > signals_; From 5dd0af07bb851a8f53f882c8c639ea109d681864 Mon Sep 17 00:00:00 2001 From: sdbbs Date: Thu, 29 Oct 2020 20:55:52 +0100 Subject: [PATCH 2/5] implemented Ctrl-B as keyboard shortcut for capturing .png bitmap screenshots, only of viewport and ruler, to temporary directory --- pv/views/trace/view.cpp | 25 +++++++++++++++++++++++++ pv/views/trace/view.hpp | 2 ++ 2 files changed, 27 insertions(+) diff --git a/pv/views/trace/view.cpp b/pv/views/trace/view.cpp index f9213d9ca..acf7dcd95 100644 --- a/pv/views/trace/view.cpp +++ b/pv/views/trace/view.cpp @@ -38,6 +38,8 @@ #include #include #include +#include +#include #include @@ -244,6 +246,10 @@ View::View(Session &session, bool is_main_view, QMainWindow *parent) : SLOT(on_h_scroll_view_right_triggered()), nullptr, Qt::WidgetWithChildrenShortcut); scroll_view_right_->setAutoRepeat(false); + bitmap_screenshot_ = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_B), this, + SLOT(on_bitmap_screenshot_triggered()), nullptr, Qt::WidgetWithChildrenShortcut); + bitmap_screenshot_->setAutoRepeat(false); + grab_ruler_left_shortcut_ = new QShortcut(QKeySequence(Qt::Key_1), this, nullptr, nullptr, Qt::WidgetWithChildrenShortcut); connect(grab_ruler_left_shortcut_, &QShortcut::activated, @@ -1777,6 +1783,25 @@ void View::on_h_scroll_view_right_triggered() h_scroll_view_fullpage(1); } +void View::on_bitmap_screenshot_triggered() +{ + //note: viewport_ does not contain track name markings at left, nor ruler + //scrollarea_ is the same, except with added scrollbars + //here we will get only viewport_ and ruler_, so as to assist in stitching/appending images + QSize vpSize = viewport_->size(); + QSize rlSize = ruler_->size(); + QSize imgsize(vpSize.width(), vpSize.height()+rlSize.height()); + QImage img(imgsize, QImage::Format::Format_ARGB32); + QPainter painter(&img); + ruler_->render(&painter, QPoint(0, 0)); + scrollarea_->render(&painter, QPoint(0, rlSize.height())); + QString fileStamp = QDateTime::currentDateTimeUtc().toString("yyyyMMdd_hhmmss"); + QString fileName = QString("pulseview_%1.png").arg(fileStamp); + QString filePath = QDir( QDir::tempPath() ).filePath(fileName); + bool issaved = img.save(filePath); + qDebug() << "Screenshot grabbed (" << issaved << "): " << filePath; +} + void View::h_scroll_value_changed(int value) { if (updating_scroll_) diff --git a/pv/views/trace/view.hpp b/pv/views/trace/view.hpp index f0b163f69..098adaee5 100644 --- a/pv/views/trace/view.hpp +++ b/pv/views/trace/view.hpp @@ -441,6 +441,7 @@ private Q_SLOTS: void on_scroll_to_end_shortcut_triggered(); void on_h_scroll_view_left_triggered(); void on_h_scroll_view_right_triggered(); + void on_bitmap_screenshot_triggered(); void h_scroll_value_changed(int value); void v_scroll_value_changed(); @@ -515,6 +516,7 @@ private Q_SLOTS: QShortcut *cancel_grab_shortcut_; QShortcut *scroll_view_left_; QShortcut *scroll_view_right_; + QShortcut *bitmap_screenshot_; mutable mutex signal_mutex_; vector< shared_ptr > signals_; From 047157e05cbfe4a3404bb3cd2d7dedcb2621d5ae Mon Sep 17 00:00:00 2001 From: sdbbs Date: Fri, 30 Oct 2020 08:51:37 +0100 Subject: [PATCH 3/5] added documentation for CTRL+m/CTRL+n/CTRL+b shortcuts --- doc/pulseview.1 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/doc/pulseview.1 b/doc/pulseview.1 index 9663fdf94..04c9e17c3 100644 --- a/doc/pulseview.1 +++ b/doc/pulseview.1 @@ -133,6 +133,19 @@ Ungroup the traces in the currently selected trace group. .B "CTRL+up/down arrow keys" Scroll down/up. .TP +.B "CTRL+m/CTRL+n" +Scroll forward or backward (right or left) in time (horizontally) for the +entire width of the capture, currently shown in the PulseView window viewport, +according to current zoom settings (could be called a "full-page" scroll, by +analogy with printable document viewers) +.TP +.B "CTRL+b" +Save a bitmap screen capture (screenshot) of only the ruler and the viewport, +currently shown in the PulseView window; which allows these screenshots to be +stitched together horizontally afterwards, if they are obtained through a +"full-page" scroll. Screenshots are saved in the temporary directory of the OS, +with a filename of 'pulseview_yyyyMMdd_hhmmss.png' (UTC timestamp). +.TP .B "CTRL+q" Quit, i.e. shutdown PulseView (closing all session tabs). .TP From 866bf477adaa34d80336e9ac35ae8958a1480e5f Mon Sep 17 00:00:00 2001 From: sdbbs Date: Fri, 30 Oct 2020 08:59:33 +0100 Subject: [PATCH 4/5] edited documentation for CTRL+m/CTRL+n/CTRL+b shortcuts --- doc/pulseview.1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/pulseview.1 b/doc/pulseview.1 index 04c9e17c3..d08ae315e 100644 --- a/doc/pulseview.1 +++ b/doc/pulseview.1 @@ -143,8 +143,9 @@ analogy with printable document viewers) Save a bitmap screen capture (screenshot) of only the ruler and the viewport, currently shown in the PulseView window; which allows these screenshots to be stitched together horizontally afterwards, if they are obtained through a -"full-page" scroll. Screenshots are saved in the temporary directory of the OS, -with a filename of 'pulseview_yyyyMMdd_hhmmss.png' (UTC timestamp). +"full-page" scroll (note: not pixel-perfect). Screenshots are saved with a +filename of 'pulseview_yyyyMMdd_hhmmss.png' (UTC timestamp), in the +temporary directory of the OS. .TP .B "CTRL+q" Quit, i.e. shutdown PulseView (closing all session tabs). From b00233dad3d8cd01340f284086515a0ac6a725e5 Mon Sep 17 00:00:00 2001 From: sdbbs Date: Sun, 29 Nov 2020 17:28:03 +0100 Subject: [PATCH 5/5] implemented Ctrl-G as keyboard shortcut for capturing .svg bitmap screenshots, only of viewport and ruler, to temporary directory --- pv/views/trace/view.cpp | 34 ++++++++++++++++++++++++++++++++++ pv/views/trace/view.hpp | 2 ++ 2 files changed, 36 insertions(+) diff --git a/pv/views/trace/view.cpp b/pv/views/trace/view.cpp index acf7dcd95..e3ed4ab06 100644 --- a/pv/views/trace/view.cpp +++ b/pv/views/trace/view.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include @@ -250,6 +251,10 @@ View::View(Session &session, bool is_main_view, QMainWindow *parent) : SLOT(on_bitmap_screenshot_triggered()), nullptr, Qt::WidgetWithChildrenShortcut); bitmap_screenshot_->setAutoRepeat(false); + svg_screenshot_ = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_G), this, + SLOT(on_svg_screenshot_triggered()), nullptr, Qt::WidgetWithChildrenShortcut); + svg_screenshot_->setAutoRepeat(false); + grab_ruler_left_shortcut_ = new QShortcut(QKeySequence(Qt::Key_1), this, nullptr, nullptr, Qt::WidgetWithChildrenShortcut); connect(grab_ruler_left_shortcut_, &QShortcut::activated, @@ -1802,6 +1807,35 @@ void View::on_bitmap_screenshot_triggered() qDebug() << "Screenshot grabbed (" << issaved << "): " << filePath; } +void View::on_svg_screenshot_triggered() +{ + //note: viewport_ does not contain track name markings at left, nor ruler + //scrollarea_ is the same, except with added scrollbars + //here we will get only viewport_ and ruler_, so as to assist in stitching/appending images + QSize vpSize = viewport_->size(); + QSize rlSize = ruler_->size(); + QSize imgsize(vpSize.width(), vpSize.height()+rlSize.height()); + QString fileStamp = QDateTime::currentDateTimeUtc().toString("yyyyMMdd_hhmmss"); + QString fileName = QString("pulseview_%1.svg").arg(fileStamp); + QString filePath = QDir( QDir::tempPath() ).filePath(fileName); + + // note that there is no explicit .save command for SVG generator + QSvgGenerator generator; + generator.setFileName(filePath); + generator.setSize(imgsize); + generator.setViewBox(QRect(0, 0, imgsize.width(), imgsize.height())); + generator.setTitle(fileName); + generator.setTitle(tr("An SVG drawing created by the Qt5 SVG Generator from PulseView")); + + QPainter painter; + painter.begin(&generator); + ruler_->render(&painter, QPoint(0, 0)); + scrollarea_->render(&painter, QPoint(0, rlSize.height())); + painter.end(); + + qDebug() << "Screenshot grabbed: " << filePath; +} + void View::h_scroll_value_changed(int value) { if (updating_scroll_) diff --git a/pv/views/trace/view.hpp b/pv/views/trace/view.hpp index 098adaee5..d064b8857 100644 --- a/pv/views/trace/view.hpp +++ b/pv/views/trace/view.hpp @@ -442,6 +442,7 @@ private Q_SLOTS: void on_h_scroll_view_left_triggered(); void on_h_scroll_view_right_triggered(); void on_bitmap_screenshot_triggered(); + void on_svg_screenshot_triggered(); void h_scroll_value_changed(int value); void v_scroll_value_changed(); @@ -517,6 +518,7 @@ private Q_SLOTS: QShortcut *scroll_view_left_; QShortcut *scroll_view_right_; QShortcut *bitmap_screenshot_; + QShortcut *svg_screenshot_; mutable mutex signal_mutex_; vector< shared_ptr > signals_;