ledok节目列表增加序号

This commit is contained in:
Gangphon 2023-06-20 08:49:01 +08:00
parent 3bafd0c46a
commit a69c444f2c
3 changed files with 43 additions and 18 deletions

View File

@ -1,4 +1,5 @@
#include "pagelistitem.h"
#include "gutil/qgui.h"
#include "base/ffutil.h"
#include "base/lodateselector.h"
#include "cfg.h"
@ -122,8 +123,9 @@ bool PageListItem::saveFiles() {
}
QWidget *PageListItem::itemWgt() {
auto wgtPage = new QWidget();
auto hBox = new QHBoxLayout(wgtPage);
auto wgtPage = new QWidget;
auto hBox = new HBox(wgtPage);
mGraView = new QGraphicsView();
mGraView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
mGraView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@ -136,11 +138,18 @@ QWidget *PageListItem::itemWgt() {
mGraView->scale(scale, scale);
hBox->addWidget(mGraView);
fdPlayTimes = new QLabel(QString::number(mAttr["repeat"].toInt()));
hBox->addWidget(fdPlayTimes);
auto vBox = new VBox(hBox);
vBox->addWidget(fdIdx = new QLabel, 0, Qt::AlignCenter);
if(listWidget()->count()>4) fdIdx->setNum(listWidget()->count());
auto hh = new HBox(vBox);
hh->addStretch();
fdPlayTimes = new QLabel(QString::number(mAttr["repeat"].toInt()));
hh->addWidget(fdPlayTimes);
hh->addWidget(new QLabel(tr("times")));
vBox->addStretch();
hBox->addWidget(new QLabel(tr("times")));
hBox->addStretch();
return wgtPage;
}

View File

@ -25,7 +25,7 @@ public:
QListWidget *mAudiosList{0};
QGraphicsScene *mScene{0};
QGraphicsView *mGraView{0};
QLabel *fdPlayTimes{0};
QLabel *fdIdx{0}, *fdPlayTimes{0};
};
struct AudioInfo {

View File

@ -130,9 +130,9 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
mProgItem->m_last = QDateTime::currentDateTime();
mProgItem->m_fsize = dirFileSize(mProgItem->mProgDir);
mProgItem->onSetProgram();
int n = listPage->count();
for(int i=0; i<n; i++) {
auto page = static_cast<PageListItem*>(listPage->item(i));
int cnt = listPage->count();
for(int i=0; i<cnt; i++) {
auto page = (PageListItem*) listPage->item(i);
page->mScene->setSceneRect(0, 0, mProgItem->mWidth, mProgItem->mHeight);
page->mGraView->resetTransform();
qreal scale = qMin(page->mGraView->width() / page->mScene->width(), page->mGraView->height() / page->mScene->height());
@ -372,7 +372,7 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
auto actCopy = new QAction(QIcon(":/res/program/Copy.png"), tr("Copy page"));
connect(actCopy, &QAction::triggered, this, [this] {
if(listPage->count() > 0) {
auto cur = static_cast<PageListItem*>(listPage->currentItem());
auto cur = (PageListItem*) listPage->currentItem();
cur->updateJson();
auto item = new PageListItem(cur->mAttr, cur->mPageDir);
item->mAttr["name"] = QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz");
@ -380,6 +380,7 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
listPage->addItem(item);
listPage->setItemWidget(item, item->itemWgt());
listPage->setCurrentItem(item);
if(listPage->count()==5) for(int i=0; i<4; i++) ((PageListItem*)listPage->item(i))->fdIdx->setNum(i+1);
}
});
toolBar->addAction(actCopy);
@ -388,13 +389,17 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
connect(actDel, &QAction::triggered, this, [this] {
if(listPage->count() == 1) mPageEditor->onClean();
else if(listPage->count() > 1) {
auto item = static_cast<PageListItem*>(listPage->currentItem());
auto item = (PageListItem*) listPage->currentItem();
auto res = QMessageBox::information(this, tr("Tip Info"), tr("Are you sure you want to delete this program page?"), QMessageBox::Ok, QMessageBox::Cancel);
if(res == QMessageBox::Ok) {
delete item;
if(listPage->count() > 0) listPage->setCurrentRow(0);
int n = listPage->count();
for(int i=0; i<n; i++) static_cast<PageListItem*>(listPage->item(i))->mAttr["order"] = QJsonValue(i);
int cnt = listPage->count();
for(int i=0; i<cnt; i++) {
auto item = (PageListItem*)listPage->item(i);
item->mAttr["order"] = i;
item->fdIdx->setNum(i+1);
}
}
}
});
@ -410,8 +415,12 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
listPage->setItemWidget(item, item->itemWgt());
listPage->setCurrentRow(index-1);
}
int n = listPage->count();
for(int i=0; i<n; i++) static_cast<PageListItem*>(listPage->item(i))->mAttr["order"] = QJsonValue(i);
int cnt = listPage->count();
for(int i=0; i<cnt; i++) {
auto item = (PageListItem*)listPage->item(i);
item->mAttr["order"] = i;
item->fdIdx->setNum(i+1);
}
}
});
toolBar->addAction(actMoveUp);
@ -426,8 +435,12 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
listPage->setItemWidget(item, item->itemWgt());
listPage->setCurrentRow(index+1);
}
int n = listPage->count();
for(int i=0; i<n; i++) static_cast<PageListItem*>(listPage->item(i))->mAttr["order"] = QJsonValue(i);
int cnt = listPage->count();
for(int i=0; i<cnt; i++) {
auto item = (PageListItem*)listPage->item(i);
item->mAttr["order"] = i;
item->fdIdx->setNum(i+1);
}
}
});
toolBar->addAction(actMoveDown);
@ -532,6 +545,8 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
auto item = new PageListItem(pageJson, pageDir);
listPage->addItem(item);
listPage->setItemWidget(item, item->itemWgt());
auto cnt = listPage->count();
if(cnt==5) for(int i=0; i<4; i++) ((PageListItem*)listPage->item(i))->fdIdx->setNum(i+1);
}
}
listPage->setCurrentRow(0);
@ -650,4 +665,5 @@ void ProgEditorWin::onAddPage() {
listPage->addItem(item);
listPage->setItemWidget(item, item->itemWgt());
listPage->setCurrentItem(item);
if(listPage->count()==5) for(int i=0; i<4; i++) ((PageListItem*)listPage->item(i))->fdIdx->setNum(i+1);
}