switch output map now lists off/on instead of false/true
Dieser Commit ist enthalten in:
Ursprung
d335fa89a9
Commit
af3b491c32
@ -142,6 +142,20 @@ void OutputMapWidget::updateItems(const std::vector<ObjectPtr>& items)
|
||||
else if(p->type() == ValueType::Boolean)
|
||||
{
|
||||
text = p->toBool() ? "true" : "false";
|
||||
|
||||
if(p->hasAttribute(AttributeName::AliasKeys))
|
||||
{
|
||||
const QVariantList aliasKeys = p->getAttribute(AttributeName::AliasKeys, QVariant()).toList();
|
||||
const QVariantList aliasValues = p->getAttribute(AttributeName::AliasValues, QVariant()).toList();
|
||||
|
||||
if(aliasKeys.size() == aliasValues.size()) /*[[likely]]*/
|
||||
{
|
||||
if(int index = aliasKeys.indexOf(p->toBool()); index != -1)
|
||||
{
|
||||
text = Locale::instance->parse(aliasValues[index].toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else /*[[unlikely]]*/
|
||||
{
|
||||
|
||||
@ -23,7 +23,11 @@
|
||||
#include "switchoutputmapitem.hpp"
|
||||
#include "../../../core/method.tpp"
|
||||
|
||||
static constexpr std::array<bool, 2> keyAliasKeys{{false, true}};
|
||||
static const std::array<std::string, 2> keyAliasValues{{"$output_map_item.switch.key:off$", "$output_map_item.switch.key:on$"}};
|
||||
|
||||
SwitchOutputMapItem::SwitchOutputMapItem(Object& map, bool value) :
|
||||
OutputMapItemBase(map, value)
|
||||
{
|
||||
Attributes::addAliases(key, tcb::span<const bool>(keyAliasKeys), tcb::span<const std::string>(keyAliasValues));
|
||||
}
|
||||
|
||||
@ -4826,5 +4826,13 @@
|
||||
{
|
||||
"term": "output_map.switch:key",
|
||||
"definition": "Value"
|
||||
},
|
||||
{
|
||||
"term": "output_map_item.switch.key:off",
|
||||
"definition": "Off"
|
||||
},
|
||||
{
|
||||
"term": "output_map_item.switch.key:on",
|
||||
"definition": "On"
|
||||
}
|
||||
]
|
||||
|
||||
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren