author | alwin <alwin> | 2005-04-12 16:35:06 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-04-12 16:35:06 (UTC) |
commit | 4fd936e4096ba9c732bde17a48489bfbb94b19ba (patch) (unidiff) | |
tree | fa96015a24e24298c227bfa19314603debb1586d | |
parent | 6df2eb36803e072ea9db62153b762250742610f0 (diff) | |
download | opie-4fd936e4096ba9c732bde17a48489bfbb94b19ba.zip opie-4fd936e4096ba9c732bde17a48489bfbb94b19ba.tar.gz opie-4fd936e4096ba9c732bde17a48489bfbb94b19ba.tar.bz2 |
some gui stuff
may switch if videos will scaled up even if display size is larger than
video size
-rw-r--r-- | noncore/multimedia/opieplayer3/audiowidget.cpp | 110 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer3/audiowidget.h | 10 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer3/mwindow.cpp | 81 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer3/mwindow.h | 16 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer3/playlist.cpp | 40 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer3/playlist.h | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer3/videowidget.cpp | 77 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer3/videowidget.h | 11 |
8 files changed, 152 insertions, 195 deletions
diff --git a/noncore/multimedia/opieplayer3/audiowidget.cpp b/noncore/multimedia/opieplayer3/audiowidget.cpp index b435c1b..aeebf45 100644 --- a/noncore/multimedia/opieplayer3/audiowidget.cpp +++ b/noncore/multimedia/opieplayer3/audiowidget.cpp | |||
@@ -1,146 +1,96 @@ | |||
1 | #include "audiowidget.h" | 1 | #include "audiowidget.h" |
2 | #include "../opieplayer2/lib.h" | 2 | #include "../opieplayer2/lib.h" |
3 | #include "../opieplayer2/threadutil.h" | 3 | #include "../opieplayer2/threadutil.h" |
4 | 4 | ||
5 | #include <opie2/odebug.h> | 5 | #include <opie2/odebug.h> |
6 | 6 | ||
7 | #include <qlayout.h> | 7 | #include <qlayout.h> |
8 | #include <qtextview.h> | 8 | #include <qtextview.h> |
9 | #include <qslider.h> | 9 | #include <qslider.h> |
10 | #include <qlabel.h> | 10 | #include <qlabel.h> |
11 | 11 | ||
12 | AudioWidget::AudioWidget( QWidget * parent, const char * name, WFlags f) | 12 | AudioWidget::AudioWidget( QWidget * parent, const char * name, WFlags f) |
13 | :QWidget(parent,name,f) | 13 | :QWidget(parent,name,f) |
14 | { | 14 | { |
15 | m_xineLib = 0; | 15 | m_xineLib = 0; |
16 | 16 | ||
17 | m_MainLayout = new QVBoxLayout(this); | 17 | m_MainLayout = new QVBoxLayout(this); |
18 | m_MainLayout->setAutoAdd(true); | 18 | m_MainLayout->setAutoAdd(true); |
19 | m_InfoBox = new QTextView(this); | 19 | m_InfoBox = new QTextView(this); |
20 | #if 0 | ||
21 | m_PosSlider = new QSlider(QSlider::Horizontal,this); | ||
22 | m_PosSlider->setTickInterval(60); | ||
23 | connect(m_PosSlider,SIGNAL(valueChanged(int)),this,SLOT(slotNewPos(int))); | ||
24 | connect(m_PosSlider,SIGNAL(sliderMoved(int)),this,SLOT(slotNewPos(int))); | ||
25 | connect(m_PosSlider,SIGNAL(sliderPressed()),this,SLOT(sliderPressed())); | ||
26 | connect(m_PosSlider,SIGNAL(sliderReleased()),this,SLOT(sliderReleased())); | ||
27 | m_pressed = false; | ||
28 | m_uppos=0; | ||
29 | #endif | ||
30 | } | 20 | } |
31 | 21 | ||
32 | AudioWidget::~AudioWidget() | 22 | AudioWidget::~AudioWidget() |
33 | { | 23 | { |
34 | } | 24 | } |
35 | 25 | ||
36 | void AudioWidget::slotNewPos(int /* pos*/) | ||
37 | { | ||
38 | if (!m_xineLib) return; | ||
39 | #if 0 | ||
40 | if (m_uppos==pos) return; | ||
41 | m_xineLib->seekTo(pos); | ||
42 | #endif | ||
43 | } | ||
44 | |||
45 | void AudioWidget::sliderPressed() | ||
46 | { | ||
47 | #if 0 | ||
48 | m_pressed = true; | ||
49 | #endif | ||
50 | } | ||
51 | |||
52 | void AudioWidget::sliderReleased() | ||
53 | { | ||
54 | #if 0 | ||
55 | m_pressed = false; | ||
56 | #endif | ||
57 | } | ||
58 | |||
59 | void AudioWidget::closeEvent(QCloseEvent*e) | ||
60 | { | ||
61 | odebug << "AudioWidget::closeEvent(QCloseEvent*e)" << oendl; | ||
62 | if (m_xineLib) { | ||
63 | m_xineLib->stop(); | ||
64 | } | ||
65 | QWidget::closeEvent(e); | ||
66 | } | ||
67 | |||
68 | int AudioWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib) | 26 | int AudioWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib) |
69 | { | 27 | { |
70 | m_current = aLnk; | 28 | m_current = aLnk; |
71 | if (m_xineLib != aLib) { | 29 | if (m_xineLib != aLib) { |
72 | if (m_xineLib) disconnect(m_xineLib); | 30 | if (m_xineLib) disconnect(m_xineLib); |
73 | m_xineLib = aLib; | 31 | m_xineLib = aLib; |
74 | } | 32 | } |
75 | if (!m_xineLib) { | 33 | if (!m_xineLib) { |
76 | return -1; | 34 | return -1; |
77 | } | 35 | } |
78 | #if 0 | 36 | int res = m_xineLib->play(m_current.file(),0,0); |
79 | m_uppos=0; | ||
80 | m_PosSlider->setValue(0); | ||
81 | #endif | ||
82 | m_xineLib->setShowVideo(false); | ||
83 | int res = m_xineLib->play(m_current.file()); | ||
84 | if (res != 1) { | 37 | if (res != 1) { |
85 | return -2; | 38 | return -2; |
86 | } | 39 | } |
40 | if (!m_xineLib->hasVideo()) { | ||
41 | m_xineLib->setShowVideo( false ); | ||
42 | } | ||
43 | |||
87 | // title | 44 | // title |
88 | QString title = m_xineLib->metaInfo(0); | 45 | QString title = m_xineLib->metaInfo(0); |
89 | // artist | 46 | // artist |
90 | QString artist = m_xineLib->metaInfo(2); | 47 | QString artist = m_xineLib->metaInfo(2); |
91 | // album | 48 | // album |
92 | QString album = m_xineLib->metaInfo(4); | 49 | QString album = m_xineLib->metaInfo(4); |
93 | 50 | ||
94 | int l = m_xineLib->length(); | 51 | int l = m_xineLib->length(); |
95 | int tmp = l; | 52 | QString laenge = secToString(l); |
96 | #if 0 | 53 | QString text = "<qt><center><table border=\"0\">"; |
97 | m_PosSlider->setRange(0,l); | ||
98 | #endif | ||
99 | QString laenge=""; | ||
100 | int h = l/3600; | ||
101 | l-=h*3600; | ||
102 | int m = l/60; | ||
103 | l-=m*60; | ||
104 | if (h>0) { | ||
105 | laenge+=QString("%1 h").arg(h); | ||
106 | } | ||
107 | if (m>0) { | ||
108 | if (!laenge.isEmpty()) laenge+=" "; | ||
109 | laenge+=QString("%1 m").arg(m); | ||
110 | } | ||
111 | if (l>0) { | ||
112 | if (!laenge.isEmpty()) laenge+=" "; | ||
113 | laenge+=QString("%1 s").arg(l); | ||
114 | } | ||
115 | QString text = "<qt>"; | ||
116 | if (artist.length()) { | 54 | if (artist.length()) { |
117 | text+="<H2><center>"+artist+"</center></h2>"; | 55 | text+="<tr><td>"+tr("Artist: ")+"</td><td><b>"+artist+"</b></td></tr>"; |
118 | } | 56 | } |
119 | if (title.length()) { | 57 | if (title.length()) { |
120 | text+="<H2><center>"+title+"</center></h2>"; | 58 | text+="<tr><td>"+tr("Title: ")+"</td><td><font size=\"+2\">"+title+"</font></td></tr>"; |
121 | } else { | 59 | } else { |
122 | text+="<H2><center>"+m_current.name()+"</center></h2>"; | 60 | text+="<tr><td>"+tr("Filename: ")+"</td><td><b>"+m_current.name()+"</b></td></tr>"; |
123 | } | 61 | } |
124 | if (album.length()) { | 62 | if (album.length()) { |
125 | text+="<H2><center>"+album+"</center></h2>"; | 63 | text+="<tr><td>"+tr("Album: ")+"</td><td><b>"+album+"</b></td></tr>"; |
126 | } | 64 | } |
127 | text+="<h3><center>"+laenge+"</center></h3>"; | 65 | text+="<tr><td>"+tr("Length: ")+"</td><td><b>"+laenge+"</b></td></tr>"; |
66 | text+="</table></center></qt>"; | ||
128 | m_InfoBox->setText(text); | 67 | m_InfoBox->setText(text); |
129 | return tmp; | 68 | return l; |
69 | } | ||
70 | |||
71 | QString AudioWidget::secToString(int sec) | ||
72 | { | ||
73 | int l = sec; | ||
74 | int h = l/3600; | ||
75 | l-=h*3600; | ||
76 | int m = l/60; | ||
77 | l-=m*60; | ||
78 | QString s = ""; | ||
79 | if (h>0) { | ||
80 | s.sprintf("%2i:%2i:%2i",h,m,l); | ||
81 | } else { | ||
82 | s.sprintf("%02i:%02i",m,l); | ||
83 | } | ||
84 | return s; | ||
130 | } | 85 | } |
131 | 86 | ||
132 | void AudioWidget::stopPlaying() | 87 | void AudioWidget::stopPlaying() |
133 | { | 88 | { |
134 | if (m_xineLib) { | 89 | if (m_xineLib) { |
135 | m_xineLib->stop(); | 90 | m_xineLib->stop(); |
136 | } | 91 | } |
137 | } | 92 | } |
138 | 93 | ||
139 | void AudioWidget::updatePos(int /* val */) | 94 | void AudioWidget::updatePos(int /* val */) |
140 | { | 95 | { |
141 | #if 0 | ||
142 | if (m_pressed) return; | ||
143 | m_uppos = val; | ||
144 | m_PosSlider->setValue(val); | ||
145 | #endif | ||
146 | } | 96 | } |
diff --git a/noncore/multimedia/opieplayer3/audiowidget.h b/noncore/multimedia/opieplayer3/audiowidget.h index 5e5dc09..abdd781 100644 --- a/noncore/multimedia/opieplayer3/audiowidget.h +++ b/noncore/multimedia/opieplayer3/audiowidget.h | |||
@@ -11,38 +11,30 @@ namespace XINE { | |||
11 | 11 | ||
12 | class QVBoxLayout; | 12 | class QVBoxLayout; |
13 | class QTextView; | 13 | class QTextView; |
14 | class QSlider; | 14 | class QSlider; |
15 | class QLabel; | 15 | class QLabel; |
16 | 16 | ||
17 | class AudioWidget:public QWidget | 17 | class AudioWidget:public QWidget |
18 | { | 18 | { |
19 | Q_OBJECT | 19 | Q_OBJECT |
20 | public: | 20 | public: |
21 | AudioWidget( QWidget * parent=0, const char * name=0, WFlags f=0 ); | 21 | AudioWidget( QWidget * parent=0, const char * name=0, WFlags f=0 ); |
22 | virtual ~AudioWidget(); | 22 | virtual ~AudioWidget(); |
23 | 23 | ||
24 | int playFile(const DocLnk&,XINE::Lib*); | 24 | int playFile(const DocLnk&,XINE::Lib*); |
25 | 25 | ||
26 | public slots: | 26 | public slots: |
27 | virtual void stopPlaying(); | 27 | virtual void stopPlaying(); |
28 | virtual void updatePos(int); | 28 | virtual void updatePos(int); |
29 | 29 | ||
30 | protected: | 30 | protected: |
31 | XINE::Lib*m_xineLib; | 31 | XINE::Lib*m_xineLib; |
32 | DocLnk m_current; | 32 | DocLnk m_current; |
33 | QVBoxLayout*m_MainLayout; | 33 | QVBoxLayout*m_MainLayout; |
34 | QTextView*m_InfoBox; | 34 | QTextView*m_InfoBox; |
35 | #if 0 | ||
36 | QSlider*m_PosSlider; | ||
37 | bool m_pressed; | ||
38 | int m_uppos; | ||
39 | #endif | ||
40 | 35 | ||
36 | static QString secToString(int sec); | ||
41 | protected slots: | 37 | protected slots: |
42 | virtual void closeEvent(QCloseEvent*e); | ||
43 | virtual void slotNewPos(int pos); | ||
44 | virtual void sliderPressed(); | ||
45 | virtual void sliderReleased(); | ||
46 | }; | 38 | }; |
47 | 39 | ||
48 | #endif | 40 | #endif |
diff --git a/noncore/multimedia/opieplayer3/mwindow.cpp b/noncore/multimedia/opieplayer3/mwindow.cpp index 57418f0..75d1490 100644 --- a/noncore/multimedia/opieplayer3/mwindow.cpp +++ b/noncore/multimedia/opieplayer3/mwindow.cpp | |||
@@ -39,107 +39,116 @@ | |||
39 | 39 | ||
40 | #include <opie2/oapplicationfactory.h> | 40 | #include <opie2/oapplicationfactory.h> |
41 | #include <opie2/owidgetstack.h> | 41 | #include <opie2/owidgetstack.h> |
42 | #include <opie2/ofileselector.h> | 42 | #include <opie2/ofileselector.h> |
43 | #include <opie2/odebug.h> | 43 | #include <opie2/odebug.h> |
44 | 44 | ||
45 | #include <qpe/resource.h> | 45 | #include <qpe/resource.h> |
46 | 46 | ||
47 | #include <qfileinfo.h> | 47 | #include <qfileinfo.h> |
48 | #include <qfile.h> | 48 | #include <qfile.h> |
49 | #include <qtoolbar.h> | 49 | #include <qtoolbar.h> |
50 | #include <qpopupmenu.h> | 50 | #include <qpopupmenu.h> |
51 | #include <qmenubar.h> | 51 | #include <qmenubar.h> |
52 | #include <qtimer.h> | 52 | #include <qtimer.h> |
53 | #include <qslider.h> | 53 | #include <qslider.h> |
54 | #include <qlayout.h> | 54 | #include <qlayout.h> |
55 | 55 | ||
56 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) | 56 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) |
57 | 57 | ||
58 | using namespace Opie::Ui; | 58 | using namespace Opie::Ui; |
59 | 59 | ||
60 | PMainWindow::PMainWindow(QWidget*w, const char*name, WFlags f) | 60 | PMainWindow::PMainWindow(QWidget*w, const char*name, WFlags f) |
61 | : QMainWindow(w,name,f) | 61 | : QMainWindow(w,name,f) |
62 | { | 62 | { |
63 | checkLib(); | ||
63 | setCaption( QObject::tr("Opie Mediaplayer 3" ) ); | 64 | setCaption( QObject::tr("Opie Mediaplayer 3" ) ); |
64 | 65 | ||
65 | m_MainBox = new QWidget(this); | 66 | m_MainBox = new QWidget(this); |
66 | 67 | ||
67 | QVBoxLayout*m_l = new QVBoxLayout(m_MainBox); | 68 | QVBoxLayout*m_l = new QVBoxLayout(m_MainBox); |
68 | 69 | ||
69 | m_stack = new OWidgetStack(m_MainBox); | 70 | m_stack = new OWidgetStack(m_MainBox); |
70 | m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen); | 71 | m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen); |
71 | m_l->addWidget(m_stack); | 72 | m_l->addWidget(m_stack); |
72 | m_scrollBar = new QSlider(QSlider::Horizontal,m_MainBox); | 73 | m_PosSlider = new QSlider(QSlider::Horizontal,m_MainBox); |
73 | m_l->addWidget(m_scrollBar); | 74 | m_l->addWidget(m_PosSlider); |
74 | m_scrollBar->setEnabled(false); | 75 | m_PosSlider->setEnabled(false); |
75 | 76 | ||
76 | m_playList = new PlaylistView(m_stack,"playlist"); | 77 | m_playList = new PlaylistView(m_stack,"playlist"); |
77 | m_stack->addWidget(m_playList,stack_list); | 78 | m_stack->addWidget(m_playList,stack_list); |
78 | connect(m_playList,SIGNAL(contentChanged(int)),this,SLOT(slotListChanged(int))); | 79 | connect(m_playList,SIGNAL(contentChanged(int)),this,SLOT(slotListChanged(int))); |
79 | m_sfl = new OFileSelector("video/*;audio/*",m_stack); | 80 | m_sfl = new OFileSelector("video/*;audio/*",m_stack); |
80 | m_stack->addWidget(m_sfl,stack_file); | 81 | m_stack->addWidget(m_sfl,stack_file); |
81 | connect(m_sfl, SIGNAL(fileSelected(const DocLnk &)), m_playList, SLOT(slotAddFile(const DocLnk &))); | 82 | connect(m_sfl, SIGNAL(fileSelected(const DocLnk &)), m_playList, SLOT(slotAddFile(const DocLnk &))); |
82 | m_AudioPlayer = new AudioWidget(m_stack); | 83 | m_AudioPlayer = new AudioWidget(m_stack); |
83 | m_stack->addWidget(m_AudioPlayer,stack_audio); | 84 | m_stack->addWidget(m_AudioPlayer,stack_audio); |
84 | connect(this,SIGNAL(sigPos(int)),m_AudioPlayer,SLOT(updatePos(int))); | 85 | connect(this,SIGNAL(sigPos(int)),m_AudioPlayer,SLOT(updatePos(int))); |
85 | m_VideoPlayer = new VideoWidget(m_stack); | 86 | m_VideoPlayer = new VideoWidget(m_stack); |
86 | m_stack->addWidget(m_VideoPlayer,stack_video); | 87 | m_stack->addWidget(m_VideoPlayer,stack_video); |
87 | connect(this,SIGNAL(sigPos(int)),m_VideoPlayer,SLOT(updatePos(int))); | 88 | connect(this,SIGNAL(sigPos(int)),m_VideoPlayer,SLOT(updatePos(int))); |
88 | connect(m_VideoPlayer,SIGNAL(videoclicked()),this,SLOT(slotVideoclicked())); | 89 | connect(m_VideoPlayer,SIGNAL(videoclicked()),this,SLOT(slotVideoclicked())); |
89 | 90 | ||
91 | connect(m_PosSlider,SIGNAL(valueChanged(int)),this,SLOT(slotNewPos(int))); | ||
92 | connect(m_PosSlider,SIGNAL(sliderMoved(int)),this,SLOT(slotNewPos(int))); | ||
93 | connect(m_PosSlider,SIGNAL(sliderPressed()),this,SLOT(sliderPressed())); | ||
94 | connect(m_PosSlider,SIGNAL(sliderReleased()),this,SLOT(sliderReleased())); | ||
95 | m_pressed = false; | ||
96 | m_uppos=0; | ||
97 | |||
90 | m_stack->raiseWidget(stack_list); | 98 | m_stack->raiseWidget(stack_list); |
91 | m_PlayLib = 0; | ||
92 | m_LastItem = 0; | 99 | m_LastItem = 0; |
93 | setupActions(); | 100 | setupActions(); |
94 | setupToolBar(); | 101 | setupToolBar(); |
95 | setupMenu(); | 102 | setupMenu(); |
96 | 103 | ||
97 | setCentralWidget(m_MainBox ); | 104 | setCentralWidget(m_MainBox ); |
98 | } | 105 | } |
99 | 106 | ||
100 | void PMainWindow::slotListChanged(int count) | 107 | void PMainWindow::slotListChanged(int count) |
101 | { | 108 | { |
109 | playersGroup->setEnabled(count>0); | ||
102 | if (!m_playList->isVisible()) { | 110 | if (!m_playList->isVisible()) { |
103 | return; | 111 | return; |
104 | } | 112 | } |
105 | a_removeFiles->setEnabled(count>0); | 113 | a_removeFiles->setEnabled(count>0); |
106 | } | 114 | } |
107 | 115 | ||
108 | void PMainWindow::mediaWindowraised() | 116 | void PMainWindow::mediaWindowraised() |
109 | { | 117 | { |
110 | playlistOnly->setEnabled(false); | 118 | playlistOnly->setEnabled(false); |
111 | a_appendFiles->setEnabled(true); | 119 | a_appendFiles->setEnabled(true); |
112 | a_loadPlaylist->setEnabled(true); | 120 | a_loadPlaylist->setEnabled(true); |
113 | a_showPlaylist->setEnabled(true); | 121 | a_showPlaylist->setEnabled(true); |
114 | a_ShowMedia->setEnabled(false); | 122 | a_ShowMedia->setEnabled(false); |
115 | } | 123 | } |
116 | 124 | ||
117 | void PMainWindow::checkLib() | 125 | void PMainWindow::checkLib() |
118 | { | 126 | { |
119 | if (m_PlayLib == 0) { | 127 | if (m_PlayLib == 0) { |
120 | m_PlayLib = new XINE::Lib(XINE::Lib::InitializeImmediately); | 128 | m_PlayLib = new XINE::Lib(XINE::Lib::InitializeInThread); |
121 | m_PlayLib->ensureInitialized(); | 129 | qApp->processEvents(); |
130 | // m_PlayLib->ensureInitialized(); | ||
122 | connect(m_PlayLib,SIGNAL(stopped()),this,SLOT(slotStopped())); | 131 | connect(m_PlayLib,SIGNAL(stopped()),this,SLOT(slotStopped())); |
123 | } | 132 | } |
124 | } | 133 | } |
125 | 134 | ||
126 | PMainWindow::~PMainWindow() | 135 | PMainWindow::~PMainWindow() |
127 | { | 136 | { |
128 | if (m_PlayLib) { | 137 | if (m_PlayLib) { |
129 | m_PlayLib->stop(); | 138 | m_PlayLib->stop(); |
130 | delete m_PlayLib; | 139 | delete m_PlayLib; |
131 | } | 140 | } |
132 | } | 141 | } |
133 | 142 | ||
134 | void PMainWindow::fileSelected(const DocLnk&) | 143 | void PMainWindow::fileSelected(const DocLnk&) |
135 | { | 144 | { |
136 | } | 145 | } |
137 | 146 | ||
138 | void PMainWindow::slotAppendFiles() | 147 | void PMainWindow::slotAppendFiles() |
139 | { | 148 | { |
140 | m_stack->raiseWidget(m_sfl); | 149 | m_stack->raiseWidget(m_sfl); |
141 | playlistOnly->setEnabled(false); | 150 | playlistOnly->setEnabled(false); |
142 | 151 | ||
143 | a_showPlaylist->setEnabled(true); | 152 | a_showPlaylist->setEnabled(true); |
144 | if (m_PlayLib && m_playing) { | 153 | if (m_PlayLib && m_playing) { |
145 | a_ShowMedia->setEnabled(true); | 154 | a_ShowMedia->setEnabled(true); |
@@ -178,204 +187,216 @@ void PMainWindow::slotShowMediaWindow() | |||
178 | } | 187 | } |
179 | } | 188 | } |
180 | 189 | ||
181 | void PMainWindow::slotPlayList() | 190 | void PMainWindow::slotPlayList() |
182 | { | 191 | { |
183 | if (m_playing && m_LastItem && m_PlayLib) { | 192 | if (m_playing && m_LastItem && m_PlayLib) { |
184 | slotShowMediaWindow(); | 193 | slotShowMediaWindow(); |
185 | return; | 194 | return; |
186 | } | 195 | } |
187 | 196 | ||
188 | m_LastItem = m_playList->currentItem(); | 197 | m_LastItem = m_playList->currentItem(); |
189 | if (!m_LastItem) { | 198 | if (!m_LastItem) { |
190 | slotPlayNext(); | 199 | slotPlayNext(); |
191 | return; | 200 | return; |
192 | } | 201 | } |
193 | //m_VideoPlayer->setFullScreen(a_ShowFull->isOn()); | 202 | //m_VideoPlayer->setFullScreen(a_ShowFull->isOn()); |
194 | slotPlayCurrent(); | 203 | slotPlayCurrent(); |
195 | } | 204 | } |
196 | 205 | ||
197 | void PMainWindow::slotUserStop() | 206 | void PMainWindow::slotUserStop() |
198 | { | 207 | { |
199 | if (!m_playing || !m_PlayLib) return; | 208 | if (!m_playing || !m_PlayLib) return; |
200 | m_playing = false; | 209 | m_playing = false; |
201 | m_PlayLib->stop(); | 210 | m_PlayLib->stop(); |
202 | m_scrollBar->setEnabled(false); | 211 | m_PosSlider->setEnabled(false); |
203 | hideVideo(); | 212 | hideVideo(); |
204 | slotShowList(); | 213 | slotShowList(); |
205 | } | 214 | } |
206 | 215 | ||
207 | void PMainWindow::slotTogglePlay(bool how) | 216 | void PMainWindow::slotTogglePlay(bool how) |
208 | { | 217 | { |
209 | if (how == m_playing) { | 218 | if (how == m_playing) { |
210 | if (how) { | 219 | if (how) { |
211 | slotShowMediaWindow(); | 220 | slotShowMediaWindow(); |
212 | } | 221 | } |
213 | return; | 222 | return; |
214 | } | 223 | } |
215 | if (how) { | 224 | if (how) { |
216 | slotPlayList(); | 225 | slotPlayList(); |
217 | } else { | 226 | } else { |
218 | slotUserStop(); | 227 | slotUserStop(); |
219 | } | 228 | } |
220 | } | 229 | } |
221 | 230 | ||
222 | void PMainWindow::hideVideo() | 231 | void PMainWindow::hideVideo() |
223 | { | 232 | { |
224 | if (m_VideoPlayer->isVisible() && a_ShowFull->isOn()) { | 233 | if (m_VideoPlayer->isVisible() && a_ShowFull->isOn()) { |
225 | //m_VideoPlayer->showNormal(); | 234 | //m_VideoPlayer->showNormal(); |
226 | m_VideoPlayer->hide(); | 235 | m_VideoPlayer->hide(); |
227 | } | 236 | } |
228 | } | 237 | } |
229 | 238 | ||
230 | void PMainWindow::slotPlayCurrent() | 239 | void PMainWindow::slotPlayCurrent() |
231 | { | 240 | { |
232 | if (!m_LastItem) { | 241 | if (!m_LastItem) { |
233 | if (m_PlayLib) m_PlayLib->stop(); | 242 | if (m_PlayLib) m_PlayLib->stop(); |
234 | m_scrollBar->setEnabled(false); | 243 | m_PosSlider->setEnabled(false); |
235 | a_playAction->setOn(false); | 244 | a_playAction->setOn(false); |
236 | hideVideo(); | 245 | hideVideo(); |
237 | slotShowList(); | 246 | slotShowList(); |
238 | return; | 247 | return; |
239 | } | 248 | } |
240 | checkLib(); | ||
241 | m_CurrentPos = 0; | 249 | m_CurrentPos = 0; |
242 | m_playList->setCurrentItem(m_LastItem); | 250 | m_playList->setCurrentItem(m_LastItem); |
243 | odebug << "Pos: " << m_PlayLib->currentTime() << oendl; | 251 | m_uppos = 0; |
252 | m_PosSlider->setValue(0); | ||
244 | int result = 0; | 253 | int result = 0; |
245 | if (!m_LastItem->isVideo()) { | 254 | if (!m_LastItem->isVideo()) { |
246 | hideVideo(); | 255 | hideVideo(); |
247 | m_playing = true; | 256 | m_playing = true; |
248 | m_stack->raiseWidget(stack_audio); | 257 | m_stack->raiseWidget(stack_audio); |
249 | result = m_AudioPlayer->playFile(m_LastItem->Lnk(),m_PlayLib); | 258 | result = m_AudioPlayer->playFile(m_LastItem->Lnk(),m_PlayLib); |
250 | } else { | 259 | } else { |
251 | m_playing = true; | 260 | m_playing = true; |
252 | setupVideo(a_ShowFull->isOn()); | 261 | setupVideo(a_ShowFull->isOn()); |
253 | result = m_VideoPlayer->playFile(m_LastItem->Lnk(),m_PlayLib); | 262 | result = m_VideoPlayer->playFile(m_LastItem->Lnk(),m_PlayLib); |
254 | } | 263 | } |
255 | if (result<0) { | 264 | if (result<0) { |
256 | // fehler | 265 | // fehler |
257 | return; | 266 | return; |
258 | } | 267 | } |
259 | mediaWindowraised(); | 268 | mediaWindowraised(); |
260 | odebug << "Range: " << result << oendl; | 269 | odebug << "Range: " << result << oendl; |
261 | m_scrollBar->setRange(0,result); | 270 | m_PosSlider->setEnabled(true); |
262 | m_scrollBar->setValue(0); | 271 | m_PosSlider->setRange(0,m_PlayLib->length()); |
263 | m_scrollBar->setEnabled(true); | 272 | m_PosSlider->setValue(m_PlayLib->currentTime()); |
264 | QTimer::singleShot( 500, this, SLOT( slotCheckPos() ) ); | 273 | QTimer::singleShot( 500, this, SLOT( slotCheckPos() ) ); |
265 | } | 274 | } |
266 | 275 | ||
267 | void PMainWindow::slotPlayNext() | 276 | void PMainWindow::slotPlayNext() |
268 | { | 277 | { |
269 | PlaylistItem*item = m_playList->nextItem(m_LastItem); | 278 | PlaylistItem*item = m_playList->nextItem(m_LastItem); |
270 | if (!item) return; | 279 | if (!item) return; |
271 | m_LastItem = item; | 280 | m_LastItem = item; |
272 | slotPlayCurrent(); | 281 | slotPlayCurrent(); |
273 | } | 282 | } |
274 | 283 | ||
275 | void PMainWindow::slotGoNext() | 284 | void PMainWindow::slotGoNext() |
276 | { | 285 | { |
277 | m_LastItem = m_playList->nextItem(m_LastItem); | 286 | m_LastItem = m_playList->nextItem(m_LastItem); |
278 | slotPlayCurrent(); | 287 | slotPlayCurrent(); |
279 | } | 288 | } |
280 | 289 | ||
281 | void PMainWindow::slotPlayPrevious() | 290 | void PMainWindow::slotPlayPrevious() |
282 | { | 291 | { |
283 | PlaylistItem*item = m_playList->prevItem(m_LastItem); | 292 | PlaylistItem*item = m_playList->prevItem(m_LastItem); |
284 | if (!item) return; | 293 | if (!item) return; |
285 | m_LastItem = item; | 294 | m_LastItem = item; |
286 | slotPlayCurrent(); | 295 | slotPlayCurrent(); |
287 | } | 296 | } |
288 | 297 | ||
289 | void PMainWindow::slotStopped() | 298 | void PMainWindow::slotStopped() |
290 | { | 299 | { |
291 | if (!m_playing) return; | 300 | if (!m_playing) return; |
301 | odebug << "Slot stopped" << oendl; | ||
292 | m_playing = false; | 302 | m_playing = false; |
293 | slotGoNext(); | 303 | slotGoNext(); |
294 | } | 304 | } |
295 | 305 | ||
296 | void PMainWindow::slotCheckPos() | 306 | void PMainWindow::slotCheckPos() |
297 | { | 307 | { |
298 | if (!m_playing) return; | 308 | if (!m_playing) return; |
299 | //emit sigPos(m_PlayLib->currentTime()); | 309 | if (!m_pressed) { |
300 | m_scrollBar->setValue(m_PlayLib->currentTime()); | 310 | m_uppos = m_PlayLib->currentTime(); |
311 | emit sigPos(m_uppos); | ||
312 | m_PosSlider->setValue(m_PlayLib->currentTime()); | ||
313 | } | ||
301 | QTimer::singleShot( 1000, this, SLOT( slotCheckPos() ) ); | 314 | QTimer::singleShot( 1000, this, SLOT( slotCheckPos() ) ); |
302 | } | 315 | } |
303 | 316 | ||
304 | void PMainWindow::slotRemoveFiles() | 317 | void PMainWindow::slotRemoveFiles() |
305 | { | 318 | { |
306 | if (m_playing||!m_playList->isVisible()) return; | 319 | if (m_playing||!m_playList->isVisible()) return; |
307 | PlaylistItem* Item = m_playList->currentItem(); | 320 | PlaylistItem* Item = m_playList->currentItem(); |
308 | slotShowList(); | 321 | slotShowList(); |
309 | m_playList->removeFromList(Item); | 322 | m_playList->removeFromList(Item); |
310 | } | 323 | } |
311 | 324 | ||
312 | void PMainWindow::setupActions() | 325 | void PMainWindow::setupActions() |
313 | { | 326 | { |
314 | a_appendFiles = new QAction(tr("Append file(s)"),Resource::loadIconSet( "opieplayer2/add_to_playlist" ), 0, 0, this, 0, false ); | 327 | a_appendFiles = new QAction(tr("Append file(s)"),Resource::loadIconSet( "opieplayer2/add_to_playlist" ), 0, 0, this, 0, false ); |
315 | connect(a_appendFiles,SIGNAL(activated()),this,SLOT(slotAppendFiles())); | 328 | connect(a_appendFiles,SIGNAL(activated()),this,SLOT(slotAppendFiles())); |
316 | a_addDir = new QAction(tr("Add directory"),Resource::loadIconSet("folder_open"),0,0,this,0,false); | 329 | a_addDir = new QAction(tr("Add directory"),Resource::loadIconSet("folder_open"),0,0,this,0,false); |
317 | connect(a_addDir,SIGNAL(activated()),m_playList,SLOT(slotAppendDir())); | 330 | connect(a_addDir,SIGNAL(activated()),m_playList,SLOT(slotAppendDir())); |
318 | a_loadPlaylist = new QAction(tr("Append .m3u playlist"),Resource::loadIconSet("opieplayer2/add_to_playlist"),0,0,this,0,false); | 331 | a_loadPlaylist = new QAction(tr("Append playlist"),Resource::loadIconSet("opieplayer2/add_to_playlist"),0,0,this,0,false); |
319 | connect(a_loadPlaylist,SIGNAL(activated()),m_playList,SLOT(slotOpenM3u())); | 332 | connect(a_loadPlaylist,SIGNAL(activated()),m_playList,SLOT(slotOpenM3u())); |
320 | a_savePlaylist = new QAction(tr("Save .m3u playlist"),Resource::loadIconSet("save"),0,0,this,0,false); | 333 | a_savePlaylist = new QAction(tr("Save playlist"),Resource::loadIconSet("save"),0,0,this,0,false); |
321 | connect(a_savePlaylist,SIGNAL(activated()),m_playList,SLOT(slotSaveAsM3u())); | 334 | connect(a_savePlaylist,SIGNAL(activated()),m_playList,SLOT(slotSaveAsM3u())); |
322 | 335 | ||
323 | playlistOnly = new QActionGroup(this,"playlistgroup",false); | 336 | playlistOnly = new QActionGroup(this,"playlistgroup",false); |
324 | playlistOnly->insert(a_appendFiles); | 337 | playlistOnly->insert(a_appendFiles); |
325 | playlistOnly->insert(a_addDir); | 338 | playlistOnly->insert(a_addDir); |
326 | playlistOnly->insert(a_loadPlaylist); | 339 | playlistOnly->insert(a_loadPlaylist); |
327 | playlistOnly->insert(a_savePlaylist); | 340 | playlistOnly->insert(a_savePlaylist); |
328 | 341 | ||
329 | a_showPlaylist = new QAction(tr("Show playlist"),Resource::loadIconSet( "txt" ), 0, 0, this, 0, false ); | 342 | a_showPlaylist = new QAction(tr("Show playlist"),Resource::loadIconSet( "txt" ), 0, 0, this, 0, false ); |
330 | connect(a_showPlaylist,SIGNAL(activated()),this,SLOT(slotShowList())); | 343 | connect(a_showPlaylist,SIGNAL(activated()),this,SLOT(slotShowList())); |
331 | a_ShowMedia = new QAction(tr("Show media window"),Resource::loadIconSet("opieplayer2/musicfile"), 0, 0, this, 0, false ); | 344 | a_ShowMedia = new QAction(tr("Show media window"),Resource::loadIconSet("opieplayer2/musicfile"), 0, 0, this, 0, false ); |
332 | connect(a_ShowMedia,SIGNAL(activated()),this,SLOT(slotShowMediaWindow())); | 345 | connect(a_ShowMedia,SIGNAL(activated()),this,SLOT(slotShowMediaWindow())); |
333 | 346 | ||
334 | a_removeFiles = new QAction(tr("Remove file"),Resource::loadIconSet( "opieplayer2/remove_from_playlist" ), 0, 0, this, 0, false ); | 347 | a_removeFiles = new QAction(tr("Remove file"),Resource::loadIconSet( "opieplayer2/remove_from_playlist" ), 0, 0, this, 0, false ); |
335 | connect(a_removeFiles,SIGNAL(activated()),this,SLOT(slotRemoveFiles())); | 348 | connect(a_removeFiles,SIGNAL(activated()),this,SLOT(slotRemoveFiles())); |
336 | 349 | ||
337 | playersGroup = new QActionGroup(this,"playgroup",false); | 350 | playersGroup = new QActionGroup(this,"playgroup",false); |
338 | 351 | ||
339 | a_playAction = new QAction(tr("Play list"),Resource::loadIconSet( "opieplayer2/play" ), 0, 0, this, 0, true); | 352 | a_playAction = new QAction(tr("Play list"),Resource::loadIconSet( "opieplayer2/play" ), 0, 0, this, 0, true); |
340 | a_playAction->setOn(false); | 353 | a_playAction->setOn(false); |
341 | connect(a_playAction,SIGNAL(toggled(bool)),this,SLOT(slotTogglePlay(bool))); | 354 | connect(a_playAction,SIGNAL(toggled(bool)),this,SLOT(slotTogglePlay(bool))); |
342 | 355 | ||
343 | a_playNext = new QAction(tr("Play next in list"),Resource::loadIconSet( "fastforward" ), 0, 0, this, 0, false ); | 356 | a_playNext = new QAction(tr("Play next in list"),Resource::loadIconSet( "fastforward" ), 0, 0, this, 0, false ); |
344 | connect(a_playNext,SIGNAL(activated()),this,SLOT(slotPlayNext())); | 357 | connect(a_playNext,SIGNAL(activated()),this,SLOT(slotPlayNext())); |
345 | a_playPrevious = new QAction(tr("Play previous in list"),Resource::loadIconSet( "fastback" ), 0, 0, this, 0, false ); | 358 | a_playPrevious = new QAction(tr("Play previous in list"),Resource::loadIconSet( "fastback" ), 0, 0, this, 0, false ); |
346 | connect(a_playPrevious,SIGNAL(activated()),this,SLOT(slotPlayPrevious())); | 359 | connect(a_playPrevious,SIGNAL(activated()),this,SLOT(slotPlayPrevious())); |
347 | a_ShowFull = new QAction(tr("Show videos fullscreen"),Resource::loadIconSet( "fullscreen" ), 0, 0, this, 0, true ); | 360 | a_ShowFull = new QAction(tr("Show videos fullscreen"),Resource::loadIconSet( "fullscreen" ), 0, 0, this, 0, true ); |
348 | connect(a_ShowFull,SIGNAL(toggled(bool)),this,SLOT(slotToggleFull(bool))); | 361 | connect(a_ShowFull,SIGNAL(toggled(bool)),this,SLOT(slotToggleFull(bool))); |
349 | 362 | ||
350 | playersGroup->insert(a_playPrevious); | 363 | playersGroup->insert(a_playPrevious); |
351 | playersGroup->insert(a_playAction); | 364 | playersGroup->insert(a_playAction); |
352 | playersGroup->insert(a_playNext); | 365 | playersGroup->insert(a_playNext); |
353 | 366 | ||
367 | |||
354 | /* initial states of actions */ | 368 | /* initial states of actions */ |
355 | a_showPlaylist->setEnabled(false); | 369 | a_showPlaylist->setEnabled(false); |
356 | a_removeFiles->setEnabled(false); | 370 | a_removeFiles->setEnabled(false); |
357 | a_ShowMedia->setEnabled(false); | 371 | a_ShowMedia->setEnabled(false); |
372 | playersGroup->setEnabled(false); | ||
373 | |||
374 | settingsGroup = new QActionGroup(this,"configgroup",false); | ||
375 | |||
376 | a_Scaleup = new QAction(tr("Scale videos larger"),Resource::loadIconSet( "fullscreen" ), 0, 0, this, 0, true ); | ||
377 | connect(a_Scaleup,SIGNAL(toggled(bool)),this,SLOT(slot_scaleupToggled(bool))); | ||
378 | settingsGroup->insert(a_Scaleup); | ||
358 | } | 379 | } |
359 | 380 | ||
360 | void PMainWindow::setupToolBar() | 381 | void PMainWindow::setupToolBar() |
361 | { | 382 | { |
362 | setToolBarsMovable( false ); | 383 | setToolBarsMovable( false ); |
363 | m_toolBar = new QToolBar( this ); | 384 | m_toolBar = new QToolBar( this ); |
364 | //m_menuBar = new QMenuBar(m_toolBar); | 385 | //m_menuBar = new QMenuBar(m_toolBar); |
365 | m_menuBar=menuBar(); | 386 | m_menuBar=menuBar(); |
366 | addToolBar(m_toolBar); | 387 | addToolBar(m_toolBar); |
367 | m_toolBar->setHorizontalStretchable( true ); | 388 | m_toolBar->setHorizontalStretchable( true ); |
368 | a_appendFiles->addTo(m_toolBar); | 389 | a_appendFiles->addTo(m_toolBar); |
369 | a_removeFiles->addTo(m_toolBar); | 390 | a_removeFiles->addTo(m_toolBar); |
370 | a_showPlaylist->addTo(m_toolBar); | 391 | a_showPlaylist->addTo(m_toolBar); |
371 | a_ShowMedia->addTo(m_toolBar); | 392 | a_ShowMedia->addTo(m_toolBar); |
372 | a_ShowFull->addTo(m_toolBar); | 393 | a_ShowFull->addTo(m_toolBar); |
373 | playersGroup->addTo(m_toolBar); | 394 | playersGroup->addTo(m_toolBar); |
374 | } | 395 | } |
375 | 396 | ||
376 | void PMainWindow::setupVideo(bool full) | 397 | void PMainWindow::setupVideo(bool full) |
377 | { | 398 | { |
378 | if (full) { | 399 | if (full) { |
379 | m_VideoPlayer->setBackgroundColor(black); | 400 | m_VideoPlayer->setBackgroundColor(black); |
380 | m_VideoPlayer->reparent(0, WStyle_Customize | WStyle_NoBorderEx, QPoint(0,0)); | 401 | m_VideoPlayer->reparent(0, WStyle_Customize | WStyle_NoBorderEx, QPoint(0,0)); |
381 | m_VideoPlayer->setGeometry(0,0,qApp->desktop()->size().width(),qApp->desktop()->size().height()); | 402 | m_VideoPlayer->setGeometry(0,0,qApp->desktop()->size().width(),qApp->desktop()->size().height()); |
@@ -406,27 +427,51 @@ void PMainWindow::slotToggleFull(bool how) | |||
406 | m_PlayLib->pause(true); | 427 | m_PlayLib->pause(true); |
407 | setupVideo(how); | 428 | setupVideo(how); |
408 | m_PlayLib->pause(false); | 429 | m_PlayLib->pause(false); |
409 | } | 430 | } |
410 | } | 431 | } |
411 | 432 | ||
412 | void PMainWindow::setupMenu() | 433 | void PMainWindow::setupMenu() |
413 | { | 434 | { |
414 | fileMenu = new QPopupMenu( m_menuBar ); | 435 | fileMenu = new QPopupMenu( m_menuBar ); |
415 | m_menuBar->insertItem( tr( "Playlist" ), fileMenu ); | 436 | m_menuBar->insertItem( tr( "Playlist" ), fileMenu ); |
416 | a_appendFiles->addTo(fileMenu); | 437 | a_appendFiles->addTo(fileMenu); |
417 | a_removeFiles->addTo(fileMenu); | 438 | a_removeFiles->addTo(fileMenu); |
418 | a_addDir->addTo(fileMenu); | 439 | a_addDir->addTo(fileMenu); |
419 | fileMenu->insertSeparator(); | 440 | fileMenu->insertSeparator(); |
420 | a_loadPlaylist->addTo(fileMenu); | 441 | a_loadPlaylist->addTo(fileMenu); |
421 | a_savePlaylist->addTo(fileMenu); | 442 | a_savePlaylist->addTo(fileMenu); |
422 | 443 | ||
423 | dispMenu = new QPopupMenu( m_menuBar ); | 444 | dispMenu = new QPopupMenu( m_menuBar ); |
424 | m_menuBar->insertItem( tr( "Show" ), dispMenu ); | 445 | m_menuBar->insertItem( tr( "Show" ), dispMenu ); |
425 | a_showPlaylist->addTo(dispMenu); | 446 | a_showPlaylist->addTo(dispMenu); |
426 | a_ShowMedia->addTo(dispMenu); | 447 | a_ShowMedia->addTo(dispMenu); |
427 | a_ShowFull->addTo(dispMenu); | 448 | a_ShowFull->addTo(dispMenu); |
428 | playMenu = new QPopupMenu(m_menuBar); | 449 | playMenu = new QPopupMenu(m_menuBar); |
429 | m_menuBar->insertItem(tr("Playing"),playMenu); | 450 | m_menuBar->insertItem(tr("Playing"),playMenu); |
430 | |||
431 | playersGroup->addTo(playMenu); | 451 | playersGroup->addTo(playMenu); |
452 | configMenu = new QPopupMenu(m_menuBar); | ||
453 | m_menuBar->insertItem(tr("Config"),configMenu); | ||
454 | settingsGroup->addTo(configMenu); | ||
455 | } | ||
456 | |||
457 | void PMainWindow::slotNewPos(int pos) | ||
458 | { | ||
459 | if (!m_PlayLib) return; | ||
460 | if (m_uppos==pos) return; | ||
461 | m_PlayLib->seekTo(pos); | ||
462 | } | ||
463 | |||
464 | void PMainWindow::sliderPressed() | ||
465 | { | ||
466 | m_pressed = true; | ||
467 | } | ||
468 | |||
469 | void PMainWindow::sliderReleased() | ||
470 | { | ||
471 | m_pressed = false; | ||
472 | } | ||
473 | |||
474 | void PMainWindow::slot_scaleupToggled(bool how) | ||
475 | { | ||
476 | m_VideoPlayer->scaleUp(how); | ||
432 | } | 477 | } |
diff --git a/noncore/multimedia/opieplayer3/mwindow.h b/noncore/multimedia/opieplayer3/mwindow.h index 10c7a29..5d011d5 100644 --- a/noncore/multimedia/opieplayer3/mwindow.h +++ b/noncore/multimedia/opieplayer3/mwindow.h | |||
@@ -61,70 +61,78 @@ class PlaylistItem; | |||
61 | class QSlider; | 61 | class QSlider; |
62 | 62 | ||
63 | class PMainWindow : public QMainWindow { | 63 | class PMainWindow : public QMainWindow { |
64 | Q_OBJECT | 64 | Q_OBJECT |
65 | public: | 65 | public: |
66 | static QString appName() { return QString::fromLatin1("opie-mediaplayer3" ); } | 66 | static QString appName() { return QString::fromLatin1("opie-mediaplayer3" ); } |
67 | PMainWindow(QWidget*, const char*, WFlags ); | 67 | PMainWindow(QWidget*, const char*, WFlags ); |
68 | virtual ~PMainWindow(); | 68 | virtual ~PMainWindow(); |
69 | 69 | ||
70 | public slots: | 70 | public slots: |
71 | virtual void slotVideoclicked(); | 71 | virtual void slotVideoclicked(); |
72 | protected: | 72 | protected: |
73 | 73 | ||
74 | /* GUI parts */ | 74 | /* GUI parts */ |
75 | static const int stack_list = 0; | 75 | static const int stack_list = 0; |
76 | static const int stack_file = 1; | 76 | static const int stack_file = 1; |
77 | static const int stack_audio = 2; | 77 | static const int stack_audio = 2; |
78 | static const int stack_video = 3; | 78 | static const int stack_video = 3; |
79 | Opie::Ui::OWidgetStack *m_stack; | 79 | Opie::Ui::OWidgetStack *m_stack; |
80 | Opie::Ui::OFileSelector*m_sfl; | 80 | Opie::Ui::OFileSelector*m_sfl; |
81 | PlaylistView*m_playList; | 81 | PlaylistView*m_playList; |
82 | AudioWidget*m_AudioPlayer; | 82 | AudioWidget*m_AudioPlayer; |
83 | VideoWidget*m_VideoPlayer; | 83 | VideoWidget*m_VideoPlayer; |
84 | QWidget*m_MainBox; | 84 | QWidget*m_MainBox; |
85 | QSlider*m_scrollBar; | 85 | QSlider*m_PosSlider; |
86 | 86 | ||
87 | QAction*a_appendFiles,*a_removeFiles,*a_showPlaylist,*a_playAction,*a_stopAction; | 87 | QAction*a_appendFiles,*a_removeFiles,*a_showPlaylist,*a_playAction,*a_stopAction; |
88 | QAction*a_playNext,*a_playPrevious,*a_ShowFull,*a_stopPlay,*a_ShowMedia; | 88 | QAction*a_playNext,*a_playPrevious,*a_ShowFull,*a_stopPlay,*a_ShowMedia; |
89 | QAction*a_addDir,*a_loadPlaylist,*a_savePlaylist; | 89 | QAction*a_addDir,*a_loadPlaylist,*a_savePlaylist; |
90 | QActionGroup*playersGroup,*playlistOnly; | 90 | QAction*a_Scaleup; |
91 | QActionGroup*playersGroup,*playlistOnly,*settingsGroup; | ||
91 | QToolBar*m_toolBar; | 92 | QToolBar*m_toolBar; |
92 | QPopupMenu *fileMenu,*dispMenu,*playMenu; | 93 | QPopupMenu *fileMenu,*dispMenu,*playMenu,*configMenu; |
93 | QMenuBar*m_menuBar; | 94 | QMenuBar*m_menuBar; |
94 | XINE::Lib*m_PlayLib; | 95 | XINE::Lib*m_PlayLib; |
95 | 96 | ||
96 | void setupActions(); | 97 | void setupActions(); |
97 | void setupToolBar(); | 98 | void setupToolBar(); |
98 | void setupMenu(); | 99 | void setupMenu(); |
99 | void checkLib(); | 100 | void checkLib(); |
100 | void setupVideo(bool full); | 101 | void setupVideo(bool full); |
101 | void hideVideo(); | 102 | void hideVideo(); |
102 | |||
103 | bool m_playing:1; | 103 | bool m_playing:1; |
104 | bool m_pressed:1; | ||
105 | int m_uppos; | ||
106 | |||
104 | int m_CurrentPos; | 107 | int m_CurrentPos; |
105 | PlaylistItem*m_LastItem; | 108 | PlaylistItem*m_LastItem; |
106 | void mediaWindowraised(); | 109 | void mediaWindowraised(); |
107 | 110 | ||
108 | protected slots: | 111 | protected slots: |
109 | virtual void fileSelected(const DocLnk&); | 112 | virtual void fileSelected(const DocLnk&); |
110 | virtual void slotAppendFiles(); | 113 | virtual void slotAppendFiles(); |
111 | virtual void slotRemoveFiles(); | 114 | virtual void slotRemoveFiles(); |
112 | virtual void slotShowList(); | 115 | virtual void slotShowList(); |
113 | virtual void slotPlayList(); | 116 | virtual void slotPlayList(); |
114 | virtual void slotPlayNext(); | 117 | virtual void slotPlayNext(); |
115 | virtual void slotPlayPrevious(); | 118 | virtual void slotPlayPrevious(); |
116 | virtual void slotPlayCurrent(); | 119 | virtual void slotPlayCurrent(); |
117 | virtual void slotStopped(); | 120 | virtual void slotStopped(); |
118 | virtual void slotCheckPos(); | 121 | virtual void slotCheckPos(); |
119 | virtual void slotToggleFull(bool); | 122 | virtual void slotToggleFull(bool); |
120 | virtual void slotUserStop(); | 123 | virtual void slotUserStop(); |
121 | virtual void slotGoNext(); | 124 | virtual void slotGoNext(); |
122 | virtual void slotTogglePlay(bool); | 125 | virtual void slotTogglePlay(bool); |
123 | virtual void slotShowMediaWindow(); | 126 | virtual void slotShowMediaWindow(); |
124 | virtual void slotListChanged(int); | 127 | virtual void slotListChanged(int); |
128 | virtual void slotNewPos(int pos); | ||
129 | virtual void sliderPressed(); | ||
130 | virtual void sliderReleased(); | ||
131 | virtual void slot_scaleupToggled(bool); | ||
132 | |||
125 | 133 | ||
126 | signals: | 134 | signals: |
127 | void sigPos(int); | 135 | void sigPos(int); |
128 | }; | 136 | }; |
129 | 137 | ||
130 | #endif | 138 | #endif |
diff --git a/noncore/multimedia/opieplayer3/playlist.cpp b/noncore/multimedia/opieplayer3/playlist.cpp index babe8ce..2eb40e3 100644 --- a/noncore/multimedia/opieplayer3/playlist.cpp +++ b/noncore/multimedia/opieplayer3/playlist.cpp | |||
@@ -83,70 +83,81 @@ PlaylistView::PlaylistView(QWidget *parent, const char *name) | |||
83 | columnLabels << tr("Album"); | 83 | columnLabels << tr("Album"); |
84 | columnLabels << tr("Title"); | 84 | columnLabels << tr("Title"); |
85 | columnLabels << tr("Type"); | 85 | columnLabels << tr("Type"); |
86 | columnLabels << tr("Size"); | 86 | columnLabels << tr("Size"); |
87 | for (QStringList::Iterator it = columnLabels.begin(); it != columnLabels.end(); ++it) { | 87 | for (QStringList::Iterator it = columnLabels.begin(); it != columnLabels.end(); ++it) { |
88 | addColumn(*it); | 88 | addColumn(*it); |
89 | } | 89 | } |
90 | m_Infolib=0; | 90 | m_Infolib=0; |
91 | setAllColumnsShowFocus(true); | 91 | setAllColumnsShowFocus(true); |
92 | setSelectionMode(Single); | 92 | setSelectionMode(Single); |
93 | setSorting(-1); | 93 | setSorting(-1); |
94 | m_lastItem = 0; | 94 | m_lastItem = 0; |
95 | m_lastDir = QDir::homeDirPath(); | 95 | m_lastDir = QDir::homeDirPath(); |
96 | } | 96 | } |
97 | 97 | ||
98 | PlaylistView::~PlaylistView() | 98 | PlaylistView::~PlaylistView() |
99 | { | 99 | { |
100 | if (m_Infolib) delete m_Infolib; | 100 | if (m_Infolib) delete m_Infolib; |
101 | } | 101 | } |
102 | 102 | ||
103 | void PlaylistView::checkLib() | 103 | void PlaylistView::checkLib() |
104 | { | 104 | { |
105 | if (!m_Infolib) { | 105 | if (!m_Infolib) { |
106 | m_Infolib = new XINE::Lib(XINE::Lib::InitializeImmediately); | 106 | m_Infolib = new XINE::Lib(XINE::Lib::InitializeImmediately); |
107 | connect(m_Infolib,SIGNAL(stopped()),this,SLOT(slotDummyStop())); | ||
107 | m_Infolib->ensureInitialized(); | 108 | m_Infolib->ensureInitialized(); |
108 | } | 109 | } |
109 | } | 110 | } |
110 | 111 | ||
112 | void PlaylistView::slotDummyStop() | ||
113 | { | ||
114 | odebug << "void PlaylistView::slotDummyStop()" << oendl; | ||
115 | } | ||
116 | |||
111 | void PlaylistView::slotAddFile(const DocLnk&aLink) | 117 | void PlaylistView::slotAddFile(const DocLnk&aLink) |
112 | { | 118 | { |
113 | addFile(aLink.file(),aLink.name()); | 119 | QFileInfo f(aLink.file()); |
120 | if (f.extension(FALSE).lower()=="m3u"||f.extension(FALSE).lower()=="pls") { | ||
121 | readPlayList(aLink.file()); | ||
122 | } else { | ||
123 | addFile(aLink.file(),aLink.name()); | ||
124 | } | ||
114 | emit contentChanged(childCount()); | 125 | emit contentChanged(childCount()); |
115 | } | 126 | } |
116 | 127 | ||
117 | void PlaylistView::addFile(const QString&aFile,const QString&aName) | 128 | void PlaylistView::addFile(const QString&aFile,const QString&aName) |
118 | { | 129 | { |
119 | QFileInfo fileInfo(aFile); | 130 | QFileInfo fileInfo(aFile); |
120 | if (!fileInfo.exists()) return; | 131 | if (!fileInfo.exists()) return; |
121 | checkLib(); | 132 | checkLib(); |
122 | m_Infolib->stop(); | ||
123 | |||
124 | QString name = aName; | 133 | QString name = aName; |
125 | if (name.isEmpty()) { | 134 | if (name.isEmpty()) { |
126 | name = fileInfo.fileName(); | 135 | name = fileInfo.fileName(); |
127 | } | 136 | } |
128 | int i = m_Infolib->setfile(aFile.utf8().data()); | 137 | int i = m_Infolib->setfile(aFile.utf8().data()); |
138 | /* realy! otherwise we get an "stopped" signal when playing! - I don't know why */ | ||
139 | m_Infolib->stop(); | ||
129 | odebug << "File set: " << i << " ("<<aFile.utf8().data()<<")"<<oendl; | 140 | odebug << "File set: " << i << " ("<<aFile.utf8().data()<<")"<<oendl; |
130 | if (i<1) { | 141 | if (i<1) { |
131 | i = m_Infolib->error(); | 142 | i = m_Infolib->error(); |
132 | odebug << "Errorcode: " << i << oendl; | 143 | odebug << "Errorcode: " << i << oendl; |
133 | QString msg; | 144 | QString msg; |
134 | msg = QString(tr("Error open file %1: ")).arg(name); | 145 | msg = QString(tr("Error open file %1: ")).arg(name); |
135 | switch (i) { | 146 | switch (i) { |
136 | case 1: | 147 | case 1: |
137 | msg += tr("No input plugin"); | 148 | msg += tr("No input plugin"); |
138 | break; | 149 | break; |
139 | case 2: | 150 | case 2: |
140 | msg += tr("No demuxer plugin"); | 151 | msg += tr("No demuxer plugin"); |
141 | break; | 152 | break; |
142 | case 3: | 153 | case 3: |
143 | msg += tr("Demuxer failed"); | 154 | msg += tr("Demuxer failed"); |
144 | break; | 155 | break; |
145 | case 4: | 156 | case 4: |
146 | msg+=tr("Malformed mrl"); | 157 | msg+=tr("Malformed mrl"); |
147 | break; | 158 | break; |
148 | default: | 159 | default: |
149 | msg += tr("Unknown error"); | 160 | msg += tr("Unknown error"); |
150 | break; | 161 | break; |
151 | } | 162 | } |
152 | QMessageBox::warning(0,tr("Error reading fileheader"),msg); | 163 | QMessageBox::warning(0,tr("Error reading fileheader"),msg); |
@@ -159,113 +170,112 @@ void PlaylistView::addFile(const QString&aFile,const QString&aName) | |||
159 | m_lastItem = new PlaylistItem(aFile,this); | 170 | m_lastItem = new PlaylistItem(aFile,this); |
160 | } | 171 | } |
161 | m_lastItem->setExpandable(false); | 172 | m_lastItem->setExpandable(false); |
162 | m_lastItem->setText(1,name); | 173 | m_lastItem->setText(1,name); |
163 | 174 | ||
164 | QString codec = m_Infolib->metaInfo(6); | 175 | QString codec = m_Infolib->metaInfo(6); |
165 | if (codec.isEmpty()) { | 176 | if (codec.isEmpty()) { |
166 | codec = m_Infolib->metaInfo(7); | 177 | codec = m_Infolib->metaInfo(7); |
167 | } | 178 | } |
168 | // codec | 179 | // codec |
169 | m_lastItem->setText(COL_TYPE,codec); | 180 | m_lastItem->setText(COL_TYPE,codec); |
170 | // title | 181 | // title |
171 | m_lastItem->setText(COL_TITLE,m_Infolib->metaInfo(0)); | 182 | m_lastItem->setText(COL_TITLE,m_Infolib->metaInfo(0)); |
172 | // artist | 183 | // artist |
173 | m_lastItem->setText(COL_ARTIST,m_Infolib->metaInfo(2)); | 184 | m_lastItem->setText(COL_ARTIST,m_Infolib->metaInfo(2)); |
174 | // album | 185 | // album |
175 | m_lastItem->setText(COL_ALBUM,m_Infolib->metaInfo(4)); | 186 | m_lastItem->setText(COL_ALBUM,m_Infolib->metaInfo(4)); |
176 | int l = m_Infolib->length(); | 187 | int l = m_Infolib->length(); |
177 | int h = l/3600; | 188 | int h = l/3600; |
178 | l-=h*3600; | 189 | l-=h*3600; |
179 | int m = l/60; | 190 | int m = l/60; |
180 | l-=m*60; | 191 | l-=m*60; |
181 | codec = ""; | 192 | codec = ""; |
182 | if (h>0) { | 193 | if (h>0) { |
183 | codec+=QString("%1 h").arg(h); | 194 | codec.sprintf("%2i:%2i:%2i h",h,m,l); |
184 | } | 195 | } else { |
185 | if (m>0) { | 196 | codec.sprintf("%02i:%02i m",m,l); |
186 | if (!codec.isEmpty()) codec+=" "; | ||
187 | codec+=QString("%1 m").arg(m); | ||
188 | } | ||
189 | if (l>0) { | ||
190 | if (!codec.isEmpty()) codec+=" "; | ||
191 | codec+=QString("%1 s").arg(l); | ||
192 | } | 197 | } |
193 | // time | 198 | // time |
194 | m_lastItem->setText(COL_TIME,codec); | 199 | m_lastItem->setText(COL_TIME,codec); |
195 | m_lastItem->Video(m_Infolib->hasVideo()); | 200 | m_lastItem->Video(m_Infolib->hasVideo()); |
196 | m_items.append(m_lastItem); | 201 | m_items.append(m_lastItem); |
197 | setSelected(m_lastItem,true); | 202 | setSelected(m_lastItem,true); |
198 | } | 203 | } |
199 | 204 | ||
200 | void PlaylistView::slotAppendDir() | 205 | void PlaylistView::slotAppendDir() |
201 | { | 206 | { |
202 | QString _dir = Opie::Ui::OFileDialog::getDirectory(Opie::Ui::OFileSelector::Extended,m_lastDir,0,m_lastDir); | 207 | QString _dir = Opie::Ui::OFileDialog::getDirectory(Opie::Ui::OFileSelector::Extended,m_lastDir,0,m_lastDir); |
203 | if (_dir.isEmpty()) return; | 208 | if (_dir.isEmpty()) return; |
204 | m_lastDir = _dir; | 209 | m_lastDir = _dir; |
205 | QDir sDir(_dir); | 210 | QDir sDir(_dir); |
206 | QStringList list = sDir.entryList(DEFAULT_FILE_TYPES,QDir::Files,QDir::Name | QDir::IgnoreCase); | 211 | QStringList list = sDir.entryList(DEFAULT_FILE_TYPES,QDir::Files,QDir::Name | QDir::IgnoreCase); |
207 | for (unsigned i = 0; i < list.count();++i) { | 212 | for (unsigned i = 0; i < list.count();++i) { |
208 | addFile(_dir+QString("/")+list[i]); | 213 | addFile(_dir+QString("/")+list[i]); |
209 | } | 214 | } |
210 | emit contentChanged(childCount()); | 215 | emit contentChanged(childCount()); |
211 | } | 216 | } |
212 | 217 | ||
213 | void PlaylistView::slotOpenM3u() | 218 | void PlaylistView::slotOpenM3u() |
214 | { | 219 | { |
215 | QStringList types; | 220 | QStringList types; |
216 | QMap<QString, QStringList> mimeTypes; | 221 | QMap<QString, QStringList> mimeTypes; |
217 | types << "audio/x-mpegurl"; | 222 | types << "audio/x-mpegurl"; |
218 | mimeTypes.insert("Playlists",types); | 223 | mimeTypes.insert("Playlists",types); |
219 | mimeTypes.insert("All",types); | 224 | // mimeTypes.insert("All",types); |
220 | QString fileName= Opie::Ui::OFileDialog::getOpenFileName(Opie::Ui::OFileSelector::EXTENDED, | 225 | QString fileName= Opie::Ui::OFileDialog::getOpenFileName(Opie::Ui::OFileSelector::EXTENDED, |
221 | m_lastDir,"playlist.m3u", mimeTypes); | 226 | m_lastDir,"playlist.m3u", mimeTypes); |
222 | if (fileName.isEmpty()) { | 227 | if (fileName.isEmpty()) { |
223 | return; | 228 | return; |
224 | } | 229 | } |
230 | readPlayList(fileName); | ||
231 | emit contentChanged(childCount()); | ||
232 | } | ||
233 | |||
234 | void PlaylistView::readPlayList(const QString&fileName) | ||
235 | { | ||
225 | QFileInfo f(fileName); | 236 | QFileInfo f(fileName); |
226 | 237 | ||
227 | Om3u _om3u(fileName, IO_ReadOnly); | 238 | Om3u _om3u(fileName, IO_ReadOnly); |
228 | if (f.extension(FALSE).lower()=="m3u") { | 239 | if (f.extension(FALSE).lower()=="m3u") { |
229 | _om3u.readM3u(); | 240 | _om3u.readM3u(); |
230 | } else if (f.extension(FALSE).lower()=="pls") { | 241 | } else if (f.extension(FALSE).lower()=="pls") { |
231 | _om3u.readPls(); | 242 | _om3u.readPls(); |
232 | } | 243 | } |
233 | for (unsigned int j=0; j<_om3u.count();++j) { | 244 | for (unsigned int j=0; j<_om3u.count();++j) { |
234 | addFile(_om3u[j]); | 245 | addFile(_om3u[j]); |
235 | } | 246 | } |
236 | emit contentChanged(childCount()); | ||
237 | } | 247 | } |
238 | 248 | ||
239 | void PlaylistView::slotSaveAsM3u() | 249 | void PlaylistView::slotSaveAsM3u() |
240 | { | 250 | { |
241 | QStringList types; | 251 | QStringList types; |
242 | QMap<QString, QStringList> mimeTypes; | 252 | QMap<QString, QStringList> mimeTypes; |
243 | types << "audio/x-mpegurl"; | 253 | types << "audio/x-mpegurl"; |
244 | mimeTypes.insert("Playlists",types); | 254 | mimeTypes.insert("Playlists",types); |
245 | mimeTypes.insert("All",types); | ||
246 | QString fileName= Opie::Ui::OFileDialog::getSaveFileName(Opie::Ui::OFileSelector::EXTENDED, | 255 | QString fileName= Opie::Ui::OFileDialog::getSaveFileName(Opie::Ui::OFileSelector::EXTENDED, |
247 | m_lastDir,"playlist.m3u", mimeTypes); | 256 | m_lastDir,"playlist.m3u", mimeTypes); |
257 | odebug << "Save as " << fileName << oendl; | ||
248 | if (fileName.isEmpty()) { | 258 | if (fileName.isEmpty()) { |
249 | return; | 259 | return; |
250 | } | 260 | } |
251 | Om3u _om3u(fileName, IO_ReadWrite | IO_Truncate); | 261 | Om3u _om3u(fileName, IO_ReadWrite | IO_Truncate); |
252 | for (unsigned j=0; j<m_items.count();++j) { | 262 | for (unsigned j=0; j<m_items.count();++j) { |
253 | _om3u.add(m_items[j]->Lnk().file()); | 263 | _om3u.add(m_items[j]->Lnk().file()); |
254 | } | 264 | } |
255 | _om3u.write(); | 265 | _om3u.write(); |
256 | } | 266 | } |
257 | 267 | ||
258 | void PlaylistView::removeFromList(PlaylistItem*Item) | 268 | void PlaylistView::removeFromList(PlaylistItem*Item) |
259 | { | 269 | { |
260 | if (!Item)return; | 270 | if (!Item)return; |
261 | t_itemlist::Iterator iter,it2; | 271 | t_itemlist::Iterator iter,it2; |
262 | iter = m_items.find(Item); | 272 | iter = m_items.find(Item); |
263 | it2 = m_items.end(); | 273 | it2 = m_items.end(); |
264 | if (iter!=m_items.end()) { | 274 | if (iter!=m_items.end()) { |
265 | it2 = iter; | 275 | it2 = iter; |
266 | ++it2; | 276 | ++it2; |
267 | m_items.remove(iter); | 277 | m_items.remove(iter); |
268 | } | 278 | } |
269 | delete Item; | 279 | delete Item; |
270 | if (it2!=m_items.end()) { | 280 | if (it2!=m_items.end()) { |
271 | setSelected((*it2),true); | 281 | setSelected((*it2),true); |
diff --git a/noncore/multimedia/opieplayer3/playlist.h b/noncore/multimedia/opieplayer3/playlist.h index 4a9268c..3c9a68d 100644 --- a/noncore/multimedia/opieplayer3/playlist.h +++ b/noncore/multimedia/opieplayer3/playlist.h | |||
@@ -74,35 +74,37 @@ public: | |||
74 | PlaylistItem* nextItem(PlaylistItem*parent)const; | 74 | PlaylistItem* nextItem(PlaylistItem*parent)const; |
75 | PlaylistItem* prevItem(PlaylistItem*parent)const; | 75 | PlaylistItem* prevItem(PlaylistItem*parent)const; |
76 | 76 | ||
77 | void removeFromList(PlaylistItem*Item); | 77 | void removeFromList(PlaylistItem*Item); |
78 | 78 | ||
79 | enum itemcolumns{ | 79 | enum itemcolumns{ |
80 | COL_ICON=0, | 80 | COL_ICON=0, |
81 | COL_FILE=1, | 81 | COL_FILE=1, |
82 | COL_TIME=2, | 82 | COL_TIME=2, |
83 | COL_ARTIST=3, | 83 | COL_ARTIST=3, |
84 | COL_ALBUM=4, | 84 | COL_ALBUM=4, |
85 | COL_TITLE=5, | 85 | COL_TITLE=5, |
86 | COL_TYPE=6, | 86 | COL_TYPE=6, |
87 | COL_SIZE=7 | 87 | COL_SIZE=7 |
88 | }; | 88 | }; |
89 | void addFile(const QString&aFile,const QString&aName=""); | 89 | void addFile(const QString&aFile,const QString&aName=""); |
90 | signals: | 90 | signals: |
91 | void contentChanged(int); | 91 | void contentChanged(int); |
92 | 92 | ||
93 | public slots: | 93 | public slots: |
94 | virtual void slotAddFile(const DocLnk&); | 94 | virtual void slotAddFile(const DocLnk&); |
95 | virtual void slotAppendDir(); | 95 | virtual void slotAppendDir(); |
96 | virtual void slotOpenM3u(); | 96 | virtual void slotOpenM3u(); |
97 | virtual void slotSaveAsM3u(); | 97 | virtual void slotSaveAsM3u(); |
98 | virtual void slotDummyStop(); | ||
98 | 99 | ||
99 | protected: | 100 | protected: |
100 | void checkLib(); | 101 | void checkLib(); |
102 | void readPlayList(const QString&); | ||
101 | QStringList columnLabels; | 103 | QStringList columnLabels; |
102 | XINE::Lib*m_Infolib; | 104 | XINE::Lib*m_Infolib; |
103 | PlaylistItem*m_lastItem; | 105 | PlaylistItem*m_lastItem; |
104 | t_itemlist m_items; | 106 | t_itemlist m_items; |
105 | QString m_lastDir; | 107 | QString m_lastDir; |
106 | }; | 108 | }; |
107 | 109 | ||
108 | #endif | 110 | #endif |
diff --git a/noncore/multimedia/opieplayer3/videowidget.cpp b/noncore/multimedia/opieplayer3/videowidget.cpp index a28d47d..833ecb4 100644 --- a/noncore/multimedia/opieplayer3/videowidget.cpp +++ b/noncore/multimedia/opieplayer3/videowidget.cpp | |||
@@ -1,145 +1,100 @@ | |||
1 | #include "videowidget.h" | 1 | #include "videowidget.h" |
2 | #include "../opieplayer2/lib.h" | 2 | #include "../opieplayer2/lib.h" |
3 | #include "../opieplayer2/threadutil.h" | 3 | #include "../opieplayer2/threadutil.h" |
4 | #include "../opieplayer2/xinevideowidget.h" | 4 | #include "../opieplayer2/xinevideowidget.h" |
5 | 5 | ||
6 | #include <opie2/odebug.h> | 6 | #include <opie2/odebug.h> |
7 | 7 | ||
8 | #include <qpe/qpeapplication.h> | 8 | #include <qpe/qpeapplication.h> |
9 | 9 | ||
10 | #include <qlayout.h> | 10 | #include <qlayout.h> |
11 | #include <qslider.h> | 11 | #include <qslider.h> |
12 | #include <qlabel.h> | 12 | #include <qlabel.h> |
13 | 13 | ||
14 | VideoWidget::VideoWidget( QWidget * parent, const char * name, WFlags f) | 14 | VideoWidget::VideoWidget( QWidget * parent, const char * name, WFlags f) |
15 | :QWidget(parent,name,f) | 15 | :QWidget(parent,name,f) |
16 | { | 16 | { |
17 | m_xineLib = 0; | 17 | m_xineLib = 0; |
18 | 18 | m_scaleUp = false; | |
19 | m_MainLayout = new QVBoxLayout(this); | 19 | m_MainLayout = new QVBoxLayout(this); |
20 | m_MainLayout->setAutoAdd(true); | 20 | m_MainLayout->setAutoAdd(true); |
21 | m_Videodisplay = new XineVideoWidget(this,"videodisp"); | 21 | m_Videodisplay = new XineVideoWidget(this,"videodisp"); |
22 | #if 0 | ||
23 | m_PosSlider = new QSlider(QSlider::Horizontal,this); | ||
24 | m_PosSlider->setTickInterval(60); | ||
25 | connect(m_PosSlider,SIGNAL(valueChanged(int)),this,SLOT(slotNewPos(int))); | ||
26 | connect(m_PosSlider,SIGNAL(sliderMoved(int)),this,SLOT(slotNewPos(int))); | ||
27 | connect(m_PosSlider,SIGNAL(sliderPressed()),this,SLOT(sliderPressed())); | ||
28 | connect(m_PosSlider,SIGNAL(sliderReleased()),this,SLOT(sliderReleased())); | ||
29 | #endif | ||
30 | connect(m_Videodisplay,SIGNAL(videoResized ( const QSize & )),this,SLOT(slot_Videoresized(const QSize&))); | 22 | connect(m_Videodisplay,SIGNAL(videoResized ( const QSize & )),this,SLOT(slot_Videoresized(const QSize&))); |
31 | connect(m_Videodisplay,SIGNAL(clicked()),this,SLOT(slotClicked())); | 23 | connect(m_Videodisplay,SIGNAL(clicked()),this,SLOT(slotClicked())); |
32 | #if 0 | ||
33 | m_pressed = false; | ||
34 | m_uppos=0; | ||
35 | #endif | ||
36 | } | 24 | } |
37 | 25 | ||
38 | VideoWidget::~VideoWidget() | 26 | VideoWidget::~VideoWidget() |
39 | { | 27 | { |
40 | } | 28 | } |
41 | 29 | ||
42 | void VideoWidget::slotClicked() | 30 | void VideoWidget::slotClicked() |
43 | { | 31 | { |
44 | odebug << "clicked " << oendl; | ||
45 | emit videoclicked(); | 32 | emit videoclicked(); |
46 | } | 33 | } |
47 | 34 | ||
48 | void VideoWidget::closeEvent(QCloseEvent*e) | 35 | void VideoWidget::closeEvent(QCloseEvent*e) |
49 | { | 36 | { |
50 | } | 37 | } |
51 | 38 | ||
52 | void VideoWidget::slotNewPos(int /*pos*/) | ||
53 | { | ||
54 | #if 0 | ||
55 | if (!m_xineLib) return; | ||
56 | if (m_uppos==pos) return; | ||
57 | m_xineLib->seekTo(pos); | ||
58 | #endif | ||
59 | } | ||
60 | |||
61 | void VideoWidget::sliderPressed() | ||
62 | { | ||
63 | #if 0 | ||
64 | m_pressed = true; | ||
65 | #endif | ||
66 | } | ||
67 | |||
68 | void VideoWidget::sliderReleased() | ||
69 | { | ||
70 | #if 0 | ||
71 | m_pressed = false; | ||
72 | #endif | ||
73 | } | ||
74 | |||
75 | void VideoWidget::fullScreen(bool /* how */) | 39 | void VideoWidget::fullScreen(bool /* how */) |
76 | { | 40 | { |
77 | #if 0 | ||
78 | if (how) { | ||
79 | m_PosSlider->hide(); | ||
80 | } else { | ||
81 | m_PosSlider->show(); | ||
82 | } | ||
83 | #endif | ||
84 | } | 41 | } |
85 | 42 | ||
86 | int VideoWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib) | 43 | int VideoWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib) |
87 | { | 44 | { |
88 | m_current = aLnk; | 45 | m_current = aLnk; |
89 | bool recon; | 46 | bool recon; |
90 | if (m_xineLib != aLib) { | 47 | if (m_xineLib != aLib) { |
91 | if (m_xineLib) disconnect(m_xineLib); | 48 | if (m_xineLib) disconnect(m_xineLib); |
92 | m_xineLib = aLib; | 49 | m_xineLib = aLib; |
93 | if (aLib) m_xineLib->setWidget(m_Videodisplay); | 50 | if (aLib) m_xineLib->setWidget(m_Videodisplay); |
94 | } | 51 | } |
95 | if (!m_xineLib) { | 52 | if (!m_xineLib) { |
96 | return -1; | 53 | return -1; |
97 | } | 54 | } |
98 | connect(m_xineLib,SIGNAL(stopped()),this,SLOT(slotStopped())); | 55 | connect(m_xineLib,SIGNAL(stopped()),this,SLOT(slotStopped())); |
99 | #if 0 | ||
100 | m_uppos=0; | ||
101 | m_PosSlider->setValue(0); | ||
102 | #endif | ||
103 | m_xineLib->setWidget(m_Videodisplay); | 56 | m_xineLib->setWidget(m_Videodisplay); |
104 | m_xineLib->setShowVideo(true); | 57 | m_xineLib->setShowVideo(true); |
105 | m_xineLib->resize(m_Videodisplay->size()); | ||
106 | int res = m_xineLib->play(m_current.file()); | 58 | int res = m_xineLib->play(m_current.file()); |
59 | vSize = m_xineLib->videoSize(); | ||
60 | slot_Videoresized(m_Videodisplay->size()); | ||
107 | odebug << "Xine play: " << res << oendl; | 61 | odebug << "Xine play: " << res << oendl; |
108 | if (res != 1) { | 62 | if (res != 1) { |
109 | return -2; | 63 | return -2; |
110 | } | 64 | } |
111 | return m_xineLib->length(); | 65 | return m_xineLib->length(); |
112 | #if 0 | ||
113 | m_PosSlider->setRange(0,l); | ||
114 | m_PosSlider->setPageStep(l/10); | ||
115 | #endif | ||
116 | } | 66 | } |
117 | 67 | ||
118 | void VideoWidget::stopPlaying() | 68 | void VideoWidget::stopPlaying() |
119 | { | 69 | { |
120 | if (m_xineLib) { | 70 | if (m_xineLib) { |
121 | m_xineLib->stop(); | 71 | m_xineLib->stop(); |
122 | } | 72 | } |
123 | } | 73 | } |
124 | 74 | ||
125 | void VideoWidget::slotStopped() | 75 | void VideoWidget::slotStopped() |
126 | { | 76 | { |
127 | // check fullscreen here! | ||
128 | } | 77 | } |
129 | 78 | ||
130 | void VideoWidget::slot_Videoresized(const QSize&s) | 79 | void VideoWidget::slot_Videoresized(const QSize&s) |
131 | { | 80 | { |
132 | odebug << "Videoresized: " << s << oendl; | ||
133 | if (m_xineLib) { | 81 | if (m_xineLib) { |
134 | m_xineLib->resize(s); | 82 | if (vSize.width()<s.width()&&vSize.height()<s.height()&&!m_scaleUp) { |
83 | m_xineLib->resize(vSize); | ||
84 | } else { | ||
85 | m_xineLib->resize(s); | ||
86 | } | ||
135 | } | 87 | } |
136 | } | 88 | } |
137 | 89 | ||
90 | void VideoWidget::scaleUp(bool how) | ||
91 | { | ||
92 | if (how == m_scaleUp) return; | ||
93 | m_scaleUp = how; | ||
94 | slot_Videoresized(m_Videodisplay->size()); | ||
95 | m_Videodisplay->repaint(); | ||
96 | } | ||
97 | |||
138 | void VideoWidget::updatePos(int /*val*/) | 98 | void VideoWidget::updatePos(int /*val*/) |
139 | { | 99 | { |
140 | #if 0 | ||
141 | if (m_pressed) return; | ||
142 | m_uppos = val; | ||
143 | m_PosSlider->setValue(val); | ||
144 | #endif | ||
145 | } | 100 | } |
diff --git a/noncore/multimedia/opieplayer3/videowidget.h b/noncore/multimedia/opieplayer3/videowidget.h index 935a648..e082407 100644 --- a/noncore/multimedia/opieplayer3/videowidget.h +++ b/noncore/multimedia/opieplayer3/videowidget.h | |||
@@ -1,55 +1,50 @@ | |||
1 | #ifndef __videowidget_h | 1 | #ifndef __videowidget_h |
2 | #define __videowidget_h | 2 | #define __videowidget_h |
3 | #include <qwidget.h> | 3 | #include <qwidget.h> |
4 | 4 | ||
5 | #include <qpe/applnk.h> | 5 | #include <qpe/applnk.h> |
6 | 6 | ||
7 | namespace XINE { | 7 | namespace XINE { |
8 | class Lib; | 8 | class Lib; |
9 | } | 9 | } |
10 | 10 | ||
11 | class QVBoxLayout; | 11 | class QVBoxLayout; |
12 | class QSlider; | 12 | class QSlider; |
13 | class QLabel; | 13 | class QLabel; |
14 | class XineVideoWidget; | 14 | class XineVideoWidget; |
15 | 15 | ||
16 | class VideoWidget:public QWidget | 16 | class VideoWidget:public QWidget |
17 | { | 17 | { |
18 | Q_OBJECT | 18 | Q_OBJECT |
19 | public: | 19 | public: |
20 | VideoWidget( QWidget * parent=0, const char * name=0, WFlags f=0 ); | 20 | VideoWidget( QWidget * parent=0, const char * name=0, WFlags f=0 ); |
21 | virtual ~VideoWidget(); | 21 | virtual ~VideoWidget(); |
22 | 22 | ||
23 | int playFile(const DocLnk&,XINE::Lib*); | 23 | int playFile(const DocLnk&,XINE::Lib*); |
24 | void fullScreen(bool how); | 24 | void fullScreen(bool how); |
25 | void scaleUp(bool how); | ||
25 | 26 | ||
26 | signals: | 27 | signals: |
27 | void videoclicked(); | 28 | void videoclicked(); |
28 | 29 | ||
29 | public slots: | 30 | public slots: |
30 | virtual void stopPlaying(); | 31 | virtual void stopPlaying(); |
31 | virtual void updatePos(int); | 32 | virtual void updatePos(int); |
32 | 33 | ||
33 | protected: | 34 | protected: |
34 | XINE::Lib*m_xineLib; | 35 | XINE::Lib*m_xineLib; |
35 | DocLnk m_current; | 36 | DocLnk m_current; |
36 | QVBoxLayout*m_MainLayout; | 37 | QVBoxLayout*m_MainLayout; |
37 | XineVideoWidget*m_Videodisplay; | 38 | XineVideoWidget*m_Videodisplay; |
38 | QWidget * m_holder; | 39 | QWidget * m_holder; |
39 | #if 0 | 40 | QSize vSize; |
40 | QSlider*m_PosSlider; | 41 | bool m_scaleUp:1; |
41 | bool m_pressed:1; | ||
42 | int m_uppos; | ||
43 | #endif | ||
44 | 42 | ||
45 | protected slots: | 43 | protected slots: |
46 | virtual void closeEvent(QCloseEvent*e); | 44 | virtual void closeEvent(QCloseEvent*e); |
47 | virtual void slotNewPos(int pos); | ||
48 | virtual void sliderPressed(); | ||
49 | virtual void sliderReleased(); | ||
50 | virtual void slot_Videoresized(const QSize&); | 45 | virtual void slot_Videoresized(const QSize&); |
51 | virtual void slotStopped(); | 46 | virtual void slotStopped(); |
52 | virtual void slotClicked(); | 47 | virtual void slotClicked(); |
53 | }; | 48 | }; |
54 | 49 | ||
55 | #endif | 50 | #endif |