From: Joel Holdsworth Date: Sat, 5 Oct 2013 11:00:47 +0000 (+0100) Subject: Moved popup text changed handler into base class, and made "Name" translatable X-Git-Tag: pulseview-0.2.0~266 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=68456dab5d519d886cf632cecc01373cc258d83c;p=pulseview.git Moved popup text changed handler into base class, and made "Name" translatable --- diff --git a/pv/view/signal.cpp b/pv/view/signal.cpp index 7c4a11e0..96417f2b 100644 --- a/pv/view/signal.cpp +++ b/pv/view/signal.cpp @@ -90,11 +90,5 @@ void Signal::populate_popup_form(QWidget *parent, QFormLayout *form) form->addRow(tr("Name"), _name_widget); } -void Signal::on_text_changed(const QString &text) -{ - Trace::set_name(text); - text_changed(); -} - } // namespace view } // namespace pv diff --git a/pv/view/signal.h b/pv/view/signal.h index 540eb6ed..cdecd408 100644 --- a/pv/view/signal.h +++ b/pv/view/signal.h @@ -60,9 +60,6 @@ public: virtual void populate_popup_form(QWidget *parent, QFormLayout *form); -private slots: - void on_text_changed(const QString &text); - protected: const sr_probe *const _probe; diff --git a/pv/view/trace.cpp b/pv/view/trace.cpp index 28084544..ebf28b62 100644 --- a/pv/view/trace.cpp +++ b/pv/view/trace.cpp @@ -213,7 +213,11 @@ void Trace::paint_axis(QPainter &p, int y, int left, int right) void Trace::populate_popup_form(QWidget *parent, QFormLayout *form) { - form->addRow("Name", new QLineEdit(parent)); + QLineEdit *const name_edit = new QLineEdit(parent); + name_edit->setText(_name); + connect(name_edit, SIGNAL(textChanged(const QString&)), + this, SLOT(on_text_changed(const QString&))); + form->addRow(tr("Name"), name_edit); } void Trace::compute_text_size(QPainter &p) @@ -260,6 +264,11 @@ void Trace::on_action_set_colour_triggered() set_colour(new_colour); } +void Trace::on_text_changed(const QString &text) +{ + set_name(text); + text_changed(); +} } // namespace view } // namespace pv diff --git a/pv/view/trace.h b/pv/view/trace.h index bae5d253..462e8094 100644 --- a/pv/view/trace.h +++ b/pv/view/trace.h @@ -181,6 +181,8 @@ private slots: void on_action_set_colour_triggered(); + void on_text_changed(const QString &text); + signals: void text_changed();