Changeset 43 for gui/main_window.cpp


Ignore:
Timestamp:
01/07/08 17:44:35 (4 years ago)
Author:
sander
Message:

Made a function to format the time nicely.
Also tried to format the message content, though it's still not perfect, at least here.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gui/main_window.cpp

    r42 r43  
    1 #include <cmath> 
    21#include <QtGui> 
    32#include <QIcon> 
     
    123122    trayIcon->setIcon(icon); 
    124123    trayIcon->setToolTip("QtMPC"); 
    125      
     124 
    126125    return true; 
    127126} 
     
    213212        if (!song->title.isEmpty() && !song->artist.isEmpty() && !song->album.isEmpty()) { 
    214213            trayIcon->showMessage(song->artist + " - " + song->title, 
    215                 "album:" + song->album + "\n" +  
    216                 "track:" + QString::number(song->track) + "\n" +  
    217                 "time:" + QString::number(song->time) + "\n", 
     214                "album:  " + song->album + "\n" + 
     215                "track:  " + QString::number(song->track) + "\n" + 
     216                "length: " + Song::formattedTime(song->time), 
    218217                QSystemTrayIcon::Information, 5000); 
    219218        } 
     
    248247        timeElapsedFormattedString = "00:00 / 00:00"; 
    249248    } else { 
    250         // Time elapsed 
    251         timeElapsedFormattedString += QString::number(floor(status.time_elapsed / 60.0)); 
    252         timeElapsedFormattedString += ":"; 
    253         if(status.time_elapsed % 60 < 10) { 
    254             timeElapsedFormattedString += "0"; 
    255         } 
    256         timeElapsedFormattedString += QString::number(status.time_elapsed % 60); 
    257  
     249        timeElapsedFormattedString += Song::formattedTime(status.time_elapsed); 
    258250        timeElapsedFormattedString += " / "; 
    259  
    260         // Time total 
    261         timeElapsedFormattedString += QString::number(floor(status.time_total / 60.0)); 
    262         timeElapsedFormattedString += ":"; 
    263         if(status.time_total % 60 < 10) { 
    264             timeElapsedFormattedString += "0"; 
    265         } 
    266         timeElapsedFormattedString += QString::number(status.time_total % 60); 
     251        timeElapsedFormattedString += Song::formattedTime(status.time_total); 
    267252    } 
    268253 
Note: See TracChangeset for help on using the changeset viewer.