Diffstat (limited to 'noncore/multimedia/opieplayer2/mediawidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index 4de7ea9..da0706e 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp | |||
@@ -37,65 +37,45 @@ MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPla | |||
37 | this, SLOT( setLength( long ) ) ); | 37 | this, SLOT( setLength( long ) ) ); |
38 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 38 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
39 | this, SLOT( setPlaying( bool ) ) ); | 39 | this, SLOT( setPlaying( bool ) ) ); |
40 | } | 40 | } |
41 | 41 | ||
42 | MediaWidget::~MediaWidget() | 42 | MediaWidget::~MediaWidget() |
43 | { | 43 | { |
44 | } | 44 | } |
45 | 45 | ||
46 | void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, | 46 | void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, |
47 | const Skin &skin, const QSize &buttonAreaSize ) | 47 | const Skin &skin, const QSize &buttonAreaSize ) |
48 | { | 48 | { |
49 | buttonMask = QImage( buttonAreaSize, 8, 255 ); | 49 | buttonMask = skin.buttonMask( skinInfo, buttonCount, buttonAreaSize ); |
50 | buttonMask.fill( 0 ); | ||
51 | 50 | ||
52 | buttons.clear(); | 51 | buttons.clear(); |
53 | buttons.reserve( buttonCount ); | 52 | buttons.reserve( buttonCount ); |
54 | 53 | ||
55 | for ( uint i = 0; i < buttonCount; ++i ) { | 54 | for ( uint i = 0; i < buttonCount; ++i ) { |
56 | Button button = setupButton( skinInfo[ i ], skin ); | 55 | Button button = setupButton( skinInfo[ i ], skin ); |
57 | buttons.push_back( button ); | 56 | buttons.push_back( button ); |
58 | } | 57 | } |
59 | } | 58 | } |
60 | 59 | ||
61 | MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ) | 60 | MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ) |
62 | { | 61 | { |
63 | Button button; | 62 | Button button; |
64 | button.command = buttonInfo.command; | 63 | button.command = buttonInfo.command; |
65 | button.type = buttonInfo.type; | 64 | button.type = buttonInfo.type; |
66 | 65 | button.mask = skin.buttonMaskImage( buttonInfo.fileName ); | |
67 | button.mask = setupButtonMask( button.command, skin.buttonMaskImage( buttonInfo.fileName ) ); | ||
68 | 66 | ||
69 | return button; | 67 | return button; |
70 | } | 68 | } |
71 | 69 | ||
72 | QBitmap MediaWidget::setupButtonMask( const Command &command, const QImage &maskImage ) | ||
73 | { | ||
74 | if ( maskImage.isNull() ) | ||
75 | return QBitmap(); | ||
76 | |||
77 | uchar **dest = buttonMask.jumpTable(); | ||
78 | for ( int y = 0; y < buttonMask.height(); y++ ) { | ||
79 | uchar *line = dest[y]; | ||
80 | for ( int x = 0; x < buttonMask.width(); x++ ) | ||
81 | if ( !qRed( maskImage.pixel( x, y ) ) ) | ||
82 | line[x] = command + 1; | ||
83 | } | ||
84 | |||
85 | // ### grmbl qt2. use constructor when switching to qt3. | ||
86 | QBitmap bm; bm = maskImage; | ||
87 | return bm; | ||
88 | } | ||
89 | |||
90 | void MediaWidget::loadDefaultSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &fileNameInfix ) | 70 | void MediaWidget::loadDefaultSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &fileNameInfix ) |
91 | { | 71 | { |
92 | Config cfg( "OpiePlayer" ); | 72 | Config cfg( "OpiePlayer" ); |
93 | cfg.setGroup( "Options" ); | 73 | cfg.setGroup( "Options" ); |
94 | QString skin = cfg.readEntry( "Skin","default" ); | 74 | QString skin = cfg.readEntry( "Skin","default" ); |
95 | 75 | ||
96 | loadSkin( skinInfo, buttonCount, skin, fileNameInfix ); | 76 | loadSkin( skinInfo, buttonCount, skin, fileNameInfix ); |
97 | } | 77 | } |
98 | 78 | ||
99 | void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &name, const QString &fileNameInfix ) | 79 | void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &name, const QString &fileNameInfix ) |
100 | { | 80 | { |
101 | Skin skin( name, fileNameInfix ); | 81 | Skin skin( name, fileNameInfix ); |