#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);
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);
}
void VideoAreaWidget::showLoading(Video *video) {
- this->loadingWidget->setVideo(video);
stackedLayout->setCurrentWidget(loadingWidget);
+ this->loadingWidget->setVideo(video);
messageLabel->hide();
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) {
listModel->setActiveRow(row);
event->acceptProposedAction();
}
-
-void VideoAreaWidget::mouseMoveEvent(QMouseEvent *event) {
- QWidget::mouseMoveEvent(event);
-
- 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";
-}
-
-void VideoAreaWidget::leaveEvent(QMouseEvent *event) {
- QWidget::leaveEvent(event);
-
- 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";
-}