11#include " DspxInspectorDialog.h"
22#include " DspxInspectorDialog_p.h"
33
4+ #include < application_config.h>
5+
46#include < QApplication>
57#include < QDir>
68#include < QVBoxLayout>
1416#include < opendspx/model.h>
1517#include < opendspxserializer/serializer.h>
1618
19+ #include < SVSCraftCore/Semver.h>
20+
21+ #include < coreplugin/CoreInterface.h>
22+ #include < coreplugin/DspxCheckerRegistry.h>
1723#include < coreplugin/OpenSaveProjectFileScenario.h>
1824
1925namespace Core {
2026
27+ static bool checkIsVersionCompatible (const QString &version) {
28+ if (version.isEmpty ())
29+ return true ;
30+ SVS ::Semver currentSemver (QStringLiteral (APPLICATION_SEMVER ));
31+ SVS ::Semver fileSemver (version);
32+ if (fileSemver == currentSemver)
33+ return true ;
34+ if (fileSemver > currentSemver)
35+ return false ;
36+ if (!fileSemver.preRelease ().isEmpty () || !fileSemver.build ().isEmpty ()) {
37+ return false ;
38+ }
39+ return true ;
40+ }
41+
2142 DspxInspectorDialog::DspxInspectorDialog (QWidget *parent) : QDialog(parent), d_ptr(new DspxInspectorDialogPrivate) {
2243 Q_D (DspxInspectorDialog);
2344 d->q_ptr = this ;
@@ -126,7 +147,7 @@ namespace Core {
126147 if (!f.open (QIODevice::ReadOnly)) {
127148 addErrorItem (
128149 problemModel,
129- tr (" Failed to open file" ),
150+ tr (" Fatal: Failed to open file" ),
130151 {},
131152 style ()->standardIcon (QStyle::SP_MessageBoxCritical),
132153 {
@@ -190,7 +211,7 @@ namespace Core {
190211 }
191212 addErrorItem (
192213 problemModel,
193- tr (" Error: Invalid data type" ) + QStringLiteral (" (0x%1)" ).arg (QString::number (error->type (), 16 ), 4 , ' 0' ),
214+ tr (" Invalid data type" ) + QStringLiteral (" (0x%1)" ).arg (QString::number (error->type (), 16 ), 4 , ' 0' ),
194215 e->path (),
195216 style ()->standardIcon (QStyle::SP_MessageBoxCritical),
196217 {
@@ -205,7 +226,7 @@ namespace Core {
205226 auto e = error.staticCast <QDspx::InvalidObjectTypeError>();
206227 addErrorItem (
207228 problemModel,
208- tr (" Error: Invalid object type" ) + QStringLiteral (" (0x%1)" ).arg (QString::number (error->type (), 16 ), 4 , ' 0' ),
229+ tr (" Invalid object type" ) + QStringLiteral (" (0x%1)" ).arg (QString::number (error->type (), 16 ), 4 , ' 0' ),
209230 e->path (),
210231 style ()->standardIcon (QStyle::SP_MessageBoxCritical),
211232 {
@@ -220,7 +241,7 @@ namespace Core {
220241 auto e = error.staticCast <QDspx::RangeConstraintViolationError>();
221242 addErrorItem (
222243 problemModel,
223- tr (" Error: Range constraint violation" ) + QStringLiteral (" (0x%1)" ).arg (QString::number (error->type (), 16 ), 4 , ' 0' ),
244+ tr (" Range constraint violation" ) + QStringLiteral (" (0x%1)" ).arg (QString::number (error->type (), 16 ), 4 , ' 0' ),
224245 e->path (),
225246 style ()->standardIcon (QStyle::SP_MessageBoxCritical),
226247 {
@@ -241,7 +262,7 @@ namespace Core {
241262 info.emplace_back (tr (" Actual enum value" ), e->actualEnumValue ().toString ());
242263 addErrorItem (
243264 problemModel,
244- tr (" Error: Enum constraint violation" ) + QStringLiteral (" (0x%1)" ).arg (QString::number (error->type (), 16 ), 4 , ' 0' ),
265+ tr (" Enum constraint violation" ) + QStringLiteral (" (0x%1)" ).arg (QString::number (error->type (), 16 ), 4 , ' 0' ),
245266 e->path (),
246267 style ()->standardIcon (QStyle::SP_MessageBoxCritical),
247268 info,
@@ -257,7 +278,7 @@ namespace Core {
257278 }
258279 addErrorItem (
259280 problemModel,
260- tr (" Error: Missing properties" ) + QStringLiteral (" (0x%1)" ).arg (QString::number (error->type (), 16 ), 4 , ' 0' ),
281+ tr (" Missing properties" ) + QStringLiteral (" (0x%1)" ).arg (QString::number (error->type (), 16 ), 4 , ' 0' ),
261282 e->path (),
262283 style ()->standardIcon (QStyle::SP_MessageBoxCritical),
263284 info,
@@ -273,7 +294,7 @@ namespace Core {
273294 }
274295 addErrorItem (
275296 problemModel,
276- tr (" Error: Redundant properties" ) + QStringLiteral (" (0x%1)" ).arg (QString::number (error->type (), 16 ), 4 , ' 0' ),
297+ tr (" Redundant properties" ) + QStringLiteral (" (0x%1)" ).arg (QString::number (error->type (), 16 ), 4 , ' 0' ),
277298 e->path (),
278299 style ()->standardIcon (QStyle::SP_MessageBoxCritical),
279300 info,
@@ -289,9 +310,9 @@ namespace Core {
289310 }
290311 addErrorItem (
291312 problemModel,
292- tr (" Warning: Overlapping items" ) + QStringLiteral (" (0x%1)" ).arg (QString::number (error->type (), 16 ), 4 , ' 0' ),
313+ tr (" Overlapping items" ) + QStringLiteral (" (0x%1)" ).arg (QString::number (error->type (), 16 ), 4 , ' 0' ),
293314 e->path (),
294- style ()-> standardIcon (QStyle::SP_MessageBoxWarning) ,
315+ {} ,
295316 info,
296317 tr (" Items at specific indexes in the array at the specific path overlap." )
297318 );
@@ -301,9 +322,9 @@ namespace Core {
301322 auto e = error.staticCast <QDspx::ZeroLengthRangeError>();
302323 addErrorItem (
303324 problemModel,
304- tr (" Warning: Zero-length range" ) + QStringLiteral (" (0x%1)" ).arg (QString::number (error->type (), 16 ), 4 , ' 0' ),
325+ tr (" Zero-length range" ) + QStringLiteral (" (0x%1)" ).arg (QString::number (error->type (), 16 ), 4 , ' 0' ),
305326 e->path (),
306- style ()-> standardIcon (QStyle::SP_MessageBoxWarning) ,
327+ {} ,
307328 {},
308329 tr (" The range length of the entity object at the specific path is zero." )
309330 );
@@ -313,9 +334,9 @@ namespace Core {
313334 auto e = error.staticCast <QDspx::ErroneousClipRangeError>();
314335 addErrorItem (
315336 problemModel,
316- tr (" Warning: Erroneous clip range" ) + QStringLiteral (" (0x%1)" ).arg (QString::number (error->type (), 16 ), 4 , ' 0' ),
337+ tr (" Erroneous clip range" ) + QStringLiteral (" (0x%1)" ).arg (QString::number (error->type (), 16 ), 4 , ' 0' ),
317338 e->path (),
318- style ()-> standardIcon (QStyle::SP_MessageBoxWarning) ,
339+ {} ,
319340 {},
320341 tr (" The clipping range of the clip entity object at the specific path exceeds its range limit." )
321342 );
@@ -325,9 +346,9 @@ namespace Core {
325346 auto e = error.staticCast <QDspx::ErroneousClipPositionError>();
326347 addErrorItem (
327348 problemModel,
328- tr (" Warning: Erroneous clip position" ) + QStringLiteral (" (0x%1)" ).arg (QString::number (error->type (), 16 ), 4 , ' 0' ),
349+ tr (" Erroneous clip position" ) + QStringLiteral (" (0x%1)" ).arg (QString::number (error->type (), 16 ), 4 , ' 0' ),
329350 e->path (),
330- style ()-> standardIcon (QStyle::SP_MessageBoxWarning) ,
351+ {} ,
331352 {},
332353 tr (" The position of the clip entity object at the specific path exceeds the view range limit. It might be not visible in the viewport." )
333354 );
@@ -337,7 +358,7 @@ namespace Core {
337358 auto e = error.staticCast <QDspx::SafeRangeLimitExceededError>();
338359 addErrorItem (
339360 problemModel,
340- tr (" Warning: Safe range limit exceeded" ) + QStringLiteral (" (0x%1)" ).arg (QString::number (error->type (), 16 ), 4 , ' 0' ),
361+ tr (" Safe range limit exceeded" ) + QStringLiteral (" (0x%1)" ).arg (QString::number (error->type (), 16 ), 4 , ' 0' ),
341362 e->path (),
342363 style ()->standardIcon (QStyle::SP_MessageBoxWarning),
343364 {},
@@ -348,6 +369,43 @@ namespace Core {
348369 }
349370 }
350371
372+ if (dspxModel.content .global .editorId != CoreInterface::dspxEditorId ()) {
373+ addErrorItem (
374+ problemModel,
375+ tr (" File Created With Another Application" ),
376+ QStringLiteral (" $.content.global.editorId" ),
377+ style ()->standardIcon (QStyle::SP_MessageBoxWarning),
378+ {
379+ {tr (" Editor ID" ), dspxModel.content .global .editorId },
380+ {tr (" Editor name" ), dspxModel.content .global .editorName },
381+ },
382+ tr (" This project file was created with another application. Some features may not be fully compatible or may behave differently." )
383+ );
384+ } else if (auto version = dspxModel.content .workspace .value (" diffscope" ).value (" editorVersion" ).toString (); !checkIsVersionCompatible (version)) {
385+ addErrorItem (
386+ problemModel,
387+ tr (" File Created With Incompatible Version" ),
388+ QStringLiteral (" $.content.workspace.diffscope.editorVersion" ),
389+ style ()->standardIcon (QStyle::SP_MessageBoxWarning),
390+ {
391+ {tr (" Version" ), version},
392+ },
393+ tr (" This project file was created with an newer version or test version of %1. Some features may not be fully compatible or may behave differently." ).arg (QApplication::applicationDisplayName ())
394+ );
395+ }
396+
397+ auto customCheckResult = CoreInterface::dspxCheckerRegistry ()->runCheck (dspxModel, IDspxChecker::Weak, false );
398+ for (const auto &warning : customCheckResult) {
399+ addErrorItem (
400+ problemModel,
401+ warning.message ,
402+ warning.jsonPath ,
403+ warning.level == IDspxChecker::Strong ? style ()->standardIcon (QStyle::SP_MessageBoxWarning) : QIcon (),
404+ warning.info ,
405+ warning.description
406+ );
407+ }
408+
351409 // TODO show file structure
352410 }
353411
0 commit comments