author | simon <simon> | 2002-12-09 16:12:41 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-09 16:12:41 (UTC) |
commit | eeb797c68aca5cad9989b8438facebee13eede5e (patch) (unidiff) | |
tree | 74a95774f68967a1b4ecd01d1c2296ebb7019d0c | |
parent | d8aead05894e6a28b5aab45807ff2e6f27620f97 (diff) | |
download | opie-eeb797c68aca5cad9989b8438facebee13eede5e.zip opie-eeb797c68aca5cad9989b8438facebee13eede5e.tar.gz opie-eeb797c68aca5cad9989b8438facebee13eede5e.tar.bz2 |
- starting to migrate the videowidget to MediaWidget::Command and friends
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 40 |
2 files changed, 21 insertions, 21 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index efba6f3..3bf01b6 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h | |||
@@ -1,111 +1,111 @@ | |||
1 | /* | 1 | /* |
2 | Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> | 2 | Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> |
3 | (C) 2002 Max Reiss <harlekin@handhelds.org> | 3 | (C) 2002 Max Reiss <harlekin@handhelds.org> |
4 | (C) 2002 L. Potter <ljp@llornkcor.com> | 4 | (C) 2002 L. Potter <ljp@llornkcor.com> |
5 | (C) 2002 Holger Freyther <zecke@handhelds.org> | 5 | (C) 2002 Holger Freyther <zecke@handhelds.org> |
6 | 6 | ||
7 | This library is free software; you can redistribute it and/or | 7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public | 8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either | 9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. | 10 | version 2 of the License, or (at your option) any later version. |
11 | 11 | ||
12 | This library is distributed in the hope that it will be useful, | 12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. | 15 | Library General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #ifndef MEDIAWIDGET_H | 23 | #ifndef MEDIAWIDGET_H |
24 | #define MEDIAWIDGET_H | 24 | #define MEDIAWIDGET_H |
25 | 25 | ||
26 | #include <qwidget.h> | 26 | #include <qwidget.h> |
27 | #include <qmap.h> | 27 | #include <qmap.h> |
28 | 28 | ||
29 | #include "mediaplayerstate.h" | 29 | #include "mediaplayerstate.h" |
30 | #include "playlistwidget.h" | 30 | #include "playlistwidget.h" |
31 | 31 | ||
32 | #include <vector> | 32 | #include <vector> |
33 | 33 | ||
34 | class MediaWidget : public QWidget | 34 | class MediaWidget : public QWidget |
35 | { | 35 | { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | public: | 37 | public: |
38 | enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, Undefined }; | 38 | enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, FullScreen, Undefined }; |
39 | enum ButtonType { NormalButton, ToggleButton }; | 39 | enum ButtonType { NormalButton, ToggleButton }; |
40 | 40 | ||
41 | struct Button | 41 | struct Button |
42 | { | 42 | { |
43 | Button() : command( Undefined ), type( NormalButton ), isHeld( false ), isDown( false ) {} | 43 | Button() : command( Undefined ), type( NormalButton ), isHeld( false ), isDown( false ) {} |
44 | 44 | ||
45 | Command command; | 45 | Command command; |
46 | 46 | ||
47 | ButtonType type : 1; | 47 | ButtonType type : 1; |
48 | bool isHeld : 1; | 48 | bool isHeld : 1; |
49 | bool isDown : 1; | 49 | bool isDown : 1; |
50 | 50 | ||
51 | QBitmap mask; | 51 | QBitmap mask; |
52 | QPixmap pixUp; | 52 | QPixmap pixUp; |
53 | QPixmap pixDown; | 53 | QPixmap pixDown; |
54 | }; | 54 | }; |
55 | typedef std::vector<Button> ButtonVector; | 55 | typedef std::vector<Button> ButtonVector; |
56 | 56 | ||
57 | struct SkinButtonInfo | 57 | struct SkinButtonInfo |
58 | { | 58 | { |
59 | Command command; | 59 | Command command; |
60 | const char *fileName; | 60 | const char *fileName; |
61 | ButtonType type; | 61 | ButtonType type; |
62 | }; | 62 | }; |
63 | 63 | ||
64 | typedef std::vector<QBitmap> MaskVector; | 64 | typedef std::vector<QBitmap> MaskVector; |
65 | typedef std::vector<QPixmap> PixmapVector; | 65 | typedef std::vector<QPixmap> PixmapVector; |
66 | 66 | ||
67 | MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); | 67 | MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); |
68 | virtual ~MediaWidget(); | 68 | virtual ~MediaWidget(); |
69 | 69 | ||
70 | public slots: | 70 | public slots: |
71 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; | 71 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; |
72 | virtual void setLength( long length ) = 0; | 72 | virtual void setLength( long length ) = 0; |
73 | virtual void setPlaying( bool playing ) = 0; | 73 | virtual void setPlaying( bool playing ) = 0; |
74 | 74 | ||
75 | signals: | 75 | signals: |
76 | void moreReleased(); | 76 | void moreReleased(); |
77 | void lessReleased(); | 77 | void lessReleased(); |
78 | void forwardReleased(); | 78 | void forwardReleased(); |
79 | void backReleased(); | 79 | void backReleased(); |
80 | 80 | ||
81 | protected: | 81 | protected: |
82 | virtual void closeEvent( QCloseEvent * ); | 82 | virtual void closeEvent( QCloseEvent * ); |
83 | 83 | ||
84 | virtual void paintEvent( QPaintEvent *pe ); | 84 | virtual void paintEvent( QPaintEvent *pe ); |
85 | 85 | ||
86 | void handleCommand( Command command, bool buttonDown ); | 86 | void handleCommand( Command command, bool buttonDown ); |
87 | 87 | ||
88 | bool isOverButton( const QPoint &position, int buttonId ) const; | 88 | bool isOverButton( const QPoint &position, int buttonId ) const; |
89 | 89 | ||
90 | void paintAllButtons( QPainter &p ); | 90 | void paintAllButtons( QPainter &p ); |
91 | void paintButton( const Button &button ); | 91 | void paintButton( const Button &button ); |
92 | void paintButton( QPainter &p, const Button &button ); | 92 | void paintButton( QPainter &p, const Button &button ); |
93 | 93 | ||
94 | void setToggleButton( Button &button, bool down ); | 94 | void setToggleButton( Button &button, bool down ); |
95 | void toggleButton( Button &button ); | 95 | void toggleButton( Button &button ); |
96 | 96 | ||
97 | MediaPlayerState &mediaPlayerState; | 97 | MediaPlayerState &mediaPlayerState; |
98 | PlayListWidget &playList; | 98 | PlayListWidget &playList; |
99 | 99 | ||
100 | ButtonVector buttons; | 100 | ButtonVector buttons; |
101 | 101 | ||
102 | QImage buttonMask; | 102 | QImage buttonMask; |
103 | 103 | ||
104 | QPoint upperLeftOfButtonMask; | 104 | QPoint upperLeftOfButtonMask; |
105 | 105 | ||
106 | QPixmap backgroundPixmap; | 106 | QPixmap backgroundPixmap; |
107 | }; | 107 | }; |
108 | 108 | ||
109 | #endif // MEDIAWIDGET_H | 109 | #endif // MEDIAWIDGET_H |
110 | /* vim: et sw=4 ts=4 | 110 | /* vim: et sw=4 ts=4 |
111 | */ | 111 | */ |
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 8409e5c..4867ef1 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -1,215 +1,215 @@ | |||
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 | ||
56 | namespace | 56 | namespace |
57 | { | 57 | { |
58 | 58 | ||
59 | const int xo = 2; // movable x offset | 59 | const int xo = 2; // movable x offset |
60 | const int yo = 0; // movable y offset | 60 | const int yo = 0; // movable y offset |
61 | 61 | ||
62 | const char * const skinV_mask_file_names[7] = { | 62 | const MediaWidget::SkinButtonInfo skinInfo[] = |
63 | "play","stop","fwd","back","up","down","full" | 63 | { |
64 | { MediaWidget::Play, "play", MediaWidget::ToggleButton }, | ||
65 | { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, | ||
66 | { MediaWidget::Next, "fwd", MediaWidget::NormalButton }, | ||
67 | { MediaWidget::Previous, "back", MediaWidget::NormalButton }, | ||
68 | { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, | ||
69 | { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, | ||
70 | { MediaWidget::FullScreen, "full", MediaWidget::ToggleButton } | ||
64 | }; | 71 | }; |
65 | 72 | ||
73 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); | ||
74 | |||
66 | } | 75 | } |
67 | 76 | ||
68 | VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) | 77 | VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) |
69 | : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) | 78 | : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) |
70 | { | 79 | { |
71 | setCaption( tr("OpiePlayer - Video") ); | 80 | setCaption( tr("OpiePlayer - Video") ); |
72 | 81 | ||
73 | Button defaultButton; | ||
74 | Button toggleButton = defaultButton; | ||
75 | toggleButton.type = ToggleButton; | ||
76 | |||
77 | buttons.push_back( toggleButton ); // play | ||
78 | buttons.push_back( toggleButton ); // stop | ||
79 | buttons.push_back( toggleButton ); // next | ||
80 | buttons.push_back( toggleButton ); // previous | ||
81 | buttons.push_back( toggleButton ); // volUp | ||
82 | buttons.push_back( toggleButton ); // volDown | ||
83 | buttons.push_back( toggleButton ); // fullscreen | ||
84 | 82 | ||
85 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | 83 | videoFrame = new XineVideoWidget ( this, "Video frame" ); |
86 | 84 | ||
87 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); | 85 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); |
88 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); | 86 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); |
89 | 87 | ||
90 | Config cfg("OpiePlayer"); | 88 | Config cfg("OpiePlayer"); |
91 | cfg.setGroup("Options"); | 89 | cfg.setGroup("Options"); |
92 | skin = cfg.readEntry("Skin","default"); | 90 | skin = cfg.readEntry("Skin","default"); |
93 | 91 | ||
94 | QString skinPath = "opieplayer2/skins/" + skin; | 92 | QString skinPath = "opieplayer2/skins/" + skin; |
95 | backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 93 | backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
96 | imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | 94 | imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); |
97 | imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | 95 | imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); |
98 | 96 | ||
99 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); | 97 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); |
100 | buttonMask.fill( 0 ); | 98 | buttonMask.fill( 0 ); |
101 | 99 | ||
102 | uint i = 0; | 100 | for ( uint i = 0; i < buttonCount; i++ ) { |
103 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it, ++i ) { | 101 | Button button; |
104 | Button &button = *it; | 102 | button.command = skinInfo[ i ].command; |
103 | button.type = skinInfo[ i ].type; | ||
105 | 104 | ||
106 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); | 105 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinInfo[i].fileName + ".png" ); |
107 | button.mask = QBitmap( filename ); | 106 | button.mask =QBitmap( filename ); |
108 | 107 | ||
109 | if ( !button.mask.isNull() ) { | 108 | if ( !button.mask.isNull() ) { |
110 | QImage imgMask = button.mask.convertToImage(); | 109 | QImage imgMask = button.mask.convertToImage(); |
111 | uchar **dest = buttonMask.jumpTable(); | 110 | uchar **dest = buttonMask.jumpTable(); |
112 | for ( int y = 0; y < imgUp.height(); y++ ) { | 111 | for ( int y = 0; y < imgUp.height(); y++ ) { |
113 | uchar *line = dest[y]; | 112 | uchar *line = dest[y]; |
114 | for ( int x = 0; x < imgUp.width(); x++ ) { | 113 | for ( int x = 0; x < imgUp.width(); x++ ) |
115 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 114 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
116 | line[x] = i + 1; | 115 | line[x] = i + 1; |
117 | } | ||
118 | } | 116 | } |
119 | } | 117 | } |
118 | |||
119 | buttons.push_back( button ); | ||
120 | } | 120 | } |
121 | 121 | ||
122 | setBackgroundPixmap( backgroundPixmap ); | 122 | setBackgroundPixmap( backgroundPixmap ); |
123 | 123 | ||
124 | slider = new QSlider( Qt::Horizontal, this ); | 124 | slider = new QSlider( Qt::Horizontal, this ); |
125 | slider->setMinValue( 0 ); | 125 | slider->setMinValue( 0 ); |
126 | slider->setMaxValue( 1 ); | 126 | slider->setMaxValue( 1 ); |
127 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 127 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); |
128 | //slider->setFocusPolicy( QWidget::NoFocus ); | 128 | //slider->setFocusPolicy( QWidget::NoFocus ); |
129 | 129 | ||
130 | resizeEvent( NULL ); | 130 | resizeEvent( NULL ); |
131 | 131 | ||
132 | setLength( mediaPlayerState.length() ); | 132 | setLength( mediaPlayerState.length() ); |
133 | setPosition( mediaPlayerState.position() ); | 133 | setPosition( mediaPlayerState.position() ); |
134 | setFullscreen( mediaPlayerState.isFullscreen() ); | 134 | setFullscreen( mediaPlayerState.isFullscreen() ); |
135 | setPlaying( mediaPlayerState.isPlaying() ); | 135 | setPlaying( mediaPlayerState.isPlaying() ); |
136 | } | 136 | } |
137 | 137 | ||
138 | 138 | ||
139 | VideoWidget::~VideoWidget() | 139 | VideoWidget::~VideoWidget() |
140 | { | 140 | { |
141 | } | 141 | } |
142 | 142 | ||
143 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 143 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
144 | QPixmap pix( img.width(), img.height() ); | 144 | QPixmap pix( img.width(), img.height() ); |
145 | QPainter p( &pix ); | 145 | QPainter p( &pix ); |
146 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 146 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
147 | p.drawImage( 0, 0, img ); | 147 | p.drawImage( 0, 0, img ); |
148 | return new QPixmap( pix ); | 148 | return new QPixmap( pix ); |
149 | } | 149 | } |
150 | 150 | ||
151 | QPixmap maskVPixToMask( QPixmap pix, QBitmap mask ) { | 151 | QPixmap maskVPixToMask( QPixmap pix, QBitmap mask ) { |
152 | QPixmap pixmap( pix ); | 152 | QPixmap pixmap( pix ); |
153 | pixmap.setMask( mask ); | 153 | pixmap.setMask( mask ); |
154 | return pixmap; | 154 | return pixmap; |
155 | } | 155 | } |
156 | 156 | ||
157 | void VideoWidget::resizeEvent( QResizeEvent * ) { | 157 | void VideoWidget::resizeEvent( QResizeEvent * ) { |
158 | int h = height(); | 158 | int h = height(); |
159 | int w = width(); | 159 | int w = width(); |
160 | //int Vh = 160; | 160 | //int Vh = 160; |
161 | //int Vw = 220; | 161 | //int Vw = 220; |
162 | 162 | ||
163 | slider->setFixedWidth( w - 20 ); | 163 | slider->setFixedWidth( w - 20 ); |
164 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 164 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
165 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | 165 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); |
166 | slider->setFocusPolicy( QWidget::NoFocus ); | 166 | slider->setFocusPolicy( QWidget::NoFocus ); |
167 | slider->setBackgroundPixmap( backgroundPixmap ); | 167 | slider->setBackgroundPixmap( backgroundPixmap ); |
168 | 168 | ||
169 | upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; | 169 | upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; |
170 | if(w>h) | 170 | if(w>h) |
171 | upperLeftOfButtonMask.ry() = 0; | 171 | upperLeftOfButtonMask.ry() = 0; |
172 | else | 172 | else |
173 | upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; | 173 | upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; |
174 | QPoint p = upperLeftOfButtonMask; | 174 | QPoint p = upperLeftOfButtonMask; |
175 | 175 | ||
176 | QPixmap *pixUp = combineVImageWithBackground( imgUp, backgroundPixmap, p ); | 176 | QPixmap *pixUp = combineVImageWithBackground( imgUp, backgroundPixmap, p ); |
177 | QPixmap *pixDn = combineVImageWithBackground( imgDn, backgroundPixmap, p ); | 177 | QPixmap *pixDn = combineVImageWithBackground( imgDn, backgroundPixmap, p ); |
178 | 178 | ||
179 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { | 179 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { |
180 | Button &button = *it; | 180 | Button &button = *it; |
181 | 181 | ||
182 | if ( !button.mask.isNull() ) { | 182 | if ( !button.mask.isNull() ) { |
183 | button.pixUp = maskVPixToMask( *pixUp, button.mask ); | 183 | button.pixUp = maskVPixToMask( *pixUp, button.mask ); |
184 | button.pixDown = maskVPixToMask( *pixDn, button.mask ); | 184 | button.pixDown = maskVPixToMask( *pixDn, button.mask ); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | delete pixUp; | 188 | delete pixUp; |
189 | delete pixDn; | 189 | delete pixDn; |
190 | } | 190 | } |
191 | 191 | ||
192 | static bool videoSliderBeingMoved = FALSE; | 192 | static bool videoSliderBeingMoved = FALSE; |
193 | 193 | ||
194 | void VideoWidget::sliderPressed() { | 194 | void VideoWidget::sliderPressed() { |
195 | videoSliderBeingMoved = TRUE; | 195 | videoSliderBeingMoved = TRUE; |
196 | } | 196 | } |
197 | 197 | ||
198 | void VideoWidget::sliderReleased() { | 198 | void VideoWidget::sliderReleased() { |
199 | videoSliderBeingMoved = FALSE; | 199 | videoSliderBeingMoved = FALSE; |
200 | if ( slider->width() == 0 ) { | 200 | if ( slider->width() == 0 ) { |
201 | return; | 201 | return; |
202 | } | 202 | } |
203 | long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); | 203 | long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); |
204 | mediaPlayerState.setPosition( val ); | 204 | mediaPlayerState.setPosition( val ); |
205 | } | 205 | } |
206 | 206 | ||
207 | void VideoWidget::setPosition( long i ) { | 207 | void VideoWidget::setPosition( long i ) { |
208 | updateSlider( i, mediaPlayerState.length() ); | 208 | updateSlider( i, mediaPlayerState.length() ); |
209 | } | 209 | } |
210 | 210 | ||
211 | 211 | ||
212 | void VideoWidget::setLength( long max ) { | 212 | void VideoWidget::setLength( long max ) { |
213 | updateSlider( mediaPlayerState.position(), max ); | 213 | updateSlider( mediaPlayerState.position(), max ); |
214 | } | 214 | } |
215 | 215 | ||