OTHER: Replaced SmallNumberDisplay
This commit is contained in:
parent
a89be5dd9b
commit
058e2d0987
10 changed files with 153 additions and 126 deletions
|
@ -457,6 +457,7 @@ Skin::BuildLetterMap (void)
|
||||||
m_items[TEXTBG] = letters[2][6];
|
m_items[TEXTBG] = letters[2][6];
|
||||||
|
|
||||||
m_smallNumbers[10] = letters[2][6];
|
m_smallNumbers[10] = letters[2][6];
|
||||||
|
m_smallNumbers[-1] = m_smallNumbers[10]; // also add Blank to index -1
|
||||||
m_smallNumbers[11] = letters[1][15];
|
m_smallNumbers[11] = letters[1][15];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -747,6 +748,7 @@ Skin::BuildNumbers (void)
|
||||||
for (int i = 0; i < num; i++) {
|
for (int i = 0; i < num; i++) {
|
||||||
m_numbers[i] = img->copy (i*9, 0, 9, qMin (13, img->height ()));
|
m_numbers[i] = img->copy (i*9, 0, 9, qMin (13, img->height ()));
|
||||||
}
|
}
|
||||||
|
m_numbers[-1] = m_numbers[10]; // add Blank space to index -1
|
||||||
if (num < 12) {
|
if (num < 12) {
|
||||||
// We do not yet have a '-' Symbol, so we create one
|
// We do not yet have a '-' Symbol, so we create one
|
||||||
// from the '2' character and the blank as background
|
// from the '2' character and the blank as background
|
||||||
|
|
|
@ -1,65 +0,0 @@
|
||||||
/**
|
|
||||||
* This file is a part of Promoe, an XMMS2 Client.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2005-2008 XMMS2 Team
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; version 2 of the License.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "SmallNumberDisplay.h"
|
|
||||||
#include "Skin.h"
|
|
||||||
|
|
||||||
#include <QPainter>
|
|
||||||
|
|
||||||
SmallNumberDisplay::SmallNumberDisplay (QWidget *parent, int w) : PixWidget (parent)
|
|
||||||
{
|
|
||||||
m_w = w;
|
|
||||||
setMinimumSize (w, 6);
|
|
||||||
setMaximumSize (w, 6);
|
|
||||||
m_pixmap = QPixmap (w, 6);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
SmallNumberDisplay::setPixmaps (Skin *skin)
|
|
||||||
{
|
|
||||||
drawNumber ();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
SmallNumberDisplay::setNumber (int num, int len)
|
|
||||||
{
|
|
||||||
snprintf (m_nums, len+1, "%02d", num);
|
|
||||||
m_num = len;
|
|
||||||
|
|
||||||
drawNumber ();
|
|
||||||
|
|
||||||
update ();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
SmallNumberDisplay::drawNumber ()
|
|
||||||
{
|
|
||||||
Skin *skin = Skin::getInstance ();
|
|
||||||
|
|
||||||
QPainter paint;
|
|
||||||
paint.begin (&m_pixmap);
|
|
||||||
paint.drawPixmap (m_pixmap.rect (),
|
|
||||||
skin->getItem (Skin::TEXTBG),
|
|
||||||
m_pixmap.rect ());
|
|
||||||
|
|
||||||
for (int i = 0; i < m_num; i++) {
|
|
||||||
paint.drawPixmap (QRect (i*5, 0, 5, 6),
|
|
||||||
skin->getLetter (m_nums[i]),
|
|
||||||
skin->getLetter (m_nums[i]).rect ());
|
|
||||||
}
|
|
||||||
|
|
||||||
paint.end ();
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
/**
|
|
||||||
* This file is a part of Promoe, an XMMS2 Client.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2005-2008 XMMS2 Team
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; version 2 of the License.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __SMALLNUMBERDISPLAY_H__
|
|
||||||
#define __SMALLNUMBERDISPLAY_H__
|
|
||||||
|
|
||||||
#include "PixWidget.h"
|
|
||||||
|
|
||||||
|
|
||||||
class SmallNumberDisplay : public PixWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT;
|
|
||||||
|
|
||||||
public:
|
|
||||||
SmallNumberDisplay (QWidget *parent, int w);
|
|
||||||
~SmallNumberDisplay () { };
|
|
||||||
|
|
||||||
void setNumber (int num, int len);
|
|
||||||
int getNumber (void) const { return m_num; }
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void setPixmaps (Skin *skin);
|
|
||||||
|
|
||||||
private:
|
|
||||||
char m_nums[2];
|
|
||||||
int m_num;
|
|
||||||
int m_w;
|
|
||||||
|
|
||||||
void drawNumber (void);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include "TextBar.h"
|
#include "TextBar.h"
|
||||||
#include "timedisplay.h"
|
#include "timedisplay.h"
|
||||||
#include "Skin.h"
|
#include "Skin.h"
|
||||||
#include "SmallNumberDisplay.h"
|
#include "pixmapnumberdisplay.h"
|
||||||
#include "stereomono.h"
|
#include "stereomono.h"
|
||||||
#include "posbar.h"
|
#include "posbar.h"
|
||||||
#include "playstatus.h"
|
#include "playstatus.h"
|
||||||
|
@ -63,13 +63,17 @@ MainDisplay::MainDisplay (QWidget *parent) : SkinDisplay(parent)
|
||||||
m_time->move (36, 26);
|
m_time->move (36, 26);
|
||||||
connect (m_time, SIGNAL(clicked()), m_mw, SLOT(toggleTime()));
|
connect (m_time, SIGNAL(clicked()), m_mw, SLOT(toggleTime()));
|
||||||
|
|
||||||
m_kbps = new SmallNumberDisplay (this, 15);
|
m_kbps = new PixmapNumberDisplay (this);
|
||||||
|
m_kbps->resize (15, 6);
|
||||||
m_kbps->move (111, 43);
|
m_kbps->move (111, 43);
|
||||||
m_kbps->setNumber (128, 3);
|
m_kbps->setDigits (3);
|
||||||
|
m_kbps->setValue (0);
|
||||||
|
|
||||||
m_khz = new SmallNumberDisplay (this, 10);
|
m_khz = new PixmapNumberDisplay (this);
|
||||||
|
m_khz->resize (10, 6);
|
||||||
m_khz->move (156, 43);
|
m_khz->move (156, 43);
|
||||||
m_khz->setNumber (44, 2);
|
m_khz->setDigits (2);
|
||||||
|
m_khz->setValue (0);
|
||||||
|
|
||||||
m_stereo = new StereoMono (this);
|
m_stereo = new StereoMono (this);
|
||||||
m_stereo->move (212, 41);
|
m_stereo->move (212, 41);
|
||||||
|
@ -119,7 +123,7 @@ MainDisplay::MainDisplay (QWidget *parent) : SkinDisplay(parent)
|
||||||
void
|
void
|
||||||
MainDisplay::handleDisconnected ()
|
MainDisplay::handleDisconnected ()
|
||||||
{
|
{
|
||||||
QMessageBox::critical( this, "xmms2 daemon disconnecte",
|
QMessageBox::critical( this, "xmms2 daemon disconnected",
|
||||||
"The xmms2 deamon has disconnected\n"
|
"The xmms2 deamon has disconnected\n"
|
||||||
"This could be because the server crashed\n"
|
"This could be because the server crashed\n"
|
||||||
"or because another client has shut down the sever.",
|
"or because another client has shut down the sever.",
|
||||||
|
@ -173,6 +177,8 @@ MainDisplay::setPixmaps (Skin *skin)
|
||||||
|
|
||||||
/* update some other widgets */
|
/* update some other widgets */
|
||||||
m_time->setPixmaps (skin->getNumbers ());
|
m_time->setPixmaps (skin->getNumbers ());
|
||||||
|
m_kbps->setPixmaps (skin->getSmallNumbers ());
|
||||||
|
m_khz->setPixmaps (skin->getSmallNumbers ());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -236,15 +242,15 @@ MainDisplay::setMediainfo (const Xmms::PropDict &info)
|
||||||
m_text->setText (n);
|
m_text->setText (n);
|
||||||
|
|
||||||
if (info.contains ("bitrate")) {
|
if (info.contains ("bitrate")) {
|
||||||
m_kbps->setNumber (info.get<int32_t> ("bitrate")/1000, 3);
|
m_kbps->setValue (info.get<int32_t> ("bitrate")/1000);
|
||||||
} else {
|
} else {
|
||||||
m_kbps->setNumber (0, 1);
|
m_kbps->setValue (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.contains ("samplerate")) {
|
if (info.contains ("samplerate")) {
|
||||||
m_khz->setNumber (info.get<int32_t> ("samplerate")/1000, 2);
|
m_khz->setValue (info.get<int32_t> ("samplerate")/1000);
|
||||||
} else {
|
} else {
|
||||||
m_khz->setNumber(0, 1);
|
m_khz->setValue(0);
|
||||||
}
|
}
|
||||||
if (info.contains ("channels") &&
|
if (info.contains ("channels") &&
|
||||||
info.get<int32_t> ("channels") > 1) {
|
info.get<int32_t> ("channels") > 1) {
|
||||||
|
|
|
@ -33,10 +33,10 @@ class MainDisplay;
|
||||||
#include "Display.h"
|
#include "Display.h"
|
||||||
|
|
||||||
class PixmapButton;
|
class PixmapButton;
|
||||||
|
class PixmapNumberDisplay;
|
||||||
class PixmapSlider;
|
class PixmapSlider;
|
||||||
class TextScroller;
|
class TextScroller;
|
||||||
class TimeDisplay;
|
class TimeDisplay;
|
||||||
class SmallNumberDisplay;
|
|
||||||
class StereoMono;
|
class StereoMono;
|
||||||
class PosBar;
|
class PosBar;
|
||||||
class Slider;
|
class Slider;
|
||||||
|
@ -55,9 +55,6 @@ class MainDisplay : public SkinDisplay
|
||||||
TextScroller *m_text;
|
TextScroller *m_text;
|
||||||
TimeDisplay *m_time;
|
TimeDisplay *m_time;
|
||||||
|
|
||||||
SmallNumberDisplay *m_kbps;
|
|
||||||
SmallNumberDisplay *m_khz;
|
|
||||||
|
|
||||||
StereoMono *m_stereo;
|
StereoMono *m_stereo;
|
||||||
PosBar *m_posbar;
|
PosBar *m_posbar;
|
||||||
PixmapSlider *m_vslider;
|
PixmapSlider *m_vslider;
|
||||||
|
@ -94,6 +91,9 @@ class MainDisplay : public SkinDisplay
|
||||||
PixmapButton *m_shuffle;
|
PixmapButton *m_shuffle;
|
||||||
PixmapButton *m_repeat;
|
PixmapButton *m_repeat;
|
||||||
|
|
||||||
|
PixmapNumberDisplay *m_kbps;
|
||||||
|
PixmapNumberDisplay *m_khz;
|
||||||
|
|
||||||
MainWindow *m_mw;
|
MainWindow *m_mw;
|
||||||
|
|
||||||
ClutterBar *m_clutterbar;
|
ClutterBar *m_clutterbar;
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include "pixmapbutton.h"
|
#include "pixmapbutton.h"
|
||||||
|
|
||||||
#include "timedisplay.h"
|
#include "timedisplay.h"
|
||||||
#include "SmallNumberDisplay.h"
|
|
||||||
#include "TextBar.h"
|
#include "TextBar.h"
|
||||||
#include "Skin.h"
|
#include "Skin.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
|
@ -10,7 +10,6 @@ HEADERS += PixWidget.h \
|
||||||
TitleBar.h \
|
TitleBar.h \
|
||||||
TextBar.h \
|
TextBar.h \
|
||||||
XMMSHandler.h \
|
XMMSHandler.h \
|
||||||
SmallNumberDisplay.h \
|
|
||||||
SkinChooser.h \
|
SkinChooser.h \
|
||||||
settingsdialog.h \
|
settingsdialog.h \
|
||||||
basewindow.h \
|
basewindow.h \
|
||||||
|
@ -25,7 +24,6 @@ SOURCES += main.cpp \
|
||||||
TitleBar.cpp \
|
TitleBar.cpp \
|
||||||
TextBar.cpp \
|
TextBar.cpp \
|
||||||
XMMSHandler.cpp \
|
XMMSHandler.cpp \
|
||||||
SmallNumberDisplay.cpp \
|
|
||||||
SkinChooser.cpp \
|
SkinChooser.cpp \
|
||||||
settingsdialog.cpp \
|
settingsdialog.cpp \
|
||||||
basewindow.cpp \
|
basewindow.cpp \
|
||||||
|
|
80
src/widgets/pixmapnumberdisplay.cpp
Normal file
80
src/widgets/pixmapnumberdisplay.cpp
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
/**
|
||||||
|
* This file is a part of Promoe, an XMMS2 Client.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2005-2008 XMMS2 Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "pixmapnumberdisplay.h"
|
||||||
|
#include "math.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
PixmapNumberDisplay::PixmapNumberDisplay (QWidget *parent) : QWidget (parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PixmapNumberDisplay::setPixmaps (PixmapMap numbers)
|
||||||
|
{
|
||||||
|
m_numbers = numbers;
|
||||||
|
update ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PixmapNumberDisplay::setValue (int value)
|
||||||
|
{
|
||||||
|
if (m_value == value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_value = value;
|
||||||
|
update ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PixmapNumberDisplay::setDigits (unsigned int digits)
|
||||||
|
{
|
||||||
|
if (m_digits == digits)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_digits = digits;
|
||||||
|
update ();
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
PixmapNumberDisplay::getDigitAtPos (unsigned int position) {
|
||||||
|
if (m_value == 0) {
|
||||||
|
if (position == 1)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if ( m_value / (unsigned int) pow (10, position - 1) == 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return (unsigned int) (m_value / pow (10, position - 1)) % 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PixmapNumberDisplay::paintEvent (QPaintEvent *event)
|
||||||
|
{
|
||||||
|
QPainter paint;
|
||||||
|
paint.begin (this);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < m_digits; i++) {
|
||||||
|
paint.drawPixmap (i*5, 0,
|
||||||
|
m_numbers[getDigitAtPos (m_digits - i)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
paint.end ();
|
||||||
|
}
|
||||||
|
|
49
src/widgets/pixmapnumberdisplay.h
Normal file
49
src/widgets/pixmapnumberdisplay.h
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
/**
|
||||||
|
* This file is a part of Promoe, an XMMS2 Client.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2005-2008 XMMS2 Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __PIXMAPNUMBERDISPLAY_H__
|
||||||
|
#define __PIXMAPNUMBERDISPLAY_H__
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QMap>
|
||||||
|
|
||||||
|
class QPaintEvent;
|
||||||
|
class Skin;
|
||||||
|
|
||||||
|
typedef QMap<int, QPixmap> PixmapMap;
|
||||||
|
|
||||||
|
class PixmapNumberDisplay : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
PixmapNumberDisplay (QWidget *parent);
|
||||||
|
~PixmapNumberDisplay () { };
|
||||||
|
|
||||||
|
void setValue (int value);
|
||||||
|
void setDigits (unsigned int digits);
|
||||||
|
void setPixmaps (PixmapMap numbers);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_value;
|
||||||
|
unsigned int m_digits;
|
||||||
|
PixmapMap m_numbers;
|
||||||
|
|
||||||
|
int getDigitAtPos (unsigned int position);
|
||||||
|
void paintEvent (QPaintEvent *event);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,7 +1,9 @@
|
||||||
HEADERS += pixmapbutton.h \
|
HEADERS += pixmapbutton.h \
|
||||||
|
pixmapnumberdisplay.h \
|
||||||
pixmapslider.h
|
pixmapslider.h
|
||||||
|
|
||||||
SOURCES += pixmapbutton.cpp \
|
SOURCES += pixmapbutton.cpp \
|
||||||
|
pixmapnumberdisplay.cpp \
|
||||||
pixmapslider.cpp
|
pixmapslider.cpp
|
||||||
|
|
||||||
INCLUDEPATH += $$PWD
|
INCLUDEPATH += $$PWD
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue