Bug 137592 - have two time labels at once, one with the elapsed time and one with the remaining time
Summary: have two time labels at once, one with the elapsed time and one with the rema...
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR wishlist
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-19 21:33 UTC by Leon Weber
Modified: 2006-11-22 08:01 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
adds a second time label to the status bar (5.23 KB, patch)
2006-11-19 21:33 UTC, Leon Weber
Details
a screenshot (162.09 KB, image/png)
2006-11-19 21:35 UTC, Leon Weber
Details
the complete version of the patch, and a bugfix for streams. (6.17 KB, patch)
2006-11-20 21:52 UTC, Leon Weber
Details
fix for streams (2.27 KB, patch)
2006-11-22 01:23 UTC, Leon Weber
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Leon Weber 2006-11-19 21:33:02 UTC
Version:           1.4-SVN (r606270) (using KDE KDE 3.5.2)
Installed from:    Gentoo Packages
OS:                Linux

I modified the statusbar code so there are two time labels.
Looks like that:
x:xx <------------ slider ------------> -x:xx
The left label shows the elapsed time, the right one shows the remaining time. When the user clicks on one of them, they swap.
Comment 1 Leon Weber 2006-11-19 21:33:45 UTC
Created attachment 18617 [details]
adds a second time label to the status bar
Comment 2 Leon Weber 2006-11-19 21:35:28 UTC
Created attachment 18618 [details]
a screenshot

a screenshot with the patch applied
Comment 3 Mark Kretschmann 2006-11-19 21:53:32 UTC
I think this is an interesting idea; Worth discussing.
Comment 4 Seb Ruiz 2006-11-20 01:55:31 UTC
Useful if you have a lot of real-estate, but on my laptop, where i am running a resolution of 1024x768, this would use a lot of the statusbar of which i could be using for something else, such as viewing messages or task progress
Comment 5 Leon Weber 2006-11-20 21:52:33 UTC
Created attachment 18632 [details]
the complete version of the patch, and a bugfix for streams.
Comment 6 Mark Kretschmann 2006-11-20 22:39:30 UTC
SVN commit 606571 by markey:

Show both remaining and elapsed time at the same time. Patch by Leon Weber <leon.weber@leonweber.de>.

I'm committing this for testing: Request for comments :)

BUG: 137592


 M  +2 -2      amarokcore/amarok.kcfg  
 M  +2 -2      playerwindow.cpp  
 M  +40 -10    statusbar/statusbar.cpp  
 M  +1 -0      statusbar/statusbar.h  
 M  +1 -1      statusbar/timeLabel.h  


--- trunk/extragear/multimedia/amarok/src/amarokcore/amarok.kcfg #606570:606571
@@ -41,8 +41,8 @@
         <whatsthis>If set, amarok follows symlinks when adding files or directories to the playlist.</whatsthis>
         <default>true</default>
     </entry>
-    <entry key="Time Display Remaining" type="Bool">
-        <label>Whether to display remaining track time</label>
+    <entry key="Left Time Display Remaining" type="Bool">
+        <label>Whether to display remaining track time in the left time label.</label>
         <whatsthis>Set this to display remaining track time instead of past track time in the player window.</whatsthis>
         <default>false</default>
     </entry>
--- trunk/extragear/multimedia/amarok/src/playerwindow.cpp #606570:606571
@@ -401,7 +401,7 @@
 {
     int seconds = ms / 1000;
     const int songLength = EngineController::instance()->bundle().length();
-    const bool showRemaining = AmarokConfig::timeDisplayRemaining() && songLength > 0;
+    const bool showRemaining = AmarokConfig::leftTimeDisplayRemaining() && songLength > 0;
 
     if( showRemaining ) seconds = songLength - seconds;
 
@@ -771,7 +771,7 @@
 
         if ( rect.contains( e->pos() ) )
         {
-            AmarokConfig::setTimeDisplayRemaining( !AmarokConfig::timeDisplayRemaining() );
+            AmarokConfig::setLeftTimeDisplayRemaining( !AmarokConfig::leftTimeDisplayRemaining() );
             timeDisplay( EngineController::engine()->position() );
         }
         else m_startDragPos = e->pos();
--- trunk/extragear/multimedia/amarok/src/statusbar/statusbar.cpp #606570:606571
@@ -74,9 +74,16 @@
 
     m_slider = new Amarok::PrettySlider( Qt::Horizontal, Amarok::PrettySlider::Normal,
 					 positionBox );
+
+    // the two time labels. m_timeLable is the left one,
+    // m_timeLabel2 the right one.
     m_timeLabel = new TimeLabel( positionBox );
     m_slider->setMinimumWidth( m_timeLabel->width() );
 
+    m_timeLabel2 = new TimeLabel( positionBox );
+    m_slider->setMinimumWidth( m_timeLabel2->width() );
+
+
     // TODO Both labels need tooltips (string freeze?)
     QWidget *hbox = new QWidget( this );
     QBoxLayout *layout = new QHBoxLayout( hbox, 0, 2 );
@@ -92,8 +99,9 @@
     addWidget( positionBox );
 
     box->addSpacing( 3 );
+    box->addWidget( m_timeLabel );
     box->addWidget( m_slider );
-    box->addWidget( m_timeLabel );
+    box->addWidget( m_timeLabel2 );
 
     connect( m_slider, SIGNAL(sliderReleased( int )), EngineController::instance(), SLOT(seek( int )) );
     connect( m_slider, SIGNAL(valueChanged( int )), SLOT(drawTimeDisplay( int )) );
@@ -126,6 +134,7 @@
         m_slider->setMaxValue( 0 );
 	m_slider->newBundle( MetaBundle() ); // Set an empty bundle
         m_timeLabel->setEnabled( false ); //must be done after the setValue() above, due to a signal connection
+        m_timeLabel2->setEnabled( false );
         setMainText( QString::null );
         break;
 
@@ -138,6 +147,7 @@
         DEBUG_LINE_INFO
         resetMainText(); // if we were paused, this is necessary
         m_timeLabel->setEnabled( true );
+        m_timeLabel2->setEnabled( true );
         break;
 
     case Engine::Idle:
@@ -251,23 +261,38 @@
 StatusBar::drawTimeDisplay( int ms )  //SLOT
 {
     int seconds = ms / 1000;
+    int seconds2 = seconds; // for the second label.
     const uint trackLength = EngineController::instance()->bundle().length();
 
-    if( AmarokConfig::timeDisplayRemaining() && trackLength > 0 ) {
+    if( AmarokConfig::leftTimeDisplayRemaining() && trackLength > 0 ) {
+        seconds2 = seconds;
         seconds = trackLength - seconds;
+    } else if( !AmarokConfig::leftTimeDisplayRemaining() && trackLength > 0 )
+    {
+        seconds2 = trackLength - seconds;
     }
 
-    QString s = MetaBundle::prettyTime( seconds );
+    QString s1 = MetaBundle::prettyTime( seconds );
+    QString s2 = MetaBundle::prettyTime( seconds2 );
 
-    if( AmarokConfig::timeDisplayRemaining() && trackLength > 0 ) {
-        s.prepend( '-' );
+    if( AmarokConfig::leftTimeDisplayRemaining() && trackLength > 0 ) {
+        s1.prepend( '-' );
+    } else if( !AmarokConfig::leftTimeDisplayRemaining() && trackLength > 0 )
+    {
+        s2.prepend( '-' );
     }
 
-    while( (int)s.length() < m_timeLength )
-        s.prepend( ' ' );
-    s += ' ';
+    while( (int)s1.length() < m_timeLength )
+        s1.prepend( ' ' );
 
-    m_timeLabel->setText( s );
+    while( (int)s2.length() < m_timeLength )
+        s2.prepend( ' ' );
+
+    s1 += ' ';
+    s2 += ' ';
+
+    m_timeLabel->setText( s1 );
+    m_timeLabel2->setText( s2 );
 }
 
 void
@@ -276,9 +301,14 @@
     static uint counter = 0;
 
     if ( counter == 0 )
+    {
         m_timeLabel->erase();
-    else
+        m_timeLabel2->erase();
+    } else
+    {
         m_timeLabel->update();
+        m_timeLabel2->update();
+    }
 
     ++counter &= 3;
 }
--- trunk/extragear/multimedia/amarok/src/statusbar/statusbar.h #606570:606571
@@ -62,6 +62,7 @@
 
     private:
         QLabel *m_timeLabel;
+        QLabel *m_timeLabel2;
         int m_timeLength;
         QLabel *m_itemCountLabel;
         QueueLabel *m_queueLabel;
--- trunk/extragear/multimedia/amarok/src/statusbar/timeLabel.h #606570:606571
@@ -33,7 +33,7 @@
 
     virtual void mousePressEvent( QMouseEvent * )
     {
-        AmarokConfig::setTimeDisplayRemaining( !AmarokConfig::timeDisplayRemaining() );
+        AmarokConfig::setLeftTimeDisplayRemaining( !AmarokConfig::leftTimeDisplayRemaining() );
 
         Amarok::StatusBar::instance()->drawTimeDisplay( EngineController::engine()->position() );
     }
Comment 7 Leon Weber 2006-11-22 01:23:06 UTC
Created attachment 18651 [details]
fix for streams

another patch which makes the label with the remaining time show 0:00 and look
gray.
Comment 8 Leon Weber 2006-11-22 01:23:32 UTC
see new patch
Comment 9 Mark Kretschmann 2006-11-22 07:51:36 UTC
I'm wondering: With the two labels, why do we still need to switch between two modes when you click the label? I don't see the point. Seems like we could just remove that.
Comment 10 Mark Kretschmann 2006-11-22 08:01:52 UTC
SVN commit 606872 by markey:

Disable "remaining" time label for streams.

BUG: 137592


 M  +29 -1     statusbar.cpp  


--- trunk/extragear/multimedia/amarok/src/statusbar/statusbar.cpp #606871:606872
@@ -264,19 +264,33 @@
     int seconds2 = seconds; // for the second label.
     const uint trackLength = EngineController::instance()->bundle().length();
 
-    if( AmarokConfig::leftTimeDisplayRemaining() && trackLength > 0 ) {
+    // when the left label shows the remaining time and it's not a stream
+    if( AmarokConfig::leftTimeDisplayRemaining() && trackLength > 0 )
+    {
         seconds2 = seconds;
         seconds = trackLength - seconds;
+    // when the left label shows the remaining time and it's a stream
+    } else if( AmarokConfig::leftTimeDisplayRemaining() && trackLength == 0 )
+    {
+        seconds2 = seconds;
+        seconds = 0; // for streams
+    // when the right label shows the remaining time and it's not a stream
     } else if( !AmarokConfig::leftTimeDisplayRemaining() && trackLength > 0 )
     {
         seconds2 = trackLength - seconds;
+    // when the right label shows the remaining time and it's a stream
+    } else if( !AmarokConfig::leftTimeDisplayRemaining() && trackLength == 0 )
+    {
+        seconds2 = 0;
     }
 
     QString s1 = MetaBundle::prettyTime( seconds );
     QString s2 = MetaBundle::prettyTime( seconds2 );
 
+    // when the left label shows the remaining time and it's not a stream
     if( AmarokConfig::leftTimeDisplayRemaining() && trackLength > 0 ) {
         s1.prepend( '-' );
+    // when the right label shows the remaining time and it's not a stream
     } else if( !AmarokConfig::leftTimeDisplayRemaining() && trackLength > 0 )
     {
         s2.prepend( '-' );
@@ -293,6 +307,20 @@
 
     m_timeLabel->setText( s1 );
     m_timeLabel2->setText( s2 );
+
+    if( AmarokConfig::leftTimeDisplayRemaining() && trackLength == 0 )
+    {
+        m_timeLabel->setEnabled( false );
+        m_timeLabel2->setEnabled( true );
+    } else if( !AmarokConfig::leftTimeDisplayRemaining() && trackLength == 0 )
+    {
+        m_timeLabel->setEnabled( true );
+        m_timeLabel2->setEnabled( false );
+    } else
+    {
+        m_timeLabel->setEnabled( true );
+        m_timeLabel2->setEnabled( true );
+    }
 }
 
 void