MediaView::MediaView(QWidget *parent) : QWidget(parent) {
+ reallyStopped = false;
+
QBoxLayout *layout = new QHBoxLayout();
layout->setMargin(0);
videoAreaWidget = new VideoAreaWidget(this);
videoAreaWidget->setMinimumSize(320,240);
- videoWidget = new Phonon::VideoWidget(this);
+ videoWidget = new VideoWidget(this);
videoAreaWidget->setVideoWidget(videoWidget);
videoAreaWidget->setListModel(listModel);
errorTimer->setSingleShot(true);
errorTimer->setInterval(3000);
connect(errorTimer, SIGNAL(timeout()), SLOT(skipVideo()));
+
}
MediaView::~MediaView() {
}
void MediaView::search(SearchParams *searchParams) {
+ reallyStopped = false;
+
this->searchParams = searchParams;
// start serching for videos
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) {
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:
void MediaView::stop() {
listModel->abortSearch();
+ reallyStopped = true;
mediaObject->stop();
- mediaObject->clear();
+ // mediaObject->clear();
}
void MediaView::activeRowChanged(int row) {
LoadingWidget *loadingWidget;
bool timerPlayFlag;
+ bool reallyStopped;
QTimer *errorTimer;
Video *skippedVideo;
+
};
#endif // __MEDIAVIEW_H__
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);
}
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")) {
#define VIDEOAREAWIDGET_H
#include <QWidget>
-#include <QTimer>
#include "video.h"
#include "loadingwidget.h"
#include "ListModel.h"
void mousePressEvent(QMouseEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
- void mouseMoveEvent (QMouseEvent *event);
-
-private slots:
- void hideMouse();
private:
QStackedLayout *stackedLayout;
LoadingWidget *loadingWidget;
ListModel *listModel;
QLabel *messageLabel;
- QTimer *mouseTimer;
+
};
#endif // VIDEOAREAWIDGET_H
--- /dev/null
+#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);
+}
--- /dev/null
+#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