1
1
#include "videoareawidget.h"
2
2
#include "videomimedata.h"
4
7
VideoAreaWidget::VideoAreaWidget(QWidget *parent) : QWidget(parent) {
5
8
QBoxLayout *vLayout = new QVBoxLayout(this);
6
9
vLayout->setMargin(0);
7
10
vLayout->setSpacing(0);
10
12
QPalette p = palette();
11
13
p.setBrush(QPalette::Window, Qt::black);
13
15
setAutoFillBackground(true);
16
17
// hidden message widget
17
18
messageLabel = new QLabel(this);
23
24
messageLabel->setWordWrap(true);
24
25
messageLabel->hide();
25
26
vLayout->addWidget(messageLabel);
27
28
stackedLayout = new QStackedLayout();
28
29
vLayout->addLayout(stackedLayout);
31
snapshotPreview = new QLabel(this);
32
stackedLayout->addWidget(snapshotPreview);
30
34
setLayout(vLayout);
31
35
setAcceptDrops(true);
58
62
void VideoAreaWidget::showLoading(Video *video) {
63
stackedLayout->setCurrentWidget(loadingWidget);
59
64
this->loadingWidget->setVideo(video);
60
stackedLayout->setCurrentWidget(loadingWidget);
61
65
messageLabel->hide();
62
66
messageLabel->clear();
69
void VideoAreaWidget::showSnapshotPreview(QPixmap pixmap) {
70
snapshotPreview->setPixmap(pixmap);
71
stackedLayout->setCurrentWidget(snapshotPreview);
73
Extra::flashInWidget(snapshotPreview);
75
QTimer::singleShot(1500, this, SLOT(hideSnapshotPreview()));
78
void VideoAreaWidget::hideSnapshotPreview() {
79
stackedLayout->setCurrentWidget(videoWidget);
65
82
void VideoAreaWidget::clear() {
66
83
stackedLayout->setCurrentWidget(loadingWidget);
67
84
loadingWidget->clear();
68
85
messageLabel->hide();
69
86
messageLabel->clear();
87
snapshotPreview->clear();
72
90
void VideoAreaWidget::mouseDoubleClickEvent(QMouseEvent *event) {
102
120
listModel->setActiveRow(row);
103
121
event->acceptProposedAction();
106
void VideoAreaWidget::mouseMoveEvent(QMouseEvent *event) {
107
QWidget::mouseMoveEvent(event);
110
QWidget* mainWindow = window();
111
if (!mainWindow->isFullScreen()) return;
113
// qDebug() << "VideoAreaWidget::mouseMoveEvent" << event->pos();
115
const int x = event->pos().x();
116
const int y = event->pos().y();
118
bool visible = y <= 10;
119
bool ret = QMetaObject::invokeMethod(mainWindow, "showFullscreenToolbar", Qt::DirectConnection, Q_ARG(bool, visible));
120
if (!ret) qDebug() << "showFullscreenToolbar invokeMethod failed";
123
ret = QMetaObject::invokeMethod(mainWindow, "showFullscreenPlaylist", Qt::DirectConnection, Q_ARG(bool, visible));
124
if (!ret) qDebug() << "showFullscreenPlaylist invokeMethod failed";
128
void VideoAreaWidget::leaveEvent(QMouseEvent *event) {
129
QWidget::leaveEvent(event);
132
QWidget* mainWindow = window();
133
if (!mainWindow->isFullScreen()) return;
135
bool visible = false;
136
bool ret = QMetaObject::invokeMethod(mainWindow, "showFullscreenToolbar", Qt::DirectConnection, Q_ARG(bool, visible));
137
if (!ret) qDebug() << "showFullscreenToolbar invokeMethod failed";
139
ret = QMetaObject::invokeMethod(mainWindow, "showFullscreenPlaylist", Qt::DirectConnection, Q_ARG(bool, visible));
140
if (!ret) qDebug() << "showFullscreenPlaylist invokeMethod failed";