]> sigrok.org Git - pulseview.git/commitdiff
Keep a pointer to the active Popup in Trace
authorJoel Holdsworth <redacted>
Sat, 30 Nov 2013 10:11:29 +0000 (10:11 +0000)
committerJoel Holdsworth <redacted>
Sat, 30 Nov 2013 18:14:05 +0000 (18:14 +0000)
pv/view/trace.cpp
pv/view/trace.h

index ffbab0639ceac05500896a94d59655bc3c5c68d0..79255bec3f98fa4491a4e81c6cb4529c12b176f0 100644 (file)
@@ -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);
index 85d137bcbd21cdd50b1c172defc9d6d2a8d2f1d5..e2ed37fd444b6c37507ffe667e4bf83a3579c72b 100644 (file)
@@ -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