From 5279f05403c1ea6495a49cd67ef1d359324b71b7 Mon Sep 17 00:00:00 2001 From: John Jones-Steele Date: Thu, 24 Jun 2021 11:59:44 +0100 Subject: [PATCH] Entity Outliner - Sort Order options don't show current selection Also fixes the menus that have checkmark and icon --- .../AzQtComponents/Components/Style.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/Style.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Components/Style.cpp index 47c0e66ff0..c94eb59ca6 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Components/Style.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/Style.cpp @@ -514,6 +514,20 @@ namespace AzQtComponents } } } + // Implement checkmark with icon in menu. + QStyleOptionMenuItem myOpt = *qstyleoption_cast(option); + bool checkable = myOpt.checkType != QStyleOptionMenuItem::NotCheckable; + bool checked = checkable ? myOpt.checked : false; + + if (!myOpt.icon.isNull() && checked) + { + const int iconSize{ 18 }; + int topPadding{ AZStd::max( 0 , (myOpt.rect.height() - iconSize) / 2) - 1}; + + QProxyStyle::drawControl(element, &myOpt, painter, widget); + myOpt.rect.adjust(0, topPadding, iconSize - myOpt.rect.width(), iconSize - myOpt.rect.height()); + return drawPrimitive(PE_IndicatorMenuCheckMark, &myOpt, painter, widget); + } } break; }