改进部分代码

This commit is contained in:
feiyangqingyun
2021-01-31 20:20:58 +08:00
parent dd9d83d690
commit 5789d8c08c
18 changed files with 2214 additions and 1246 deletions

View File

@@ -273,6 +273,7 @@ void VideoWidget::drawBorder(QPainter *painter)
void VideoWidget::drawBg(QPainter *painter)
{
painter->save();
painter->fillRect(rect(), bgColor);
//背景图片为空则绘制文字,否则绘制背景图片
if (bgImage.isNull()) {
@@ -464,6 +465,11 @@ QColor VideoWidget::getFocusColor() const
return this->focusColor;
}
QColor VideoWidget::getBgColor() const
{
return this->bgColor;
}
QString VideoWidget::getBgText() const
{
return this->bgText;
@@ -736,96 +742,121 @@ void VideoWidget::setTimeout(int timeout)
void VideoWidget::setBorderWidth(int borderWidth)
{
this->borderWidth = borderWidth;
this->update();
}
void VideoWidget::setBorderColor(const QColor &borderColor)
{
this->borderColor = borderColor;
this->update();
}
void VideoWidget::setFocusColor(const QColor &focusColor)
{
this->focusColor = focusColor;
this->update();
}
void VideoWidget::setBgColor(const QColor &bgColor)
{
this->bgColor = bgColor;
this->update();
}
void VideoWidget::setBgText(const QString &bgText)
{
this->bgText = bgText;
this->update();
}
void VideoWidget::setBgImage(const QImage &bgImage)
{
this->bgImage = bgImage;
this->update();
}
void VideoWidget::setOSD1Visible(bool osdVisible)
{
this->osd1Visible = osdVisible;
this->update();
}
void VideoWidget::setOSD1FontSize(int osdFontSize)
{
this->osd1FontSize = osdFontSize;
this->update();
}
void VideoWidget::setOSD1Text(const QString &osdText)
{
this->osd1Text = osdText;
this->update();
}
void VideoWidget::setOSD1Color(const QColor &osdColor)
{
this->osd1Color = osdColor;
this->update();
}
void VideoWidget::setOSD1Image(const QImage &osdImage)
{
this->osd1Image = osdImage;
this->update();
}
void VideoWidget::setOSD1Format(const VideoWidget::OSDFormat &osdFormat)
{
this->osd1Format = osdFormat;
this->update();
}
void VideoWidget::setOSD1Position(const VideoWidget::OSDPosition &osdPosition)
{
this->osd1Position = osdPosition;
this->update();
}
void VideoWidget::setOSD2Visible(bool osdVisible)
{
this->osd2Visible = osdVisible;
this->update();
}
void VideoWidget::setOSD2FontSize(int osdFontSize)
{
this->osd2FontSize = osdFontSize;
this->update();
}
void VideoWidget::setOSD2Text(const QString &osdText)
{
this->osd2Text = osdText;
this->update();
}
void VideoWidget::setOSD2Color(const QColor &osdColor)
{
this->osd2Color = osdColor;
this->update();
}
void VideoWidget::setOSD2Image(const QImage &osdImage)
{
this->osd2Image = osdImage;
this->update();
}
void VideoWidget::setOSD2Format(const VideoWidget::OSDFormat &osdFormat)
{
this->osd2Format = osdFormat;
this->update();
}
void VideoWidget::setOSD2Position(const VideoWidget::OSDPosition &osdPosition)
{
this->osd2Position = osdPosition;
this->update();
}
void VideoWidget::setOSD1Format(quint8 osdFormat)
@@ -851,16 +882,19 @@ void VideoWidget::setOSD2Position(quint8 osdPosition)
void VideoWidget::setFaceBorder(int faceBorder)
{
this->faceBorder = faceBorder;
this->update();
}
void VideoWidget::setFaceColor(const QColor &faceColor)
{
this->faceColor = faceColor;
this->update();
}
void VideoWidget::setFaceRects(const QList<QRect> &faceRects)
{
this->faceRects = faceRects;
this->update();
}
void VideoWidget::open()

View File

@@ -45,7 +45,8 @@ class VideoWidget : public QWidget
Q_PROPERTY(int timeout READ getTimeout WRITE setTimeout)
Q_PROPERTY(int borderWidth READ getBorderWidth WRITE setBorderWidth)
Q_PROPERTY(QColor borderColor READ getBorderColor WRITE setBorderColor)
Q_PROPERTY(QColor focusColor READ getFocusColor WRITE setFocusColor)
Q_PROPERTY(QColor focusColor READ getFocusColor WRITE setFocusColor)
Q_PROPERTY(QColor bgColor READ getBgColor WRITE setBgColor)
Q_PROPERTY(QString bgText READ getBgText WRITE setBgText)
Q_PROPERTY(QImage bgImage READ getBgImage WRITE setBgImage)
@@ -122,7 +123,8 @@ private:
int timeout; //超时时间
int borderWidth; //边框宽度
QColor borderColor; //边框颜色
QColor focusColor; //有焦点边框颜色
QColor focusColor; //有焦点边框颜色
QColor bgColor; //背景颜色
QString bgText; //默认无图像显示文字
QImage bgImage; //默认无图像背景图片
@@ -178,6 +180,7 @@ public:
int getBorderWidth() const;
QColor getBorderColor() const;
QColor getFocusColor() const;
QColor getBgColor() const;
QString getBgText() const;
QImage getBgImage() const;
@@ -288,7 +291,7 @@ public slots:
void setFillImage(bool fillImage);
//设置是否启用悬浮条
void setFlowEnable(bool flowEnable);
void setFlowEnable(bool flowEnable);
//设置悬浮条背景颜色
void setFlowBgColor(const QColor &flowBgColor);
//设置悬浮条按下颜色
@@ -301,7 +304,9 @@ public slots:
//设置边框颜色
void setBorderColor(const QColor &borderColor);
//设置有焦点边框颜色
void setFocusColor(const QColor &focusColor);
void setFocusColor(const QColor &focusColor);
//设置背景颜色
void setBgColor(const QColor &bgColor);
//设置无图像文字
void setBgText(const QString &bgText);
//设置无图像背景图