Diffstat (limited to 'noncore/multimedia/opieplayer2/audiowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 56b75f2..3b33209 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -47,80 +47,80 @@ | |||
47 | #include <stdio.h> | 47 | #include <stdio.h> |
48 | 48 | ||
49 | #include "audiowidget.h" | 49 | #include "audiowidget.h" |
50 | #include "mediaplayerstate.h" | 50 | #include "mediaplayerstate.h" |
51 | #include "playlistwidget.h" | 51 | #include "playlistwidget.h" |
52 | 52 | ||
53 | namespace | 53 | namespace |
54 | { | 54 | { |
55 | 55 | ||
56 | const int xo = -2; // movable x offset | 56 | const int xo = -2; // movable x offset |
57 | const int yo = 22; // movable y offset | 57 | const int yo = 22; // movable y offset |
58 | 58 | ||
59 | const char * const skin_mask_file_names[10] = { | 59 | const MediaWidget::SkinButtonInfo skinInfo[] = |
60 | "play", "stop", "next", "prev", "up", | 60 | { |
61 | "down", "loop", "playlist", "forward", "back" | 61 | { MediaWidget::Play, "play", MediaWidget::ToggleButton }, |
62 | { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, | ||
63 | { MediaWidget::Next, "next", MediaWidget::NormalButton }, | ||
64 | { MediaWidget::Previous, "prev", MediaWidget::NormalButton }, | ||
65 | { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, | ||
66 | { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, | ||
67 | { MediaWidget::Loop, "loop", MediaWidget::ToggleButton }, | ||
68 | { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton }, | ||
69 | { MediaWidget::Forward, "forward", MediaWidget::NormalButton }, | ||
70 | { MediaWidget::Back, "back", MediaWidget::NormalButton } | ||
62 | }; | 71 | }; |
63 | 72 | ||
73 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); | ||
74 | |||
64 | void changeTextColor( QWidget * w) { | 75 | void changeTextColor( QWidget * w) { |
65 | QPalette p = w->palette(); | 76 | QPalette p = w->palette(); |
66 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 77 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
67 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 78 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
68 | w->setPalette( p ); | 79 | w->setPalette( p ); |
69 | } | 80 | } |
70 | 81 | ||
71 | } | 82 | } |
72 | 83 | ||
73 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : | 84 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : |
74 | 85 | ||
75 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), | 86 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), |
76 | audioSliderBeingMoved( false ) | 87 | audioSliderBeingMoved( false ) |
77 | { | 88 | { |
78 | Button defaultButton; | 89 | for ( uint i = 0; i < buttonCount; ++i ) { |
79 | 90 | Button button; | |
80 | Button toggleButton = defaultButton; | 91 | button.buttonType = skinInfo[ i ].buttonType; |
81 | toggleButton.buttonType = ToggleButton; | 92 | buttons.push_back( button ); |
82 | 93 | } | |
83 | buttons.reserve( 10 ); | ||
84 | buttons.push_back( toggleButton ); // play | ||
85 | buttons.push_back( defaultButton ); // stop | ||
86 | buttons.push_back( defaultButton ); // next | ||
87 | buttons.push_back( defaultButton ); // previous | ||
88 | buttons.push_back( defaultButton ); // volume up | ||
89 | buttons.push_back( defaultButton ); // volume down | ||
90 | buttons.push_back( toggleButton ); // repeat/loop | ||
91 | buttons.push_back( defaultButton ); // playlist | ||
92 | buttons.push_back( defaultButton ); // forward | ||
93 | buttons.push_back( defaultButton ); // back | ||
94 | 94 | ||
95 | setCaption( tr("OpiePlayer") ); | 95 | setCaption( tr("OpiePlayer") ); |
96 | 96 | ||
97 | Config cfg("OpiePlayer"); | 97 | Config cfg("OpiePlayer"); |
98 | cfg.setGroup("Options"); | 98 | cfg.setGroup("Options"); |
99 | skin = cfg.readEntry("Skin","default"); | 99 | skin = cfg.readEntry("Skin","default"); |
100 | //skin = "scaleTest"; | 100 | //skin = "scaleTest"; |
101 | // color of background, frame, degree of transparency | 101 | // color of background, frame, degree of transparency |
102 | 102 | ||
103 | QString skinPath = "opieplayer2/skins/" + skin; | 103 | QString skinPath = "opieplayer2/skins/" + skin; |
104 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 104 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
105 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 105 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
106 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 106 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
107 | 107 | ||
108 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); | 108 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); |
109 | buttonMask.fill( 0 ); | 109 | buttonMask.fill( 0 ); |
110 | 110 | ||
111 | masks.reserve( 10 ); | 111 | masks.reserve( buttonCount ); |
112 | 112 | ||
113 | for ( uint i = 0; i < masks.capacity(); i++ ) { | 113 | for ( uint i = 0; i < masks.capacity(); i++ ) { |
114 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); | 114 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skinInfo[i].fileName + ".png" ); |
115 | masks.push_back( QBitmap( filename ) ); | 115 | masks.push_back( QBitmap( filename ) ); |
116 | 116 | ||
117 | if ( !masks[i].isNull() ) { | 117 | if ( !masks[i].isNull() ) { |
118 | QImage imgMask = masks[i].convertToImage(); | 118 | QImage imgMask = masks[i].convertToImage(); |
119 | uchar **dest = buttonMask.jumpTable(); | 119 | uchar **dest = buttonMask.jumpTable(); |
120 | for ( int y = 0; y < imgUp.height(); y++ ) { | 120 | for ( int y = 0; y < imgUp.height(); y++ ) { |
121 | uchar *line = dest[y]; | 121 | uchar *line = dest[y]; |
122 | for ( int x = 0; x < imgUp.width(); x++ ) | 122 | for ( int x = 0; x < imgUp.width(); x++ ) |
123 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 123 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
124 | line[x] = i + 1; | 124 | line[x] = i + 1; |
125 | } | 125 | } |
126 | } | 126 | } |