]> git.sur5r.net Git - minitube/blobdiff - src/videoareawidget.cpp
Imported Upstream version 2.3
[minitube] / src / videoareawidget.cpp
index 14a57187b09d2af07c2fe810d8523cfe33063304..4adc47ee0c639a1711039d9e885efa82324e6098 100644 (file)
@@ -19,25 +19,21 @@ along with Minitube.  If not, see <http://www.gnu.org/licenses/>.
 $END_LICENSE */
 
 #include "videoareawidget.h"
+#include "video.h"
+#include "loadingwidget.h"
+#include "playlistmodel.h"
 #include "videomimedata.h"
 #include "mainwindow.h"
-#ifdef APP_EXTRA
-#include "extra.h"
-#endif
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
 #include "macutils.h"
 #endif
+#include "snapshotpreview.h"
 
-VideoAreaWidget::VideoAreaWidget(QWidget *parent) : QWidget(parent) {
+VideoAreaWidget::VideoAreaWidget(QWidget *parent) : QWidget(parent), videoWidget(0) {
     QBoxLayout *vLayout = new QVBoxLayout(this);
     vLayout->setMargin(0);
     vLayout->setSpacing(0);
 
-    QPalette p = palette();
-    p.setBrush(QPalette::Window, Qt::black);
-    setPalette(p);
-    setAutoFillBackground(true);
-
     // hidden message widget
     messageLabel = new QLabel(this);
     messageLabel->setOpenExternalLinks(true);
@@ -52,9 +48,11 @@ VideoAreaWidget::VideoAreaWidget(QWidget *parent) : QWidget(parent) {
     stackedLayout = new QStackedLayout();
     vLayout->addLayout(stackedLayout);
 
-    // snapshotPreview = new QLabel(this);
-    // stackedLayout->addWidget(snapshotPreview);
-    
+#ifdef APP_SNAPSHOT
+    snapshotPreview = new SnapshotPreview();
+    connect(stackedLayout, SIGNAL(currentChanged(int)), snapshotPreview, SLOT(hide()));
+#endif
+
     setAcceptDrops(true);
     setMouseTracking(true);
     setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
@@ -73,7 +71,8 @@ void VideoAreaWidget::setLoadingWidget(LoadingWidget *loadingWidget) {
 }
 
 void VideoAreaWidget::showVideo() {
-    stackedLayout->setCurrentWidget(videoWidget);
+    if (videoWidget)
+        stackedLayout->setCurrentWidget(videoWidget);
     loadingWidget->clear();
 }
 
@@ -91,26 +90,24 @@ void VideoAreaWidget::showLoading(Video *video) {
     loadingWidget->setVideo(video);
 }
 
-/*
-void VideoAreaWidget::showSnapshotPreview(QPixmap pixmap) {
-    snapshotPreview->setPixmap(pixmap);
-    stackedLayout->setCurrentWidget(snapshotPreview);
-#ifdef APP_EXTRA
-    Extra::flashInWidget(snapshotPreview);
+#ifdef APP_SNAPSHOT
+void VideoAreaWidget::showSnapshotPreview(const QPixmap &pixmap) {
+    bool soundOnly = false;
+#ifdef APP_MAC
+    soundOnly = MainWindow::instance()->isReallyFullScreen();
 #endif
-    QTimer::singleShot(1500, this, SLOT(hideSnapshotPreview()));
+    snapshotPreview->start(videoWidget, pixmap, soundOnly);
 }
 
 void VideoAreaWidget::hideSnapshotPreview() {
-    stackedLayout->setCurrentWidget(videoWidget);
+
 }
-*/
+#endif
 
 void VideoAreaWidget::clear() {
     loadingWidget->clear();
     messageLabel->hide();
     messageLabel->clear();
-    // snapshotPreview->clear();
     stackedLayout->setCurrentWidget(loadingWidget);
 }
 
@@ -140,7 +137,7 @@ void VideoAreaWidget::mouseMoveEvent(QMouseEvent *event) {
             !MainWindow::instance()->isReallyFullScreen();
     if (event->buttons() & Qt::LeftButton && isNormalWindow) {
         QPoint p = event->globalPos() - dragPosition;
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
         mac::moveWindowTo(window()->winId(), p.x(), p.y());
 #else
         window()->move(p);