From 78b97bbbbdad3339c43afda120ab218a41bc74b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Nusser?= Date: Sun, 23 Apr 2017 18:58:42 +0200 Subject: Fix broken PowerButton state of the frame. --- plugingui/frame.cc | 16 ++++------------ plugingui/frame.h | 2 +- 2 files changed, 5 insertions(+), 13 deletions(-) (limited to 'plugingui') diff --git a/plugingui/frame.cc b/plugingui/frame.cc index c56245a..efe0281 100644 --- a/plugingui/frame.cc +++ b/plugingui/frame.cc @@ -44,7 +44,7 @@ FrameWidget::FrameWidget(Widget* parent, bool has_switch) power_button.setChecked(is_switched_on); CONNECT(&power_button, stateChangedNotifier, this, - &FrameWidget::powerButtonClicked); + &FrameWidget::powerButtonStateChanged); } power_button.setVisible(has_switch); @@ -80,15 +80,10 @@ void FrameWidget::repaintEvent(RepaintEvent* repaintEvent) p.drawText(center_x - label_width, bar_height - 4, font, title_buf); } -void FrameWidget::powerButtonClicked(bool clicked) +void FrameWidget::powerButtonStateChanged(bool new_state) { - is_switched_on = !is_switched_on; + is_switched_on = new_state; onSwitchChangeNotifier(is_switched_on); - - if(content) - { - content->setVisible(true); - } } void FrameWidget::setTitle(std::string const& title) @@ -101,15 +96,12 @@ void FrameWidget::setContent(Widget* content) { this->content = content; content->reparent(this); - content->setVisible(true); } void FrameWidget::setOnSwitch(bool on) { is_switched_on = on; - onSwitchChangeNotifier(is_switched_on); - - redraw(); + power_button.setChecked(is_switched_on); } void FrameWidget::sizeChanged(int width, int height) diff --git a/plugingui/frame.h b/plugingui/frame.h index 04cfeb2..8475690 100644 --- a/plugingui/frame.h +++ b/plugingui/frame.h @@ -77,7 +77,7 @@ private: bool is_switched_on; PowerButton power_button{this}; - void powerButtonClicked(bool clicked); + void powerButtonStateChanged(bool clicked); // grey box std::size_t bar_height; -- cgit v1.2.3