From 18bcad6f99518d1f649502f79d21dd847d8ee214 Mon Sep 17 00:00:00 2001 From: Thomas Frauendorfer Date: Sun, 18 May 2008 14:04:05 +0200 Subject: [PATCH] OTHER: Fix timedisplay for playtimes >= 100 minutes If the playtime is bigger or equal to 100 minutes, timedisplay shows hours and minutes now, if playtime is bigger or equal to 100 hours, timedisplay gives up and only showes '--:--' --- TODO | 4 ++-- src/Skin.cpp | 8 ++++++-- src/mainwindow/maindisplay.cpp | 12 +++++++++++- src/mainwindow/timedisplay.cpp | 34 +++++++++++++++++++++++++--------- 4 files changed, 44 insertions(+), 14 deletions(-) diff --git a/TODO b/TODO index bd5761b..712c5b1 100644 --- a/TODO +++ b/TODO @@ -4,7 +4,8 @@ General: + Feature Requests and Bugs on tracker + Mainwindow - + enable random play (will have to wait for a randomplay service client) + + enable random play (will have to wait for a randomplay service client), + has to wait for bug 1598 before even considering * Playlist + Make displayed Information configurable + Add scrollbuttons to slider @@ -13,7 +14,6 @@ General: * jump to entry when it's played. * accept drops from other applications * Skin - + Numbers in playtime display can have variable height * Compressed file reader * Manage with faulty skins * make cool effects when switching skin? diff --git a/src/Skin.cpp b/src/Skin.cpp index 788aea5..10d15b3 100644 --- a/src/Skin.cpp +++ b/src/Skin.cpp @@ -122,8 +122,10 @@ void Skin::BuildEqualizer (void) { QPixmap *img = getPixmap ("eqmain"); + // eq_ex is optional, so this Pointer can be null. check before using it QPixmap *imgex = getPixmap ("eq_ex"); - if (img && imgex) { + + if (img) { m_items[EQ_WIN_BG] = img->copy (0, 0, 275, 116); if (img->height () > 294) { @@ -139,7 +141,9 @@ Skin::BuildEqualizer (void) icon = QIcon (); icon.addPixmap (img->copy (254, 3, 9, 9), QIcon::Normal, QIcon::Off); - icon.addPixmap (imgex->copy ( 1, 38, 9, 9), QIcon::Active, QIcon::Off); + if (imgex) { + icon.addPixmap (imgex->copy ( 1, 38, 9, 9), QIcon::Active, QIcon::Off); + } m_icons[BUTTON_EQ_SHADE] = icon; icon = QIcon (); diff --git a/src/mainwindow/maindisplay.cpp b/src/mainwindow/maindisplay.cpp index de89390..70c1e4b 100644 --- a/src/mainwindow/maindisplay.cpp +++ b/src/mainwindow/maindisplay.cpp @@ -167,10 +167,20 @@ MainDisplay::setStatus (Xmms::Playback::Status status) m_playstatus->setStatus (status); if (status == Xmms::Playback::STOPPED) { - m_time->setTime(0); + //m_time->setTime(0); + m_time->hide (); + m_kbps->hide (); + m_khz->hide (); m_posbar->setValue (0); m_posbar->hide (); m_stereo->setStereoMono (false, false); + } else if (status == Xmms::Playback::PLAYING) { + m_time->show (); + m_kbps->show (); + m_khz->show (); + // m_posbar will be shown when fetching metadata + // m_stereo is set there too + } } diff --git a/src/mainwindow/timedisplay.cpp b/src/mainwindow/timedisplay.cpp index 03355e6..953cba8 100644 --- a/src/mainwindow/timedisplay.cpp +++ b/src/mainwindow/timedisplay.cpp @@ -20,14 +20,22 @@ #include -//TimeDisplay::TimeDisplay (QWidget *parent) : PixWidget (parent) TimeDisplay::TimeDisplay (QWidget *parent) : QWidget (parent) { setFixedSize (63, 13); } +/* + * This method takes the playtime in seconds + */ void TimeDisplay::setTime (int time) { + // Hack to make display hours and seconds instead of seconds and minutes + // if time (or reversetime) is 100 Minutes or longer + if ((time >= 6000) || (time <= -6000)) { + time /= 60; + } + if (m_time == time) return; m_time = time; @@ -52,15 +60,23 @@ TimeDisplay::paintEvent (QPaintEvent *event) paint.drawPixmap (0, 0, m_pixmaps[10]); } uint showtime = abs(m_time); - // draw minutes - uint min = showtime / 60; - paint.drawPixmap (12, 0, m_pixmaps[min/10]); - paint.drawPixmap (24, 0, m_pixmaps[min%10]); - // draw seconds - uint sec = showtime % 60; - paint.drawPixmap (42, 0, m_pixmaps[sec/10]); - paint.drawPixmap (54, 0, m_pixmaps[sec%10]); + if (showtime < 6000) { + // draw minutes + uint min = showtime / 60; + paint.drawPixmap (12, 0, m_pixmaps[min/10]); + paint.drawPixmap (24, 0, m_pixmaps[min%10]); + // draw seconds + uint sec = showtime % 60; + paint.drawPixmap (42, 0, m_pixmaps[sec/10]); + paint.drawPixmap (54, 0, m_pixmaps[sec%10]); + } else { + // Just give up and draw '-' if min would become 100 or bigger + paint.drawPixmap (12, 0, m_pixmaps[11]); + paint.drawPixmap (24, 0, m_pixmaps[11]); + paint.drawPixmap (42, 0, m_pixmaps[11]); + paint.drawPixmap (54, 0, m_pixmaps[11]); + } paint.end (); }