]> git.sur5r.net Git - minitube/commitdiff
Moved autohide to Phonon:VideoWidget subclass
authorFlavio Tordini <flavio.tordini@gmail.com>
Mon, 31 Aug 2009 21:20:55 +0000 (23:20 +0200)
committerFlavio Tordini <flavio.tordini@gmail.com>
Mon, 31 Aug 2009 21:20:55 +0000 (23:20 +0200)
Fixed loading of empty url when pressing Stop

src/MediaView.cpp
src/MediaView.h
src/videoareawidget.cpp
src/videoareawidget.h
src/videowidget.cpp [new file with mode: 0644]
src/videowidget.h [new file with mode: 0644]

index 5b294dabff10dd53349207417326250231c8ee17..f5b256fe319e31dde1d62a57814768047661ffe6 100644 (file)
@@ -12,6 +12,8 @@ namespace The {
 
 MediaView::MediaView(QWidget *parent) : QWidget(parent) {
 
+    reallyStopped = false;
+
     QBoxLayout *layout = new QHBoxLayout();
     layout->setMargin(0);
 
@@ -77,7 +79,7 @@ MediaView::MediaView(QWidget *parent) : QWidget(parent) {
     videoAreaWidget = new VideoAreaWidget(this);
     videoAreaWidget->setMinimumSize(320,240);
 
-    videoWidget = new Phonon::VideoWidget(this);
+    videoWidget = new VideoWidget(this);
     videoAreaWidget->setVideoWidget(videoWidget);
     videoAreaWidget->setListModel(listModel);
 
@@ -93,6 +95,7 @@ MediaView::MediaView(QWidget *parent) : QWidget(parent) {
     errorTimer->setSingleShot(true);
     errorTimer->setInterval(3000);
     connect(errorTimer, SIGNAL(timeout()), SLOT(skipVideo()));
+
 }
 
 MediaView::~MediaView() {
@@ -119,6 +122,8 @@ void MediaView::setMediaObject(Phonon::MediaObject *mediaObject) {
 }
 
 void MediaView::search(SearchParams *searchParams) {
+    reallyStopped = false;
+
     this->searchParams = searchParams;
 
     // start serching for videos
@@ -156,15 +161,15 @@ void MediaView::stateChanged(Phonon::State newState, Phonon::State /*oldState*/)
         break;
 
          case Phonon::PlayingState:
-        qDebug("playing");
+        //qDebug("playing");
         videoAreaWidget->showVideo();
         break;
 
          case Phonon::StoppedState:
-        qDebug("stopped");
+        //qDebug("stopped");
         // play() has already been called when setting the source
         // but Phonon on Linux needs a little more help to start playback
-        mediaObject->play();
+        if (!reallyStopped) mediaObject->play();
 
         // Workaround for Mac playback start problem
         if (!timerPlayFlag) {
@@ -174,15 +179,15 @@ void MediaView::stateChanged(Phonon::State newState, Phonon::State /*oldState*/)
         break;
 
          case Phonon::PausedState:
-        qDebug("paused");
+        //qDebug("paused");
         break;
 
          case Phonon::BufferingState:
-        qDebug("buffering");
+        //qDebug("buffering");
         break;
 
          case Phonon::LoadingState:
-        qDebug("loading");
+        //qDebug("loading");
         break;
 
          default:
@@ -204,8 +209,9 @@ void MediaView::pause() {
 
 void MediaView::stop() {
     listModel->abortSearch();
+    reallyStopped = true;
     mediaObject->stop();
-    mediaObject->clear();
+    // mediaObject->clear();
 }
 
 void MediaView::activeRowChanged(int row) {
index a536402e58ca632981143a4de1c7a57b58da7c2f..5344cc6e8cfe66342d70af0014f288669e8aabb0 100644 (file)
@@ -92,9 +92,11 @@ private:
     LoadingWidget *loadingWidget;
 
     bool timerPlayFlag;
+    bool reallyStopped;
 
     QTimer *errorTimer;
     Video *skippedVideo;
+
 };
 
 #endif // __MEDIAVIEW_H__
index abba1e07460f10ed1e8d8bb2a3609307ad47fab2..81a29cb6d6ce0e2fde7a94d7172f2ad044c646b3 100644 (file)
@@ -23,16 +23,11 @@ VideoAreaWidget::VideoAreaWidget(QWidget *parent) : QWidget(parent) {
     setLayout(vLayout);
     setAcceptDrops(true);
     
-    // mouse autohide
-    setMouseTracking(true);
-    mouseTimer = new QTimer(this);
-    mouseTimer->setInterval(3000);
-    mouseTimer->setSingleShot(true);
-    connect(mouseTimer, SIGNAL(timeout()), SLOT(hideMouse()));
 }
 
 void VideoAreaWidget::setVideoWidget(QWidget *videoWidget) {
     this->videoWidget = videoWidget;
+    videoWidget->setMouseTracking(true);
     stackedLayout->addWidget(videoWidget);
 }
 
@@ -69,18 +64,6 @@ void VideoAreaWidget::mousePressEvent(QMouseEvent *event) {
             emit rightClicked();
 }
 
-void VideoAreaWidget::mouseMoveEvent(QMouseEvent * /* event */) {
-    // show the normal cursor
-    videoWidget->unsetCursor();
-
-    // then hide it again after a few seconds
-    mouseTimer->start();
-}
-
-void VideoAreaWidget::hideMouse() {
-    videoWidget->setCursor(QCursor(Qt::BlankCursor));
-}
-
 void VideoAreaWidget::dragEnterEvent(QDragEnterEvent *event) {
     qDebug() << event->mimeData()->formats();
     if (event->mimeData()->hasFormat("application/x-minitube-video")) {
index 34650cc519b413576453c16345e6347c6abb8de7..3fd1cab562d63a16bf4c6c9b41bf40abed429b5c 100644 (file)
@@ -2,7 +2,6 @@
 #define VIDEOAREAWIDGET_H
 
 #include <QWidget>
-#include <QTimer>
 #include "video.h"
 #include "loadingwidget.h"
 #include "ListModel.h"
@@ -31,10 +30,6 @@ protected:
     void mousePressEvent(QMouseEvent *event);
     void dragEnterEvent(QDragEnterEvent *event);
     void dropEvent(QDropEvent *event);
-    void mouseMoveEvent (QMouseEvent *event);
-
-private slots:
-    void hideMouse();
 
 private:
     QStackedLayout *stackedLayout;
@@ -42,7 +37,7 @@ private:
     LoadingWidget *loadingWidget;
     ListModel *listModel;
     QLabel *messageLabel;
-    QTimer *mouseTimer;
+
 };
 
 #endif // VIDEOAREAWIDGET_H
diff --git a/src/videowidget.cpp b/src/videowidget.cpp
new file mode 100644 (file)
index 0000000..c0137ed
--- /dev/null
@@ -0,0 +1,27 @@
+#include "videowidget.h"
+
+VideoWidget::VideoWidget(QWidget *parent) : Phonon::VideoWidget(parent) {
+//#ifndef Q_WS_MAC
+    // mouse autohide
+    // setMouseTracking(true);
+    mouseTimer = new QTimer(this);
+    mouseTimer->setInterval(3000);
+    mouseTimer->setSingleShot(true);
+    connect(mouseTimer, SIGNAL(timeout()), SLOT(hideMouse()));
+// #endif
+}
+
+void VideoWidget::mouseMoveEvent(QMouseEvent * /* event */) {
+    qDebug() << "mouseMoveEvent";
+
+    // show the normal cursor
+    unsetCursor();
+
+    // then hide it again after a few seconds
+    mouseTimer->start();
+}
+
+void VideoWidget::hideMouse() {
+    qDebug() << "hideMouse()";
+    setCursor(Qt::BlankCursor);
+}
diff --git a/src/videowidget.h b/src/videowidget.h
new file mode 100644 (file)
index 0000000..5d0e016
--- /dev/null
@@ -0,0 +1,26 @@
+#ifndef VIDEOWIDGET_H
+#define VIDEOWIDGET_H
+
+#include <QtGui>
+#include <phonon>
+#include <QTimer>
+
+class VideoWidget : public Phonon::VideoWidget {
+
+    Q_OBJECT
+
+public:
+    VideoWidget(QWidget *parent);
+
+protected:
+    void mouseMoveEvent (QMouseEvent *event);
+
+private slots:
+    void hideMouse();
+
+private:
+    QTimer *mouseTimer;
+
+};
+
+#endif // VIDEOWIDGET_H