diff --git a/src/mkvtoolnix-gui/util/json_config_file.cpp b/src/mkvtoolnix-gui/util/json_config_file.cpp index 6b5687e25..8389761e3 100644 --- a/src/mkvtoolnix-gui/util/json_config_file.cpp +++ b/src/mkvtoolnix-gui/util/json_config_file.cpp @@ -8,11 +8,24 @@ #include #include #include +#include + +#include "common/qt.h" #include "mkvtoolnix-gui/util/json_config_file.h" namespace mtx { namespace gui { namespace Util { +static QJsonDocument::JsonFormat +jsonFormat() { + static boost::optional s_jsonFormat; + + if (!s_jsonFormat) + s_jsonFormat.reset( QString::fromUtf8(qgetenv("MTX_JSON_FORMAT")).toLower() == Q("indented") ? QJsonDocument::Indented : QJsonDocument::Compact ); + + return s_jsonFormat.get(); +} + class GroupConverter { protected: QStack m_objects; @@ -123,7 +136,7 @@ JsonConfigFile::save() { QFile out{m_fileName}; if (out.open(QIODevice::WriteOnly | QIODevice::Truncate)) { auto doc = GroupConverter::toJson(m_rootGroup); - out.write(doc.toJson(QJsonDocument::Compact)); + out.write(doc.toJson(jsonFormat())); out.close(); } }