Python: support remote file paths when loading projects

Change-Id: I94f709275d3b226685439ac55d58b029d3323d12
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
David Schulz
2023-06-06 09:34:24 +02:00
parent beaf86f9de
commit d617b046c6

View File

@@ -90,14 +90,13 @@ private:
static QJsonObject readObjJson(const FilePath &projectFile, QString *errorMessage)
{
QFile file(projectFile.toString());
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
*errorMessage = Tr::tr("Unable to open \"%1\" for reading: %2")
.arg(projectFile.toUserOutput(), file.errorString());
return QJsonObject();
const expected_str<QByteArray> fileContentsResult = projectFile.fileContents();
if (!fileContentsResult) {
*errorMessage = fileContentsResult.error();
return {};
}
const QByteArray content = file.readAll();
const QByteArray content = *fileContentsResult;
// This assumes the project file is formed with only one field called
// 'files' that has a list associated of the files to include in the project.