Skip to content

Commit

Permalink
slow down volume change if it,s small
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Jan 20, 2013
1 parent 922272c commit ad39d9b
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/EventFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,28 @@ bool EventFilter::eventFilter(QObject *watched, QEvent *event)
break;
case Qt::Key_Up:
if (player->audio) {
player->audio->setVolume(player->audio->volume() + 0.1);
qDebug("vol = %.1f", player->audio->volume());
qreal v = player->audio->volume();
if (v > 0.5)
v += 0.1;
else if (v > 0.1)
v += 0.05;
else
v += 0.025;
player->audio->setVolume(v);
qDebug("vol = %.3f", player->audio->volume());
}
break;
case Qt::Key_Down:
if (player->audio) {
player->audio->setVolume(player->audio->volume() - 0.1);
qDebug("vol = %.1f", player->audio->volume());
qreal v = player->audio->volume();
if (v > 0.5)
v -= 0.1;
else if (v > 0.1)
v -= 0.05;
else
v -= 0.025;
player->audio->setVolume(v);
qDebug("vol = %.3f", player->audio->volume());
}
break;
case Qt::Key_O: {
Expand Down

0 comments on commit ad39d9b

Please sign in to comment.