2019-12-19 01:48:51 +00:00
|
|
|
|
#pragma execution_character_set("utf-8")
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
#include "videowindow.h"
|
2019-12-19 01:48:51 +00:00
|
|
|
|
#include "qfontdatabase.h"
|
|
|
|
|
#include "qpushbutton.h"
|
|
|
|
|
#include "qtreewidget.h"
|
|
|
|
|
#include "qlayout.h"
|
|
|
|
|
#include "qtimer.h"
|
|
|
|
|
#include "qdir.h"
|
|
|
|
|
#include "qpainter.h"
|
|
|
|
|
#include "qevent.h"
|
|
|
|
|
#include "qmimedata.h"
|
|
|
|
|
#include "qurl.h"
|
|
|
|
|
#include "qdebug.h"
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
VideoWindow::VideoWindow(QWidget *parent) : QWidget(parent)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
//设置强焦点
|
|
|
|
|
setFocusPolicy(Qt::StrongFocus);
|
|
|
|
|
//设置支持拖放
|
|
|
|
|
setAcceptDrops(true);
|
|
|
|
|
|
2020-06-01 09:40:18 +00:00
|
|
|
|
//定时器校验视频
|
2019-12-19 01:48:51 +00:00
|
|
|
|
timerCheck = new QTimer(this);
|
|
|
|
|
timerCheck->setInterval(10 * 1000);
|
|
|
|
|
connect(timerCheck, SIGNAL(timeout()), this, SLOT(checkVideo()));
|
|
|
|
|
|
|
|
|
|
image = QImage();
|
2020-06-01 09:40:18 +00:00
|
|
|
|
copyImage = false;
|
|
|
|
|
checkLive = true;
|
|
|
|
|
drawImage = true;
|
|
|
|
|
fillImage = true;
|
|
|
|
|
|
|
|
|
|
flowEnable = false;
|
|
|
|
|
flowBgColor = "#000000";
|
|
|
|
|
flowPressColor = "#5EC7D9";
|
|
|
|
|
|
|
|
|
|
timeout = 20;
|
|
|
|
|
borderWidth = 5;
|
|
|
|
|
borderColor = "#000000";
|
|
|
|
|
focusColor = "#22A3A9";
|
2021-03-20 05:54:55 +00:00
|
|
|
|
bgColor = Qt::transparent;
|
2020-06-01 09:40:18 +00:00
|
|
|
|
bgText = "实时视频";
|
|
|
|
|
bgImage = QImage();
|
|
|
|
|
|
|
|
|
|
osd1Visible = false;
|
|
|
|
|
osd1FontSize = 12;
|
|
|
|
|
osd1Text = "时间";
|
|
|
|
|
osd1Color = "#FF0000";
|
|
|
|
|
osd1Image = QImage();
|
|
|
|
|
osd1Format = OSDFormat_DateTime;
|
|
|
|
|
osd1Position = OSDPosition_Right_Top;
|
2019-12-19 01:48:51 +00:00
|
|
|
|
|
2020-06-01 09:40:18 +00:00
|
|
|
|
osd2Visible = false;
|
|
|
|
|
osd2FontSize = 12;
|
|
|
|
|
osd2Text = "通道名称";
|
|
|
|
|
osd2Color = "#FF0000";
|
|
|
|
|
osd2Image = QImage();
|
|
|
|
|
osd2Format = OSDFormat_Text;
|
|
|
|
|
osd2Position = OSDPosition_Left_Bottom;
|
|
|
|
|
|
|
|
|
|
//初始化解码线程
|
|
|
|
|
this->initThread();
|
|
|
|
|
//初始化悬浮条
|
|
|
|
|
this->initFlowPanel();
|
|
|
|
|
//初始化悬浮条样式
|
|
|
|
|
this->initFlowStyle();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::initThread()
|
2020-06-01 09:40:18 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::initFlowPanel()
|
2020-06-01 09:40:18 +00:00
|
|
|
|
{
|
2019-12-19 01:48:51 +00:00
|
|
|
|
//顶部工具栏,默认隐藏,鼠标移入显示移除隐藏
|
|
|
|
|
flowPanel = new QWidget(this);
|
|
|
|
|
flowPanel->setObjectName("flowPanel");
|
|
|
|
|
flowPanel->setVisible(false);
|
|
|
|
|
|
|
|
|
|
//用布局顶住,左侧弹簧
|
|
|
|
|
QHBoxLayout *layout = new QHBoxLayout;
|
|
|
|
|
layout->setSpacing(2);
|
2020-12-24 10:00:09 +00:00
|
|
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
2019-12-19 01:48:51 +00:00
|
|
|
|
layout->addStretch();
|
|
|
|
|
flowPanel->setLayout(layout);
|
|
|
|
|
|
|
|
|
|
//按钮集合名称,如果需要新增按钮则在这里增加即可
|
|
|
|
|
QList<QString> btns;
|
|
|
|
|
btns << "btnFlowVideo" << "btnFlowSnap" << "btnFlowSound" << "btnFlowAlarm" << "btnFlowClose";
|
|
|
|
|
|
|
|
|
|
//有多种办法来设置图片,qt内置的图标+自定义的图标+图形字体
|
|
|
|
|
//既可以设置图标形式,也可以直接图形字体设置文本
|
|
|
|
|
#if 0
|
|
|
|
|
QList<QIcon> icons;
|
|
|
|
|
icons << QApplication::style()->standardIcon(QStyle::SP_ComputerIcon);
|
|
|
|
|
icons << QApplication::style()->standardIcon(QStyle::SP_FileIcon);
|
|
|
|
|
icons << QApplication::style()->standardIcon(QStyle::SP_DirIcon);
|
|
|
|
|
icons << QApplication::style()->standardIcon(QStyle::SP_DialogOkButton);
|
|
|
|
|
icons << QApplication::style()->standardIcon(QStyle::SP_DialogCancelButton);
|
|
|
|
|
#else
|
2021-06-04 05:33:16 +00:00
|
|
|
|
QList<int> icons;
|
|
|
|
|
icons << 0xe68d << 0xe672 << 0xe674 << 0xea36 << 0xe74c;
|
2019-12-19 01:48:51 +00:00
|
|
|
|
|
|
|
|
|
//判断图形字体是否存在,不存在则加入
|
|
|
|
|
QFont iconFont;
|
|
|
|
|
QFontDatabase fontDb;
|
|
|
|
|
if (!fontDb.families().contains("iconfont")) {
|
2021-11-03 06:13:56 +00:00
|
|
|
|
int fontId = fontDb.addApplicationFont(":/font/iconfont.ttf");
|
2019-12-19 01:48:51 +00:00
|
|
|
|
QStringList fontName = fontDb.applicationFontFamilies(fontId);
|
2023-03-20 07:04:23 +00:00
|
|
|
|
if (fontName.count() == 0) {
|
2019-12-19 01:48:51 +00:00
|
|
|
|
qDebug() << "load iconfont.ttf error";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (fontDb.families().contains("iconfont")) {
|
|
|
|
|
iconFont = QFont("iconfont");
|
|
|
|
|
iconFont.setPixelSize(17);
|
|
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(4,8,0))
|
|
|
|
|
iconFont.setHintingPreference(QFont::PreferNoHinting);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
//循环添加顶部按钮
|
2023-03-20 07:04:23 +00:00
|
|
|
|
for (int i = 0; i < btns.count(); ++i) {
|
2019-12-19 01:48:51 +00:00
|
|
|
|
QPushButton *btn = new QPushButton;
|
|
|
|
|
//绑定按钮单击事件,用来发出信号通知
|
|
|
|
|
connect(btn, SIGNAL(clicked(bool)), this, SLOT(btnClicked()));
|
|
|
|
|
//设置标识,用来区别按钮
|
|
|
|
|
btn->setObjectName(btns.at(i));
|
|
|
|
|
//设置固定宽度
|
|
|
|
|
btn->setFixedWidth(20);
|
|
|
|
|
//设置拉伸策略使得填充
|
|
|
|
|
btn->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
|
|
|
|
|
//设置焦点策略为无焦点,避免单击后焦点跑到按钮上
|
|
|
|
|
btn->setFocusPolicy(Qt::NoFocus);
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
//设置图标大小和图标
|
|
|
|
|
btn->setIconSize(QSize(16, 16));
|
|
|
|
|
btn->setIcon(icons.at(i));
|
|
|
|
|
#else
|
|
|
|
|
btn->setFont(iconFont);
|
2021-06-04 05:33:16 +00:00
|
|
|
|
btn->setText((QChar)icons.at(i));
|
2019-12-19 01:48:51 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
//将按钮加到布局中
|
|
|
|
|
layout->addWidget(btn);
|
|
|
|
|
}
|
2020-06-01 09:40:18 +00:00
|
|
|
|
}
|
2019-12-19 01:48:51 +00:00
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::initFlowStyle()
|
2020-06-01 09:40:18 +00:00
|
|
|
|
{
|
|
|
|
|
//设置样式以便区分,可以自行更改样式,也可以不用样式
|
|
|
|
|
QStringList qss;
|
|
|
|
|
QString rgba = QString("rgba(%1,%2,%3,150)").arg(flowBgColor.red()).arg(flowBgColor.green()).arg(flowBgColor.blue());
|
|
|
|
|
qss.append(QString("#flowPanel{background:%1;border:none;}").arg(rgba));
|
|
|
|
|
qss.append(QString("QPushButton{border:none;padding:0px;background:rgba(0,0,0,0);}"));
|
|
|
|
|
qss.append(QString("QPushButton:pressed{color:%1;}").arg(flowPressColor.name()));
|
|
|
|
|
flowPanel->setStyleSheet(qss.join(""));
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
VideoWindow::~VideoWindow()
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
if (timerCheck->isActive()) {
|
|
|
|
|
timerCheck->stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
close();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::resizeEvent(QResizeEvent *)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
//重新设置顶部工具栏的位置和宽高,可以自行设置顶部显示或者底部显示
|
|
|
|
|
int height = 20;
|
|
|
|
|
flowPanel->setGeometry(borderWidth, borderWidth, this->width() - (borderWidth * 2), height);
|
|
|
|
|
//flowPanel->setGeometry(borderWidth, this->height() - height - borderWidth, this->width() - (borderWidth * 2), height);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-09 12:39:42 +00:00
|
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0))
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::enterEvent(QEnterEvent *)
|
2021-11-09 12:39:42 +00:00
|
|
|
|
#else
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::enterEvent(QEvent *)
|
2021-11-09 12:39:42 +00:00
|
|
|
|
#endif
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
//这里还可以增加一个判断,是否获取了焦点的才需要显示
|
|
|
|
|
//if (this->hasFocus()) {}
|
|
|
|
|
if (flowEnable) {
|
|
|
|
|
flowPanel->setVisible(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::leaveEvent(QEvent *)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
if (flowEnable) {
|
|
|
|
|
flowPanel->setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::dropEvent(QDropEvent *event)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
//拖放完毕鼠标松开的时候执行
|
|
|
|
|
//判断拖放进来的类型,取出文件,进行播放
|
2021-07-21 08:06:22 +00:00
|
|
|
|
QString url;
|
2020-06-22 02:14:10 +00:00
|
|
|
|
if (event->mimeData()->hasUrls()) {
|
2021-07-21 08:06:22 +00:00
|
|
|
|
url = event->mimeData()->urls().first().toLocalFile();
|
2019-12-19 01:48:51 +00:00
|
|
|
|
} else if (event->mimeData()->hasFormat("application/x-qabstractitemmodeldatalist")) {
|
|
|
|
|
QTreeWidget *treeWidget = (QTreeWidget *)event->source();
|
2023-01-30 03:41:18 +00:00
|
|
|
|
if (treeWidget) {
|
2021-07-21 08:06:22 +00:00
|
|
|
|
url = treeWidget->currentItem()->data(0, Qt::UserRole).toString();
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-07-21 08:06:22 +00:00
|
|
|
|
|
|
|
|
|
if (!url.isEmpty()) {
|
2023-12-06 11:15:52 +00:00
|
|
|
|
Q_EMIT fileDrag(url);
|
2021-07-21 08:06:22 +00:00
|
|
|
|
this->restart(url);
|
|
|
|
|
}
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::dragEnterEvent(QDragEnterEvent *event)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
//拖曳进来的时候先判断下类型,非法类型则不处理
|
2020-06-22 02:14:10 +00:00
|
|
|
|
if (event->mimeData()->hasFormat("application/x-qabstractitemmodeldatalist")) {
|
2019-12-19 01:48:51 +00:00
|
|
|
|
event->setDropAction(Qt::CopyAction);
|
|
|
|
|
event->accept();
|
2020-06-22 02:14:10 +00:00
|
|
|
|
} else if (event->mimeData()->hasFormat("text/uri-list")) {
|
2019-12-19 01:48:51 +00:00
|
|
|
|
event->setDropAction(Qt::LinkAction);
|
|
|
|
|
event->accept();
|
|
|
|
|
} else {
|
|
|
|
|
event->ignore();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::paintEvent(QPaintEvent *)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
//如果不需要绘制
|
|
|
|
|
if (!drawImage) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//qDebug() << TIMEMS << "paintEvent" << objectName();
|
|
|
|
|
QPainter painter(this);
|
|
|
|
|
painter.setRenderHints(QPainter::Antialiasing);
|
|
|
|
|
|
|
|
|
|
//绘制边框
|
|
|
|
|
drawBorder(&painter);
|
|
|
|
|
if (!image.isNull()) {
|
|
|
|
|
//绘制背景图片
|
|
|
|
|
drawImg(&painter, image);
|
2020-06-22 02:14:10 +00:00
|
|
|
|
//绘制标签
|
|
|
|
|
drawOSD(&painter, osd1Visible, osd1FontSize, osd1Text, osd1Color, osd1Image, osd1Format, osd1Position);
|
|
|
|
|
drawOSD(&painter, osd2Visible, osd2FontSize, osd2Text, osd2Color, osd2Image, osd2Format, osd2Position);
|
2019-12-19 01:48:51 +00:00
|
|
|
|
} else {
|
|
|
|
|
//绘制背景
|
|
|
|
|
drawBg(&painter);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::drawBorder(QPainter *painter)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
painter->save();
|
2022-04-26 08:56:33 +00:00
|
|
|
|
|
2019-12-19 01:48:51 +00:00
|
|
|
|
QPen pen;
|
|
|
|
|
pen.setWidth(borderWidth);
|
|
|
|
|
pen.setColor(hasFocus() ? focusColor : borderColor);
|
2022-04-26 08:56:33 +00:00
|
|
|
|
//边框宽度=0则不绘制边框
|
|
|
|
|
painter->setPen(borderWidth == 0 ? Qt::NoPen : pen);
|
|
|
|
|
//顺带把背景颜色这里也一并处理
|
|
|
|
|
if (bgColor != Qt::transparent) {
|
|
|
|
|
painter->setBrush(bgColor);
|
|
|
|
|
}
|
2019-12-19 01:48:51 +00:00
|
|
|
|
painter->drawRect(rect());
|
2022-04-26 08:56:33 +00:00
|
|
|
|
|
2019-12-19 01:48:51 +00:00
|
|
|
|
painter->restore();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::drawBg(QPainter *painter)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
painter->save();
|
|
|
|
|
|
|
|
|
|
//背景图片为空则绘制文字,否则绘制背景图片
|
|
|
|
|
if (bgImage.isNull()) {
|
2020-06-30 09:54:00 +00:00
|
|
|
|
painter->setFont(this->font());
|
2020-12-24 10:00:09 +00:00
|
|
|
|
painter->setPen(palette().windowText().color());
|
2019-12-19 01:48:51 +00:00
|
|
|
|
painter->drawText(rect(), Qt::AlignCenter, bgText);
|
|
|
|
|
} else {
|
|
|
|
|
//居中绘制
|
2020-09-26 02:15:16 +00:00
|
|
|
|
int x = rect().center().x() - bgImage.width() / 2;
|
|
|
|
|
int y = rect().center().y() - bgImage.height() / 2;
|
|
|
|
|
QPoint point(x, y);
|
2019-12-19 01:48:51 +00:00
|
|
|
|
painter->drawImage(point, bgImage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
painter->restore();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::drawImg(QPainter *painter, QImage img)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
painter->save();
|
|
|
|
|
|
|
|
|
|
int offset = borderWidth * 1 + 0;
|
|
|
|
|
if (fillImage) {
|
|
|
|
|
QRect rect(offset / 2, offset / 2, width() - offset, height() - offset);
|
|
|
|
|
painter->drawImage(rect, img);
|
|
|
|
|
} else {
|
|
|
|
|
//按照比例自动居中绘制
|
|
|
|
|
img = img.scaled(width() - offset, height() - offset, Qt::KeepAspectRatio);
|
2020-09-26 02:15:16 +00:00
|
|
|
|
int x = rect().center().x() - img.width() / 2;
|
|
|
|
|
int y = rect().center().y() - img.height() / 2;
|
|
|
|
|
QPoint point(x, y);
|
2019-12-19 01:48:51 +00:00
|
|
|
|
painter->drawImage(point, img);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
painter->restore();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::drawOSD(QPainter *painter,
|
2020-06-22 02:14:10 +00:00
|
|
|
|
bool osdVisible,
|
2019-12-19 01:48:51 +00:00
|
|
|
|
int osdFontSize,
|
|
|
|
|
const QString &osdText,
|
|
|
|
|
const QColor &osdColor,
|
|
|
|
|
const QImage &osdImage,
|
2022-11-01 06:28:21 +00:00
|
|
|
|
const VideoWindow::OSDFormat &osdFormat,
|
|
|
|
|
const VideoWindow::OSDPosition &osdPosition)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
2020-06-22 02:14:10 +00:00
|
|
|
|
if (!osdVisible) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-19 01:48:51 +00:00
|
|
|
|
painter->save();
|
|
|
|
|
|
|
|
|
|
//标签位置尽量偏移多一点避免遮挡
|
|
|
|
|
QRect osdRect(rect().x() + (borderWidth * 2), rect().y() + (borderWidth * 2), width() - (borderWidth * 5), height() - (borderWidth * 5));
|
|
|
|
|
int flag = Qt::AlignLeft | Qt::AlignTop;
|
|
|
|
|
QPoint point = QPoint(osdRect.x(), osdRect.y());
|
|
|
|
|
|
|
|
|
|
if (osdPosition == OSDPosition_Left_Top) {
|
|
|
|
|
flag = Qt::AlignLeft | Qt::AlignTop;
|
|
|
|
|
point = QPoint(osdRect.x(), osdRect.y());
|
|
|
|
|
} else if (osdPosition == OSDPosition_Left_Bottom) {
|
|
|
|
|
flag = Qt::AlignLeft | Qt::AlignBottom;
|
|
|
|
|
point = QPoint(osdRect.x(), osdRect.height() - osdImage.height());
|
|
|
|
|
} else if (osdPosition == OSDPosition_Right_Top) {
|
|
|
|
|
flag = Qt::AlignRight | Qt::AlignTop;
|
|
|
|
|
point = QPoint(osdRect.width() - osdImage.width(), osdRect.y());
|
|
|
|
|
} else if (osdPosition == OSDPosition_Right_Bottom) {
|
|
|
|
|
flag = Qt::AlignRight | Qt::AlignBottom;
|
|
|
|
|
point = QPoint(osdRect.width() - osdImage.width(), osdRect.height() - osdImage.height());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (osdFormat == OSDFormat_Image) {
|
|
|
|
|
painter->drawImage(point, osdImage);
|
|
|
|
|
} else {
|
|
|
|
|
QDateTime now = QDateTime::currentDateTime();
|
|
|
|
|
QString text = osdText;
|
|
|
|
|
if (osdFormat == OSDFormat_Date) {
|
|
|
|
|
text = now.toString("yyyy-MM-dd");
|
|
|
|
|
} else if (osdFormat == OSDFormat_Time) {
|
|
|
|
|
text = now.toString("HH:mm:ss");
|
|
|
|
|
} else if (osdFormat == OSDFormat_DateTime) {
|
|
|
|
|
text = now.toString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//设置颜色及字号
|
|
|
|
|
QFont font;
|
|
|
|
|
font.setPixelSize(osdFontSize);
|
|
|
|
|
painter->setPen(osdColor);
|
|
|
|
|
painter->setFont(font);
|
|
|
|
|
|
|
|
|
|
painter->drawText(osdRect, flag, text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
painter->restore();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
QImage VideoWindow::getImage() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->image;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
QPixmap VideoWindow::getPixmap() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
2020-11-19 02:44:45 +00:00
|
|
|
|
return QPixmap();
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
QString VideoWindow::getUrl() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->property("url").toString();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
QDateTime VideoWindow::getLastTime() const
|
2020-11-19 02:44:45 +00:00
|
|
|
|
{
|
|
|
|
|
return QDateTime::currentDateTime();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
bool VideoWindow::getCallback() const
|
2020-11-19 02:44:45 +00:00
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
bool VideoWindow::getIsPlaying() const
|
2020-11-19 02:44:45 +00:00
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
bool VideoWindow::getIsRtsp() const
|
2020-11-19 02:44:45 +00:00
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
bool VideoWindow::getIsUsbCamera() const
|
2020-11-19 02:44:45 +00:00
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
bool VideoWindow::getCopyImage() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->copyImage;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
bool VideoWindow::getCheckLive() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->checkLive;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
bool VideoWindow::getDrawImage() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->drawImage;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
bool VideoWindow::getFillImage() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->fillImage;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
bool VideoWindow::getFlowEnable() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->flowEnable;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
QColor VideoWindow::getFlowBgColor() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->flowBgColor;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
QColor VideoWindow::getFlowPressColor() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->flowPressColor;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
int VideoWindow::getTimeout() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->timeout;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
int VideoWindow::getBorderWidth() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->borderWidth;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
QColor VideoWindow::getBorderColor() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->borderColor;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
QColor VideoWindow::getFocusColor() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->focusColor;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
QColor VideoWindow::getBgColor() const
|
2021-01-28 04:55:09 +00:00
|
|
|
|
{
|
|
|
|
|
return this->bgColor;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
QString VideoWindow::getBgText() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->bgText;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
QImage VideoWindow::getBgImage() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->bgImage;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
bool VideoWindow::getOSD1Visible() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->osd1Visible;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
int VideoWindow::getOSD1FontSize() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->osd1FontSize;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
QString VideoWindow::getOSD1Text() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->osd1Text;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
QColor VideoWindow::getOSD1Color() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->osd1Color;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
QImage VideoWindow::getOSD1Image() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->osd1Image;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
VideoWindow::OSDFormat VideoWindow::getOSD1Format() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->osd1Format;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
VideoWindow::OSDPosition VideoWindow::getOSD1Position() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->osd1Position;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
bool VideoWindow::getOSD2Visible() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->osd2Visible;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
int VideoWindow::getOSD2FontSize() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->osd2FontSize;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
QString VideoWindow::getOSD2Text() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->osd2Text;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
QColor VideoWindow::getOSD2Color() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->osd2Color;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
QImage VideoWindow::getOSD2Image() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->osd2Image;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
VideoWindow::OSDFormat VideoWindow::getOSD2Format() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->osd2Format;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
VideoWindow::OSDPosition VideoWindow::getOSD2Position() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
return this->osd2Position;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
int VideoWindow::getFaceBorder() const
|
2020-11-19 02:44:45 +00:00
|
|
|
|
{
|
|
|
|
|
return this->faceBorder;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
QColor VideoWindow::getFaceColor() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
2020-11-19 02:44:45 +00:00
|
|
|
|
return this->faceColor;
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
QList<QRect> VideoWindow::getFaceRects() const
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
2020-11-19 02:44:45 +00:00
|
|
|
|
return this->faceRects;
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
QSize VideoWindow::sizeHint() const
|
2021-03-31 07:58:26 +00:00
|
|
|
|
{
|
|
|
|
|
return QSize(400, 300);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
QSize VideoWindow::minimumSizeHint() const
|
2021-03-31 07:58:26 +00:00
|
|
|
|
{
|
|
|
|
|
return QSize(40, 30);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::updateImage(const QImage &image)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
//拷贝图片有个好处,当处理器比较差的时候,图片不会产生断层,缺点是占用时间
|
|
|
|
|
//默认QImage类型是浅拷贝,可能正在绘制的时候,那边已经更改了图片的上部分数据
|
|
|
|
|
this->image = copyImage ? image.copy() : image;
|
|
|
|
|
this->update();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::checkVideo()
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
QDateTime now = QDateTime::currentDateTime();
|
|
|
|
|
QDateTime lastTime = now;
|
|
|
|
|
int sec = lastTime.secsTo(now);
|
|
|
|
|
if (sec >= timeout) {
|
2021-07-21 08:06:22 +00:00
|
|
|
|
restart(this->getUrl());
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::btnClicked()
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
QPushButton *btn = (QPushButton *)sender();
|
2023-12-06 11:15:52 +00:00
|
|
|
|
Q_EMIT btnClicked(btn->objectName());
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
uint VideoWindow::getLength()
|
2020-10-29 00:43:51 +00:00
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
uint VideoWindow::getPosition()
|
2020-10-29 00:43:51 +00:00
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setPosition(int position)
|
2020-10-29 00:43:51 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
bool VideoWindow::getMuted()
|
2020-10-29 00:43:51 +00:00
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setMuted(bool muted)
|
2020-10-29 00:43:51 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
int VideoWindow::getVolume()
|
2020-10-29 00:43:51 +00:00
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setVolume(int volume)
|
2020-10-29 00:43:51 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setInterval(int interval)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setSleepTime(int sleepTime)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setCheckTime(int checkTime)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setCheckConn(bool checkConn)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setUrl(const QString &url)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->setProperty("url", url);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setCallback(bool callback)
|
2020-11-19 02:44:45 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setHardware(const QString &hardware)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setTransport(const QString &transport)
|
2020-11-20 01:21:00 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setSaveFile(bool saveFile)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setSaveInterval(int saveInterval)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setFileFlag(const QString &fileFlag)
|
2020-11-19 02:44:45 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setSavePath(const QString &savePath)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
//如果目录不存在则新建
|
|
|
|
|
QDir dir(savePath);
|
|
|
|
|
if (!dir.exists()) {
|
|
|
|
|
dir.mkdir(savePath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setFileName(const QString &fileName)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setCopyImage(bool copyImage)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->copyImage = copyImage;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setCheckLive(bool checkLive)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->checkLive = checkLive;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setDrawImage(bool drawImage)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->drawImage = drawImage;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setFillImage(bool fillImage)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->fillImage = fillImage;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setFlowEnable(bool flowEnable)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->flowEnable = flowEnable;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setFlowBgColor(const QColor &flowBgColor)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
if (this->flowBgColor != flowBgColor) {
|
|
|
|
|
this->flowBgColor = flowBgColor;
|
|
|
|
|
this->initFlowStyle();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setFlowPressColor(const QColor &flowPressColor)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
if (this->flowPressColor != flowPressColor) {
|
|
|
|
|
this->flowPressColor = flowPressColor;
|
|
|
|
|
this->initFlowStyle();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setTimeout(int timeout)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->timeout = timeout;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setBorderWidth(int borderWidth)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->borderWidth = borderWidth;
|
2021-01-28 04:55:09 +00:00
|
|
|
|
this->update();
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setBorderColor(const QColor &borderColor)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->borderColor = borderColor;
|
2021-01-28 04:55:09 +00:00
|
|
|
|
this->update();
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setFocusColor(const QColor &focusColor)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->focusColor = focusColor;
|
2021-01-28 04:55:09 +00:00
|
|
|
|
this->update();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setBgColor(const QColor &bgColor)
|
2021-01-28 04:55:09 +00:00
|
|
|
|
{
|
|
|
|
|
this->bgColor = bgColor;
|
|
|
|
|
this->update();
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setBgText(const QString &bgText)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->bgText = bgText;
|
2021-01-28 04:55:09 +00:00
|
|
|
|
this->update();
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setBgImage(const QImage &bgImage)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->bgImage = bgImage;
|
2021-01-28 04:55:09 +00:00
|
|
|
|
this->update();
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setOSD1Visible(bool osdVisible)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->osd1Visible = osdVisible;
|
2021-01-28 04:55:09 +00:00
|
|
|
|
this->update();
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setOSD1FontSize(int osdFontSize)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->osd1FontSize = osdFontSize;
|
2021-01-28 04:55:09 +00:00
|
|
|
|
this->update();
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setOSD1Text(const QString &osdText)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->osd1Text = osdText;
|
2021-01-28 04:55:09 +00:00
|
|
|
|
this->update();
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setOSD1Color(const QColor &osdColor)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->osd1Color = osdColor;
|
2021-01-28 04:55:09 +00:00
|
|
|
|
this->update();
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setOSD1Image(const QImage &osdImage)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->osd1Image = osdImage;
|
2021-01-28 04:55:09 +00:00
|
|
|
|
this->update();
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setOSD1Format(const VideoWindow::OSDFormat &osdFormat)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->osd1Format = osdFormat;
|
2021-01-28 04:55:09 +00:00
|
|
|
|
this->update();
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setOSD1Position(const VideoWindow::OSDPosition &osdPosition)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->osd1Position = osdPosition;
|
2021-01-28 04:55:09 +00:00
|
|
|
|
this->update();
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setOSD2Visible(bool osdVisible)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->osd2Visible = osdVisible;
|
2021-01-28 04:55:09 +00:00
|
|
|
|
this->update();
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setOSD2FontSize(int osdFontSize)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->osd2FontSize = osdFontSize;
|
2021-01-28 04:55:09 +00:00
|
|
|
|
this->update();
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setOSD2Text(const QString &osdText)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->osd2Text = osdText;
|
2021-01-28 04:55:09 +00:00
|
|
|
|
this->update();
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setOSD2Color(const QColor &osdColor)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->osd2Color = osdColor;
|
2021-01-28 04:55:09 +00:00
|
|
|
|
this->update();
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setOSD2Image(const QImage &osdImage)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->osd2Image = osdImage;
|
2021-01-28 04:55:09 +00:00
|
|
|
|
this->update();
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setOSD2Format(const VideoWindow::OSDFormat &osdFormat)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->osd2Format = osdFormat;
|
2021-01-28 04:55:09 +00:00
|
|
|
|
this->update();
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setOSD2Position(const VideoWindow::OSDPosition &osdPosition)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
this->osd2Position = osdPosition;
|
2021-01-28 04:55:09 +00:00
|
|
|
|
this->update();
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setOSD1Format(quint8 osdFormat)
|
2021-01-16 03:24:07 +00:00
|
|
|
|
{
|
2022-11-01 06:28:21 +00:00
|
|
|
|
setOSD1Format((VideoWindow::OSDFormat)osdFormat);
|
2021-01-16 03:24:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setOSD2Format(quint8 osdFormat)
|
2021-01-16 03:24:07 +00:00
|
|
|
|
{
|
2022-11-01 06:28:21 +00:00
|
|
|
|
setOSD2Format((VideoWindow::OSDFormat)osdFormat);
|
2021-01-16 03:24:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setOSD1Position(quint8 osdPosition)
|
2021-01-16 03:24:07 +00:00
|
|
|
|
{
|
2022-11-01 06:28:21 +00:00
|
|
|
|
setOSD1Position((VideoWindow::OSDPosition)osdPosition);
|
2021-01-16 03:24:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setOSD2Position(quint8 osdPosition)
|
2021-01-16 03:24:07 +00:00
|
|
|
|
{
|
2022-11-01 06:28:21 +00:00
|
|
|
|
setOSD2Position((VideoWindow::OSDPosition)osdPosition);
|
2021-01-16 03:24:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setFaceBorder(int faceBorder)
|
2020-11-19 02:44:45 +00:00
|
|
|
|
{
|
|
|
|
|
this->faceBorder = faceBorder;
|
2021-01-28 04:55:09 +00:00
|
|
|
|
this->update();
|
2020-11-19 02:44:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setFaceColor(const QColor &faceColor)
|
2020-11-19 02:44:45 +00:00
|
|
|
|
{
|
|
|
|
|
this->faceColor = faceColor;
|
2021-01-28 04:55:09 +00:00
|
|
|
|
this->update();
|
2020-11-19 02:44:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::setFaceRects(const QList<QRect> &faceRects)
|
2020-11-19 02:44:45 +00:00
|
|
|
|
{
|
|
|
|
|
this->faceRects = faceRects;
|
2021-01-28 04:55:09 +00:00
|
|
|
|
this->update();
|
2020-11-19 02:44:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::open()
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
//qDebug() << TIMEMS << "open video" << objectName();
|
|
|
|
|
clear();
|
|
|
|
|
|
|
|
|
|
//如果是图片则只显示图片就行
|
|
|
|
|
image = QImage(this->property("url").toString());
|
|
|
|
|
if (!image.isNull()) {
|
|
|
|
|
this->update();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-21 08:06:22 +00:00
|
|
|
|
//thread->play();
|
|
|
|
|
//thread->start();
|
2019-12-19 01:48:51 +00:00
|
|
|
|
|
|
|
|
|
if (checkLive) {
|
|
|
|
|
timerCheck->start();
|
|
|
|
|
}
|
2021-07-21 08:06:22 +00:00
|
|
|
|
|
|
|
|
|
this->setProperty("isPause", false);
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::pause()
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
2021-07-21 08:06:22 +00:00
|
|
|
|
if (!this->property("isPause").toBool()) {
|
|
|
|
|
//thread->pause();
|
|
|
|
|
this->setProperty("isPause", true);
|
|
|
|
|
}
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::next()
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
2021-07-21 08:06:22 +00:00
|
|
|
|
if (this->property("isPause").toBool()) {
|
|
|
|
|
//thread->next();
|
|
|
|
|
this->setProperty("isPause", false);
|
|
|
|
|
}
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::close()
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
if (checkLive) {
|
|
|
|
|
timerCheck->stop();
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-21 08:06:22 +00:00
|
|
|
|
this->clear();
|
|
|
|
|
//QTimer::singleShot(5, this, SLOT(clear()));
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::restart(const QString &url, int delayOpen)
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
//qDebug() << TIMEMS << "restart video" << objectName();
|
2021-07-21 08:06:22 +00:00
|
|
|
|
//关闭视频
|
2019-12-19 01:48:51 +00:00
|
|
|
|
close();
|
2021-07-21 08:06:22 +00:00
|
|
|
|
//重新设置播放地址
|
|
|
|
|
setUrl(url);
|
|
|
|
|
|
|
|
|
|
//打开视频
|
2020-11-19 02:44:45 +00:00
|
|
|
|
if (delayOpen > 0) {
|
|
|
|
|
QTimer::singleShot(delayOpen, this, SLOT(open()));
|
|
|
|
|
} else {
|
|
|
|
|
open();
|
|
|
|
|
}
|
2019-12-19 01:48:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::clear()
|
2019-12-19 01:48:51 +00:00
|
|
|
|
{
|
|
|
|
|
image = QImage();
|
|
|
|
|
this->update();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-01 06:28:21 +00:00
|
|
|
|
void VideoWindow::snap(const QString &fileName)
|
2020-11-19 02:44:45 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|