diff --git a/Code/Editor/AboutDialog.cpp b/Code/Editor/AboutDialog.cpp index f8abe67376..2c76526731 100644 --- a/Code/Editor/AboutDialog.cpp +++ b/Code/Editor/AboutDialog.cpp @@ -20,6 +20,7 @@ // AzCore #include // for aznumeric_cast +#include AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING #include @@ -46,8 +47,13 @@ CAboutDialog::CAboutDialog(QString versionText, QString richTextCopyrightNotice, CAboutDialog > QLabel#link { text-decoration: underline; color: #94D2FF; }"); // Prepare background image - QImage backgroundImage(QStringLiteral(":/StartupLogoDialog/splashscreen_background_developer_preview.jpg")); - m_backgroundImage = QPixmap::fromImage(backgroundImage.scaled(m_enforcedWidth, m_enforcedHeight, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + m_backgroundImage = AzQtComponents::ScalePixmapForScreenDpi( + QPixmap(QStringLiteral(":/StartupLogoDialog/splashscreen_background_developer_preview.jpg")), + screen(), + QSize(m_enforcedWidth, m_enforcedHeight), + Qt::IgnoreAspectRatio, + Qt::SmoothTransformation + ); // Draw the Open 3D Engine logo from svg m_ui->m_logo->load(QStringLiteral(":/StartupLogoDialog/o3de_logo.svg")); diff --git a/Code/Editor/StartupLogoDialog.cpp b/Code/Editor/StartupLogoDialog.cpp index d9625aff1a..ab251b1564 100644 --- a/Code/Editor/StartupLogoDialog.cpp +++ b/Code/Editor/StartupLogoDialog.cpp @@ -9,11 +9,11 @@ // Description : implementation file - #include "EditorDefs.h" - #include "StartupLogoDialog.h" +#include + // Qt #include #include @@ -22,8 +22,6 @@ AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING #include AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING - - ///////////////////////////////////////////////////////////////////////////// // CStartupLogoDialog dialog @@ -36,13 +34,16 @@ CStartupLogoDialog::CStartupLogoDialog(QString versionText, QString richTextCopy m_ui->setupUi(this); s_pLogoWindow = this; - - m_backgroundImage = QPixmap(QStringLiteral(":/StartupLogoDialog/splashscreen_background_developer_preview.jpg")); setFixedSize(QSize(600, 300)); // Prepare background image - QImage backgroundImage(QStringLiteral(":/StartupLogoDialog/splashscreen_background_developer_preview.jpg")); - m_backgroundImage = QPixmap::fromImage(backgroundImage.scaled(m_enforcedWidth, m_enforcedHeight, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + m_backgroundImage = AzQtComponents::ScalePixmapForScreenDpi( + QPixmap(QStringLiteral(":/StartupLogoDialog/splashscreen_background_developer_preview.jpg")), + screen(), + QSize(m_enforcedWidth, m_enforcedHeight), + Qt::IgnoreAspectRatio, + Qt::SmoothTransformation + ); // Draw the Open 3D Engine logo from svg m_ui->m_logo->load(QStringLiteral(":/StartupLogoDialog/o3de_logo.svg")); diff --git a/Code/Editor/WelcomeScreen/WelcomeScreenDialog.cpp b/Code/Editor/WelcomeScreen/WelcomeScreenDialog.cpp index 0f73023acf..17f576b5ee 100644 --- a/Code/Editor/WelcomeScreen/WelcomeScreenDialog.cpp +++ b/Code/Editor/WelcomeScreen/WelcomeScreenDialog.cpp @@ -34,6 +34,7 @@ // AzQtComponents #include #include +#include // Editor #include "Settings.h" @@ -79,8 +80,11 @@ WelcomeScreenDialog::WelcomeScreenDialog(QWidget* pParent) { projectPreviewPath = ":/WelcomeScreenDialog/DefaultProjectImage.png"; } + ui->activeProjectIcon->setPixmap( - QPixmap(projectPreviewPath).scaled( + AzQtComponents::ScalePixmapForScreenDpi( + QPixmap(projectPreviewPath), + screen(), ui->activeProjectIcon->size(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Utilities/PixmapScaleUtilities.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Utilities/PixmapScaleUtilities.cpp new file mode 100644 index 0000000000..fa32b708d7 --- /dev/null +++ b/Code/Framework/AzQtComponents/AzQtComponents/Utilities/PixmapScaleUtilities.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#include +#include + +#include + +namespace AzQtComponents +{ + QPixmap ScalePixmapForScreenDpi( + QPixmap pixmap, QScreen* screen, QSize size, Qt::AspectRatioMode aspectRatioMode, Qt::TransformationMode transformationMode) + { + qreal screenDpiFactor = QHighDpiScaling::factor(screen); + pixmap.setDevicePixelRatio(screenDpiFactor); + + QPixmap scaledPixmap; + + size.setWidth(aznumeric_cast(aznumeric_cast(size.width()) * screenDpiFactor)); + size.setHeight(aznumeric_cast(aznumeric_cast(size.height()) * screenDpiFactor)); + + scaledPixmap = pixmap.scaled(size, aspectRatioMode, transformationMode); + + return scaledPixmap; + } +} diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Utilities/PixmapScaleUtilities.h b/Code/Framework/AzQtComponents/AzQtComponents/Utilities/PixmapScaleUtilities.h new file mode 100644 index 0000000000..4b083855d5 --- /dev/null +++ b/Code/Framework/AzQtComponents/AzQtComponents/Utilities/PixmapScaleUtilities.h @@ -0,0 +1,19 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#pragma once + +#include + +#include +#include + +namespace AzQtComponents +{ + AZ_QT_COMPONENTS_API QPixmap ScalePixmapForScreenDpi(QPixmap pixmap, QScreen* screen, QSize size, Qt::AspectRatioMode aspectRatioMode, Qt::TransformationMode transformationMode); +}; // namespace AzQtComponents diff --git a/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake b/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake index c214b81405..8219ab04b2 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake +++ b/Code/Framework/AzQtComponents/AzQtComponents/azqtcomponents_files.cmake @@ -276,6 +276,8 @@ set(FILES Utilities/HandleDpiAwareness.cpp Utilities/HandleDpiAwareness.h Utilities/MouseHider.h + Utilities/PixmapScaleUtilities.cpp + Utilities/PixmapScaleUtilities.h Utilities/QtPluginPaths.cpp Utilities/QtPluginPaths.h Utilities/QtWindowUtilities.cpp diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.cpp index f0462532e6..a0da20ebf0 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.cpp @@ -47,9 +47,9 @@ namespace AzToolsFramework return QString(); } - QPixmap EditorEntityUiHandlerBase::GenerateItemIcon(AZ::EntityId /*entityId*/) const + QIcon EditorEntityUiHandlerBase::GenerateItemIcon(AZ::EntityId /*entityId*/) const { - return QPixmap(); + return QIcon(); } bool EditorEntityUiHandlerBase::CanToggleLockVisibility(AZ::EntityId /*entityId*/) const diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.h b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.h index e7008b7abf..c37b099272 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/EditorEntityUi/EditorEntityUiHandlerBase.h @@ -40,7 +40,7 @@ namespace AzToolsFramework //! Returns the item tooltip text to display in the Outliner. virtual QString GenerateItemTooltip(AZ::EntityId entityId) const; //! Returns the item icon pixmap to display in the Outliner. - virtual QPixmap GenerateItemIcon(AZ::EntityId entityId) const; + virtual QIcon GenerateItemIcon(AZ::EntityId entityId) const; //! Returns whether the element's lock and visibility state should be accessible in the Outliner virtual bool CanToggleLockVisibility(AZ::EntityId entityId) const; //! Returns whether the element's name should be editable diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Layer/LayerUiHandler.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Layer/LayerUiHandler.cpp index b0eee96abc..8a001bc04f 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Layer/LayerUiHandler.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Layer/LayerUiHandler.cpp @@ -66,9 +66,9 @@ namespace AzToolsFramework return result; } - QPixmap LayerUiHandler::GenerateItemIcon(AZ::EntityId /*entityId*/) const + QIcon LayerUiHandler::GenerateItemIcon(AZ::EntityId /*entityId*/) const { - return QPixmap(m_layerIconPath); + return QIcon(m_layerIconPath); } void LayerUiHandler::PaintItemBackground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Layer/LayerUiHandler.h b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Layer/LayerUiHandler.h index 56b62832ce..b1af9d694e 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Layer/LayerUiHandler.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Layer/LayerUiHandler.h @@ -24,7 +24,7 @@ namespace AzToolsFramework // EditorEntityUiHandler... QString GenerateItemInfoString(AZ::EntityId entityId) const override; - QPixmap GenerateItemIcon(AZ::EntityId entityId) const override; + QIcon GenerateItemIcon(AZ::EntityId entityId) const override; void PaintItemBackground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override; void PaintDescendantBackground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index, const QModelIndex& descendantIndex) const override; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp index b9180f8ef6..d9f3ff8bb8 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp @@ -280,17 +280,17 @@ namespace AzToolsFramework QVariant EntityOutlinerListModel::GetEntityIcon(const AZ::EntityId& id) const { auto entityUiHandler = m_editorEntityFrameworkInterface->GetHandler(id); - QPixmap pixmap; + QIcon icon; // Retrieve the icon from the handler if (entityUiHandler != nullptr) { - pixmap = entityUiHandler->GenerateItemIcon(id); + icon = entityUiHandler->GenerateItemIcon(id); } - if (!pixmap.isNull()) + if (!icon.isNull()) { - return QIcon(pixmap); + return icon; } // If no icon was returned by the handler, use the default one. @@ -299,7 +299,7 @@ namespace AzToolsFramework if (isEditorOnly) { - return QIcon(QPixmap(QString(":/Icons/Entity_Editor_Only.svg"))); + return QIcon(QString(":/Icons/Entity_Editor_Only.svg")); } AZ::Entity* entity = nullptr; @@ -308,10 +308,10 @@ namespace AzToolsFramework if (!isInitiallyActive) { - return QIcon(QPixmap(QString(":/Icons/Entity_Not_Active.svg"))); + return QIcon(QString(":/Icons/Entity_Not_Active.svg")); } - return QIcon(QPixmap(QString(":/Icons/Entity.svg"))); + return QIcon(QString(":/Icons/Entity.svg")); } QVariant EntityOutlinerListModel::GetEntityTooltip(const AZ::EntityId& id) const diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/LevelRootUiHandler.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/LevelRootUiHandler.cpp index 73a28a3edc..c75f6aa86d 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/LevelRootUiHandler.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/LevelRootUiHandler.cpp @@ -41,9 +41,9 @@ namespace AzToolsFramework } } - QPixmap LevelRootUiHandler::GenerateItemIcon(AZ::EntityId /*entityId*/) const + QIcon LevelRootUiHandler::GenerateItemIcon(AZ::EntityId /*entityId*/) const { - return QPixmap(m_levelRootIconPath); + return QIcon(m_levelRootIconPath); } QString LevelRootUiHandler::GenerateItemInfoString(AZ::EntityId entityId) const diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/LevelRootUiHandler.h b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/LevelRootUiHandler.h index 29bb5a7d49..6eeccfe88d 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/LevelRootUiHandler.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/LevelRootUiHandler.h @@ -29,7 +29,7 @@ namespace AzToolsFramework ~LevelRootUiHandler() override = default; // EditorEntityUiHandler... - QPixmap GenerateItemIcon(AZ::EntityId entityId) const override; + QIcon GenerateItemIcon(AZ::EntityId entityId) const override; QString GenerateItemInfoString(AZ::EntityId entityId) const override; bool CanToggleLockVisibility(AZ::EntityId entityId) const override; bool CanRename(AZ::EntityId entityId) const override; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/PrefabUiHandler.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/PrefabUiHandler.cpp index 1a9632b0e1..fda56b79f1 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/PrefabUiHandler.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/PrefabUiHandler.cpp @@ -81,14 +81,14 @@ namespace AzToolsFramework return tooltip; } - QPixmap PrefabUiHandler::GenerateItemIcon(AZ::EntityId entityId) const + QIcon PrefabUiHandler::GenerateItemIcon(AZ::EntityId entityId) const { if (m_prefabEditInterface->IsOwningPrefabBeingEdited(entityId)) { - return QPixmap(m_prefabEditIconPath); + return QIcon(m_prefabEditIconPath); } - return QPixmap(m_prefabIconPath); + return QIcon(m_prefabIconPath); } void PrefabUiHandler::PaintItemBackground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/PrefabUiHandler.h b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/PrefabUiHandler.h index 0d73fba049..d900fae427 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/PrefabUiHandler.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/PrefabUiHandler.h @@ -31,7 +31,7 @@ namespace AzToolsFramework // EditorEntityUiHandler... QString GenerateItemInfoString(AZ::EntityId entityId) const override; QString GenerateItemTooltip(AZ::EntityId entityId) const override; - QPixmap GenerateItemIcon(AZ::EntityId entityId) const override; + QIcon GenerateItemIcon(AZ::EntityId entityId) const override; void PaintItemBackground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override; void PaintDescendantBackground(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index, const QModelIndex& descendantIndex) const override;