Diffstat (limited to 'noncore/multimedia/opieplayer2/videowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index c829e03..a4d09f5 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -1,171 +1,171 @@ | |||
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 "videowidget.h" | 34 | #include "videowidget.h" |
35 | #include "mediaplayerstate.h" | 35 | #include "mediaplayerstate.h" |
36 | #include "playlistwidget.h" | 36 | #include "playlistwidget.h" |
37 | 37 | ||
38 | 38 | ||
39 | #ifdef Q_WS_QWS | 39 | #ifdef Q_WS_QWS |
40 | # define USE_DIRECT_PAINTER | 40 | # define USE_DIRECT_PAINTER |
41 | # include <qdirectpainter_qws.h> | 41 | # include <qdirectpainter_qws.h> |
42 | # include <qgfxraster_qws.h> | 42 | # include <qgfxraster_qws.h> |
43 | #endif | 43 | #endif |
44 | 44 | ||
45 | 45 | ||
46 | namespace | 46 | namespace |
47 | { | 47 | { |
48 | 48 | ||
49 | const int xo = 2; // movable x offset | 49 | const int xo = 2; // movable x offset |
50 | const int yo = 0; // movable y offset | 50 | const int yo = 0; // movable y offset |
51 | 51 | ||
52 | const MediaWidget::SkinButtonInfo skinInfo[] = | 52 | const MediaWidget::SkinButtonInfo skinInfo[] = |
53 | { | 53 | { |
54 | { MediaWidget::Play, "play", MediaWidget::ToggleButton }, | 54 | { MediaWidget::Play, "play", MediaWidget::ToggleButton }, |
55 | { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, | 55 | { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, |
56 | { MediaWidget::Next, "fwd", MediaWidget::NormalButton }, | 56 | { MediaWidget::Next, "fwd", MediaWidget::NormalButton }, |
57 | { MediaWidget::Previous, "back", MediaWidget::NormalButton }, | 57 | { MediaWidget::Previous, "back", MediaWidget::NormalButton }, |
58 | { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, | 58 | { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, |
59 | { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, | 59 | { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, |
60 | { MediaWidget::FullScreen, "full", MediaWidget::ToggleButton } | 60 | { MediaWidget::FullScreen, "full", MediaWidget::ToggleButton } |
61 | }; | 61 | }; |
62 | 62 | ||
63 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); | 63 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); |
64 | 64 | ||
65 | } | 65 | } |
66 | 66 | ||
67 | VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) | 67 | VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) |
68 | : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ), videoSliderBeingMoved( false ) | 68 | : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ), videoSliderBeingMoved( false ) |
69 | { | 69 | { |
70 | setCaption( tr("OpiePlayer - Video") ); | 70 | setCaption( tr("OpiePlayer - Video") ); |
71 | 71 | ||
72 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | 72 | videoFrame = new XineVideoWidget ( this, "Video frame" ); |
73 | 73 | ||
74 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); | 74 | connect ( videoFrame, SIGNAL( videoResized(const QSize&)), this, SIGNAL( videoResized(const QSize&))); |
75 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); | 75 | connect ( videoFrame, SIGNAL( clicked() ), this, SLOT ( backToNormal() ) ); |
76 | 76 | ||
77 | slider = 0; | 77 | slider = 0; |
78 | 78 | ||
79 | loadSkin(); | 79 | loadSkin(); |
80 | 80 | ||
81 | setLength( mediaPlayerState.length() ); | 81 | setLength( mediaPlayerState.length() ); |
82 | setPosition( mediaPlayerState.position() ); | 82 | setPosition( mediaPlayerState.position() ); |
83 | setFullscreen( mediaPlayerState.isFullscreen() ); | 83 | setFullscreen( mediaPlayerState.isFullscreen() ); |
84 | setPlaying( mediaPlayerState.isPlaying() ); | 84 | setPlaying( mediaPlayerState.isPlaying() ); |
85 | } | 85 | } |
86 | 86 | ||
87 | 87 | ||
88 | VideoWidget::~VideoWidget() | 88 | VideoWidget::~VideoWidget() |
89 | { | 89 | { |
90 | } | 90 | } |
91 | 91 | ||
92 | MediaWidget::GUIInfo VideoWidget::guiInfo() | 92 | MediaWidget::GUIInfo VideoWidget::guiInfo() |
93 | { | 93 | { |
94 | return GUIInfo( "V" /* infix */, ::skinInfo, ::buttonCount ); | 94 | return GUIInfo( "V" /* infix */, ::skinInfo, ::buttonCount ); |
95 | } | 95 | } |
96 | 96 | ||
97 | void VideoWidget::resizeEvent( QResizeEvent *e ) { | 97 | void VideoWidget::resizeEvent( QResizeEvent *e ) { |
98 | int h = height(); | 98 | int h = height(); |
99 | int w = width(); | 99 | int w = width(); |
100 | //int Vh = 160; | 100 | //int Vh = 160; |
101 | //int Vw = 220; | 101 | //int Vw = 220; |
102 | 102 | ||
103 | slider->setFixedWidth( w - 20 ); | 103 | slider->setFixedWidth( w - 20 ); |
104 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 104 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
105 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | 105 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); |
106 | slider->setFocusPolicy( QWidget::NoFocus ); | 106 | slider->setFocusPolicy( QWidget::NoFocus ); |
107 | slider->setBackgroundPixmap( backgroundPixmap ); | 107 | slider->setBackgroundPixmap( backgroundPixmap ); |
108 | 108 | ||
109 | upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; | 109 | upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; |
110 | if(w>h) | 110 | if(w>h) |
111 | upperLeftOfButtonMask.ry() = 0; | 111 | upperLeftOfButtonMask.ry() = 0; |
112 | else | 112 | else |
113 | upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; | 113 | upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; |
114 | 114 | ||
115 | MediaWidget::resizeEvent( e ); | 115 | MediaWidget::resizeEvent( e ); |
116 | } | 116 | } |
117 | 117 | ||
118 | void VideoWidget::sliderPressed() { | 118 | void VideoWidget::sliderPressed() { |
119 | videoSliderBeingMoved = TRUE; | 119 | videoSliderBeingMoved = TRUE; |
120 | } | 120 | } |
121 | 121 | ||
122 | void VideoWidget::sliderReleased() { | 122 | void VideoWidget::sliderReleased() { |
123 | videoSliderBeingMoved = FALSE; | 123 | videoSliderBeingMoved = FALSE; |
124 | if ( slider->width() == 0 ) { | 124 | if ( slider->width() == 0 ) { |
125 | return; | 125 | return; |
126 | } | 126 | } |
127 | long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); | 127 | long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); |
128 | mediaPlayerState.setPosition( val ); | 128 | mediaPlayerState.setPosition( val ); |
129 | } | 129 | } |
130 | 130 | ||
131 | void VideoWidget::setPosition( long i ) { | 131 | void VideoWidget::setPosition( long i ) { |
132 | updateSlider( i, mediaPlayerState.length() ); | 132 | updateSlider( i, mediaPlayerState.length() ); |
133 | } | 133 | } |
134 | 134 | ||
135 | 135 | ||
136 | void VideoWidget::setLength( long max ) { | 136 | void VideoWidget::setLength( long max ) { |
137 | updateSlider( mediaPlayerState.position(), max ); | 137 | updateSlider( mediaPlayerState.position(), max ); |
138 | } | 138 | } |
139 | 139 | ||
140 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) | 140 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) |
141 | { | 141 | { |
142 | if ( displayType == MediaPlayerState::Video ) { | 142 | if ( displayType == MediaPlayerState::Video ) { |
143 | makeVisible(); | 143 | makeVisible(); |
144 | return; | 144 | return; |
145 | } | 145 | } |
146 | 146 | ||
147 | // Effectively blank the view next time we show it so it looks nicer | 147 | // Effectively blank the view next time we show it so it looks nicer |
148 | scaledWidth = 0; | 148 | scaledWidth = 0; |
149 | scaledHeight = 0; | 149 | scaledHeight = 0; |
150 | hide(); | 150 | hide(); |
151 | } | 151 | } |
152 | 152 | ||
153 | void VideoWidget::loadSkin() | 153 | void VideoWidget::loadSkin() |
154 | { | 154 | { |
155 | loadDefaultSkin( guiInfo() ); | 155 | loadDefaultSkin( guiInfo() ); |
156 | 156 | ||
157 | delete slider; | 157 | delete slider; |
158 | slider = new QSlider( Qt::Horizontal, this ); | 158 | slider = new QSlider( Qt::Horizontal, this ); |
159 | slider->setMinValue( 0 ); | 159 | slider->setMinValue( 0 ); |
160 | slider->setMaxValue( 1 ); | 160 | slider->setMaxValue( 1 ); |
161 | slider->setBackgroundPixmap( backgroundPixmap ); | 161 | slider->setBackgroundPixmap( backgroundPixmap ); |
162 | //slider->setFocusPolicy( QWidget::NoFocus ); | 162 | //slider->setFocusPolicy( QWidget::NoFocus ); |
163 | 163 | ||
164 | resizeEvent( 0 ); | 164 | resizeEvent( 0 ); |
165 | } | 165 | } |
166 | 166 | ||
167 | void VideoWidget::updateSlider( long i, long max ) { | 167 | void VideoWidget::updateSlider( long i, long max ) { |
168 | // Will flicker too much if we don't do this | 168 | // Will flicker too much if we don't do this |
169 | if ( max == 0 ) { | 169 | if ( max == 0 ) { |
170 | return; | 170 | return; |
171 | } | 171 | } |