From: Joel Holdsworth Date: Sun, 29 Sep 2013 14:08:58 +0000 (+0900) Subject: Added TimeMarker popups X-Git-Tag: pulseview-0.2.0~269 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=a28a212c7a9a3470e300911fe8aa62833a62d26a;p=pulseview.git Added TimeMarker popups --- diff --git a/pv/view/ruler.cpp b/pv/view/ruler.cpp index 06cd1b15..ad7082e6 100644 --- a/pv/view/ruler.cpp +++ b/pv/view/ruler.cpp @@ -34,6 +34,8 @@ #include #include +#include + using namespace boost; using namespace std; @@ -225,6 +227,16 @@ void Ruler::mousePressEvent(QMouseEvent *e) void Ruler::mouseReleaseEvent(QMouseEvent *) { + using pv::widgets::Popup; + + if (!_dragging) + if (shared_ptr m = _grabbed_marker.lock()) { + Popup *const p = m->create_popup(&_view); + p->set_position(mapToGlobal(QPoint(m->get_x(), + height())), Popup::Bottom); + p->show(); + } + _dragging = false; _grabbed_marker.reset(); } diff --git a/pv/view/selectableitem.h b/pv/view/selectableitem.h index 41f68117..fa728c72 100644 --- a/pv/view/selectableitem.h +++ b/pv/view/selectableitem.h @@ -30,6 +30,11 @@ class QMenu; class QWidget; namespace pv { + +namespace widgets { +class Popup; +} + namespace view { class SelectableItem : public QObject @@ -56,6 +61,8 @@ public: public: virtual QMenu* create_context_menu(QWidget *parent); + virtual pv::widgets::Popup* create_popup(QWidget *parent) = 0; + protected: static QPen highlight_pen(); diff --git a/pv/view/timemarker.cpp b/pv/view/timemarker.cpp index 40bb8173..4c3645b4 100644 --- a/pv/view/timemarker.cpp +++ b/pv/view/timemarker.cpp @@ -24,6 +24,8 @@ #include +#include + using namespace std; namespace pv { @@ -69,6 +71,28 @@ void TimeMarker::paint(QPainter &p, const QRect &rect) p.drawLine(QPointF(x, rect.top()), QPointF(x, rect.bottom())); } +pv::widgets::Popup* TimeMarker::create_popup(QWidget *parent) +{ + using pv::widgets::Popup; + + Popup *const popup = new Popup(parent); + QFormLayout *const form = new QFormLayout(popup); + popup->setLayout(form); + + _value_widget = new QDoubleSpinBox(parent); + _value_widget->setValue(_time); + _value_widget->setDecimals(6); + _value_widget->setSuffix("s"); + _value_widget->setSingleStep(1e-6); + + connect(_value_widget, SIGNAL(valueChanged(double)), + this, SLOT(on_value_changed(double))); + + form->addRow(tr("Time"), _value_widget); + + return popup; +} + void TimeMarker::on_value_changed(double value) { if (!_updating_value_widget) { diff --git a/pv/view/timemarker.h b/pv/view/timemarker.h index 03fdd0fb..fc058c27 100644 --- a/pv/view/timemarker.h +++ b/pv/view/timemarker.h @@ -86,6 +86,8 @@ public: virtual void paint_label(QPainter &p, const QRect &rect, unsigned int prefix) = 0; + pv::widgets::Popup* create_popup(QWidget *parent); + private slots: void on_value_changed(double value); diff --git a/pv/view/trace.h b/pv/view/trace.h index ff65a213..bae5d253 100644 --- a/pv/view/trace.h +++ b/pv/view/trace.h @@ -35,10 +35,6 @@ namespace pv { class SigSession; -namespace widgets { -class Popup; -} - namespace view { class View;