@ -622,6 +622,10 @@ void MessageDelegate::paint(QPainter *painter, const QStyleOptionViewItem &optio
/* compute elapsed/frac for progress */
float elapsed = 0 , frac = 0 , durSec = st . durationSec ;
if ( durSec < = 0 ) {
QString ds = index . data ( MsgVoiceDurationRole ) . toString ( ) ;
ds . remove ( ' s ' ) ; durSec = ds . toFloat ( ) ;
}
if ( isPaused ) {
elapsed = st . pausedPosSec ;
} else if ( isPlaying ) {
@ -662,16 +666,24 @@ void MessageDelegate::paint(QPainter *painter, const QStyleOptionViewItem &optio
QRect wfR = L . voiceWaveformRect ;
if ( wfN > 0 ) {
float barW = ( float ) wfR . width ( ) / wfN ;
int ph = wfR . height ( ) - 3 ; /* leave 3px for progress bar at bottom */
int ph = wfR . height ( ) - 3 ;
for ( int i = 0 ; i < wfN ; i + + ) {
float v = wf [ i ] . toFloat ( ) ;
int barH = 1 + ( int ) ( v * ( ph - 1 ) ) ;
float db = v > 0.00001f ? 20.0f * log10f ( v ) : - 100.0f ;
float logV = ( db + 60.0f ) / 60.0f ;
if ( logV < 0 ) logV = 0 ; if ( logV > 1 ) logV = 1 ;
int barH = 2 + ( int ) ( logV * ( ph - 2 ) ) ;
int x = wfR . left ( ) + ( int ) ( i * barW ) ;
int y = wfR . top ( ) + ph - barH ;
int bw = qMax ( 2 , ( int ) ( barW * 0.8f ) ) ;
bool before = wfN > 0 & & ( float ) i / wfN < = frac ;
painter - > setBrush ( before ? QColor ( 0x33 , 0x90 , 0xEC ) : QColor ( 0x33 , 0x90 , 0xEC , 45 ) ) ;
QColor played ( 0x33 , 0x90 , 0xEC ) ;
QColor unplayed ( 0x33 , 0x90 , 0xEC , 80 ) ;
QColor idle ( 0x70 , 0x70 , 0x78 , 130 ) ;
painter - > setBrush ( ( isPlaying | | isPaused ) ? ( before ? played : unplayed ) : idle ) ;
painter - > drawRect ( QRect ( x , y , bw , barH ) ) ;
if ( i = = 0 ) GUI_DEBUG ( " voice paint: wfN=%d wfW=%d v=%.3f dB=%.1f logV=%.2f barH=%d " ,
wfN , wfR . width ( ) , v , db , logV , barH ) ;
}
}