From: Joel Holdsworth Date: Sat, 30 Nov 2013 10:11:29 +0000 (+0000) Subject: Keep a pointer to the active Popup in Trace X-Git-Tag: pulseview-0.2.0~212 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=20eaae392762d69fc97cdc68115bcc0e648a59da;p=pulseview.git Keep a pointer to the active Popup in Trace --- diff --git a/pv/view/trace.cpp b/pv/view/trace.cpp index ffbab063..79255bec 100644 --- a/pv/view/trace.cpp +++ b/pv/view/trace.cpp @@ -41,7 +41,9 @@ const int Trace::LabelHitPadding = 2; Trace::Trace(pv::SigSession &session, QString name) : _session(session), _name(name), - _v_offset(0) + _v_offset(0), + _popup(NULL), + _popup_form(NULL) { } @@ -179,11 +181,17 @@ QMenu* Trace::create_context_menu(QWidget *parent) pv::widgets::Popup* Trace::create_popup(QWidget *parent) { using pv::widgets::Popup; - Popup *const popup = new Popup(parent); - QFormLayout *const form = new QFormLayout(popup); - popup->setLayout(form); - populate_popup_form(popup, form); - return popup; + + _popup = new Popup(parent); + _popup_form = new QFormLayout(_popup); + _popup->setLayout(_popup_form); + + populate_popup_form(_popup, _popup_form); + + connect(_popup, SIGNAL(closed()), + this, SLOT(on_popup_closed())); + + return _popup; } int Trace::get_y() const @@ -250,6 +258,12 @@ QRectF Trace::get_label_rect(int right) label_size.width(), label_size.height()); } +void Trace::on_popup_closed() +{ + _popup = NULL; + _popup_form = NULL; +} + void Trace::on_text_changed(const QString &text) { set_name(text); diff --git a/pv/view/trace.h b/pv/view/trace.h index 85d137bc..e2ed37fd 100644 --- a/pv/view/trace.h +++ b/pv/view/trace.h @@ -185,6 +185,8 @@ private slots: void on_colour_changed(const QColor &colour); + void on_popup_closed(); + signals: void visibility_changed(); void text_changed(); @@ -199,6 +201,9 @@ protected: int _v_offset; QSizeF _text_size; + + pv::widgets::Popup *_popup; + QFormLayout *_popup_form; }; } // namespace view