icon path fix
[musique.git] / common.cpp
blob211f672f291c085940bba4866bda87f9ddfa1c50
1 //
2 // C++ Implementation: common
3 //
4 // Author: Oliver Groß <z.o.gross@gmx.de>, (C) 2008
5 //
6 // Copyright: See COPYING file that comes with this distribution
7 //
8 #include <QString>
9 #include "common.h"
11 QString toStringFormated(xmms_playback_status_t state) {
12 switch (state) {
13 case XMMS_PLAYBACK_STATUS_PLAY:
14 return "[PLAYING] %1";
15 case XMMS_PLAYBACK_STATUS_STOP:
16 return "[STOPPED] %1";
17 case XMMS_PLAYBACK_STATUS_PAUSE:
18 return "[PAUSED] %1";
19 default:
20 return "%1";
24 QString formatedTime(quint32 milliseconds) {
25 quint16 seconds = milliseconds / 1000 + (milliseconds % 1000 > 500 ? 1 : 0);
26 quint8 minutes = seconds / 60;
27 quint8 hours = minutes / 60;
29 QString result;
31 if (hours) {
32 if (hours < 10)
33 result += '0';
34 result += QString::number(hours);
35 result += ':';
38 minutes %= 60;
40 if (minutes < 10)
41 result += '0';
42 result += QString::number(minutes);
43 result += ':';
45 seconds %= 60;
47 if (seconds < 10)
48 result += '0';
49 result += QString::number(seconds);
51 return result;