summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOwen Williams <owilliams@mixxx.org>2014-04-21 07:37:42 -0400
committerOwen Williams <owilliams@mixxx.org>2014-04-21 07:37:42 -0400
commit068782beb007ef17f8843189e2b7c88ebf559adc (patch)
tree170cdcf62b440112cb3faadc0e1c346d6c219e3b /src
parent3d35a1d116390c4780e80428f1aec5fe1bee2657 (diff)
Move the unpolish/polish calls outside paint, because they call paint.
Diffstat (limited to 'src')
-rw-r--r--src/widget/wpushbutton.cpp15
-rw-r--r--src/widget/wpushbutton.h6
2 files changed, 9 insertions, 12 deletions
diff --git a/src/widget/wpushbutton.cpp b/src/widget/wpushbutton.cpp
index 79517bb3a2..47eca0d541 100644
--- a/src/widget/wpushbutton.cpp
+++ b/src/widget/wpushbutton.cpp
@@ -238,10 +238,17 @@ void WPushButton::onConnectedControlChanged(double dParameter, double dValue) {
m_bPressed = (dValue == 1.0);
}
+ double value = getControlParameterDisplay();
+ int idx = static_cast<int>(value) % m_iNoStates;
+ setProperty("displayValue", idx);
+ // According to http://stackoverflow.com/a/3822243 this is the least
+ // expensive way to restyle just this widget.
+ // These calls trigger the repaint.
// Since we expect button connections to not change at high frequency we
// don't try to detect whether things have changed for WPushButton, we just
// re-render.
- update();
+ style()->unpolish(this);
+ style()->polish(this);
}
void WPushButton::paintEvent(QPaintEvent* e) {
@@ -287,12 +294,6 @@ void WPushButton::paintEvent(QPaintEvent* e) {
if (!text.isEmpty()) {
p.drawText(rect(), m_align.at(idx), text);
}
-
- setProperty("displayValue", idx);
- // According to http://stackoverflow.com/a/3822243 this is the least
- // expensive way to restyle just this widget.
- style()->unpolish(this);
- style()->polish(this);
}
void WPushButton::mousePressEvent(QMouseEvent * e) {
diff --git a/src/widget/wpushbutton.h b/src/widget/wpushbutton.h
index 3d7fb2938d..f318078f69 100644
--- a/src/widget/wpushbutton.h
+++ b/src/widget/wpushbutton.h
@@ -52,7 +52,7 @@ class WPushButton : public WWidget {
// The declaration #MyButton[displayValue="0"] { } will define the style
// when the widget is in state 0. This allows for effects like reversing
// background and foreground colors to indicate enabled/disabled state.
- Q_PROPERTY(int displayValue READ readDisplayValue WRITE setDisplayValue)
+ Q_PROPERTY(int displayValue READ readDisplayValue)
int readDisplayValue() const {
double value = getControlParameterDisplay();
@@ -60,10 +60,6 @@ class WPushButton : public WWidget {
return idx;
}
- void setDisplayValue(int val) {
- setControlParameter(static_cast<double>(val));
- }
-
void setup(QDomNode node, const SkinContext& context);
// Sets the number of states associated with this button, and removes