OTHER: Update ShadedDisplay to use new SmallTimeDisplay
split Timedisplay into a common class and a specialised class and make new SmallTimeDisplay inherit from the common class. Thus as much code as possible is reused in SmallTimeDisplay
This commit is contained in:
parent
1fa72bd3f0
commit
221e1255d0
9 changed files with 115 additions and 54 deletions
|
@ -334,6 +334,7 @@ Skin::setSkin (const QString& name)
|
||||||
BuildEqualizer ();
|
BuildEqualizer ();
|
||||||
|
|
||||||
m_letterMap.clear();
|
m_letterMap.clear();
|
||||||
|
m_smallNumbers.clear ();
|
||||||
BuildLetterMap();
|
BuildLetterMap();
|
||||||
|
|
||||||
BuildSliders();
|
BuildSliders();
|
||||||
|
@ -418,6 +419,7 @@ Skin::BuildLetterMap (void)
|
||||||
/* digits */
|
/* digits */
|
||||||
for (uint i = 0; i <= 9; i++) {
|
for (uint i = 0; i <= 9; i++) {
|
||||||
m_letterMap[i+48] = letters[1][i];
|
m_letterMap[i+48] = letters[1][i];
|
||||||
|
m_smallNumbers [i] = letters[1][i];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* special characters */
|
/* special characters */
|
||||||
|
@ -453,6 +455,9 @@ Skin::BuildLetterMap (void)
|
||||||
|
|
||||||
/* text background */
|
/* text background */
|
||||||
m_items[TEXTBG] = letters[2][6];
|
m_items[TEXTBG] = letters[2][6];
|
||||||
|
|
||||||
|
m_smallNumbers[10] = letters[2][6];
|
||||||
|
m_smallNumbers[11] = letters[1][15];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
setSkin(":CleanAMP/");
|
setSkin(":CleanAMP/");
|
||||||
|
|
|
@ -45,6 +45,7 @@ class Skin : public QObject
|
||||||
const QPixmapList getBackgrounds (uint item) const
|
const QPixmapList getBackgrounds (uint item) const
|
||||||
{ return m_backgrounds.value(item); };
|
{ return m_backgrounds.value(item); };
|
||||||
const PixmapMap getNumbers () const { return m_numbers; }
|
const PixmapMap getNumbers () const { return m_numbers; }
|
||||||
|
const PixmapMap getSmallNumbers () const { return m_smallNumbers; }
|
||||||
|
|
||||||
const QPixmap getItem (uint part) const { return m_items[part]; }
|
const QPixmap getItem (uint part) const { return m_items[part]; }
|
||||||
const QPixmap getPls (uint part) const { return m_playlist[part]; }
|
const QPixmap getPls (uint part) const { return m_playlist[part]; }
|
||||||
|
@ -258,6 +259,7 @@ class Skin : public QObject
|
||||||
QMap<uint, QPixmapList> m_backgrounds;
|
QMap<uint, QPixmapList> m_backgrounds;
|
||||||
|
|
||||||
QMap<int, QPixmap> m_numbers;
|
QMap<int, QPixmap> m_numbers;
|
||||||
|
QMap<int, QPixmap> m_smallNumbers;
|
||||||
QMap<uint, QPixmap> m_items;
|
QMap<uint, QPixmap> m_items;
|
||||||
QMap<uint, QPixmap> m_letterMap;
|
QMap<uint, QPixmap> m_letterMap;
|
||||||
QMap<uint, QPixmap> m_playlist;
|
QMap<uint, QPixmap> m_playlist;
|
||||||
|
|
|
@ -60,7 +60,7 @@ MainDisplay::MainDisplay (QWidget *parent) : SkinDisplay(parent)
|
||||||
|
|
||||||
m_time = new TimeDisplay(this);
|
m_time = new TimeDisplay(this);
|
||||||
m_time->move (36, 26);
|
m_time->move (36, 26);
|
||||||
connect (m_time, SIGNAL(clicked()), this, SLOT(toggleTime()));
|
connect (m_time, SIGNAL(clicked()), m_mw, SLOT(toggleTime()));
|
||||||
|
|
||||||
m_kbps = new SmallNumberDisplay (this, 15);
|
m_kbps = new SmallNumberDisplay (this, 15);
|
||||||
m_kbps->move (111, 43);
|
m_kbps->move (111, 43);
|
||||||
|
@ -187,7 +187,7 @@ MainDisplay::setStatus (Xmms::Playback::Status status)
|
||||||
void
|
void
|
||||||
MainDisplay::setPlaytime (uint32_t time)
|
MainDisplay::setPlaytime (uint32_t time)
|
||||||
{
|
{
|
||||||
uint32_t showtime;
|
int32_t showtime;
|
||||||
if (m_mw->isTimemodeReverse()) {
|
if (m_mw->isTimemodeReverse()) {
|
||||||
uint maxtime = m_posbar->maximum ();
|
uint maxtime = m_posbar->maximum ();
|
||||||
showtime = (time/1000 - maxtime/1000);
|
showtime = (time/1000 - maxtime/1000);
|
||||||
|
@ -243,6 +243,7 @@ MainDisplay::setMediainfo (const Xmms::PropDict &info)
|
||||||
m_posbar->setMaximum (info.get<int32_t> ("duration"));
|
m_posbar->setMaximum (info.get<int32_t> ("duration"));
|
||||||
m_posbar->show ();
|
m_posbar->show ();
|
||||||
} else {
|
} else {
|
||||||
|
m_posbar->setMaximum (0);
|
||||||
m_posbar->hide ();
|
m_posbar->hide ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -289,13 +290,6 @@ MainDisplay::SetupToggleButtons (void)
|
||||||
this, SLOT (setRepeatAllEnabled (bool)));
|
this, SLOT (setRepeatAllEnabled (bool)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
MainDisplay::toggleTime (void)
|
|
||||||
{
|
|
||||||
m_mw->setTimemodeReverse (!m_mw->isTimemodeReverse());
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MainDisplay::SetupPushButtons (void)
|
MainDisplay::SetupPushButtons (void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -71,7 +71,6 @@ class MainDisplay : public SkinDisplay
|
||||||
void setStatus (Xmms::Playback::Status status);
|
void setStatus (Xmms::Playback::Status status);
|
||||||
void setPlaytime (uint32_t time);
|
void setPlaytime (uint32_t time);
|
||||||
void setMediainfo (const Xmms::PropDict &);
|
void setMediainfo (const Xmms::PropDict &);
|
||||||
void toggleTime(void);
|
|
||||||
void updateVolume (uint volume);
|
void updateVolume (uint volume);
|
||||||
void setVolume (int volume);
|
void setVolume (int volume);
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ class MainWindow : public BaseWindow
|
||||||
public slots:
|
public slots:
|
||||||
void switchDisplay ();
|
void switchDisplay ();
|
||||||
void mouseMoveEvent (QMouseEvent *event);
|
void mouseMoveEvent (QMouseEvent *event);
|
||||||
|
void toggleTime () { setTimemodeReverse (!isTimemodeReverse ()); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isShaded (void) { QSettings s; return s.value("MainWindow/shaded").toBool(); }
|
bool isShaded (void) { QSettings s; return s.value("MainWindow/shaded").toBool(); }
|
||||||
|
|
|
@ -22,26 +22,25 @@
|
||||||
#include "TitleBar.h"
|
#include "TitleBar.h"
|
||||||
#include "pixmapbutton.h"
|
#include "pixmapbutton.h"
|
||||||
|
|
||||||
|
#include "timedisplay.h"
|
||||||
#include "SmallNumberDisplay.h"
|
#include "SmallNumberDisplay.h"
|
||||||
#include "TextBar.h"
|
#include "TextBar.h"
|
||||||
|
#include "Skin.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
|
||||||
ShadedDisplay::ShadedDisplay (QWidget *parent) : SkinDisplay (parent)
|
ShadedDisplay::ShadedDisplay (QWidget *parent) : SkinDisplay (parent)
|
||||||
{
|
{
|
||||||
XMMSHandler &client = XMMSHandler::getInstance ();
|
XMMSHandler &client = XMMSHandler::getInstance ();
|
||||||
|
|
||||||
setMinimumSize (275, 14);
|
setFixedSize (275, 14);
|
||||||
setMaximumSize (275, 14);
|
|
||||||
|
|
||||||
m_tbar = new TitleBar(this, true);
|
m_tbar = new TitleBar(this, true);
|
||||||
m_tbar->move (0, 0);
|
m_tbar->move (0, 0);
|
||||||
|
|
||||||
m_number = new SmallNumberDisplay (this, 10);
|
m_time = new SmallTimeDisplay (this);
|
||||||
m_number->move (135, 4);
|
m_time->move (130, 4);
|
||||||
m_number->setNumber (0, 2);
|
MainWindow *mw = dynamic_cast<MainWindow *>(parent);
|
||||||
|
connect (m_time, SIGNAL(clicked()), mw, SLOT(toggleTime()));
|
||||||
m_number2 = new SmallNumberDisplay (this, 10);
|
|
||||||
m_number2->move (147, 4);
|
|
||||||
m_number2->setNumber (0, 2);
|
|
||||||
|
|
||||||
m_title = new TextScroller (this, 39, 7, "shaded");
|
m_title = new TextScroller (this, 39, 7, "shaded");
|
||||||
m_title->move (79, 4);
|
m_title->move (79, 4);
|
||||||
|
@ -85,6 +84,12 @@ ShadedDisplay::ShadedDisplay (QWidget *parent) : SkinDisplay (parent)
|
||||||
this, SLOT(setMediainfo (const Xmms::PropDict &)));
|
this, SLOT(setMediainfo (const Xmms::PropDict &)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ShadedDisplay::setPixmaps (Skin *skin)
|
||||||
|
{
|
||||||
|
m_time->setPixmaps (skin->getSmallNumbers ());
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ShadedDisplay::setMediainfo (const Xmms::PropDict &info)
|
ShadedDisplay::setMediainfo (const Xmms::PropDict &info)
|
||||||
{
|
{
|
||||||
|
@ -99,6 +104,12 @@ ShadedDisplay::setMediainfo (const Xmms::PropDict &info)
|
||||||
} else {
|
} else {
|
||||||
n = QString::fromUtf8 (info.get<std::string> ("url").c_str ());
|
n = QString::fromUtf8 (info.get<std::string> ("url").c_str ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (info.contains ("duration")) {
|
||||||
|
m_duration = (info.get<int32_t> ("duration"));
|
||||||
|
} else {
|
||||||
|
m_duration = 0;
|
||||||
|
}
|
||||||
m_title->setText (n);
|
m_title->setText (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,21 +117,21 @@ void
|
||||||
ShadedDisplay::setStatus (Xmms::Playback::Status status)
|
ShadedDisplay::setStatus (Xmms::Playback::Status status)
|
||||||
{
|
{
|
||||||
if (status == Xmms::Playback::STOPPED) {
|
if (status == Xmms::Playback::STOPPED) {
|
||||||
m_number->setNumber (0, 2);
|
//m_number->setNumber (0, 2);
|
||||||
m_number2->setNumber (0, 2);
|
//nm_number2->setNumber (0, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ShadedDisplay::setPlaytime (uint32_t time)
|
ShadedDisplay::setPlaytime (uint32_t time)
|
||||||
{
|
{
|
||||||
uint sec, min;
|
int32_t showtime;
|
||||||
|
if (dynamic_cast<MainWindow *>(m_mw)->isTimemodeReverse()) {
|
||||||
sec = (time / 1000) % 60;
|
showtime = (time/1000 - m_duration/1000);
|
||||||
min = (time / 1000) / 60;
|
} else {
|
||||||
|
showtime = time/1000;
|
||||||
m_number2->setNumber (sec, 2);
|
}
|
||||||
m_number->setNumber (min, 2);
|
m_time->setTime (showtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,9 @@ class ShadedDisplay;
|
||||||
#include "Display.h"
|
#include "Display.h"
|
||||||
|
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
|
class Skin;
|
||||||
class PixmapButton;
|
class PixmapButton;
|
||||||
|
class SmallTimeDisplay;
|
||||||
class SmallNumberDisplay;
|
class SmallNumberDisplay;
|
||||||
class TextScroller;
|
class TextScroller;
|
||||||
|
|
||||||
|
@ -38,6 +40,9 @@ class ShadedDisplay : public SkinDisplay
|
||||||
TextScroller *m_title;
|
TextScroller *m_title;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int32_t m_duration;
|
||||||
|
SmallTimeDisplay *m_time;
|
||||||
|
|
||||||
PixmapButton *m_prev;
|
PixmapButton *m_prev;
|
||||||
PixmapButton *m_play;
|
PixmapButton *m_play;
|
||||||
PixmapButton *m_pause;
|
PixmapButton *m_pause;
|
||||||
|
@ -49,6 +54,7 @@ class ShadedDisplay : public SkinDisplay
|
||||||
void setStatus (Xmms::Playback::Status status);
|
void setStatus (Xmms::Playback::Status status);
|
||||||
void setPlaytime (uint32_t time);
|
void setPlaytime (uint32_t time);
|
||||||
void setMediainfo (const Xmms::PropDict &info);
|
void setMediainfo (const Xmms::PropDict &info);
|
||||||
|
void setPixmaps (Skin *skin);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -20,15 +20,32 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
|
||||||
|
|
||||||
TimeDisplay::TimeDisplay (QWidget *parent) : QWidget (parent)
|
TimeDisplay::TimeDisplay (QWidget *parent) : AbstractTimeDisplay (parent)
|
||||||
{
|
{
|
||||||
setFixedSize (63, 13);
|
setFixedSize (63, 13);
|
||||||
|
|
||||||
|
m_d1_x_pos = 12;
|
||||||
|
m_d2_x_pos = 24;
|
||||||
|
m_d3_x_pos = 42;
|
||||||
|
m_d4_x_pos = 54;
|
||||||
|
}
|
||||||
|
|
||||||
|
SmallTimeDisplay::SmallTimeDisplay (QWidget *parent)
|
||||||
|
: AbstractTimeDisplay (parent)
|
||||||
|
{
|
||||||
|
setFixedSize (28, 6);
|
||||||
|
|
||||||
|
m_d1_x_pos = 5;
|
||||||
|
m_d2_x_pos = 10;
|
||||||
|
m_d3_x_pos = 18;
|
||||||
|
m_d4_x_pos = 23;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This method takes the playtime in seconds
|
* This method takes the playtime in seconds
|
||||||
*/
|
*/
|
||||||
void TimeDisplay::setTime (int time)
|
void
|
||||||
|
AbstractTimeDisplay::setTime (int time)
|
||||||
{
|
{
|
||||||
// Hack to make display hours and seconds instead of seconds and minutes
|
// Hack to make display hours and seconds instead of seconds and minutes
|
||||||
// if time (or reversetime) is 100 Minutes or longer
|
// if time (or reversetime) is 100 Minutes or longer
|
||||||
|
@ -43,12 +60,24 @@ void TimeDisplay::setTime (int time)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TimeDisplay::paintEvent (QPaintEvent *event)
|
AbstractTimeDisplay::setPixmaps (const PixmapMap &p) {
|
||||||
{
|
if (p.size () < 11) {
|
||||||
if (m_pixmaps.size () < 11) {
|
// This shouldn't happen, if it does then there is a bug in Skin.cpp
|
||||||
qDebug ("too small");
|
qDebug ("TimeDisplay: PixmapMap has not enough elements");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
m_pixmaps = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AbstractTimeDisplay::mouseReleaseEvent (QMouseEvent *event)
|
||||||
|
{
|
||||||
|
emit clicked();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AbstractTimeDisplay::paintEvent (QPaintEvent *event)
|
||||||
|
{
|
||||||
QPainter paint;
|
QPainter paint;
|
||||||
paint.begin (this);
|
paint.begin (this);
|
||||||
|
|
||||||
|
@ -63,26 +92,19 @@ TimeDisplay::paintEvent (QPaintEvent *event)
|
||||||
if (showtime < 6000) {
|
if (showtime < 6000) {
|
||||||
// draw minutes
|
// draw minutes
|
||||||
uint min = showtime / 60;
|
uint min = showtime / 60;
|
||||||
paint.drawPixmap (12, 0, m_pixmaps[min/10]);
|
paint.drawPixmap (m_d1_x_pos, 0, m_pixmaps[min/10]);
|
||||||
paint.drawPixmap (24, 0, m_pixmaps[min%10]);
|
paint.drawPixmap (m_d2_x_pos, 0, m_pixmaps[min%10]);
|
||||||
// draw seconds
|
// draw seconds
|
||||||
uint sec = showtime % 60;
|
uint sec = showtime % 60;
|
||||||
paint.drawPixmap (42, 0, m_pixmaps[sec/10]);
|
paint.drawPixmap (m_d3_x_pos, 0, m_pixmaps[sec/10]);
|
||||||
paint.drawPixmap (54, 0, m_pixmaps[sec%10]);
|
paint.drawPixmap (m_d4_x_pos, 0, m_pixmaps[sec%10]);
|
||||||
} else {
|
} else {
|
||||||
// Just give up and draw '-' if min would become 100 or bigger
|
// Just give up and draw '-' if min would become 100 or bigger
|
||||||
paint.drawPixmap (12, 0, m_pixmaps[11]);
|
paint.drawPixmap (m_d1_x_pos, 0, m_pixmaps[11]);
|
||||||
paint.drawPixmap (24, 0, m_pixmaps[11]);
|
paint.drawPixmap (m_d2_x_pos, 0, m_pixmaps[11]);
|
||||||
paint.drawPixmap (42, 0, m_pixmaps[11]);
|
paint.drawPixmap (m_d3_x_pos, 0, m_pixmaps[11]);
|
||||||
paint.drawPixmap (54, 0, m_pixmaps[11]);
|
paint.drawPixmap (m_d4_x_pos, 0, m_pixmaps[11]);
|
||||||
|
|
||||||
}
|
}
|
||||||
paint.end ();
|
paint.end ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
TimeDisplay::mouseReleaseEvent (QMouseEvent *event)
|
|
||||||
{
|
|
||||||
emit clicked();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -25,16 +25,17 @@ class QPixmap;
|
||||||
|
|
||||||
typedef QMap<int, QPixmap> PixmapMap;
|
typedef QMap<int, QPixmap> PixmapMap;
|
||||||
|
|
||||||
class TimeDisplay : public QWidget
|
// This class is not really abstract, but named so anyway
|
||||||
|
class AbstractTimeDisplay : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
TimeDisplay (QWidget *parent);
|
AbstractTimeDisplay (QWidget *parent) : QWidget (parent) {};
|
||||||
~TimeDisplay () {};
|
~AbstractTimeDisplay () {};
|
||||||
void setTime (int);
|
void setTime (int);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setPixmaps (const PixmapMap &p) {m_pixmaps = p;}
|
void setPixmaps (const PixmapMap &p);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void clicked(void);
|
void clicked(void);
|
||||||
|
@ -44,8 +45,28 @@ class TimeDisplay : public QWidget
|
||||||
void mouseReleaseEvent (QMouseEvent *event);
|
void mouseReleaseEvent (QMouseEvent *event);
|
||||||
void paintEvent (QPaintEvent *event);
|
void paintEvent (QPaintEvent *event);
|
||||||
|
|
||||||
|
// positions for the digits, numbered from left to right
|
||||||
|
int m_d1_x_pos;
|
||||||
|
int m_d2_x_pos;
|
||||||
|
int m_d3_x_pos;
|
||||||
|
int m_d4_x_pos;
|
||||||
|
|
||||||
int m_time;
|
int m_time;
|
||||||
PixmapMap m_pixmaps;
|
PixmapMap m_pixmaps;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TimeDisplay : public AbstractTimeDisplay
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
TimeDisplay (QWidget *parent);
|
||||||
|
};
|
||||||
|
|
||||||
|
class SmallTimeDisplay : public AbstractTimeDisplay
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
SmallTimeDisplay (QWidget *parent);
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue