summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-08 20:44:22 (UTC)
committer simon <simon>2002-12-08 20:44:22 (UTC)
commit8824690b4900ebfac866b90cf3e715b62a2acc89 (patch) (unidiff)
tree943b937168bc723402b4f94471dfdcc8db10f5ae
parent7c3bd0be34ef70a2297e6f27c592da62f3010da5 (diff)
downloadopie-8824690b4900ebfac866b90cf3e715b62a2acc89.zip
opie-8824690b4900ebfac866b90cf3e715b62a2acc89.tar.gz
opie-8824690b4900ebfac866b90cf3e715b62a2acc89.tar.bz2
- merged duplicated MediaButton definition into common MediaWidget::Button
structure
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp4
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h9
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp9
3 files changed, 13 insertions, 9 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 7bf3a19..879d0b4 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -1,217 +1,217 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37#include <opie/oticker.h> 37#include <opie/oticker.h>
38 38
39#include <qwidget.h> 39#include <qwidget.h>
40#include <qpixmap.h> 40#include <qpixmap.h>
41#include <qbutton.h> 41#include <qbutton.h>
42#include <qpainter.h> 42#include <qpainter.h>
43#include <qframe.h> 43#include <qframe.h>
44#include <qlayout.h> 44#include <qlayout.h>
45#include <qdir.h> 45#include <qdir.h>
46#include <stdlib.h> 46#include <stdlib.h>
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
53namespace 53namespace
54{ 54{
55 55
56const int xo = -2; // movable x offset 56const int xo = -2; // movable x offset
57const int yo = 22; // movable y offset 57const int yo = 22; // movable y offset
58 58
59struct MediaButton { 59struct MediaButton {
60 bool isToggle, isHeld, isDown; 60 bool isToggle, isHeld, isDown;
61}; 61};
62 62
63//Layout information for the audioButtons (and if it is a toggle button or not) 63//Layout information for the audioButtons (and if it is a toggle button or not)
64MediaButton audioButtons[] = { 64MediaWidget::Button audioButtons[] = {
65 { TRUE, FALSE, FALSE }, // play 65 { TRUE, FALSE, FALSE }, // play
66 { FALSE, FALSE, FALSE }, // stop 66 { FALSE, FALSE, FALSE }, // stop
67 { FALSE, FALSE, FALSE }, // next 67 { FALSE, FALSE, FALSE }, // next
68 { FALSE, FALSE, FALSE }, // previous 68 { FALSE, FALSE, FALSE }, // previous
69 { FALSE, FALSE, FALSE }, // volume up 69 { FALSE, FALSE, FALSE }, // volume up
70 { FALSE, FALSE, FALSE }, // volume down 70 { FALSE, FALSE, FALSE }, // volume down
71 { TRUE, FALSE, FALSE }, // repeat/loop 71 { TRUE, FALSE, FALSE }, // repeat/loop
72 { FALSE, FALSE, FALSE }, // playlist 72 { FALSE, FALSE, FALSE }, // playlist
73 { FALSE, FALSE, FALSE }, // forward 73 { FALSE, FALSE, FALSE }, // forward
74 { FALSE, FALSE, FALSE } // back 74 { FALSE, FALSE, FALSE } // back
75}; 75};
76 76
77const char * const skin_mask_file_names[10] = { 77const char * const skin_mask_file_names[10] = {
78 "play", "stop", "next", "prev", "up", 78 "play", "stop", "next", "prev", "up",
79 "down", "loop", "playlist", "forward", "back" 79 "down", "loop", "playlist", "forward", "back"
80}; 80};
81 81
82void changeTextColor( QWidget * w) { 82void changeTextColor( QWidget * w) {
83 QPalette p = w->palette(); 83 QPalette p = w->palette();
84 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 84 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
85 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 85 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
86 w->setPalette( p ); 86 w->setPalette( p );
87} 87}
88 88
89const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 89const int numButtons = (sizeof(audioButtons)/sizeof(MediaWidget::Button));
90 90
91} 91}
92 92
93AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : 93AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) :
94 94
95 MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { 95 MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) {
96 96
97 setCaption( tr("OpiePlayer") ); 97 setCaption( tr("OpiePlayer") );
98 98
99 Config cfg("OpiePlayer"); 99 Config cfg("OpiePlayer");
100 cfg.setGroup("Options"); 100 cfg.setGroup("Options");
101 skin = cfg.readEntry("Skin","default"); 101 skin = cfg.readEntry("Skin","default");
102 //skin = "scaleTest"; 102 //skin = "scaleTest";
103 // color of background, frame, degree of transparency 103 // color of background, frame, degree of transparency
104 104
105 QString skinPath = "opieplayer2/skins/" + skin; 105 QString skinPath = "opieplayer2/skins/" + skin;
106 pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 106 pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
107 imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 107 imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
108 imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 108 imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
109 109
110 imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); 110 imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 );
111 imgButtonMask.fill( 0 ); 111 imgButtonMask.fill( 0 );
112 112
113 for ( int i = 0; i < 10; i++ ) { 113 for ( int i = 0; i < 10; 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_" + skin_mask_file_names[i] + ".png" );
115 masks[i] = new QBitmap( filename ); 115 masks[i] = new 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 = imgButtonMask.jumpTable(); 119 uchar **dest = imgButtonMask.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 }
127 127
128 } 128 }
129 129
130 for ( int i = 0; i < 10; i++ ) { 130 for ( int i = 0; i < 10; i++ ) {
131 buttonPixUp[i] = 0l; 131 buttonPixUp[i] = 0l;
132 buttonPixDown[i] = 0l; 132 buttonPixDown[i] = 0l;
133 } 133 }
134 134
135 setBackgroundPixmap( pixBg ); 135 setBackgroundPixmap( pixBg );
136 136
137 songInfo.setFocusPolicy( QWidget::NoFocus ); 137 songInfo.setFocusPolicy( QWidget::NoFocus );
138// changeTextColor( &songInfo ); 138// changeTextColor( &songInfo );
139// songInfo.setBackgroundColor( QColor( 167, 212, 167 )); 139// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
140// songInfo.setFrameStyle( QFrame::NoFrame); 140// songInfo.setFrameStyle( QFrame::NoFrame);
141 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); 141 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
142// songInfo.setForegroundColor(Qt::white); 142// songInfo.setForegroundColor(Qt::white);
143 143
144 slider.setFixedHeight( 20 ); 144 slider.setFixedHeight( 20 );
145 slider.setMinValue( 0 ); 145 slider.setMinValue( 0 );
146 slider.setMaxValue( 1 ); 146 slider.setMaxValue( 1 );
147 slider.setFocusPolicy( QWidget::NoFocus ); 147 slider.setFocusPolicy( QWidget::NoFocus );
148 slider.setBackgroundPixmap( pixBg ); 148 slider.setBackgroundPixmap( pixBg );
149 149
150// Config cofg("qpe"); 150// Config cofg("qpe");
151// cofg.setGroup("Appearance"); 151// cofg.setGroup("Appearance");
152// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); 152// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) );
153 153
154 time.setFocusPolicy( QWidget::NoFocus ); 154 time.setFocusPolicy( QWidget::NoFocus );
155 time.setAlignment( Qt::AlignCenter ); 155 time.setAlignment( Qt::AlignCenter );
156 156
157// time.setFrame(FALSE); 157// time.setFrame(FALSE);
158// changeTextColor( &time ); 158// changeTextColor( &time );
159 159
160 resizeEvent( NULL ); 160 resizeEvent( NULL );
161 161
162 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 162 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
163 connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); 163 connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) );
164 164
165 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); 165 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
166 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); 166 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
167 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); 167 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
168 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); 168 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
169 169
170 // Intialise state 170 // Intialise state
171 setLength( mediaPlayerState.length() ); 171 setLength( mediaPlayerState.length() );
172 setPosition( mediaPlayerState.position() ); 172 setPosition( mediaPlayerState.position() );
173 setLooping( mediaPlayerState.isFullscreen() ); 173 setLooping( mediaPlayerState.isFullscreen() );
174 // setPaused( mediaPlayerState->paused() ); 174 // setPaused( mediaPlayerState->paused() );
175 setPlaying( mediaPlayerState.isPlaying() ); 175 setPlaying( mediaPlayerState.isPlaying() );
176 176
177} 177}
178 178
179AudioWidget::~AudioWidget() { 179AudioWidget::~AudioWidget() {
180 180
181 for ( int i = 0; i < 10; i++ ) { 181 for ( int i = 0; i < 10; i++ ) {
182 delete buttonPixUp[i]; 182 delete buttonPixUp[i];
183 delete buttonPixDown[i]; 183 delete buttonPixDown[i];
184 } 184 }
185 for ( int i = 0; i < 10; i++ ) { 185 for ( int i = 0; i < 10; i++ ) {
186 delete masks[i]; 186 delete masks[i];
187 } 187 }
188// mediaPlayerState->setPlaying(false); 188// mediaPlayerState->setPlaying(false);
189} 189}
190 190
191namespace { 191namespace {
192 192
193QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 193QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
194 QPixmap pix( img.width(), img.height() ); 194 QPixmap pix( img.width(), img.height() );
195 QPainter p( &pix ); 195 QPainter p( &pix );
196 p.drawTiledPixmap( pix.rect(), bg, offset ); 196 p.drawTiledPixmap( pix.rect(), bg, offset );
197 p.drawImage( 0, 0, img ); 197 p.drawImage( 0, 0, img );
198 return pix; 198 return pix;
199} 199}
200 200
201 201
202QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { 202QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) {
203 QPixmap *pixmap = new QPixmap( pix ); 203 QPixmap *pixmap = new QPixmap( pix );
204 pixmap->setMask( mask ); 204 pixmap->setMask( mask );
205 return pixmap; 205 return pixmap;
206} 206}
207 207
208}; 208};
209 209
210void AudioWidget::resizeEvent( QResizeEvent * ) { 210void AudioWidget::resizeEvent( QResizeEvent * ) {
211 int h = height(); 211 int h = height();
212 int w = width(); 212 int w = width();
213 213
214 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); 214 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) );
215 slider.setFixedWidth( w - 110 ); 215 slider.setFixedWidth( w - 110 );
216 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 216 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
217 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 217 slider.setBackgroundOrigin( QWidget::ParentOrigin );
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 2d92d65..0b9d826 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -1,59 +1,68 @@
1/* 1/*
2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> 2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#ifndef MEDIAWIDGET_H 20#ifndef MEDIAWIDGET_H
21#define MEDIAWIDGET_H 21#define MEDIAWIDGET_H
22 22
23#include <qwidget.h> 23#include <qwidget.h>
24 24
25#include "mediaplayerstate.h" 25#include "mediaplayerstate.h"
26#include "playlistwidget.h" 26#include "playlistwidget.h"
27 27
28class MediaWidget : public QWidget 28class MediaWidget : public QWidget
29{ 29{
30 Q_OBJECT 30 Q_OBJECT
31public: 31public:
32 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back }; 32 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back };
33 33
34 struct Button
35 {
36// Button() : isToggle( false ), isHeld( false ), isDown( false ) {}
37
38 bool isToggle : 1;
39 bool isHeld : 1;
40 bool isDown : 1;
41 };
42
34 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); 43 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 );
35 virtual ~MediaWidget(); 44 virtual ~MediaWidget();
36 45
37public slots: 46public slots:
38 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; 47 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0;
39 virtual void setLength( long length ) = 0; 48 virtual void setLength( long length ) = 0;
40 virtual void setPlaying( bool playing ) = 0; 49 virtual void setPlaying( bool playing ) = 0;
41 50
42signals: 51signals:
43 void moreReleased(); 52 void moreReleased();
44 void lessReleased(); 53 void lessReleased();
45 void forwardReleased(); 54 void forwardReleased();
46 void backReleased(); 55 void backReleased();
47 56
48protected: 57protected:
49 virtual void closeEvent( QCloseEvent * ); 58 virtual void closeEvent( QCloseEvent * );
50 59
51 void handleCommand( Command command, bool buttonDown ); 60 void handleCommand( Command command, bool buttonDown );
52 61
53 MediaPlayerState &mediaPlayerState; 62 MediaPlayerState &mediaPlayerState;
54 PlayListWidget &playList; 63 PlayListWidget &playList;
55}; 64};
56 65
57#endif // MEDIAWIDGET_H 66#endif // MEDIAWIDGET_H
58/* vim: et sw=4 ts=4 67/* vim: et sw=4 ts=4
59 */ 68 */
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index a0aed62..7c20c6d 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -1,209 +1,204 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37 37
38 38
39#include <qwidget.h> 39#include <qwidget.h>
40#include <qpainter.h> 40#include <qpainter.h>
41#include <qpixmap.h> 41#include <qpixmap.h>
42#include <qslider.h> 42#include <qslider.h>
43#include <qdrawutil.h> 43#include <qdrawutil.h>
44#include "videowidget.h" 44#include "videowidget.h"
45#include "mediaplayerstate.h" 45#include "mediaplayerstate.h"
46#include "playlistwidget.h" 46#include "playlistwidget.h"
47 47
48 48
49#ifdef Q_WS_QWS 49#ifdef Q_WS_QWS
50# define USE_DIRECT_PAINTER 50# define USE_DIRECT_PAINTER
51# include <qdirectpainter_qws.h> 51# include <qdirectpainter_qws.h>
52# include <qgfxraster_qws.h> 52# include <qgfxraster_qws.h>
53#endif 53#endif
54 54
55 55
56namespace 56namespace
57{ 57{
58 58
59const int xo = 2; // movable x offset 59const int xo = 2; // movable x offset
60const int yo = 0; // movable y offset 60const int yo = 0; // movable y offset
61 61
62 62MediaWidget::Button videoButtons[] = {
63struct MediaButton {
64 bool isToggle, isHeld, isDown;
65};
66
67MediaButton videoButtons[] = {
68 { FALSE, FALSE, FALSE }, // stop 63 { FALSE, FALSE, FALSE }, // stop
69 { TRUE, FALSE, FALSE }, // play 64 { TRUE, FALSE, FALSE }, // play
70 { FALSE, FALSE, FALSE }, // previous 65 { FALSE, FALSE, FALSE }, // previous
71 { FALSE, FALSE, FALSE }, // next 66 { FALSE, FALSE, FALSE }, // next
72 { FALSE, FALSE, FALSE }, // volUp 67 { FALSE, FALSE, FALSE }, // volUp
73 { FALSE, FALSE, FALSE }, // volDown 68 { FALSE, FALSE, FALSE }, // volDown
74 { TRUE, FALSE, FALSE } // fullscreen 69 { TRUE, FALSE, FALSE } // fullscreen
75}; 70};
76 71
77const char * const skinV_mask_file_names[7] = { 72const char * const skinV_mask_file_names[7] = {
78"stop","play","back","fwd","up","down","full" 73"stop","play","back","fwd","up","down","full"
79}; 74};
80 75
81const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 76const int numVButtons = (sizeof(videoButtons)/sizeof(MediaWidget::Button));
82 77
83} 78}
84 79
85VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) 80VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name )
86 : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) 81 : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 )
87{ 82{
88 setCaption( tr("OpiePlayer - Video") ); 83 setCaption( tr("OpiePlayer - Video") );
89 84
90 videoFrame = new XineVideoWidget ( this, "Video frame" ); 85 videoFrame = new XineVideoWidget ( this, "Video frame" );
91 86
92 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 87 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
93 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); 88 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
94 89
95 Config cfg("OpiePlayer"); 90 Config cfg("OpiePlayer");
96 cfg.setGroup("Options"); 91 cfg.setGroup("Options");
97 skin = cfg.readEntry("Skin","default"); 92 skin = cfg.readEntry("Skin","default");
98 93
99 QString skinPath = "opieplayer2/skins/" + skin; 94 QString skinPath = "opieplayer2/skins/" + skin;
100 pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 95 pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
101 imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); 96 imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
102 imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); 97 imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
103 98
104 imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); 99 imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 );
105 imgButtonMask.fill( 0 ); 100 imgButtonMask.fill( 0 );
106 101
107 for ( int i = 0; i < 7; i++ ) { 102 for ( int i = 0; i < 7; i++ ) {
108 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); 103 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" );
109 masks[i] = new QBitmap( filename ); 104 masks[i] = new QBitmap( filename );
110 105
111 if ( !masks[i]->isNull() ) { 106 if ( !masks[i]->isNull() ) {
112 QImage imgMask = masks[i]->convertToImage(); 107 QImage imgMask = masks[i]->convertToImage();
113 uchar **dest = imgButtonMask.jumpTable(); 108 uchar **dest = imgButtonMask.jumpTable();
114 for ( int y = 0; y < imgUp.height(); y++ ) { 109 for ( int y = 0; y < imgUp.height(); y++ ) {
115 uchar *line = dest[y]; 110 uchar *line = dest[y];
116 for ( int x = 0; x < imgUp.width(); x++ ) { 111 for ( int x = 0; x < imgUp.width(); x++ ) {
117 if ( !qRed( imgMask.pixel( x, y ) ) ) 112 if ( !qRed( imgMask.pixel( x, y ) ) )
118 line[x] = i + 1; 113 line[x] = i + 1;
119 } 114 }
120 } 115 }
121 } 116 }
122 } 117 }
123 118
124 for ( int i = 0; i < 7; i++ ) { 119 for ( int i = 0; i < 7; i++ ) {
125 buttonPixUp[i] = NULL; 120 buttonPixUp[i] = NULL;
126 buttonPixDown[i] = NULL; 121 buttonPixDown[i] = NULL;
127 } 122 }
128 123
129 setBackgroundPixmap( pixBg ); 124 setBackgroundPixmap( pixBg );
130 125
131 slider = new QSlider( Qt::Horizontal, this ); 126 slider = new QSlider( Qt::Horizontal, this );
132 slider->setMinValue( 0 ); 127 slider->setMinValue( 0 );
133 slider->setMaxValue( 1 ); 128 slider->setMaxValue( 1 );
134 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 129 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
135 //slider->setFocusPolicy( QWidget::NoFocus ); 130 //slider->setFocusPolicy( QWidget::NoFocus );
136 131
137 resizeEvent( NULL ); 132 resizeEvent( NULL );
138 133
139 setLength( mediaPlayerState.length() ); 134 setLength( mediaPlayerState.length() );
140 setPosition( mediaPlayerState.position() ); 135 setPosition( mediaPlayerState.position() );
141 setFullscreen( mediaPlayerState.isFullscreen() ); 136 setFullscreen( mediaPlayerState.isFullscreen() );
142 setPlaying( mediaPlayerState.isPlaying() ); 137 setPlaying( mediaPlayerState.isPlaying() );
143} 138}
144 139
145 140
146VideoWidget::~VideoWidget() { 141VideoWidget::~VideoWidget() {
147 142
148 for ( int i = 0; i < 7; i++ ) { 143 for ( int i = 0; i < 7; i++ ) {
149 delete buttonPixUp[i]; 144 delete buttonPixUp[i];
150 delete buttonPixDown[i]; 145 delete buttonPixDown[i];
151 } 146 }
152 147
153 for ( int i = 0; i < 7; i++ ) { 148 for ( int i = 0; i < 7; i++ ) {
154 delete masks[i]; 149 delete masks[i];
155 } 150 }
156 151
157} 152}
158 153
159QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 154QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
160 QPixmap pix( img.width(), img.height() ); 155 QPixmap pix( img.width(), img.height() );
161 QPainter p( &pix ); 156 QPainter p( &pix );
162 p.drawTiledPixmap( pix.rect(), bg, offset ); 157 p.drawTiledPixmap( pix.rect(), bg, offset );
163 p.drawImage( 0, 0, img ); 158 p.drawImage( 0, 0, img );
164 return new QPixmap( pix ); 159 return new QPixmap( pix );
165} 160}
166 161
167QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { 162QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) {
168 QPixmap *pixmap = new QPixmap( pix ); 163 QPixmap *pixmap = new QPixmap( pix );
169 pixmap->setMask( mask ); 164 pixmap->setMask( mask );
170 return pixmap; 165 return pixmap;
171} 166}
172 167
173void VideoWidget::resizeEvent( QResizeEvent * ) { 168void VideoWidget::resizeEvent( QResizeEvent * ) {
174 int h = height(); 169 int h = height();
175 int w = width(); 170 int w = width();
176 //int Vh = 160; 171 //int Vh = 160;
177 //int Vw = 220; 172 //int Vw = 220;
178 173
179 slider->setFixedWidth( w - 20 ); 174 slider->setFixedWidth( w - 20 );
180 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 175 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
181 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 176 slider->setBackgroundOrigin( QWidget::ParentOrigin );
182 slider->setFocusPolicy( QWidget::NoFocus ); 177 slider->setFocusPolicy( QWidget::NoFocus );
183 slider->setBackgroundPixmap( pixBg ); 178 slider->setBackgroundPixmap( pixBg );
184 179
185 xoff = 0;// ( imgUp->width() ) / 2; 180 xoff = 0;// ( imgUp->width() ) / 2;
186 if(w>h) 181 if(w>h)
187 yoff = 0; 182 yoff = 0;
188 else 183 else
189 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; 184 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10;
190 QPoint p( xoff, yoff ); 185 QPoint p( xoff, yoff );
191 186
192 QPixmap *pixUp = combineVImageWithBackground( imgUp, pixBg, p ); 187 QPixmap *pixUp = combineVImageWithBackground( imgUp, pixBg, p );
193 QPixmap *pixDn = combineVImageWithBackground( imgDn, pixBg, p ); 188 QPixmap *pixDn = combineVImageWithBackground( imgDn, pixBg, p );
194 189
195 for ( int i = 0; i < 7; i++ ) { 190 for ( int i = 0; i < 7; i++ ) {
196 if ( !masks[i]->isNull() ) { 191 if ( !masks[i]->isNull() ) {
197 delete buttonPixUp[i]; 192 delete buttonPixUp[i];
198 delete buttonPixDown[i]; 193 delete buttonPixDown[i];
199 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); 194 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] );
200 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); 195 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] );
201 } 196 }
202 } 197 }
203 198
204 delete pixUp; 199 delete pixUp;
205 delete pixDn; 200 delete pixDn;
206} 201}
207 202
208static bool videoSliderBeingMoved = FALSE; 203static bool videoSliderBeingMoved = FALSE;
209 204