mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 14:13:47 +02:00
Refactor if..else into a switch.
Also support the hidden and suspended states.
This commit is contained in:
parent
292f37154b
commit
d580f177a3
1 changed files with 21 additions and 8 deletions
|
@ -54,14 +54,27 @@ void GLCanvas::mouseReleaseEvent(QMouseEvent* event) {
|
|||
}
|
||||
|
||||
void GLCanvas::activeChanged() {
|
||||
if (Application::applicationState() != Qt::ApplicationActive) {
|
||||
if (!_throttleRendering) {
|
||||
_frameTimer.start(_idleRenderInterval);
|
||||
_throttleRendering = true;
|
||||
}
|
||||
} else {
|
||||
_frameTimer.stop();
|
||||
_throttleRendering = false;
|
||||
switch (Application::applicationState()) {
|
||||
case Qt::ApplicationActive:
|
||||
// If we're active, stop the frame timer and the throttle.
|
||||
_frameTimer.stop();
|
||||
_throttleRendering = false;
|
||||
break;
|
||||
|
||||
case Qt::ApplicationSuspended:
|
||||
case Qt::ApplicationHidden:
|
||||
// If we're hidden or are about to suspend, don't render anything.
|
||||
_throttleRendering = false;
|
||||
_frameTimer.stop();
|
||||
break;
|
||||
|
||||
default:
|
||||
// Otherwise, throttle.
|
||||
if (!_throttleRendering) {
|
||||
_frameTimer.start(_idleRenderInterval);
|
||||
_throttleRendering = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue