summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-08-02 10:47:50 (UTC)
committer harlekin <harlekin>2002-08-02 10:47:50 (UTC)
commit471dc69956af37e7c5f481c10482f280db853491 (patch) (unidiff)
tree48d05dfe1c626d277181cf76ee051047b2522483
parentca057e02c3bacb8226d5209fcd9aa24009cdb78e (diff)
downloadopie-471dc69956af37e7c5f481c10482f280db853491.zip
opie-471dc69956af37e7c5f481c10482f280db853491.tar.gz
opie-471dc69956af37e7c5f481c10482f280db853491.tar.bz2
cleanups
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp1
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp24
2 files changed, 6 insertions, 19 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index cd53748..cce445b 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,194 +1,193 @@
1 1
2// code added by L. J. Potter Sat 03-02-2002 06:17:54
3#define QTOPIA_INTERNAL_FSLP 2#define QTOPIA_INTERNAL_FSLP
4#include <qpe/qcopenvelope_qws.h> 3#include <qpe/qcopenvelope_qws.h>
5 4
6#include <qpe/qpemenubar.h> 5#include <qpe/qpemenubar.h>
7#include <qpe/qpetoolbar.h> 6#include <qpe/qpetoolbar.h>
8#include <qpe/fileselector.h> 7#include <qpe/fileselector.h>
9#include <qpe/qpeapplication.h> 8#include <qpe/qpeapplication.h>
10#include <qpe/lnkproperties.h> 9#include <qpe/lnkproperties.h>
11#include <qpe/storage.h> 10#include <qpe/storage.h>
12 11
13#include <qpe/applnk.h> 12#include <qpe/applnk.h>
14#include <qpe/config.h> 13#include <qpe/config.h>
15#include <qpe/global.h> 14#include <qpe/global.h>
16#include <qpe/resource.h> 15#include <qpe/resource.h>
17#include <qaction.h> 16#include <qaction.h>
18#include <qcursor.h> 17#include <qcursor.h>
19#include <qimage.h> 18#include <qimage.h>
20#include <qfile.h> 19#include <qfile.h>
21#include <qdir.h> 20#include <qdir.h>
22#include <qlayout.h> 21#include <qlayout.h>
23#include <qlabel.h> 22#include <qlabel.h>
24#include <qlist.h> 23#include <qlist.h>
25#include <qlistbox.h> 24#include <qlistbox.h>
26#include <qmainwindow.h> 25#include <qmainwindow.h>
27#include <qmessagebox.h> 26#include <qmessagebox.h>
28#include <qtoolbutton.h> 27#include <qtoolbutton.h>
29#include <qtabwidget.h> 28#include <qtabwidget.h>
30#include <qlistview.h> 29#include <qlistview.h>
31#include <qpoint.h> 30#include <qpoint.h>
32#include <qlineedit.h> 31#include <qlineedit.h>
33#include <qpushbutton.h> 32#include <qpushbutton.h>
34#include <qregexp.h> 33#include <qregexp.h>
35#include <qtextstream.h> 34#include <qtextstream.h>
36 35
37 36
38#include "playlistselection.h" 37#include "playlistselection.h"
39#include "playlistwidget.h" 38#include "playlistwidget.h"
40#include "mediaplayerstate.h" 39#include "mediaplayerstate.h"
41 40
42#include "inputDialog.h" 41#include "inputDialog.h"
43 42
44#include <stdlib.h> 43#include <stdlib.h>
45#include "audiowidget.h" 44#include "audiowidget.h"
46#include "videowidget.h" 45#include "videowidget.h"
47 46
48#include <unistd.h> 47#include <unistd.h>
49#include <sys/file.h> 48#include <sys/file.h>
50#include <sys/ioctl.h> 49#include <sys/ioctl.h>
51#include <sys/soundcard.h> 50#include <sys/soundcard.h>
52 51
53// for setBacklight() 52// for setBacklight()
54#include <linux/fb.h> 53#include <linux/fb.h>
55#include <sys/types.h> 54#include <sys/types.h>
56#include <sys/stat.h> 55#include <sys/stat.h>
57#include <stdlib.h> 56#include <stdlib.h>
58 57
59#define BUTTONS_ON_TOOLBAR 58#define BUTTONS_ON_TOOLBAR
60#define SIDE_BUTTONS 59#define SIDE_BUTTONS
61#define CAN_SAVE_LOAD_PLAYLISTS 60#define CAN_SAVE_LOAD_PLAYLISTS
62 61
63extern MediaPlayerState *mediaPlayerState; 62extern MediaPlayerState *mediaPlayerState;
64 63
65 64
66class PlayListWidgetPrivate { 65class PlayListWidgetPrivate {
67public: 66public:
68 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 67 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
69 QFrame *playListFrame; 68 QFrame *playListFrame;
70 FileSelector *files; 69 FileSelector *files;
71 PlayListSelection *selectedFiles; 70 PlayListSelection *selectedFiles;
72 bool setDocumentUsed; 71 bool setDocumentUsed;
73 DocLnk *current; 72 DocLnk *current;
74}; 73};
75 74
76 75
77class ToolButton : public QToolButton { 76class ToolButton : public QToolButton {
78public: 77public:
79 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 78 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
80 : QToolButton( parent, name ) { 79 : QToolButton( parent, name ) {
81 setTextLabel( name ); 80 setTextLabel( name );
82 setPixmap( Resource::loadPixmap( icon ) ); 81 setPixmap( Resource::loadPixmap( icon ) );
83 setAutoRaise( TRUE ); 82 setAutoRaise( TRUE );
84 setFocusPolicy( QWidget::NoFocus ); 83 setFocusPolicy( QWidget::NoFocus );
85 setToggleButton( t ); 84 setToggleButton( t );
86 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 85 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
87 QPEMenuToolFocusManager::manager()->addWidget( this ); 86 QPEMenuToolFocusManager::manager()->addWidget( this );
88 } 87 }
89}; 88};
90 89
91 90
92class MenuItem : public QAction { 91class MenuItem : public QAction {
93public: 92public:
94 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 93 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
95 : QAction( text, QString::null, 0, 0 ) { 94 : QAction( text, QString::null, 0, 0 ) {
96 connect( this, SIGNAL( activated() ), handler, slot ); 95 connect( this, SIGNAL( activated() ), handler, slot );
97 addTo( parent ); 96 addTo( parent );
98 } 97 }
99}; 98};
100 99
101 100
102PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 101PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
103 : QMainWindow( parent, name, fl ) { 102 : QMainWindow( parent, name, fl ) {
104 103
105 d = new PlayListWidgetPrivate; 104 d = new PlayListWidgetPrivate;
106 d->setDocumentUsed = FALSE; 105 d->setDocumentUsed = FALSE;
107 d->current = NULL; 106 d->current = NULL;
108 fromSetDocument = FALSE; 107 fromSetDocument = FALSE;
109 insanityBool=FALSE; 108 insanityBool=FALSE;
110 audioScan = FALSE; 109 audioScan = FALSE;
111 videoScan = FALSE; 110 videoScan = FALSE;
112 111
113 setBackgroundMode( PaletteButton ); 112 setBackgroundMode( PaletteButton );
114 113
115 setCaption( tr("OpiePlayer") ); 114 setCaption( tr("OpiePlayer") );
116 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); 115 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) );
117 116
118 setToolBarsMovable( FALSE ); 117 setToolBarsMovable( FALSE );
119 118
120 // Create Toolbar 119 // Create Toolbar
121 QPEToolBar *toolbar = new QPEToolBar( this ); 120 QPEToolBar *toolbar = new QPEToolBar( this );
122 toolbar->setHorizontalStretchable( TRUE ); 121 toolbar->setHorizontalStretchable( TRUE );
123 122
124 // Create Menubar 123 // Create Menubar
125 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 124 QPEMenuBar *menu = new QPEMenuBar( toolbar );
126 menu->setMargin( 0 ); 125 menu->setMargin( 0 );
127 126
128 QPEToolBar *bar = new QPEToolBar( this ); 127 QPEToolBar *bar = new QPEToolBar( this );
129 bar->setLabel( tr( "Play Operations" ) ); 128 bar->setLabel( tr( "Play Operations" ) );
130 129
131 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 130 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
132 tbDeletePlaylist->setFlat(TRUE); 131 tbDeletePlaylist->setFlat(TRUE);
133 tbDeletePlaylist->setFixedSize(20,20); 132 tbDeletePlaylist->setFixedSize(20,20);
134 133
135 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", 134 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist",
136 this , SLOT(addSelected()) ); 135 this , SLOT(addSelected()) );
137 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", 136 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist",
138 this , SLOT(removeSelected()) ); 137 this , SLOT(removeSelected()) );
139 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", 138 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play",
140 this , SLOT( btnPlay(bool) ), TRUE ); 139 this , SLOT( btnPlay(bool) ), TRUE );
141 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", 140 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle",
142 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 141 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
143 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", 142 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop",
144 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 143 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
145 tbDeletePlaylist->hide(); 144 tbDeletePlaylist->hide();
146 145
147 QPopupMenu *pmPlayList = new QPopupMenu( this ); 146 QPopupMenu *pmPlayList = new QPopupMenu( this );
148 menu->insertItem( tr( "File" ), pmPlayList ); 147 menu->insertItem( tr( "File" ), pmPlayList );
149 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 148 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
150 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 149 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
151 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 150 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
152 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 151 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
153 pmPlayList->insertSeparator(-1); 152 pmPlayList->insertSeparator(-1);
154 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 153 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
155 new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); 154 new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) );
156 pmPlayList->insertSeparator(-1); 155 pmPlayList->insertSeparator(-1);
157 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 156 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
158 pmPlayList->insertSeparator(-1); 157 pmPlayList->insertSeparator(-1);
159 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 158 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
160 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 159 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
161 160
162 QPopupMenu *pmView = new QPopupMenu( this ); 161 QPopupMenu *pmView = new QPopupMenu( this );
163 menu->insertItem( tr( "View" ), pmView ); 162 menu->insertItem( tr( "View" ), pmView );
164 163
165 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); 164 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
166 fullScreenButton->addTo(pmView); 165 fullScreenButton->addTo(pmView);
167 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); 166 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0);
168 scaleButton->addTo(pmView); 167 scaleButton->addTo(pmView);
169 168
170 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 169 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
171 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 170 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
172 171
173 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 172 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
174 173
175 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 174 tabWidget = new QTabWidget( hbox6, "tabWidget" );
176 tabWidget->setTabShape(QTabWidget::Triangular); 175 tabWidget->setTabShape(QTabWidget::Triangular);
177 176
178 QWidget *pTab; 177 QWidget *pTab;
179 pTab = new QWidget( tabWidget, "pTab" ); 178 pTab = new QWidget( tabWidget, "pTab" );
180 tabWidget->insertTab( pTab,"Playlist"); 179 tabWidget->insertTab( pTab,"Playlist");
181 180
182 181
183 // Add the playlist area 182 // Add the playlist area
184 183
185 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 184 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
186 d->playListFrame = vbox3; 185 d->playListFrame = vbox3;
187 d->playListFrame ->setMinimumSize(235,260); 186 d->playListFrame ->setMinimumSize(235,260);
188 187
189 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 188 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
190 189
191 d->selectedFiles = new PlayListSelection( hbox2); 190 d->selectedFiles = new PlayListSelection( hbox2);
192 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 191 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
193 192
194 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 193 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index d3898a0..bce6b89 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -1,388 +1,376 @@
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/resource.h> 34#include <qpe/resource.h>
35#include <qpe/mediaplayerplugininterface.h> 35#include <qpe/mediaplayerplugininterface.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37 37
38#include <qwidget.h> 38#include <qwidget.h>
39#include <qpainter.h> 39#include <qpainter.h>
40#include <qpixmap.h> 40#include <qpixmap.h>
41#include <qslider.h> 41#include <qslider.h>
42#include <qdrawutil.h> 42#include <qdrawutil.h>
43#include "videowidget.h" 43#include "videowidget.h"
44#include "mediaplayerstate.h" 44#include "mediaplayerstate.h"
45 45
46 46
47#ifdef Q_WS_QWS 47#ifdef Q_WS_QWS
48# define USE_DIRECT_PAINTER 48# define USE_DIRECT_PAINTER
49# include <qdirectpainter_qws.h> 49# include <qdirectpainter_qws.h>
50# include <qgfxraster_qws.h> 50# include <qgfxraster_qws.h>
51#endif 51#endif
52 52
53 53
54extern MediaPlayerState *mediaPlayerState; 54extern MediaPlayerState *mediaPlayerState;
55 55
56 56
57static const int xo = 2; // movable x offset 57static const int xo = 2; // movable x offset
58static const int yo = 0; // movable y offset 58static const int yo = 0; // movable y offset
59 59
60 60
61struct MediaButton { 61struct MediaButton {
62 int xPos, yPos; 62 int xPos, yPos;
63 bool isToggle, isHeld, isDown; 63 bool isToggle, isHeld, isDown;
64 int controlType; 64 int controlType;
65}; 65};
66 66
67 67
68// Layout information for the videoButtons (and if it is a toggle button or not) 68// Layout information for the videoButtons (and if it is a toggle button or not)
69MediaButton videoButtons[] = { 69MediaButton videoButtons[] = {
70 { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous 70 { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous
71 { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop 71 { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop
72 { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play 72 { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play
73 { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause 73 { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause
74 { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next 74 { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next
75 { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist 75 { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist
76 { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen 76 { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen
77}; 77};
78 78
79 79
80static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 80static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton));
81 81
82 82
83VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 83VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
84 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { 84 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) {
85 setCaption( tr("OpiePlayer - Video") ); 85 setCaption( tr("OpiePlayer - Video") );
86 Config cfg("OpiePlayer"); 86 Config cfg("OpiePlayer");
87 cfg.setGroup("VideoWidget"); 87 cfg.setGroup("VideoWidget");
88 88
89 QString backgroundPix, Button0aPix, Button0bPix, controlsPix; 89 QString backgroundPix, Button0aPix, Button0bPix, controlsPix;
90 backgroundPix=cfg.readEntry( "backgroundPix", "opieplayer/metalFinish"); 90 backgroundPix=cfg.readEntry( "backgroundPix", "opieplayer/metalFinish");
91 Button0aPix=cfg.readEntry( "Button0aPix", "opieplayer/mediaButton0a"); 91 Button0aPix=cfg.readEntry( "Button0aPix", "opieplayer/mediaButton0a");
92 Button0bPix=cfg.readEntry( "Button0bPix","opieplayer/mediaButton0b"); 92 Button0bPix=cfg.readEntry( "Button0bPix","opieplayer/mediaButton0b");
93 controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls0" ); 93 controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls0" );
94 94
95 setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); 95 setBackgroundPixmap( Resource::loadPixmap( backgroundPix) );
96 pixmaps[0] = new QPixmap( Resource::loadPixmap( Button0aPix ) ); 96 pixmaps[0] = new QPixmap( Resource::loadPixmap( Button0aPix ) );
97 pixmaps[1] = new QPixmap( Resource::loadPixmap( Button0bPix ) ); 97 pixmaps[1] = new QPixmap( Resource::loadPixmap( Button0bPix ) );
98 pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix) ); 98 pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix) );
99 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); 99 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 );
100 100
101 slider = new QSlider( Qt::Horizontal, this ); 101 slider = new QSlider( Qt::Horizontal, this );
102 slider->setMinValue( 0 ); 102 slider->setMinValue( 0 );
103 slider->setMaxValue( 1 ); 103 slider->setMaxValue( 1 );
104 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 104 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
105 slider->setFocusPolicy( QWidget::NoFocus ); 105 slider->setFocusPolicy( QWidget::NoFocus );
106 slider->setGeometry( QRect( 7, 250, 220, 20 ) ); 106 slider->setGeometry( QRect( 7, 250, 220, 20 ) );
107 107
108 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 108 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
109 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 109 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
110 110
111 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 111 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
112 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 112 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
113 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 113 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
114 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 114 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
115 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 115 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
116 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 116 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
117 117
118 // Intialise state 118 // Intialise state
119 setLength( mediaPlayerState->length() ); 119 setLength( mediaPlayerState->length() );
120 setPosition( mediaPlayerState->position() ); 120 setPosition( mediaPlayerState->position() );
121 setFullscreen( mediaPlayerState->fullscreen() ); 121 setFullscreen( mediaPlayerState->fullscreen() );
122 setPaused( mediaPlayerState->paused() ); 122 setPaused( mediaPlayerState->paused() );
123 setPlaying( mediaPlayerState->playing() ); 123 setPlaying( mediaPlayerState->playing() );
124 124
125 videoFrame = new XineVideoWidget( 200, 150 ,this, "Video frame" ); 125 videoFrame = new XineVideoWidget( 240, 155 ,this, "Video frame" );
126 videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) ); 126 videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) );
127} 127}
128 128
129 129
130VideoWidget::~VideoWidget() { 130VideoWidget::~VideoWidget() {
131 for ( int i = 0; i < 3; i++ ) { 131 for ( int i = 0; i < 3; i++ ) {
132 delete pixmaps[i]; 132 delete pixmaps[i];
133 } 133 }
134 delete currentFrame; 134 delete currentFrame;
135} 135}
136 136
137 137
138static bool videoSliderBeingMoved = FALSE; 138static bool videoSliderBeingMoved = FALSE;
139 139
140 140
141void VideoWidget::sliderPressed() { 141void VideoWidget::sliderPressed() {
142 videoSliderBeingMoved = TRUE; 142 videoSliderBeingMoved = TRUE;
143} 143}
144 144
145 145
146void VideoWidget::sliderReleased() { 146void VideoWidget::sliderReleased() {
147 videoSliderBeingMoved = FALSE; 147 videoSliderBeingMoved = FALSE;
148 if ( slider->width() == 0 ) { 148 if ( slider->width() == 0 ) {
149 return; 149 return;
150 } 150 }
151 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 151 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
152 mediaPlayerState->setPosition( val ); 152 mediaPlayerState->setPosition( val );
153} 153}
154 154
155 155
156void VideoWidget::setPosition( long i ) { 156void VideoWidget::setPosition( long i ) {
157 updateSlider( i, mediaPlayerState->length() ); 157 updateSlider( i, mediaPlayerState->length() );
158} 158}
159 159
160 160
161void VideoWidget::setLength( long max ) { 161void VideoWidget::setLength( long max ) {
162 updateSlider( mediaPlayerState->position(), max ); 162 updateSlider( mediaPlayerState->position(), max );
163} 163}
164 164
165 165
166void VideoWidget::setView( char view ) { 166void VideoWidget::setView( char view ) {
167 if ( view == 'v' ) { 167 if ( view == 'v' ) {
168 makeVisible(); 168 makeVisible();
169 } else { 169 } else {
170 // Effectively blank the view next time we show it so it looks nicer 170 // Effectively blank the view next time we show it so it looks nicer
171 scaledWidth = 0; 171 scaledWidth = 0;
172 scaledHeight = 0; 172 scaledHeight = 0;
173 hide(); 173 hide();
174 } 174 }
175} 175}
176 176
177 177
178void VideoWidget::updateSlider( long i, long max ) { 178void VideoWidget::updateSlider( long i, long max ) {
179 // Will flicker too much if we don't do this 179 // Will flicker too much if we don't do this
180 if ( max == 0 ) { 180 if ( max == 0 ) {
181 return; 181 return;
182 } 182 }
183 int width = slider->width(); 183 int width = slider->width();
184 int val = int((double)i * width / max); 184 int val = int((double)i * width / max);
185 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { 185 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) {
186 if ( slider->value() != val ) { 186 if ( slider->value() != val ) {
187 slider->setValue( val ); 187 slider->setValue( val );
188 } 188 }
189 if ( slider->maxValue() != width ) { 189 if ( slider->maxValue() != width ) {
190 slider->setMaxValue( width ); 190 slider->setMaxValue( width );
191 } 191 }
192 } 192 }
193} 193}
194 194
195 195
196void VideoWidget::setToggleButton( int i, bool down ) { 196void VideoWidget::setToggleButton( int i, bool down ) {
197 if ( down != videoButtons[i].isDown ) { 197 if ( down != videoButtons[i].isDown ) {
198 toggleButton( i ); 198 toggleButton( i );
199 } 199 }
200} 200}
201 201
202 202
203void VideoWidget::toggleButton( int i ) { 203void VideoWidget::toggleButton( int i ) {
204 videoButtons[i].isDown = !videoButtons[i].isDown; 204 videoButtons[i].isDown = !videoButtons[i].isDown;
205 QPainter p(this); 205 QPainter p(this);
206 paintButton ( &p, i ); 206 paintButton ( &p, i );
207} 207}
208 208
209 209
210void VideoWidget::paintButton( QPainter *p, int i ) { 210void VideoWidget::paintButton( QPainter *p, int i ) {
211 int x = videoButtons[i].xPos; 211 int x = videoButtons[i].xPos;
212 int y = videoButtons[i].yPos; 212 int y = videoButtons[i].yPos;
213 int offset = 10 + videoButtons[i].isDown; 213 int offset = 10 + videoButtons[i].isDown;
214 p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] ); 214 p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] );
215 p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 ); 215 p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 );
216} 216}
217 217
218 218
219void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 219void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
220 for ( int i = 0; i < numButtons; i++ ) { 220 for ( int i = 0; i < numButtons; i++ ) {
221 int x = videoButtons[i].xPos; 221 int x = videoButtons[i].xPos;
222 int y = videoButtons[i].yPos; 222 int y = videoButtons[i].yPos;
223 if ( event->state() == QMouseEvent::LeftButton ) { 223 if ( event->state() == QMouseEvent::LeftButton ) {
224 // The test to see if the mouse click is inside the circular button or not 224 // The test to see if the mouse click is inside the circular button or not
225 // (compared with the radius squared to avoid a square-root of our distance) 225 // (compared with the radius squared to avoid a square-root of our distance)
226 int radius = 16; 226 int radius = 16;
227 QPoint center = QPoint( x + radius, y + radius ); 227 QPoint center = QPoint( x + radius, y + radius );
228 QPoint dXY = center - event->pos(); 228 QPoint dXY = center - event->pos();
229 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); 229 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y();
230 bool isOnButton = dist <= (radius * radius); 230 bool isOnButton = dist <= (radius * radius);
231 if ( isOnButton != videoButtons[i].isHeld ) { 231 if ( isOnButton != videoButtons[i].isHeld ) {
232 videoButtons[i].isHeld = isOnButton; 232 videoButtons[i].isHeld = isOnButton;
233 toggleButton(i); 233 toggleButton(i);
234 } 234 }
235 } else { 235 } else {
236 if ( videoButtons[i].isHeld ) { 236 if ( videoButtons[i].isHeld ) {
237 videoButtons[i].isHeld = FALSE; 237 videoButtons[i].isHeld = FALSE;
238 if ( !videoButtons[i].isToggle ) 238 if ( !videoButtons[i].isToggle )
239 setToggleButton( i, FALSE ); 239 setToggleButton( i, FALSE );
240 } 240 }
241 } 241 }
242 switch (i) { 242 switch (i) {
243 case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; 243 case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return;
244 case VideoStop: mediaPlayerState->setPlaying(FALSE); return; 244 case VideoStop: mediaPlayerState->setPlaying(FALSE); return;
245 case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; 245 case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return;
246 case VideoNext: mediaPlayerState->setNext(); return; 246 case VideoNext: mediaPlayerState->setNext(); return;
247 case VideoPrevious: mediaPlayerState->setPrev(); return; 247 case VideoPrevious: mediaPlayerState->setPrev(); return;
248 case VideoPlayList: mediaPlayerState->setList(); return; 248 case VideoPlayList: mediaPlayerState->setList(); return;
249 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; 249 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
250 } 250 }
251 251
252 } 252 }
253} 253}
254 254
255 255
256void VideoWidget::mousePressEvent( QMouseEvent *event ) { 256void VideoWidget::mousePressEvent( QMouseEvent *event ) {
257 mouseMoveEvent( event ); 257 mouseMoveEvent( event );
258} 258}
259 259
260 260
261void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 261void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
262 if ( mediaPlayerState->fullscreen() ) { 262 if ( mediaPlayerState->fullscreen() ) {
263 mediaPlayerState->setFullscreen( FALSE ); 263 mediaPlayerState->setFullscreen( FALSE );
264 makeVisible(); 264 makeVisible();
265 265
266 mouseMoveEvent( event ); 266 mouseMoveEvent( event );
267 } 267 }
268} 268}
269 269
270 270
271void VideoWidget::makeVisible() { 271void VideoWidget::makeVisible() {
272 if ( mediaPlayerState->fullscreen() ) { 272 if ( mediaPlayerState->fullscreen() ) {
273 setBackgroundMode( QWidget::NoBackground ); 273 setBackgroundMode( QWidget::NoBackground );
274 showFullScreen(); 274 showFullScreen();
275 resize( qApp->desktop()->size() ); 275 resize( qApp->desktop()->size() );
276 slider->hide(); 276 slider->hide();
277 } else { 277 } else {
278 setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); 278 setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) );
279 showNormal(); 279 showNormal();
280 showMaximized(); 280 showMaximized();
281 slider->show(); 281 slider->show();
282 } 282 }
283} 283}
284 284
285 285
286void VideoWidget::paintEvent( QPaintEvent * ) { 286void VideoWidget::paintEvent( QPaintEvent * ) {
287 QPainter p( this ); 287 QPainter p( this );
288 288
289 if ( mediaPlayerState->fullscreen() ) { 289 if ( mediaPlayerState->fullscreen() ) {
290 // Clear the background 290 // Clear the background
291// p.setBrush( QBrush( Qt::black ) ); 291 p.setBrush( QBrush( Qt::black ) );
292 //p.drawRect( rect() ); 292 videoFrame->setGeometry( QRect( 0, 0 , 240 ,340 ) );
293 293
294 } else { 294 } else {
295 // draw border 295 // draw the buttons
296 qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL );
297
298 // Clear the movie screen first
299// p.setBrush( QBrush( Qt::black ) );
300// p.drawRect( 9, 20, 220, 160 );
301
302 // draw current frame (centrally positioned from scaling to maintain aspect ratio)
303 //p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight );
304
305 // draw the buttons
306 for ( int i = 0; i < numButtons; i++ ) { 296 for ( int i = 0; i < numButtons; i++ ) {
307 paintButton( &p, i ); 297 paintButton( &p, i );
308 } 298 }
309
310 // draw the slider 299 // draw the slider
311 slider->repaint( TRUE ); 300 slider->repaint( TRUE );
312 //videoFrame->repaint( TRUE );
313 } 301 }
314} 302}
315 303
316 304
317void VideoWidget::closeEvent( QCloseEvent* ) { 305void VideoWidget::closeEvent( QCloseEvent* ) {
318 mediaPlayerState->setList(); 306 mediaPlayerState->setList();
319} 307}
320 308
321 309
322bool VideoWidget::playVideo() { 310bool VideoWidget::playVideo() {
323 bool result = FALSE; 311 bool result = FALSE;
324 312
325 int stream = 0; 313 int stream = 0;
326 314
327 int sw = 240; 315 int sw = 240;
328 int sh = 320; 316 int sh = 320;
329 int dd = QPixmap::defaultDepth(); 317 int dd = QPixmap::defaultDepth();
330 int w = height(); 318 int w = height();
331 int h = width(); 319 int h = width();
332 320
333 return true; 321 return true;
334} 322}
335 323
336 324
337 325
338void VideoWidget::keyReleaseEvent( QKeyEvent *e) 326void VideoWidget::keyReleaseEvent( QKeyEvent *e)
339{ 327{
340 switch ( e->key() ) { 328 switch ( e->key() ) {
341////////////////////////////// Zaurus keys 329////////////////////////////// Zaurus keys
342 case Key_Home: 330 case Key_Home:
343 break; 331 break;
344 case Key_F9: //activity 332 case Key_F9: //activity
345 break; 333 break;
346 case Key_F10: //contacts 334 case Key_F10: //contacts
347// hide(); 335// hide();
348 break; 336 break;
349 case Key_F11: //menu 337 case Key_F11: //menu
350 break; 338 break;
351 case Key_F12: //home 339 case Key_F12: //home
352 break; 340 break;
353 case Key_F13: //mail 341 case Key_F13: //mail
354 break; 342 break;
355 case Key_Space: { 343 case Key_Space: {
356 if(mediaPlayerState->playing()) { 344 if(mediaPlayerState->playing()) {
357 mediaPlayerState->setPlaying(FALSE); 345 mediaPlayerState->setPlaying(FALSE);
358 } else { 346 } else {
359 mediaPlayerState->setPlaying(TRUE); 347 mediaPlayerState->setPlaying(TRUE);
360 } 348 }
361 } 349 }
362 break; 350 break;
363 case Key_Down: 351 case Key_Down:
364// toggleButton(6); 352// toggleButton(6);
365// emit lessClicked(); 353// emit lessClicked();
366// emit lessReleased(); 354// emit lessReleased();
367// toggleButton(6); 355// toggleButton(6);
368 break; 356 break;
369 case Key_Up: 357 case Key_Up:
370// toggleButton(5); 358// toggleButton(5);
371// emit moreClicked(); 359// emit moreClicked();
372// emit moreReleased(); 360// emit moreReleased();
373// toggleButton(5); 361// toggleButton(5);
374 break; 362 break;
375 case Key_Right: 363 case Key_Right:
376 mediaPlayerState->setNext(); 364 mediaPlayerState->setNext();
377 break; 365 break;
378 case Key_Left: 366 case Key_Left:
379 mediaPlayerState->setPrev(); 367 mediaPlayerState->setPrev();
380 break; 368 break;
381 case Key_Escape: 369 case Key_Escape:
382 break; 370 break;
383 371
384 }; 372 };
385} 373}
386XineVideoWidget* VideoWidget::vidWidget() { 374XineVideoWidget* VideoWidget::vidWidget() {
387 return videoFrame; 375 return videoFrame;
388} 376}