From: Joel Holdsworth Date: Wed, 26 Apr 2017 16:12:23 +0000 (-0600) Subject: Trace: Removed coloured_bg state X-Git-Tag: pulseview-0.4.0~97 X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=489953884c0d7692fa20748314751e114ae54cf2 Trace: Removed coloured_bg state The state should be taken from the View --- diff --git a/pv/view/trace.cpp b/pv/view/trace.cpp index 985c2950..2a1eb959 100644 --- a/pv/view/trace.cpp +++ b/pv/view/trace.cpp @@ -53,20 +53,12 @@ Trace::Trace(shared_ptr channel) : popup_(nullptr), popup_form_(nullptr) { - GlobalSettings settings; - coloured_bg_ = settings.value(GlobalSettings::Key_View_ColouredBG).toBool(); - connect(channel.get(), SIGNAL(name_changed(const QString&)), this, SLOT(on_name_changed(const QString&))); connect(channel.get(), SIGNAL(colour_changed(const QColor&)), this, SLOT(on_colour_changed(const QColor&))); } -void Trace::set_coloured_bg(bool state) -{ - coloured_bg_ = state; -} - void Trace::paint_label(QPainter &p, const QRect &rect, bool hover) { const int y = get_visual_y(); @@ -161,7 +153,10 @@ QRectF Trace::label_rect(const QRectF &rect) const void Trace::paint_back(QPainter &p, const ViewItemPaintParams &pp) { - if (coloured_bg_) + const View *view = owner_->view(); + assert(view); + + if (view->coloured_bg()) p.setBrush(base_->bgcolour()); else p.setBrush(bgcolour_state_ ? BrightGrayBGColour : DarkGrayBGColour); diff --git a/pv/view/trace.hpp b/pv/view/trace.hpp index 62588a16..882c2d70 100644 --- a/pv/view/trace.hpp +++ b/pv/view/trace.hpp @@ -70,11 +70,6 @@ public: */ virtual void set_colour(QColor colour); - /** - * Enables or disables the coloured background for this trace. - */ - void set_coloured_bg(bool state); - /** * Paints the signal label. * @param p the QPainter to paint into. @@ -130,7 +125,7 @@ private Q_SLOTS: protected: shared_ptr base_; - bool coloured_bg_, coloured_bg_state_; + bool coloured_bg_state_; private: pv::widgets::Popup *popup_; diff --git a/pv/view/view.cpp b/pv/view/view.cpp index 8f5494ac..ab458f26 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -570,31 +570,15 @@ void View::enable_show_analog_minor_grid(bool state) void View::enable_coloured_bg(bool state) { - const vector> items( - list_by_type()); - - for (shared_ptr i : items) { - // Can't cast to Trace because it's abstract, so we need to - // check for any derived classes individually - - shared_ptr a = dynamic_pointer_cast(i); - if (a) - a->set_coloured_bg(state); - - shared_ptr l = dynamic_pointer_cast(i); - if (l) - l->set_coloured_bg(state); - -#ifdef ENABLE_DECODE - shared_ptr d = dynamic_pointer_cast(i); - if (d) - d->set_coloured_bg(state); -#endif - } - + coloured_bg_ = state; viewport_->update(); } +bool View::coloured_bg() const +{ + return coloured_bg_; +} + bool View::cursors_shown() const { return show_cursors_; diff --git a/pv/view/view.hpp b/pv/view/view.hpp index 08b8a37e..9fac1a67 100644 --- a/pv/view/view.hpp +++ b/pv/view/view.hpp @@ -212,6 +212,11 @@ public: */ void enable_coloured_bg(bool state); + /** + * Returns true if the trace background should be drawn with a coloured background. + */ + bool coloured_bg() const; + /** * Enable or disable showing sampling points. */