summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h1
-rw-r--r--noncore/multimedia/opieplayer2/om3u.h43
-rw-r--r--noncore/multimedia/opieplayer2/playlistfileview.cpp5
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp44
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidgetgui.cpp46
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidgetgui.h52
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.cpp3
7 files changed, 100 insertions, 94 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index d885150..a64ab92 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -1,148 +1,149 @@
1/* 1/*
2 Copyright (C) 2002 Simon Hausmann <simon@lst.de> 2 Copyright (C) 2002 Simon Hausmann <simon@lst.de>
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 program is free software; you can redistribute it and/or 7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public 8 modify it under the terms of the GNU 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 program is distributed in the hope that it will be useful, 12 This program 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 General Public License for more details. 15 General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not, write to 18 along with this program; see the file COPYING. 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 <qbitmap.h>
26#include <qwidget.h> 27#include <qwidget.h>
27#include <qmap.h> 28#include <qmap.h>
28 29
29#include "mediaplayerstate.h" 30#include "mediaplayerstate.h"
30#include "playlistwidget.h" 31#include "playlistwidget.h"
31 32
32class Skin; 33class Skin;
33 34
34class MediaWidget : public QWidget 35class MediaWidget : public QWidget
35{ 36{
36 Q_OBJECT 37 Q_OBJECT
37public: 38public:
38 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, FullScreen, Undefined }; 39 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, FullScreen, Undefined };
39 enum ButtonType { NormalButton, ToggleButton }; 40 enum ButtonType { NormalButton, ToggleButton };
40 41
41 struct Button 42 struct Button
42 { 43 {
43 Button() : command( Undefined ), type( NormalButton ), isDown( false ) {} 44 Button() : command( Undefined ), type( NormalButton ), isDown( false ) {}
44 45
45 Command command; 46 Command command;
46 47
47 ButtonType type; // this should be part of the bitfield but gcc2 is too buggy to support this :-( 48 ButtonType type; // this should be part of the bitfield but gcc2 is too buggy to support this :-(
48 bool isDown : 1; 49 bool isDown : 1;
49 50
50 QBitmap mask; 51 QBitmap mask;
51 QPixmap pixUp; 52 QPixmap pixUp;
52 QPixmap pixDown; 53 QPixmap pixDown;
53 }; 54 };
54 typedef QValueList<Button> ButtonVector; 55 typedef QValueList<Button> ButtonVector;
55 56
56 struct SkinButtonInfo 57 struct SkinButtonInfo
57 { 58 {
58 Command command; 59 Command command;
59 const char *fileName; 60 const char *fileName;
60 ButtonType type; 61 ButtonType type;
61 }; 62 };
62 63
63 struct GUIInfo 64 struct GUIInfo
64 { 65 {
65 GUIInfo() : buttonInfo( 0 ), buttonCount( 0 ) {} 66 GUIInfo() : buttonInfo( 0 ), buttonCount( 0 ) {}
66 GUIInfo( const QString &_fileNameInfix, const SkinButtonInfo *_buttonInfo, const uint _buttonCount ) 67 GUIInfo( const QString &_fileNameInfix, const SkinButtonInfo *_buttonInfo, const uint _buttonCount )
67 : fileNameInfix( _fileNameInfix ), buttonInfo( _buttonInfo ), buttonCount( _buttonCount ) 68 : fileNameInfix( _fileNameInfix ), buttonInfo( _buttonInfo ), buttonCount( _buttonCount )
68 {} 69 {}
69 70
70 QString fileNameInfix; 71 QString fileNameInfix;
71 const SkinButtonInfo *buttonInfo; 72 const SkinButtonInfo *buttonInfo;
72 const uint buttonCount; 73 const uint buttonCount;
73 }; 74 };
74 typedef QValueList<GUIInfo> GUIInfoList; 75 typedef QValueList<GUIInfo> GUIInfoList;
75 76
76 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); 77 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 );
77 virtual ~MediaWidget(); 78 virtual ~MediaWidget();
78 79
79public slots: 80public slots:
80 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; 81 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0;
81 virtual void setLength( long length ) = 0; 82 virtual void setLength( long length ) = 0;
82 virtual void setPlaying( bool playing ) = 0; 83 virtual void setPlaying( bool playing ) = 0;
83 84
84 virtual void loadSkin() = 0; 85 virtual void loadSkin() = 0;
85 86
86signals: 87signals:
87 void moreReleased(); 88 void moreReleased();
88 void lessReleased(); 89 void lessReleased();
89 void forwardReleased(); 90 void forwardReleased();
90 void backReleased(); 91 void backReleased();
91 void forwardClicked(); 92 void forwardClicked();
92 void backClicked(); 93 void backClicked();
93 void moreClicked(); 94 void moreClicked();
94 void lessClicked(); 95 void lessClicked();
95 96
96protected: 97protected:
97 void setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, 98 void setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
98 const Skin &skin ); 99 const Skin &skin );
99 Button setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ); 100 Button setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin );
100 101
101 void loadDefaultSkin( const GUIInfo &guiInfo ); 102 void loadDefaultSkin( const GUIInfo &guiInfo );
102 void loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin ); 103 void loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin );
103 104
104 virtual void closeEvent( QCloseEvent * ); 105 virtual void closeEvent( QCloseEvent * );
105 106
106 virtual void paintEvent( QPaintEvent *pe ); 107 virtual void paintEvent( QPaintEvent *pe );
107 108
108 virtual void resizeEvent( QResizeEvent *e ); 109 virtual void resizeEvent( QResizeEvent *e );
109 110
110 Button *buttonAt( const QPoint &position ); 111 Button *buttonAt( const QPoint &position );
111 112
112 virtual void mousePressEvent( QMouseEvent *event ); 113 virtual void mousePressEvent( QMouseEvent *event );
113 virtual void mouseReleaseEvent( QMouseEvent *event ); 114 virtual void mouseReleaseEvent( QMouseEvent *event );
114 115
115 virtual void makeVisible(); 116 virtual void makeVisible();
116 117
117 void handleCommand( Command command, bool buttonDown ); 118 void handleCommand( Command command, bool buttonDown );
118 119
119 bool isOverButton( const QPoint &position, int buttonId ) const; 120 bool isOverButton( const QPoint &position, int buttonId ) const;
120 121
121 void paintAllButtons( QPainter &p ); 122 void paintAllButtons( QPainter &p );
122 void paintButton( const Button &button ); 123 void paintButton( const Button &button );
123 void paintButton( QPainter &p, const Button &button ); 124 void paintButton( QPainter &p, const Button &button );
124 125
125 void setToggleButton( Button &button, bool down ); 126 void setToggleButton( Button &button, bool down );
126 void setToggleButton( Command command, bool down ); 127 void setToggleButton( Command command, bool down );
127 void toggleButton( Button &button ); 128 void toggleButton( Button &button );
128 129
129 MediaPlayerState &mediaPlayerState; 130 MediaPlayerState &mediaPlayerState;
130 PlayListWidget &playList; 131 PlayListWidget &playList;
131 132
132 ButtonVector buttons; 133 ButtonVector buttons;
133 134
134 QImage buttonMask; 135 QImage buttonMask;
135 136
136 QPoint upperLeftOfButtonMask; 137 QPoint upperLeftOfButtonMask;
137 138
138 QPixmap backgroundPixmap; 139 QPixmap backgroundPixmap;
139 QImage buttonUpImage; 140 QImage buttonUpImage;
140 QImage buttonDownImage; 141 QImage buttonDownImage;
141 142
142 static QPixmap combineImageWithBackground( const QImage &background, const QPixmap &pixmap, const QPoint &offset ); 143 static QPixmap combineImageWithBackground( const QImage &background, const QPixmap &pixmap, const QPoint &offset );
143 static QPixmap addMaskToPixmap( const QPixmap &pix, const QBitmap &mask ); 144 static QPixmap addMaskToPixmap( const QPixmap &pix, const QBitmap &mask );
144}; 145};
145 146
146#endif // MEDIAWIDGET_H 147#endif // MEDIAWIDGET_H
147/* vim: et sw=4 ts=4 148/* vim: et sw=4 ts=4
148 */ 149 */
diff --git a/noncore/multimedia/opieplayer2/om3u.h b/noncore/multimedia/opieplayer2/om3u.h
index 9c7cf9a..0e04f72 100644
--- a/noncore/multimedia/opieplayer2/om3u.h
+++ b/noncore/multimedia/opieplayer2/om3u.h
@@ -1,79 +1,80 @@
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 L. Potter <ljp@llornkcor.com> 4 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7 .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8_;:, .> :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_, > . <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU General Public 10:`=1 )Y*s>-.-- : the terms of the GNU General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i, .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12- . .-<_> .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13 ._= =} : or (at your option) any later version.
14    .%`+i>       _;_. 14 .%`+i> _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15 .i_,=:_. -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17 : .. .:, . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; General Public License for more 20..}^=.= = ; General Public License for more
21++=   -.     .`     .: details. 21++= -. .` .: details.
22 :     =  ...= . :.=- 22: = ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23-. .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = General Public License along with 24 -_. . . )=. = General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25 -- :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#ifndef OM3U_H 32#ifndef OM3U_H
33#define OM3U_H 33#define OM3U_H
34 34
35#include "playlistwidget.h" 35#include "playlistwidget.h"
36 36
37#include <opie2/oresource.h>
38
37#include <qpe/applnk.h> 39#include <qpe/applnk.h>
38#include <qpe/qpeapplication.h> 40#include <qpe/qpeapplication.h>
39#include <qpe/storage.h> 41#include <qpe/storage.h>
40#include <qpe/mimetype.h> 42#include <qpe/mimetype.h>
41#include <qpe/global.h> 43#include <qpe/global.h>
42#include <qpe/resource.h>
43 44
44#include <qdir.h> 45#include <qdir.h>
45#include <qregexp.h> 46#include <qregexp.h>
46#include <qstring.h> 47#include <qstring.h>
47#include <qtextstream.h> 48#include <qtextstream.h>
48#include <qstringlist.h> 49#include <qstringlist.h>
49#include <qcstring.h> 50#include <qcstring.h>
50#include <qfile.h> 51#include <qfile.h>
51 52
52 53
53class Om3u : public QStringList { 54class Om3u : public QStringList {
54// Q_OBJECT 55// Q_OBJECT
55public: 56public:
56 Om3u( const QString &filePath, int mode); 57 Om3u( const QString &filePath, int mode);
57 ~Om3u(); 58 ~Om3u();
58 void readM3u(); 59 void readM3u();
59 void readPls(); 60 void readPls();
60 void write(); 61 void write();
61 void add(const QString &); 62 void add(const QString &);
62 void remove(const QString &); 63 void remove(const QString &);
63 void deleteFile(const QString &); 64 void deleteFile(const QString &);
64 void close(); 65 void close();
65 66
66public slots: 67public slots:
67 68
68protected: 69protected:
69 70
70private: 71private:
71 QFile f; 72 QFile f;
72private slots: 73private slots:
73 74
74 75
75}; 76};
76 77
77#endif// M3U_H 78#endif// M3U_H
78 79
79 80
diff --git a/noncore/multimedia/opieplayer2/playlistfileview.cpp b/noncore/multimedia/opieplayer2/playlistfileview.cpp
index 3094876..7ccc518 100644
--- a/noncore/multimedia/opieplayer2/playlistfileview.cpp
+++ b/noncore/multimedia/opieplayer2/playlistfileview.cpp
@@ -1,106 +1,107 @@
1 1
2#include "playlistfileview.h" 2#include "playlistfileview.h"
3 3
4#include <opie2/oresource.h>
5
4#include <qfile.h> 6#include <qfile.h>
5#include <qpe/global.h> 7#include <qpe/global.h>
6#include <qpe/resource.h>
7 8
8PlayListFileView::PlayListFileView( const QString &mimeTypePattern, const QString &itemPixmapName, QWidget *parent, const char *name ) 9PlayListFileView::PlayListFileView( const QString &mimeTypePattern, const QString &itemPixmapName, QWidget *parent, const char *name )
9 : PlayListView( parent, name ), m_mimeTypePattern( mimeTypePattern ), m_itemPixmapName( itemPixmapName ), m_scannedFiles( false ), 10 : PlayListView( parent, name ), m_mimeTypePattern( mimeTypePattern ), m_itemPixmapName( itemPixmapName ), m_scannedFiles( false ),
10 m_viewPopulated( false ) 11 m_viewPopulated( false )
11{ 12{
12 addColumn( tr( "Title" ), 140); 13 addColumn( tr( "Title" ), 140);
13 addColumn( tr( "Size" ), -1 ); 14 addColumn( tr( "Size" ), -1 );
14 addColumn(tr( "Media" ), 0 ); 15 addColumn(tr( "Media" ), 0 );
15 addColumn(tr( "Path" ), -1 ); 16 addColumn(tr( "Path" ), -1 );
16 setColumnAlignment( 1, Qt::AlignRight ); 17 setColumnAlignment( 1, Qt::AlignRight );
17 setColumnAlignment( 2, Qt::AlignRight ); 18 setColumnAlignment( 2, Qt::AlignRight );
18 setAllColumnsShowFocus( TRUE ); 19 setAllColumnsShowFocus( TRUE );
19 setSorting( 3, TRUE ); 20 setSorting( 3, TRUE );
20 setMultiSelection( TRUE ); 21 setMultiSelection( TRUE );
21 setSelectionMode( QListView::Extended ); 22 setSelectionMode( QListView::Extended );
22 23
23 connect( this, SIGNAL( selectionChanged() ), 24 connect( this, SIGNAL( selectionChanged() ),
24 this, SLOT( checkSelection() ) ); 25 this, SLOT( checkSelection() ) );
25} 26}
26 27
27PlayListFileView::~PlayListFileView() 28PlayListFileView::~PlayListFileView()
28{ 29{
29} 30}
30 31
31bool PlayListFileView::hasSelection() const 32bool PlayListFileView::hasSelection() const
32{ 33{
33 for ( QListViewItemIterator it( const_cast<PlayListFileView *>( this ) ); it.current(); ++it ) 34 for ( QListViewItemIterator it( const_cast<PlayListFileView *>( this ) ); it.current(); ++it )
34 if ( it.current()->isSelected() ) 35 if ( it.current()->isSelected() )
35 return true; 36 return true;
36 37
37 return false; 38 return false;
38} 39}
39 40
40void PlayListFileView::scanFiles() 41void PlayListFileView::scanFiles()
41{ 42{
42 m_files.detachChildren(); 43 m_files.detachChildren();
43 QListIterator<DocLnk> sdit( m_files.children() ); 44 QListIterator<DocLnk> sdit( m_files.children() );
44 for ( ; sdit.current(); ++sdit ) 45 for ( ; sdit.current(); ++sdit )
45 delete sdit.current(); 46 delete sdit.current();
46 47
47 Global::findDocuments( &m_files, m_mimeTypePattern ); 48 Global::findDocuments( &m_files, m_mimeTypePattern );
48 49
49 if ( m_viewPopulated ) { 50 if ( m_viewPopulated ) {
50 m_viewPopulated = false; 51 m_viewPopulated = false;
51 populateView(); 52 populateView();
52 } 53 }
53} 54}
54 55
55void PlayListFileView::populateView() 56void PlayListFileView::populateView()
56{ 57{
57 if ( m_viewPopulated ) 58 if ( m_viewPopulated )
58 return; 59 return;
59 60
60 clear(); 61 clear();
61 62
62 if( !m_scannedFiles ) { 63 if( !m_scannedFiles ) {
63 m_viewPopulated = false; // avoid a recursion :) 64 m_viewPopulated = false; // avoid a recursion :)
64 scanFiles(); 65 scanFiles();
65 m_scannedFiles = true; 66 m_scannedFiles = true;
66 } 67 }
67 68
68 m_viewPopulated = true; 69 m_viewPopulated = true;
69 70
70 QString storage; 71 QString storage;
71 QListIterator<DocLnk> dit( m_files.children() ); 72 QListIterator<DocLnk> dit( m_files.children() );
72 for ( ; dit.current(); ++dit ) { 73 for ( ; dit.current(); ++dit ) {
73 74
74 QListViewItem *newItem; 75 QListViewItem *newItem;
75 76
76 if ( QFile::exists( dit.current()->file() ) || 77 if ( QFile::exists( dit.current()->file() ) ||
77 dit.current()->file().left( 4 ) == "http" ) { 78 dit.current()->file().left( 4 ) == "http" ) {
78 79
79 unsigned long size = QFile( dit.current()->file() ).size(); 80 unsigned long size = QFile( dit.current()->file() ).size();
80 QString sizestr; 81 QString sizestr;
81 fileSize(size, sizestr); 82 fileSize(size, sizestr);
82 83
83 newItem = new QListViewItem( this, dit.current()->name(), 84 newItem = new QListViewItem( this, dit.current()->name(),
84 sizestr, "" /*storage*/, 85 sizestr, "" /*storage*/,
85 dit.current()->file() ); 86 dit.current()->file() );
86 newItem->setPixmap( 0, Resource::loadPixmap( m_itemPixmapName ) ); 87 newItem->setPixmap( 0, Opie::Core::OResource::loadPixmap( m_itemPixmapName, Opie::Core::OResource::SmallIcon ) );
87 } 88 }
88 } 89 }
89} 90}
90 91
91void PlayListFileView::checkSelection() 92void PlayListFileView::checkSelection()
92{ 93{
93 emit itemsSelected( hasSelection() ); 94 emit itemsSelected( hasSelection() );
94} 95}
95 96
96void PlayListFileView::fileSize(unsigned long size, QString &str) { 97void PlayListFileView::fileSize(unsigned long size, QString &str) {
97 if( size > 1048576 ) 98 if( size > 1048576 )
98 str.sprintf( "%.0fM", size / 1048576.0 ); 99 str.sprintf( "%.0fM", size / 1048576.0 );
99 else if( size > 1024 ) 100 else if( size > 1024 )
100 str.sprintf( "%.0fK", size / 1024.0 ); 101 str.sprintf( "%.0fK", size / 1024.0 );
101 else 102 else
102 str.sprintf( "%d", size ); 103 str.sprintf( "%d", size );
103} 104}
104 105
105/* vim: et sw=4 ts=4 106/* vim: et sw=4 ts=4
106 */ 107 */
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 98326a8..4178f32 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,867 +1,867 @@
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,2003 Max Reiss <harlekin@handhelds.org> 4 Copyright (c) 2002,2003 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..}^=.=       =       ; General Public License for more 22..}^=.= = ; 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  -_. . .   )=.  = General Public License along with 26 -_. . . )=. = 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 "playlistselection.h" 34#include "playlistselection.h"
35#include "playlistwidget.h" 35#include "playlistwidget.h"
36#include "mediaplayer.h" 36#include "mediaplayer.h"
37#include "inputDialog.h" 37#include "inputDialog.h"
38#include "om3u.h" 38#include "om3u.h"
39#include "playlistfileview.h" 39#include "playlistfileview.h"
40 40
41/* OPIE */ 41/* OPIE */
42#include <opie2/odebug.h> 42#include <opie2/odebug.h>
43#include <opie2/ofiledialog.h> 43#include <opie2/ofiledialog.h>
44using namespace Opie::Core; 44using namespace Opie::Core;
45using namespace Opie::Ui; 45using namespace Opie::Ui;
46 46
47/* QT */ 47/* QT */
48#include <qmessagebox.h> 48#include <qmessagebox.h>
49#include <qtoolbar.h> 49#include <qtoolbar.h>
50 50
51/* STD */ 51/* STD */
52#include <assert.h> 52#include <assert.h>
53 53
54PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) 54PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl )
55 : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 ) 55 : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 )
56{ 56{
57 Global::statusMessage( tr( "Loading of Skin started" ) ); 57 Global::statusMessage( tr( "Loading of Skin started" ) );
58 mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" ); 58 mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" );
59 m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer"); 59 m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer");
60 60
61 61
62 62
63 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), 63 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),
64 "opieplayer2/add_to_playlist", 64 "opieplayer2/add_to_playlist",
65 this , SLOT(addSelected() ) ); 65 this , SLOT(addSelected() ) );
66 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), 66 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ),
67 "opieplayer2/remove_from_playlist", 67 "opieplayer2/remove_from_playlist",
68 this , SLOT(removeSelected() ) ); 68 this , SLOT(removeSelected() ) );
69 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 69 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
70 this , SLOT( btnPlay(bool) ), TRUE ); 70 this , SLOT( btnPlay(bool) ), TRUE );
71 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 71 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
72 mediaPlayerState, SLOT( setShuffled(bool) ), TRUE ); 72 mediaPlayerState, SLOT( setShuffled(bool) ), TRUE );
73 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", 73 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop",
74 mediaPlayerState, SLOT( setLooping(bool) ), TRUE ); 74 mediaPlayerState, SLOT( setLooping(bool) ), TRUE );
75 75
76 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 76 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
77 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), 77 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ),
78 this, SLOT( addAllMusicToList() ) ); 78 this, SLOT( addAllMusicToList() ) );
79 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), 79 (void)new MenuItem( pmPlayList, tr( "Add all video files" ),
80 this, SLOT( addAllVideoToList() ) ); 80 this, SLOT( addAllVideoToList() ) );
81 (void)new MenuItem( pmPlayList, tr( "Add all files" ), 81 (void)new MenuItem( pmPlayList, tr( "Add all files" ),
82 this, SLOT( addAllToList() ) ); 82 this, SLOT( addAllToList() ) );
83 pmPlayList->insertSeparator(-1); 83 pmPlayList->insertSeparator(-1);
84 (void)new MenuItem( pmPlayList, tr( "Add File" ), 84 (void)new MenuItem( pmPlayList, tr( "Add File" ),
85 this,SLOT( openFile() ) ); 85 this,SLOT( openFile() ) );
86 (void)new MenuItem( pmPlayList, tr("Add URL"), 86 (void)new MenuItem( pmPlayList, tr("Add URL"),
87 this,SLOT( openURL() ) ); 87 this,SLOT( openURL() ) );
88 (void)new MenuItem( pmPlayList, tr( "Add Directory"), 88 (void)new MenuItem( pmPlayList, tr( "Add Directory"),
89 this, SLOT(openDirectory())); 89 this, SLOT(openDirectory()));
90 pmPlayList->insertSeparator(-1); 90 pmPlayList->insertSeparator(-1);
91 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), 91 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ),
92 this, SLOT(writem3u() ) ); 92 this, SLOT(writem3u() ) );
93 pmPlayList->insertSeparator(-1); 93 pmPlayList->insertSeparator(-1);
94 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), 94 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ),
95 audioView, SLOT( scanFiles() ) ); 95 audioView, SLOT( scanFiles() ) );
96 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), 96 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ),
97 videoView, SLOT( scanFiles() ) ); 97 videoView, SLOT( scanFiles() ) );
98 98
99 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), 99 pmView->insertItem( Opie::Core::OResource::loadPixmap("fullscreen", Opie::Core::OResource::SmallIcon) , tr( "Full Screen"),
100 mediaPlayerState, SLOT( toggleFullscreen() ) ); 100 mediaPlayerState, SLOT( toggleFullscreen() ) );
101 101
102 Config cfg( "OpiePlayer" ); 102 Config cfg( "OpiePlayer" );
103 bool b= cfg.readBoolEntry("FullScreen", 0); 103 bool b= cfg.readBoolEntry("FullScreen", 0);
104 mediaPlayerState->setFullscreen( b ); 104 mediaPlayerState->setFullscreen( b );
105 pmView->setItemChecked( -16, b ); 105 pmView->setItemChecked( -16, b );
106 106
107 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", 107 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up",
108 d->selectedFiles, SLOT(moveSelectedUp() ) ); 108 d->selectedFiles, SLOT(moveSelectedUp() ) );
109 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", 109 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut",
110 d->selectedFiles, SLOT(removeSelected() ) ); 110 d->selectedFiles, SLOT(removeSelected() ) );
111 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", 111 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down",
112 d->selectedFiles, SLOT(moveSelectedDown() ) ); 112 d->selectedFiles, SLOT(moveSelectedDown() ) );
113 QVBox *stretch2 = new QVBox( vbox1 ); 113 QVBox *stretch2 = new QVBox( vbox1 );
114 114
115 connect( tbDeletePlaylist, ( SIGNAL( released() ) ), 115 connect( tbDeletePlaylist, ( SIGNAL( released() ) ),
116 SLOT( deletePlaylist() ) ); 116 SLOT( deletePlaylist() ) );
117 connect( pmView, SIGNAL( activated(int) ), 117 connect( pmView, SIGNAL( activated(int) ),
118 this, SLOT( pmViewActivated(int) ) ); 118 this, SLOT( pmViewActivated(int) ) );
119 connect( skinsMenu, SIGNAL( activated(int) ) , 119 connect( skinsMenu, SIGNAL( activated(int) ) ,
120 this, SLOT( skinsMenuActivated(int) ) ); 120 this, SLOT( skinsMenuActivated(int) ) );
121 connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), 121 connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),
122 this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int) ) ); 122 this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int) ) );
123 connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), 123 connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),
124 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); 124 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) );
125 connect( audioView, SIGNAL( returnPressed(QListViewItem*) ), 125 connect( audioView, SIGNAL( returnPressed(QListViewItem*) ),
126 this,SLOT( playIt(QListViewItem*) ) ); 126 this,SLOT( playIt(QListViewItem*) ) );
127 connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), 127 connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ),
128 this, SLOT( addToSelection(QListViewItem*) ) ); 128 this, SLOT( addToSelection(QListViewItem*) ) );
129 connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), 129 connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),
130 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); 130 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) );
131 connect( videoView, SIGNAL( returnPressed(QListViewItem*) ), 131 connect( videoView, SIGNAL( returnPressed(QListViewItem*) ),
132 this,SLOT( playIt(QListViewItem*) ) ); 132 this,SLOT( playIt(QListViewItem*) ) );
133 connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), 133 connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ),
134 this, SLOT( addToSelection(QListViewItem*) ) ); 134 this, SLOT( addToSelection(QListViewItem*) ) );
135 connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), 135 connect( playLists, SIGNAL( fileSelected(const DocLnk&) ),
136 this, SLOT( loadList(const DocLnk&) ) ); 136 this, SLOT( loadList(const DocLnk&) ) );
137 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), 137 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ),
138 this, SLOT( tabChanged(QWidget*) ) ); 138 this, SLOT( tabChanged(QWidget*) ) );
139 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), 139 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ),
140 d->tbPlay, SLOT( setOn(bool) ) ); 140 d->tbPlay, SLOT( setOn(bool) ) );
141 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), 141 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ),
142 d->tbLoop, SLOT( setOn(bool) ) ); 142 d->tbLoop, SLOT( setOn(bool) ) );
143 connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), 143 connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ),
144 d->tbShuffle, SLOT( setOn(bool) ) ); 144 d->tbShuffle, SLOT( setOn(bool) ) );
145 connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), 145 connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ),
146 this, SLOT( playIt(QListViewItem*) ) ); 146 this, SLOT( playIt(QListViewItem*) ) );
147 connect ( gammaSlider, SIGNAL( valueChanged(int) ), 147 connect ( gammaSlider, SIGNAL( valueChanged(int) ),
148 mediaPlayerState, SLOT( setVideoGamma(int) ) ); 148 mediaPlayerState, SLOT( setVideoGamma(int) ) );
149 149
150 connect( this, SIGNAL(skinSelected() ), 150 connect( this, SIGNAL(skinSelected() ),
151 m_mp, SLOT( reloadSkins() ) ); 151 m_mp, SLOT( reloadSkins() ) );
152 152
153 // see which skins are installed 153 // see which skins are installed
154 populateSkinsMenu(); 154 populateSkinsMenu();
155 initializeStates(); 155 initializeStates();
156 156
157 channel = new QCopChannel( "QPE/Application/opieplayer2", this ); 157 channel = new QCopChannel( "QPE/Application/opieplayer2", this );
158 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), 158 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
159 this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); 159 this, SLOT( qcopReceive(const QCString&,const QByteArray&)) );
160 160
161 161
162 cfg.setGroup("PlayList"); 162 cfg.setGroup("PlayList");
163 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 163 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
164 loadList(DocLnk( currentPlaylist ) ); 164 loadList(DocLnk( currentPlaylist ) );
165 165
166 tabWidget->showPage( playListTab ); 166 tabWidget->showPage( playListTab );
167} 167}
168 168
169 169
170PlayListWidget::~PlayListWidget() { 170PlayListWidget::~PlayListWidget() {
171 delete d; 171 delete d;
172 delete m_mp; 172 delete m_mp;
173} 173}
174 174
175 175
176void PlayListWidget::initializeStates() { 176void PlayListWidget::initializeStates() {
177 d->tbPlay->setOn( mediaPlayerState->isPlaying() ); 177 d->tbPlay->setOn( mediaPlayerState->isPlaying() );
178 d->tbLoop->setOn( mediaPlayerState->isLooping() ); 178 d->tbLoop->setOn( mediaPlayerState->isLooping() );
179 d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); 179 d->tbShuffle->setOn( mediaPlayerState->isShuffled() );
180 d->playListFrame->show(); 180 d->playListFrame->show();
181} 181}
182 182
183void PlayListWidget::setButtons(void) { 183void PlayListWidget::setButtons(void) {
184 bool hasitem; 184 bool hasitem;
185 185
186 switch ( currentTab() ) { 186 switch ( currentTab() ) {
187 case CurrentPlayList: 187 case CurrentPlayList:
188 { 188 {
189 hasitem = !d->selectedFiles->isEmpty(); 189 hasitem = !d->selectedFiles->isEmpty();
190 d->tbPlay->setEnabled( hasitem ); 190 d->tbPlay->setEnabled( hasitem );
191 d->tbRemoveFromList->setEnabled( hasitem ); 191 d->tbRemoveFromList->setEnabled( hasitem );
192 } 192 }
193 break; 193 break;
194 case AudioFiles: 194 case AudioFiles:
195 { 195 {
196 d->tbPlay->setEnabled( audioView->hasSelection() ); 196 d->tbPlay->setEnabled( audioView->hasSelection() );
197 d->tbRemoveFromList->setEnabled( false ); 197 d->tbRemoveFromList->setEnabled( false );
198 } 198 }
199 break; 199 break;
200 case VideoFiles: 200 case VideoFiles:
201 { 201 {
202 d->tbPlay->setEnabled( videoView->hasSelection() ); 202 d->tbPlay->setEnabled( videoView->hasSelection() );
203 d->tbRemoveFromList->setEnabled( false ); 203 d->tbRemoveFromList->setEnabled( false );
204 } 204 }
205 break; 205 break;
206 case PlayLists: 206 case PlayLists:
207 { 207 {
208 d->tbPlay->setEnabled( false ); 208 d->tbPlay->setEnabled( false );
209 d->tbRemoveFromList->setEnabled( false ); 209 d->tbRemoveFromList->setEnabled( false );
210 } 210 }
211 break; 211 break;
212 }; 212 };
213} 213}
214 214
215void PlayListWidget::writeDefaultPlaylist() { 215void PlayListWidget::writeDefaultPlaylist() {
216 216
217 Config config( "OpiePlayer" ); 217 Config config( "OpiePlayer" );
218 config.setGroup( "PlayList" ); 218 config.setGroup( "PlayList" );
219 QString filename=QPEApplication::documentDir() + "/default.m3u"; 219 QString filename=QPEApplication::documentDir() + "/default.m3u";
220 QString currentString = config.readEntry( "CurrentPlaylist", filename); 220 QString currentString = config.readEntry( "CurrentPlaylist", filename);
221 if( currentString == filename) { 221 if( currentString == filename) {
222 Om3u *m3uList; 222 Om3u *m3uList;
223 if( d->selectedFiles->first() ) { 223 if( d->selectedFiles->first() ) {
224 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); 224 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
225 do { 225 do {
226 m3uList->add( d->selectedFiles->current()->file() ); 226 m3uList->add( d->selectedFiles->current()->file() );
227 } 227 }
228 while ( d->selectedFiles->next() ); 228 while ( d->selectedFiles->next() );
229 229
230 m3uList->write(); 230 m3uList->write();
231 m3uList->close(); 231 m3uList->close();
232 delete m3uList; 232 delete m3uList;
233 233
234 } 234 }
235 } 235 }
236} 236}
237 237
238void PlayListWidget::addToSelection( const DocLnk& lnk ) { 238void PlayListWidget::addToSelection( const DocLnk& lnk ) {
239 d->setDocumentUsed = FALSE; 239 d->setDocumentUsed = FALSE;
240 if( QFileInfo( lnk.file() ).exists() || 240 if( QFileInfo( lnk.file() ).exists() ||
241 lnk.file().left(4) == "http" ) { 241 lnk.file().left(4) == "http" ) {
242 d->selectedFiles->addToSelection( lnk ); 242 d->selectedFiles->addToSelection( lnk );
243 } 243 }
244} 244}
245 245
246 246
247void PlayListWidget::clearList() { 247void PlayListWidget::clearList() {
248 while ( first() ) { 248 while ( first() ) {
249 d->selectedFiles->removeSelected(); 249 d->selectedFiles->removeSelected();
250 } 250 }
251 Config cfg( "OpiePlayer" ); 251 Config cfg( "OpiePlayer" );
252 cfg.setGroup("PlayList"); 252 cfg.setGroup("PlayList");
253 cfg.writeEntry("CurrentPlaylist","default"); 253 cfg.writeEntry("CurrentPlaylist","default");
254 setCaption("OpiePlayer"); 254 setCaption("OpiePlayer");
255 setButtons(); 255 setButtons();
256} 256}
257 257
258void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 258void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
259 switch (mouse) { 259 switch (mouse) {
260 case LeftButton: 260 case LeftButton:
261 break; 261 break;
262 case RightButton: 262 case RightButton:
263 { 263 {
264 QPopupMenu m; 264 QPopupMenu m;
265 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 265 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
266 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 266 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
267 m.exec( QCursor::pos() ); 267 m.exec( QCursor::pos() );
268 } 268 }
269 break; 269 break;
270 } 270 }
271} 271}
272 272
273 273
274void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { 274void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
275 switch (mouse) { 275 switch (mouse) {
276 case LeftButton: 276 case LeftButton:
277 break; 277 break;
278 case RightButton: 278 case RightButton:
279 { 279 {
280 QPopupMenu m; 280 QPopupMenu m;
281 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 281 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
282 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 282 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
283 m.exec( QCursor::pos() ); 283 m.exec( QCursor::pos() );
284 } 284 }
285 break; 285 break;
286 } 286 }
287} 287}
288 288
289 289
290void PlayListWidget::addAllToList() { 290void PlayListWidget::addAllToList() {
291 291
292 292
293 audioView->populateView(); 293 audioView->populateView();
294 294
295 QListViewItemIterator audioIt( audioView ); 295 QListViewItemIterator audioIt( audioView );
296 DocLnk lnk; 296 DocLnk lnk;
297 QString filename; 297 QString filename;
298 // iterate through all items of the listview 298 // iterate through all items of the listview
299 for ( ; audioIt.current(); ++audioIt ) { 299 for ( ; audioIt.current(); ++audioIt ) {
300 filename = audioIt.current()->text(3); 300 filename = audioIt.current()->text(3);
301 lnk.setName( QFileInfo(filename).baseName() ); //sets name 301 lnk.setName( QFileInfo(filename).baseName() ); //sets name
302 lnk.setFile( filename ); //sets file name 302 lnk.setFile( filename ); //sets file name
303 d->selectedFiles->addToSelection( lnk); 303 d->selectedFiles->addToSelection( lnk);
304 } 304 }
305 305
306 videoView->populateView(); 306 videoView->populateView();
307 307
308 QListViewItemIterator videoIt( videoView ); 308 QListViewItemIterator videoIt( videoView );
309 for ( ; videoIt.current(); ++videoIt ) { 309 for ( ; videoIt.current(); ++videoIt ) {
310 filename = videoIt.current()->text(3); 310 filename = videoIt.current()->text(3);
311 lnk.setName( QFileInfo(filename).baseName() ); //sets name 311 lnk.setName( QFileInfo(filename).baseName() ); //sets name
312 lnk.setFile( filename ); //sets file name 312 lnk.setFile( filename ); //sets file name
313 d->selectedFiles->addToSelection( lnk); 313 d->selectedFiles->addToSelection( lnk);
314 } 314 }
315 315
316 tabWidget->setCurrentPage(0); 316 tabWidget->setCurrentPage(0);
317 317
318 writeCurrentM3u(); 318 writeCurrentM3u();
319 d->selectedFiles->first(); 319 d->selectedFiles->first();
320 320
321 setButtons(); 321 setButtons();
322} 322}
323 323
324 324
325void PlayListWidget::addAllMusicToList() { 325void PlayListWidget::addAllMusicToList() {
326 326
327 audioView->populateView(); 327 audioView->populateView();
328 328
329 QListViewItemIterator audioIt( audioView ); 329 QListViewItemIterator audioIt( audioView );
330 DocLnk lnk; 330 DocLnk lnk;
331 QString filename; 331 QString filename;
332 // iterate through all items of the listview 332 // iterate through all items of the listview
333 for ( ; audioIt.current(); ++audioIt ) { 333 for ( ; audioIt.current(); ++audioIt ) {
334 filename = audioIt.current()->text(3); 334 filename = audioIt.current()->text(3);
335 lnk.setName( QFileInfo(filename).baseName() ); //sets name 335 lnk.setName( QFileInfo(filename).baseName() ); //sets name
336 lnk.setFile( filename ); //sets file name 336 lnk.setFile( filename ); //sets file name
337 d->selectedFiles->addToSelection( lnk); 337 d->selectedFiles->addToSelection( lnk);
338 } 338 }
339 339
340 tabWidget->setCurrentPage(0); 340 tabWidget->setCurrentPage(0);
341 writeCurrentM3u(); 341 writeCurrentM3u();
342 d->selectedFiles->first(); 342 d->selectedFiles->first();
343 343
344 setButtons(); 344 setButtons();
345} 345}
346 346
347 347
348void PlayListWidget::addAllVideoToList() { 348void PlayListWidget::addAllVideoToList() {
349 349
350 videoView->populateView(); 350 videoView->populateView();
351 351
352 QListViewItemIterator videoIt( videoView ); 352 QListViewItemIterator videoIt( videoView );
353 DocLnk lnk; 353 DocLnk lnk;
354 QString filename; 354 QString filename;
355 for ( ; videoIt.current(); ++videoIt ) { 355 for ( ; videoIt.current(); ++videoIt ) {
356 filename = videoIt.current()->text(3); 356 filename = videoIt.current()->text(3);
357 lnk.setName( QFileInfo(filename).baseName() ); //sets name 357 lnk.setName( QFileInfo(filename).baseName() ); //sets name
358 lnk.setFile( filename ); //sets file name 358 lnk.setFile( filename ); //sets file name
359 d->selectedFiles->addToSelection( lnk); 359 d->selectedFiles->addToSelection( lnk);
360 } 360 }
361 tabWidget->setCurrentPage(0); 361 tabWidget->setCurrentPage(0);
362 writeCurrentM3u(); 362 writeCurrentM3u();
363 d->selectedFiles->first(); 363 d->selectedFiles->first();
364 364
365 setButtons(); 365 setButtons();
366} 366}
367 367
368 368
369void PlayListWidget::setDocument( const QString& _fileref ) { 369void PlayListWidget::setDocument( const QString& _fileref ) {
370 // odebug << "<<<<<<<<set document>>>>>>>>>> "+fileref << oendl; 370 // odebug << "<<<<<<<<set document>>>>>>>>>> "+fileref << oendl;
371 QString fileref = _fileref; 371 QString fileref = _fileref;
372 fromSetDocument = TRUE; 372 fromSetDocument = TRUE;
373 373
374 DocLnk lnk(_fileref); 374 DocLnk lnk(_fileref);
375 if(lnk.isValid()) 375 if(lnk.isValid())
376 fileref = lnk.file(); 376 fileref = lnk.file();
377 377
378 QFileInfo fileInfo(fileref); 378 QFileInfo fileInfo(fileref);
379 379
380 if ( !fileInfo.exists() ) { 380 if ( !fileInfo.exists() ) {
381 QMessageBox::warning( this, tr( "Invalid File" ), 381 QMessageBox::warning( this, tr( "Invalid File" ),
382 tr( "There was a problem in getting the file." ) ); 382 tr( "There was a problem in getting the file." ) );
383 return; 383 return;
384 } 384 }
385 385
386 clearList(); 386 clearList();
387 QString extension = fileInfo.extension(false); 387 QString extension = fileInfo.extension(false);
388 388
389 if( extension.find( "m3u", 0, false) != -1 389 if( extension.find( "m3u", 0, false) != -1
390 || extension.find( "pls", 0, false) != -1 ) { 390 || extension.find( "pls", 0, false) != -1 ) {
391 readListFromFile( fileref ); 391 readListFromFile( fileref );
392 } else { 392 } else {
393 clearList(); 393 clearList();
394 DocLnk lnk; 394 DocLnk lnk;
395 lnk.setName( fileInfo.baseName() ); //sets name 395 lnk.setName( fileInfo.baseName() ); //sets name
396 lnk.setFile( fileref ); //sets file name 396 lnk.setFile( fileref ); //sets file name
397 addToSelection( lnk ); 397 addToSelection( lnk );
398 writeCurrentM3u(); 398 writeCurrentM3u();
399 399
400 d->setDocumentUsed = TRUE; 400 d->setDocumentUsed = TRUE;
401 mediaPlayerState->setPlaying( FALSE ); 401 mediaPlayerState->setPlaying( FALSE );
402 mediaPlayerState->setPlaying( TRUE ); 402 mediaPlayerState->setPlaying( TRUE );
403 } 403 }
404} 404}
405 405
406 406
407void PlayListWidget::useSelectedDocument() { 407void PlayListWidget::useSelectedDocument() {
408 d->setDocumentUsed = FALSE; 408 d->setDocumentUsed = FALSE;
409} 409}
410 410
411 411
412const DocLnk *PlayListWidget::current() const { // this is fugly 412const DocLnk *PlayListWidget::current() const { // this is fugly
413 assert( currentTab() == CurrentPlayList ); 413 assert( currentTab() == CurrentPlayList );
414 414
415 const DocLnk *lnk = d->selectedFiles->current(); 415 const DocLnk *lnk = d->selectedFiles->current();
416 if ( !lnk ) { 416 if ( !lnk ) {
417 d->selectedFiles->first(); 417 d->selectedFiles->first();
418 lnk = d->selectedFiles->current(); 418 lnk = d->selectedFiles->current();
419 } 419 }
420 assert( lnk ); 420 assert( lnk );
421 return lnk; 421 return lnk;
422} 422}
423 423
424 424
425bool PlayListWidget::prev() { 425bool PlayListWidget::prev() {
426 if ( mediaPlayerState->isShuffled() ) { 426 if ( mediaPlayerState->isShuffled() ) {
427 const DocLnk *cur = current(); 427 const DocLnk *cur = current();
428 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 428 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
429 for ( int i = 0; i < j; i++ ) { 429 for ( int i = 0; i < j; i++ ) {
430 if ( !d->selectedFiles->next() ) 430 if ( !d->selectedFiles->next() )
431 d->selectedFiles->first(); 431 d->selectedFiles->first();
432 } 432 }
433 if ( cur == current() ) 433 if ( cur == current() )
434 if ( !d->selectedFiles->next() ) { 434 if ( !d->selectedFiles->next() ) {
435 d->selectedFiles->first(); 435 d->selectedFiles->first();
436 } 436 }
437 return TRUE; 437 return TRUE;
438 } else { 438 } else {
439 if ( !d->selectedFiles->prev() ) { 439 if ( !d->selectedFiles->prev() ) {
440 if ( mediaPlayerState->isLooping() ) { 440 if ( mediaPlayerState->isLooping() ) {
441 return d->selectedFiles->last(); 441 return d->selectedFiles->last();
442 } else { 442 } else {
443 return FALSE; 443 return FALSE;
444 } 444 }
445 } 445 }
446 return TRUE; 446 return TRUE;
447 } 447 }
448} 448}
449 449
450 450
451bool PlayListWidget::next() { 451bool PlayListWidget::next() {
452//odebug << "<<<<<<<<<<<<next()" << oendl; 452//odebug << "<<<<<<<<<<<<next()" << oendl;
453 if ( mediaPlayerState->isShuffled() ) { 453 if ( mediaPlayerState->isShuffled() ) {
454 return prev(); 454 return prev();
455 } else { 455 } else {
456 if ( !d->selectedFiles->next() ) { 456 if ( !d->selectedFiles->next() ) {
457 if ( mediaPlayerState->isLooping() ) { 457 if ( mediaPlayerState->isLooping() ) {
458 return d->selectedFiles->first(); 458 return d->selectedFiles->first();
459 } else { 459 } else {
460 return FALSE; 460 return FALSE;
461 } 461 }
462 } 462 }
463 return TRUE; 463 return TRUE;
464 } 464 }
465} 465}
466 466
467 467
468bool PlayListWidget::first() { 468bool PlayListWidget::first() {
469 return d->selectedFiles->first(); 469 return d->selectedFiles->first();
470} 470}
471 471
472 472
473bool PlayListWidget::last() { 473bool PlayListWidget::last() {
474 return d->selectedFiles->last(); 474 return d->selectedFiles->last();
475} 475}
476 476
477 477
478 void PlayListWidget::saveList() { 478 void PlayListWidget::saveList() {
479 writem3u(); 479 writem3u();
480 } 480 }
481 481
482 482
483void PlayListWidget::loadList( const DocLnk & lnk) { 483void PlayListWidget::loadList( const DocLnk & lnk) {
484 QString name = lnk.name(); 484 QString name = lnk.name();
485 485
486 if( name.length()>0) { 486 if( name.length()>0) {
487 setCaption("OpiePlayer: "+name); 487 setCaption("OpiePlayer: "+name);
488 clearList(); 488 clearList();
489 readListFromFile(lnk.file()); 489 readListFromFile(lnk.file());
490 tabWidget->setCurrentPage(0); 490 tabWidget->setCurrentPage(0);
491 } 491 }
492} 492}
493 493
494void PlayListWidget::addSelected() { 494void PlayListWidget::addSelected() {
495 assert( inFileListMode() ); 495 assert( inFileListMode() );
496 496
497 QListViewItemIterator it( currentFileListView ); 497 QListViewItemIterator it( currentFileListView );
498 for ( ; it.current(); ++it ) 498 for ( ; it.current(); ++it )
499 if ( it.current()->isSelected() ) { 499 if ( it.current()->isSelected() ) {
500 QString filename = it.current()->text(3); 500 QString filename = it.current()->text(3);
501 501
502 DocLnk lnk; 502 DocLnk lnk;
503 lnk.setName( QFileInfo( filename ).baseName() ); //sets name 503 lnk.setName( QFileInfo( filename ).baseName() ); //sets name
504 lnk.setFile( filename ); //sets file name 504 lnk.setFile( filename ); //sets file name
505 505
506 d->selectedFiles->addToSelection( lnk ); 506 d->selectedFiles->addToSelection( lnk );
507 } 507 }
508 508
509 currentFileListView->clearSelection(); 509 currentFileListView->clearSelection();
510 510
511 writeCurrentM3u(); 511 writeCurrentM3u();
512} 512}
513 513
514 514
515void PlayListWidget::removeSelected() { 515void PlayListWidget::removeSelected() {
516 d->selectedFiles->removeSelected( ); 516 d->selectedFiles->removeSelected( );
517 writeCurrentM3u(); 517 writeCurrentM3u();
518 setButtons(); 518 setButtons();
519} 519}
520 520
521 521
522void PlayListWidget::playIt( QListViewItem *it) { 522void PlayListWidget::playIt( QListViewItem *it) {
523 if(!it) return; 523 if(!it) return;
524 mediaPlayerState->setPlaying(FALSE); 524 mediaPlayerState->setPlaying(FALSE);
525 mediaPlayerState->setPlaying(TRUE); 525 mediaPlayerState->setPlaying(TRUE);
526 d->selectedFiles->unSelect(); 526 d->selectedFiles->unSelect();
527} 527}
528 528
529 529
530void PlayListWidget::addToSelection( QListViewItem *it) { 530void PlayListWidget::addToSelection( QListViewItem *it) {
531 d->setDocumentUsed = FALSE; 531 d->setDocumentUsed = FALSE;
532 532
533 if(it) { 533 if(it) {
534 if ( currentTab() == CurrentPlayList ) 534 if ( currentTab() == CurrentPlayList )
535 return; 535 return;
536 DocLnk lnk; 536 DocLnk lnk;
537 QString filename; 537 QString filename;
538 538
539 filename=it->text(3); 539 filename=it->text(3);
540 lnk.setName( QFileInfo(filename).baseName() ); //sets name 540 lnk.setName( QFileInfo(filename).baseName() ); //sets name
541 lnk.setFile( filename ); //sets file name 541 lnk.setFile( filename ); //sets file name
542 d->selectedFiles->addToSelection( lnk); 542 d->selectedFiles->addToSelection( lnk);
543 543
544 writeCurrentM3u(); 544 writeCurrentM3u();
545// tabWidget->setCurrentPage(0); 545// tabWidget->setCurrentPage(0);
546 546
547 } 547 }
548} 548}
549 549
550 550
551void PlayListWidget::tabChanged(QWidget *) { 551void PlayListWidget::tabChanged(QWidget *) {
552 552
553 disconnect( audioView, SIGNAL( itemsSelected(bool) ), 553 disconnect( audioView, SIGNAL( itemsSelected(bool) ),
554 d->tbPlay, SLOT( setEnabled(bool) ) ); 554 d->tbPlay, SLOT( setEnabled(bool) ) );
555 disconnect( videoView, SIGNAL( itemsSelected(bool) ), 555 disconnect( videoView, SIGNAL( itemsSelected(bool) ),
556 d->tbPlay, SLOT( setEnabled(bool) ) ); 556 d->tbPlay, SLOT( setEnabled(bool) ) );
557 557
558 currentFileListView = 0; 558 currentFileListView = 0;
559 559
560 switch ( currentTab() ) { 560 switch ( currentTab() ) {
561 case CurrentPlayList: 561 case CurrentPlayList:
562 { 562 {
563 if( !tbDeletePlaylist->isHidden() ) { 563 if( !tbDeletePlaylist->isHidden() ) {
564 tbDeletePlaylist->hide(); 564 tbDeletePlaylist->hide();
565 } 565 }
566 d->tbAddToList->setEnabled(FALSE); 566 d->tbAddToList->setEnabled(FALSE);
567 567
568 } 568 }
569 break; 569 break;
570 case AudioFiles: 570 case AudioFiles:
571 { 571 {
572 audioView->populateView(); 572 audioView->populateView();
573 573
574 if( !tbDeletePlaylist->isHidden() ) { 574 if( !tbDeletePlaylist->isHidden() ) {
575 tbDeletePlaylist->hide(); 575 tbDeletePlaylist->hide();
576 } 576 }
577 d->tbAddToList->setEnabled(TRUE); 577 d->tbAddToList->setEnabled(TRUE);
578 578
579 connect( audioView, SIGNAL( itemsSelected(bool) ), 579 connect( audioView, SIGNAL( itemsSelected(bool) ),
580 d->tbPlay, SLOT( setEnabled(bool) ) ); 580 d->tbPlay, SLOT( setEnabled(bool) ) );
581 581
582 currentFileListView = audioView; 582 currentFileListView = audioView;
583 } 583 }
584 break; 584 break;
585 case VideoFiles: 585 case VideoFiles:
586 { 586 {
587 videoView->populateView(); 587 videoView->populateView();
588 if( !tbDeletePlaylist->isHidden() ) { 588 if( !tbDeletePlaylist->isHidden() ) {
589 tbDeletePlaylist->hide(); 589 tbDeletePlaylist->hide();
590 } 590 }
591 d->tbAddToList->setEnabled(TRUE); 591 d->tbAddToList->setEnabled(TRUE);
592 592
593 connect( videoView, SIGNAL( itemsSelected(bool) ), 593 connect( videoView, SIGNAL( itemsSelected(bool) ),
594 d->tbPlay, SLOT( setEnabled(bool) ) ); 594 d->tbPlay, SLOT( setEnabled(bool) ) );
595 595
596 currentFileListView = videoView; 596 currentFileListView = videoView;
597 } 597 }
598 break; 598 break;
599 case PlayLists: 599 case PlayLists:
600 { 600 {
601 if( tbDeletePlaylist->isHidden() ) { 601 if( tbDeletePlaylist->isHidden() ) {
602 tbDeletePlaylist->show(); 602 tbDeletePlaylist->show();
603 } 603 }
604 playLists->reread(); 604 playLists->reread();
605 d->tbAddToList->setEnabled(FALSE); 605 d->tbAddToList->setEnabled(FALSE);
606 606
607 } 607 }
608 break; 608 break;
609 }; 609 };
610 610
611 setButtons(); 611 setButtons();
612} 612}
613 613
614 614
615void PlayListWidget::btnPlay(bool b) { 615void PlayListWidget::btnPlay(bool b) {
616// mediaPlayerState->setPlaying(false); 616// mediaPlayerState->setPlaying(false);
617 mediaPlayerState->setPlaying(b); 617 mediaPlayerState->setPlaying(b);
618 insanityBool=FALSE; 618 insanityBool=FALSE;
619} 619}
620 620
621void PlayListWidget::deletePlaylist() { 621void PlayListWidget::deletePlaylist() {
622 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 622 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
623 (tr("You really want to delete\nthis playlist?")), 623 (tr("You really want to delete\nthis playlist?")),
624 (tr("Yes")), (tr("No")), 0 )){ 624 (tr("Yes")), (tr("No")), 0 )){
625 case 0: // Yes clicked, 625 case 0: // Yes clicked,
626 QFile().remove(playLists->selectedDocument().file()); 626 QFile().remove(playLists->selectedDocument().file());
627 QFile().remove(playLists->selectedDocument().linkFile()); 627 QFile().remove(playLists->selectedDocument().linkFile());
628 playLists->reread(); 628 playLists->reread();
629 break; 629 break;
630 case 1: // Cancel 630 case 1: // Cancel
631 break; 631 break;
632 }; 632 };
633} 633}
634 634
635 635
636void PlayListWidget::playSelected() { 636void PlayListWidget::playSelected() {
637 btnPlay( TRUE); 637 btnPlay( TRUE);
638} 638}
639 639
640bool PlayListWidget::inFileListMode() const 640bool PlayListWidget::inFileListMode() const
641{ 641{
642 TabType tab = currentTab(); 642 TabType tab = currentTab();
643 return tab == AudioFiles || tab == VideoFiles; 643 return tab == AudioFiles || tab == VideoFiles;
644} 644}
645 645
646void PlayListWidget::openURL() { 646void PlayListWidget::openURL() {
647 // http://66.28.164.33:2080 647 // http://66.28.164.33:2080
648 // http://somafm.com/star0242.m3u 648 // http://somafm.com/star0242.m3u
649 QString filename, name; 649 QString filename, name;
650 InputDialog *fileDlg; 650 InputDialog *fileDlg;
651 fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); 651 fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0);
652 fileDlg->exec(); 652 fileDlg->exec();
653 if( fileDlg->result() == 1 ) { 653 if( fileDlg->result() == 1 ) {
654 filename = fileDlg->text(); 654 filename = fileDlg->text();
655 odebug << "Selected filename is " + filename << oendl; 655 odebug << "Selected filename is " + filename << oendl;
656 // Om3u *m3uList; 656 // Om3u *m3uList;
657 DocLnk lnk; 657 DocLnk lnk;
658 Config cfg( "OpiePlayer" ); 658 Config cfg( "OpiePlayer" );
659 cfg.setGroup("PlayList"); 659 cfg.setGroup("PlayList");
660 660
661 if(filename.left(4) == "http") { 661 if(filename.left(4) == "http") {
662 QString m3uFile, m3uFilePath; 662 QString m3uFile, m3uFilePath;
663 if(filename.find(":",8,TRUE) != -1) { //found a port 663 if(filename.find(":",8,TRUE) != -1) { //found a port
664 m3uFile = filename.left( filename.find( ":",8,TRUE)); 664 m3uFile = filename.left( filename.find( ":",8,TRUE));
665 m3uFile = m3uFile.right( 7); 665 m3uFile = m3uFile.right( 7);
666 } else if(filename.left(4) == "http"){ 666 } else if(filename.left(4) == "http"){
667 m3uFile=filename; 667 m3uFile=filename;
668 m3uFile = m3uFile.right( m3uFile.length() - 7); 668 m3uFile = m3uFile.right( m3uFile.length() - 7);
669 } else{ 669 } else{
670 m3uFile=filename; 670 m3uFile=filename;
671 } 671 }
672 672
673 lnk.setName( filename ); //sets name 673 lnk.setName( filename ); //sets name
674 lnk.setFile( filename ); //sets file name 674 lnk.setFile( filename ); //sets file name
675 675
676// lnk.setIcon("opieplayer2/musicfile"); 676// lnk.setIcon("opieplayer2/musicfile");
677 677
678 d->selectedFiles->addToSelection( lnk ); 678 d->selectedFiles->addToSelection( lnk );
679 writeCurrentM3u(); 679 writeCurrentM3u();
680 d->selectedFiles->setSelectedItem( lnk.name()); 680 d->selectedFiles->setSelectedItem( lnk.name());
681 } 681 }
682 else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { 682 else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) {
683 readListFromFile( filename ); 683 readListFromFile( filename );
684 } else { 684 } else {
685 lnk.setName( QFileInfo(filename).baseName() ); //sets name 685 lnk.setName( QFileInfo(filename).baseName() ); //sets name
686 lnk.setFile( filename ); //sets file name 686 lnk.setFile( filename ); //sets file name
687 d->selectedFiles->addToSelection( lnk); 687 d->selectedFiles->addToSelection( lnk);
688 writeCurrentM3u(); 688 writeCurrentM3u();
689 d->selectedFiles->setSelectedItem( lnk.name()); 689 d->selectedFiles->setSelectedItem( lnk.name());
690 } 690 }
691 } 691 }
692 692
693 693
694 delete fileDlg; 694 delete fileDlg;
695} 695}
696 696
697 697
698static MimeTypes fileSelectorMimeTypes() { 698static MimeTypes fileSelectorMimeTypes() {
699 MimeTypes types; 699 MimeTypes types;
700 QStringList audio, video, all; 700 QStringList audio, video, all;
701 audio << "audio/*"; 701 audio << "audio/*";
702 audio << "playlist/plain"; 702 audio << "playlist/plain";
703 audio << "audio/x-ogg"; 703 audio << "audio/x-ogg";
704 audio << "audio/x-mpegurl"; 704 audio << "audio/x-mpegurl";
705 705
706 video << "video/*"; 706 video << "video/*";
707 video << "playlist/plain"; 707 video << "playlist/plain";
708 708
709 all += audio; 709 all += audio;
710 all += video; 710 all += video;
711 types.insert("All Media Files", all ); 711 types.insert("All Media Files", all );
712 types.insert("Audio", audio ); 712 types.insert("Audio", audio );
713 types.insert("Video", video ); 713 types.insert("Video", video );
714 714
715 return types; 715 return types;
716} 716}
717 717
718void PlayListWidget::openFile() { 718void PlayListWidget::openFile() {
719 719
720 QString filename, name; 720 QString filename, name;
721 721
722 Config cfg( "OpiePlayer" ); 722 Config cfg( "OpiePlayer" );
723 cfg.setGroup("Dialog"); 723 cfg.setGroup("Dialog");
724 MimeTypes types = fileSelectorMimeTypes(); 724 MimeTypes types = fileSelectorMimeTypes();
725 725
726 726
727 QString str = OFileDialog::getOpenFileName( 1, QString::null, 727 QString str = OFileDialog::getOpenFileName( 1, QString::null,
728 QString::null, types, 0, 728 QString::null, types, 0,
729 tr("Add File to Playlist") ); 729 tr("Add File to Playlist") );
730 730
731 if( str.isEmpty() ) 731 if( str.isEmpty() )
732 return; 732 return;
733 733
734 if(str.left(2) == "//") str=str.right(str.length()-1); 734 if(str.left(2) == "//") str=str.right(str.length()-1);
735 735
736 736
737 if( str.right( 3) == "m3u" || str.right(3) == "pls" ) { 737 if( str.right( 3) == "m3u" || str.right(3) == "pls" ) {
738 readListFromFile( str ); 738 readListFromFile( str );
739 } else { 739 } else {
740 QFileInfo info( str ); 740 QFileInfo info( str );
741 DocLnk lnk = addFileToPlaylist( str, info.baseName() ); 741 DocLnk lnk = addFileToPlaylist( str, info.baseName() );
742 d->selectedFiles->setSelectedItem( lnk.name() ); 742 d->selectedFiles->setSelectedItem( lnk.name() );
743 } 743 }
744 744
745 setButtons(); 745 setButtons();
746} 746}
747 747
748void PlayListWidget::openDirectory() { 748void PlayListWidget::openDirectory() {
749 QString str = OFileDialog::getDirectory( OFileSelector::DirectorySelector, 749 QString str = OFileDialog::getDirectory( OFileSelector::DirectorySelector,
750 QString::null, 0, 750 QString::null, 0,
751 tr( "Add Files from Directory")); 751 tr( "Add Files from Directory"));
752 752
753 if(str.isEmpty() ) 753 if(str.isEmpty() )
754 return; 754 return;
755 755
756 if(str.left(2) == "//") str=str.right(str.length()-1); 756 if(str.left(2) == "//") str=str.right(str.length()-1);
757 QDir dir( str ); 757 QDir dir( str );
758 QStringList lst = dir.entryList(QDir::Files|QDir::Readable); 758 QStringList lst = dir.entryList(QDir::Files|QDir::Readable);
759 759
760 for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { 760 for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) {
761 QString filename = str + "/" + *it; 761 QString filename = str + "/" + *it;
762 762
763 if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) 763 if( filename.right( 3) == "m3u" || filename.right(3) == "pls" )
764 readListFromFile( filename ); 764 readListFromFile( filename );
765 else { 765 else {
766 addFileToPlaylist( filename, QFileInfo(*it).baseName() ); 766 addFileToPlaylist( filename, QFileInfo(*it).baseName() );
767 } 767 }
768 } 768 }
769 769
770 if (!d->selectedFiles->isEmpty()) { 770 if (!d->selectedFiles->isEmpty()) {
771 d->selectedFiles->first(); 771 d->selectedFiles->first();
772 772
773 setButtons(); 773 setButtons();
774 } 774 }
775} 775}
776 776
777void PlayListWidget::readListFromFile( const QString &filename ) { 777void PlayListWidget::readListFromFile( const QString &filename ) {
778 odebug << "read list filename " + filename << oendl; 778 odebug << "read list filename " + filename << oendl;
779 QFileInfo fi(filename); 779 QFileInfo fi(filename);
780 Om3u *m3uList; 780 Om3u *m3uList;
781 QString s, name; 781 QString s, name;
782 m3uList = new Om3u( filename, IO_ReadOnly ); 782 m3uList = new Om3u( filename, IO_ReadOnly );
783 if(fi.extension(false).find("m3u",0,false) != -1 ) 783 if(fi.extension(false).find("m3u",0,false) != -1 )
784 m3uList->readM3u(); 784 m3uList->readM3u();
785 else if(fi.extension(false).find("pls",0,false) != -1 ) 785 else if(fi.extension(false).find("pls",0,false) != -1 )
786 m3uList->readPls(); 786 m3uList->readPls();
787 787
788 DocLnk lnk; 788 DocLnk lnk;
789 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 789 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
790 s = *it; 790 s = *it;
791 // odebug << s << oendl; 791 // odebug << s << oendl;
792 if(s.left(4)=="http") { 792 if(s.left(4)=="http") {
793 lnk.setName( s ); //sets file name 793 lnk.setName( s ); //sets file name
794 lnk.setIcon("opieplayer2/musicfile"); 794 lnk.setIcon("opieplayer2/musicfile");
795 lnk.setFile( s ); //sets file name 795 lnk.setFile( s ); //sets file name
796 796
797 } else { //is file 797 } else { //is file
798 lnk.setName( QFileInfo(s).baseName()); 798 lnk.setName( QFileInfo(s).baseName());
799 if(s.left(1) != "/") { 799 if(s.left(1) != "/") {
800 800
801 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 801 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
802 } else { 802 } else {
803 lnk.setFile( s); 803 lnk.setFile( s);
804 } 804 }
805 } 805 }
806 d->selectedFiles->addToSelection( lnk ); 806 d->selectedFiles->addToSelection( lnk );
807 } 807 }
808 Config config( "OpiePlayer" ); 808 Config config( "OpiePlayer" );
809 config.setGroup( "PlayList" ); 809 config.setGroup( "PlayList" );
810 810
811 config.writeEntry("CurrentPlaylist",filename); 811 config.writeEntry("CurrentPlaylist",filename);
812 config.write(); 812 config.write();
813 currentPlayList=filename; 813 currentPlayList=filename;
814 814
815 m3uList->close(); 815 m3uList->close();
816 delete m3uList; 816 delete m3uList;
817 817
818 d->selectedFiles->setSelectedItem( s); 818 d->selectedFiles->setSelectedItem( s);
819 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); 819 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
820 820
821 setButtons(); 821 setButtons();
822} 822}
823 823
824// writes current playlist to current m3u file */ 824// writes current playlist to current m3u file */
825 void PlayListWidget::writeCurrentM3u() { 825 void PlayListWidget::writeCurrentM3u() {
826 odebug << "writing to current m3u" << oendl; 826 odebug << "writing to current m3u" << oendl;
827 Config cfg( "OpiePlayer" ); 827 Config cfg( "OpiePlayer" );
828 cfg.setGroup("PlayList"); 828 cfg.setGroup("PlayList");
829 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 829 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
830 830
831 Om3u *m3uList; 831 Om3u *m3uList;
832 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 832 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
833 if( d->selectedFiles->first()) { 833 if( d->selectedFiles->first()) {
834 834
835 do { 835 do {
836 // odebug << "add writeCurrentM3u " +d->selectedFiles->current()->file() << oendl; 836 // odebug << "add writeCurrentM3u " +d->selectedFiles->current()->file() << oendl;
837 m3uList->add( d->selectedFiles->current()->file() ); 837 m3uList->add( d->selectedFiles->current()->file() );
838 } 838 }
839 while ( d->selectedFiles->next() ); 839 while ( d->selectedFiles->next() );
840 // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl; 840 // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl;
841 m3uList->write(); 841 m3uList->write();
842 m3uList->close(); 842 m3uList->close();
843 } 843 }
844 delete m3uList; 844 delete m3uList;
845 845
846 } 846 }
847 847
848 /* 848 /*
849 writes current playlist to m3u file */ 849 writes current playlist to m3u file */
850void PlayListWidget::writem3u() { 850void PlayListWidget::writem3u() {
851 851
852 Config cfg( "OpiePlayer" ); 852 Config cfg( "OpiePlayer" );
853 cfg.setGroup("Dialog"); 853 cfg.setGroup("Dialog");
854 MimeTypes types = fileSelectorMimeTypes(); 854 MimeTypes types = fileSelectorMimeTypes();
855 855
856 QString str = OFileDialog::getOpenFileName( 1, QString::null, 856 QString str = OFileDialog::getOpenFileName( 1, QString::null,
857 QString::null, types, 0, 857 QString::null, types, 0,
858 tr( "Save Playlist" )); 858 tr( "Save Playlist" ));
859 859
860 if(str.left(2) == "//") str=str.right(str.length()-1); 860 if(str.left(2) == "//") str=str.right(str.length()-1);
861 861
862 QString name, filename, list; 862 QString name, filename, list;
863 Om3u *m3uList; 863 Om3u *m3uList;
864 864
865 if( !str.isEmpty() ) { 865 if( !str.isEmpty() ) {
866 name = str; 866 name = str;
867 // name = fileDlg->text(); 867 // name = fileDlg->text();
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp
index c3c1282..589c11f 100644
--- a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp
@@ -1,192 +1,192 @@
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..}^=.=       =       ; General Public License for more 22..}^=.= = ; 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  -_. . .   )=.  = General Public License along with 26 -_. . . )=. = 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
35#include <qtoolbar.h> 34#include <qtoolbar.h>
36#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
37 36
38#include <qlayout.h> 37#include <qlayout.h>
39#include <qmenubar.h> 38#include <qmenubar.h>
40 39
41#include "playlistselection.h" 40#include "playlistselection.h"
42#include "playlistwidget.h" 41#include "playlistwidget.h"
43#include "mediaplayerstate.h" 42#include "mediaplayerstate.h"
44#include "inputDialog.h" 43#include "inputDialog.h"
45#include "playlistfileview.h" 44#include "playlistfileview.h"
46 45
47 46
48PlayListWidgetGui::PlayListWidgetGui(QWidget* parent, const char* name ) 47PlayListWidgetGui::PlayListWidgetGui(QWidget* parent, const char* name )
49 : QMainWindow( parent, name ) { 48 : QMainWindow( parent, name ) {
50 49
51 d = new PlayListWidgetPrivate; 50 d = new PlayListWidgetPrivate;
52 d->setDocumentUsed = FALSE; 51 d->setDocumentUsed = FALSE;
53 52
54 setBackgroundMode( PaletteButton ); 53 setBackgroundMode( PaletteButton );
55 setToolBarsMovable( FALSE ); 54 setToolBarsMovable( FALSE );
56 55
57 // Create Toolbar 56 // Create Toolbar
58 QToolBar *toolbar = new QToolBar( this ); 57 QToolBar *toolbar = new QToolBar( this );
59 toolbar->setHorizontalStretchable( TRUE ); 58 toolbar->setHorizontalStretchable( TRUE );
60 59
61 // Create Menubar 60 // Create Menubar
62 QMenuBar *menu = new QMenuBar( toolbar ); 61 QMenuBar *menu = new QMenuBar( toolbar );
63 menu->setMargin( 0 ); 62 menu->setMargin( 0 );
64 63
65 bar = new QToolBar( this ); 64 bar = new QToolBar( this );
66 bar->setLabel( tr( "Play Operations" ) ); 65 bar->setLabel( tr( "Play Operations" ) );
67 66
68 tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" ); 67 tbDeletePlaylist = new QPushButton( Opie::Core::OResource::loadIconSet( "trash", Opie::Core::OResource::SmallIcon ),
68 "", bar, "close" );
69 tbDeletePlaylist->setFlat( TRUE ); 69 tbDeletePlaylist->setFlat( TRUE );
70 tbDeletePlaylist->setFixedSize( 20, 20 ); 70 tbDeletePlaylist->setFixedSize( 20, 20 );
71 71
72 tbDeletePlaylist->hide(); 72 tbDeletePlaylist->hide();
73 73
74 pmPlayList = new QPopupMenu( this ); 74 pmPlayList = new QPopupMenu( this );
75 menu->insertItem( tr( "File" ), pmPlayList ); 75 menu->insertItem( tr( "File" ), pmPlayList );
76 76
77 pmView = new QPopupMenu( this ); 77 pmView = new QPopupMenu( this );
78 menu->insertItem( tr( "View" ), pmView ); 78 menu->insertItem( tr( "View" ), pmView );
79 pmView->isCheckable(); 79 pmView->isCheckable();
80 80
81 skinsMenu = new QPopupMenu( this ); 81 skinsMenu = new QPopupMenu( this );
82 pmView->insertItem( tr( "Skins" ), skinsMenu ); 82 pmView->insertItem( tr( "Skins" ), skinsMenu );
83 skinsMenu->isCheckable(); 83 skinsMenu->isCheckable();
84 84
85 gammaMenu = new QPopupMenu( this ); 85 gammaMenu = new QPopupMenu( this );
86 pmView->insertItem( tr( "Gamma (Video)" ), gammaMenu ); 86 pmView->insertItem( tr( "Gamma (Video)" ), gammaMenu );
87 87
88 gammaSlider = new QSlider( QSlider::Vertical, gammaMenu ); 88 gammaSlider = new QSlider( QSlider::Vertical, gammaMenu );
89 gammaSlider->setRange( -40, 40 ); 89 gammaSlider->setRange( -40, 40 );
90 gammaSlider->setTickmarks( QSlider::Left ); 90 gammaSlider->setTickmarks( QSlider::Left );
91 gammaSlider->setTickInterval( 20 ); 91 gammaSlider->setTickInterval( 20 );
92 gammaSlider->setFocusPolicy( QWidget::StrongFocus ); 92 gammaSlider->setFocusPolicy( QWidget::StrongFocus );
93 gammaSlider->setValue( 0 ); 93 gammaSlider->setValue( 0 );
94 gammaSlider->setMinimumHeight( 50 ); 94 gammaSlider->setMinimumHeight( 50 );
95 95
96 gammaLCD = new QLCDNumber( 3, gammaMenu ); 96 gammaLCD = new QLCDNumber( 3, gammaMenu );
97 gammaLCD-> setFrameShape ( QFrame::NoFrame ); 97 gammaLCD-> setFrameShape ( QFrame::NoFrame );
98 gammaLCD-> setSegmentStyle ( QLCDNumber::Flat ); 98 gammaLCD-> setSegmentStyle ( QLCDNumber::Flat );
99 99
100 gammaMenu->insertItem( gammaSlider ); 100 gammaMenu->insertItem( gammaSlider );
101 gammaMenu->insertItem( gammaLCD ); 101 gammaMenu->insertItem( gammaLCD );
102 102
103 connect( gammaSlider, SIGNAL( valueChanged(int) ), gammaLCD, SLOT( display(int) ) ); 103 connect( gammaSlider, SIGNAL( valueChanged(int) ), gammaLCD, SLOT( display(int) ) );
104 104
105 vbox5 = new QVBox( this ); 105 vbox5 = new QVBox( this );
106 QVBox *vbox4 = new QVBox( vbox5 ); 106 QVBox *vbox4 = new QVBox( vbox5 );
107 QHBox *hbox6 = new QHBox( vbox4 ); 107 QHBox *hbox6 = new QHBox( vbox4 );
108 108
109 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 109 tabWidget = new QTabWidget( hbox6, "tabWidget" );
110 110
111 playListTab = new QWidget( tabWidget, "PlayListTab" ); 111 playListTab = new QWidget( tabWidget, "PlayListTab" );
112 tabWidget->insertTab( playListTab, "Playlist"); 112 tabWidget->insertTab( playListTab, "Playlist");
113 113
114 QGridLayout *Playout = new QGridLayout( playListTab ); 114 QGridLayout *Playout = new QGridLayout( playListTab );
115 Playout->setSpacing( 2); 115 Playout->setSpacing( 2);
116 Playout->setMargin( 2); 116 Playout->setMargin( 2);
117 117
118 // Add the playlist area 118 // Add the playlist area
119 QVBox *vbox3 = new QVBox( playListTab ); 119 QVBox *vbox3 = new QVBox( playListTab );
120 d->playListFrame = vbox3; 120 d->playListFrame = vbox3;
121 121
122 QHBox *hbox2 = new QHBox( vbox3 ); 122 QHBox *hbox2 = new QHBox( vbox3 );
123 d->selectedFiles = new PlayListSelection( hbox2 ); 123 d->selectedFiles = new PlayListSelection( hbox2 );
124 124
125 vbox1 = new QVBox( hbox2 ); 125 vbox1 = new QVBox( hbox2 );
126 QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold ); 126 QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold );
127 QVBox *stretch1 = new QVBox( vbox1 ); // add stretch 127 QVBox *stretch1 = new QVBox( vbox1 ); // add stretch
128 128
129 Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); 129 Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 );
130 130
131 QWidget *aTab; 131 QWidget *aTab;
132 aTab = new QWidget( tabWidget, "aTab" ); 132 aTab = new QWidget( tabWidget, "aTab" );
133 133
134 QGridLayout *Alayout = new QGridLayout( aTab ); 134 QGridLayout *Alayout = new QGridLayout( aTab );
135 Alayout->setSpacing( 2 ); 135 Alayout->setSpacing( 2 );
136 Alayout->setMargin( 2 ); 136 Alayout->setMargin( 2 );
137 // no m3u's here please 137 // no m3u's here please
138 audioView = new PlayListFileView( "audio/mpeg;audio/x-wav;application/ogg", "opieplayer2/musicfile", aTab, "Audioview" ); 138 audioView = new PlayListFileView( "audio/mpeg;audio/x-wav;application/ogg", "opieplayer2/musicfile", aTab, "Audioview" );
139 Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); 139 Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 );
140 tabWidget->insertTab( aTab, tr( "Audio" ) ); 140 tabWidget->insertTab( aTab, tr( "Audio" ) );
141 141
142 QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); 142 QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold );
143 143
144 QWidget *vTab; 144 QWidget *vTab;
145 vTab = new QWidget( tabWidget, "vTab" ); 145 vTab = new QWidget( tabWidget, "vTab" );
146 146
147 QGridLayout *Vlayout = new QGridLayout( vTab ); 147 QGridLayout *Vlayout = new QGridLayout( vTab );
148 Vlayout->setSpacing( 2 ); 148 Vlayout->setSpacing( 2 );
149 Vlayout->setMargin( 2 ); 149 Vlayout->setMargin( 2 );
150 videoView = new PlayListFileView( "video/*", "opieplayer2/videofile", vTab, "Videoview" ); 150 videoView = new PlayListFileView( "video/*", "opieplayer2/videofile", vTab, "Videoview" );
151 Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); 151 Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 );
152 152
153 QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); 153 QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold );
154 154
155 tabWidget->insertTab( vTab, tr( "Video" ) ); 155 tabWidget->insertTab( vTab, tr( "Video" ) );
156 156
157 //playlists list 157 //playlists list
158 QWidget *LTab; 158 QWidget *LTab;
159 LTab = new QWidget( tabWidget, "LTab" ); 159 LTab = new QWidget( tabWidget, "LTab" );
160 QGridLayout *Llayout = new QGridLayout( LTab ); 160 QGridLayout *Llayout = new QGridLayout( LTab );
161 Llayout->setSpacing( 2 ); 161 Llayout->setSpacing( 2 );
162 Llayout->setMargin( 2 ); 162 Llayout->setMargin( 2 );
163 163
164 playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE ); 164 playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE );
165 Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); 165 Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 );
166 166
167 tabWidget->insertTab( LTab, tr( "Lists" ) ); 167 tabWidget->insertTab( LTab, tr( "Lists" ) );
168 168
169 setCentralWidget( vbox5 ); 169 setCentralWidget( vbox5 );
170} 170}
171 171
172 172
173 173
174PlayListWidgetGui::~PlayListWidgetGui() { 174PlayListWidgetGui::~PlayListWidgetGui() {
175} 175}
176 176
177void PlayListWidgetGui::setView( char view ) { 177void PlayListWidgetGui::setView( char view ) {
178 if ( view == 'l' ) 178 if ( view == 'l' )
179 showMaximized(); 179 showMaximized();
180 else 180 else
181 hide(); 181 hide();
182} 182}
183 183
184 184
185void PlayListWidgetGui::setActiveWindow() { 185void PlayListWidgetGui::setActiveWindow() {
186 // When we get raised we need to ensure that it switches views 186 // When we get raised we need to ensure that it switches views
187 MediaPlayerState::DisplayType origDisplayType = mediaPlayerState->displayType(); 187 MediaPlayerState::DisplayType origDisplayType = mediaPlayerState->displayType();
188 mediaPlayerState->setDisplayType( MediaPlayerState::MediaSelection ); // invalidate 188 mediaPlayerState->setDisplayType( MediaPlayerState::MediaSelection ); // invalidate
189 mediaPlayerState->setDisplayType( origDisplayType ); // now switch back 189 mediaPlayerState->setDisplayType( origDisplayType ); // now switch back
190} 190}
191 191
192 192
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.h b/noncore/multimedia/opieplayer2/playlistwidgetgui.h
index 5706d14..0f4a120 100644
--- a/noncore/multimedia/opieplayer2/playlistwidgetgui.h
+++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.h
@@ -1,129 +1,133 @@
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..}^=.=       =       ; General Public License for more 22..}^=.= = ; 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  -_. . .   )=.  = General Public License along with 26 -_. . . )=. = 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#ifndef PLAY_LIST_WIDGET_GUI_H 34#ifndef PLAY_LIST_WIDGET_GUI_H
35#define PLAY_LIST_WIDGET_GUI_H 35#define PLAY_LIST_WIDGET_GUI_H
36 36
37#include <qmainwindow.h> 37#include <qmainwindow.h>
38#include <qpe/resource.h>
39 38
40#include <qtabwidget.h> 39#include <opie2/oresource.h>
40
41#include <qpe/qpeapplication.h>
41#include <qpe/fileselector.h> 42#include <qpe/fileselector.h>
43
44#include <qtabwidget.h>
42#include <qaction.h> 45#include <qaction.h>
43#include <qtoolbutton.h> 46#include <qtoolbutton.h>
44#include <qslider.h> 47#include <qslider.h>
45#include <qlcdnumber.h> 48#include <qlcdnumber.h>
46 49
47class PlayListWidgetPrivate; 50class PlayListWidgetPrivate;
48class PlayListSelection; 51class PlayListSelection;
49class MediaPlayerState; 52class MediaPlayerState;
50class PlayListFileView; 53class PlayListFileView;
51 54
52class Config; 55class Config;
53class QToolBar; 56class QToolBar;
54class QListViewItem; 57class QListViewItem;
55class QListView; 58class QListView;
56class QPoint; 59class QPoint;
57class QAction; 60class QAction;
58class QLabel; 61class QLabel;
59 62
60class PlayListWidgetPrivate { 63class PlayListWidgetPrivate {
61public: 64public:
62 QToolButton *tbPlay, *tbFull, *tbLoop, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 65 QToolButton *tbPlay, *tbFull, *tbLoop, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
63 QFrame *playListFrame; 66 QFrame *playListFrame;
64 PlayListSelection *selectedFiles; 67 PlayListSelection *selectedFiles;
65 bool setDocumentUsed; 68 bool setDocumentUsed;
66}; 69};
67 70
68 71
69class ToolButton : public QToolButton { 72class ToolButton : public QToolButton {
70 Q_OBJECT 73 Q_OBJECT
71public: 74public:
72 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 75 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
73 : QToolButton( parent, name ) { 76 : QToolButton( parent, name ) {
74 setTextLabel( name ); 77 setTextLabel( name );
75 setPixmap( Resource::loadPixmap( icon ) ); 78 setUsesBigPixmap( qApp->desktop()->size().width() > 330 );
79 setPixmap( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) );
76 setAutoRaise( TRUE ); 80 setAutoRaise( TRUE );
77 setFocusPolicy( QWidget::NoFocus ); 81 setFocusPolicy( QWidget::NoFocus );
78 setToggleButton( t ); 82 setToggleButton( t );
79 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 83 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
80 } 84 }
81}; 85};
82 86
83class MenuItem : public QAction { 87class MenuItem : public QAction {
84 88
85public: 89public:
86 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 90 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
87 : QAction( text, QString::null, 0, 0 ) { 91 : QAction( text, QString::null, 0, 0 ) {
88 connect( this, SIGNAL( activated() ), handler, slot ); 92 connect( this, SIGNAL( activated() ), handler, slot );
89 addTo( parent ); 93 addTo( parent );
90 } 94 }
91}; 95};
92 96
93class PlayListWidgetGui : public QMainWindow { 97class PlayListWidgetGui : public QMainWindow {
94 Q_OBJECT 98 Q_OBJECT
95public: 99public:
96 PlayListWidgetGui( QWidget* parent=0, const char* name=0 ); 100 PlayListWidgetGui( QWidget* parent=0, const char* name=0 );
97 ~PlayListWidgetGui(); 101 ~PlayListWidgetGui();
98 102
99protected: 103protected:
100 QTabWidget * tabWidget; 104 QTabWidget * tabWidget;
101 PlayListFileView *audioView, *videoView; 105 PlayListFileView *audioView, *videoView;
102 QListView *playlistView; 106 QListView *playlistView;
103 QLabel *libString; 107 QLabel *libString;
104 QPopupMenu *pmView ; 108 QPopupMenu *pmView ;
105 QPopupMenu *gammaMenu; 109 QPopupMenu *gammaMenu;
106 QSlider *gammaSlider; 110 QSlider *gammaSlider;
107 QLCDNumber *gammaLCD; 111 QLCDNumber *gammaLCD;
108 bool fromSetDocument; 112 bool fromSetDocument;
109 bool insanityBool; 113 bool insanityBool;
110 QString setDocFileRef; 114 QString setDocFileRef;
111 // retrieve the current playlist entry (media file link) 115 // retrieve the current playlist entry (media file link)
112 QPushButton *tbDeletePlaylist; 116 QPushButton *tbDeletePlaylist;
113 int selected; 117 int selected;
114 QPopupMenu *pmPlayList; 118 QPopupMenu *pmPlayList;
115 FileSelector* playLists; 119 FileSelector* playLists;
116 QPopupMenu *skinsMenu; 120 QPopupMenu *skinsMenu;
117 PlayListWidgetPrivate *d; // Private implementation data 121 PlayListWidgetPrivate *d; // Private implementation data
118 QVBox *vbox1; 122 QVBox *vbox1;
119 QVBox *vbox5; 123 QVBox *vbox5;
120 QToolBar *bar; 124 QToolBar *bar;
121 QWidget *playListTab; 125 QWidget *playListTab;
122 void setActiveWindow(); // need to handle this to show the right view 126 void setActiveWindow(); // need to handle this to show the right view
123 void setView( char ); 127 void setView( char );
124 128
125 MediaPlayerState *mediaPlayerState; 129 MediaPlayerState *mediaPlayerState;
126}; 130};
127 131
128#endif 132#endif
129 133
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
index 7c98ce5..eac84dd 100644
--- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp
+++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
@@ -1,324 +1,323 @@
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 "xinevideowidget.h" 34#include "xinevideowidget.h"
35#include <opie2/odebug.h> 35#include <opie2/odebug.h>
36#include <opie2/oresource.h>
36 37
37#include <qimage.h> 38#include <qimage.h>
38#include <qdirectpainter_qws.h> 39#include <qdirectpainter_qws.h>
39#include <qgfx_qws.h> 40#include <qgfx_qws.h>
40#include <qsize.h> 41#include <qsize.h>
41#include <qapplication.h> 42#include <qapplication.h>
42 43
43#include <qpe/resource.h>
44
45#include <pthread.h> 44#include <pthread.h>
46 45
47 46
48 47
49// 0 deg rot: copy a line from src to dst (use libc memcpy) 48// 0 deg rot: copy a line from src to dst (use libc memcpy)
50 49
51// 180 deg rot: copy a line from src to dst reversed 50// 180 deg rot: copy a line from src to dst reversed
52 51
53/* 52/*
54 * This code relies the len be a multiply of 16bit 53 * This code relies the len be a multiply of 16bit
55 */ 54 */
56static inline void memcpy_rev ( void *_dst, void *_src, size_t len ) 55static inline void memcpy_rev ( void *_dst, void *_src, size_t len )
57{ 56{
58 57
59 /* 58 /*
60 * move the source to the end 59 * move the source to the end
61 */ 60 */
62 char *src_c = static_cast<char*>(_src) + len; 61 char *src_c = static_cast<char*>(_src) + len;
63 62
64 /* 63 /*
65 * as we copy by 16bit and not 8bit 64 * as we copy by 16bit and not 8bit
66 * devide the length by two 65 * devide the length by two
67 */ 66 */
68 len >>= 1; 67 len >>= 1;
69 68
70 short int* dst = static_cast<short int*>( _dst ); 69 short int* dst = static_cast<short int*>( _dst );
71 short int* src = reinterpret_cast<short int*>( src_c ); 70 short int* src = reinterpret_cast<short int*>( src_c );
72 71
73 /* 72 /*
74 * Increment dst after assigning 73 * Increment dst after assigning
75 * Decrement src before assigning becase we move backwards 74 * Decrement src before assigning becase we move backwards
76 */ 75 */
77 while ( len-- ) 76 while ( len-- )
78 *dst++ = *--src; 77 *dst++ = *--src;
79 78
80} 79}
81 80
82// 90 deg rot: copy a column from src to dst 81// 90 deg rot: copy a column from src to dst
83 82
84static inline void memcpy_step ( void *_dst, void *_src, size_t len, size_t step ) 83static inline void memcpy_step ( void *_dst, void *_src, size_t len, size_t step )
85{ 84{
86 short int *dst = static_cast<short int*>( _dst ); 85 short int *dst = static_cast<short int*>( _dst );
87 short int *src = static_cast<short int*>( _src ); 86 short int *src = static_cast<short int*>( _src );
88 87
89 len >>= 1; 88 len >>= 1;
90 89
91 /* 90 /*
92 * Copy 16bit from src to dst and move to the next address 91 * Copy 16bit from src to dst and move to the next address
93 */ 92 */
94 while ( len-- ) { 93 while ( len-- ) {
95 *dst++ = *src; 94 *dst++ = *src;
96 src = reinterpret_cast<short int*>(reinterpret_cast<char*>(src)+step); 95 src = reinterpret_cast<short int*>(reinterpret_cast<char*>(src)+step);
97 } 96 }
98} 97}
99 98
100// 270 deg rot: copy a column from src to dst reversed 99// 270 deg rot: copy a column from src to dst reversed
101 100
102static inline void memcpy_step_rev ( void *_dst, void *_src, size_t len, size_t step ) 101static inline void memcpy_step_rev ( void *_dst, void *_src, size_t len, size_t step )
103{ 102{
104 len >>= 1; 103 len >>= 1;
105 104
106 char *src_c = static_cast<char*>( _src ) + (len*step); 105 char *src_c = static_cast<char*>( _src ) + (len*step);
107 short int* dst = static_cast<short int*>( _dst ); 106 short int* dst = static_cast<short int*>( _dst );
108 short int* src = reinterpret_cast<short int*>( src_c ); 107 short int* src = reinterpret_cast<short int*>( src_c );
109 108
110 while ( len-- ) { 109 while ( len-- ) {
111 src_c -= step; 110 src_c -= step;
112 src = reinterpret_cast<short int*>( src_c ); 111 src = reinterpret_cast<short int*>( src_c );
113 *dst++ = *src; 112 *dst++ = *src;
114 } 113 }
115} 114}
116 115
117 116
118XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) 117XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name )
119 : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ),old_framerect(0,0,0,0),old_size(0,0) 118 : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ),old_framerect(0,0,0,0),old_size(0,0)
120{ 119{
121 setBackgroundMode ( NoBackground ); 120 setBackgroundMode ( NoBackground );
122 121
123 m_logo = 0; 122 m_logo = 0;
124 m_buff = 0; 123 m_buff = 0;
125 m_bytes_per_line_fb = qt_screen-> linestep ( ); 124 m_bytes_per_line_fb = qt_screen-> linestep ( );
126 m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; 125 m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8;
127 m_rotation = 0; 126 m_rotation = 0;
128 m_lastsize = 0; 127 m_lastsize = 0;
129} 128}
130 129
131 130
132XineVideoWidget::~XineVideoWidget ( ) 131XineVideoWidget::~XineVideoWidget ( )
133{ 132{
134#if 0 133#if 0
135 if (m_buff) { 134 if (m_buff) {
136 delete[]m_buff; 135 delete[]m_buff;
137 m_lastsize=0; 136 m_lastsize=0;
138 m_buff = 0; 137 m_buff = 0;
139 } 138 }
140#endif 139#endif
141 if (m_logo) { 140 if (m_logo) {
142 delete m_logo; 141 delete m_logo;
143 } 142 }
144} 143}
145 144
146void XineVideoWidget::clear ( ) 145void XineVideoWidget::clear ( )
147{ 146{
148#if 0 147#if 0
149 ThreadUtil::AutoLock a(m_bufmutex); 148 ThreadUtil::AutoLock a(m_bufmutex);
150 if (m_buff) { 149 if (m_buff) {
151 delete[]m_buff; 150 delete[]m_buff;
152 m_lastsize=0; 151 m_lastsize=0;
153 m_buff = 0; 152 m_buff = 0;
154 } 153 }
155#endif 154#endif
156 repaint ( false ); 155 repaint ( false );
157} 156}
158 157
159QSize XineVideoWidget::videoSize() const 158QSize XineVideoWidget::videoSize() const
160{ 159{
161 QSize s = size(); 160 QSize s = size();
162 bool fs = ( s == qApp->desktop()->size() ); 161 bool fs = ( s == qApp->desktop()->size() );
163 162
164 // if we are in fullscreen mode, do not rotate the video 163 // if we are in fullscreen mode, do not rotate the video
165 // (!! the paint routine uses m_rotation + qt_screen-> transformOrientation() !!) 164 // (!! the paint routine uses m_rotation + qt_screen-> transformOrientation() !!)
166 m_rotation = fs ? - qt_screen->transformOrientation() : 0; 165 m_rotation = fs ? - qt_screen->transformOrientation() : 0;
167 166
168 if ( fs && qt_screen->isTransformed() ) 167 if ( fs && qt_screen->isTransformed() )
169 s = qt_screen->mapToDevice( s ); 168 s = qt_screen->mapToDevice( s );
170 169
171 return s; 170 return s;
172} 171}
173 172
174void XineVideoWidget::paintEvent ( QPaintEvent * ) 173void XineVideoWidget::paintEvent ( QPaintEvent * )
175{ 174{
176 QPainter p ( this ); 175 QPainter p ( this );
177 p. fillRect ( rect (), black ); 176 p. fillRect ( rect (), black );
178 if (m_logo) 177 if (m_logo)
179 p. drawImage ( 0, 0, *m_logo ); 178 p. drawImage ( 0, 0, *m_logo );
180} 179}
181 180
182void XineVideoWidget::paintEvent2 ( QPaintEvent * ) 181void XineVideoWidget::paintEvent2 ( QPaintEvent * )
183{ 182{
184 if ( m_buff == 0 ) { 183 if ( m_buff == 0 ) {
185 return; 184 return;
186 } else if (m_lastsize){ 185 } else if (m_lastsize){
187 { 186 {
188 QDirectPainter dp ( this ); 187 QDirectPainter dp ( this );
189 int rot = dp. transformOrientation ( ) + m_rotation; // device rotation + custom rotation 188 int rot = dp. transformOrientation ( ) + m_rotation; // device rotation + custom rotation
190 bool rot90 = (( -m_rotation ) & 1 ); 189 bool rot90 = (( -m_rotation ) & 1 );
191 int _vw,_vh; 190 int _vw,_vh;
192 switch (rot90) { 191 switch (rot90) {
193 case true: 192 case true:
194 _vh = m_framesize.width(); 193 _vh = m_framesize.width();
195 _vw = m_framesize.height(); 194 _vw = m_framesize.height();
196 break; 195 break;
197 default: 196 default:
198 _vw = m_framesize.width(); 197 _vw = m_framesize.width();
199 _vh = m_framesize.height(); 198 _vh = m_framesize.height();
200 break; 199 break;
201 break; 200 break;
202 } 201 }
203 int middle_w = _vw/2; 202 int middle_w = _vw/2;
204 int middle_h = _vh/2; 203 int middle_h = _vh/2;
205 m_thisframe.setRect(width()/2-middle_w,height()/2-middle_h,_vw,_vh); 204 m_thisframe.setRect(width()/2-middle_w,height()/2-middle_h,_vw,_vh);
206 uchar *fb = dp. frameBuffer ( ); 205 uchar *fb = dp. frameBuffer ( );
207 uchar *frame = m_buff; 206 uchar *frame = m_buff;
208 207
209 // where is the video frame in fb coordinates 208 // where is the video frame in fb coordinates
210 QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), 209 QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ),
211 qt_screen-> height ( ))); 210 qt_screen-> height ( )));
212 211
213 uchar * src = frame; 212 uchar * src = frame;
214 uchar * dst = fb+framerect.y()*m_bytes_per_line_fb+framerect.x()*m_bytes_per_pixel; 213 uchar * dst = fb+framerect.y()*m_bytes_per_line_fb+framerect.x()*m_bytes_per_pixel;
215 214
216 /* clean up the fb screen when shrinking the image only! */ 215 /* clean up the fb screen when shrinking the image only! */
217 if (old_framerect.isValid() && old_size.width()==width()&&old_size.height()==height() && 216 if (old_framerect.isValid() && old_size.width()==width()&&old_size.height()==height() &&
218 (old_framerect.width()>framerect.width() || old_framerect.height()>framerect.height())) { 217 (old_framerect.width()>framerect.width() || old_framerect.height()>framerect.height())) {
219 uchar*_dst = fb+old_framerect.y()*m_bytes_per_line_fb+old_framerect.x()*m_bytes_per_pixel; 218 uchar*_dst = fb+old_framerect.y()*m_bytes_per_line_fb+old_framerect.x()*m_bytes_per_pixel;
220 for (int z=0;z<old_framerect.height();++z) { 219 for (int z=0;z<old_framerect.height();++z) {
221 memset(_dst,0,m_bytes_per_line_fb); 220 memset(_dst,0,m_bytes_per_line_fb);
222 _dst+=m_bytes_per_line_fb; 221 _dst+=m_bytes_per_line_fb;
223 } 222 }
224 } 223 }
225 old_framerect=framerect; 224 old_framerect=framerect;
226 old_size = size(); 225 old_size = size();
227 226
228 if (framerect.height()!=m_framesize.height()) { 227 if (framerect.height()!=m_framesize.height()) {
229 odebug << "Hoehm: " << framerect.height() << " <-> " << m_framesize.height() << oendl; 228 odebug << "Hoehm: " << framerect.height() << " <-> " << m_framesize.height() << oendl;
230 } 229 }
231 for (int y = 0;y<framerect.height();++y) { 230 for (int y = 0;y<framerect.height();++y) {
232 switch (rot) { 231 switch (rot) {
233 case 0: 232 case 0:
234 memcpy(dst,src,m_bytes_per_line_frame); 233 memcpy(dst,src,m_bytes_per_line_frame);
235 src+=m_bytes_per_line_frame; 234 src+=m_bytes_per_line_frame;
236 break; 235 break;
237 case 1: 236 case 1:
238 memcpy_step ( dst, src, m_thisframe.size().width(), m_bytes_per_line_frame ); 237 memcpy_step ( dst, src, m_thisframe.size().width(), m_bytes_per_line_frame );
239 src -= m_bytes_per_pixel; 238 src -= m_bytes_per_pixel;
240 break; 239 break;
241 case 2: 240 case 2:
242 memcpy_rev ( dst, src, m_thisframe.size().width()); 241 memcpy_rev ( dst, src, m_thisframe.size().width());
243 src-=m_bytes_per_line_frame; 242 src-=m_bytes_per_line_frame;
244 break; 243 break;
245 case 3: 244 case 3:
246 memcpy_step_rev ( dst, src, m_thisframe.size().width(), m_bytes_per_line_frame ); 245 memcpy_step_rev ( dst, src, m_thisframe.size().width(), m_bytes_per_line_frame );
247 src += m_bytes_per_pixel; 246 src += m_bytes_per_pixel;
248 break; 247 break;
249 default: 248 default:
250 break; 249 break;
251 } 250 }
252 dst += m_bytes_per_line_fb; 251 dst += m_bytes_per_line_fb;
253 } 252 }
254 } 253 }
255 } 254 }
256} 255}
257 256
258QImage *XineVideoWidget::logo ( ) const 257QImage *XineVideoWidget::logo ( ) const
259{ 258{
260 return m_logo; 259 return m_logo;
261} 260}
262 261
263 262
264void XineVideoWidget::setLogo ( QImage* logo ) 263void XineVideoWidget::setLogo ( QImage* logo )
265{ 264{
266 delete m_logo; 265 delete m_logo;
267 m_logo = logo; 266 m_logo = logo;
268} 267}
269 268
270void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl ) 269void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl )
271{ 270{
272 // mutex area for AutoLock 271 // mutex area for AutoLock
273 { 272 {
274#if 0 273#if 0
275 ThreadUtil::AutoLock a(m_bufmutex); 274 ThreadUtil::AutoLock a(m_bufmutex);
276#endif 275#endif
277 if (!isVisible()||w>width()||h>height()/*||m_bufmutex.isLocked()*/) { 276 if (!isVisible()||w>width()||h>height()/*||m_bufmutex.isLocked()*/) {
278 //drop frame 277 //drop frame
279 return; 278 return;
280 } 279 }
281 bool rot90 = (( -m_rotation ) & 1 ); 280 bool rot90 = (( -m_rotation ) & 1 );
282 int l = h*bpl; 281 int l = h*bpl;
283#if 0 282#if 0
284 if (l!=m_lastsize) { 283 if (l!=m_lastsize) {
285 if (m_buff) { 284 if (m_buff) {
286 delete[]m_buff; 285 delete[]m_buff;
287 } 286 }
288 if (l>0) { 287 if (l>0) {
289 m_buff = new uchar[l]; 288 m_buff = new uchar[l];
290 odebug << "Point to: " << (unsigned long)m_buff << oendl; 289 odebug << "Point to: " << (unsigned long)m_buff << oendl;
291 m_lastsize=l; 290 m_lastsize=l;
292 } else { 291 } else {
293 m_buff = 0; 292 m_buff = 0;
294 } 293 }
295 } 294 }
296#endif 295#endif
297 m_lastsize = l; 296 m_lastsize = l;
298 m_framesize = QSize(w,h); 297 m_framesize = QSize(w,h);
299#if 0 298#if 0
300 if (m_buff && m_lastsize) { 299 if (m_buff && m_lastsize) {
301 memcpy(m_buff,img,m_lastsize); 300 memcpy(m_buff,img,m_lastsize);
302 } 301 }
303#endif 302#endif
304 m_buff = img; 303 m_buff = img;
305 m_bytes_per_line_frame = bpl; 304 m_bytes_per_line_frame = bpl;
306 if (m_buff) paintEvent2(0); 305 if (m_buff) paintEvent2(0);
307 } // Release Mutex 306 } // Release Mutex
308} 307}
309 308
310void XineVideoWidget::resizeEvent ( QResizeEvent * ) 309void XineVideoWidget::resizeEvent ( QResizeEvent * )
311{ 310{
312#if 0 311#if 0
313 ThreadUtil::AutoLock a(m_bufmutex); 312 ThreadUtil::AutoLock a(m_bufmutex);
314#endif 313#endif
315 emit videoResized( videoSize() ); 314 emit videoResized( videoSize() );
316 odebug << "All resize done" << oendl; 315 odebug << "All resize done" << oendl;
317} 316}
318 317
319 318
320void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ ) 319void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ )
321{ 320{
322 emit clicked(); 321 emit clicked();
323} 322}
324 323