From: Flavio Tordini Date: Wed, 11 Nov 2009 20:30:20 +0000 (+0100) Subject: Clear video area before loading a new video X-Git-Tag: 0.8~16 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=cf5a57c1c20c2a4fda204a64706c75b702a3c12c;p=minitube Clear video area before loading a new video HD mode refinements Stop timers before loading a new video --- diff --git a/src/MediaView.cpp b/src/MediaView.cpp index ea0df72..2913a4c 100644 --- a/src/MediaView.cpp +++ b/src/MediaView.cpp @@ -3,6 +3,7 @@ #include "networkaccess.h" #include "videowidget.h" #include "minisplitter.h" +#include "flickcharm.h" namespace The { QMap* globalActions(); @@ -58,6 +59,7 @@ MediaView::MediaView(QWidget *parent) : QWidget(parent) { listView->setFrameShape( QFrame::NoFrame ); listView->setAttribute(Qt::WA_MacShowFocusRect, false); listView->setMinimumSize(320,240); + listView->setUniformItemSizes(true); // respond to the user doubleclicking a playlist item connect(listView, SIGNAL(activated(const QModelIndex &)), this, SLOT(itemActivated(const QModelIndex &))); @@ -112,6 +114,9 @@ MediaView::MediaView(QWidget *parent) : QWidget(parent) { workaroundTimer->setInterval(3000); connect(workaroundTimer, SIGNAL(timeout()), SLOT(timerPlay())); + FlickCharm *flickCharm = new FlickCharm(this); + flickCharm->activateOn(listView); + } MediaView::~MediaView() { @@ -140,6 +145,10 @@ void MediaView::setMediaObject(Phonon::MediaObject *mediaObject) { void MediaView::search(SearchParams *searchParams) { reallyStopped = false; + videoAreaWidget->clear(); + workaroundTimer->stop(); + errorTimer->stop(); + this->searchParams = searchParams; // start serching for videos @@ -150,7 +159,6 @@ void MediaView::search(SearchParams *searchParams) { listView->setFocus(); - loadingWidget->clear(); } void MediaView::disappear() { @@ -229,8 +237,16 @@ void MediaView::stop() { listModel->abortSearch(); reallyStopped = true; mediaObject->stop(); + videoAreaWidget->clear(); workaroundTimer->stop(); errorTimer->stop(); + listView->selectionModel()->clearSelection(); + + // turn off HD indicator + bool ret = QMetaObject::invokeMethod(parent()->parent(), "hdIndicator", Qt::DirectConnection, Q_ARG(bool, false)); + if (!ret) qDebug() << "hdIndicator invokeMethod failed"; + QAction *hdAct = The::globalActions()->value("hd"); + hdAct->setToolTip(""); } void MediaView::activeRowChanged(int row) { @@ -312,7 +328,7 @@ void MediaView::aboutToFinish() { } void MediaView::currentSourceChanged(const Phonon::MediaSource source) { - qDebug() << source.url().toString(); + qDebug() << "Playing" << source.url().toString(); } @@ -403,12 +419,12 @@ void MediaView::setPlaylistVisible(bool visible) { void MediaView::timerPlay() { // Workaround Phonon bug on Mac OSX - qDebug() << mediaObject->currentTime(); + // qDebug() << mediaObject->currentTime(); if (mediaObject->currentTime() <= 0 && mediaObject->state() == Phonon::PlayingState) { // qDebug() << "Mac playback workaround"; mediaObject->pause(); - QTimer::singleShot(1000, mediaObject, SLOT(play())); - // mediaObject->play(); + // QTimer::singleShot(1000, mediaObject, SLOT(play())); + mediaObject->play(); } } diff --git a/src/videoareawidget.cpp b/src/videoareawidget.cpp index 81a29cb..1d743a8 100644 --- a/src/videoareawidget.cpp +++ b/src/videoareawidget.cpp @@ -54,6 +54,13 @@ void VideoAreaWidget::showLoading(Video *video) { messageLabel->clear(); } +void VideoAreaWidget::clear() { + stackedLayout->setCurrentWidget(loadingWidget); + loadingWidget->clear(); + messageLabel->hide(); + messageLabel->clear(); +} + void VideoAreaWidget::mouseDoubleClickEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) emit doubleClicked(); @@ -65,7 +72,7 @@ void VideoAreaWidget::mousePressEvent(QMouseEvent *event) { } void VideoAreaWidget::dragEnterEvent(QDragEnterEvent *event) { - qDebug() << event->mimeData()->formats(); + // qDebug() << event->mimeData()->formats(); if (event->mimeData()->hasFormat("application/x-minitube-video")) { event->acceptProposedAction(); } @@ -77,10 +84,11 @@ void VideoAreaWidget::dropEvent(QDropEvent *event) { if(!videoMimeData ) return; QList droppedVideos = videoMimeData->videos(); - foreach( Video *video, droppedVideos) { - int row = listModel->rowForVideo(video); - if (row != -1) - listModel->setActiveRow(row); - } + if (droppedVideos.isEmpty()) + return; + Video *video = droppedVideos.first(); + int row = listModel->rowForVideo(video); + if (row != -1) + listModel->setActiveRow(row); event->acceptProposedAction(); } diff --git a/src/videoareawidget.h b/src/videoareawidget.h index 3fd1cab..fa37a59 100644 --- a/src/videoareawidget.h +++ b/src/videoareawidget.h @@ -17,6 +17,7 @@ public: void showLoading(Video* video); void showVideo(); void showError(QString message); + void clear(); void setListModel(ListModel *listModel) { this->listModel = listModel; }