Version: 1.2.4 (using KDE KDE 3.5.0) Installed from: Gentoo Packages Compiler: gcc-3.4.4 OS: Linux I would like to display the currently elapsed (or remaining) time of a song in the OSD, because I have a lot of tracks that are over 10 minutes long, just to have a better overview. Shouldn't be too hard to implement. ;)
Created attachment 18834 [details] Patch for osd.cpp, .h, Options5.ui.h
I wrote a small patch for it (and clear out the extra Vector class).
Created attachment 18835 [details] working patch
SVN commit 611451 by markey: Elapsed time can be shown in OSD. Patch by Christian Engels <s9chenge@stud.uni-sb.de>. BUG: 120051 M +2 -0 ChangeLog M +5 -4 src/Options5.ui.h M +26 -17 src/osd.cpp M +1 -1 src/osd.h --- trunk/extragear/multimedia/amarok/ChangeLog #611450:611451 @@ -5,6 +5,8 @@ VERSION 1.4.5 FEATURES: + * Elapsed time can be shown in OSD. Patch by Christian Engels + <s9chenge@stud.uni-sb.de>. (BR 120051) * New redownload manager for the Magnatune.com store. Allows re-download of any previous purchase free of charge (in any format). * Star ratings now have different colors for different ratings, to easily --- trunk/extragear/multimedia/amarok/src/Options5.ui.h #611450:611451 @@ -77,6 +77,7 @@ "<li>Disc Number - %15" "<li>Rating - %16" "<li>Moodbar - %17" + "<li>Elapsed Time - %18" "</ul>" "If you surround sections of text that contain a token with curly-braces, that section will be hidden if the token is empty, for example:" "<pre>%11</pre>" @@ -84,10 +85,10 @@ QToolTip::add( kcfg_OsdText, text.args( QStringList() // we don't translate these, it is not sensible to do so - << "%title" << "%album" << "%artist" << "%genre" << "%bitrate" - << "%year " << "%length" << "%track" << "%filename" << "%directory" - << "%type" << "%comment" << "%score" << "%playcount" << "%discnumber" - << "%rating" << "%moodbar" + << "%title" << "%album" << "%artist" << "%genre" << "%bitrate" + << "%year " << "%length" << "%track" << "%filename" << "%directory" + << "%type" << "%comment" << "%score" << "%playcount" << "%discnumber" + << "%rating" << "%moodbar" << "%elapsed" << "%title {Score: %score}" ) ); } --- trunk/extragear/multimedia/amarok/src/osd.cpp #611450:611451 @@ -16,6 +16,7 @@ #include "amarokconfig.h" #include "collectiondb.h" //for albumCover location #include "debug.h" +#include "enginecontroller.h" #include "osd.h" #include "playlist.h" //if osdUsePlaylistColumns() #include "playlistitem.h" //ditto @@ -626,17 +627,6 @@ this, SLOT( slotImageChanged( const QString& ) ) ); } -template<class T> -class MyVector: public QValueVector<T> //QValueVector doesn't have operator<<, wtf? -{ - public: - inline MyVector<T> &operator<< (const T &x) - { - append( x ); - return *this; - } -}; - void Amarok::OSD::show( const MetaBundle &bundle ) //slot { @@ -646,10 +636,10 @@ else { - MyVector<QString> tags; - tags << bundle.prettyTitle(); + QValueVector<QString> tags; + tags.append(bundle.prettyTitle()); for( int i = 0; i < PlaylistItem::NUM_COLUMNS; ++i ) - tags << bundle.prettyText( i ); + tags.append(bundle.prettyText( i )); if( bundle.length() <= 0 ) tags[PlaylistItem::Length+1] = QString::null; @@ -657,7 +647,7 @@ if( AmarokConfig::osdUsePlaylistColumns() ) { QString tag; - MyVector<int> availableTags; //eg, ones that aren't empty + QValueVector<int> availableTags; //eg, ones that aren't empty static const QValueList<int> parens = //display these in parentheses QValueList<int>() << PlaylistItem::PlayCount << PlaylistItem::Year << PlaylistItem::Comment << PlaylistItem::Genre << PlaylistItem::Length << PlaylistItem::Bitrate @@ -668,7 +658,7 @@ { const int column = Playlist::instance()->mapToLogicalColumn( i ); if( !tags.at( column + 1 ).isEmpty() && column != PlaylistItem::Rating ) - availableTags << column; + availableTags.append(column); if( column == PlaylistItem::Rating ) OSDWidget::setRating( bundle.rating() ); else if( column == PlaylistItem::Mood ) @@ -695,7 +685,26 @@ if( bundle.length() <= 0 ) args["length"] = QString::null; - + + + uint time=EngineController::instance()->engine()->position(); + uint sec=(time/1000)%60; //is there a better way to calculate the time? + time /= 1000; + uint min=(time/60)%60; + time /= 60; + uint hour=(time/60)%60; + QString timeformat=""; + if(hour!=0) + { + timeformat += QString::number(hour); + timeformat +=":"; + } + timeformat +=QString::number(min); + timeformat +=":"; + if(sec<10) + timeformat +="0"; + timeformat +=QString::number(sec); + args["elapsed"]=timeformat; QStringx osd = AmarokConfig::osdText(); // hacky, but works... --- trunk/extragear/multimedia/amarok/src/osd.h #611450:611451 @@ -16,7 +16,7 @@ #define AMAROK_OSD_H #include "metabundle.h" - + #include <kpixmap.h> #include <qimage.h> #include <qvaluelist.h>