summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-09 14:06:14 (UTC)
committer simon <simon>2002-12-09 14:06:14 (UTC)
commit17f319bb44feb947a26be333a4c7e6fef7020c87 (patch) (unidiff)
treee02e34fb78ad4e4896cc07fd2a81d1a475e772a6
parent46bca195f0dacc3b596eb1537ae47bc2117ce8e4 (diff)
downloadopie-17f319bb44feb947a26be333a4c7e6fef7020c87.zip
opie-17f319bb44feb947a26be333a4c7e6fef7020c87.tar.gz
opie-17f319bb44feb947a26be333a4c7e6fef7020c87.tar.bz2
- re-organizing a bit the button storage. more to come.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp42
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h7
2 files changed, 28 insertions, 21 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 56b75f2..3b33209 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -11,152 +11,152 @@
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
59const char * const skin_mask_file_names[10] = { 59const MediaWidget::SkinButtonInfo skinInfo[] =
60 "play", "stop", "next", "prev", "up", 60{
61 "down", "loop", "playlist", "forward", "back" 61 { MediaWidget::Play, "play", MediaWidget::ToggleButton },
62 { MediaWidget::Stop, "stop", MediaWidget::NormalButton },
63 { MediaWidget::Next, "next", MediaWidget::NormalButton },
64 { MediaWidget::Previous, "prev", MediaWidget::NormalButton },
65 { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton },
66 { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton },
67 { MediaWidget::Loop, "loop", MediaWidget::ToggleButton },
68 { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton },
69 { MediaWidget::Forward, "forward", MediaWidget::NormalButton },
70 { MediaWidget::Back, "back", MediaWidget::NormalButton }
62}; 71};
63 72
73const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] );
74
64void changeTextColor( QWidget * w) { 75void changeTextColor( QWidget * w) {
65 QPalette p = w->palette(); 76 QPalette p = w->palette();
66 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 77 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
67 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 78 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
68 w->setPalette( p ); 79 w->setPalette( p );
69} 80}
70 81
71} 82}
72 83
73AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : 84AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) :
74 85
75 MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), 86 MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ),
76 audioSliderBeingMoved( false ) 87 audioSliderBeingMoved( false )
77{ 88{
78 Button defaultButton; 89 for ( uint i = 0; i < buttonCount; ++i ) {
79 90 Button button;
80 Button toggleButton = defaultButton; 91 button.buttonType = skinInfo[ i ].buttonType;
81 toggleButton.buttonType = ToggleButton; 92 buttons.push_back( button );
82 93 }
83 buttons.reserve( 10 );
84 buttons.push_back( toggleButton ); // play
85 buttons.push_back( defaultButton ); // stop
86 buttons.push_back( defaultButton ); // next
87 buttons.push_back( defaultButton ); // previous
88 buttons.push_back( defaultButton ); // volume up
89 buttons.push_back( defaultButton ); // volume down
90 buttons.push_back( toggleButton ); // repeat/loop
91 buttons.push_back( defaultButton ); // playlist
92 buttons.push_back( defaultButton ); // forward
93 buttons.push_back( defaultButton ); // back
94 94
95 setCaption( tr("OpiePlayer") ); 95 setCaption( tr("OpiePlayer") );
96 96
97 Config cfg("OpiePlayer"); 97 Config cfg("OpiePlayer");
98 cfg.setGroup("Options"); 98 cfg.setGroup("Options");
99 skin = cfg.readEntry("Skin","default"); 99 skin = cfg.readEntry("Skin","default");
100 //skin = "scaleTest"; 100 //skin = "scaleTest";
101 // color of background, frame, degree of transparency 101 // color of background, frame, degree of transparency
102 102
103 QString skinPath = "opieplayer2/skins/" + skin; 103 QString skinPath = "opieplayer2/skins/" + skin;
104 pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 104 pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
105 imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 105 imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
106 imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 106 imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
107 107
108 buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); 108 buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 );
109 buttonMask.fill( 0 ); 109 buttonMask.fill( 0 );
110 110
111 masks.reserve( 10 ); 111 masks.reserve( buttonCount );
112 112
113 for ( uint i = 0; i < masks.capacity(); i++ ) { 113 for ( uint i = 0; i < masks.capacity(); 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_" + skinInfo[i].fileName + ".png" );
115 masks.push_back( QBitmap( filename ) ); 115 masks.push_back( 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 = buttonMask.jumpTable(); 119 uchar **dest = buttonMask.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 buttonPixUp.resize( masks.size(), QPixmap() ); 130 buttonPixUp.resize( masks.size(), QPixmap() );
131 buttonPixDown.resize( masks.size(), QPixmap() ); 131 buttonPixDown.resize( masks.size(), QPixmap() );
132 132
133 setBackgroundPixmap( pixBg ); 133 setBackgroundPixmap( pixBg );
134 134
135 songInfo.setFocusPolicy( QWidget::NoFocus ); 135 songInfo.setFocusPolicy( QWidget::NoFocus );
136// changeTextColor( &songInfo ); 136// changeTextColor( &songInfo );
137// songInfo.setBackgroundColor( QColor( 167, 212, 167 )); 137// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
138// songInfo.setFrameStyle( QFrame::NoFrame); 138// songInfo.setFrameStyle( QFrame::NoFrame);
139 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); 139 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
140// songInfo.setForegroundColor(Qt::white); 140// songInfo.setForegroundColor(Qt::white);
141 141
142 slider.setFixedHeight( 20 ); 142 slider.setFixedHeight( 20 );
143 slider.setMinValue( 0 ); 143 slider.setMinValue( 0 );
144 slider.setMaxValue( 1 ); 144 slider.setMaxValue( 1 );
145 slider.setFocusPolicy( QWidget::NoFocus ); 145 slider.setFocusPolicy( QWidget::NoFocus );
146 slider.setBackgroundPixmap( pixBg ); 146 slider.setBackgroundPixmap( pixBg );
147 147
148// Config cofg("qpe"); 148// Config cofg("qpe");
149// cofg.setGroup("Appearance"); 149// cofg.setGroup("Appearance");
150// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); 150// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) );
151 151
152 time.setFocusPolicy( QWidget::NoFocus ); 152 time.setFocusPolicy( QWidget::NoFocus );
153 time.setAlignment( Qt::AlignCenter ); 153 time.setAlignment( Qt::AlignCenter );
154 154
155// time.setFrame(FALSE); 155// time.setFrame(FALSE);
156// changeTextColor( &time ); 156// changeTextColor( &time );
157 157
158 resizeEvent( NULL ); 158 resizeEvent( NULL );
159 159
160 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 160 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
161 connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); 161 connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) );
162 162
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index aa8891f..e0f2cf1 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -2,87 +2,94 @@
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 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
33class MediaWidget : public QWidget 33class MediaWidget : public QWidget
34{ 34{
35 Q_OBJECT 35 Q_OBJECT
36public: 36public:
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 enum ButtonType { NormalButton, ToggleButton };
39 39
40 struct Button 40 struct Button
41 { 41 {
42 Button() : buttonType( NormalButton ), isHeld( false ), isDown( false ) {} 42 Button() : buttonType( NormalButton ), isHeld( false ), isDown( false ) {}
43 43
44 ButtonType buttonType : 1; 44 ButtonType buttonType : 1;
45 bool isHeld : 1; 45 bool isHeld : 1;
46 bool isDown : 1; 46 bool isDown : 1;
47 }; 47 };
48 typedef std::vector<Button> ButtonVector; 48 typedef std::vector<Button> ButtonVector;
49 49
50 struct SkinButtonInfo
51 {
52 Command command;
53 const char *fileName;
54 ButtonType buttonType;
55 };
56
50 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); 57 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 );
51 virtual ~MediaWidget(); 58 virtual ~MediaWidget();
52 59
53public slots: 60public slots:
54 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; 61 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0;
55 virtual void setLength( long length ) = 0; 62 virtual void setLength( long length ) = 0;
56 virtual void setPlaying( bool playing ) = 0; 63 virtual void setPlaying( bool playing ) = 0;
57 64
58signals: 65signals:
59 void moreReleased(); 66 void moreReleased();
60 void lessReleased(); 67 void lessReleased();
61 void forwardReleased(); 68 void forwardReleased();
62 void backReleased(); 69 void backReleased();
63 70
64protected: 71protected:
65 virtual void closeEvent( QCloseEvent * ); 72 virtual void closeEvent( QCloseEvent * );
66 73
67 void handleCommand( Command command, bool buttonDown ); 74 void handleCommand( Command command, bool buttonDown );
68 75
69 bool isOverButton( const QPoint &position, int buttonId ) const; 76 bool isOverButton( const QPoint &position, int buttonId ) const;
70 77
71 void paintButton( int buttonId ); 78 void paintButton( int buttonId );
72 virtual void paintButton( QPainter &p, int i ) = 0; 79 virtual void paintButton( QPainter &p, int i ) = 0;
73 80
74 void toggleButton( int buttonId ); 81 void toggleButton( int buttonId );
75 82
76 MediaPlayerState &mediaPlayerState; 83 MediaPlayerState &mediaPlayerState;
77 PlayListWidget &playList; 84 PlayListWidget &playList;
78 85
79 ButtonVector buttons; 86 ButtonVector buttons;
80 87
81 QImage buttonMask; 88 QImage buttonMask;
82 89
83 QPoint upperLeftOfButtonMask; 90 QPoint upperLeftOfButtonMask;
84}; 91};
85 92
86#endif // MEDIAWIDGET_H 93#endif // MEDIAWIDGET_H
87/* vim: et sw=4 ts=4 94/* vim: et sw=4 ts=4
88 */ 95 */