From f5b5ad1f791bbe607a0cb5eb19a9043f749dd499 Mon Sep 17 00:00:00 2001 From: Gangphon Date: Mon, 19 Aug 2024 16:10:49 +0800 Subject: [PATCH] ledok --- LedOK/device/ctrladvancedpanel.cpp | 73 +++++++++++++++++++++++++++++- LedOK/device/ctrladvancedpanel.h | 2 +- LedOK/progpanel.cpp | 11 ++++- LedOK/program/ebase.cpp | 43 ++++++++++-------- LedOK/program/ebase.h | 4 +- LedOK/program/evideo.cpp | 8 ++-- LedOK/program/gentmpthread.cpp | 1 + LedOK/program/progeditorwin.cpp | 8 ++++ LedOK/program/progeditorwin.h | 2 +- LedOK/program/progitem.cpp | 3 +- LedOK/program/progitem.h | 2 +- 11 files changed, 124 insertions(+), 33 deletions(-) diff --git a/LedOK/device/ctrladvancedpanel.cpp b/LedOK/device/ctrladvancedpanel.cpp index 4085526..b5ea0d7 100644 --- a/LedOK/device/ctrladvancedpanel.cpp +++ b/LedOK/device/ctrladvancedpanel.cpp @@ -2174,7 +2174,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() { lbRotate = new QLabel; hBox->addWidget(lbRotate); - hBox->addSpacing(12); + hBox->addSpacing(6); auto fdDeg0 = new QRadioButton("0°"); hBox->addWidget(fdDeg0); @@ -2250,6 +2250,76 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() { } }); hBox->addWidget(btn); + hBox->addSpacing(12); + + lbOffset = new QLabel; + hBox->addWidget(lbOffset); + + hBox->addLabel("X"); + auto edOffX = new QSpinBox; + edOffX->setRange(-9999, 99999); + hBox->addWidget(edOffX); + + hBox->addLabel("Y"); + auto edOffY = new QSpinBox; + edOffY->setRange(-9999, 99999); + hBox->addWidget(edOffY); + + btnSets.push_back(btn = new QPushButton); + connect(btn, &QPushButton::clicked, this, [=] { + if(gSelCards.isEmpty()) { + QMessageBox::information(this, tr("Tip"), tr("NoSelectedController")); + return; + } + JObj json; + json.insert("_id", "SetScreenOffset"); + json.insert("_type", "SetScreenOffset"); + json.insert("x", edOffX->value()); + json.insert("y", edOffY->value()); + if(gSelCards.count() == 1) { + auto waitingDlg = new WaitingDlg(this, tr("SetScreenOffset")); + Def_CtrlReqPre + connect(reply, &QNetworkReply::finished, this, [=] { + Def_CtrlSetReqAfter + }); + } else { + for(auto &card : gSelCards) { + Def_CtrlSetMulti(tr("SetScreenOffset")) + } + } + }); + hBox->addWidget(btn); + btnGets.push_back(btn = new QPushButton); + connect(btn, &QPushButton::clicked, this, [=] { + if(gSelCards.isEmpty()) { + QMessageBox::information(this, tr("Tip"), tr("NoSelectedController")); + return; + } + QJsonObject json; + json.insert("_id", "GetScreenOffset"); + json.insert("_type", "GetScreenOffset"); + if(gSelCards.count() == 1) { + auto waitingDlg = new WaitingDlg(this, tr("GetScreenOffset")+" ..."); + Def_CtrlReqPre + connect(reply, &QNetworkReply::finished, this, [=] { + Def_CtrlSingleGetReply + waitingDlg->success(); + edOffX->setValue(json["x"].toInt()); + edOffY->setValue(json["y"].toInt()); + }); + } else { + for(auto &card : gSelCards) { + auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json); + connect(reply, &QNetworkReply::finished, this, [=] { + QJsonDocument json; + auto err = checkReplyForJson(reply, &json); + if(err.isEmpty()) err = "x: "+ QString::number(json["x"].toInt())+" y: "+ QString::number(json["y"].toInt()); + gFdResInfo->append(card.id+" "+tr("GetScreenOffset")+" "+err); + }); + } + } + }); + hBox->addWidget(btn); hBox->addStretch(); @@ -2881,6 +2951,7 @@ void CtrlAdvancedPanel::transUi() { fdHighForBusy->setText(tr("Service:High Out of service:Low")); fdTopLevelLH->setText(tr("Service:Low Out of service:High")); lbRotate->setText(tr("Rotate")); + lbOffset->setText(tr("Offset")); grpBoxHiddenSettings->setTitle(tr("Hidden Settings")+" ("+tr("Click right button to hide")+")"); btnSysUpd->setText(tr("System Update")); diff --git a/LedOK/device/ctrladvancedpanel.h b/LedOK/device/ctrladvancedpanel.h index 6ac6ee7..d7049a3 100644 --- a/LedOK/device/ctrladvancedpanel.h +++ b/LedOK/device/ctrladvancedpanel.h @@ -63,7 +63,7 @@ private: QLabel *lbDisMode; QLabel *lbScreenPos, *lbScreenOff; - QLabel *lbCameraDis; + QLabel *lbOffset, *lbCameraDis; QGroupBox *grpHighForBusy; QRadioButton *fdHighForBusy; diff --git a/LedOK/progpanel.cpp b/LedOK/progpanel.cpp index de5b285..5fa2a30 100644 --- a/LedOK/progpanel.cpp +++ b/LedOK/progpanel.cpp @@ -59,6 +59,7 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) { } } auto item = new ProgItem(mProgsDir, dlg.fdName->text(), dlg.fdWidth->value(), dlg.fdHeight->value(), dlg.fdRemark->toPlainText(), widths, max, dlg.fdVer->isChecked(), mProgTree); + item->isInsert = dlg.edIsInsert->isChecked(); item->save();//保存pro.json if(mProgTree->fdCheckAll->checkState()==Qt::Checked) { mProgTree->fdCheckAll->blockSignals(true); @@ -99,7 +100,7 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) { if(QFileInfo::exists(dir + "/pro.json")) progDirs.append(dir); else { QStringList subdirNames = QDir(dir).entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks); - foreach(QString subdirName, subdirNames) { + for(QString &subdirName : subdirNames) { auto subdir = dir + "/" + subdirName; if(! QFileInfo::exists(subdir + "/pro.json")) continue; if(QFileInfo::exists(progsDir + "/" + subdirName)) { @@ -246,8 +247,13 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) { auto act = new QAction("Open folder"); menu->addAction(act); connect(act, &QAction::triggered, this, [=] { - //QProcess::execute("explorer", {((ProgItem*)item)->mProgDir.replace('/', '\\')}); +#ifdef Q_OS_WINDOWS + auto str = ((ProgItem*)item)->mProgDir; + QProcess::execute("explorer", {str.replace('/','\\')}); +#endif +#ifdef Q_OS_MACOS QProcess::execute("open", {"-R", ((ProgItem*)item)->mProgDir}); +#endif }); menu->exec(QCursor::pos()+QPoint{2,2}); } @@ -318,6 +324,7 @@ void ProgPanel::addProFiles() { item->mWidth = json["resolution"]["w"].toInt(); item->mHeight = json["resolution"]["h"].toInt(); item->mRemark = json["remarks"].toString(); + item->isInsert = json["isInsert"].toBool(); item->isVer = json["isVer"].toBool(); auto partLengths = json["splitWidths"].toArray(); for(auto &partLength : partLengths) { diff --git a/LedOK/program/ebase.cpp b/LedOK/program/ebase.cpp index 088b0f4..f36c668 100644 --- a/LedOK/program/ebase.cpp +++ b/LedOK/program/ebase.cpp @@ -42,11 +42,11 @@ EBase::EBase(EBase *multiWin) : mMultiWin(multiWin) { } void EBase::setBaseAttr(const JObj &json) { - mStartTime = json["startTime"].toInt(); - mDuration = json["duration"].toInt(); - if(mDuration==0) { - mDuration = json["play"]["playDuration"].toInt(); - if(mDuration==0) mDuration = json["play"]["duration"].toInt(10); + _startTime = json["startTime"].toInt(); + _duration = json["duration"].toInt(); + if(_duration==0) { + _duration = json["play"]["playDuration"].toInt(); + if(_duration==0) _duration = json["play"]["duration"].toInt(10); } mEntryEffect = json["entryEffect"].toStr(); mExitEffect = json["exitEffect"].toStr(); @@ -82,8 +82,8 @@ void EBase::addBaseAttr(JObj &obj) const { obj.insert("innerY", ((int)ele->y())+bdWidth); obj.insert("innerW", ((int)ele->mWidth)-bdWidth-bdWidth); obj.insert("innerH", ((int)ele->mHeight)-bdWidth-bdWidth); - obj.insert("startTime", mStartTime); - obj.insert("duration", mDuration); + obj.insert("startTime", _startTime); + obj.insert("duration", _duration); obj.insert("entryEffect", mEntryEffect); obj.insert("exitEffect", mExitEffect); obj.insert("entryDur", mEntryDur); @@ -784,7 +784,10 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) { auto fdStart = new QSpinBox; fdStart->setRange(0, 9999); - fdStart->setValue(mStartTime); + fdStart->setValue(_startTime); + connect(fdStart, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [=](int value) { + _startTime = value; + }); hBox->addWidget(fdStart); hBox->addLabel(tr("s")); hBox->addStretch(); @@ -792,10 +795,10 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) { hBox->addLabel(tr("Duration")); - fdDuration = new QSpinBox; - fdDuration->setRange(1, 9999); - fdDuration->setValue(mDuration); - hBox->addWidget(fdDuration); + edDuration = new QSpinBox; + edDuration->setRange(1, 9999); + edDuration->setValue(_duration); + hBox->addWidget(edDuration); hBox->addLabel(tr("s")); hBox->addStretch(); @@ -851,9 +854,9 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) { fdEntryDur->setValue(mEntryDur); connect(fdEntryDur, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [=](int value) { mEntryDur = value; - if(mDuration < value) { - mDuration = value; - fdDuration->setValue(value); + if(_duration < value) { + _duration = value; + edDuration->setValue(value); } }); grid->addWidget(fdEntryDur, 0, ccc++); @@ -898,16 +901,16 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) { fdExitDur->setValue(mExitDur); connect(fdExitDur, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [=](int value) { mExitDur = value; - if(mDuration < value) { - mDuration = value; - fdDuration->setValue(value); + if(_duration < value) { + _duration = value; + edDuration->setValue(value); } }); grid->addWidget(fdExitDur, 1, ccc++); grid->addLabel(tr("s"), 1, ccc++); - connect(fdDuration, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [=](int value) { - mDuration = value; + connect(edDuration, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [=](int value) { + _duration = value; if(mEntryDur > value) { mEntryDur = value; fdEntryDur->setValue(value); diff --git a/LedOK/program/ebase.h b/LedOK/program/ebase.h index 8d1e03b..117f7db 100644 --- a/LedOK/program/ebase.h +++ b/LedOK/program/ebase.h @@ -48,8 +48,8 @@ public: EBase *mMultiWin = 0; qreal mWidth = 0, mHeight = 0; int _rotate = 0; - QSpinBox *fdDuration = 0; - int mStartTime = 0, mDuration = 10; + QSpinBox *edDuration; + int _startTime = 0, _duration = 10; QString mEntryEffect, mExitEffect; int mEntryDur = 1, mExitDur = 1; double _opacity = 1, _blink = 1; diff --git a/LedOK/program/evideo.cpp b/LedOK/program/evideo.cpp index a29e526..3a9513a 100644 --- a/LedOK/program/evideo.cpp +++ b/LedOK/program/evideo.cpp @@ -26,7 +26,7 @@ EVideo *EVideo::create(const QString &file, PageListItem *pageItem, EBase *multi QFileInfo outInfo(outFile); if(! outInfo.isFile() || outInfo.size()==0) return 0; auto ins = new EVideo(outInfo.absolutePath(), outInfo.fileName(), rawInfo.absolutePath(), rawName, img, pageItem, multiWin); - ins->mDuration = round(dur*0.000001); + ins->_duration = round(dur*0.000001); return ins; } EVideo *EVideo::create(const JObj &ele, PageListItem *pageItem, EBase *multiWin) { @@ -46,7 +46,7 @@ EVideo *EVideo::create(const JObj &ele, PageListItem *pageItem, EBase *multiWin) dur = round(dur*0.000001); auto ins = new EVideo(dir, name, widget["pathRaw"].toString(), widget["fileRaw"].toString(), img, pageItem, multiWin); ins->setBaseAttr(ele); - if(ins->mDuration < 4) ins->mDuration = dur; + if(ins->_duration < 4) ins->_duration = dur; auto play = ele["play"]; ins->playTimes = (play.isNull() ? ele : play)["playTimes"].toInt(1); return ins; @@ -117,8 +117,8 @@ QWidget* EVideo::attrWgt() { mRawName = rawInfo.fileName(); gFileHome = mRawDir; fdFileName->setText(mRawName); - mDuration = round(dur*0.000001); - fdDuration->setValue(mDuration); + _duration = round(dur*0.000001); + edDuration->setValue(_duration); auto outFile = transcoding(wgtAttr, rawFile, mRawName, mPageItem->mPageDir, mCoverImg.width(), mCoverImg.height(), codecId); if(outFile.isEmpty()) return; QFileInfo outInfo(outFile); diff --git a/LedOK/program/gentmpthread.cpp b/LedOK/program/gentmpthread.cpp index 19b03d0..7cbb05d 100644 --- a/LedOK/program/gentmpthread.cpp +++ b/LedOK/program/gentmpthread.cpp @@ -70,6 +70,7 @@ void GenTmpThread::run() { {"name", prog_name}, {"width", proJson["resolution"]["w"]}, {"height", proJson["resolution"]["h"]}, + {"insert", proJson["isInsert"]}, {"partLengths", proJson["splitWidths"]}, {"isVertical", proJson["isVer"]}, {"items", items} diff --git a/LedOK/program/progeditorwin.cpp b/LedOK/program/progeditorwin.cpp index 789e01b..639a3ed 100644 --- a/LedOK/program/progeditorwin.cpp +++ b/LedOK/program/progeditorwin.cpp @@ -109,10 +109,12 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare widthsStr.append(QString::number(width)); } ProgCreateDlg dlg(mProgItem->mName, mProgItem->mWidth, mProgItem->mHeight, mProgItem->mRemark, widthsStr, mProgItem->isVer, this); + dlg.edIsInsert->setChecked(mProgItem->isInsert); if(dlg.exec() != QDialog::Accepted) return; mProgItem->mWidth = dlg.fdWidth->value(); mProgItem->mHeight = dlg.fdHeight->value(); mProgItem->mRemark = dlg.fdRemark->toPlainText(); + mProgItem->isInsert = dlg.edIsInsert->isChecked(); mProgItem->partLens.clear(); mProgItem->maxLen = 0; mProgItem->isVer = dlg.fdVer->isChecked(); @@ -716,6 +718,12 @@ ProgCreateDlg::ProgCreateDlg(QString name, int width, int height, QString remark fdRemark->setFixedHeight(80); hBox->addWidget(fdRemark); + hBox = new HBox(vBox); + hBox->addSpacing(72); + + edIsInsert = new QCheckBox(tr("Is Insert")); + hBox->addWidget(edIsInsert); + vBox->addSpacing(6); hBox = new HBox(vBox); diff --git a/LedOK/program/progeditorwin.h b/LedOK/program/progeditorwin.h index fff4175..265a7d0 100644 --- a/LedOK/program/progeditorwin.h +++ b/LedOK/program/progeditorwin.h @@ -42,7 +42,7 @@ public: QSpinBox *fdWidth; QSpinBox *fdHeight; QTextEdit *fdRemark; - QCheckBox *fdIsUltraLong; + QCheckBox *edIsInsert, *fdIsUltraLong; QRadioButton *fdHor, *fdVer; QLineEdit *fdSplitWidths; }; diff --git a/LedOK/program/progitem.cpp b/LedOK/program/progitem.cpp index 5fe7135..3261442 100644 --- a/LedOK/program/progitem.cpp +++ b/LedOK/program/progitem.cpp @@ -162,6 +162,7 @@ void ProgItem::save() { json["name"] = mName; json["resolution"] = JObj{{"w", mWidth}, {"h", mHeight}}; json["remarks"] = mRemark; + json["isInsert"] = isInsert; json["isVer"] = isVer; JArray partLens; for(auto partLen : this->partLens) partLens.append(partLen); @@ -169,7 +170,7 @@ void ProgItem::save() { json["file_size"] = m_fsize; QFile file(mProgDir + "/pro.json"); if(file.open(QIODevice::WriteOnly)) { - file.write(JToBytes(json, "\n")); + file.write(JToBytes(json, "\t")); file.close(); } } diff --git a/LedOK/program/progitem.h b/LedOK/program/progitem.h index 380c425..476ef67 100644 --- a/LedOK/program/progitem.h +++ b/LedOK/program/progitem.h @@ -21,7 +21,7 @@ public: QString mRemark; std::vector partLens; int maxLen = 0; - bool isVer = false; + bool isInsert = false, isVer = false; QString mProgsDir; QString mProgDir; qint64 m_fsize = 0;