Ticket #3937: mythmusic-time-fix.patch

File mythmusic-time-fix.patch, 3.8 KB (added by otto at kolsi dot fi, 18 years ago)
  • mythmusic/mythmusic/playbackbox.cpp

     
    14621462    delete input;
    14631463    input = 0;
    14641464
    1465     QString time_string;
    1466     int maxh = maxTime / 3600;
    1467     int maxm = (maxTime / 60) % 60;
    1468     int maxs = maxm % 60;
    1469     if (maxh > 0)
    1470         time_string.sprintf("%d:%02d:%02d", maxh, maxm, maxs);
    1471     else
    1472         time_string.sprintf("%02d:%02d", maxm, maxs);
     1465    QString time_string = getTimeString(maxTime, 0);
    14731466
    14741467    if (time_text)
    14751468        time_text->SetText(time_string);
     
    19281931        {
    19291932            OutputEvent *oe = (OutputEvent *) event;
    19301933
    1931             int eh, em, es, rs, ts;
    1932             currentTime = rs = ts = oe->elapsedSeconds();
     1934            int rs;
     1935            currentTime = rs = oe->elapsedSeconds();
    19331936
    1934             eh = ts / 3600;
    1935             em = (ts / 60) % 60;
    1936             es = ts % 60;
     1937            QString time_string = getTimeString(rs, maxTime);
    19371938
    1938             QString time_string;
    1939 
    1940             int maxh = maxTime / 3600;
    1941             int maxm = (maxTime / 60) % 60;
    1942             int maxs = maxTime % 60;
    1943 
    1944             if (maxTime <= 0)
    1945             {
    1946                 if (eh > 0)
    1947                     time_string.sprintf("%d:%02d:%02d", eh, em, es);
    1948                 else
    1949                     time_string.sprintf("%02d:%02d", em, es);
    1950             }
    1951             else
    1952             {
    1953                 if (maxh > 0)
    1954                     time_string.sprintf("%d:%02d:%02d / %02d:%02d:%02d", eh, em,
    1955                                         es, maxh, maxm, maxs);
    1956                 else
    1957                     time_string.sprintf("%02d:%02d / %02d:%02d", em, es, maxm,
    1958                                         maxs);
    1959             }
    1960            
    19611939            showProgressBar();
    19621940           
    19631941            if (curMeta)
     
    21272105
    21282106        maxTime = curMeta->Length() / 1000;
    21292107
    2130         QString time_string;
    2131         int maxh = maxTime / 3600;
    2132         int maxm = (maxTime / 60) % 60;
    2133         int maxs = maxm % 60;
    2134         if (maxh > 0)
    2135             time_string.sprintf("%d:%02d:%02d", maxh, maxm, maxs);
    2136         else
    2137             time_string.sprintf("%02d:%02d", maxm, maxs);
    2138         if (time_text)
    2139             time_text->SetText(time_string);
     2108        QString time_string = getTimeString(maxTime, 0);
     2109       
    21402110        if (showrating)
    21412111        {
    21422112            if(ratings_image)
     
    23822352
    23832353    return (res >= 0);
    23842354}
     2355
     2356QString PlaybackBoxMusic::getTimeString(int exTime, int maxTime)
     2357{
     2358    QString time_string;
     2359
     2360    int eh = exTime / 3600;
     2361    int em = (exTime / 60) % 60;
     2362    int es = exTime % 60;
     2363
     2364    int maxh = maxTime / 3600;
     2365    int maxm = (maxTime / 60) % 60;
     2366    int maxs = maxTime % 60;
     2367
     2368    if (maxTime <= 0)
     2369    {
     2370        if (eh > 0)
     2371            time_string.sprintf("%d:%02d:%02d", eh, em, es);
     2372        else
     2373            time_string.sprintf("%02d:%02d", em, es);
     2374    }
     2375    else
     2376    {
     2377        if (maxh > 0)
     2378            time_string.sprintf("%d:%02d:%02d / %02d:%02d:%02d", eh, em,
     2379                    es, maxh, maxm, maxs);
     2380        else
     2381            time_string.sprintf("%02d:%02d / %02d:%02d", em, es, maxm,
     2382                    maxs);
     2383    }
     2384
     2385    return time_string;
     2386}
  • mythmusic/mythmusic/playbackbox.h

     
    117117    void bannerToggle(Metadata *mdata);
    118118    void savePosition(uint position);
    119119    void restorePosition(void);
    120 
    121120    void pushButton(UIPushButtonType *button);
     121    QString getTimeString(int exTime, int maxTime);
    122122
    123123    QIODevice *input;
    124124    AudioOutput *output;