-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 21 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.cpp | 19 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.h | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 99 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 11 |
6 files changed, 105 insertions, 50 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 8d8e4e5..a3238f0 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -22,64 +22,65 @@ extern PlayListWidget *playList; | |||
22 | extern MediaPlayerState *mediaPlayerState; | 22 | extern MediaPlayerState *mediaPlayerState; |
23 | 23 | ||
24 | 24 | ||
25 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) | 25 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) |
26 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { | 26 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { |
27 | 27 | ||
28 | 28 | ||
29 | xineControl = new XineControl(); | 29 | xineControl = new XineControl(); |
30 | // QPEApplication::grabKeyboard(); // EVIL | 30 | // QPEApplication::grabKeyboard(); // EVIL |
31 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 31 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
32 | 32 | ||
33 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); | 33 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); |
34 | |||
34 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); | 35 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); |
36 | |||
35 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 37 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
36 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); | 38 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); |
37 | 39 | ||
38 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 40 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
39 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 41 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
40 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 42 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
41 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 43 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
42 | 44 | ||
43 | volControl = new VolumeControl; | 45 | volControl = new VolumeControl; |
44 | 46 | ||
45 | } | 47 | } |
46 | 48 | ||
47 | MediaPlayer::~MediaPlayer() { | 49 | MediaPlayer::~MediaPlayer() { |
48 | delete xineControl; | 50 | delete xineControl; |
49 | delete volControl; | 51 | delete volControl; |
50 | } | 52 | } |
51 | 53 | ||
52 | void MediaPlayer::pauseCheck( bool b ) { | 54 | void MediaPlayer::pauseCheck( bool b ) { |
53 | // Only pause if playing | 55 | if ( b && !mediaPlayerState->playing() ) { |
54 | if ( b && !mediaPlayerState->playing() ) { | 56 | mediaPlayerState->setPaused( FALSE ); |
55 | mediaPlayerState->setPaused( FALSE ); | 57 | } |
56 | } | ||
57 | } | 58 | } |
58 | 59 | ||
59 | void MediaPlayer::play() { | 60 | void MediaPlayer::play() { |
60 | mediaPlayerState->setPlaying( FALSE ); | 61 | mediaPlayerState->setPlaying( FALSE ); |
61 | mediaPlayerState->setPlaying( TRUE ); | 62 | mediaPlayerState->setPlaying( TRUE ); |
62 | } | 63 | } |
63 | 64 | ||
64 | void MediaPlayer::setPlaying( bool play ) { | 65 | void MediaPlayer::setPlaying( bool play ) { |
65 | if ( !play ) { | 66 | if ( !play ) { |
66 | mediaPlayerState->setPaused( FALSE ); | 67 | mediaPlayerState->setPaused( FALSE ); |
67 | return; | 68 | return; |
68 | } | 69 | } |
69 | 70 | ||
70 | if ( mediaPlayerState->paused() ) { | 71 | if ( mediaPlayerState->paused() ) { |
71 | mediaPlayerState->setPaused( FALSE ); | 72 | mediaPlayerState->setPaused( FALSE ); |
72 | return; | 73 | return; |
73 | } | 74 | } |
74 | 75 | ||
75 | const DocLnk *playListCurrent = playList->current(); | 76 | const DocLnk *playListCurrent = playList->current(); |
76 | if ( playListCurrent != NULL ) { | 77 | if ( playListCurrent != NULL ) { |
77 | currentFile = playListCurrent; | 78 | currentFile = playListCurrent; |
78 | } | 79 | } |
79 | 80 | ||
80 | xineControl->play( currentFile->file() ); | 81 | xineControl->play( currentFile->file() ); |
81 | 82 | ||
82 | xineControl->length(); | 83 | xineControl->length(); |
83 | long seconds = mediaPlayerState->length();// | 84 | long seconds = mediaPlayerState->length();// |
84 | QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 85 | QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
85 | qDebug(time); | 86 | qDebug(time); |
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp index 57b1c81..bb8d905 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp | |||
@@ -44,26 +44,24 @@ void MediaPlayerState::readConfig( Config& cfg ) { | |||
44 | 44 | ||
45 | 45 | ||
46 | void MediaPlayerState::writeConfig( Config& cfg ) const { | 46 | void MediaPlayerState::writeConfig( Config& cfg ) const { |
47 | cfg.setGroup("Options"); | 47 | cfg.setGroup("Options"); |
48 | cfg.writeEntry("FullScreen", isFullscreen ); | 48 | cfg.writeEntry("FullScreen", isFullscreen ); |
49 | cfg.writeEntry("Scaling", isScaled ); | 49 | cfg.writeEntry("Scaling", isScaled ); |
50 | cfg.writeEntry("Looping", isLooping ); | 50 | cfg.writeEntry("Looping", isLooping ); |
51 | cfg.writeEntry("Shuffle", isShuffled ); | 51 | cfg.writeEntry("Shuffle", isShuffled ); |
52 | cfg.writeEntry("UsePlayList", usePlaylist ); | 52 | cfg.writeEntry("UsePlayList", usePlaylist ); |
53 | } | 53 | } |
54 | 54 | ||
55 | 55 | ||
56 | |||
57 | |||
58 | // public stuff | 56 | // public stuff |
59 | 57 | ||
60 | 58 | ||
61 | bool MediaPlayerState::streaming() { | 59 | bool MediaPlayerState::streaming() { |
62 | return isStreaming; | 60 | return isStreaming; |
63 | } | 61 | } |
64 | 62 | ||
65 | bool MediaPlayerState::fullscreen() { | 63 | bool MediaPlayerState::fullscreen() { |
66 | return isFullscreen; | 64 | return isFullscreen; |
67 | } | 65 | } |
68 | 66 | ||
69 | bool MediaPlayerState::scaled() { | 67 | bool MediaPlayerState::scaled() { |
@@ -150,32 +148,31 @@ void MediaPlayerState::setShuffled( bool b ) { | |||
150 | emit shuffledToggled(b); | 148 | emit shuffledToggled(b); |
151 | } | 149 | } |
152 | 150 | ||
153 | void MediaPlayerState::setPlaylist( bool b ) { | 151 | void MediaPlayerState::setPlaylist( bool b ) { |
154 | if ( usePlaylist == b ) { | 152 | if ( usePlaylist == b ) { |
155 | return; | 153 | return; |
156 | } | 154 | } |
157 | usePlaylist = b; | 155 | usePlaylist = b; |
158 | emit playlistToggled(b); | 156 | emit playlistToggled(b); |
159 | } | 157 | } |
160 | 158 | ||
161 | void MediaPlayerState::setPaused( bool b ) { | 159 | void MediaPlayerState::setPaused( bool b ) { |
162 | if(b) qDebug("setPaused true"); | 160 | if ( isPaused == b ) { |
163 | else qDebug("setPaused false"); | 161 | isPaused = FALSE; |
164 | 162 | emit pausedToggled(FALSE); | |
165 | if ( isPaused == b ) { | 163 | return; |
166 | return; | 164 | } |
167 | } | 165 | isPaused = b; |
168 | isPaused = b; | 166 | emit pausedToggled(b); |
169 | emit pausedToggled(b); | ||
170 | } | 167 | } |
171 | 168 | ||
172 | void MediaPlayerState::setPlaying( bool b ) { | 169 | void MediaPlayerState::setPlaying( bool b ) { |
173 | if ( isPlaying == b ) { | 170 | if ( isPlaying == b ) { |
174 | return; | 171 | return; |
175 | } | 172 | } |
176 | isPlaying = b; | 173 | isPlaying = b; |
177 | isStoped = !b; | 174 | isStoped = !b; |
178 | emit playingToggled(b); | 175 | emit playingToggled(b); |
179 | } | 176 | } |
180 | 177 | ||
181 | void MediaPlayerState::setStop( bool b ) { | 178 | void MediaPlayerState::setStop( bool b ) { |
@@ -251,22 +248,22 @@ void MediaPlayerState::toggleLooping() { | |||
251 | setLooping( !isLooping); | 248 | setLooping( !isLooping); |
252 | } | 249 | } |
253 | 250 | ||
254 | void MediaPlayerState::toggleShuffled() { | 251 | void MediaPlayerState::toggleShuffled() { |
255 | setShuffled( !isShuffled); | 252 | setShuffled( !isShuffled); |
256 | } | 253 | } |
257 | 254 | ||
258 | void MediaPlayerState::togglePlaylist() { | 255 | void MediaPlayerState::togglePlaylist() { |
259 | setPlaylist( !usePlaylist); | 256 | setPlaylist( !usePlaylist); |
260 | } | 257 | } |
261 | 258 | ||
262 | void MediaPlayerState::togglePaused() { | 259 | void MediaPlayerState::togglePaused() { |
263 | setPaused( !isPaused); | 260 | setPaused( !isPaused); |
264 | } | 261 | } |
265 | 262 | ||
266 | void MediaPlayerState::togglePlaying() { | 263 | void MediaPlayerState::togglePlaying() { |
267 | setPlaying( !isPlaying); | 264 | setPlaying( !isPlaying); |
268 | } | 265 | } |
269 | 266 | ||
270 | 267 | ||
271 | 268 | ||
272 | 269 | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 65458e7..27db464 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -155,32 +155,32 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
155 | new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); | 155 | new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); |
156 | pmPlayList->insertSeparator(-1); | 156 | pmPlayList->insertSeparator(-1); |
157 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 157 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
158 | pmPlayList->insertSeparator(-1); | 158 | pmPlayList->insertSeparator(-1); |
159 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); | 159 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); |
160 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); | 160 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); |
161 | 161 | ||
162 | 162 | ||
163 | pmView = new QPopupMenu( this ); | 163 | pmView = new QPopupMenu( this ); |
164 | menu->insertItem( tr( "View" ), pmView ); | 164 | menu->insertItem( tr( "View" ), pmView ); |
165 | pmView->isCheckable(); | 165 | pmView->isCheckable(); |
166 | 166 | ||
167 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), this, SLOT( toggleFull() ) ); | 167 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) ); |
168 | 168 | ||
169 | Config cfg( "OpiePlayer" ); | 169 | Config cfg( "OpiePlayer" ); |
170 | bool b= cfg.readBoolEntry("FullScreen", 0); | 170 | bool b= cfg.readBoolEntry("FullScreen", 0); |
171 | mediaPlayerState->setFullscreen( b ); | 171 | mediaPlayerState->setFullscreen( b ); |
172 | pmView->setItemChecked( -16, b ); | 172 | pmView->setItemChecked( -16, b ); |
173 | 173 | ||
174 | pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), this, SLOT(toggleScaled() ) ); | 174 | pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), mediaPlayerState, SLOT(toggleScaled() ) ); |
175 | 175 | ||
176 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 176 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
177 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 177 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
178 | 178 | ||
179 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 179 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
180 | 180 | ||
181 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 181 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
182 | // tabWidget->setTabShape(QTabWidget::Triangular); | 182 | // tabWidget->setTabShape(QTabWidget::Triangular); |
183 | 183 | ||
184 | QWidget *pTab; | 184 | QWidget *pTab; |
185 | pTab = new QWidget( tabWidget, "pTab" ); | 185 | pTab = new QWidget( tabWidget, "pTab" ); |
186 | tabWidget->insertTab( pTab,"Playlist"); | 186 | tabWidget->insertTab( pTab,"Playlist"); |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h index fdfa666..dd49892 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.h +++ b/noncore/multimedia/opieplayer2/playlistwidget.h | |||
@@ -53,25 +53,24 @@ public slots: | |||
53 | protected: | 53 | protected: |
54 | /* void contentsMousePressEvent( QMouseEvent * e ); */ | 54 | /* void contentsMousePressEvent( QMouseEvent * e ); */ |
55 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ | 55 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ |
56 | void keyReleaseEvent( QKeyEvent *e); | 56 | void keyReleaseEvent( QKeyEvent *e); |
57 | void keyPressEvent( QKeyEvent *e); | 57 | void keyPressEvent( QKeyEvent *e); |
58 | private: | 58 | private: |
59 | bool audioScan, videoScan; | 59 | bool audioScan, videoScan; |
60 | void doBlank(); | 60 | void doBlank(); |
61 | void doUnblank(); | 61 | void doUnblank(); |
62 | void readm3u(const QString &); | 62 | void readm3u(const QString &); |
63 | void readPls(const QString &); | 63 | void readPls(const QString &); |
64 | 64 | ||
65 | |||
66 | void initializeStates(); | 65 | void initializeStates(); |
67 | void readConfig( Config& cfg ); | 66 | void readConfig( Config& cfg ); |
68 | void writeConfig( Config& cfg ) const; | 67 | void writeConfig( Config& cfg ) const; |
69 | PlayListWidgetPrivate *d; // Private implementation data | 68 | PlayListWidgetPrivate *d; // Private implementation data |
70 | void populateAudioView(); | 69 | void populateAudioView(); |
71 | void populateVideoView(); | 70 | void populateVideoView(); |
72 | private slots: | 71 | private slots: |
73 | void pmViewActivated(int); | 72 | void pmViewActivated(int); |
74 | void writem3u(); | 73 | void writem3u(); |
75 | void scanForAudio(); | 74 | void scanForAudio(); |
76 | void scanForVideo(); | 75 | void scanForVideo(); |
77 | void openFile(); | 76 | void openFile(); |
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 9b88299..33153d4 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -54,38 +54,38 @@ | |||
54 | extern MediaPlayerState *mediaPlayerState; | 54 | extern MediaPlayerState *mediaPlayerState; |
55 | 55 | ||
56 | 56 | ||
57 | static const int xo = 2; // movable x offset | 57 | static const int xo = 2; // movable x offset |
58 | static const int yo = 0; // movable y offset | 58 | static const int yo = 0; // movable y offset |
59 | 59 | ||
60 | 60 | ||
61 | struct MediaButton { | 61 | struct MediaButton { |
62 | bool isToggle, isHeld, isDown; | 62 | bool isToggle, isHeld, isDown; |
63 | }; | 63 | }; |
64 | 64 | ||
65 | MediaButton videoButtons[] = { | 65 | MediaButton videoButtons[] = { |
66 | { FALSE, FALSE, FALSE }, // previous | ||
67 | { FALSE, FALSE, FALSE }, // stop | 66 | { FALSE, FALSE, FALSE }, // stop |
68 | { TRUE, FALSE, FALSE }, // play | 67 | { TRUE, FALSE, FALSE }, // play |
69 | { TRUE, FALSE, FALSE }, // pause | 68 | { FALSE, FALSE, FALSE }, // previous |
70 | { FALSE, FALSE, FALSE }, // next | 69 | { FALSE, FALSE, FALSE }, // next |
71 | { FALSE, FALSE, FALSE }, // playlist | 70 | { FALSE, FALSE, FALSE }, // volUp |
71 | { FALSE, FALSE, FALSE }, // volDown | ||
72 | { TRUE, FALSE, FALSE } // fullscreen | 72 | { TRUE, FALSE, FALSE } // fullscreen |
73 | }; | 73 | }; |
74 | 74 | ||
75 | const char *skinV_mask_file_names[7] = { | 75 | const char *skinV_mask_file_names[7] = { |
76 | "stop","play","back","fwd","up","down","full" | 76 | "stop","play","back","fwd","up","down","full" |
77 | }; | 77 | }; |
78 | 78 | ||
79 | static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 79 | static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); |
80 | 80 | ||
81 | 81 | ||
82 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | 82 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : |
83 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | 83 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { |
84 | setCaption( tr("OpiePlayer - Video") ); | 84 | setCaption( tr("OpiePlayer - Video") ); |
85 | 85 | ||
86 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | 86 | videoFrame = new XineVideoWidget ( this, "Video frame" ); |
87 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); | 87 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); |
88 | 88 | ||
89 | Config cfg("OpiePlayer"); | 89 | Config cfg("OpiePlayer"); |
90 | cfg.setGroup("VideoWidget"); | 90 | cfg.setGroup("VideoWidget"); |
91 | skin = cfg.readEntry("Skin","default"); | 91 | skin = cfg.readEntry("Skin","default"); |
@@ -128,51 +128,54 @@ QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | |||
128 | slider->setMaxValue( 1 ); | 128 | slider->setMaxValue( 1 ); |
129 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 129 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); |
130 | slider->setFocusPolicy( QWidget::NoFocus ); | 130 | slider->setFocusPolicy( QWidget::NoFocus ); |
131 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); | 131 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); |
132 | 132 | ||
133 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 133 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
134 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 134 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
135 | 135 | ||
136 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 136 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
137 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 137 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
138 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 138 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
139 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 139 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
140 | |||
140 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 141 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
141 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 142 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
142 | 143 | ||
143 | setLength( mediaPlayerState->length() ); | 144 | setLength( mediaPlayerState->length() ); |
144 | setPosition( mediaPlayerState->position() ); | 145 | setPosition( mediaPlayerState->position() ); |
145 | 146 | ||
146 | ////////////////////////// FIXME | 147 | ////////////////////////// FIXME |
147 | // setFullscreen( mediaPlayerState->fullscreen() ); | 148 | // setFullscreen( mediaPlayerState->fullscreen() ); |
148 | setPaused( mediaPlayerState->paused() ); | 149 | setPaused( mediaPlayerState->paused() ); |
149 | setPlaying( mediaPlayerState->playing() ); | 150 | setPlaying( mediaPlayerState->playing() ); |
150 | qDebug("finished videowidget"); | 151 | qDebug("finished videowidget"); |
151 | } | 152 | } |
152 | 153 | ||
153 | 154 | ||
154 | VideoWidget::~VideoWidget() { | 155 | VideoWidget::~VideoWidget() { |
156 | mediaPlayerState->setPlaying( FALSE ); | ||
155 | for ( int i = 0; i < 7; i++ ) { | 157 | for ( int i = 0; i < 7; i++ ) { |
156 | delete buttonPixUp[i]; | 158 | delete buttonPixUp[i]; |
157 | delete buttonPixDown[i]; | 159 | delete buttonPixDown[i]; |
158 | } | 160 | } |
159 | 161 | ||
160 | delete pixBg; | 162 | delete pixBg; |
161 | delete imgUp; | 163 | delete imgUp; |
162 | delete imgDn; | 164 | delete imgDn; |
163 | delete imgButtonMask; | 165 | delete imgButtonMask; |
164 | for ( int i = 0; i < 7; i++ ) { | 166 | for ( int i = 0; i < 7; i++ ) { |
165 | delete masks[i]; | 167 | delete masks[i]; |
166 | } | 168 | } |
169 | |||
167 | } | 170 | } |
168 | 171 | ||
169 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 172 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
170 | QPixmap pix( img.width(), img.height() ); | 173 | QPixmap pix( img.width(), img.height() ); |
171 | QPainter p( &pix ); | 174 | QPainter p( &pix ); |
172 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 175 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
173 | p.drawImage( 0, 0, img ); | 176 | p.drawImage( 0, 0, img ); |
174 | return new QPixmap( pix ); | 177 | return new QPixmap( pix ); |
175 | } | 178 | } |
176 | 179 | ||
177 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { | 180 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { |
178 | QPixmap *pixmap = new QPixmap( pix ); | 181 | QPixmap *pixmap = new QPixmap( pix ); |
@@ -281,53 +284,98 @@ void VideoWidget::toggleButton( int i ) { | |||
281 | paintButton ( &p, i ); | 284 | paintButton ( &p, i ); |
282 | } | 285 | } |
283 | 286 | ||
284 | void VideoWidget::paintButton( QPainter *p, int i ) { | 287 | void VideoWidget::paintButton( QPainter *p, int i ) { |
285 | 288 | ||
286 | if ( videoButtons[i].isDown ) | 289 | if ( videoButtons[i].isDown ) |
287 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 290 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
288 | else | 291 | else |
289 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 292 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
290 | } | 293 | } |
291 | 294 | ||
292 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 295 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
293 | for ( int i = 0; i < numButtons; i++ ) { | 296 | for ( int i = 0; i < numVButtons; i++ ) { |
294 | if ( event->state() == QMouseEvent::LeftButton ) { | 297 | if ( event->state() == QMouseEvent::LeftButton ) { |
295 | // The test to see if the mouse click is inside the button or not | 298 | // The test to see if the mouse click is inside the button or not |
296 | int x = event->pos().x() - xoff; | 299 | int x = event->pos().x() - xoff; |
297 | int y = event->pos().y() - yoff; | 300 | int y = event->pos().y() - yoff; |
298 | 301 | ||
299 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | 302 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
300 | && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | 303 | && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
301 | if ( isOnButton != videoButtons[i].isHeld ) { | 304 | if ( isOnButton != videoButtons[i].isHeld ) { |
302 | videoButtons[i].isHeld = isOnButton; | 305 | videoButtons[i].isHeld = isOnButton; |
303 | toggleButton(i); | 306 | toggleButton(i); |
304 | } | 307 | } |
308 | |||
309 | // qDebug("mouseMove event switch1 %d", i); | ||
310 | if( isOnButton) | ||
311 | switch (i) { | ||
312 | case VideoStop:{ | ||
313 | setToggleButton( i, FALSE ); | ||
314 | mediaPlayerState->setStop(TRUE); | ||
315 | mediaPlayerState->setPlaying(FALSE); | ||
316 | return; | ||
317 | } | ||
318 | case VideoPlay: { | ||
319 | |||
320 | if( mediaPlayerState->isPaused) { | ||
321 | setToggleButton( i, FALSE ); | ||
322 | mediaPlayerState->setPaused( FALSE); | ||
323 | return; | ||
324 | } | ||
325 | else if( mediaPlayerState->isPlaying) { | ||
326 | setToggleButton( i, TRUE ); | ||
327 | mediaPlayerState->setPaused( TRUE); | ||
328 | return; | ||
329 | } | ||
330 | else { | ||
331 | setToggleButton( i, FALSE ); | ||
332 | mediaPlayerState->setPlaying( videoButtons[i].isDown ); | ||
333 | return; | ||
334 | } | ||
335 | } | ||
336 | case VideoNext: qDebug("next"); mediaPlayerState->setNext(); return; | ||
337 | case VideoPrevious: qDebug("previous"); mediaPlayerState->setPrev(); return; | ||
338 | case VideoVolUp: return; | ||
339 | case VideoVolDown: return; | ||
340 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | ||
341 | |||
342 | }; | ||
343 | |||
305 | } else { | 344 | } else { |
306 | if ( videoButtons[i].isHeld ) { | 345 | if ( videoButtons[i].isHeld ) { |
307 | videoButtons[i].isHeld = FALSE; | 346 | videoButtons[i].isHeld = FALSE; |
308 | if ( !videoButtons[i].isToggle ) | 347 | if ( !videoButtons[i].isToggle ) { |
309 | setToggleButton( i, FALSE ); | 348 | setToggleButton( i, FALSE ); |
349 | } | ||
350 | // qDebug("mouseMove event switch2 %d %d", i, VideoPlay); | ||
351 | switch (i) { | ||
352 | case VideoPlay: { | ||
353 | if( mediaPlayerState->isPaused) { | ||
354 | mediaPlayerState->setPaused( FALSE); return; } | ||
355 | else if( mediaPlayerState->isPlaying) { | ||
356 | mediaPlayerState->setPaused( TRUE); return; } | ||
357 | else | ||
358 | mediaPlayerState->setPlaying( TRUE /*videoButtons[i].isDown*/ ); return; | ||
359 | } | ||
360 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; | ||
361 | // case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; | ||
362 | case VideoNext: mediaPlayerState->setNext(); return; | ||
363 | case VideoPrevious: mediaPlayerState->setPrev(); return; | ||
364 | case VideoVolUp: return; | ||
365 | case VideoVolDown: return; | ||
366 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | ||
367 | } | ||
310 | } | 368 | } |
311 | } | 369 | } |
312 | switch (i) { | ||
313 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; | ||
314 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; | ||
315 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; | ||
316 | case VideoNext: mediaPlayerState->setNext(); return; | ||
317 | case VideoPrevious: mediaPlayerState->setPrev(); return; | ||
318 | case VideoPlayList: mediaPlayerState->setList(); return; | ||
319 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | ||
320 | } | ||
321 | |||
322 | } | 370 | } |
323 | } | 371 | } |
324 | 372 | ||
325 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 373 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
326 | mouseMoveEvent( event ); | 374 | mouseMoveEvent( event ); |
327 | } | 375 | } |
328 | 376 | ||
329 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 377 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
330 | if ( mediaPlayerState->fullscreen() ) { | 378 | if ( mediaPlayerState->fullscreen() ) { |
331 | mediaPlayerState->setFullscreen( FALSE ); | 379 | mediaPlayerState->setFullscreen( FALSE ); |
332 | makeVisible(); | 380 | makeVisible(); |
333 | 381 | ||
@@ -362,38 +410,38 @@ void VideoWidget::paintEvent( QPaintEvent * pe) { | |||
362 | 410 | ||
363 | } else { | 411 | } else { |
364 | 412 | ||
365 | // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) ); | 413 | // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) ); |
366 | // draw the buttons | 414 | // draw the buttons |
367 | 415 | ||
368 | if ( !pe->erased() ) { | 416 | if ( !pe->erased() ) { |
369 | // Combine with background and double buffer | 417 | // Combine with background and double buffer |
370 | QPixmap pix( pe->rect().size() ); | 418 | QPixmap pix( pe->rect().size() ); |
371 | QPainter p( &pix ); | 419 | QPainter p( &pix ); |
372 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 420 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
373 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | 421 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); |
374 | for ( int i = 0; i < numButtons; i++ ) | 422 | for ( int i = 0; i < numVButtons; i++ ) |
375 | paintButton( &p, i ); | 423 | paintButton( &p, i ); |
376 | QPainter p2( this ); | 424 | QPainter p2( this ); |
377 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 425 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
378 | } else { | 426 | } else { |
379 | QPainter p( this ); | 427 | QPainter p( this ); |
380 | for ( int i = 0; i < numButtons; i++ ) | 428 | for ( int i = 0; i < numVButtons; i++ ) |
381 | paintButton( &p, i ); | 429 | paintButton( &p, i ); |
382 | } | 430 | } |
383 | // for ( int i = 0; i < numButtons; i++ ) { | 431 | // for ( int i = 0; i < numButtons; i++ ) { |
384 | // paintButton( &p, i ); | 432 | // paintButton( &p, i ); |
385 | // } | 433 | // } |
386 | // // draw the slider | 434 | // draw the slider |
387 | // slider->repaint( TRUE ); | 435 | slider->repaint( TRUE ); |
388 | } | 436 | } |
389 | } | 437 | } |
390 | 438 | ||
391 | 439 | ||
392 | void VideoWidget::closeEvent( QCloseEvent* ) { | 440 | void VideoWidget::closeEvent( QCloseEvent* ) { |
393 | mediaPlayerState->setList(); | 441 | mediaPlayerState->setList(); |
394 | } | 442 | } |
395 | 443 | ||
396 | 444 | ||
397 | bool VideoWidget::playVideo() { | 445 | bool VideoWidget::playVideo() { |
398 | bool result = FALSE; | 446 | bool result = FALSE; |
399 | 447 | ||
@@ -455,12 +503,21 @@ void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | |||
455 | 503 | ||
456 | }; | 504 | }; |
457 | } | 505 | } |
458 | 506 | ||
459 | XineVideoWidget* VideoWidget::vidWidget() { | 507 | XineVideoWidget* VideoWidget::vidWidget() { |
460 | return videoFrame; | 508 | return videoFrame; |
461 | } | 509 | } |
462 | 510 | ||
463 | 511 | ||
464 | void VideoWidget::setFullscreen ( bool b ) { | 512 | void VideoWidget::setFullscreen ( bool b ) { |
465 | setToggleButton( VideoFullscreen, b ); | 513 | setToggleButton( VideoFullscreen, b ); |
466 | } | 514 | } |
515 | |||
516 | void VideoWidget::setPaused( bool b) { | ||
517 | // setToggleButton( VideoPause, b ); | ||
518 | } | ||
519 | |||
520 | void VideoWidget::setPlaying( bool b) { | ||
521 | setToggleButton( VideoPlay, b ); | ||
522 | } | ||
523 | |||
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index 830696e..92193a4 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h | |||
@@ -32,47 +32,48 @@ | |||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef VIDEO_WIDGET_H | 34 | #ifndef VIDEO_WIDGET_H |
35 | #define VIDEO_WIDGET_H | 35 | #define VIDEO_WIDGET_H |
36 | 36 | ||
37 | #include <qwidget.h> | 37 | #include <qwidget.h> |
38 | #include "xinevideowidget.h" | 38 | #include "xinevideowidget.h" |
39 | 39 | ||
40 | class QPixmap; | 40 | class QPixmap; |
41 | class QSlider; | 41 | class QSlider; |
42 | 42 | ||
43 | enum VideoButtons { | 43 | enum VideoButtons { |
44 | VideoPrevious, | ||
45 | VideoStop, | 44 | VideoStop, |
46 | VideoPlay, | 45 | VideoPlay, |
47 | VideoPause, | 46 | // VideoPause, |
47 | VideoPrevious, | ||
48 | VideoNext, | 48 | VideoNext, |
49 | VideoPlayList, | 49 | VideoVolUp, |
50 | VideoVolDown, | ||
50 | VideoFullscreen | 51 | VideoFullscreen |
51 | }; | 52 | }; |
52 | 53 | ||
53 | class VideoWidget : public QWidget { | 54 | class VideoWidget : public QWidget { |
54 | Q_OBJECT | 55 | Q_OBJECT |
55 | public: | 56 | public: |
56 | VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); | 57 | VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); |
57 | ~VideoWidget(); | 58 | ~VideoWidget(); |
58 | 59 | ||
59 | bool playVideo(); | 60 | bool playVideo(); |
60 | XineVideoWidget* vidWidget(); | 61 | XineVideoWidget* vidWidget(); |
61 | public slots: | 62 | public slots: |
62 | void updateSlider( long, long ); | 63 | void updateSlider( long, long ); |
63 | void sliderPressed( ); | 64 | void sliderPressed( ); |
64 | void sliderReleased( ); | 65 | void sliderReleased( ); |
65 | void setPaused( bool b) { setToggleButton( VideoPause, b ); } | 66 | void setPaused( bool b); |
66 | void setPlaying( bool b) { setToggleButton( VideoPlay, b ); } | 67 | void setPlaying( bool b); |
67 | void setFullscreen( bool b ); | 68 | void setFullscreen( bool b ); |
68 | void makeVisible(); | 69 | void makeVisible(); |
69 | void setPosition( long ); | 70 | void setPosition( long ); |
70 | void setLength( long ); | 71 | void setLength( long ); |
71 | void setView( char ); | 72 | void setView( char ); |
72 | 73 | ||
73 | signals: | 74 | signals: |
74 | void sliderMoved( long ); | 75 | void sliderMoved( long ); |
75 | void videoResized ( const QSize &s ); | 76 | void videoResized ( const QSize &s ); |
76 | 77 | ||
77 | protected: | 78 | protected: |
78 | QString skin; | 79 | QString skin; |