diff --git a/video/playmdk/playmdk.pro b/video/playmdk/playmdk.pro index e44dd45..afd4ac4 100644 --- a/video/playmdk/playmdk.pro +++ b/video/playmdk/playmdk.pro @@ -13,7 +13,7 @@ CONFIG += warn_off INCLUDEPATH += $$PWD/mdk include ($$PWD/mdk/mdk.pri) - +message($$DEFINES) !contains(DEFINES, mdkx) { -error("no c++11") +error("mdk need c++1122") } diff --git a/video/video.pro b/video/video.pro index 7eb9f49..be9d6d4 100644 --- a/video/video.pro +++ b/video/video.pro @@ -7,5 +7,23 @@ win32 { SUBDIRS += playffmpeg SUBDIRS += playvlc SUBDIRS += plaympv -SUBDIRS += playmdk } + +#下面是为了判断是否能启用mdk项目 +DEFINES += mdkx +#下面表示Qt4.7及以下版本移除标记 +lessThan(QT_MAJOR_VERSION, 5) { +lessThan(QT_MINOR_VERSION, 8) { +DEFINES -= mdkx +}} + +#mdk组件最低支持msvc2013(msvc2013=12/msvc2015=14) +msvc { +lessThan(MSVC_VER, 12) { +DEFINES -= mdkx +}} + +win32 { +contains(DEFINES, mdkx) { +SUBDIRS += playmdk +}} diff --git a/video/videobox/frmvideobox.cpp b/video/videobox/frmvideobox.cpp index 206db09..3efa199 100644 --- a/video/videobox/frmvideobox.cpp +++ b/video/videobox/frmvideobox.cpp @@ -61,7 +61,8 @@ void frmVideoBox::initForm() label->installEventFilter(this); label->setFrameShape(QLabel::Box); label->setAlignment(Qt::AlignCenter); - label->setText(QString("通道 %1").arg(i + 1)); + label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + label->setText(QString("通道 %1").arg(i + 1, 2, 10, QChar('0'))); widgets << label; } @@ -69,26 +70,26 @@ void frmVideoBox::initForm() box = new VideoBox(this); //关联信号槽 connect(box, SIGNAL(changeVideo(int, QString, bool)), this, SLOT(changeVideo(int, QString, bool))); - //可以改成 1_4 5_8 1_36 等 + //可以改成 1_4/5_8/1_36 等 box->setVideoType("1_16"); box->setLayout(ui->gridLayout); box->setWidgets(widgets); - box->setMenuFlag("排列"); - box->setActionFlag("监控"); - box->show_video_all(); - //实例化菜单 + //box->setMenuFlag("排列"); + //box->setActionFlag("监控"); + //增加自定义布局(通道1开始3行3列布局) + //box->appendType(1, 3, 4); + + //实例化菜单/先添加自己的菜单 menu = new QMenu(this); - //先安排自己的菜单 //这里关联到一个槽函数处理,也可以关联到不同的槽函数 menu->addAction("切换全屏模式", this, SLOT(doAction())); menu->addAction("启动轮询视频", this, SLOT(doAction())); menu->addSeparator(); - //把菜单加到盒子上,并控制布局切换菜单是否可用(默认9个布局切换菜单) - QList enable; - enable << true << true << true << true << true << true << true << true << true; - box->initMenu(menu, enable); + //把菜单加到盒子上 + box->initMenu(menu); + box->show_video_all(); } void frmVideoBox::doAction() diff --git a/video/videobox/frmvideobox.ui b/video/videobox/frmvideobox.ui index 40f6544..ee71e49 100644 --- a/video/videobox/frmvideobox.ui +++ b/video/videobox/frmvideobox.ui @@ -14,6 +14,21 @@ Form + + 6 + + + 6 + + + 6 + + + 6 + + + 6 + diff --git a/video/videobox/main.cpp b/video/videobox/main.cpp index 86d9e93..af99186 100644 --- a/video/videobox/main.cpp +++ b/video/videobox/main.cpp @@ -27,7 +27,7 @@ int main(int argc, char *argv[]) #endif frmVideoBox w; - w.setWindowTitle("视频监控布局(QQ: 517216493 WX: feiyangqingyun)"); + w.setWindowTitle("视频监控布局 (QQ: 517216493 WX: feiyangqingyun)"); w.resize(800, 600); w.show(); diff --git a/video/videobox/videobox.cpp b/video/videobox/videobox.cpp index 00d32cc..067f9c9 100644 --- a/video/videobox/videobox.cpp +++ b/video/videobox/videobox.cpp @@ -12,18 +12,20 @@ VideoBox::VideoBox(QObject *parent) : QObject(parent) videoCount = 64; videoType = "1_16"; - enableOther = false; menuFlag = "画面"; actionFlag = "通道"; //通过这里设置好数据下面只需要循环添加和判断就行(灵活性大大增强/只需要这里改动下就行) - //1_2表示通道1-通道2/前面是通道开始的索引/后面是通道结束的索引 + + //自定义x布局/按照行列数生成/可以通过appendtype函数添加其他类型 //1_2x4表示通道1开始2x4行列布局画面(相当于通道1-8按照2行4列排列) //9_2x4表示通道9开始2x4行列布局画面(相当于通道9-16按照2行4列排列) - types.insert("2", QStringList() << "1_2"); - types.insert("3", QStringList() << "1_3"); - //按照行列数生成的可以自行添加其他布局 - types.insert("x", QStringList() << "1_4x1" << "1_2x4" << "9_2x4" << "1_4x2" << "9_4x2" << "1_2x5" << "10_2x5" << "1_5x2" << "1_6x2" << "1_7x2"); + types.insert("x", QStringList() << "1_4x1" << "1_2x4" << "9_2x4" << "1_3x2" << "1_4x2" << "1_5x2" << "1_6x2" << "1_7x2" << "1_8x2"); + + //自定义y布局/主要是一些用户定义的不规则的排列布局/加个y用于区分其他布局/可能有雷同 + types.insert("y", QStringList() << "y_1_2" << "y_1_3" << "y_1_9" << "y_1_10" << "y_1_12" << "y_1_16"); + + //1_4表示通道1-通道4/前面是通道开始的索引/后面是通道结束的索引 types.insert("4", QStringList() << "1_4" << "5_8" << "9_12" << "13_16" << "17_20" << "21_24" << "25_28" << "29_32" << "33_36"); types.insert("6", QStringList() << "1_6" << "7_12" << "13_18" << "19_24" << "25_30" << "31_36"); types.insert("8", QStringList() << "1_8" << "9_16" << "17_24" << "25_32" << "33_40" << "41_48" << "49_57" << "57_64"); @@ -33,6 +35,12 @@ VideoBox::VideoBox(QObject *parent) : QObject(parent) types.insert("25", QStringList() << "1_25"); types.insert("36", QStringList() << "1_36"); types.insert("64", QStringList() << "1_64"); + + //默认全部可见 + int count = types.count(); + for (int i = 0; i < count; ++i) { + visibles << true; + } } void VideoBox::addMenu(QMenu *menu, const QString &type) @@ -62,6 +70,12 @@ void VideoBox::addMenu(QMenu *menu, const QString &type) list = end.split("x"); text = QString("%1 x %2").arg(list.at(0)).arg(list.at(1)); text = QString("%1%2 (%3)").arg(actionFlag).arg(start).arg(text); + } else if (type == "y") { + start = list.at(1); + end = list.at(2); + start = QString("%1").arg(start, 2, QChar('0')); + end = QString("%1").arg(end, 2, QChar('0')); + text = QString("%1%2-%1%3").arg(actionFlag).arg(start).arg(end); } else { end = QString("%1").arg(end, 2, QChar('0')); text = QString("%1%2-%1%3").arg(actionFlag).arg(start).arg(end); @@ -81,180 +95,6 @@ void VideoBox::addMenu(QMenu *menu, const QString &type) } } -QString VideoBox::getVideoType() const -{ - return this->videoType; -} - -void VideoBox::setVideoType(const QString &videoType) -{ - this->videoType = videoType; -} - -QWidgetList VideoBox::getWidgets() const -{ - return this->widgets; -} - -void VideoBox::setWidgets(QWidgetList widgets) -{ - this->widgets = widgets; - this->videoCount = widgets.count(); -} - -void VideoBox::setLayout(QGridLayout *gridLayout) -{ - this->gridLayout = gridLayout; -} - -void VideoBox::setEnableOther(bool enableOther) -{ - this->enableOther = enableOther; -} - -void VideoBox::setMenuFlag(const QString &menuFlag) -{ - this->menuFlag = menuFlag; -} - -void VideoBox::setActionFlag(const QString &actionFlag) -{ - this->actionFlag = actionFlag; -} - -void VideoBox::setTypes(const QMap &types) -{ - this->types = types; -} - -void VideoBox::initMenu(QMenu *menu, const QList &enable) -{ - if (enableOther) { - addMenu(menu, "2"); - addMenu(menu, "3"); - addMenu(menu, "x"); - } - - //通过菜单是否可见设置每个菜单可见与否 - if (enable.count() < 9) { - return; - } - - if (enable.at(0)) { - addMenu(menu, "4"); - } - if (enable.at(1)) { - addMenu(menu, "6"); - } - if (enable.at(2)) { - addMenu(menu, "8"); - } - if (enable.at(3)) { - addMenu(menu, "9"); - } - if (enable.at(4)) { - addMenu(menu, "13"); - } - if (enable.at(5)) { - addMenu(menu, "16"); - } - if (enable.at(6)) { - addMenu(menu, "25"); - } - if (enable.at(7)) { - addMenu(menu, "36"); - } - if (enable.at(8)) { - addMenu(menu, "64"); - } -} - -void VideoBox::show_video(int type, int index) -{ - //根据不同的父菜单类型执行对应的函数 - if (type == 0) { - //取出行列 - QString text = videoType.split("_").last(); - QStringList list = text.split("x"); - int row = list.at(0).toInt(); - int column = list.at(1).toInt(); - change_video_normal(index, row, column); - } else if (type == 1) { - change_video_1(index); - } else if (type == 2) { - change_video_2(index); - } else if (type == 3) { - change_video_3(index); - } else if (type == 4) { - change_video_4(index); - } else if (type == 6) { - change_video_6(index); - } else if (type == 8) { - change_video_8(index); - } else if (type == 9) { - change_video_9(index); - } else if (type == 13) { - change_video_13(index); - } else if (type == 16) { - change_video_16(index); - } else if (type == 25) { - change_video_25(index); - } else if (type == 36) { - change_video_36(index); - } else if (type == 64) { - change_video_64(index); - } - - Q_EMIT changeVideo(type, videoType, false); -} - -void VideoBox::show_video() -{ - //识别具体是哪个动作菜单触发的 - QAction *action = (QAction *)sender(); - //从弱属性取出值 - int index = action->property("index").toInt() - 1; - int type = action->property("type").toInt(); - QString videoType = action->property("flag").toString(); - - //只有当画面布局类型改变了才需要切换 - if (this->videoType != videoType) { - this->videoType = videoType; - show_video(type, index); - } -} - -void VideoBox::show_video_all() -{ - //一般是从配置文件读取到了最后的通道画面类型进行设置 - int type = 1; - if (videoType.startsWith("0_")) { - int index = videoType.split("_").last().toInt() - 1; - change_video_1(index); - Q_EMIT changeVideo(type, videoType, true); - } else { - int index = videoType.split("_").first().toInt() - 1; - QMap::iterator iter = types.begin(); - while (iter != types.end()) { - QStringList flags = iter.value(); - if (flags.contains(videoType)) { - type = iter.key().toInt(); - show_video(type, index); - break; - } - iter++; - } - } -} - -void VideoBox::hide_video_all() -{ - for (int i = 0; i < videoCount; ++i) { - gridLayout->removeWidget(widgets.at(i)); - widgets.at(i)->setVisible(false); - } -} - //行列数一致的比如 2*2 3*3 4*4 5*5 等可以直接套用通用的公式 //按照这个函数还可以非常容易的拓展出 10*10 16*16=256 通道界面 void VideoBox::change_video_normal(int index, int row, int column) @@ -296,12 +136,15 @@ void VideoBox::change_video_custom(int index, int type) indexs << i; } - if (type == 6) { - change_video_6(indexs); - } else if (type == 8) { - change_video_8(indexs); + //过滤防止索引越界 + if (indexs.count() < type) { + return; + } + + if (type == 6 || type == 8 || type == 10 || type == 12 || type == 16) { + change_video_l(indexs); } else if (type == 13) { - change_video_13(indexs); + change_video_o(indexs); } } @@ -313,55 +156,43 @@ void VideoBox::change_video_visible(int start, int end) } } -void VideoBox::change_video_6(const QList &indexs) +void VideoBox::change_video_l(const QList &indexs) { - //过滤防止索引越界 - if (indexs.count() < 6) { - return; - } + //通过观察发现这种都是左上角一个大通道/右侧和底部排列几个小通道 + int count = indexs.count(); + int num = count / 2; + int flag = num - 1; //首先隐藏所有通道 hide_video_all(); - //挨个重新添加到布局 + + //添加大通道 + gridLayout->addWidget(widgets.at(indexs.at(0)), 0, 0, flag, flag); + //添加右侧小通道 + for (int i = 0; i < flag; ++i) { + gridLayout->addWidget(widgets.at(indexs.at(i + 1)), i, flag); + } + //添加底部小通道 + for (int i = num; i < count; ++i) { + gridLayout->addWidget(widgets.at(indexs.at(i)), flag, count - i - 1); + } + + //下面添加6通道/这里留着挨个添加的写法/方便学习和对比 +#if 0 gridLayout->addWidget(widgets.at(indexs.at(0)), 0, 0, 2, 2); gridLayout->addWidget(widgets.at(indexs.at(1)), 0, 2, 1, 1); gridLayout->addWidget(widgets.at(indexs.at(2)), 1, 2, 1, 1); gridLayout->addWidget(widgets.at(indexs.at(3)), 2, 2, 1, 1); gridLayout->addWidget(widgets.at(indexs.at(4)), 2, 1, 1, 1); gridLayout->addWidget(widgets.at(indexs.at(5)), 2, 0, 1, 1); +#endif + //设置通道控件可见 change_video_visible(indexs.first(), indexs.last()); } -void VideoBox::change_video_8(const QList &indexs) +void VideoBox::change_video_o(const QList &indexs) { - //过滤防止索引越界 - if (indexs.count() < 8) { - return; - } - - //首先隐藏所有通道 - hide_video_all(); - //挨个重新添加到布局 - gridLayout->addWidget(widgets.at(indexs.at(0)), 0, 0, 3, 3); - gridLayout->addWidget(widgets.at(indexs.at(1)), 0, 3, 1, 1); - gridLayout->addWidget(widgets.at(indexs.at(2)), 1, 3, 1, 1); - gridLayout->addWidget(widgets.at(indexs.at(3)), 2, 3, 1, 1); - gridLayout->addWidget(widgets.at(indexs.at(4)), 3, 3, 1, 1); - gridLayout->addWidget(widgets.at(indexs.at(5)), 3, 2, 1, 1); - gridLayout->addWidget(widgets.at(indexs.at(6)), 3, 1, 1, 1); - gridLayout->addWidget(widgets.at(indexs.at(7)), 3, 0, 1, 1); - //设置通道控件可见 - change_video_visible(indexs.first(), indexs.last()); -} - -void VideoBox::change_video_13(const QList &indexs) -{ - //过滤防止索引越界 - if (indexs.count() < 13) { - return; - } - //首先隐藏所有通道 hide_video_all(); //挨个重新添加到布局 @@ -382,39 +213,268 @@ void VideoBox::change_video_13(const QList &indexs) change_video_visible(indexs.first(), indexs.last()); } -void VideoBox::change_video_1(int index) +QString VideoBox::getVideoType() const { - //首先隐藏所有通道 - hide_video_all(); - //添加通道到布局 - gridLayout->addWidget(widgets.at(index), 0, 0); - //设置通道控件可见 - widgets.at(index)->setVisible(true); + return this->videoType; } -void VideoBox::change_video_2(int index) +void VideoBox::setVideoType(const QString &videoType) { - //首先隐藏所有通道 - hide_video_all(); - //添加通道到布局 - gridLayout->addWidget(widgets.at(index), 0, 0); - gridLayout->addWidget(widgets.at(index + 1), 0, 1); - //设置通道控件可见 - change_video_visible(index, index + 1); + this->videoType = videoType; } -void VideoBox::change_video_3(int index) +QWidgetList VideoBox::getWidgets() const +{ + return this->widgets; +} + +void VideoBox::setWidgets(QWidgetList widgets) +{ + this->widgets = widgets; + this->videoCount = widgets.count(); +} + +void VideoBox::setLayout(QGridLayout *gridLayout) +{ + this->gridLayout = gridLayout; +} + +void VideoBox::setMenuFlag(const QString &menuFlag) +{ + this->menuFlag = menuFlag; +} + +void VideoBox::setActionFlag(const QString &actionFlag) +{ + this->actionFlag = actionFlag; +} + +void VideoBox::setVisibles(const QList &visibles) +{ + this->visibles = visibles; +} + +void VideoBox::appendType(int index, int row, int column) +{ + //先要过滤下是否满足最大通道数量/start从1开始 + if (((index - 1) + (row * column)) > videoCount) { + return; + } + + //追加到x布局后面 + QString type = QString("%1_%2x%3").arg(index).arg(row).arg(column); + QMap::iterator iter = types.begin(); + while (iter != types.end()) { + if (iter.key() == "x") { + QStringList value = iter.value(); + if (!value.contains(type)) { + value.append(type); + types["x"] = value; + } + break; + } + iter++; + } +} + +void VideoBox::initMenu(QMenu *menu) +{ + //约定依次是按照顺序控制启用状态 + int count = visibles.count(); + if (count > 0 && visibles.at(0)) { + addMenu(menu, "x"); + } + if (count > 1 && visibles.at(1)) { + addMenu(menu, "y"); + } + if (count > 2 && visibles.at(2)) { + addMenu(menu, "4"); + } + if (count > 3 && visibles.at(3)) { + addMenu(menu, "6"); + } + if (count > 4 && visibles.at(4)) { + addMenu(menu, "8"); + } + if (count > 5 && visibles.at(5)) { + addMenu(menu, "9"); + } + if (count > 6 && visibles.at(6)) { + addMenu(menu, "13"); + } + if (count > 7 && visibles.at(7)) { + addMenu(menu, "16"); + } + if (count > 8 && visibles.at(8)) { + addMenu(menu, "25"); + } + if (count > 9 && visibles.at(9)) { + addMenu(menu, "36"); + } + if (count > 10 && visibles.at(10)) { + addMenu(menu, "64"); + } +} + +void VideoBox::show_video_all() +{ + //一般是从配置文件读取到了最后的通道画面类型进行设置 + int type = 1; + if (videoType.startsWith("0_")) { + int index = videoType.split("_").last().toInt() - 1; + change_video_1(index); + Q_EMIT changeVideo(type, videoType, true); + } else { + int index = videoType.split("_").first().toInt() - 1; + //y开头的布局需要重置索引=0 + if (videoType.startsWith("y")) { + index = 0; + } + + QMap::iterator iter = types.begin(); + while (iter != types.end()) { + QStringList flags = iter.value(); + if (flags.contains(videoType)) { + type = iter.key().toInt(); + show_video(type, index); + return; + } + iter++; + } + + //如果运行到这里说明设置了不存在的布局/强制纠正 + videoType = "1_4"; + this->show_video_all(); + } +} + +void VideoBox::hide_video_all() +{ + for (int i = 0; i < videoCount; ++i) { + gridLayout->removeWidget(widgets.at(i)); + widgets.at(i)->setVisible(false); + } +} + +void VideoBox::show_video() +{ + //识别具体是哪个动作菜单触发的 + QAction *action = (QAction *)sender(); + //从弱属性取出值 + int index = action->property("index").toInt() - 1; + int type = action->property("type").toInt(); + QString videoType = action->property("flag").toString(); + //只有当画面布局类型改变了才需要切换 + if (this->videoType != videoType) { + this->videoType = videoType; + show_video(type, index); + } +} + +void VideoBox::show_video(int type, int index) +{ + //根据不同的父菜单类型执行对应的函数 + if (type == 0) { + if (videoType.contains("x")) { + //取出行列 + QString text = videoType.split("_").last(); + QStringList list = text.split("x"); + int row = list.at(0).toInt(); + int column = list.at(1).toInt(); + change_video_normal(index, row, column); + } else if (videoType == "y_1_2") { + change_video_y_1_2(index); + } else if (videoType == "y_1_3") { + change_video_y_1_3(index); + } else if (videoType == "y_1_9") { + change_video_y_1_9(index); + } else if (videoType == "y_1_10") { + change_video_y_1_10(index); + } else if (videoType == "y_1_12") { + change_video_y_1_12(index); + } else if (videoType == "y_1_16") { + change_video_y_1_16(index); + } + } else if (type == 1) { + change_video_1(index); + } else if (type == 4) { + change_video_4(index); + } else if (type == 6) { + change_video_6(index); + } else if (type == 8) { + change_video_8(index); + } else if (type == 9) { + change_video_9(index); + } else if (type == 13) { + change_video_13(index); + } else if (type == 16) { + change_video_16(index); + } else if (type == 25) { + change_video_25(index); + } else if (type == 36) { + change_video_36(index); + } else if (type == 64) { + change_video_64(index); + } + + Q_EMIT changeVideo(type, videoType, false); +} + +void VideoBox::change_video_y_1_2(int index) +{ + change_video_normal(index, 1, 2); +} + +void VideoBox::change_video_y_1_3(int index) { //首先隐藏所有通道 hide_video_all(); //添加通道到布局 - gridLayout->addWidget(widgets.at(index), 0, 0, 1, 2); + gridLayout->addWidget(widgets.at(index + 0), 0, 0, 1, 2); gridLayout->addWidget(widgets.at(index + 1), 1, 0); gridLayout->addWidget(widgets.at(index + 2), 1, 1); //设置通道控件可见 change_video_visible(index, index + 2); } +void VideoBox::change_video_y_1_9(int index) +{ + //首先隐藏所有通道 + hide_video_all(); + //添加通道到布局 + gridLayout->addWidget(widgets.at(index + 0), 0, 0, 2, 2); + gridLayout->addWidget(widgets.at(index + 1), 0, 2, 1, 1); + gridLayout->addWidget(widgets.at(index + 2), 0, 3, 1, 1); + gridLayout->addWidget(widgets.at(index + 3), 1, 2, 1, 1); + gridLayout->addWidget(widgets.at(index + 4), 1, 3, 1, 1); + gridLayout->addWidget(widgets.at(index + 5), 2, 3, 1, 1); + gridLayout->addWidget(widgets.at(index + 6), 2, 2, 1, 1); + gridLayout->addWidget(widgets.at(index + 7), 2, 1, 1, 1); + gridLayout->addWidget(widgets.at(index + 8), 2, 0, 1, 1); + //设置通道控件可见 + change_video_visible(index, index + 8); +} + +void VideoBox::change_video_y_1_10(int index) +{ + change_video_custom(index, 10); +} + +void VideoBox::change_video_y_1_12(int index) +{ + change_video_custom(index, 12); +} + +void VideoBox::change_video_y_1_16(int index) +{ + change_video_custom(index, 16); +} + +void VideoBox::change_video_1(int index) +{ + change_video_normal(index, 1, 1); +} + void VideoBox::change_video_4(int index) { change_video_normal(index, 2, 2); diff --git a/video/videobox/videobox.h b/video/videobox/videobox.h index cf1c79c..2322a8e 100644 --- a/video/videobox/videobox.h +++ b/video/videobox/videobox.h @@ -4,12 +4,14 @@ /** * 监控画面切换控件 作者:feiyangqingyun(QQ:517216493) 2021-11-08 * 1. 将所有通道切换处理全部集中到一个类。 - * 2. 通用整数倍数布局切换函数,可方便拓展到100/255通道等。 - * 3. 通用异形布局切换函数,可以参考进行自定义异形布局。 - * 4. 通道布局切换发出信号通知。 - * 5. 可控每种布局切换菜单是否启用。 - * 6. 支持自定义子菜单布局内容。 - * 7. 支持设置对应的菜单标识比如默认的通道字样改成设备。 + * 2. 通用整数倍数布局切换函数,比如4x4/5x5,可方便拓展到100/255通道等。 + * 3. 通用行列数量布局切换函数,比如1x4/4x2,可方便拓展各种axb行列数。 + * 4. 通用特殊异形布局切换函数,可以参考进行自定义异形布局。 + * 5. 提供添加行列数布局函数。 + * 6. 通道布局切换发出信号通知。 + * 7. 可控每种布局切换菜单是否启用。 + * 8. 支持自定义子菜单布局内容。 + * 9. 支持设置对应的菜单标识比如默认的通道字样改成设备。 */ #include @@ -43,18 +45,30 @@ private: //当前画面类型 QString videoType; - //启用其他通道画面(2画面/3画面) - bool enableOther; - //主菜单子菜单文字标识 QString menuFlag; QString actionFlag; + //可以控制每个子菜单是否可见 + QList visibles; + //布局方案标识集合 QMap types; void addMenu(QMenu *menu, const QString &type); -public Q_SLOTS: +private: + //常规及异形通道布局 + void change_video_normal(int index, int row, int column); + void change_video_custom(int index, int type); + + //设置可见 + void change_video_visible(int start, int end); + + //异形布局(l表示右侧底部环绕布局/o表示上下左右环绕布局) + void change_video_l(const QList &indexs); + void change_video_o(const QList &indexs); + +public: //获取和设置当前画面类型 QString getVideoType() const; void setVideoType(const QString &videoType); @@ -65,43 +79,38 @@ public Q_SLOTS: //设置表格布局 void setLayout(QGridLayout *gridLayout); - //设置启用其他通道画面 - void setEnableOther(bool enableOther); //设置主菜单子菜单文字标识 void setMenuFlag(const QString &menuFlag); void setActionFlag(const QString &actionFlag); - //设置菜单类型集合 - void setTypes(const QMap &types); + //设置子菜单可见 + void setVisibles(const QList &visibles); + + //添加行列布局(必须在initMenu前调用) + void appendType(int index, int row, int column); //初始化菜单 - void initMenu(QMenu *menu, const QList &enable); - - //通用设置函数 - void show_video(int type, int index); - //菜单切换布局槽函数 - void show_video(); + void initMenu(QMenu *menu); +public Q_SLOTS: //显示和隐藏所有通道 void show_video_all(); void hide_video_all(); - //常规及异形通道布局 - void change_video_normal(int index, int row, int column); - void change_video_custom(int index, int type); + //菜单切换布局槽函数 + void show_video(); + void show_video(int type, int index); - //设置可见 - void change_video_visible(int start, int end); + //自定义布局通道切换函数 + void change_video_y_1_2(int index); + void change_video_y_1_3(int index); + void change_video_y_1_9(int index); + void change_video_y_1_10(int index); + void change_video_y_1_12(int index); + void change_video_y_1_16(int index); - //异形布局 - void change_video_6(const QList &indexs); - void change_video_8(const QList &indexs); - void change_video_13(const QList &indexs); - - //具体通道切换函数 + //常规布局通道切换函数 void change_video_1(int index); - void change_video_2(int index); - void change_video_3(int index); void change_video_4(int index); void change_video_6(int index); void change_video_8(int index); diff --git a/video/videopanel/frmvideopanel.ui b/video/videopanel/frmvideopanel.ui index 35d7b1d..adea16e 100644 --- a/video/videopanel/frmvideopanel.ui +++ b/video/videopanel/frmvideopanel.ui @@ -14,6 +14,21 @@ Form + + 6 + + + 6 + + + 6 + + + 6 + + + 6 + diff --git a/video/videopanel/videobox.cpp b/video/videopanel/videobox.cpp index 00d32cc..067f9c9 100644 --- a/video/videopanel/videobox.cpp +++ b/video/videopanel/videobox.cpp @@ -12,18 +12,20 @@ VideoBox::VideoBox(QObject *parent) : QObject(parent) videoCount = 64; videoType = "1_16"; - enableOther = false; menuFlag = "画面"; actionFlag = "通道"; //通过这里设置好数据下面只需要循环添加和判断就行(灵活性大大增强/只需要这里改动下就行) - //1_2表示通道1-通道2/前面是通道开始的索引/后面是通道结束的索引 + + //自定义x布局/按照行列数生成/可以通过appendtype函数添加其他类型 //1_2x4表示通道1开始2x4行列布局画面(相当于通道1-8按照2行4列排列) //9_2x4表示通道9开始2x4行列布局画面(相当于通道9-16按照2行4列排列) - types.insert("2", QStringList() << "1_2"); - types.insert("3", QStringList() << "1_3"); - //按照行列数生成的可以自行添加其他布局 - types.insert("x", QStringList() << "1_4x1" << "1_2x4" << "9_2x4" << "1_4x2" << "9_4x2" << "1_2x5" << "10_2x5" << "1_5x2" << "1_6x2" << "1_7x2"); + types.insert("x", QStringList() << "1_4x1" << "1_2x4" << "9_2x4" << "1_3x2" << "1_4x2" << "1_5x2" << "1_6x2" << "1_7x2" << "1_8x2"); + + //自定义y布局/主要是一些用户定义的不规则的排列布局/加个y用于区分其他布局/可能有雷同 + types.insert("y", QStringList() << "y_1_2" << "y_1_3" << "y_1_9" << "y_1_10" << "y_1_12" << "y_1_16"); + + //1_4表示通道1-通道4/前面是通道开始的索引/后面是通道结束的索引 types.insert("4", QStringList() << "1_4" << "5_8" << "9_12" << "13_16" << "17_20" << "21_24" << "25_28" << "29_32" << "33_36"); types.insert("6", QStringList() << "1_6" << "7_12" << "13_18" << "19_24" << "25_30" << "31_36"); types.insert("8", QStringList() << "1_8" << "9_16" << "17_24" << "25_32" << "33_40" << "41_48" << "49_57" << "57_64"); @@ -33,6 +35,12 @@ VideoBox::VideoBox(QObject *parent) : QObject(parent) types.insert("25", QStringList() << "1_25"); types.insert("36", QStringList() << "1_36"); types.insert("64", QStringList() << "1_64"); + + //默认全部可见 + int count = types.count(); + for (int i = 0; i < count; ++i) { + visibles << true; + } } void VideoBox::addMenu(QMenu *menu, const QString &type) @@ -62,6 +70,12 @@ void VideoBox::addMenu(QMenu *menu, const QString &type) list = end.split("x"); text = QString("%1 x %2").arg(list.at(0)).arg(list.at(1)); text = QString("%1%2 (%3)").arg(actionFlag).arg(start).arg(text); + } else if (type == "y") { + start = list.at(1); + end = list.at(2); + start = QString("%1").arg(start, 2, QChar('0')); + end = QString("%1").arg(end, 2, QChar('0')); + text = QString("%1%2-%1%3").arg(actionFlag).arg(start).arg(end); } else { end = QString("%1").arg(end, 2, QChar('0')); text = QString("%1%2-%1%3").arg(actionFlag).arg(start).arg(end); @@ -81,180 +95,6 @@ void VideoBox::addMenu(QMenu *menu, const QString &type) } } -QString VideoBox::getVideoType() const -{ - return this->videoType; -} - -void VideoBox::setVideoType(const QString &videoType) -{ - this->videoType = videoType; -} - -QWidgetList VideoBox::getWidgets() const -{ - return this->widgets; -} - -void VideoBox::setWidgets(QWidgetList widgets) -{ - this->widgets = widgets; - this->videoCount = widgets.count(); -} - -void VideoBox::setLayout(QGridLayout *gridLayout) -{ - this->gridLayout = gridLayout; -} - -void VideoBox::setEnableOther(bool enableOther) -{ - this->enableOther = enableOther; -} - -void VideoBox::setMenuFlag(const QString &menuFlag) -{ - this->menuFlag = menuFlag; -} - -void VideoBox::setActionFlag(const QString &actionFlag) -{ - this->actionFlag = actionFlag; -} - -void VideoBox::setTypes(const QMap &types) -{ - this->types = types; -} - -void VideoBox::initMenu(QMenu *menu, const QList &enable) -{ - if (enableOther) { - addMenu(menu, "2"); - addMenu(menu, "3"); - addMenu(menu, "x"); - } - - //通过菜单是否可见设置每个菜单可见与否 - if (enable.count() < 9) { - return; - } - - if (enable.at(0)) { - addMenu(menu, "4"); - } - if (enable.at(1)) { - addMenu(menu, "6"); - } - if (enable.at(2)) { - addMenu(menu, "8"); - } - if (enable.at(3)) { - addMenu(menu, "9"); - } - if (enable.at(4)) { - addMenu(menu, "13"); - } - if (enable.at(5)) { - addMenu(menu, "16"); - } - if (enable.at(6)) { - addMenu(menu, "25"); - } - if (enable.at(7)) { - addMenu(menu, "36"); - } - if (enable.at(8)) { - addMenu(menu, "64"); - } -} - -void VideoBox::show_video(int type, int index) -{ - //根据不同的父菜单类型执行对应的函数 - if (type == 0) { - //取出行列 - QString text = videoType.split("_").last(); - QStringList list = text.split("x"); - int row = list.at(0).toInt(); - int column = list.at(1).toInt(); - change_video_normal(index, row, column); - } else if (type == 1) { - change_video_1(index); - } else if (type == 2) { - change_video_2(index); - } else if (type == 3) { - change_video_3(index); - } else if (type == 4) { - change_video_4(index); - } else if (type == 6) { - change_video_6(index); - } else if (type == 8) { - change_video_8(index); - } else if (type == 9) { - change_video_9(index); - } else if (type == 13) { - change_video_13(index); - } else if (type == 16) { - change_video_16(index); - } else if (type == 25) { - change_video_25(index); - } else if (type == 36) { - change_video_36(index); - } else if (type == 64) { - change_video_64(index); - } - - Q_EMIT changeVideo(type, videoType, false); -} - -void VideoBox::show_video() -{ - //识别具体是哪个动作菜单触发的 - QAction *action = (QAction *)sender(); - //从弱属性取出值 - int index = action->property("index").toInt() - 1; - int type = action->property("type").toInt(); - QString videoType = action->property("flag").toString(); - - //只有当画面布局类型改变了才需要切换 - if (this->videoType != videoType) { - this->videoType = videoType; - show_video(type, index); - } -} - -void VideoBox::show_video_all() -{ - //一般是从配置文件读取到了最后的通道画面类型进行设置 - int type = 1; - if (videoType.startsWith("0_")) { - int index = videoType.split("_").last().toInt() - 1; - change_video_1(index); - Q_EMIT changeVideo(type, videoType, true); - } else { - int index = videoType.split("_").first().toInt() - 1; - QMap::iterator iter = types.begin(); - while (iter != types.end()) { - QStringList flags = iter.value(); - if (flags.contains(videoType)) { - type = iter.key().toInt(); - show_video(type, index); - break; - } - iter++; - } - } -} - -void VideoBox::hide_video_all() -{ - for (int i = 0; i < videoCount; ++i) { - gridLayout->removeWidget(widgets.at(i)); - widgets.at(i)->setVisible(false); - } -} - //行列数一致的比如 2*2 3*3 4*4 5*5 等可以直接套用通用的公式 //按照这个函数还可以非常容易的拓展出 10*10 16*16=256 通道界面 void VideoBox::change_video_normal(int index, int row, int column) @@ -296,12 +136,15 @@ void VideoBox::change_video_custom(int index, int type) indexs << i; } - if (type == 6) { - change_video_6(indexs); - } else if (type == 8) { - change_video_8(indexs); + //过滤防止索引越界 + if (indexs.count() < type) { + return; + } + + if (type == 6 || type == 8 || type == 10 || type == 12 || type == 16) { + change_video_l(indexs); } else if (type == 13) { - change_video_13(indexs); + change_video_o(indexs); } } @@ -313,55 +156,43 @@ void VideoBox::change_video_visible(int start, int end) } } -void VideoBox::change_video_6(const QList &indexs) +void VideoBox::change_video_l(const QList &indexs) { - //过滤防止索引越界 - if (indexs.count() < 6) { - return; - } + //通过观察发现这种都是左上角一个大通道/右侧和底部排列几个小通道 + int count = indexs.count(); + int num = count / 2; + int flag = num - 1; //首先隐藏所有通道 hide_video_all(); - //挨个重新添加到布局 + + //添加大通道 + gridLayout->addWidget(widgets.at(indexs.at(0)), 0, 0, flag, flag); + //添加右侧小通道 + for (int i = 0; i < flag; ++i) { + gridLayout->addWidget(widgets.at(indexs.at(i + 1)), i, flag); + } + //添加底部小通道 + for (int i = num; i < count; ++i) { + gridLayout->addWidget(widgets.at(indexs.at(i)), flag, count - i - 1); + } + + //下面添加6通道/这里留着挨个添加的写法/方便学习和对比 +#if 0 gridLayout->addWidget(widgets.at(indexs.at(0)), 0, 0, 2, 2); gridLayout->addWidget(widgets.at(indexs.at(1)), 0, 2, 1, 1); gridLayout->addWidget(widgets.at(indexs.at(2)), 1, 2, 1, 1); gridLayout->addWidget(widgets.at(indexs.at(3)), 2, 2, 1, 1); gridLayout->addWidget(widgets.at(indexs.at(4)), 2, 1, 1, 1); gridLayout->addWidget(widgets.at(indexs.at(5)), 2, 0, 1, 1); +#endif + //设置通道控件可见 change_video_visible(indexs.first(), indexs.last()); } -void VideoBox::change_video_8(const QList &indexs) +void VideoBox::change_video_o(const QList &indexs) { - //过滤防止索引越界 - if (indexs.count() < 8) { - return; - } - - //首先隐藏所有通道 - hide_video_all(); - //挨个重新添加到布局 - gridLayout->addWidget(widgets.at(indexs.at(0)), 0, 0, 3, 3); - gridLayout->addWidget(widgets.at(indexs.at(1)), 0, 3, 1, 1); - gridLayout->addWidget(widgets.at(indexs.at(2)), 1, 3, 1, 1); - gridLayout->addWidget(widgets.at(indexs.at(3)), 2, 3, 1, 1); - gridLayout->addWidget(widgets.at(indexs.at(4)), 3, 3, 1, 1); - gridLayout->addWidget(widgets.at(indexs.at(5)), 3, 2, 1, 1); - gridLayout->addWidget(widgets.at(indexs.at(6)), 3, 1, 1, 1); - gridLayout->addWidget(widgets.at(indexs.at(7)), 3, 0, 1, 1); - //设置通道控件可见 - change_video_visible(indexs.first(), indexs.last()); -} - -void VideoBox::change_video_13(const QList &indexs) -{ - //过滤防止索引越界 - if (indexs.count() < 13) { - return; - } - //首先隐藏所有通道 hide_video_all(); //挨个重新添加到布局 @@ -382,39 +213,268 @@ void VideoBox::change_video_13(const QList &indexs) change_video_visible(indexs.first(), indexs.last()); } -void VideoBox::change_video_1(int index) +QString VideoBox::getVideoType() const { - //首先隐藏所有通道 - hide_video_all(); - //添加通道到布局 - gridLayout->addWidget(widgets.at(index), 0, 0); - //设置通道控件可见 - widgets.at(index)->setVisible(true); + return this->videoType; } -void VideoBox::change_video_2(int index) +void VideoBox::setVideoType(const QString &videoType) { - //首先隐藏所有通道 - hide_video_all(); - //添加通道到布局 - gridLayout->addWidget(widgets.at(index), 0, 0); - gridLayout->addWidget(widgets.at(index + 1), 0, 1); - //设置通道控件可见 - change_video_visible(index, index + 1); + this->videoType = videoType; } -void VideoBox::change_video_3(int index) +QWidgetList VideoBox::getWidgets() const +{ + return this->widgets; +} + +void VideoBox::setWidgets(QWidgetList widgets) +{ + this->widgets = widgets; + this->videoCount = widgets.count(); +} + +void VideoBox::setLayout(QGridLayout *gridLayout) +{ + this->gridLayout = gridLayout; +} + +void VideoBox::setMenuFlag(const QString &menuFlag) +{ + this->menuFlag = menuFlag; +} + +void VideoBox::setActionFlag(const QString &actionFlag) +{ + this->actionFlag = actionFlag; +} + +void VideoBox::setVisibles(const QList &visibles) +{ + this->visibles = visibles; +} + +void VideoBox::appendType(int index, int row, int column) +{ + //先要过滤下是否满足最大通道数量/start从1开始 + if (((index - 1) + (row * column)) > videoCount) { + return; + } + + //追加到x布局后面 + QString type = QString("%1_%2x%3").arg(index).arg(row).arg(column); + QMap::iterator iter = types.begin(); + while (iter != types.end()) { + if (iter.key() == "x") { + QStringList value = iter.value(); + if (!value.contains(type)) { + value.append(type); + types["x"] = value; + } + break; + } + iter++; + } +} + +void VideoBox::initMenu(QMenu *menu) +{ + //约定依次是按照顺序控制启用状态 + int count = visibles.count(); + if (count > 0 && visibles.at(0)) { + addMenu(menu, "x"); + } + if (count > 1 && visibles.at(1)) { + addMenu(menu, "y"); + } + if (count > 2 && visibles.at(2)) { + addMenu(menu, "4"); + } + if (count > 3 && visibles.at(3)) { + addMenu(menu, "6"); + } + if (count > 4 && visibles.at(4)) { + addMenu(menu, "8"); + } + if (count > 5 && visibles.at(5)) { + addMenu(menu, "9"); + } + if (count > 6 && visibles.at(6)) { + addMenu(menu, "13"); + } + if (count > 7 && visibles.at(7)) { + addMenu(menu, "16"); + } + if (count > 8 && visibles.at(8)) { + addMenu(menu, "25"); + } + if (count > 9 && visibles.at(9)) { + addMenu(menu, "36"); + } + if (count > 10 && visibles.at(10)) { + addMenu(menu, "64"); + } +} + +void VideoBox::show_video_all() +{ + //一般是从配置文件读取到了最后的通道画面类型进行设置 + int type = 1; + if (videoType.startsWith("0_")) { + int index = videoType.split("_").last().toInt() - 1; + change_video_1(index); + Q_EMIT changeVideo(type, videoType, true); + } else { + int index = videoType.split("_").first().toInt() - 1; + //y开头的布局需要重置索引=0 + if (videoType.startsWith("y")) { + index = 0; + } + + QMap::iterator iter = types.begin(); + while (iter != types.end()) { + QStringList flags = iter.value(); + if (flags.contains(videoType)) { + type = iter.key().toInt(); + show_video(type, index); + return; + } + iter++; + } + + //如果运行到这里说明设置了不存在的布局/强制纠正 + videoType = "1_4"; + this->show_video_all(); + } +} + +void VideoBox::hide_video_all() +{ + for (int i = 0; i < videoCount; ++i) { + gridLayout->removeWidget(widgets.at(i)); + widgets.at(i)->setVisible(false); + } +} + +void VideoBox::show_video() +{ + //识别具体是哪个动作菜单触发的 + QAction *action = (QAction *)sender(); + //从弱属性取出值 + int index = action->property("index").toInt() - 1; + int type = action->property("type").toInt(); + QString videoType = action->property("flag").toString(); + //只有当画面布局类型改变了才需要切换 + if (this->videoType != videoType) { + this->videoType = videoType; + show_video(type, index); + } +} + +void VideoBox::show_video(int type, int index) +{ + //根据不同的父菜单类型执行对应的函数 + if (type == 0) { + if (videoType.contains("x")) { + //取出行列 + QString text = videoType.split("_").last(); + QStringList list = text.split("x"); + int row = list.at(0).toInt(); + int column = list.at(1).toInt(); + change_video_normal(index, row, column); + } else if (videoType == "y_1_2") { + change_video_y_1_2(index); + } else if (videoType == "y_1_3") { + change_video_y_1_3(index); + } else if (videoType == "y_1_9") { + change_video_y_1_9(index); + } else if (videoType == "y_1_10") { + change_video_y_1_10(index); + } else if (videoType == "y_1_12") { + change_video_y_1_12(index); + } else if (videoType == "y_1_16") { + change_video_y_1_16(index); + } + } else if (type == 1) { + change_video_1(index); + } else if (type == 4) { + change_video_4(index); + } else if (type == 6) { + change_video_6(index); + } else if (type == 8) { + change_video_8(index); + } else if (type == 9) { + change_video_9(index); + } else if (type == 13) { + change_video_13(index); + } else if (type == 16) { + change_video_16(index); + } else if (type == 25) { + change_video_25(index); + } else if (type == 36) { + change_video_36(index); + } else if (type == 64) { + change_video_64(index); + } + + Q_EMIT changeVideo(type, videoType, false); +} + +void VideoBox::change_video_y_1_2(int index) +{ + change_video_normal(index, 1, 2); +} + +void VideoBox::change_video_y_1_3(int index) { //首先隐藏所有通道 hide_video_all(); //添加通道到布局 - gridLayout->addWidget(widgets.at(index), 0, 0, 1, 2); + gridLayout->addWidget(widgets.at(index + 0), 0, 0, 1, 2); gridLayout->addWidget(widgets.at(index + 1), 1, 0); gridLayout->addWidget(widgets.at(index + 2), 1, 1); //设置通道控件可见 change_video_visible(index, index + 2); } +void VideoBox::change_video_y_1_9(int index) +{ + //首先隐藏所有通道 + hide_video_all(); + //添加通道到布局 + gridLayout->addWidget(widgets.at(index + 0), 0, 0, 2, 2); + gridLayout->addWidget(widgets.at(index + 1), 0, 2, 1, 1); + gridLayout->addWidget(widgets.at(index + 2), 0, 3, 1, 1); + gridLayout->addWidget(widgets.at(index + 3), 1, 2, 1, 1); + gridLayout->addWidget(widgets.at(index + 4), 1, 3, 1, 1); + gridLayout->addWidget(widgets.at(index + 5), 2, 3, 1, 1); + gridLayout->addWidget(widgets.at(index + 6), 2, 2, 1, 1); + gridLayout->addWidget(widgets.at(index + 7), 2, 1, 1, 1); + gridLayout->addWidget(widgets.at(index + 8), 2, 0, 1, 1); + //设置通道控件可见 + change_video_visible(index, index + 8); +} + +void VideoBox::change_video_y_1_10(int index) +{ + change_video_custom(index, 10); +} + +void VideoBox::change_video_y_1_12(int index) +{ + change_video_custom(index, 12); +} + +void VideoBox::change_video_y_1_16(int index) +{ + change_video_custom(index, 16); +} + +void VideoBox::change_video_1(int index) +{ + change_video_normal(index, 1, 1); +} + void VideoBox::change_video_4(int index) { change_video_normal(index, 2, 2); diff --git a/video/videopanel/videobox.h b/video/videopanel/videobox.h index cf1c79c..2322a8e 100644 --- a/video/videopanel/videobox.h +++ b/video/videopanel/videobox.h @@ -4,12 +4,14 @@ /** * 监控画面切换控件 作者:feiyangqingyun(QQ:517216493) 2021-11-08 * 1. 将所有通道切换处理全部集中到一个类。 - * 2. 通用整数倍数布局切换函数,可方便拓展到100/255通道等。 - * 3. 通用异形布局切换函数,可以参考进行自定义异形布局。 - * 4. 通道布局切换发出信号通知。 - * 5. 可控每种布局切换菜单是否启用。 - * 6. 支持自定义子菜单布局内容。 - * 7. 支持设置对应的菜单标识比如默认的通道字样改成设备。 + * 2. 通用整数倍数布局切换函数,比如4x4/5x5,可方便拓展到100/255通道等。 + * 3. 通用行列数量布局切换函数,比如1x4/4x2,可方便拓展各种axb行列数。 + * 4. 通用特殊异形布局切换函数,可以参考进行自定义异形布局。 + * 5. 提供添加行列数布局函数。 + * 6. 通道布局切换发出信号通知。 + * 7. 可控每种布局切换菜单是否启用。 + * 8. 支持自定义子菜单布局内容。 + * 9. 支持设置对应的菜单标识比如默认的通道字样改成设备。 */ #include @@ -43,18 +45,30 @@ private: //当前画面类型 QString videoType; - //启用其他通道画面(2画面/3画面) - bool enableOther; - //主菜单子菜单文字标识 QString menuFlag; QString actionFlag; + //可以控制每个子菜单是否可见 + QList visibles; + //布局方案标识集合 QMap types; void addMenu(QMenu *menu, const QString &type); -public Q_SLOTS: +private: + //常规及异形通道布局 + void change_video_normal(int index, int row, int column); + void change_video_custom(int index, int type); + + //设置可见 + void change_video_visible(int start, int end); + + //异形布局(l表示右侧底部环绕布局/o表示上下左右环绕布局) + void change_video_l(const QList &indexs); + void change_video_o(const QList &indexs); + +public: //获取和设置当前画面类型 QString getVideoType() const; void setVideoType(const QString &videoType); @@ -65,43 +79,38 @@ public Q_SLOTS: //设置表格布局 void setLayout(QGridLayout *gridLayout); - //设置启用其他通道画面 - void setEnableOther(bool enableOther); //设置主菜单子菜单文字标识 void setMenuFlag(const QString &menuFlag); void setActionFlag(const QString &actionFlag); - //设置菜单类型集合 - void setTypes(const QMap &types); + //设置子菜单可见 + void setVisibles(const QList &visibles); + + //添加行列布局(必须在initMenu前调用) + void appendType(int index, int row, int column); //初始化菜单 - void initMenu(QMenu *menu, const QList &enable); - - //通用设置函数 - void show_video(int type, int index); - //菜单切换布局槽函数 - void show_video(); + void initMenu(QMenu *menu); +public Q_SLOTS: //显示和隐藏所有通道 void show_video_all(); void hide_video_all(); - //常规及异形通道布局 - void change_video_normal(int index, int row, int column); - void change_video_custom(int index, int type); + //菜单切换布局槽函数 + void show_video(); + void show_video(int type, int index); - //设置可见 - void change_video_visible(int start, int end); + //自定义布局通道切换函数 + void change_video_y_1_2(int index); + void change_video_y_1_3(int index); + void change_video_y_1_9(int index); + void change_video_y_1_10(int index); + void change_video_y_1_12(int index); + void change_video_y_1_16(int index); - //异形布局 - void change_video_6(const QList &indexs); - void change_video_8(const QList &indexs); - void change_video_13(const QList &indexs); - - //具体通道切换函数 + //常规布局通道切换函数 void change_video_1(int index); - void change_video_2(int index); - void change_video_3(int index); void change_video_4(int index); void change_video_6(int index); void change_video_8(int index); diff --git a/video/videopanel/videopanel.cpp b/video/videopanel/videopanel.cpp index 97acb73..e7c28a3 100644 --- a/video/videopanel/videopanel.cpp +++ b/video/videopanel/videopanel.cpp @@ -113,9 +113,7 @@ void VideoPanel::initMenu() //实例化通道布局类 videoBox = new VideoBox(this); - QList enable; - enable << true << true << true << true << true << true << true << true << true; - videoBox->initMenu(videoMenu, enable); + videoBox->initMenu(videoMenu); videoBox->setVideoType(videoType); videoBox->setLayout(gridLayout); videoBox->setWidgets(widgets);