~ubuntu-branches/ubuntu/saucy/minitube/saucy-proposed

« back to all changes in this revision

Viewing changes to src/videoareawidget.cpp

  • Committer: Package Import Robot
  • Author(s): Jakob Haufe
  • Date: 2012-09-29 02:43:53 UTC
  • mto: This revision was merged to the branch mainline in revision 15.
  • Revision ID: package-import@ubuntu.com-20120929024353-fxbrlvqxrlu6cwld
Tags: upstream-1.9
ImportĀ upstreamĀ versionĀ 1.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include "videoareawidget.h"
2
2
#include "videomimedata.h"
 
3
#ifndef Q_WS_X11
 
4
#include "extra.h"
 
5
#endif
3
6
 
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);
8
11
 
9
 
#ifdef APP_WIN
10
12
    QPalette p = palette();
11
13
    p.setBrush(QPalette::Window, Qt::black);
12
14
    setPalette(p);
13
15
    setAutoFillBackground(true);
14
 
#endif
15
16
 
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);
26
 
    
 
27
 
27
28
    stackedLayout = new QStackedLayout();
28
29
    vLayout->addLayout(stackedLayout);
 
30
 
 
31
    snapshotPreview = new QLabel(this);
 
32
    stackedLayout->addWidget(snapshotPreview);
29
33
    
30
34
    setLayout(vLayout);
31
35
    setAcceptDrops(true);
56
60
}
57
61
 
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();
63
67
}
64
68
 
 
69
void VideoAreaWidget::showSnapshotPreview(QPixmap pixmap) {
 
70
    snapshotPreview->setPixmap(pixmap);
 
71
    stackedLayout->setCurrentWidget(snapshotPreview);
 
72
#ifndef Q_WS_X11
 
73
    Extra::flashInWidget(snapshotPreview);
 
74
#endif
 
75
    QTimer::singleShot(1500, this, SLOT(hideSnapshotPreview()));
 
76
}
 
77
 
 
78
void VideoAreaWidget::hideSnapshotPreview() {
 
79
    stackedLayout->setCurrentWidget(videoWidget);
 
80
}
 
81
 
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();
70
88
}
71
89
 
72
90
void VideoAreaWidget::mouseDoubleClickEvent(QMouseEvent *event) {
102
120
        listModel->setActiveRow(row);
103
121
    event->acceptProposedAction();
104
122
}
105
 
 
106
 
void VideoAreaWidget::mouseMoveEvent(QMouseEvent *event) {
107
 
    QWidget::mouseMoveEvent(event);
108
 
 
109
 
#ifdef Q_WS_X11
110
 
    QWidget* mainWindow = window();
111
 
    if (!mainWindow->isFullScreen()) return;
112
 
 
113
 
    // qDebug() << "VideoAreaWidget::mouseMoveEvent" << event->pos();
114
 
 
115
 
    const int x = event->pos().x();
116
 
    const int y = event->pos().y();
117
 
 
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";
121
 
 
122
 
    visible = x <= 10;
123
 
    ret = QMetaObject::invokeMethod(mainWindow, "showFullscreenPlaylist", Qt::DirectConnection, Q_ARG(bool, visible));
124
 
    if (!ret) qDebug() << "showFullscreenPlaylist invokeMethod failed";
125
 
#endif
126
 
}
127
 
 
128
 
void VideoAreaWidget::leaveEvent(QMouseEvent *event) {
129
 
    QWidget::leaveEvent(event);
130
 
 
131
 
#ifdef Q_WS_X11
132
 
    QWidget* mainWindow = window();
133
 
    if (!mainWindow->isFullScreen()) return;
134
 
 
135
 
    bool visible = false;
136
 
    bool ret = QMetaObject::invokeMethod(mainWindow, "showFullscreenToolbar", Qt::DirectConnection, Q_ARG(bool, visible));
137
 
    if (!ret) qDebug() << "showFullscreenToolbar invokeMethod failed";
138
 
 
139
 
    ret = QMetaObject::invokeMethod(mainWindow, "showFullscreenPlaylist", Qt::DirectConnection, Q_ARG(bool, visible));
140
 
    if (!ret) qDebug() << "showFullscreenPlaylist invokeMethod failed";
141
 
#endif
142
 
}