Added the volume slider, and made the Skin loader a bit more robust in the face

of garbage/moved/deleted skins.
This commit is contained in:
Chris Gilbert 2006-03-15 06:28:34 +01:00 committed by Tobias Rundstrom
parent d7eede1737
commit 73e283cc48
7 changed files with 685 additions and 273 deletions

View file

@ -48,6 +48,9 @@ MainDisplay::MainDisplay (QWidget *parent) : SkinDisplay(parent)
m_playstatus = new PlayStatus (this);
m_playstatus->move (24, 28);
m_vslider = new VolumeSlider(this);
m_vslider->move (107, 57);
connect (xmmsh, SIGNAL(currentSong (const QHash<QString, QString> &)),
this, SLOT(setMediainfo (const QHash<QString, QString> &)));
connect (xmmsh, SIGNAL(playbackStatusChanged(uint)),

View file

@ -23,6 +23,7 @@ class MainDisplay;
#include "StereoMono.h"
#include "Slider.h"
#include "PlayStatus.h"
#include "VolumeSlider.h"
#include "MainWindow.h"
class MainDisplay : public SkinDisplay
@ -42,7 +43,8 @@ class MainDisplay : public SkinDisplay
StereoMono *m_stereo;
Slider *m_slider;
VolumeSlider *m_vslider;
PlayStatus *m_playstatus;
public slots:

605
Skin.cpp
View file

@ -18,114 +18,119 @@ Skin::BuildPlaylist (void)
QPixmap *img = getPixmap ("pledit");
m_playlist[PLS_CORNER_UL_0] = img->copy(0, 0, 25, 20);
m_playlist[PLS_CORNER_UL_1] = img->copy(0, 21, 25, 20);
if(img)
{
m_playlist[PLS_CORNER_UL_0] = img->copy(0, 0, 25, 20);
m_playlist[PLS_CORNER_UL_1] = img->copy(0, 21, 25, 20);
m_playlist[PLS_TBAR_0] = img->copy (26, 0, 100, 20);
m_playlist[PLS_TBAR_1] = img->copy (26, 21, 100, 20);
m_playlist[PLS_CORNER_UR_0] = img->copy(153, 0, 25, 20);
m_playlist[PLS_CORNER_UR_1] = img->copy(153, 21, 25, 20);
m_playlist[PLS_TBAR_0] = img->copy (26, 0, 100, 20);
m_playlist[PLS_TBAR_1] = img->copy (26, 21, 100, 20);
m_playlist[PLS_TFILL_0] = img->copy(127, 0, 25, 20);
m_playlist[PLS_TFILL_1] = img->copy(127, 21, 25, 20);
m_playlist[PLS_CORNER_UR_0] = img->copy(153, 0, 25, 20);
m_playlist[PLS_CORNER_UR_1] = img->copy(153, 21, 25, 20);
m_playlist[PLS_TFILL_0] = img->copy(127, 0, 25, 20);
m_playlist[PLS_TFILL_1] = img->copy(127, 21, 25, 20);
m_playlist[PLS_BFILL_0] = img->copy(179, 0, 25, 38);
m_playlist[PLS_VISMINI_0] = img->copy(205, 0, 75, 38);
m_playlist[PLS_LFILL_0] = img->copy(0, 42, 12, 29);
m_playlist[PLS_RFILL_0] = img->copy(31, 42, 5, 29);
m_playlist[PLS_RFILL2_0] = img->copy(36, 42, 8, 29);
m_playlist[PLS_RFILL3_0] = img->copy(44, 42, 7, 29);
tmp = m_playlist[PLS_CORNER_UR_0];
m_playlist[PLS_CLOSE_BTN_0] = tmp.copy(14, 3, 9, 9);
m_playlist[PLS_CLOSE_BTN_1] = img->copy(52, 42, 9, 9);
m_playlist[PLS_SHADE_BTN_0] = tmp.copy(14, 3, 9, 9);
m_playlist[PLS_SHADE_BTN_1] = img->copy(62, 42, 9, 9);
m_playlist[PLS_MAX_BTN_0] = img->copy(150, 42, 9, 9);
m_playlist[PLS_SCROLL_0] = img->copy(52, 53, 8, 18);
m_playlist[PLS_SCROLL_1] = img->copy(61, 53, 8, 18);
m_playlist[PLS_WS_LE_0] = img->copy(72, 42, 25, 14);
m_playlist[PLS_WS_RE_0] = img->copy(99, 42, 50, 14);
m_playlist[PLS_WS_RE_1] = img->copy(99, 57, 50, 14);
m_playlist[PLS_WS_MID_0] = img->copy(72, 57, 25, 14);
m_playlist[PLS_LCBAR] = img->copy(0, 72, 125, 38);
m_playlist[PLS_RCBAR] = img->copy(126, 72, 150, 38);
/* extract the buttons */
m_playlist[PLS_ADD] = img->copy(11, 80, 25, 18);
m_playlist[PLS_ADD_DEC] = img->copy(48, 111, 3, 54);
m_playlist[PLS_ADD_URL_0] = img->copy(0, 111, 22, 18);
m_playlist[PLS_ADD_URL_1] = img->copy(23, 111, 22, 18);
m_playlist[PLS_BFILL_0] = img->copy(179, 0, 25, 38);
m_playlist[PLS_ADD_DIR_0] = img->copy(0, 130, 22, 18);
m_playlist[PLS_ADD_DIR_1] = img->copy(23, 130, 22, 18);
m_playlist[PLS_ADD_FIL_0] = img->copy(0, 149, 22, 18);
m_playlist[PLS_ADD_FIL_1] = img->copy(23, 149, 22, 18);
/* Delete buttons */
m_playlist[PLS_DEL] = img->copy(40, 80, 25, 18);
m_playlist[PLS_DEL_DEC] = img->copy(100, 111, 3, 72);
m_playlist[PLS_DEL_ALL_0] = img->copy(54, 111, 22, 18);
m_playlist[PLS_DEL_ALL_1] = img->copy(77, 111, 22, 18);
m_playlist[PLS_VISMINI_0] = img->copy(205, 0, 75, 38);
m_playlist[PLS_DEL_CRP_0] = img->copy(54, 130, 22, 18);
m_playlist[PLS_DEL_CRP_1] = img->copy(77, 130, 22, 18);
m_playlist[PLS_LFILL_0] = img->copy(0, 42, 12, 29);
m_playlist[PLS_DEL_FIL_0] = img->copy(54, 149, 22, 18);
m_playlist[PLS_DEL_FIL_1] = img->copy(77, 149, 22, 18);
m_playlist[PLS_RFILL_0] = img->copy(31, 42, 5, 29);
m_playlist[PLS_RFILL2_0] = img->copy(36, 42, 8, 29);
m_playlist[PLS_RFILL3_0] = img->copy(44, 42, 7, 29);
/* Select buttons */
m_playlist[PLS_SEL] = img->copy(69, 80, 25, 18);
m_playlist[PLS_SEL_DEC] = img->copy(150, 111, 3, 54);
m_playlist[PLS_SEL_INV_0] = img->copy(104, 111, 22, 18);
m_playlist[PLS_SEL_INV_1] = img->copy(127, 111, 22, 18);
m_playlist[PLS_SEL_NIL_0] = img->copy(104, 130, 22, 18);
m_playlist[PLS_SEL_NIL_1] = img->copy(127, 130, 22, 18);
tmp = m_playlist[PLS_CORNER_UR_0];
m_playlist[PLS_SEL_ALL_0] = img->copy(104, 149, 22, 18);
m_playlist[PLS_SEL_ALL_1] = img->copy(127, 149, 22, 18);
/* misc buttons */
m_playlist[PLS_MSC] = img->copy(98, 80, 25, 18);
m_playlist[PLS_MSC_DEC] = img->copy(200, 111, 3, 54);
m_playlist[PLS_MSC_SRT_0] = img->copy(154, 111, 22, 18);
m_playlist[PLS_MSC_SRT_1] = img->copy(177, 111, 22, 18);
m_playlist[PLS_MSC_INF_0] = img->copy(154, 130, 22, 18);
m_playlist[PLS_MSC_INF_1] = img->copy(177, 130, 22, 18);
m_playlist[PLS_CLOSE_BTN_0] = tmp.copy(14, 3, 9, 9);
m_playlist[PLS_CLOSE_BTN_1] = img->copy(52, 42, 9, 9);
m_playlist[PLS_MSC_OPT_0] = img->copy(154, 149, 22, 18);
m_playlist[PLS_MSC_OPT_1] = img->copy(177, 149, 22, 18);
m_playlist[PLS_SHADE_BTN_0] = tmp.copy(14, 3, 9, 9);
m_playlist[PLS_SHADE_BTN_1] = img->copy(62, 42, 9, 9);
/* list buttons */
m_playlist[PLS_LST] = img->copy(229, 80, 25, 18);
m_playlist[PLS_LST_DEC] = img->copy(250, 111, 3, 54);
m_playlist[PLS_LST_NEW_0] = img->copy(204, 111, 22, 18);
m_playlist[PLS_LST_NEW_1] = img->copy(227, 111, 22, 18);
m_playlist[PLS_LST_SAV_0] = img->copy(204, 130, 22, 18);
m_playlist[PLS_LST_SAV_1] = img->copy(227, 130, 22, 18);
m_playlist[PLS_LST_OPN_0] = img->copy(204, 149, 22, 18);
m_playlist[PLS_LST_OPN_1] = img->copy(227, 149, 22, 18);
/* misc button */
m_playlist[PLS_MSC_BTN_0] = img->copy(54, 168, 22, 18);
m_playlist[PLS_MSC_BTN_1] = img->copy(77, 168, 22, 18);
delete img;
m_playlist[PLS_MAX_BTN_0] = img->copy(150, 42, 9, 9);
m_playlist[PLS_SCROLL_0] = img->copy(52, 53, 8, 18);
m_playlist[PLS_SCROLL_1] = img->copy(61, 53, 8, 18);
m_playlist[PLS_WS_LE_0] = img->copy(72, 42, 25, 14);
m_playlist[PLS_WS_RE_0] = img->copy(99, 42, 50, 14);
m_playlist[PLS_WS_RE_1] = img->copy(99, 57, 50, 14);
m_playlist[PLS_WS_MID_0] = img->copy(72, 57, 25, 14);
m_playlist[PLS_LCBAR] = img->copy(0, 72, 125, 38);
m_playlist[PLS_RCBAR] = img->copy(126, 72, 150, 38);
/* extract the buttons */
m_playlist[PLS_ADD] = img->copy(11, 80, 25, 18);
m_playlist[PLS_ADD_DEC] = img->copy(48, 111, 3, 54);
m_playlist[PLS_ADD_URL_0] = img->copy(0, 111, 22, 18);
m_playlist[PLS_ADD_URL_1] = img->copy(23, 111, 22, 18);
m_playlist[PLS_ADD_DIR_0] = img->copy(0, 130, 22, 18);
m_playlist[PLS_ADD_DIR_1] = img->copy(23, 130, 22, 18);
m_playlist[PLS_ADD_FIL_0] = img->copy(0, 149, 22, 18);
m_playlist[PLS_ADD_FIL_1] = img->copy(23, 149, 22, 18);
/* Delete buttons */
m_playlist[PLS_DEL] = img->copy(40, 80, 25, 18);
m_playlist[PLS_DEL_DEC] = img->copy(100, 111, 3, 72);
m_playlist[PLS_DEL_ALL_0] = img->copy(54, 111, 22, 18);
m_playlist[PLS_DEL_ALL_1] = img->copy(77, 111, 22, 18);
m_playlist[PLS_DEL_CRP_0] = img->copy(54, 130, 22, 18);
m_playlist[PLS_DEL_CRP_1] = img->copy(77, 130, 22, 18);
m_playlist[PLS_DEL_FIL_0] = img->copy(54, 149, 22, 18);
m_playlist[PLS_DEL_FIL_1] = img->copy(77, 149, 22, 18);
/* Select buttons */
m_playlist[PLS_SEL] = img->copy(69, 80, 25, 18);
m_playlist[PLS_SEL_DEC] = img->copy(150, 111, 3, 54);
m_playlist[PLS_SEL_INV_0] = img->copy(104, 111, 22, 18);
m_playlist[PLS_SEL_INV_1] = img->copy(127, 111, 22, 18);
m_playlist[PLS_SEL_NIL_0] = img->copy(104, 130, 22, 18);
m_playlist[PLS_SEL_NIL_1] = img->copy(127, 130, 22, 18);
m_playlist[PLS_SEL_ALL_0] = img->copy(104, 149, 22, 18);
m_playlist[PLS_SEL_ALL_1] = img->copy(127, 149, 22, 18);
/* misc buttons */
m_playlist[PLS_MSC] = img->copy(98, 80, 25, 18);
m_playlist[PLS_MSC_DEC] = img->copy(200, 111, 3, 54);
m_playlist[PLS_MSC_SRT_0] = img->copy(154, 111, 22, 18);
m_playlist[PLS_MSC_SRT_1] = img->copy(177, 111, 22, 18);
m_playlist[PLS_MSC_INF_0] = img->copy(154, 130, 22, 18);
m_playlist[PLS_MSC_INF_1] = img->copy(177, 130, 22, 18);
m_playlist[PLS_MSC_OPT_0] = img->copy(154, 149, 22, 18);
m_playlist[PLS_MSC_OPT_1] = img->copy(177, 149, 22, 18);
/* list buttons */
m_playlist[PLS_LST] = img->copy(229, 80, 25, 18);
m_playlist[PLS_LST_DEC] = img->copy(250, 111, 3, 54);
m_playlist[PLS_LST_NEW_0] = img->copy(204, 111, 22, 18);
m_playlist[PLS_LST_NEW_1] = img->copy(227, 111, 22, 18);
m_playlist[PLS_LST_SAV_0] = img->copy(204, 130, 22, 18);
m_playlist[PLS_LST_SAV_1] = img->copy(227, 130, 22, 18);
m_playlist[PLS_LST_OPN_0] = img->copy(204, 149, 22, 18);
m_playlist[PLS_LST_OPN_1] = img->copy(227, 149, 22, 18);
/* misc button */
m_playlist[PLS_MSC_BTN_0] = img->copy(54, 168, 22, 18);
m_playlist[PLS_MSC_BTN_1] = img->copy(77, 168, 22, 18);
delete img;
}
else
setSkin(":CleanAMP/");
}
@ -203,61 +208,66 @@ Skin::BuildLetterMap (void)
{
QPixmap *img = getPixmap("text");
QList<QList<QPixmap> >(letters);
for (int i = 0; i < 3; i++) {
QList<QPixmap>(l);
for (int j = 0; j < 31; j++) {
l.append(img->copy(j*5, i*6, 4, 6));
if(img)
{
QList<QList<QPixmap> >(letters);
for (int i = 0; i < 3; i++) {
QList<QPixmap>(l);
for (int j = 0; j < 31; j++) {
l.append(img->copy(j*5, i*6, 4, 6));
}
letters.append(l);
}
letters.append(l);
delete img;
/* alphabet */
for (uint i = 97; i < 123; i++) {
m_letterMap[i] = letters[0][i-97];
}
/* digits */
for (uint i = 0; i <= 9; i++) {
m_letterMap[i+48] = letters[1][i];
}
/* special characters */
m_letterMap['"'] = letters[0][27];
m_letterMap['@'] = letters[0][28];
m_letterMap['('] = letters[1][13];
m_letterMap[')'] = letters[1][14];
m_letterMap['-'] = letters[1][15];
m_letterMap['\''] = letters[1][16];
m_letterMap['`'] = letters[1][16];
m_letterMap['!'] = letters[1][17];
m_letterMap['_'] = letters[1][18];
m_letterMap['+'] = letters[1][19];
m_letterMap['\\'] = letters[1][20];
m_letterMap['/'] = letters[1][21];
m_letterMap['['] = letters[1][22];
m_letterMap[']'] = letters[1][23];
m_letterMap['^'] = letters[1][24];
m_letterMap['&'] = letters[1][25];
m_letterMap['%'] = letters[1][26];
m_letterMap['.'] = letters[1][27];
m_letterMap[','] = letters[1][27];
m_letterMap['='] = letters[1][28];
m_letterMap['$'] = letters[1][29];
m_letterMap['#'] = letters[1][30];
m_letterMap[229] = letters[2][0];
m_letterMap[246] = letters[2][1];
m_letterMap[228] = letters[2][2];
m_letterMap['?'] = letters[2][3];
m_letterMap['*'] = letters[2][4];
m_letterMap[' '] = letters[2][5];
/* text background */
m_items[TEXTBG] = letters[2][6];
}
delete img;
/* alphabet */
for (uint i = 97; i < 123; i++) {
m_letterMap[i] = letters[0][i-97];
}
/* digits */
for (uint i = 0; i <= 9; i++) {
m_letterMap[i+48] = letters[1][i];
}
/* special characters */
m_letterMap['"'] = letters[0][27];
m_letterMap['@'] = letters[0][28];
m_letterMap['('] = letters[1][13];
m_letterMap[')'] = letters[1][14];
m_letterMap['-'] = letters[1][15];
m_letterMap['\''] = letters[1][16];
m_letterMap['`'] = letters[1][16];
m_letterMap['!'] = letters[1][17];
m_letterMap['_'] = letters[1][18];
m_letterMap['+'] = letters[1][19];
m_letterMap['\\'] = letters[1][20];
m_letterMap['/'] = letters[1][21];
m_letterMap['['] = letters[1][22];
m_letterMap[']'] = letters[1][23];
m_letterMap['^'] = letters[1][24];
m_letterMap['&'] = letters[1][25];
m_letterMap['%'] = letters[1][26];
m_letterMap['.'] = letters[1][27];
m_letterMap[','] = letters[1][27];
m_letterMap['='] = letters[1][28];
m_letterMap['$'] = letters[1][29];
m_letterMap['#'] = letters[1][30];
m_letterMap[229] = letters[2][0];
m_letterMap[246] = letters[2][1];
m_letterMap[228] = letters[2][2];
m_letterMap['?'] = letters[2][3];
m_letterMap['*'] = letters[2][4];
m_letterMap[' '] = letters[2][5];
/* text background */
m_items[TEXTBG] = letters[2][6];
else
setSkin(":CleanAMP/");
}
@ -265,26 +275,30 @@ void
Skin::BuildButtons (void)
{
QPixmap *img = getPixmap("cbuttons");
if(img)
{
m_items[BTN_PREV_0] = img->copy(0, 0, 23, 18);
m_items[BTN_PREV_1] = img->copy(0, 18, 23, 18);
m_items[BTN_PREV_0] = img->copy(0, 0, 23, 18);
m_items[BTN_PREV_1] = img->copy(0, 18, 23, 18);
m_items[BTN_PLAY_0] = img->copy(23, 0, 23, 18);
m_items[BTN_PLAY_1] = img->copy(23, 18, 23, 18);
m_items[BTN_PAUSE_0] = img->copy(46, 0, 23, 18);
m_items[BTN_PAUSE_1] = img->copy(46, 18, 23, 18);
m_items[BTN_STOP_0] = img->copy(69, 0, 23, 18);
m_items[BTN_STOP_1] = img->copy(69, 18, 23, 18);
m_items[BTN_NEXT_0] = img->copy(92, 0, 22, 18);
m_items[BTN_NEXT_1] = img->copy(92, 18, 22, 18);
m_items[BTN_EJECT_0] = img->copy(114, 0, 22, 16);
m_items[BTN_EJECT_1] = img->copy(114, 16, 22, 16);
delete img;
m_items[BTN_PLAY_0] = img->copy(23, 0, 23, 18);
m_items[BTN_PLAY_1] = img->copy(23, 18, 23, 18);
m_items[BTN_PAUSE_0] = img->copy(46, 0, 23, 18);
m_items[BTN_PAUSE_1] = img->copy(46, 18, 23, 18);
m_items[BTN_STOP_0] = img->copy(69, 0, 23, 18);
m_items[BTN_STOP_1] = img->copy(69, 18, 23, 18);
m_items[BTN_NEXT_0] = img->copy(92, 0, 22, 18);
m_items[BTN_NEXT_1] = img->copy(92, 18, 22, 18);
m_items[BTN_EJECT_0] = img->copy(114, 0, 22, 16);
m_items[BTN_EJECT_1] = img->copy(114, 16, 22, 16);
delete img;
}
else
setSkin(":CleanAMP/");
}
@ -293,31 +307,36 @@ Skin::BuildToggleButtons (void)
{
QPixmap *img = getPixmap("shufrep");
m_items[REPEAT_ON_0] = img->copy(0, 30, 28, 15);
m_items[REPEAT_ON_1] = img->copy(0, 45, 28, 15);
m_items[REPEAT_OFF_0] = img->copy(0, 0, 28, 15);
m_items[REPEAT_OFF_1] = img->copy(0, 15, 28, 15);
m_items[SHUFFLE_ON_0] = img->copy(28, 30, 46, 15);
m_items[SHUFFLE_ON_1] = img->copy(28, 45, 46, 15);
m_items[SHUFFLE_OFF_0] = img->copy(28, 0, 46, 15);
m_items[SHUFFLE_OFF_1] = img->copy(28, 15, 46, 15);
m_items[EQ_ON_0] = img->copy( 0, 73, 23, 12);
m_items[EQ_ON_1] = img->copy(46, 73, 23, 12);
m_items[EQ_OFF_0] = img->copy( 0, 61, 23, 12);
m_items[EQ_OFF_1] = img->copy(46, 61, 23, 12);
m_items[PLS_ON_0] = img->copy(23, 73, 23, 12);
m_items[PLS_ON_1] = img->copy(69, 73, 23, 12);
m_items[PLS_OFF_0] = img->copy(23, 61, 23, 12);
m_items[PLS_OFF_1] = img->copy(69, 61, 23, 12);
delete img;
if(img)
{
m_items[REPEAT_ON_0] = img->copy(0, 30, 28, 15);
m_items[REPEAT_ON_1] = img->copy(0, 45, 28, 15);
m_items[REPEAT_OFF_0] = img->copy(0, 0, 28, 15);
m_items[REPEAT_OFF_1] = img->copy(0, 15, 28, 15);
m_items[SHUFFLE_ON_0] = img->copy(28, 30, 46, 15);
m_items[SHUFFLE_ON_1] = img->copy(28, 45, 46, 15);
m_items[SHUFFLE_OFF_0] = img->copy(28, 0, 46, 15);
m_items[SHUFFLE_OFF_1] = img->copy(28, 15, 46, 15);
m_items[EQ_ON_0] = img->copy( 0, 73, 23, 12);
m_items[EQ_ON_1] = img->copy(46, 73, 23, 12);
m_items[EQ_OFF_0] = img->copy( 0, 61, 23, 12);
m_items[EQ_OFF_1] = img->copy(46, 61, 23, 12);
m_items[PLS_ON_0] = img->copy(23, 73, 23, 12);
m_items[PLS_ON_1] = img->copy(69, 73, 23, 12);
m_items[PLS_OFF_0] = img->copy(23, 61, 23, 12);
m_items[PLS_OFF_1] = img->copy(69, 61, 23, 12);
delete img;
}
else
setSkin(":CleanAMP/");
}
@ -326,28 +345,33 @@ Skin::BuildTitleBar (void)
{
QPixmap *img = getPixmap("titlebar");
m_items[MENUBUTTON_0] = img->copy(0, 0, 9, 9);
m_items[MENUBUTTON_1] = img->copy(0, 9, 9, 9);
m_items[MINIMIZE_0] = img->copy(9, 0, 9, 9);
m_items[MINIMIZE_1] = img->copy(9, 9, 9, 9);
m_items[CLOSE_0] = img->copy(18, 0, 9, 9);
m_items[CLOSE_1] = img->copy(18, 9, 9 ,9);
m_items[SHADE_1_0] = img->copy(0, 18, 9, 9);
m_items[SHADE_1_1] = img->copy(9, 18, 9, 9);
m_items[SHADE_2_0] = img->copy(0, 27, 9, 9);
m_items[SHADE_2_1] = img->copy(9, 27, 9, 9);
m_items[TITLEBAR_0] = img->copy(27, 0, 275, 14);
m_items[TITLEBAR_1] = img->copy(27, 15, 275, 14);
m_items[STATUSBAR_0] = img->copy(27, 29, 275, 14);
m_items[STATUSBAR_1] = img->copy(27, 29+13, 275, 14);
delete img;
if(img)
{
m_items[MENUBUTTON_0] = img->copy(0, 0, 9, 9);
m_items[MENUBUTTON_1] = img->copy(0, 9, 9, 9);
m_items[MINIMIZE_0] = img->copy(9, 0, 9, 9);
m_items[MINIMIZE_1] = img->copy(9, 9, 9, 9);
m_items[CLOSE_0] = img->copy(18, 0, 9, 9);
m_items[CLOSE_1] = img->copy(18, 9, 9 ,9);
m_items[SHADE_1_0] = img->copy(0, 18, 9, 9);
m_items[SHADE_1_1] = img->copy(9, 18, 9, 9);
m_items[SHADE_2_0] = img->copy(0, 27, 9, 9);
m_items[SHADE_2_1] = img->copy(9, 27, 9, 9);
m_items[TITLEBAR_0] = img->copy(27, 0, 275, 14);
m_items[TITLEBAR_1] = img->copy(27, 15, 275, 14);
m_items[STATUSBAR_0] = img->copy(27, 29, 275, 14);
m_items[STATUSBAR_1] = img->copy(27, 29+13, 275, 14);
delete img;
}
else
setSkin(":CleanAMP/");
}
@ -358,47 +382,59 @@ Skin::BuildOther (void)
QPainter(painter);
img = getPixmap("monoster");
m_items[MONO_1] = img->copy(29, 0, 27, 12);
m_items[MONO_0] = img->copy(29, 12, 27, 12);
m_items[STEREO_1] = img->copy(0, 0, 29, 12);
m_items[STEREO_0] = img->copy(0, 12, 29, 12);
delete img;
if(img)
{
m_items[MONO_1] = img->copy(29, 0, 27, 12);
m_items[MONO_0] = img->copy(29, 12, 27, 12);
m_items[STEREO_1] = img->copy(0, 0, 29, 12);
m_items[STEREO_0] = img->copy(0, 12, 29, 12);
delete img;
}
else
setSkin(":CleanAMP/");
img = getPixmap("playpaus");
if(img)
{
part = new QPixmap(11, 9);
painter.begin(part);
painter.drawPixmap (0, 0, 3, 9, *img, 36, 0, 3, 9);
painter.drawPixmap (3, 0, 8, 9, *img, 1, 0, 8, 9);
painter.end();
m_items[PIC_PLAY] = part->copy();
delete part;
part = new QPixmap(11, 9);
painter.begin(part);
painter.drawPixmap (0, 0, 3, 9, *img, 36, 0, 3, 9);
painter.drawPixmap (3, 0, 8, 9, *img, 1, 0, 8, 9);
painter.end();
m_items[PIC_PLAY] = part->copy();
delete part;
part = new QPixmap(11, 9);
painter.begin(part);
painter.drawPixmap (0, 0, 2, 9, *img, 27, 0, 2, 9);
painter.drawPixmap (2, 0, 9, 9, *img, 9, 0, 9, 9);
painter.end();
m_items[PIC_PAUSE] = part->copy();
delete part;
part = new QPixmap(11, 9);
painter.begin(part);
painter.drawPixmap (0, 0, 2, 9, *img, 27, 0, 2, 9);
painter.drawPixmap (2, 0, 9, 9, *img, 18, 0, 9, 9);
painter.end();
m_items[PIC_STOP] = part->copy();
delete part;
delete img;
part = new QPixmap(11, 9);
painter.begin(part);
painter.drawPixmap (0, 0, 2, 9, *img, 27, 0, 2, 9);
painter.drawPixmap (2, 0, 9, 9, *img, 9, 0, 9, 9);
painter.end();
m_items[PIC_PAUSE] = part->copy();
delete part;
part = new QPixmap(11, 9);
painter.begin(part);
painter.drawPixmap (0, 0, 2, 9, *img, 27, 0, 2, 9);
painter.drawPixmap (2, 0, 9, 9, *img, 18, 0, 9, 9);
painter.end();
m_items[PIC_STOP] = part->copy();
delete part;
delete img;
}
else
setSkin(":CleanAMP/");
img = getPixmap ("main");
m_items[MAIN_WINDOW] = img->copy();
m_items[ABOUT_0] = img->copy(247, 83, 20, 25);
m_items[ABOUT_1] = img->copy(247, 83, 20, 24);
delete img;
if(img)
{
m_items[MAIN_WINDOW] = img->copy();
m_items[ABOUT_0] = img->copy(247, 83, 20, 25);
m_items[ABOUT_1] = img->copy(247, 83, 20, 24);
delete img;
}
else
setSkin(":CleanAMP/");
}
@ -408,27 +444,52 @@ Skin::BuildSliders (void)
QPixmap *img;
img = getPixmap("posbar");
m_items[POSBAR] = img->copy (0, 0, 248, 10);
m_items[POSBAR_BTN_0] = img->copy (248, 0, 29, 10);
m_items[POSBAR_BTN_1] = img->copy (278, 0, 29, 10);
delete img;
img = getPixmap("volume");
for (int i = VOLUMEBAR_POS_MIN; i < VOLUMEBAR_POS_MAX; i++) {
m_volume_bar[i] = img->copy(0, i*15, 68, 13);
if(img)
{
m_items[POSBAR] = img->copy (0, 0, 248, 10);
m_items[POSBAR_BTN_0] = img->copy (248, 0, 29, 10);
m_items[POSBAR_BTN_1] = img->copy (278, 0, 29, 10);
delete img;
}
delete img;
else
setSkin(":CleanAMP/");
img = getPixmap("volume");
if(img)
{
for (int i = VOLUMEBAR_POS_MIN; i <= VOLUMEBAR_POS_MAX; i++) {
m_volume_bar[i] = img->copy(0, i*15, 68, 13);
}
if(img->height() > 420)
{
m_items[VOLBAR_BTN_1] = img->copy (0, 422, 14, 11);
m_items[VOLBAR_BTN_0] = img->copy (15, 422, 14, 11);
m_volbtn = true;
}
else
{
m_volbtn = false;
}
delete img;
}
else
setSkin(":CleanAMP/");
img = getPixmap("balance");
if (!img) {
img = getPixmap("volume");
}
for (int i = BALANCE_POS_MIN; i < BALANCE_POS_MAX; i++) {
m_balance[i] = img->copy(9, i*15, 38, 13);
if(img)
{
for (int i = BALANCE_POS_MIN; i <= BALANCE_POS_MAX; i++) {
m_balance[i] = img->copy(9, i*15, 38, 13);
}
delete img;
}
delete img;
else
setSkin(":CleanAMP/");
}
@ -443,11 +504,15 @@ Skin::BuildNumbers (void)
img = getPixmap ("nums_ex");
}
for (uint i = 0; i < num; i++) {
m_numbers[i] = img->copy (i*9, 0, 9, 13);
if(img)
{
for (uint i = 0; i < num; i++) {
m_numbers[i] = img->copy (i*9, 0, 9, 13);
}
delete img;
}
delete img;
else
setSkin(":CleanAMP/");
}

7
Skin.h
View file

@ -25,6 +25,8 @@ class Skin : public QWidget
const QPixmap getLetter (uint c) const { return m_letterMap[c]; }
const QPixmap getNumber (uint c) const { return m_numbers[c]; }
const QByteArray getPLeditValue (QByteArray c) const { return m_pledit_txt[c]; }
const bool getVolBtn(void) const { return m_volbtn; }
const bool getBalBtn(void) const { return m_balbtn; }
enum Volume {
VOLUMEBAR_POS_MIN,
@ -148,6 +150,8 @@ class Skin : public QWidget
POSBAR,
POSBAR_BTN_0,
POSBAR_BTN_1,
VOLBAR_BTN_0,
VOLBAR_BTN_1,
};
enum PlaylistParts {
PLS_CORNER_UL_0,
@ -271,6 +275,9 @@ class Skin : public QWidget
QMap<QByteArray, QByteArray> m_pledit_txt;
QList<QPixmap *> m_buttons;
bool m_volbtn;
bool m_balbtn;
signals:
void skinChanged (Skin *skin);
};

267
VolumeSlider.cpp Normal file
View file

@ -0,0 +1,267 @@
#include "VolumeSlider.h"
#include <QMouseEvent>
// NOTE!
// This file has lots of seemingly strange math.
// I will document it as we go, but please keep in mind
// that all of the coord-space and normalization is pixel-space dependent.
VolumeSlider::VolumeSlider (QWidget *parent) : PixWidget (parent)
{
setMinimumSize (68, 13);
setMaximumSize (68, 13);
m_volume = 0;
m_position = 0;
m_hasvolbtn = false;
m_volbtn = NULL;
m_pixmap = QPixmap (68, 13);
}
VolumeSlider::~VolumeSlider ()
{
}
void
VolumeSlider::setPixmaps (Skin *skin)
{
m_skin = skin;
if(m_skin->getVolBtn())
{
m_hasvolbtn = true;
if(m_volbtn)
delete m_volbtn;
m_volbtn = new VolButton (this, Skin::VOLBAR_BTN_0, Skin::VOLBAR_BTN_1);
// If we are out of scope high or low, we clamp the values.
if(m_volume <= 0)
m_volbtn->move (0, 1);
else if(m_volume >= 27)
m_volbtn->move (54, 1);
else
{
// If we are not.. we do two things.
// First, we normalize the difference between the current position
// and the maximum position. This will give us the progress ratio.
float temp = ((float)(m_volume) / (float)(27.0f));
// Now, we multiply that by the number of possible positions in our
// space. This gives us our relative position according to the progress
// ratio.
m_volbtn->move ((int)(49 * temp), 1);
}
m_volbtn->setPixmaps (m_skin);
m_volbtn->show ();
}
else
{
m_hasvolbtn = false;
if(m_volbtn)
{
delete m_volbtn;
m_volbtn = NULL;
}
}
m_volslider = m_skin->getVol (m_volume);
drawPixmaps ();
}
void
VolumeSlider::changePixmap ()
{
m_volslider = m_skin->getVol (m_volume);
drawPixmaps ();
}
void
VolumeSlider::drawPixmaps ()
{
QPainter paint;
paint.begin (&m_pixmap);
paint.drawPixmap (QRect (0, 0, 68, 13),
m_volslider,
m_pixmap.rect ());
paint.end ();
update ();
}
void
VolumeSlider::mousePressEvent (QMouseEvent *event)
{
updatePos (event);
if(m_hasvolbtn)
{
m_volbtn->mousePressEvent (event);
}
}
void
VolumeSlider::mouseMoveEvent (QMouseEvent *event)
{
updatePos (event);
if(m_hasvolbtn)
{
m_volbtn->mouseMoveEvent (event);
}
}
void
VolumeSlider::mouseReleaseEvent (QMouseEvent *event)
{
updatePos (event);
if(m_hasvolbtn)
{
m_volbtn->mouseReleaseEvent (event);
}
}
void
VolumeSlider::updatePos (QMouseEvent *event)
{
QPoint p (event->pos ());
int curx = p.x ();
// Check for scope and clamp.
if(curx <= 0)
{
m_volume = 0;
m_volume_base100 = 0;
}
else if(curx >= 68)
{
m_volume = 27;
m_volume_base100 = 100;
}
else
{
// Normalize the same way we do above, except this time
// we calculate a base-100 value as well.
float temp = ((float)(curx - 5) / (float)(width() - 5));
m_volume_base100 = (int)(100 * temp);
m_volume = (int)(28 * temp);
}
changePixmap ();
}
void
VolumeSlider::setVolume (uint volume_base100)
{
m_volume_base100 = volume_base100;
if(volume_base100 > 100)
volume_base100 = 100;
m_volume = (int)((float)(volume_base100) *.28);
if(m_volume > 27)
m_volume = 27;
changePixmap ();
}
VolButton::VolButton (QWidget *parent, uint normal, uint pressed) : PixWidget (parent)
{
m_volslider = dynamic_cast<VolumeSlider *>(parent);
setMinimumSize (14, 11);
setMaximumSize (14, 11);
m_normal = normal;
m_pressed = pressed;
m_pixmap = QPixmap (14, 11);
}
VolButton::~VolButton ()
{
}
void
VolButton::mousePressEvent (QMouseEvent *event)
{
QPoint p (event->globalPos ());
QPoint np = m_volslider->mapFromGlobal(p);
move(np.x() - 7, 1);
changePixmap (true);
}
void
VolButton::mouseReleaseEvent (QMouseEvent *event)
{
changePixmap (false);
}
void
VolButton::mouseMoveEvent (QMouseEvent *event)
{
QPoint p = m_volslider->mapFromGlobal(event->globalPos ());
int volume = 0;
int curx = p.x ();
// Same deal, clamp then normalize.
if(curx < 7)
{
volume = 0;
m_volslider->setVolume(0);
}
else if(curx > 61)
{
volume = 54;
m_volslider->setVolume(100);
}
else
{
float temp = ((float)(((float)curx) / (float)(68.0f)));
float b100temp = ((float)(((float)curx - 12) / (float)(68.0f - 19)));
volume = (int)(68 * temp) - 7;
// This is to make sure the volume slider itself reflects our changes.
m_volslider->setVolume((int)(100 * b100temp));
}
move(volume, 1);
}
void
VolButton::setPixmaps (Skin *skin)
{
m_skin = skin;
m_volbtn = m_skin->getItem (m_normal);
drawPixmaps ();
}
void
VolButton::changePixmap (bool pressed)
{
if(pressed)
m_volbtn = m_skin->getItem (m_pressed);
else
m_volbtn = m_skin->getItem (m_normal);
drawPixmaps ();
}
void
VolButton::drawPixmaps ()
{
QPainter paint;
paint.begin (&m_pixmap);
paint.drawPixmap (QRect (0, 0, 14, 11),
m_volbtn,
m_pixmap.rect ());
paint.end ();
update ();
}

66
VolumeSlider.h Normal file
View file

@ -0,0 +1,66 @@
#ifndef __VOLUMESLIDER_H__
#define __VOLUMESLIDER_H__
#include "PixWidget.h"
#include "Button.h"
class VolumeSlider;
class MainDisplay;
class VolButton : public PixWidget
{
Q_OBJECT
public:
VolButton (QWidget *, uint, uint);
~VolButton ();
void mouseMoveEvent (QMouseEvent *);
void mousePressEvent (QMouseEvent *);
void mouseReleaseEvent (QMouseEvent *);
public slots:
void setPixmaps (Skin *skin);
private:
void changePixmap (bool pressed);
void drawPixmaps();
VolumeSlider *m_volslider;
Skin *m_skin;
QPixmap m_volbtn;
uint m_normal;
uint m_pressed;
};
class VolumeSlider : public PixWidget
{
Q_OBJECT
public:
VolumeSlider (QWidget *parent);
~VolumeSlider ();
void mouseMoveEvent (QMouseEvent *);
void mousePressEvent (QMouseEvent *);
void mouseReleaseEvent (QMouseEvent *);
uint getVolume (void) { return m_volume_base100; };
void setVolume (uint volume_base100);
public slots:
void setPixmaps (Skin *skin);
private:
void drawPixmaps ();
void updatePos (QMouseEvent *event);
void changePixmap ();
QPixmap m_volslider;
VolButton *m_volbtn;
Skin *m_skin;
int m_volume;
int m_position;
uint m_volume_base100;
bool m_hasvolbtn;
};
#endif

View file

@ -24,7 +24,8 @@ SOURCES += XmmsQT4.cpp \
MediaArtistList.cpp \
MediaAlbumList.cpp \
MediaSongList.cpp \
PlaylistMenu.cpp
PlaylistMenu.cpp \
VolumeSlider.cpp
HEADERS += XmmsQT4.h \
PixWidget.h \
@ -52,7 +53,8 @@ HEADERS += XmmsQT4.h \
MediaArtistList.h \
MediaAlbumList.h \
MediaSongList.h \
PlaylistMenu.h
PlaylistMenu.h \
VolumeSlider.h