summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2017-04-23 18:58:42 +0200
committerAndré Nusser <andre.nusser@googlemail.com>2017-04-23 18:58:42 +0200
commit78b97bbbbdad3339c43afda120ab218a41bc74b3 (patch)
tree79fdcc6f3e69c32b55db26c0875264bc2907c744
parent7e811d0a92ed8a89ef01531a7e7826692f4898e5 (diff)
Fix broken PowerButton state of the frame.
-rw-r--r--plugingui/frame.cc16
-rw-r--r--plugingui/frame.h2
2 files changed, 5 insertions, 13 deletions
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;