Qt/IOWindow: Fix detection of button names containing non-alphabetical characters

The button wouldn't be highlighted in the list, as it would look for something like `Click 1` instead of Click 1.
This commit is contained in:
Techjar
2018-07-16 17:15:37 -04:00
parent 6044165f9d
commit f37813d8b6
3 changed files with 24 additions and 11 deletions

View File

@ -14,7 +14,7 @@ namespace MappingCommon
{
QString GetExpressionForControl(const QString& control_name,
const ciface::Core::DeviceQualifier& control_device,
const ciface::Core::DeviceQualifier& default_device)
const ciface::Core::DeviceQualifier& default_device, Quote quote)
{
QString expr;
@ -28,22 +28,26 @@ QString GetExpressionForControl(const QString& control_name,
// append the control name
expr += control_name;
QRegExp reg(QStringLiteral("[a-zA-Z]+"));
if (!reg.exactMatch(expr))
expr = QStringLiteral("`%1`").arg(expr);
if (quote == Quote::On)
{
QRegExp reg(QStringLiteral("[a-zA-Z]+"));
if (!reg.exactMatch(expr))
expr = QStringLiteral("`%1`").arg(expr);
}
return expr;
}
QString DetectExpression(ControlReference* reference, ciface::Core::Device* device,
const ciface::Core::DeviceQualifier& default_device)
const ciface::Core::DeviceQualifier& default_device, Quote quote)
{
ciface::Core::Device::Control* const ctrl = reference->Detect(5000, device);
if (ctrl)
{
return MappingCommon::GetExpressionForControl(QString::fromStdString(ctrl->GetName()),
default_device, default_device);
default_device, default_device, quote);
}
return QStringLiteral("");
}
}
} // namespace MappingCommon