This commit is contained in:
Gangphon 2024-02-28 11:34:33 +08:00
parent e54f367005
commit c311554cee
2 changed files with 13 additions and 21 deletions

View File

@ -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;

View File

@ -3,7 +3,6 @@
#include "globaldefine.h"
#include "tools.h"
#include "program/eenviron.h"
#include "program/etext.h"
#include "program/evideo.h"
#include <QBuffer>
#include <QProcess>
@ -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<JObj> 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;