Diffstat (limited to 'noncore/multimedia/opieplayer2/mediawidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index 2031b4d..4de7ea9 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp | |||
@@ -35,90 +35,86 @@ MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPla | |||
35 | this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); | 35 | this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); |
36 | connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), | 36 | connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), |
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 QString &imagePrefix, const QSize &buttonAreaSize ) | 47 | const Skin &skin, const QSize &buttonAreaSize ) |
48 | { | 48 | { |
49 | buttonMask = QImage( buttonAreaSize, 8, 255 ); | 49 | buttonMask = QImage( buttonAreaSize, 8, 255 ); |
50 | buttonMask.fill( 0 ); | 50 | buttonMask.fill( 0 ); |
51 | 51 | ||
52 | buttons.clear(); | 52 | buttons.clear(); |
53 | buttons.reserve( buttonCount ); | 53 | buttons.reserve( buttonCount ); |
54 | 54 | ||
55 | for ( uint i = 0; i < buttonCount; ++i ) { | 55 | for ( uint i = 0; i < buttonCount; ++i ) { |
56 | Button button = setupButton( skinInfo[ i ], imagePrefix ); | 56 | Button button = setupButton( skinInfo[ i ], skin ); |
57 | buttons.push_back( button ); | 57 | buttons.push_back( button ); |
58 | } | 58 | } |
59 | } | 59 | } |
60 | 60 | ||
61 | MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const QString &imagePrefix ) | 61 | MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ) |
62 | { | 62 | { |
63 | Button button; | 63 | Button button; |
64 | button.command = buttonInfo.command; | 64 | button.command = buttonInfo.command; |
65 | button.type = buttonInfo.type; | 65 | button.type = buttonInfo.type; |
66 | 66 | ||
67 | QString fileName = imagePrefix + buttonInfo.fileName + ".png"; | 67 | button.mask = setupButtonMask( button.command, skin.buttonMaskImage( buttonInfo.fileName ) ); |
68 | |||
69 | button.mask = setupButtonMask( button.command, fileName ); | ||
70 | 68 | ||
71 | return button; | 69 | return button; |
72 | } | 70 | } |
73 | 71 | ||
74 | QBitmap MediaWidget::setupButtonMask( const Command &command, const QString &fileName ) | 72 | QBitmap MediaWidget::setupButtonMask( const Command &command, const QImage &maskImage ) |
75 | { | 73 | { |
76 | QImage imgMask( Resource::findPixmap( fileName ) ); | 74 | if ( maskImage.isNull() ) |
77 | if ( imgMask.isNull() ) | ||
78 | return QBitmap(); | 75 | return QBitmap(); |
79 | 76 | ||
80 | uchar **dest = buttonMask.jumpTable(); | 77 | uchar **dest = buttonMask.jumpTable(); |
81 | for ( int y = 0; y < buttonMask.height(); y++ ) { | 78 | for ( int y = 0; y < buttonMask.height(); y++ ) { |
82 | uchar *line = dest[y]; | 79 | uchar *line = dest[y]; |
83 | for ( int x = 0; x < buttonMask.width(); x++ ) | 80 | for ( int x = 0; x < buttonMask.width(); x++ ) |
84 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 81 | if ( !qRed( maskImage.pixel( x, y ) ) ) |
85 | line[x] = command + 1; | 82 | line[x] = command + 1; |
86 | } | 83 | } |
87 | 84 | ||
88 | // ### grmbl qt2. use constructor when switching to qt3. | 85 | // ### grmbl qt2. use constructor when switching to qt3. |
89 | QBitmap bm; bm = imgMask; | 86 | QBitmap bm; bm = maskImage; |
90 | return bm; | 87 | return bm; |
91 | } | 88 | } |
92 | 89 | ||
93 | void MediaWidget::loadDefaultSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &fileNameInfix ) | 90 | void MediaWidget::loadDefaultSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &fileNameInfix ) |
94 | { | 91 | { |
95 | Config cfg( "OpiePlayer" ); | 92 | Config cfg( "OpiePlayer" ); |
96 | cfg.setGroup( "Options" ); | 93 | cfg.setGroup( "Options" ); |
97 | QString skin = cfg.readEntry( "Skin","default" ); | 94 | QString skin = cfg.readEntry( "Skin","default" ); |
98 | 95 | ||
99 | loadSkin( skinInfo, buttonCount, skin, fileNameInfix ); | 96 | loadSkin( skinInfo, buttonCount, skin, fileNameInfix ); |
100 | } | 97 | } |
101 | 98 | ||
102 | void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &name, const QString &fileNameInfix ) | 99 | void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &name, const QString &fileNameInfix ) |
103 | { | 100 | { |
104 | Skin skin( name, fileNameInfix ); | 101 | Skin skin( name, fileNameInfix ); |
105 | 102 | ||
106 | QString skinPath = "opieplayer2/skins/" + name; | 103 | QString skinPath = "opieplayer2/skins/" + name; |
107 | backgroundPixmap = skin.backgroundImage(); | 104 | backgroundPixmap = skin.backgroundImage(); |
108 | buttonUpImage = skin.buttonUpImage(); | 105 | buttonUpImage = skin.buttonUpImage(); |
109 | buttonDownImage = skin.buttonDownImage(); | 106 | buttonDownImage = skin.buttonDownImage(); |
110 | 107 | ||
111 | setupButtons( skinInfo, buttonCount, | 108 | setupButtons( skinInfo, buttonCount, skin, buttonUpImage.size() ); |
112 | skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( fileNameInfix ), buttonUpImage.size() ); | ||
113 | } | 109 | } |
114 | 110 | ||
115 | void MediaWidget::closeEvent( QCloseEvent * ) | 111 | void MediaWidget::closeEvent( QCloseEvent * ) |
116 | { | 112 | { |
117 | mediaPlayerState.setList(); | 113 | mediaPlayerState.setList(); |
118 | } | 114 | } |
119 | 115 | ||
120 | void MediaWidget::paintEvent( QPaintEvent *pe ) | 116 | void MediaWidget::paintEvent( QPaintEvent *pe ) |
121 | { | 117 | { |
122 | QPainter p( this ); | 118 | QPainter p( this ); |
123 | 119 | ||
124 | if ( mediaPlayerState.isFullscreen() ) { | 120 | if ( mediaPlayerState.isFullscreen() ) { |