From a69c444f2ca0ce40e38056f8e9d5dac52f679451 Mon Sep 17 00:00:00 2001 From: Gangphon Date: Tue, 20 Jun 2023 08:49:01 +0800 Subject: [PATCH] =?UTF-8?q?ledok=E8=8A=82=E7=9B=AE=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BA=8F=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LedOK/program/pagelistitem.cpp | 21 ++++++++++++------ LedOK/program/pagelistitem.h | 2 +- LedOK/program/progeditorwin.cpp | 38 +++++++++++++++++++++++---------- 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/LedOK/program/pagelistitem.cpp b/LedOK/program/pagelistitem.cpp index 280eb00..731ea2e 100644 --- a/LedOK/program/pagelistitem.cpp +++ b/LedOK/program/pagelistitem.cpp @@ -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; } diff --git a/LedOK/program/pagelistitem.h b/LedOK/program/pagelistitem.h index 81b5d38..3e9963f 100644 --- a/LedOK/program/pagelistitem.h +++ b/LedOK/program/pagelistitem.h @@ -25,7 +25,7 @@ public: QListWidget *mAudiosList{0}; QGraphicsScene *mScene{0}; QGraphicsView *mGraView{0}; - QLabel *fdPlayTimes{0}; + QLabel *fdIdx{0}, *fdPlayTimes{0}; }; struct AudioInfo { diff --git a/LedOK/program/progeditorwin.cpp b/LedOK/program/progeditorwin.cpp index a9c94f0..5f6d10b 100644 --- a/LedOK/program/progeditorwin.cpp +++ b/LedOK/program/progeditorwin.cpp @@ -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(listPage->item(i)); + int cnt = listPage->count(); + for(int i=0; iitem(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(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(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(listPage->item(i))->mAttr["order"] = QJsonValue(i); + int cnt = listPage->count(); + for(int i=0; iitem(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(listPage->item(i))->mAttr["order"] = QJsonValue(i); + int cnt = listPage->count(); + for(int i=0; iitem(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(listPage->item(i))->mAttr["order"] = QJsonValue(i); + int cnt = listPage->count(); + for(int i=0; iitem(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); }