]> git.sur5r.net Git - minitube/blobdiff - src/videoareawidget.cpp
Imported Upstream version 2.0
[minitube] / src / videoareawidget.cpp
index bf2ae03312302b58f33557e840aa6249196bbea0..695070f7141c2eb195ee42d5d0e9a07ce9b527a8 100644 (file)
@@ -1,17 +1,18 @@
 #include "videoareawidget.h"
 #include "videomimedata.h"
+#ifndef Q_WS_X11
+#include "extra.h"
+#endif
 
 VideoAreaWidget::VideoAreaWidget(QWidget *parent) : QWidget(parent) {
     QBoxLayout *vLayout = new QVBoxLayout(this);
     vLayout->setMargin(0);
     vLayout->setSpacing(0);
 
-#ifdef APP_WIN
     QPalette p = palette();
     p.setBrush(QPalette::Window, Qt::black);
     setPalette(p);
     setAutoFillBackground(true);
-#endif
 
     // hidden message widget
     messageLabel = new QLabel(this);
@@ -23,13 +24,14 @@ VideoAreaWidget::VideoAreaWidget(QWidget *parent) : QWidget(parent) {
     messageLabel->setWordWrap(true);
     messageLabel->hide();
     vLayout->addWidget(messageLabel);
-    
+
     stackedLayout = new QStackedLayout();
     vLayout->addLayout(stackedLayout);
+
+    snapshotPreview = new QLabel(this);
+    stackedLayout->addWidget(snapshotPreview);
     
-    setLayout(vLayout);
-    setAcceptDrops(true);
-    
+    setAcceptDrops(true);    
     setMouseTracking(true);
 }
 
@@ -62,11 +64,25 @@ void VideoAreaWidget::showLoading(Video *video) {
     messageLabel->clear();
 }
 
+void VideoAreaWidget::showSnapshotPreview(QPixmap pixmap) {
+    snapshotPreview->setPixmap(pixmap);
+    stackedLayout->setCurrentWidget(snapshotPreview);
+#ifndef Q_WS_X11
+    Extra::flashInWidget(snapshotPreview);
+#endif
+    QTimer::singleShot(1500, this, SLOT(hideSnapshotPreview()));
+}
+
+void VideoAreaWidget::hideSnapshotPreview() {
+    stackedLayout->setCurrentWidget(videoWidget);
+}
+
 void VideoAreaWidget::clear() {
     stackedLayout->setCurrentWidget(loadingWidget);
     loadingWidget->clear();
     messageLabel->hide();
     messageLabel->clear();
+    snapshotPreview->clear();
 }
 
 void VideoAreaWidget::mouseDoubleClickEvent(QMouseEvent *event) {
@@ -102,41 +118,3 @@ void VideoAreaWidget::dropEvent(QDropEvent *event) {
         listModel->setActiveRow(row);
     event->acceptProposedAction();
 }
-
-void VideoAreaWidget::mouseMoveEvent(QMouseEvent *event) {
-    QWidget::mouseMoveEvent(event);
-
-#ifdef Q_WS_X11
-    QWidget* mainWindow = window();
-    if (!mainWindow->isFullScreen()) return;
-
-    // qDebug() << "VideoAreaWidget::mouseMoveEvent" << event->pos();
-
-    const int x = event->pos().x();
-    const int y = event->pos().y();
-
-    bool visible = y <= 10;
-    bool ret = QMetaObject::invokeMethod(mainWindow, "showFullscreenToolbar", Qt::DirectConnection, Q_ARG(bool, visible));
-    if (!ret) qDebug() << "showFullscreenToolbar invokeMethod failed";
-
-    visible = x <= 10;
-    ret = QMetaObject::invokeMethod(mainWindow, "showFullscreenPlaylist", Qt::DirectConnection, Q_ARG(bool, visible));
-    if (!ret) qDebug() << "showFullscreenPlaylist invokeMethod failed";
-#endif
-}
-
-void VideoAreaWidget::leaveEvent(QMouseEvent *event) {
-    QWidget::leaveEvent(event);
-
-#ifdef Q_WS_X11
-    QWidget* mainWindow = window();
-    if (!mainWindow->isFullScreen()) return;
-
-    bool visible = false;
-    bool ret = QMetaObject::invokeMethod(mainWindow, "showFullscreenToolbar", Qt::DirectConnection, Q_ARG(bool, visible));
-    if (!ret) qDebug() << "showFullscreenToolbar invokeMethod failed";
-
-    ret = QMetaObject::invokeMethod(mainWindow, "showFullscreenPlaylist", Qt::DirectConnection, Q_ARG(bool, visible));
-    if (!ret) qDebug() << "showFullscreenPlaylist invokeMethod failed";
-#endif
-}