Support xml file as input document for command line

master
huxingyi 2020-10-16 19:36:04 +09:30
parent 3cff6ad52a
commit 9c8ea6bb83
4 changed files with 81 additions and 66 deletions

View File

@ -8,7 +8,6 @@ language: cpp
matrix: matrix:
include: include:
- if: tag IS present
- os: linux - os: linux
dist: xenial dist: xenial
sudo: required sudo: required

View File

@ -1,6 +1,6 @@
os: Visual Studio 2017 os: Visual Studio 2017
skip_non_tags: true skip_non_tags: false
environment: environment:
matrix: matrix:

View File

@ -1663,13 +1663,24 @@ void DocumentWindow::createPartSnapshotForFillMesh(const QUuid &fillMeshFileId,
void DocumentWindow::openPathAs(const QString &path, const QString &asName) void DocumentWindow::openPathAs(const QString &path, const QString &asName)
{ {
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
Ds3FileReader ds3Reader(path);
m_document->clearHistories(); m_document->clearHistories();
m_document->resetScript(); m_document->resetScript();
m_document->reset(); m_document->reset();
m_document->saveSnapshot(); m_document->saveSnapshot();
if (path.endsWith(".xml")) {
QFile file(path);
file.open(QIODevice::ReadOnly);
QXmlStreamReader stream(&file);
Snapshot snapshot;
loadSkeletonFromXmlStream(&snapshot, stream);
m_document->fromSnapshot(snapshot);
m_document->saveSnapshot();
} else {
Ds3FileReader ds3Reader(path);
for (int i = 0; i < ds3Reader.items().size(); ++i) { for (int i = 0; i < ds3Reader.items().size(); ++i) {
Ds3ReaderItem item = ds3Reader.items().at(i); Ds3ReaderItem item = ds3Reader.items().at(i);
if (item.type == "asset") { if (item.type == "asset") {
@ -1731,6 +1742,8 @@ void DocumentWindow::openPathAs(const QString &path, const QString &asName)
} }
} }
} }
}
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
setCurrentFilename(asName); setCurrentFilename(asName);
@ -2122,6 +2135,9 @@ void DocumentWindow::checkExportWaitingList()
} else if (filename.endsWith(".glb")) { } else if (filename.endsWith(".glb")) {
exportGlbToFilename(filename); exportGlbToFilename(filename);
emit waitingExportFinished(filename, isSuccessful); emit waitingExportFinished(filename, isSuccessful);
} else if (filename.endsWith(".png")) {
exportImageToFilename(filename);
emit waitingExportFinished(filename, isSuccessful);
} else { } else {
emit waitingExportFinished(filename, false); emit waitingExportFinished(filename, false);
} }

View File

@ -79,7 +79,7 @@ int main(int argc, char ** argv)
continue; continue;
} }
QString arg = argv[i]; QString arg = argv[i];
if (arg.endsWith(".ds3")) { if (arg.endsWith(".ds3") || arg.endsWith(".xml")) {
openFileList.append(arg); openFileList.append(arg);
continue; continue;
} }