From f91db840988e4deaebaefaf5dbafe3b3c70b4b25 Mon Sep 17 00:00:00 2001 From: feiyangqingyun Date: Tue, 1 Nov 2022 14:28:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +- third/3rd_qcustomplot/3rd_qcustomplot.pri | 2 + tool/base64helper/base64helper.cpp | 4 +- tool/base64helper/frmbase64helper.cpp | 77 +++--- tool/base64helper/frmbase64helper.h | 5 + tool/base64helper/frmbase64helper.ui | 170 ++++++------ ui/core_base/base64helper.cpp | 4 +- .../{videowidget.jpg => videowindow.jpg} | Bin video/video.pro | 2 +- video/videowidget/frmvideowidget.cpp | 35 --- video/videowidget/frmvideowidget.h | 26 -- .../font/iconfont.ttf | Bin video/videowindow/frmvideowindow.cpp | 35 +++ video/videowindow/frmvideowindow.h | 26 ++ .../frmvideowindow.ui} | 24 +- video/{videowidget => videowindow}/main.cpp | 4 +- video/{videowidget => videowindow}/main.qrc | 0 .../videowindow.cpp} | 258 +++++++++--------- .../videowindow.h} | 18 +- .../videowindow.pro} | 14 +- 20 files changed, 362 insertions(+), 348 deletions(-) rename video/0snap/{videowidget.jpg => videowindow.jpg} (100%) delete mode 100644 video/videowidget/frmvideowidget.cpp delete mode 100644 video/videowidget/frmvideowidget.h rename video/{videowidget => videowindow}/font/iconfont.ttf (100%) create mode 100644 video/videowindow/frmvideowindow.cpp create mode 100644 video/videowindow/frmvideowindow.h rename video/{videowidget/frmvideowidget.ui => videowindow/frmvideowindow.ui} (71%) rename video/{videowidget => videowindow}/main.cpp (94%) rename video/{videowidget => videowindow}/main.qrc (100%) rename video/{videowidget/videowidget.cpp => videowindow/videowindow.cpp} (73%) rename video/{videowidget/videowidget.h => videowindow/videowindow.h} (98%) rename video/{videowidget/videowidget.pro => videowindow/videowindow.pro} (50%) diff --git a/README.md b/README.md index ac9a14c..d63cf6b 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ | tool | 工具相关 | livedemo | 程序启动示例 | | video | 视频播放 | videobox | **视频监控布局** | | video | 视频播放 | videopanel | **视频监控面板** | -| video | 视频播放 | videowidget | 视频监控控件 | +| video | 视频播放 | videowindow | 视频监控控件 | | video | 视频播放 | playffmpeg | 视频播放ffmpeg | | video | 视频播放 | playvlc | 视频播放vlc | | video | 视频播放 | plaympv | 视频播放mpv | @@ -144,8 +144,8 @@ ![](video/0snap/videobox.jpg) - 视频监控面板-videopanel ![](video/0snap/videopanel.jpg) -- 视频监控控件-videowidget -![](video/0snap/videowidget.jpg) +- 视频监控控件-videowindow +![](video/0snap/videowindow.jpg) - 视频播放ffmpeg-playffmpeg ![](video/0snap/playffmpeg.jpg) - 视频播放vlc-playvlc diff --git a/third/3rd_qcustomplot/3rd_qcustomplot.pri b/third/3rd_qcustomplot/3rd_qcustomplot.pri index 88a1ef5..d726d2e 100644 --- a/third/3rd_qcustomplot/3rd_qcustomplot.pri +++ b/third/3rd_qcustomplot/3rd_qcustomplot.pri @@ -2,6 +2,8 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += printsupport greaterThan(QT_MAJOR_VERSION, 4): CONFIG += c++11 #lessThan(QT_MAJOR_VERSION, 5): QMAKE_CXXFLAGS += -std=c++11 +DEFINES += qcustomplot + #引入平滑曲线类 HEADERS += $$PWD/smoothcurve.h SOURCES += $$PWD/smoothcurve.cpp diff --git a/tool/base64helper/base64helper.cpp b/tool/base64helper/base64helper.cpp index 6093970..e294fcd 100644 --- a/tool/base64helper/base64helper.cpp +++ b/tool/base64helper/base64helper.cpp @@ -32,10 +32,10 @@ QImage Base64Helper::base64ToImagex(const QByteArray &data) QString Base64Helper::textToBase64(const QString &text) { - return QString(text.toLocal8Bit().toBase64()); + return QString(text.toUtf8().toBase64()); } QString Base64Helper::base64ToText(const QString &text) { - return QString(QByteArray::fromBase64(text.toLocal8Bit())); + return QString(QByteArray::fromBase64(text.toUtf8())); } diff --git a/tool/base64helper/frmbase64helper.cpp b/tool/base64helper/frmbase64helper.cpp index 864c555..3769725 100644 --- a/tool/base64helper/frmbase64helper.cpp +++ b/tool/base64helper/frmbase64helper.cpp @@ -4,7 +4,6 @@ #include "ui_frmbase64helper.h" #include "base64helper.h" #include "qfiledialog.h" -#include "qelapsedtimer.h" #include "qdebug.h" frmBase64Helper::frmBase64Helper(QWidget *parent) : QWidget(parent), ui(new Ui::frmBase64Helper) @@ -17,6 +16,18 @@ frmBase64Helper::~frmBase64Helper() delete ui; } +void frmBase64Helper::showTime(qint64 size1, qint64 size2) +{ + //统计用时 +#if (QT_VERSION >= QT_VERSION_CHECK(4,8,0)) + double elapsed = (double)timer.nsecsElapsed() / 1000000; +#else + double elapsed = (double)timer.elapsed(); +#endif + QString time = QString::number(elapsed, 'f', 3); + ui->labInfo->setText(QString("用时: %1 毫秒 大小: %2 -> %3").arg(time).arg(size1).arg(size2)); +} + void frmBase64Helper::on_btnOpen_clicked() { QString fileName = QFileDialog::getOpenFileName(this, "选择文件", "", "图片(*.png *.bmp *.jpg)"); @@ -38,60 +49,56 @@ void frmBase64Helper::on_btnClear_clicked() void frmBase64Helper::on_btnImageToBase64_clicked() { - //计时 - QElapsedTimer time; - time.start(); - QString fileName = ui->txtFile->text().trimmed(); - if (!fileName.isEmpty()) { - ui->txtBase64->setText(Base64Helper::imageToBase64(QImage(fileName))); + if (fileName.isEmpty()) { + return; } - //统计用时 -#if (QT_VERSION >= QT_VERSION_CHECK(4,8,0)) - double elapsed = (double)time.nsecsElapsed() / 1000000; -#else - double elapsed = (double)time.elapsed(); -#endif - QString strTime = QString::number(elapsed, 'f', 3); - ui->labInfo->setText(QString("图片转base64 用时 %1 毫秒").arg(strTime)); + timer.restart(); + QImage image(fileName); + QString text = Base64Helper::imageToBase64(image); + showTime(QFile(fileName).size(), text.size()); + ui->txtBase64->setText(text); } void frmBase64Helper::on_btnBase64ToImage_clicked() { - //计时 - QElapsedTimer time; - time.start(); - + QString fileName = ui->txtFile->text().trimmed(); QString text = ui->txtBase64->toPlainText().trimmed(); - if (!text.isEmpty()) { - QPixmap pix = QPixmap::fromImage(Base64Helper::base64ToImage(text)); - pix = pix.scaled(ui->labImage->size() - QSize(4, 4), Qt::KeepAspectRatio); - ui->labImage->setPixmap(pix); + if (text.isEmpty()) { + return; } - //统计用时 -#if (QT_VERSION >= QT_VERSION_CHECK(4,8,0)) - double elapsed = (double)time.nsecsElapsed() / 1000000; -#else - double elapsed = (double)time.elapsed(); -#endif - QString strTime = QString::number(elapsed, 'f', 3); - ui->labInfo->setText(QString("base64转图片 用时 %1 毫秒").arg(strTime)); + timer.restart(); + QImage image = Base64Helper::base64ToImage(text); + showTime(text.size(), QFile(fileName).size()); + QPixmap pix = QPixmap::fromImage(image); + pix = pix.scaled(ui->labImage->size() - QSize(4, 4), Qt::KeepAspectRatio); + ui->labImage->setPixmap(pix); } void frmBase64Helper::on_btnTextToBase64_clicked() { QString text = ui->txtText->text().trimmed(); - if (!text.isEmpty()) { - ui->txtBase64->setText(Base64Helper::textToBase64(text)); + if (text.isEmpty()) { + return; } + + timer.restart(); + QString result = Base64Helper::textToBase64(text); + showTime(text.size(), result.size()); + ui->txtBase64->setText(result); } void frmBase64Helper::on_btnBase64ToText_clicked() { QString text = ui->txtBase64->toPlainText().trimmed(); - if (!text.isEmpty()) { - ui->txtText->setText(Base64Helper::base64ToText(text)); + if (text.isEmpty()) { + return; } + + timer.restart(); + QString result = Base64Helper::base64ToText(text); + showTime(text.size(), result.size()); + ui->txtText->setText(result); } diff --git a/tool/base64helper/frmbase64helper.h b/tool/base64helper/frmbase64helper.h index 8e13ae4..3477f73 100644 --- a/tool/base64helper/frmbase64helper.h +++ b/tool/base64helper/frmbase64helper.h @@ -2,6 +2,7 @@ #define FRMBASE64HELPER_H #include +#include namespace Ui { class frmBase64Helper; @@ -17,12 +18,16 @@ public: private: Ui::frmBase64Helper *ui; + QElapsedTimer timer; private slots: + void showTime(qint64 size1, qint64 size2); void on_btnOpen_clicked(); void on_btnClear_clicked(); + void on_btnImageToBase64_clicked(); void on_btnBase64ToImage_clicked(); + void on_btnTextToBase64_clicked(); void on_btnBase64ToText_clicked(); }; diff --git a/tool/base64helper/frmbase64helper.ui b/tool/base64helper/frmbase64helper.ui index 6938d27..d23b970 100644 --- a/tool/base64helper/frmbase64helper.ui +++ b/tool/base64helper/frmbase64helper.ui @@ -14,6 +14,52 @@ Widget + + + + E:/myFile/美女图片/2.jpg + + + + + + + + 120 + 0 + + + + 打开文件 + + + + + + + + 120 + 0 + + + + 图片转base64 + + + + + + + + 120 + 0 + + + + base64转图片 + + + @@ -34,6 +80,45 @@ + + + + + 120 + 0 + + + + 文字转base64 + + + + + + + + 120 + 0 + + + + base64转文字 + + + + + + + QFrame::Box + + + QFrame::Sunken + + + + + + @@ -56,94 +141,9 @@ - - - - - 120 - 0 - - - - 图片转base64 - - - - - - - - 120 - 0 - - - - base64转文字 - - - - - - - - 120 - 0 - - - - 打开文件 - - - - - - - E:/myFile/美女图片/2.jpg - - - - - - - - 120 - 0 - - - - base64转图片 - - - - - - - - 120 - 0 - - - - 文字转base64 - - - - - - - QFrame::Box - - - QFrame::Sunken - - - - - - diff --git a/ui/core_base/base64helper.cpp b/ui/core_base/base64helper.cpp index 6093970..e294fcd 100644 --- a/ui/core_base/base64helper.cpp +++ b/ui/core_base/base64helper.cpp @@ -32,10 +32,10 @@ QImage Base64Helper::base64ToImagex(const QByteArray &data) QString Base64Helper::textToBase64(const QString &text) { - return QString(text.toLocal8Bit().toBase64()); + return QString(text.toUtf8().toBase64()); } QString Base64Helper::base64ToText(const QString &text) { - return QString(QByteArray::fromBase64(text.toLocal8Bit())); + return QString(QByteArray::fromBase64(text.toUtf8())); } diff --git a/video/0snap/videowidget.jpg b/video/0snap/videowindow.jpg similarity index 100% rename from video/0snap/videowidget.jpg rename to video/0snap/videowindow.jpg diff --git a/video/video.pro b/video/video.pro index 6a23bc8..936687e 100644 --- a/video/video.pro +++ b/video/video.pro @@ -1,7 +1,7 @@ TEMPLATE = subdirs SUBDIRS += videobox SUBDIRS += videopanel -SUBDIRS += videowidget +SUBDIRS += videowindow win32 { SUBDIRS += playffmpeg diff --git a/video/videowidget/frmvideowidget.cpp b/video/videowidget/frmvideowidget.cpp deleted file mode 100644 index f4fc519..0000000 --- a/video/videowidget/frmvideowidget.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#pragma execution_character_set("utf-8") - -#include "frmvideowidget.h" -#include "ui_frmvideowidget.h" - -frmVideoWidget::frmVideoWidget(QWidget *parent) : QWidget(parent), ui(new Ui::frmVideoWidget) -{ - ui->setupUi(this); - this->initForm(); -} - -frmVideoWidget::~frmVideoWidget() -{ - delete ui; -} - -void frmVideoWidget::initForm() -{ - ui->videoWidget1->setFlowEnable(true); - ui->videoWidget2->setFlowEnable(true); - ui->videoWidget3->setFlowEnable(true); - ui->videoWidget4->setFlowEnable(true); - - connect(ui->videoWidget1, SIGNAL(btnClicked(QString)), this, SLOT(btnClicked(QString))); - connect(ui->videoWidget2, SIGNAL(btnClicked(QString)), this, SLOT(btnClicked(QString))); - connect(ui->videoWidget3, SIGNAL(btnClicked(QString)), this, SLOT(btnClicked(QString))); - connect(ui->videoWidget4, SIGNAL(btnClicked(QString)), this, SLOT(btnClicked(QString))); -} - -void frmVideoWidget::btnClicked(const QString &objName) -{ - VideoWidget *videoWidget = (VideoWidget *)sender(); - QString str = QString("当前单击了控件 %1 的按钮 %2").arg(videoWidget->objectName()).arg(objName); - ui->label->setText(str); -} diff --git a/video/videowidget/frmvideowidget.h b/video/videowidget/frmvideowidget.h deleted file mode 100644 index c12a88a..0000000 --- a/video/videowidget/frmvideowidget.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef FRMVIDEOWIDGET_H -#define FRMVIDEOWIDGET_H - -#include - -namespace Ui { -class frmVideoWidget; -} - -class frmVideoWidget : public QWidget -{ - Q_OBJECT - -public: - explicit frmVideoWidget(QWidget *parent = 0); - ~frmVideoWidget(); - -private: - Ui::frmVideoWidget *ui; - -private slots: - void initForm(); - void btnClicked(const QString &objName); -}; - -#endif // FRMVIDEOWIDGET_H diff --git a/video/videowidget/font/iconfont.ttf b/video/videowindow/font/iconfont.ttf similarity index 100% rename from video/videowidget/font/iconfont.ttf rename to video/videowindow/font/iconfont.ttf diff --git a/video/videowindow/frmvideowindow.cpp b/video/videowindow/frmvideowindow.cpp new file mode 100644 index 0000000..0503fe2 --- /dev/null +++ b/video/videowindow/frmvideowindow.cpp @@ -0,0 +1,35 @@ +#pragma execution_character_set("utf-8") + +#include "frmvideowindow.h" +#include "ui_frmvideowindow.h" + +frmVideoWindow::frmVideoWindow(QWidget *parent) : QWidget(parent), ui(new Ui::frmVideoWindow) +{ + ui->setupUi(this); + this->initForm(); +} + +frmVideoWindow::~frmVideoWindow() +{ + delete ui; +} + +void frmVideoWindow::initForm() +{ + ui->videoWindow1->setFlowEnable(true); + ui->videoWindow2->setFlowEnable(true); + ui->videoWindow3->setFlowEnable(true); + ui->videoWindow4->setFlowEnable(true); + + connect(ui->videoWindow1, SIGNAL(btnClicked(QString)), this, SLOT(btnClicked(QString))); + connect(ui->videoWindow2, SIGNAL(btnClicked(QString)), this, SLOT(btnClicked(QString))); + connect(ui->videoWindow3, SIGNAL(btnClicked(QString)), this, SLOT(btnClicked(QString))); + connect(ui->videoWindow4, SIGNAL(btnClicked(QString)), this, SLOT(btnClicked(QString))); +} + +void frmVideoWindow::btnClicked(const QString &objName) +{ + VideoWindow *videoWindow = (VideoWindow *)sender(); + QString str = QString("当前单击了控件 %1 的按钮 %2").arg(videoWindow->objectName()).arg(objName); + ui->label->setText(str); +} diff --git a/video/videowindow/frmvideowindow.h b/video/videowindow/frmvideowindow.h new file mode 100644 index 0000000..3d25eed --- /dev/null +++ b/video/videowindow/frmvideowindow.h @@ -0,0 +1,26 @@ +#ifndef FRMVIDEOWINDOW_H +#define FRMVIDEOWINDOW_H + +#include + +namespace Ui { +class frmVideoWindow; +} + +class frmVideoWindow : public QWidget +{ + Q_OBJECT + +public: + explicit frmVideoWindow(QWidget *parent = 0); + ~frmVideoWindow(); + +private: + Ui::frmVideoWindow *ui; + +private slots: + void initForm(); + void btnClicked(const QString &objName); +}; + +#endif // FRMVIDEOWINDOW_H diff --git a/video/videowidget/frmvideowidget.ui b/video/videowindow/frmvideowindow.ui similarity index 71% rename from video/videowidget/frmvideowidget.ui rename to video/videowindow/frmvideowindow.ui index db40a0a..e2dfae1 100644 --- a/video/videowidget/frmvideowidget.ui +++ b/video/videowindow/frmvideowindow.ui @@ -1,7 +1,7 @@ - frmVideoWidget - + frmVideoWindow + 0 @@ -15,9 +15,9 @@ - + - + 0 0 @@ -25,9 +25,9 @@ - + - + 0 0 @@ -35,9 +35,9 @@ - + - + 0 0 @@ -45,9 +45,9 @@ - + - + 0 0 @@ -71,9 +71,9 @@ - VideoWidget + VideoWindow QWidget -
videowidget.h
+
videowindow.h
1
diff --git a/video/videowidget/main.cpp b/video/videowindow/main.cpp similarity index 94% rename from video/videowidget/main.cpp rename to video/videowindow/main.cpp index 61d0dbe..9d81b3b 100644 --- a/video/videowidget/main.cpp +++ b/video/videowindow/main.cpp @@ -1,6 +1,6 @@ #pragma execution_character_set("utf-8") -#include "frmvideowidget.h" +#include "frmvideowindow.h" #include #include @@ -26,7 +26,7 @@ int main(int argc, char *argv[]) QTextCodec::setCodecForLocale(codec); #endif - frmVideoWidget w; + frmVideoWindow w; w.setWindowTitle("视频监控控件 (QQ: 517216493 WX: feiyangqingyun)"); w.resize(800, 600); w.show(); diff --git a/video/videowidget/main.qrc b/video/videowindow/main.qrc similarity index 100% rename from video/videowidget/main.qrc rename to video/videowindow/main.qrc diff --git a/video/videowidget/videowidget.cpp b/video/videowindow/videowindow.cpp similarity index 73% rename from video/videowidget/videowidget.cpp rename to video/videowindow/videowindow.cpp index 414b649..5f23894 100644 --- a/video/videowidget/videowidget.cpp +++ b/video/videowindow/videowindow.cpp @@ -1,6 +1,6 @@ #pragma execution_character_set("utf-8") -#include "videowidget.h" +#include "videowindow.h" #include "qfontdatabase.h" #include "qpushbutton.h" #include "qtreewidget.h" @@ -13,7 +13,7 @@ #include "qurl.h" #include "qdebug.h" -VideoWidget::VideoWidget(QWidget *parent) : QWidget(parent) +VideoWindow::VideoWindow(QWidget *parent) : QWidget(parent) { //设置强焦点 setFocusPolicy(Qt::StrongFocus); @@ -67,12 +67,12 @@ VideoWidget::VideoWidget(QWidget *parent) : QWidget(parent) this->initFlowStyle(); } -void VideoWidget::initThread() +void VideoWindow::initThread() { } -void VideoWidget::initFlowPanel() +void VideoWindow::initFlowPanel() { //顶部工具栏,默认隐藏,鼠标移入显示移除隐藏 flowPanel = new QWidget(this); @@ -151,7 +151,7 @@ void VideoWidget::initFlowPanel() } } -void VideoWidget::initFlowStyle() +void VideoWindow::initFlowStyle() { //设置样式以便区分,可以自行更改样式,也可以不用样式 QStringList qss; @@ -162,7 +162,7 @@ void VideoWidget::initFlowStyle() flowPanel->setStyleSheet(qss.join("")); } -VideoWidget::~VideoWidget() +VideoWindow::~VideoWindow() { if (timerCheck->isActive()) { timerCheck->stop(); @@ -171,7 +171,7 @@ VideoWidget::~VideoWidget() close(); } -void VideoWidget::resizeEvent(QResizeEvent *) +void VideoWindow::resizeEvent(QResizeEvent *) { //重新设置顶部工具栏的位置和宽高,可以自行设置顶部显示或者底部显示 int height = 20; @@ -180,9 +180,9 @@ void VideoWidget::resizeEvent(QResizeEvent *) } #if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) -void VideoWidget::enterEvent(QEnterEvent *) +void VideoWindow::enterEvent(QEnterEvent *) #else -void VideoWidget::enterEvent(QEvent *) +void VideoWindow::enterEvent(QEvent *) #endif { //这里还可以增加一个判断,是否获取了焦点的才需要显示 @@ -192,14 +192,14 @@ void VideoWidget::enterEvent(QEvent *) } } -void VideoWidget::leaveEvent(QEvent *) +void VideoWindow::leaveEvent(QEvent *) { if (flowEnable) { flowPanel->setVisible(false); } } -void VideoWidget::dropEvent(QDropEvent *event) +void VideoWindow::dropEvent(QDropEvent *event) { //拖放完毕鼠标松开的时候执行 //判断拖放进来的类型,取出文件,进行播放 @@ -219,7 +219,7 @@ void VideoWidget::dropEvent(QDropEvent *event) } } -void VideoWidget::dragEnterEvent(QDragEnterEvent *event) +void VideoWindow::dragEnterEvent(QDragEnterEvent *event) { //拖曳进来的时候先判断下类型,非法类型则不处理 if (event->mimeData()->hasFormat("application/x-qabstractitemmodeldatalist")) { @@ -233,7 +233,7 @@ void VideoWidget::dragEnterEvent(QDragEnterEvent *event) } } -void VideoWidget::paintEvent(QPaintEvent *) +void VideoWindow::paintEvent(QPaintEvent *) { //如果不需要绘制 if (!drawImage) { @@ -258,7 +258,7 @@ void VideoWidget::paintEvent(QPaintEvent *) } } -void VideoWidget::drawBorder(QPainter *painter) +void VideoWindow::drawBorder(QPainter *painter) { painter->save(); @@ -276,7 +276,7 @@ void VideoWidget::drawBorder(QPainter *painter) painter->restore(); } -void VideoWidget::drawBg(QPainter *painter) +void VideoWindow::drawBg(QPainter *painter) { painter->save(); @@ -296,7 +296,7 @@ void VideoWidget::drawBg(QPainter *painter) painter->restore(); } -void VideoWidget::drawImg(QPainter *painter, QImage img) +void VideoWindow::drawImg(QPainter *painter, QImage img) { painter->save(); @@ -316,14 +316,14 @@ void VideoWidget::drawImg(QPainter *painter, QImage img) painter->restore(); } -void VideoWidget::drawOSD(QPainter *painter, +void VideoWindow::drawOSD(QPainter *painter, bool osdVisible, int osdFontSize, const QString &osdText, const QColor &osdColor, const QImage &osdImage, - const VideoWidget::OSDFormat &osdFormat, - const VideoWidget::OSDPosition &osdPosition) + const VideoWindow::OSDFormat &osdFormat, + const VideoWindow::OSDPosition &osdPosition) { if (!osdVisible) { return; @@ -375,212 +375,212 @@ void VideoWidget::drawOSD(QPainter *painter, painter->restore(); } -QImage VideoWidget::getImage() const +QImage VideoWindow::getImage() const { return this->image; } -QPixmap VideoWidget::getPixmap() const +QPixmap VideoWindow::getPixmap() const { return QPixmap(); } -QString VideoWidget::getUrl() const +QString VideoWindow::getUrl() const { return this->property("url").toString(); } -QDateTime VideoWidget::getLastTime() const +QDateTime VideoWindow::getLastTime() const { return QDateTime::currentDateTime(); } -bool VideoWidget::getCallback() const +bool VideoWindow::getCallback() const { return false; } -bool VideoWidget::getIsPlaying() const +bool VideoWindow::getIsPlaying() const { return false; } -bool VideoWidget::getIsRtsp() const +bool VideoWindow::getIsRtsp() const { return false; } -bool VideoWidget::getIsUsbCamera() const +bool VideoWindow::getIsUsbCamera() const { return false; } -bool VideoWidget::getCopyImage() const +bool VideoWindow::getCopyImage() const { return this->copyImage; } -bool VideoWidget::getCheckLive() const +bool VideoWindow::getCheckLive() const { return this->checkLive; } -bool VideoWidget::getDrawImage() const +bool VideoWindow::getDrawImage() const { return this->drawImage; } -bool VideoWidget::getFillImage() const +bool VideoWindow::getFillImage() const { return this->fillImage; } -bool VideoWidget::getFlowEnable() const +bool VideoWindow::getFlowEnable() const { return this->flowEnable; } -QColor VideoWidget::getFlowBgColor() const +QColor VideoWindow::getFlowBgColor() const { return this->flowBgColor; } -QColor VideoWidget::getFlowPressColor() const +QColor VideoWindow::getFlowPressColor() const { return this->flowPressColor; } -int VideoWidget::getTimeout() const +int VideoWindow::getTimeout() const { return this->timeout; } -int VideoWidget::getBorderWidth() const +int VideoWindow::getBorderWidth() const { return this->borderWidth; } -QColor VideoWidget::getBorderColor() const +QColor VideoWindow::getBorderColor() const { return this->borderColor; } -QColor VideoWidget::getFocusColor() const +QColor VideoWindow::getFocusColor() const { return this->focusColor; } -QColor VideoWidget::getBgColor() const +QColor VideoWindow::getBgColor() const { return this->bgColor; } -QString VideoWidget::getBgText() const +QString VideoWindow::getBgText() const { return this->bgText; } -QImage VideoWidget::getBgImage() const +QImage VideoWindow::getBgImage() const { return this->bgImage; } -bool VideoWidget::getOSD1Visible() const +bool VideoWindow::getOSD1Visible() const { return this->osd1Visible; } -int VideoWidget::getOSD1FontSize() const +int VideoWindow::getOSD1FontSize() const { return this->osd1FontSize; } -QString VideoWidget::getOSD1Text() const +QString VideoWindow::getOSD1Text() const { return this->osd1Text; } -QColor VideoWidget::getOSD1Color() const +QColor VideoWindow::getOSD1Color() const { return this->osd1Color; } -QImage VideoWidget::getOSD1Image() const +QImage VideoWindow::getOSD1Image() const { return this->osd1Image; } -VideoWidget::OSDFormat VideoWidget::getOSD1Format() const +VideoWindow::OSDFormat VideoWindow::getOSD1Format() const { return this->osd1Format; } -VideoWidget::OSDPosition VideoWidget::getOSD1Position() const +VideoWindow::OSDPosition VideoWindow::getOSD1Position() const { return this->osd1Position; } -bool VideoWidget::getOSD2Visible() const +bool VideoWindow::getOSD2Visible() const { return this->osd2Visible; } -int VideoWidget::getOSD2FontSize() const +int VideoWindow::getOSD2FontSize() const { return this->osd2FontSize; } -QString VideoWidget::getOSD2Text() const +QString VideoWindow::getOSD2Text() const { return this->osd2Text; } -QColor VideoWidget::getOSD2Color() const +QColor VideoWindow::getOSD2Color() const { return this->osd2Color; } -QImage VideoWidget::getOSD2Image() const +QImage VideoWindow::getOSD2Image() const { return this->osd2Image; } -VideoWidget::OSDFormat VideoWidget::getOSD2Format() const +VideoWindow::OSDFormat VideoWindow::getOSD2Format() const { return this->osd2Format; } -VideoWidget::OSDPosition VideoWidget::getOSD2Position() const +VideoWindow::OSDPosition VideoWindow::getOSD2Position() const { return this->osd2Position; } -int VideoWidget::getFaceBorder() const +int VideoWindow::getFaceBorder() const { return this->faceBorder; } -QColor VideoWidget::getFaceColor() const +QColor VideoWindow::getFaceColor() const { return this->faceColor; } -QList VideoWidget::getFaceRects() const +QList VideoWindow::getFaceRects() const { return this->faceRects; } -QSize VideoWidget::sizeHint() const +QSize VideoWindow::sizeHint() const { return QSize(400, 300); } -QSize VideoWidget::minimumSizeHint() const +QSize VideoWindow::minimumSizeHint() const { return QSize(40, 30); } -void VideoWidget::updateImage(const QImage &image) +void VideoWindow::updateImage(const QImage &image) { //拷贝图片有个好处,当处理器比较差的时候,图片不会产生断层,缺点是占用时间 //默认QImage类型是浅拷贝,可能正在绘制的时候,那边已经更改了图片的上部分数据 @@ -588,7 +588,7 @@ void VideoWidget::updateImage(const QImage &image) this->update(); } -void VideoWidget::checkVideo() +void VideoWindow::checkVideo() { QDateTime now = QDateTime::currentDateTime(); QDateTime lastTime = now; @@ -598,103 +598,103 @@ void VideoWidget::checkVideo() } } -void VideoWidget::btnClicked() +void VideoWindow::btnClicked() { QPushButton *btn = (QPushButton *)sender(); emit btnClicked(btn->objectName()); } -uint VideoWidget::getLength() +uint VideoWindow::getLength() { return 0; } -uint VideoWidget::getPosition() +uint VideoWindow::getPosition() { return 0; } -void VideoWidget::setPosition(int position) +void VideoWindow::setPosition(int position) { } -bool VideoWidget::getMuted() +bool VideoWindow::getMuted() { return false; } -void VideoWidget::setMuted(bool muted) +void VideoWindow::setMuted(bool muted) { } -int VideoWidget::getVolume() +int VideoWindow::getVolume() { return 0; } -void VideoWidget::setVolume(int volume) +void VideoWindow::setVolume(int volume) { } -void VideoWidget::setInterval(int interval) +void VideoWindow::setInterval(int interval) { } -void VideoWidget::setSleepTime(int sleepTime) +void VideoWindow::setSleepTime(int sleepTime) { } -void VideoWidget::setCheckTime(int checkTime) +void VideoWindow::setCheckTime(int checkTime) { } -void VideoWidget::setCheckConn(bool checkConn) +void VideoWindow::setCheckConn(bool checkConn) { } -void VideoWidget::setUrl(const QString &url) +void VideoWindow::setUrl(const QString &url) { this->setProperty("url", url); } -void VideoWidget::setCallback(bool callback) +void VideoWindow::setCallback(bool callback) { } -void VideoWidget::setHardware(const QString &hardware) +void VideoWindow::setHardware(const QString &hardware) { } -void VideoWidget::setTransport(const QString &transport) +void VideoWindow::setTransport(const QString &transport) { } -void VideoWidget::setSaveFile(bool saveFile) +void VideoWindow::setSaveFile(bool saveFile) { } -void VideoWidget::setSaveInterval(int saveInterval) +void VideoWindow::setSaveInterval(int saveInterval) { } -void VideoWidget::setFileFlag(const QString &fileFlag) +void VideoWindow::setFileFlag(const QString &fileFlag) { } -void VideoWidget::setSavePath(const QString &savePath) +void VideoWindow::setSavePath(const QString &savePath) { //如果目录不存在则新建 QDir dir(savePath); @@ -703,37 +703,37 @@ void VideoWidget::setSavePath(const QString &savePath) } } -void VideoWidget::setFileName(const QString &fileName) +void VideoWindow::setFileName(const QString &fileName) { } -void VideoWidget::setCopyImage(bool copyImage) +void VideoWindow::setCopyImage(bool copyImage) { this->copyImage = copyImage; } -void VideoWidget::setCheckLive(bool checkLive) +void VideoWindow::setCheckLive(bool checkLive) { this->checkLive = checkLive; } -void VideoWidget::setDrawImage(bool drawImage) +void VideoWindow::setDrawImage(bool drawImage) { this->drawImage = drawImage; } -void VideoWidget::setFillImage(bool fillImage) +void VideoWindow::setFillImage(bool fillImage) { this->fillImage = fillImage; } -void VideoWidget::setFlowEnable(bool flowEnable) +void VideoWindow::setFlowEnable(bool flowEnable) { this->flowEnable = flowEnable; } -void VideoWidget::setFlowBgColor(const QColor &flowBgColor) +void VideoWindow::setFlowBgColor(const QColor &flowBgColor) { if (this->flowBgColor != flowBgColor) { this->flowBgColor = flowBgColor; @@ -741,7 +741,7 @@ void VideoWidget::setFlowBgColor(const QColor &flowBgColor) } } -void VideoWidget::setFlowPressColor(const QColor &flowPressColor) +void VideoWindow::setFlowPressColor(const QColor &flowPressColor) { if (this->flowPressColor != flowPressColor) { this->flowPressColor = flowPressColor; @@ -749,170 +749,170 @@ void VideoWidget::setFlowPressColor(const QColor &flowPressColor) } } -void VideoWidget::setTimeout(int timeout) +void VideoWindow::setTimeout(int timeout) { this->timeout = timeout; } -void VideoWidget::setBorderWidth(int borderWidth) +void VideoWindow::setBorderWidth(int borderWidth) { this->borderWidth = borderWidth; this->update(); } -void VideoWidget::setBorderColor(const QColor &borderColor) +void VideoWindow::setBorderColor(const QColor &borderColor) { this->borderColor = borderColor; this->update(); } -void VideoWidget::setFocusColor(const QColor &focusColor) +void VideoWindow::setFocusColor(const QColor &focusColor) { this->focusColor = focusColor; this->update(); } -void VideoWidget::setBgColor(const QColor &bgColor) +void VideoWindow::setBgColor(const QColor &bgColor) { this->bgColor = bgColor; this->update(); } -void VideoWidget::setBgText(const QString &bgText) +void VideoWindow::setBgText(const QString &bgText) { this->bgText = bgText; this->update(); } -void VideoWidget::setBgImage(const QImage &bgImage) +void VideoWindow::setBgImage(const QImage &bgImage) { this->bgImage = bgImage; this->update(); } -void VideoWidget::setOSD1Visible(bool osdVisible) +void VideoWindow::setOSD1Visible(bool osdVisible) { this->osd1Visible = osdVisible; this->update(); } -void VideoWidget::setOSD1FontSize(int osdFontSize) +void VideoWindow::setOSD1FontSize(int osdFontSize) { this->osd1FontSize = osdFontSize; this->update(); } -void VideoWidget::setOSD1Text(const QString &osdText) +void VideoWindow::setOSD1Text(const QString &osdText) { this->osd1Text = osdText; this->update(); } -void VideoWidget::setOSD1Color(const QColor &osdColor) +void VideoWindow::setOSD1Color(const QColor &osdColor) { this->osd1Color = osdColor; this->update(); } -void VideoWidget::setOSD1Image(const QImage &osdImage) +void VideoWindow::setOSD1Image(const QImage &osdImage) { this->osd1Image = osdImage; this->update(); } -void VideoWidget::setOSD1Format(const VideoWidget::OSDFormat &osdFormat) +void VideoWindow::setOSD1Format(const VideoWindow::OSDFormat &osdFormat) { this->osd1Format = osdFormat; this->update(); } -void VideoWidget::setOSD1Position(const VideoWidget::OSDPosition &osdPosition) +void VideoWindow::setOSD1Position(const VideoWindow::OSDPosition &osdPosition) { this->osd1Position = osdPosition; this->update(); } -void VideoWidget::setOSD2Visible(bool osdVisible) +void VideoWindow::setOSD2Visible(bool osdVisible) { this->osd2Visible = osdVisible; this->update(); } -void VideoWidget::setOSD2FontSize(int osdFontSize) +void VideoWindow::setOSD2FontSize(int osdFontSize) { this->osd2FontSize = osdFontSize; this->update(); } -void VideoWidget::setOSD2Text(const QString &osdText) +void VideoWindow::setOSD2Text(const QString &osdText) { this->osd2Text = osdText; this->update(); } -void VideoWidget::setOSD2Color(const QColor &osdColor) +void VideoWindow::setOSD2Color(const QColor &osdColor) { this->osd2Color = osdColor; this->update(); } -void VideoWidget::setOSD2Image(const QImage &osdImage) +void VideoWindow::setOSD2Image(const QImage &osdImage) { this->osd2Image = osdImage; this->update(); } -void VideoWidget::setOSD2Format(const VideoWidget::OSDFormat &osdFormat) +void VideoWindow::setOSD2Format(const VideoWindow::OSDFormat &osdFormat) { this->osd2Format = osdFormat; this->update(); } -void VideoWidget::setOSD2Position(const VideoWidget::OSDPosition &osdPosition) +void VideoWindow::setOSD2Position(const VideoWindow::OSDPosition &osdPosition) { this->osd2Position = osdPosition; this->update(); } -void VideoWidget::setOSD1Format(quint8 osdFormat) +void VideoWindow::setOSD1Format(quint8 osdFormat) { - setOSD1Format((VideoWidget::OSDFormat)osdFormat); + setOSD1Format((VideoWindow::OSDFormat)osdFormat); } -void VideoWidget::setOSD2Format(quint8 osdFormat) +void VideoWindow::setOSD2Format(quint8 osdFormat) { - setOSD2Format((VideoWidget::OSDFormat)osdFormat); + setOSD2Format((VideoWindow::OSDFormat)osdFormat); } -void VideoWidget::setOSD1Position(quint8 osdPosition) +void VideoWindow::setOSD1Position(quint8 osdPosition) { - setOSD1Position((VideoWidget::OSDPosition)osdPosition); + setOSD1Position((VideoWindow::OSDPosition)osdPosition); } -void VideoWidget::setOSD2Position(quint8 osdPosition) +void VideoWindow::setOSD2Position(quint8 osdPosition) { - setOSD2Position((VideoWidget::OSDPosition)osdPosition); + setOSD2Position((VideoWindow::OSDPosition)osdPosition); } -void VideoWidget::setFaceBorder(int faceBorder) +void VideoWindow::setFaceBorder(int faceBorder) { this->faceBorder = faceBorder; this->update(); } -void VideoWidget::setFaceColor(const QColor &faceColor) +void VideoWindow::setFaceColor(const QColor &faceColor) { this->faceColor = faceColor; this->update(); } -void VideoWidget::setFaceRects(const QList &faceRects) +void VideoWindow::setFaceRects(const QList &faceRects) { this->faceRects = faceRects; this->update(); } -void VideoWidget::open() +void VideoWindow::open() { //qDebug() << TIMEMS << "open video" << objectName(); clear(); @@ -934,7 +934,7 @@ void VideoWidget::open() this->setProperty("isPause", false); } -void VideoWidget::pause() +void VideoWindow::pause() { if (!this->property("isPause").toBool()) { //thread->pause(); @@ -942,7 +942,7 @@ void VideoWidget::pause() } } -void VideoWidget::next() +void VideoWindow::next() { if (this->property("isPause").toBool()) { //thread->next(); @@ -950,7 +950,7 @@ void VideoWidget::next() } } -void VideoWidget::close() +void VideoWindow::close() { if (checkLive) { timerCheck->stop(); @@ -960,7 +960,7 @@ void VideoWidget::close() //QTimer::singleShot(5, this, SLOT(clear())); } -void VideoWidget::restart(const QString &url, int delayOpen) +void VideoWindow::restart(const QString &url, int delayOpen) { //qDebug() << TIMEMS << "restart video" << objectName(); //关闭视频 @@ -976,13 +976,13 @@ void VideoWidget::restart(const QString &url, int delayOpen) } } -void VideoWidget::clear() +void VideoWindow::clear() { image = QImage(); this->update(); } -void VideoWidget::snap(const QString &fileName) +void VideoWindow::snap(const QString &fileName) { } diff --git a/video/videowidget/videowidget.h b/video/videowindow/videowindow.h similarity index 98% rename from video/videowidget/videowidget.h rename to video/videowindow/videowindow.h index ffb0c44..3b9d069 100644 --- a/video/videowidget/videowidget.h +++ b/video/videowindow/videowindow.h @@ -1,5 +1,5 @@ -#ifndef VIDEOWIDGET_H -#define VIDEOWIDGET_H +#ifndef VIDEOWINDOW_H +#define VIDEOWINDOW_H /** * 通用视频播放控件 作者:feiyangqingyun(QQ:517216493) 2018-05-01 @@ -23,10 +23,10 @@ class QTimer; #ifdef quc -class Q_DECL_EXPORT VideoWidget : public QWidget - #else -class VideoWidget : public QWidget - #endif +class Q_DECL_EXPORT VideoWindow : public QWidget +#else +class VideoWindow : public QWidget +#endif { Q_OBJECT @@ -84,8 +84,8 @@ public: OSDPosition_Right_Bottom = 3 //右下角 }; - explicit VideoWidget(QWidget *parent = 0); - ~VideoWidget(); + explicit VideoWindow(QWidget *parent = 0); + ~VideoWindow(); protected: void resizeEvent(QResizeEvent *); @@ -378,4 +378,4 @@ public slots: void snap(const QString &fileName); }; -#endif // VIDEOWIDGET_H +#endif // VIDEOWINDOW_H diff --git a/video/videowidget/videowidget.pro b/video/videowindow/videowindow.pro similarity index 50% rename from video/videowidget/videowidget.pro rename to video/videowindow/videowindow.pro index 3e6076c..66c2d95 100644 --- a/video/videowidget/videowidget.pro +++ b/video/videowindow/videowindow.pro @@ -2,18 +2,18 @@ QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat -TARGET = videowidget +TARGET = videowindow TEMPLATE = app DESTDIR = $$PWD/../bin CONFIG += warn_off SOURCES += main.cpp -SOURCES += frmvideowidget.cpp -SOURCES += videowidget.cpp +SOURCES += frmvideowindow.cpp +SOURCES += videowindow.cpp -HEADERS += frmvideowidget.h -HEADERS += videowidget.h +HEADERS += frmvideowindow.h +HEADERS += videowindow.h -FORMS += frmvideowidget.ui +FORMS += frmvideowindow.ui -RESOURCES += main.qrc +RESOURCES += main.qrc