]> git.sur5r.net Git - minitube/blobdiff - src/mediaview.cpp
Fix build without APP_SNAPSHOT
[minitube] / src / mediaview.cpp
index a2c4587cc17e231eb52c4934071a244c9403c189..302c77a1ea478d6ca0c91329c42eb3fba6b48f86 100644 (file)
@@ -64,7 +64,7 @@ MediaView* MediaView::instance() {
     return i;
 }
 
-MediaView::MediaView(QWidget *parent) : QWidget(parent)
+MediaView::MediaView(QWidget *parent) : View(parent)
   , stopped(false)
   , downloadItem(0)
   #ifdef APP_SNAPSHOT
@@ -190,7 +190,7 @@ void MediaView::setMediaObject(Phonon::MediaObject *mediaObject) {
 SearchParams* MediaView::getSearchParams() {
     VideoSource *videoSource = playlistModel->getVideoSource();
     if (videoSource && videoSource->metaObject()->className() == QLatin1String("YTSearch")) {
-        YTSearch *search = dynamic_cast<YTSearch *>(videoSource);
+        YTSearch *search = qobject_cast<YTSearch *>(videoSource);
         return search->getSearchParams();
     }
     return 0;
@@ -400,12 +400,16 @@ void MediaView::stop() {
     QSlider *slider = MainWindow::instance()->getSlider();
     slider->setEnabled(false);
     slider->setValue(0);
+#else
+    Phonon::SeekSlider *slider = MainWindow::instance()->getSeekSlider();
 #endif
 
+#ifdef APP_SNAPSHOT
     if (snapshotSettings) {
         delete snapshotSettings;
         snapshotSettings = 0;
     }
+#endif
 }
 
 const QString & MediaView::getCurrentVideoId() {
@@ -476,11 +480,13 @@ void MediaView::activeRowChanged(int row) {
     slider->setValue(0);
 #endif
 
+#ifdef APP_SNAPSHOT
     if (snapshotSettings) {
         delete snapshotSettings;
         snapshotSettings = 0;
         MainWindow::instance()->adjustStatusBarVisibility();
     }
+#endif
 
     // see you in gotStreamUrl...
 }
@@ -644,7 +650,7 @@ void MediaView::aboutToFinish() {
 #ifdef APP_PHONON
     qint64 currentTime = mediaObject->currentTime();
     qint64 totalTime = mediaObject->totalTime();
-    qDebug() << __PRETTY_FUNCTION__ << currentTime << totalTime;
+    // qDebug() << __PRETTY_FUNCTION__ << currentTime << totalTime;
     if (totalTime < 1 || currentTime + 10000 < totalTime) {
         // QTimer::singleShot(500, this, SLOT(playbackResume()));
         mediaObject->seek(currentTime);
@@ -659,7 +665,7 @@ void MediaView::playbackFinished() {
 #ifdef APP_PHONON
     const qint64 totalTime = mediaObject->totalTime();
     const qint64 currentTime = mediaObject->currentTime();
-    qDebug() << __PRETTY_FUNCTION__ << mediaObject->currentTime() << totalTime;
+    // qDebug() << __PRETTY_FUNCTION__ << mediaObject->currentTime() << totalTime;
     // add 10 secs for imprecise Phonon backends (VLC, Xine)
     if (currentTime > 0 && currentTime + 10000 < totalTime) {
         // mediaObject->seek(currentTime);
@@ -677,7 +683,7 @@ void MediaView::playbackResume() {
     if (stopped) return;
 #ifdef APP_PHONON
     const qint64 currentTime = mediaObject->currentTime();
-    qDebug() << __PRETTY_FUNCTION__ << currentTime;
+    // qDebug() << __PRETTY_FUNCTION__ << currentTime;
     if (currentTime > 0)
         mediaObject->seek(currentTime);
     mediaObject->play();
@@ -690,7 +696,8 @@ void MediaView::openWebPage() {
 #ifdef APP_PHONON
     mediaObject->pause();
 #endif
-    QDesktopServices::openUrl(video->webpage());
+    QString url = video->webpage() + QLatin1String("&t=") + QString::number(mediaObject->currentTime() / 1000);
+    QDesktopServices::openUrl(url);
 }
 
 void MediaView::copyWebPage() {
@@ -795,7 +802,7 @@ void MediaView::demoMessage() {
 #endif
 
     QMessageBox msgBox(this);
-    msgBox.setIconPixmap(QPixmap(":/images/app.png").scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation));
+    msgBox.setIconPixmap(IconUtils::pixmap(":/images/app.png").scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation));
     msgBox.setText(tr("This is just the demo version of %1.").arg(Constants::NAME));
     msgBox.setInformativeText(tr("It allows you to test the application and see if it works for you."));
     msgBox.setModal(true);
@@ -842,7 +849,7 @@ void MediaView::downloadVideo() {
     Video* video = playlistModel->activeVideo();
     if (!video) return;
     DownloadManager::instance()->addItem(video);
-    The::globalActions()->value("downloads")->setVisible(true);
+    MainWindow::instance()->showActionInStatusBar(The::globalActions()->value("downloads"), true);
     QString message = tr("Downloading %1").arg(video->title());
     MainWindow::instance()->showMessage(message);
 }
@@ -1160,8 +1167,13 @@ void MediaView::toggleSubscription() {
     QString userId = video->channelId();
     if (userId.isEmpty()) return;
     bool subscribed = YTChannel::isSubscribed(userId);
-    if (subscribed) YTChannel::unsubscribe(userId);
-    else YTChannel::subscribe(userId);
+    if (subscribed) {
+        YTChannel::unsubscribe(userId);
+        MainWindow::instance()->showMessage(tr("Unsubscribed from %1").arg(video->channelTitle()));
+    } else {
+        YTChannel::subscribe(userId);
+        MainWindow::instance()->showMessage(tr("Subscribed to %1").arg(video->channelTitle()));
+    }
     updateSubscriptionAction(video, !subscribed);
 }