3
0

ImagePreviewerFactory.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <AzCore/PlatformDef.h>
  9. AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT
  10. #include <Source/Previewer/ImagePreviewer.h>
  11. #include <Source/Previewer/ImagePreviewerFactory.h>
  12. #include <AzCore/Asset/AssetTypeInfoBus.h>
  13. #include <AzToolsFramework/AssetBrowser/AssetBrowserEntry.h>
  14. #include <AzToolsFramework/AssetBrowser/EBusFindAssetTypeByName.h>
  15. #include <ImageLoader/ImageLoaders.h>
  16. AZ_POP_DISABLE_WARNING
  17. namespace ImageProcessingAtom
  18. {
  19. AzToolsFramework::AssetBrowser::Previewer* ImagePreviewerFactory::CreatePreviewer(QWidget* parent) const
  20. {
  21. return new ImagePreviewer(parent);
  22. }
  23. bool ImagePreviewerFactory::IsEntrySupported(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) const
  24. {
  25. using namespace AzToolsFramework::AssetBrowser;
  26. EBusFindAssetTypeByName textureAssetTypeResult("StreamingImage");
  27. AZ::AssetTypeInfoBus::BroadcastResult(textureAssetTypeResult, &AZ::AssetTypeInfo::GetAssetType);
  28. switch (entry->GetEntryType())
  29. {
  30. case AssetBrowserEntry::AssetEntryType::Source:
  31. {
  32. const auto source = azrtti_cast<const SourceAssetBrowserEntry*>(entry);
  33. AZStd::string extention = source->GetExtension();
  34. // Skip the '.' when check the extension
  35. return IsExtensionSupported(extention.c_str() + 1);
  36. }
  37. case AssetBrowserEntry::AssetEntryType::Product:
  38. const auto product = azrtti_cast<const ProductAssetBrowserEntry*>(entry);
  39. return product->GetAssetType() == textureAssetTypeResult.GetAssetType();
  40. }
  41. return false;
  42. }
  43. const QString& ImagePreviewerFactory::GetName() const
  44. {
  45. return m_name;
  46. }
  47. }//namespace ImageProcessingAtom