Merge pull request #6676 from aws-lumberyard-dev/Atom/mriegger/format
Remove 'INF' from integer widget and replace it with better formatted…
This commit is contained in:
+12
-30
@@ -14,6 +14,7 @@
|
||||
#include <AzToolsFramework/UI/PropertyEditor/PropertyQTConstants.h>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/QtWidgetLimits.h>
|
||||
#include <QtWidgets/QWidget>
|
||||
#include <QLocale>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
@@ -92,25 +93,11 @@ namespace AzToolsFramework
|
||||
{
|
||||
toolTipString += "\n";
|
||||
}
|
||||
toolTipString += "[";
|
||||
if (propertyControl->minimum() <= aznumeric_cast<AZ::s64>(QtWidgetLimits<T>::Min()))
|
||||
{
|
||||
toolTipString += "-" + QObject::tr(PropertyQTConstant_InfinityString);
|
||||
}
|
||||
else
|
||||
{
|
||||
toolTipString += QString::number(propertyControl->minimum());
|
||||
}
|
||||
toolTipString += ", ";
|
||||
if (propertyControl->maximum() >= aznumeric_cast<AZ::s64>(QtWidgetLimits<T>::Max()))
|
||||
{
|
||||
toolTipString += QObject::tr(PropertyQTConstant_InfinityString);
|
||||
}
|
||||
else
|
||||
{
|
||||
toolTipString += QString::number(propertyControl->maximum());
|
||||
}
|
||||
toolTipString += "]";
|
||||
|
||||
const QString minString = QLocale().toString(propertyControl->minimum());
|
||||
const QString maxString = QLocale().toString(propertyControl->maximum());
|
||||
toolTipString += QString("[%1, %2]").arg(minString).arg(maxString);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -128,16 +115,11 @@ namespace AzToolsFramework
|
||||
{
|
||||
toolTipString += "\n";
|
||||
}
|
||||
toolTipString += "[" + QString::number(propertyControl->minimum()) + ", ";
|
||||
if (propertyControl->maximum() >= aznumeric_cast<AZ::s64>(QtWidgetLimits<T>::Max()))
|
||||
{
|
||||
toolTipString += QObject::tr(PropertyQTConstant_InfinityString);
|
||||
}
|
||||
else
|
||||
{
|
||||
toolTipString += QString::number(propertyControl->maximum());
|
||||
}
|
||||
toolTipString += "]";
|
||||
|
||||
const QString minString = QLocale().toString(propertyControl->minimum());
|
||||
const QString maxString = QLocale().toString(propertyControl->maximum());
|
||||
toolTipString += QString("[%1, %2]").arg(minString).arg(maxString);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -196,7 +178,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_WarningOnce("AzToolsFramework", false, "Property %s: 'Min' attribute from property '%s' into widget", debugName);
|
||||
AZ_WarningOnce("AzToolsFramework", false, "Failed to read 'Min' attribute from property '%s' into widget", debugName);
|
||||
}
|
||||
}
|
||||
else if (attrib == AZ::Edit::Attributes::Max)
|
||||
|
||||
@@ -83,18 +83,6 @@ namespace UnitTest
|
||||
widget->setMaximum(widget->maximum() - 1);
|
||||
}
|
||||
|
||||
static std::string GetToolTipStringAtLimits()
|
||||
{
|
||||
if constexpr (std::is_signed<ValueType>::value)
|
||||
{
|
||||
return "[-INF, INF]";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "[0, INF]";
|
||||
}
|
||||
}
|
||||
|
||||
void PropertyCtrlHandlersCreated()
|
||||
{
|
||||
using ::testing::Ne;
|
||||
@@ -125,11 +113,13 @@ namespace UnitTest
|
||||
auto& widget = m_widget;
|
||||
auto& handler = m_handler;
|
||||
QString tooltip;
|
||||
std::string expected;
|
||||
|
||||
// Retrieve the tooltip string for this widget
|
||||
auto success = handler->ModifyTooltip(widget, tooltip);
|
||||
expected = GetToolTipStringAtLimits();
|
||||
|
||||
const QString minString = QLocale().toString(widget->minimum());
|
||||
const QString maxString = QLocale().toString(widget->maximum());
|
||||
const AZStd::string expected = AZStd::string::format("[%s, %s]", minString.toStdString().c_str(), maxString.toStdString().c_str());
|
||||
|
||||
// Expect the operation to be successful and a valid limit tooltip string generated
|
||||
EXPECT_TRUE(success);
|
||||
@@ -142,18 +132,21 @@ namespace UnitTest
|
||||
auto& widget = m_widget;
|
||||
auto& handler = m_handler;
|
||||
QString tooltip;
|
||||
std::stringstream expected;
|
||||
|
||||
// That is not at the extremeties of the type range limit
|
||||
SetWidgetRangeToNonExtremeties(widget);
|
||||
|
||||
// Retrieve the tooltip string for this widget
|
||||
auto success = handler->ModifyTooltip(widget, tooltip);
|
||||
expected << "[" << widget->minimum() << ", " << widget->maximum() << "]";
|
||||
|
||||
const QString minString = QLocale().toString(widget->minimum());
|
||||
const QString maxString = QLocale().toString(widget->maximum());
|
||||
|
||||
const AZStd::string expected = AZStd::string::format("[%s, %s]", minString.toStdString().c_str(), maxString.toStdString().c_str());
|
||||
|
||||
// Expect the operation to be successful and a valid less than limit tooltip string generated
|
||||
EXPECT_TRUE(success);
|
||||
EXPECT_STREQ(tooltip.toStdString().c_str(), expected.str().c_str());
|
||||
EXPECT_STREQ(tooltip.toStdString().c_str(), expected.c_str());
|
||||
}
|
||||
|
||||
void EmitWidgetValueChanged()
|
||||
|
||||
Reference in New Issue
Block a user