author | simon <simon> | 2002-12-09 13:52:00 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-09 13:52:00 (UTC) |
commit | 46bca195f0dacc3b596eb1537ae47bc2117ce8e4 (patch) (unidiff) | |
tree | 135414127395da9466d77ef71fa85bd41b130bf0 | |
parent | 374d7ba11f669449900c7e93f7929d724eb85f26 (diff) | |
download | opie-46bca195f0dacc3b596eb1537ae47bc2117ce8e4.zip opie-46bca195f0dacc3b596eb1537ae47bc2117ce8e4.tar.gz opie-46bca195f0dacc3b596eb1537ae47bc2117ce8e4.tar.bz2 |
- isToggle is now an enum ButtonType { NormalButton, ToggleButton };
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 10 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 5 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 8 |
3 files changed, 10 insertions, 13 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 8659971..56b75f2 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -66,30 +66,28 @@ void changeTextColor( QWidget * w) { | |||
66 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 66 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
67 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 67 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
68 | w->setPalette( p ); | 68 | w->setPalette( p ); |
69 | } | 69 | } |
70 | 70 | ||
71 | } | 71 | } |
72 | 72 | ||
73 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : | 73 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : |
74 | 74 | ||
75 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), | 75 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), |
76 | audioSliderBeingMoved( false ) | 76 | audioSliderBeingMoved( false ) |
77 | { | 77 | { |
78 | Button defaultButton; | ||
78 | 79 | ||
79 | Button defaultButton; | 80 | Button toggleButton = defaultButton; |
80 | defaultButton.isToggle = defaultButton.isHeld = defaultButton.isDown = false; | 81 | toggleButton.buttonType = ToggleButton; |
81 | Button toggleButton; | ||
82 | toggleButton.isToggle = true; | ||
83 | toggleButton.isHeld = toggleButton.isDown = false; | ||
84 | 82 | ||
85 | buttons.reserve( 10 ); | 83 | buttons.reserve( 10 ); |
86 | buttons.push_back( toggleButton ); // play | 84 | buttons.push_back( toggleButton ); // play |
87 | buttons.push_back( defaultButton ); // stop | 85 | buttons.push_back( defaultButton ); // stop |
88 | buttons.push_back( defaultButton ); // next | 86 | buttons.push_back( defaultButton ); // next |
89 | buttons.push_back( defaultButton ); // previous | 87 | buttons.push_back( defaultButton ); // previous |
90 | buttons.push_back( defaultButton ); // volume up | 88 | buttons.push_back( defaultButton ); // volume up |
91 | buttons.push_back( defaultButton ); // volume down | 89 | buttons.push_back( defaultButton ); // volume down |
92 | buttons.push_back( toggleButton ); // repeat/loop | 90 | buttons.push_back( toggleButton ); // repeat/loop |
93 | buttons.push_back( defaultButton ); // playlist | 91 | buttons.push_back( defaultButton ); // playlist |
94 | buttons.push_back( defaultButton ); // forward | 92 | buttons.push_back( defaultButton ); // forward |
95 | buttons.push_back( defaultButton ); // back | 93 | buttons.push_back( defaultButton ); // back |
@@ -380,25 +378,25 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
380 | return; | 378 | return; |
381 | case Back: | 379 | case Back: |
382 | emit backClicked(); | 380 | emit backClicked(); |
383 | return; | 381 | return; |
384 | } | 382 | } |
385 | } else if ( !isOnButton && buttons[i].isHeld ) { | 383 | } else if ( !isOnButton && buttons[i].isHeld ) { |
386 | buttons[i].isHeld = FALSE; | 384 | buttons[i].isHeld = FALSE; |
387 | toggleButton(i); | 385 | toggleButton(i); |
388 | } | 386 | } |
389 | } else { | 387 | } else { |
390 | if ( buttons[i].isHeld ) { | 388 | if ( buttons[i].isHeld ) { |
391 | buttons[i].isHeld = FALSE; | 389 | buttons[i].isHeld = FALSE; |
392 | if ( !buttons[i].isToggle ) { | 390 | if ( buttons[i].buttonType != ToggleButton ) { |
393 | setToggleButton( i, FALSE ); | 391 | setToggleButton( i, FALSE ); |
394 | } | 392 | } |
395 | qDebug("mouseEvent %d", i); | 393 | qDebug("mouseEvent %d", i); |
396 | handleCommand( static_cast<Command>( i ), buttons[ i ].isDown ); | 394 | handleCommand( static_cast<Command>( i ), buttons[ i ].isDown ); |
397 | } | 395 | } |
398 | } | 396 | } |
399 | } | 397 | } |
400 | } | 398 | } |
401 | 399 | ||
402 | 400 | ||
403 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 401 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
404 | mouseMoveEvent( event ); | 402 | mouseMoveEvent( event ); |
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index 46c304d..aa8891f 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h | |||
@@ -26,30 +26,31 @@ | |||
26 | #include <qwidget.h> | 26 | #include <qwidget.h> |
27 | 27 | ||
28 | #include "mediaplayerstate.h" | 28 | #include "mediaplayerstate.h" |
29 | #include "playlistwidget.h" | 29 | #include "playlistwidget.h" |
30 | 30 | ||
31 | #include <vector> | 31 | #include <vector> |
32 | 32 | ||
33 | class MediaWidget : public QWidget | 33 | class MediaWidget : public QWidget |
34 | { | 34 | { |
35 | Q_OBJECT | 35 | Q_OBJECT |
36 | public: | 36 | public: |
37 | enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back }; | 37 | enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back }; |
38 | enum ButtonType { NormalButton, ToggleButton }; | ||
38 | 39 | ||
39 | struct Button | 40 | struct Button |
40 | { | 41 | { |
41 | Button() : isToggle( false ), isHeld( false ), isDown( false ) {} | 42 | Button() : buttonType( NormalButton ), isHeld( false ), isDown( false ) {} |
42 | 43 | ||
43 | bool isToggle : 1; | 44 | ButtonType buttonType : 1; |
44 | bool isHeld : 1; | 45 | bool isHeld : 1; |
45 | bool isDown : 1; | 46 | bool isDown : 1; |
46 | }; | 47 | }; |
47 | typedef std::vector<Button> ButtonVector; | 48 | typedef std::vector<Button> ButtonVector; |
48 | 49 | ||
49 | MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); | 50 | MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); |
50 | virtual ~MediaWidget(); | 51 | virtual ~MediaWidget(); |
51 | 52 | ||
52 | public slots: | 53 | public slots: |
53 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; | 54 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; |
54 | virtual void setLength( long length ) = 0; | 55 | virtual void setLength( long length ) = 0; |
55 | virtual void setPlaying( bool playing ) = 0; | 56 | virtual void setPlaying( bool playing ) = 0; |
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 2f51c82..23acfa3 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -62,28 +62,26 @@ const int yo = 0; // movable y offset | |||
62 | const char * const skinV_mask_file_names[7] = { | 62 | const char * const skinV_mask_file_names[7] = { |
63 | "play","stop","fwd","back","up","down","full" | 63 | "play","stop","fwd","back","up","down","full" |
64 | }; | 64 | }; |
65 | 65 | ||
66 | } | 66 | } |
67 | 67 | ||
68 | VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) | 68 | VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) |
69 | : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) | 69 | : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) |
70 | { | 70 | { |
71 | setCaption( tr("OpiePlayer - Video") ); | 71 | setCaption( tr("OpiePlayer - Video") ); |
72 | 72 | ||
73 | Button defaultButton; | 73 | Button defaultButton; |
74 | defaultButton.isToggle = defaultButton.isHeld = defaultButton.isDown = false; | 74 | Button toggleButton = defaultButton; |
75 | Button toggleButton; | 75 | toggleButton.buttonType = ToggleButton; |
76 | toggleButton.isToggle = true; | ||
77 | toggleButton.isHeld = toggleButton.isDown = false; | ||
78 | 76 | ||
79 | buttons.reserve( 7 ); | 77 | buttons.reserve( 7 ); |
80 | buttons.push_back( toggleButton ); // play | 78 | buttons.push_back( toggleButton ); // play |
81 | buttons.push_back( defaultButton ); // stop | 79 | buttons.push_back( defaultButton ); // stop |
82 | buttons.push_back( defaultButton ); // next | 80 | buttons.push_back( defaultButton ); // next |
83 | buttons.push_back( defaultButton ); // previous | 81 | buttons.push_back( defaultButton ); // previous |
84 | buttons.push_back( defaultButton ); // volUp | 82 | buttons.push_back( defaultButton ); // volUp |
85 | buttons.push_back( defaultButton ); // volDown | 83 | buttons.push_back( defaultButton ); // volDown |
86 | buttons.push_back( toggleButton ); //fullscreen | 84 | buttons.push_back( toggleButton ); //fullscreen |
87 | 85 | ||
88 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | 86 | videoFrame = new XineVideoWidget ( this, "Video frame" ); |
89 | 87 | ||
@@ -289,25 +287,25 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
289 | case VideoVolDown: | 287 | case VideoVolDown: |
290 | emit lessClicked(); | 288 | emit lessClicked(); |
291 | return; | 289 | return; |
292 | } | 290 | } |
293 | } else if ( !isOnButton && buttons[i].isHeld ) { | 291 | } else if ( !isOnButton && buttons[i].isHeld ) { |
294 | buttons[i].isHeld = FALSE; | 292 | buttons[i].isHeld = FALSE; |
295 | toggleButton(i); | 293 | toggleButton(i); |
296 | } | 294 | } |
297 | } else { | 295 | } else { |
298 | 296 | ||
299 | if ( buttons[i].isHeld ) { | 297 | if ( buttons[i].isHeld ) { |
300 | buttons[i].isHeld = FALSE; | 298 | buttons[i].isHeld = FALSE; |
301 | if ( !buttons[i].isToggle ) { | 299 | if ( buttons[i].buttonType != ToggleButton ) { |
302 | setToggleButton( i, FALSE ); | 300 | setToggleButton( i, FALSE ); |
303 | } | 301 | } |
304 | 302 | ||
305 | switch(i) { | 303 | switch(i) { |
306 | 304 | ||
307 | case VideoPlay: { | 305 | case VideoPlay: { |
308 | if( mediaPlayerState.isPaused() ) { | 306 | if( mediaPlayerState.isPaused() ) { |
309 | setToggleButton( i, FALSE ); | 307 | setToggleButton( i, FALSE ); |
310 | mediaPlayerState.setPaused( FALSE ); | 308 | mediaPlayerState.setPaused( FALSE ); |
311 | return; | 309 | return; |
312 | } else if( !mediaPlayerState.isPaused() ) { | 310 | } else if( !mediaPlayerState.isPaused() ) { |
313 | setToggleButton( i, TRUE ); | 311 | setToggleButton( i, TRUE ); |