summaryrefslogtreecommitdiff
authoralwin <alwin>2005-04-14 09:23:25 (UTC)
committer alwin <alwin>2005-04-14 09:23:25 (UTC)
commitc643e152dc7d2167381d3fc0568ad4043de5604e (patch) (unidiff)
tree3050f49d659a1d6eb54cca2a08ed64cf0d04842a
parentcb10570b4118161a066b741c2674d8d522670623 (diff)
downloadopie-c643e152dc7d2167381d3fc0568ad4043de5604e.zip
opie-c643e152dc7d2167381d3fc0568ad4043de5604e.tar.gz
opie-c643e152dc7d2167381d3fc0568ad4043de5604e.tar.bz2
gui polish
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer3/mwindow.cpp9
-rw-r--r--noncore/multimedia/opieplayer3/mwindow.h1
-rw-r--r--noncore/multimedia/opieplayer3/playlist.cpp6
-rw-r--r--noncore/multimedia/opieplayer3/videowidget.cpp1
4 files changed, 14 insertions, 3 deletions
diff --git a/noncore/multimedia/opieplayer3/mwindow.cpp b/noncore/multimedia/opieplayer3/mwindow.cpp
index 75d1490..0898c7b 100644
--- a/noncore/multimedia/opieplayer3/mwindow.cpp
+++ b/noncore/multimedia/opieplayer3/mwindow.cpp
@@ -30,51 +30,52 @@
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include "mwindow.h" 34#include "mwindow.h"
35#include "playlist.h" 35#include "playlist.h"
36#include "audiowidget.h" 36#include "audiowidget.h"
37#include "videowidget.h" 37#include "videowidget.h"
38#include "../opieplayer2/lib.h" 38#include "../opieplayer2/lib.h"
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#include <qpe/qpeapplication.h>
46 47
47#include <qfileinfo.h> 48#include <qfileinfo.h>
48#include <qfile.h> 49#include <qfile.h>
49#include <qtoolbar.h> 50#include <qtoolbar.h>
50#include <qpopupmenu.h> 51#include <qpopupmenu.h>
51#include <qmenubar.h> 52#include <qmenubar.h>
52#include <qtimer.h> 53#include <qtimer.h>
53#include <qslider.h> 54#include <qslider.h>
54#include <qlayout.h> 55#include <qlayout.h>
55 56
56OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) 57OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>)
57 58
58using namespace Opie::Ui; 59using namespace Opie::Ui;
59 60
60PMainWindow::PMainWindow(QWidget*w, const char*name, WFlags f) 61PMainWindow::PMainWindow(QWidget*w, const char*name, WFlags f)
61 : QMainWindow(w,name,f) 62 : QMainWindow(w,name,f)
62{ 63{
63 checkLib(); 64 checkLib();
64 setCaption( QObject::tr("Opie Mediaplayer 3" ) ); 65 setCaption(appTitle());
65 66
66 m_MainBox = new QWidget(this); 67 m_MainBox = new QWidget(this);
67 68
68 QVBoxLayout*m_l = new QVBoxLayout(m_MainBox); 69 QVBoxLayout*m_l = new QVBoxLayout(m_MainBox);
69 70
70 m_stack = new OWidgetStack(m_MainBox); 71 m_stack = new OWidgetStack(m_MainBox);
71 m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen); 72 m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen);
72 m_l->addWidget(m_stack); 73 m_l->addWidget(m_stack);
73 m_PosSlider = new QSlider(QSlider::Horizontal,m_MainBox); 74 m_PosSlider = new QSlider(QSlider::Horizontal,m_MainBox);
74 m_l->addWidget(m_PosSlider); 75 m_l->addWidget(m_PosSlider);
75 m_PosSlider->setEnabled(false); 76 m_PosSlider->setEnabled(false);
76 77
77 m_playList = new PlaylistView(m_stack,"playlist"); 78 m_playList = new PlaylistView(m_stack,"playlist");
78 m_stack->addWidget(m_playList,stack_list); 79 m_stack->addWidget(m_playList,stack_list);
79 connect(m_playList,SIGNAL(contentChanged(int)),this,SLOT(slotListChanged(int))); 80 connect(m_playList,SIGNAL(contentChanged(int)),this,SLOT(slotListChanged(int)));
80 m_sfl = new OFileSelector("video/*;audio/*",m_stack); 81 m_sfl = new OFileSelector("video/*;audio/*",m_stack);
@@ -198,32 +199,33 @@ void PMainWindow::slotPlayList()
198 if (!m_LastItem) { 199 if (!m_LastItem) {
199 slotPlayNext(); 200 slotPlayNext();
200 return; 201 return;
201 } 202 }
202 //m_VideoPlayer->setFullScreen(a_ShowFull->isOn()); 203 //m_VideoPlayer->setFullScreen(a_ShowFull->isOn());
203 slotPlayCurrent(); 204 slotPlayCurrent();
204} 205}
205 206
206void PMainWindow::slotUserStop() 207void PMainWindow::slotUserStop()
207{ 208{
208 if (!m_playing || !m_PlayLib) return; 209 if (!m_playing || !m_PlayLib) return;
209 m_playing = false; 210 m_playing = false;
210 m_PlayLib->stop(); 211 m_PlayLib->stop();
211 m_PosSlider->setEnabled(false); 212 m_PosSlider->setEnabled(false);
212 hideVideo(); 213 hideVideo();
213 slotShowList(); 214 slotShowList();
215 setCaption(appTitle());
214} 216}
215 217
216void PMainWindow::slotTogglePlay(bool how) 218void PMainWindow::slotTogglePlay(bool how)
217{ 219{
218 if (how == m_playing) { 220 if (how == m_playing) {
219 if (how) { 221 if (how) {
220 slotShowMediaWindow(); 222 slotShowMediaWindow();
221 } 223 }
222 return; 224 return;
223 } 225 }
224 if (how) { 226 if (how) {
225 slotPlayList(); 227 slotPlayList();
226 } else { 228 } else {
227 slotUserStop(); 229 slotUserStop();
228 } 230 }
229} 231}
@@ -231,54 +233,56 @@ void PMainWindow::slotTogglePlay(bool how)
231void PMainWindow::hideVideo() 233void PMainWindow::hideVideo()
232{ 234{
233 if (m_VideoPlayer->isVisible() && a_ShowFull->isOn()) { 235 if (m_VideoPlayer->isVisible() && a_ShowFull->isOn()) {
234 //m_VideoPlayer->showNormal(); 236 //m_VideoPlayer->showNormal();
235 m_VideoPlayer->hide(); 237 m_VideoPlayer->hide();
236 } 238 }
237} 239}
238 240
239void PMainWindow::slotPlayCurrent() 241void PMainWindow::slotPlayCurrent()
240{ 242{
241 if (!m_LastItem) { 243 if (!m_LastItem) {
242 if (m_PlayLib) m_PlayLib->stop(); 244 if (m_PlayLib) m_PlayLib->stop();
243 m_PosSlider->setEnabled(false); 245 m_PosSlider->setEnabled(false);
244 a_playAction->setOn(false); 246 a_playAction->setOn(false);
245 hideVideo(); 247 hideVideo();
246 slotShowList(); 248 slotShowList();
249 setCaption(appTitle());
247 return; 250 return;
248 } 251 }
249 m_CurrentPos = 0; 252 m_CurrentPos = 0;
250 m_playList->setCurrentItem(m_LastItem); 253 m_playList->setCurrentItem(m_LastItem);
251 m_uppos = 0; 254 m_uppos = 0;
252 m_PosSlider->setValue(0); 255 m_PosSlider->setValue(0);
253 int result = 0; 256 int result = 0;
254 if (!m_LastItem->isVideo()) { 257 if (!m_LastItem->isVideo()) {
255 hideVideo(); 258 hideVideo();
256 m_playing = true; 259 m_playing = true;
257 m_stack->raiseWidget(stack_audio); 260 m_stack->raiseWidget(stack_audio);
258 result = m_AudioPlayer->playFile(m_LastItem->Lnk(),m_PlayLib); 261 result = m_AudioPlayer->playFile(m_LastItem->Lnk(),m_PlayLib);
259 } else { 262 } else {
260 m_playing = true; 263 m_playing = true;
261 setupVideo(a_ShowFull->isOn()); 264 setupVideo(a_ShowFull->isOn());
262 result = m_VideoPlayer->playFile(m_LastItem->Lnk(),m_PlayLib); 265 result = m_VideoPlayer->playFile(m_LastItem->Lnk(),m_PlayLib);
263 } 266 }
264 if (result<0) { 267 if (result<0) {
265 // fehler 268 // fehler
266 return; 269 return;
267 } 270 }
268 mediaWindowraised(); 271 mediaWindowraised();
272 setCaption(appTitle()+" - "+m_LastItem->Lnk().name());
269 odebug << "Range: " << result << oendl; 273 odebug << "Range: " << result << oendl;
270 m_PosSlider->setEnabled(true); 274 m_PosSlider->setEnabled(true);
271 m_PosSlider->setRange(0,m_PlayLib->length()); 275 m_PosSlider->setRange(0,m_PlayLib->length());
272 m_PosSlider->setValue(m_PlayLib->currentTime()); 276 m_PosSlider->setValue(m_PlayLib->currentTime());
273 QTimer::singleShot( 500, this, SLOT( slotCheckPos() ) ); 277 QTimer::singleShot( 500, this, SLOT( slotCheckPos() ) );
274} 278}
275 279
276void PMainWindow::slotPlayNext() 280void PMainWindow::slotPlayNext()
277{ 281{
278 PlaylistItem*item = m_playList->nextItem(m_LastItem); 282 PlaylistItem*item = m_playList->nextItem(m_LastItem);
279 if (!item) return; 283 if (!item) return;
280 m_LastItem = item; 284 m_LastItem = item;
281 slotPlayCurrent(); 285 slotPlayCurrent();
282} 286}
283 287
284void PMainWindow::slotGoNext() 288void PMainWindow::slotGoNext()
@@ -298,33 +302,34 @@ void PMainWindow::slotPlayPrevious()
298void PMainWindow::slotStopped() 302void PMainWindow::slotStopped()
299{ 303{
300 if (!m_playing) return; 304 if (!m_playing) return;
301 odebug << "Slot stopped" << oendl; 305 odebug << "Slot stopped" << oendl;
302 m_playing = false; 306 m_playing = false;
303 slotGoNext(); 307 slotGoNext();
304} 308}
305 309
306void PMainWindow::slotCheckPos() 310void PMainWindow::slotCheckPos()
307{ 311{
308 if (!m_playing) return; 312 if (!m_playing) return;
309 if (!m_pressed) { 313 if (!m_pressed) {
310 m_uppos = m_PlayLib->currentTime(); 314 m_uppos = m_PlayLib->currentTime();
311 emit sigPos(m_uppos); 315 emit sigPos(m_uppos);
312 m_PosSlider->setValue(m_PlayLib->currentTime()); 316 m_PosSlider->setValue(m_PlayLib->currentTime());
313 } 317 }
314 QTimer::singleShot( 1000, this, SLOT( slotCheckPos() ) ); 318 qApp->processEvents(100);
319 QTimer::singleShot( 900, this, SLOT( slotCheckPos() ) );
315} 320}
316 321
317void PMainWindow::slotRemoveFiles() 322void PMainWindow::slotRemoveFiles()
318{ 323{
319 if (m_playing||!m_playList->isVisible()) return; 324 if (m_playing||!m_playList->isVisible()) return;
320 PlaylistItem* Item = m_playList->currentItem(); 325 PlaylistItem* Item = m_playList->currentItem();
321 slotShowList(); 326 slotShowList();
322 m_playList->removeFromList(Item); 327 m_playList->removeFromList(Item);
323} 328}
324 329
325void PMainWindow::setupActions() 330void PMainWindow::setupActions()
326{ 331{
327 a_appendFiles = new QAction(tr("Append file(s)"),Resource::loadIconSet( "opieplayer2/add_to_playlist" ), 0, 0, this, 0, false ); 332 a_appendFiles = new QAction(tr("Append file(s)"),Resource::loadIconSet( "opieplayer2/add_to_playlist" ), 0, 0, this, 0, false );
328 connect(a_appendFiles,SIGNAL(activated()),this,SLOT(slotAppendFiles())); 333 connect(a_appendFiles,SIGNAL(activated()),this,SLOT(slotAppendFiles()));
329 a_addDir = new QAction(tr("Add directory"),Resource::loadIconSet("folder_open"),0,0,this,0,false); 334 a_addDir = new QAction(tr("Add directory"),Resource::loadIconSet("folder_open"),0,0,this,0,false);
330 connect(a_addDir,SIGNAL(activated()),m_playList,SLOT(slotAppendDir())); 335 connect(a_addDir,SIGNAL(activated()),m_playList,SLOT(slotAppendDir()));
diff --git a/noncore/multimedia/opieplayer3/mwindow.h b/noncore/multimedia/opieplayer3/mwindow.h
index 5d011d5..3ea9a52 100644
--- a/noncore/multimedia/opieplayer3/mwindow.h
+++ b/noncore/multimedia/opieplayer3/mwindow.h
@@ -51,32 +51,33 @@ namespace XINE {
51 class Lib; 51 class Lib;
52} 52}
53 53
54class PlaylistView; 54class PlaylistView;
55class QToolBar; 55class QToolBar;
56class QPopupMenu; 56class QPopupMenu;
57class QMenuBar; 57class QMenuBar;
58class AudioWidget; 58class AudioWidget;
59class VideoWidget; 59class VideoWidget;
60class PlaylistItem; 60class PlaylistItem;
61class QSlider; 61class QSlider;
62 62
63class PMainWindow : public QMainWindow { 63class PMainWindow : public QMainWindow {
64 Q_OBJECT 64 Q_OBJECT
65public: 65public:
66 static QString appName() { return QString::fromLatin1("opie-mediaplayer3" ); } 66 static QString appName() { return QString::fromLatin1("opie-mediaplayer3" ); }
67 static QString appTitle() {return QString::fromLatin1("Opie Mediaplayer 3" ); }
67 PMainWindow(QWidget*, const char*, WFlags ); 68 PMainWindow(QWidget*, const char*, WFlags );
68 virtual ~PMainWindow(); 69 virtual ~PMainWindow();
69 70
70public slots: 71public slots:
71 virtual void slotVideoclicked(); 72 virtual void slotVideoclicked();
72protected: 73protected:
73 74
74 /* GUI parts */ 75 /* GUI parts */
75 static const int stack_list = 0; 76 static const int stack_list = 0;
76 static const int stack_file = 1; 77 static const int stack_file = 1;
77 static const int stack_audio = 2; 78 static const int stack_audio = 2;
78 static const int stack_video = 3; 79 static const int stack_video = 3;
79 Opie::Ui::OWidgetStack *m_stack; 80 Opie::Ui::OWidgetStack *m_stack;
80 Opie::Ui::OFileSelector*m_sfl; 81 Opie::Ui::OFileSelector*m_sfl;
81 PlaylistView*m_playList; 82 PlaylistView*m_playList;
82 AudioWidget*m_AudioPlayer; 83 AudioWidget*m_AudioPlayer;
diff --git a/noncore/multimedia/opieplayer3/playlist.cpp b/noncore/multimedia/opieplayer3/playlist.cpp
index 2eb40e3..6f2e668 100644
--- a/noncore/multimedia/opieplayer3/playlist.cpp
+++ b/noncore/multimedia/opieplayer3/playlist.cpp
@@ -151,32 +151,34 @@ void PlaylistView::addFile(const QString&aFile,const QString&aName)
151 msg += tr("No demuxer plugin"); 151 msg += tr("No demuxer plugin");
152 break; 152 break;
153 case 3: 153 case 3:
154 msg += tr("Demuxer failed"); 154 msg += tr("Demuxer failed");
155 break; 155 break;
156 case 4: 156 case 4:
157 msg+=tr("Malformed mrl"); 157 msg+=tr("Malformed mrl");
158 break; 158 break;
159 default: 159 default:
160 msg += tr("Unknown error"); 160 msg += tr("Unknown error");
161 break; 161 break;
162 } 162 }
163 QMessageBox::warning(0,tr("Error reading fileheader"),msg); 163 QMessageBox::warning(0,tr("Error reading fileheader"),msg);
164 return; 164 return;
165 } 165 }
166 m_lastItem = m_items.last(); 166 m_lastItem = m_items.last();
167 PlaylistItem*_it = currentItem();
168
167 if (m_lastItem) { 169 if (m_lastItem) {
168 m_lastItem = new PlaylistItem(aFile,this,m_lastItem); 170 m_lastItem = new PlaylistItem(aFile,this,m_lastItem);
169 } else { 171 } else {
170 m_lastItem = new PlaylistItem(aFile,this); 172 m_lastItem = new PlaylistItem(aFile,this);
171 } 173 }
172 m_lastItem->setExpandable(false); 174 m_lastItem->setExpandable(false);
173 m_lastItem->setText(1,name); 175 m_lastItem->setText(1,name);
174 176
175 QString codec = m_Infolib->metaInfo(6); 177 QString codec = m_Infolib->metaInfo(6);
176 if (codec.isEmpty()) { 178 if (codec.isEmpty()) {
177 codec = m_Infolib->metaInfo(7); 179 codec = m_Infolib->metaInfo(7);
178 } 180 }
179 // codec 181 // codec
180 m_lastItem->setText(COL_TYPE,codec); 182 m_lastItem->setText(COL_TYPE,codec);
181 // title 183 // title
182 m_lastItem->setText(COL_TITLE,m_Infolib->metaInfo(0)); 184 m_lastItem->setText(COL_TITLE,m_Infolib->metaInfo(0));
@@ -186,33 +188,35 @@ void PlaylistView::addFile(const QString&aFile,const QString&aName)
186 m_lastItem->setText(COL_ALBUM,m_Infolib->metaInfo(4)); 188 m_lastItem->setText(COL_ALBUM,m_Infolib->metaInfo(4));
187 int l = m_Infolib->length(); 189 int l = m_Infolib->length();
188 int h = l/3600; 190 int h = l/3600;
189 l-=h*3600; 191 l-=h*3600;
190 int m = l/60; 192 int m = l/60;
191 l-=m*60; 193 l-=m*60;
192 codec = ""; 194 codec = "";
193 if (h>0) { 195 if (h>0) {
194 codec.sprintf("%2i:%2i:%2i h",h,m,l); 196 codec.sprintf("%2i:%2i:%2i h",h,m,l);
195 } else { 197 } else {
196 codec.sprintf("%02i:%02i m",m,l); 198 codec.sprintf("%02i:%02i m",m,l);
197 } 199 }
198 // time 200 // time
199 m_lastItem->setText(COL_TIME,codec); 201 m_lastItem->setText(COL_TIME,codec);
200 m_lastItem->Video(m_Infolib->hasVideo()); 202 m_lastItem->Video(m_Infolib->hasVideo());
201 m_items.append(m_lastItem); 203 m_items.append(m_lastItem);
202 setSelected(m_lastItem,true); 204 if (_it==NULL) {
205 setSelected(m_lastItem,true);
206 }
203} 207}
204 208
205void PlaylistView::slotAppendDir() 209void PlaylistView::slotAppendDir()
206{ 210{
207 QString _dir = Opie::Ui::OFileDialog::getDirectory(Opie::Ui::OFileSelector::Extended,m_lastDir,0,m_lastDir); 211 QString _dir = Opie::Ui::OFileDialog::getDirectory(Opie::Ui::OFileSelector::Extended,m_lastDir,0,m_lastDir);
208 if (_dir.isEmpty()) return; 212 if (_dir.isEmpty()) return;
209 m_lastDir = _dir; 213 m_lastDir = _dir;
210 QDir sDir(_dir); 214 QDir sDir(_dir);
211 QStringList list = sDir.entryList(DEFAULT_FILE_TYPES,QDir::Files,QDir::Name | QDir::IgnoreCase); 215 QStringList list = sDir.entryList(DEFAULT_FILE_TYPES,QDir::Files,QDir::Name | QDir::IgnoreCase);
212 for (unsigned i = 0; i < list.count();++i) { 216 for (unsigned i = 0; i < list.count();++i) {
213 addFile(_dir+QString("/")+list[i]); 217 addFile(_dir+QString("/")+list[i]);
214 } 218 }
215 emit contentChanged(childCount()); 219 emit contentChanged(childCount());
216} 220}
217 221
218void PlaylistView::slotOpenM3u() 222void PlaylistView::slotOpenM3u()
diff --git a/noncore/multimedia/opieplayer3/videowidget.cpp b/noncore/multimedia/opieplayer3/videowidget.cpp
index 833ecb4..414400b 100644
--- a/noncore/multimedia/opieplayer3/videowidget.cpp
+++ b/noncore/multimedia/opieplayer3/videowidget.cpp
@@ -44,32 +44,33 @@ int VideoWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib)
44{ 44{
45 m_current = aLnk; 45 m_current = aLnk;
46 bool recon; 46 bool recon;
47 if (m_xineLib != aLib) { 47 if (m_xineLib != aLib) {
48 if (m_xineLib) disconnect(m_xineLib); 48 if (m_xineLib) disconnect(m_xineLib);
49 m_xineLib = aLib; 49 m_xineLib = aLib;
50 if (aLib) m_xineLib->setWidget(m_Videodisplay); 50 if (aLib) m_xineLib->setWidget(m_Videodisplay);
51 } 51 }
52 if (!m_xineLib) { 52 if (!m_xineLib) {
53 return -1; 53 return -1;
54 } 54 }
55 connect(m_xineLib,SIGNAL(stopped()),this,SLOT(slotStopped())); 55 connect(m_xineLib,SIGNAL(stopped()),this,SLOT(slotStopped()));
56 m_xineLib->setWidget(m_Videodisplay); 56 m_xineLib->setWidget(m_Videodisplay);
57 m_xineLib->setShowVideo(true); 57 m_xineLib->setShowVideo(true);
58 int res = m_xineLib->play(m_current.file()); 58 int res = m_xineLib->play(m_current.file());
59 vSize = m_xineLib->videoSize(); 59 vSize = m_xineLib->videoSize();
60
60 slot_Videoresized(m_Videodisplay->size()); 61 slot_Videoresized(m_Videodisplay->size());
61 odebug << "Xine play: " << res << oendl; 62 odebug << "Xine play: " << res << oendl;
62 if (res != 1) { 63 if (res != 1) {
63 return -2; 64 return -2;
64 } 65 }
65 return m_xineLib->length(); 66 return m_xineLib->length();
66} 67}
67 68
68void VideoWidget::stopPlaying() 69void VideoWidget::stopPlaying()
69{ 70{
70 if (m_xineLib) { 71 if (m_xineLib) {
71 m_xineLib->stop(); 72 m_xineLib->stop();
72 } 73 }
73} 74}
74 75
75void VideoWidget::slotStopped() 76void VideoWidget::slotStopped()