-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvideoframethumbnail.cpp
More file actions
84 lines (69 loc) · 1.88 KB
/
videoframethumbnail.cpp
File metadata and controls
84 lines (69 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <QImage>
#include <QLabel>
#include <QPainter>
#include <QPixmap>
#include <QStyle>
#include <QStyleOption>
#include <QVBoxLayout>
#include <QWidget>
#include "videoframethumbnail.h"
namespace vfg {
namespace ui {
VideoFrameThumbnail::VideoFrameThumbnail(
const int frame, const QImage& thumbnail, QWidget *parent) :
QWidget(parent),
pixmapLabel(new QLabel),
thumb(QPixmap::fromImage(thumbnail.scaledToWidth(200, Qt::SmoothTransformation))),
frameNumber(frame)
{
pixmapLabel->setPixmap(thumb);
auto layout = new QVBoxLayout;
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(pixmapLabel.get());
setLayout(layout);
setContentsMargins(0, 0, 0, 0);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
setContextMenuPolicy(Qt::CustomContextMenu);
}
void VideoFrameThumbnail::updateFrameSize()
{
pixmapLabel->setPixmap(thumb.scaledToWidth(pixmapLabel->width(),
Qt::SmoothTransformation));
}
void VideoFrameThumbnail::markSelected()
{
setStyleSheet("background-color: #e0e0e0; border: 1px solid #dd22ff;");
}
void VideoFrameThumbnail::markUnselected()
{
setStyleSheet("background-color: inherit; border: 0;");
}
int VideoFrameThumbnail::frameNum() const
{
return frameNumber;
}
void VideoFrameThumbnail::mouseDoubleClickEvent(QMouseEvent *event)
{
Q_UNUSED(event);
emit doubleClicked(frameNumber);
}
void VideoFrameThumbnail::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event);
updateFrameSize();
}
void VideoFrameThumbnail::mousePressEvent(QMouseEvent *event)
{
Q_UNUSED(event);
emit selected(this);
}
void VideoFrameThumbnail::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QStyleOption o;
o.initFrom(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &o, &p, this);
}
} // namespace ui
} // namespace vfg