git mv Code\Sandbox\Plugins Code/Editor/Plugins
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QImage>
|
||||
|
||||
namespace ProjectSettingsTool
|
||||
{
|
||||
namespace Validators
|
||||
{
|
||||
static const char* pngMimeType = "image/png";
|
||||
|
||||
// Returns true if path is empty or valid png file with specified dimensions
|
||||
template <int imageWidth, int imageHeight>
|
||||
FunctorValidator::ReturnType PngImageSetSizeOrEmpty(const QString& path)
|
||||
{
|
||||
using RetType = FunctorValidator::ReturnType;
|
||||
|
||||
if (IsNotEmpty(path).first != QValidator::Acceptable)
|
||||
{
|
||||
return FunctorValidator::ReturnType(QValidator::Acceptable, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
RetType correct = Internal::FileReadableAndCorrectType(path, pngMimeType);
|
||||
|
||||
if (correct.first)
|
||||
{
|
||||
QImage image(path);
|
||||
|
||||
if (imageWidth == image.width() && imageHeight == image.height())
|
||||
{
|
||||
return FunctorValidator::ReturnType(QValidator::Acceptable, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
return RetType(QValidator::Intermediate, QObject::tr("Image is not %1x%2 pixels.")
|
||||
.arg(QString::number(imageWidth)).arg(QString::number(imageHeight)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return correct;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace Validators
|
||||
} // namespace ProjectSettingsTool
|
||||
Reference in New Issue
Block a user