[prev in list] [next in list] [prev in thread] [next in thread] 

List:       amarok-devel
Subject:    This patch attempts to fix bug 195935
From:       Victor W <victor.w () pervices ! com>
Date:       2009-10-21 5:03:18
Message-ID: 4ADE9616.1000505 () pervices ! com
[Download RAW message or body]

The attached patch attempts to fix Bug 195935: 	 remaining time of long tracks 
gets cut off



["0001-Fixes-Bug-195935-remaining-time-of-long-tracks-gets-.patch" (text/plain)]

From e7e12e54ceb6ecb02105099416cd37d19b294987 Mon Sep 17 00:00:00 2001
From: Victor Wollesen <victor.w@pervices.com>
Date: Wed, 21 Oct 2009 00:28:49 -0400
Subject: [PATCH] Fixes Bug 195935: remaining time of long tracks gets cut off


Signed-off-by: Victor Wollesen <victor.w@pervices.com>
---
 src/widgets/ProgressWidget.cpp |   17 +++++++++++++++--
 src/widgets/TimeLabel.h        |   16 ++++++++++++++++
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/src/widgets/ProgressWidget.cpp b/src/widgets/ProgressWidget.cpp
index 7e2e695..f21151b 100644
--- a/src/widgets/ProgressWidget.cpp
+++ b/src/widgets/ProgressWidget.cpp
@@ -1,5 +1,6 @@
 /****************************************************************************************
                
  * Copyright (c) 2007 Dan Meltzer <parallelgrapefruit@gmail.com>                     \
* + * Copyright (c) 2009 Victor Wollesen <victor.w@pervices.com>                      \
                *
  *                                                                                   \
                *
  * This program is free software; you can redistribute it and/or modify it under     \
                *
  * the terms of the GNU General Public License as published by the Free Software     \
* @@ -51,7 +52,7 @@ ProgressWidget::ProgressWidget( QWidget *parent )
     m_timeLabelLeft->setToolTip( i18n( "The amount of time elapsed in current song" \
) );  
     m_timeLabelRight = new TimeLabel( this );
-    m_timeLabelRight->setFixedWidth( 60 );
+    m_timeLabelRight->setNomWidth( 60 ); //Sets nominal label width.
     m_timeLabelRight->setToolTip( i18n( "The amount of time remaining in current \
song" ) );  m_timeLabelRight->setAlignment( Qt::AlignRight );
 
@@ -144,7 +145,7 @@ ProgressWidget::drawTimeDisplay( int ms )  //SLOT
     s1 += ' ';
     s2 += ' ';
 
-    m_timeLabelLeft->setText( s1 );
+    m_timeLabelLeft->setText( s1 );   
     m_timeLabelRight->setText( s2 );
 
     if( AmarokConfig::leftTimeDisplayRemaining() && trackLength == 0 )
@@ -227,6 +228,18 @@ ProgressWidget::engineTrackLengthChanged( qint64 milliseconds )
     debug() << "slider enabled!";
     m_timeLength = Meta::msToPrettyTime( milliseconds ).length()+1; // account for - \
in remaining time  
+    //https://bugs.kde.org/show_bug.cgi?id=195935: time of long tracks gets cut off
+    //For long tracks, the contents of m_timeLengthRight are cut off by the slider
+    //if they exceed 60px. Because such very long songs are rare, the idea here is
+    //to dynamically increase m_timeLengthRight.width as needed, and then restore
+    //the previous, nominal, width once in the clear.
+
+    //If the bounding rectangle is greater than the assigned nominal width, we \
override nominal width for the song +    if ( fontMetrics().boundingRect( \
Meta::msToPrettyTime( milliseconds ) + "  " ).width() > m_timeLabelRight->nomWidth() \
) +        m_timeLabelRight->setFixedWidth( fontMetrics().boundingRect( \
Meta::msToPrettyTime( milliseconds ) + "  " ).width() ); +    else
+        m_timeLabelRight->setFixedWidth( m_timeLabelRight->nomWidth() );
+
     //get the urlid of the current track as the engine might stop and start several \
                times
     //when skipping lst.fm tracks, so we need to know if we are still on the same \
track...  if ( The::engineController()->currentTrack() )
diff --git a/src/widgets/TimeLabel.h b/src/widgets/TimeLabel.h
index fa1e039..f96bc60 100644
--- a/src/widgets/TimeLabel.h
+++ b/src/widgets/TimeLabel.h
@@ -1,5 +1,6 @@
 /****************************************************************************************
                
  * Copyright (c) 2005 Max Howell <max.howell@methylblue.com>                         \
* + * Copyright (c) 2009 Victor Wollesen <victor.w@pervices.com>                      \
                *
  *                                                                                   \
                *
  * This program is free software; you can redistribute it and/or modify it under     \
                *
  * the terms of the GNU General Public License as published by the Free Software     \
* @@ -70,8 +71,23 @@ public:
             QLabel::setText( text );
     }
 
+    void setNomWidth( int nomWidth )
+    {
+        if( nomWidth > 0)
+        {
+         m_nomWidth = nomWidth;
+         QWidget::setFixedWidth( m_nomWidth );
+        }
+    }
+
+    int nomWidth() const
+    {
+        return m_nomWidth;
+    }
+
 private:
     bool m_showTime;
+    int  m_nomWidth;
 
 };
 
-- 
1.6.5.1



_______________________________________________
Amarok-devel mailing list
Amarok-devel@kde.org
https://mail.kde.org/mailman/listinfo/amarok-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic