Fix wildcard window title matching in Auto-Type

* Fixes #6413
This commit is contained in:
Jonathan White 2021-12-30 09:19:07 -05:00
parent 4a21cee98c
commit 7f92504a2d
7 changed files with 85 additions and 23 deletions

View file

@ -281,7 +281,7 @@ QString Entry::effectiveAutoTypeSequence() const
}
/**
* Retrive the autotype sequences matches for a given windowTitle
* Retrieve the Auto-Type sequences matches for a given windowTitle
* This returns a list with priority ordering. If you don't want duplicates call .toSet() on it.
*/
QList<QString> Entry::autoTypeSequences(const QString& windowTitle) const
@ -295,13 +295,14 @@ QList<QString> Entry::autoTypeSequences(const QString& windowTitle) const
auto windowMatches = [&](const QString& pattern) {
// Regex searching
if (pattern.startsWith("//") && pattern.endsWith("//") && pattern.size() >= 4) {
QRegExp regExp(pattern.mid(2, pattern.size() - 4), Qt::CaseInsensitive, QRegExp::RegExp2);
return (regExp.indexIn(windowTitle) != -1);
QRegularExpression regExp(pattern.mid(2, pattern.size() - 4), QRegularExpression::CaseInsensitiveOption);
return regExp.match(windowTitle).hasMatch();
}
// Wildcard searching
auto regex = Tools::convertToRegex(pattern, true, false, false);
return windowTitle.contains(regex);
const auto regExp = Tools::convertToRegex(
pattern, Tools::RegexConvertOpts::EXACT_MATCH | Tools::RegexConvertOpts::WILDCARD_UNLIMITED_MATCH);
return regExp.match(windowTitle).hasMatch();
};
auto windowMatchesTitle = [&](const QString& entryTitle) {