更新
This commit is contained in:
@@ -20,12 +20,59 @@ VideoWidget::VideoWidget(QWidget *parent) : QWidget(parent)
|
|||||||
//设置支持拖放
|
//设置支持拖放
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
|
//定时器校验视频
|
||||||
timerCheck = new QTimer(this);
|
timerCheck = new QTimer(this);
|
||||||
timerCheck->setInterval(10 * 1000);
|
timerCheck->setInterval(10 * 1000);
|
||||||
connect(timerCheck, SIGNAL(timeout()), this, SLOT(checkVideo()));
|
connect(timerCheck, SIGNAL(timeout()), this, SLOT(checkVideo()));
|
||||||
|
|
||||||
image = QImage();
|
image = QImage();
|
||||||
|
copyImage = false;
|
||||||
|
checkLive = true;
|
||||||
|
drawImage = true;
|
||||||
|
fillImage = true;
|
||||||
|
|
||||||
|
flowEnable = false;
|
||||||
|
flowBgColor = "#000000";
|
||||||
|
flowPressColor = "#5EC7D9";
|
||||||
|
|
||||||
|
timeout = 20;
|
||||||
|
borderWidth = 5;
|
||||||
|
borderColor = "#000000";
|
||||||
|
focusColor = "#22A3A9";
|
||||||
|
bgText = "实时视频";
|
||||||
|
bgImage = QImage();
|
||||||
|
|
||||||
|
osd1Visible = false;
|
||||||
|
osd1FontSize = 12;
|
||||||
|
osd1Text = "时间";
|
||||||
|
osd1Color = "#FF0000";
|
||||||
|
osd1Image = QImage();
|
||||||
|
osd1Format = OSDFormat_DateTime;
|
||||||
|
osd1Position = OSDPosition_Right_Top;
|
||||||
|
|
||||||
|
osd2Visible = false;
|
||||||
|
osd2FontSize = 12;
|
||||||
|
osd2Text = "通道名称";
|
||||||
|
osd2Color = "#FF0000";
|
||||||
|
osd2Image = QImage();
|
||||||
|
osd2Format = OSDFormat_Text;
|
||||||
|
osd2Position = OSDPosition_Left_Bottom;
|
||||||
|
|
||||||
|
//初始化解码线程
|
||||||
|
this->initThread();
|
||||||
|
//初始化悬浮条
|
||||||
|
this->initFlowPanel();
|
||||||
|
//初始化悬浮条样式
|
||||||
|
this->initFlowStyle();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VideoWidget::initThread()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void VideoWidget::initFlowPanel()
|
||||||
|
{
|
||||||
//顶部工具栏,默认隐藏,鼠标移入显示移除隐藏
|
//顶部工具栏,默认隐藏,鼠标移入显示移除隐藏
|
||||||
flowPanel = new QWidget(this);
|
flowPanel = new QWidget(this);
|
||||||
flowPanel->setObjectName("flowPanel");
|
flowPanel->setObjectName("flowPanel");
|
||||||
@@ -101,40 +148,17 @@ VideoWidget::VideoWidget(QWidget *parent) : QWidget(parent)
|
|||||||
//将按钮加到布局中
|
//将按钮加到布局中
|
||||||
layout->addWidget(btn);
|
layout->addWidget(btn);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
copyImage = false;
|
void VideoWidget::initFlowStyle()
|
||||||
checkLive = true;
|
{
|
||||||
drawImage = true;
|
//设置样式以便区分,可以自行更改样式,也可以不用样式
|
||||||
fillImage = true;
|
QStringList qss;
|
||||||
|
QString rgba = QString("rgba(%1,%2,%3,150)").arg(flowBgColor.red()).arg(flowBgColor.green()).arg(flowBgColor.blue());
|
||||||
flowEnable = false;
|
qss.append(QString("#flowPanel{background:%1;border:none;}").arg(rgba));
|
||||||
flowBgColor = "#000000";
|
qss.append(QString("QPushButton{border:none;padding:0px;background:rgba(0,0,0,0);}"));
|
||||||
flowPressColor = "#5EC7D9";
|
qss.append(QString("QPushButton:pressed{color:%1;}").arg(flowPressColor.name()));
|
||||||
|
flowPanel->setStyleSheet(qss.join(""));
|
||||||
timeout = 20;
|
|
||||||
borderWidth = 5;
|
|
||||||
borderColor = "#000000";
|
|
||||||
focusColor = "#22A3A9";
|
|
||||||
bgText = "实时视频";
|
|
||||||
bgImage = QImage();
|
|
||||||
|
|
||||||
osd1Visible = false;
|
|
||||||
osd1FontSize = 12;
|
|
||||||
osd1Text = "时间";
|
|
||||||
osd1Color = "#FF0000";
|
|
||||||
osd1Image = QImage();
|
|
||||||
osd1Format = OSDFormat_DateTime;
|
|
||||||
osd1Position = OSDPosition_Right_Top;
|
|
||||||
|
|
||||||
osd2Visible = false;
|
|
||||||
osd2FontSize = 12;
|
|
||||||
osd2Text = "通道名称";
|
|
||||||
osd2Color = "#FF0000";
|
|
||||||
osd2Image = QImage();
|
|
||||||
osd2Format = OSDFormat_Text;
|
|
||||||
osd2Position = OSDPosition_Left_Bottom;
|
|
||||||
|
|
||||||
this->initFlowStyle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoWidget::~VideoWidget()
|
VideoWidget::~VideoWidget()
|
||||||
@@ -503,17 +527,6 @@ QSize VideoWidget::minimumSizeHint() const
|
|||||||
return QSize(50, 35);
|
return QSize(50, 35);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoWidget::initFlowStyle()
|
|
||||||
{
|
|
||||||
//设置样式以便区分,可以自行更改样式,也可以不用样式
|
|
||||||
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(""));
|
|
||||||
}
|
|
||||||
|
|
||||||
void VideoWidget::updateImage(const QImage &image)
|
void VideoWidget::updateImage(const QImage &image)
|
||||||
{
|
{
|
||||||
//拷贝图片有个好处,当处理器比较差的时候,图片不会产生断层,缺点是占用时间
|
//拷贝图片有个好处,当处理器比较差的时候,图片不会产生断层,缺点是占用时间
|
||||||
|
|||||||
@@ -3,18 +3,18 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用视频播放控件 作者:feiyangqingyun(QQ:517216493) 2018-5-1
|
* 通用视频播放控件 作者:feiyangqingyun(QQ:517216493) 2018-5-1
|
||||||
* 1:可设置边框大小
|
* 1. 可设置边框大小
|
||||||
* 2:可设置边框颜色
|
* 2. 可设置边框颜色
|
||||||
* 3:可设置两路OSD标签
|
* 3. 可设置两路OSD标签
|
||||||
* 4:可设置是否绘制OSD标签
|
* 4. 可设置是否绘制OSD标签
|
||||||
* 5:可设置标签文本或图片
|
* 5. 可设置标签文本或图片
|
||||||
* 6:可设置OSD位置 左上角+左下角+右上角+右下角
|
* 6. 可设置OSD位置 左上角+左下角+右上角+右下角
|
||||||
* 7:可设置OSD风格 文本+日期+时间+日期时间+图片
|
* 7. 可设置OSD风格 文本+日期+时间+日期时间+图片
|
||||||
* 8:自定义半透明悬浮窗体,一排按钮
|
* 8. 自定义半透明悬浮窗体,一排按钮
|
||||||
* 9:悬浮按钮可自定义设置,包括背景颜色+按下颜色
|
* 9. 悬浮按钮可自定义设置,包括背景颜色+按下颜色
|
||||||
* 10:发送信号通知单击了哪个悬浮按钮
|
* 10. 发送信号通知单击了哪个悬浮按钮
|
||||||
* 11:能够识别拖进来的文件,通知url
|
* 11. 能够识别拖进来的文件,通知url
|
||||||
* 12:提供open close pause等接口
|
* 12. 提供open close pause等接口
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
@@ -147,6 +147,14 @@ private:
|
|||||||
OSDFormat osd2Format; //标签2文本格式
|
OSDFormat osd2Format; //标签2文本格式
|
||||||
OSDPosition osd2Position; //标签2位置
|
OSDPosition osd2Position; //标签2位置
|
||||||
|
|
||||||
|
private:
|
||||||
|
//初始化解码线程
|
||||||
|
void initThread();
|
||||||
|
//初始化悬浮条
|
||||||
|
void initFlowPanel();
|
||||||
|
//初始化悬浮条样式
|
||||||
|
void initFlowStyle();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QImage getImage() const;
|
QImage getImage() const;
|
||||||
QDateTime getLastTime() const;
|
QDateTime getLastTime() const;
|
||||||
@@ -188,8 +196,6 @@ public:
|
|||||||
QSize minimumSizeHint() const;
|
QSize minimumSizeHint() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
//初始化悬浮条样式
|
|
||||||
void initFlowStyle();
|
|
||||||
//接收图像并绘制
|
//接收图像并绘制
|
||||||
void updateImage(const QImage &image);
|
void updateImage(const QImage &image);
|
||||||
//校验设备
|
//校验设备
|
||||||
|
|||||||
Reference in New Issue
Block a user