From 5eb13a62c115a7a45331c6af1f02b5cc118c9228 Mon Sep 17 00:00:00 2001 From: Ludovic Fauvet Date: Tue, 11 Aug 2009 01:29:17 +0200 Subject: [PATCH] Qt: Fix the bug where the volume was losing 1% at each start The bug originates from an implicit conversion to int. This commit explicitly convert the value to qreal then use qRound to take the nearest integer. Signed-off-by: Jean-Baptiste Kempf --- modules/gui/qt4/components/controller_widget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/gui/qt4/components/controller_widget.cpp b/modules/gui/qt4/components/controller_widget.cpp index fbb19becad..db295423b6 100644 --- a/modules/gui/qt4/components/controller_widget.cpp +++ b/modules/gui/qt4/components/controller_widget.cpp @@ -111,8 +111,8 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf, layout->addWidget( volumeSlider, 0, Qt::AlignBottom ); /* Set the volume from the config */ - volumeSlider->setValue( ( config_GetInt( p_intf, "volume" ) ) * - VOLUME_MAX / (AOUT_VOLUME_MAX/2) ); + volumeSlider->setValue( qRound( ( (qreal)config_GetInt( p_intf, "volume" ) ) * + VOLUME_MAX / (AOUT_VOLUME_MAX/2) ) ); /* Force the update at build time in order to have a muted icon if needed */ updateVolume( volumeSlider->value() ); -- 2.39.2