summaryrefslogtreecommitdiffstats
path: root/src/widget/wpushbutton.cpp
diff options
context:
space:
mode:
authorRJ Ryan <rryan@mixxx.org>2014-11-24 10:06:38 -0500
committerRJ Ryan <rryan@mixxx.org>2014-11-24 10:06:38 -0500
commit4e0cb7cdfc8239a33cc9ffdc15d5b36e6426a838 (patch)
tree8e26776b2b32b77c1b19fa59c5a2986b9f7e0900 /src/widget/wpushbutton.cpp
parent5f86ed50007f7a21a21bd93469bdc5aff7be253e (diff)
Fix re-styling of WPushButton on state changes.
This got broken somewhere along the way with the control widget connection refactorings.
Diffstat (limited to 'src/widget/wpushbutton.cpp')
-rw-r--r--src/widget/wpushbutton.cpp41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/widget/wpushbutton.cpp b/src/widget/wpushbutton.cpp
index 5b57a74f71..294d1503a9 100644
--- a/src/widget/wpushbutton.cpp
+++ b/src/widget/wpushbutton.cpp
@@ -239,19 +239,8 @@ void WPushButton::setPixmapBackground(PixmapSource source,
}
}
-void WPushButton::onConnectedControlChanged(double dParameter, double dValue) {
- Q_UNUSED(dParameter);
- // Enums are not currently represented using parameter space so it doesn't
- // make sense to use the parameter here yet.
- if (m_iNoStates == 1) {
- m_bPressed = (dValue == 1.0);
- }
-
- double value = getControlParameterDisplay();
- if (!isnan(value) && m_iNoStates > 0) {
- int idx = static_cast<int>(value) % m_iNoStates;
- emit(displayValueChanged(idx));
- }
+void WPushButton::restyleAndRepaint() {
+ emit(displayValueChanged(readDisplayValue()));
// According to http://stackoverflow.com/a/3822243 this is the least
// expensive way to restyle just this widget.
@@ -260,10 +249,22 @@ void WPushButton::onConnectedControlChanged(double dParameter, double dValue) {
// re-render.
style()->unpolish(this);
style()->polish(this);
+
// These calls don't always trigger the repaint, so call it explicitly.
repaint();
}
+void WPushButton::onConnectedControlChanged(double dParameter, double dValue) {
+ Q_UNUSED(dParameter);
+ // Enums are not currently represented using parameter space so it doesn't
+ // make sense to use the parameter here yet.
+ if (m_iNoStates == 1) {
+ m_bPressed = (dValue == 1.0);
+ }
+
+ restyleAndRepaint();
+}
+
void WPushButton::paintEvent(QPaintEvent* e) {
Q_UNUSED(e);
QStyleOption option;
@@ -321,7 +322,7 @@ void WPushButton::mousePressEvent(QMouseEvent * e) {
}
m_bPressed = true;
setControlParameterLeftDown(1.0);
- update();
+ restyleAndRepaint();
}
// discharge right clicks here, because is used for latching in POWERWINDOW mode
return;
@@ -334,7 +335,7 @@ void WPushButton::mousePressEvent(QMouseEvent * e) {
|| m_iNoStates == 1) {
m_bPressed = true;
setControlParameterRightDown(1.0);
- update();
+ restyleAndRepaint();
}
return;
}
@@ -359,7 +360,7 @@ void WPushButton::mousePressEvent(QMouseEvent * e) {
}
m_bPressed = true;
setControlParameterLeftDown(emitValue);
- update();
+ restyleAndRepaint();
}
}
@@ -370,7 +371,7 @@ void WPushButton::focusOutEvent(QFocusEvent* e) {
// the pressed flag if the Primary touch point is moved to an
// other widget
m_bPressed = false;
- update();
+ restyleAndRepaint();
}
}
@@ -390,7 +391,7 @@ void WPushButton::mouseReleaseEvent(QMouseEvent * e) {
} else if (rightClick) {
m_bPressed = false;
}
- update();
+ restyleAndRepaint();
return;
}
@@ -402,7 +403,7 @@ void WPushButton::mouseReleaseEvent(QMouseEvent * e) {
|| m_iNoStates == 1) {
m_bPressed = false;
setControlParameterRightUp(0.0);
- update();
+ restyleAndRepaint();
}
return;
}
@@ -426,7 +427,7 @@ void WPushButton::mouseReleaseEvent(QMouseEvent * e) {
}
m_bPressed = false;
setControlParameterLeftUp(emitValue);
- update();
+ restyleAndRepaint();
}
}