From c311554cee01041be371653494295970dd4fca93 Mon Sep 17 00:00:00 2001 From: Gangphon Date: Wed, 28 Feb 2024 11:34:33 +0800 Subject: [PATCH] ledok --- LedOK/program/eaclock.cpp | 21 ++++++--------------- LedOK/program/gentmpthread.cpp | 13 +++++++------ 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/LedOK/program/eaclock.cpp b/LedOK/program/eaclock.cpp index 9d76171..6560005 100644 --- a/LedOK/program/eaclock.cpp +++ b/LedOK/program/eaclock.cpp @@ -551,22 +551,13 @@ QWidget* EAClock::attrWgt() { bool EAClock::save(const QString &pRoot){ if(m_attr.hasDialImg) { - QString file0 = m_attr.path + PAGEDEL_SUFFIX + "/" + m_attr.name; - QString file1 = m_attr.path + "/" + m_attr.name; - QFile f0(file0); - QFile f1(file1); - QString old_file; - QString new_file = pRoot + "/" + m_attr.name; - if(f0.exists()) { - old_file = file0; - } else if(f1.exists()) { - old_file = file1; - } else {//自己画点,不用背景表盘 - return false; + auto old_file = m_attr.path + PAGEDEL_SUFFIX + "/" + m_attr.name; + if(! QFileInfo::exists(old_file)) { + old_file = m_attr.path + "/" + m_attr.name; + if(! QFileInfo::exists(old_file)) return false; //自己画点,不用背景表盘 } - QFile old_f(old_file); - QFile new_f(new_file); - if(!new_f.exists()) old_f.copy(new_file); + auto new_file = pRoot + "/" + m_attr.name; + if(! QFileInfo::exists(new_file)) QFile(old_file).copy(new_file); } else { auto filename = QString("%1-%2-%3-%4-%5.png").arg((int)zValue()).arg((int)x()).arg((int)y()).arg((int)mWidth).arg((int)mHeight); m_attr.path = pRoot; diff --git a/LedOK/program/gentmpthread.cpp b/LedOK/program/gentmpthread.cpp index 5462b38..ba45ec7 100644 --- a/LedOK/program/gentmpthread.cpp +++ b/LedOK/program/gentmpthread.cpp @@ -3,7 +3,6 @@ #include "globaldefine.h" #include "tools.h" #include "program/eenviron.h" -#include "program/etext.h" #include "program/evideo.h" #include #include @@ -45,7 +44,7 @@ void GenTmpThread::run() { } //扫描节目, 返回多个节目数组 - QStringList pageNames = QDir(srcDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot); + auto pageNames = QDir(srcDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot); //查询 order 属性, 将最上层的放在转换后 layers 的最前面 //一个 page.json 对应节目任务中的一个 items 里的 program std::vector pageJsons; @@ -461,11 +460,13 @@ JObj GenTmpThread::convertDClock(const JValue &json){ JObj GenTmpThread::convertAClock(const JValue &json) { auto widget = json["widget"]; if(widget.isNull()) widget = json; - QString srcFile = srcPageDir + "/" + widget["selfCreateDialName"].toString(); - QFile srcQFile(srcFile); - if(! srcQFile.exists()) return JObj(); + auto srcFile = srcPageDir + "/" + widget["selfCreateDialName"].toString(); + if(! QFileInfo::exists(srcFile)) { + srcFile = srcPageDir + "/" + widget["name"].toString(); + if(! QFileInfo::exists(srcFile)) return JObj(); + } QString id = Tools::fileMd5(srcFile); - srcQFile.copy(dstDir+"/"+id); + QFile(srcFile).copy(dstDir+"/"+id); JObj oRes; oRes["_type"] = "AnalogClock"; oRes["id"] = id;