Compare window title with entry URLs during autotype matching. (#556)

* Compare window title with entry URLs during autotype matching.

* Adapted option label to reflect that both entry title and URL are used for auto-type window matching.
This commit is contained in:
Jens Rutschmann 2017-05-14 01:02:54 +02:00 committed by louib
parent 03f00c5526
commit 9a59a124aa
5 changed files with 56 additions and 3 deletions

View file

@ -574,8 +574,9 @@ QString AutoType::autoTypeSequence(const Entry* entry, const QString& windowTitl
}
}
if (!match && config()->get("AutoTypeEntryTitleMatch").toBool() && !entry->resolvePlaceholder(entry->title()).isEmpty()
&& windowTitle.contains(entry->resolvePlaceholder(entry->title()), Qt::CaseInsensitive)) {
if (!match && config()->get("AutoTypeEntryTitleMatch").toBool()
&& (windowMatchesTitle(windowTitle, entry->resolvePlaceholder(entry->title()))
|| windowMatchesUrl(windowTitle, entry->resolvePlaceholder(entry->url())))) {
sequence = entry->defaultAutoTypeSequence();
match = true;
}
@ -631,3 +632,22 @@ bool AutoType::windowMatches(const QString& windowTitle, const QString& windowPa
return WildcardMatcher(windowTitle).match(windowPattern);
}
}
bool AutoType::windowMatchesTitle(const QString& windowTitle, const QString& resolvedTitle)
{
return !resolvedTitle.isEmpty() && windowTitle.contains(resolvedTitle, Qt::CaseInsensitive);
}
bool AutoType::windowMatchesUrl(const QString& windowTitle, const QString& resolvedUrl)
{
if (!resolvedUrl.isEmpty() && windowTitle.contains(resolvedUrl, Qt::CaseInsensitive)) {
return true;
}
QUrl url(resolvedUrl);
if (url.isValid() && !url.host().isEmpty()) {
return windowTitle.contains(url.host(), Qt::CaseInsensitive);
}
return false;
}

View file

@ -66,6 +66,8 @@ private:
bool parseActions(const QString& sequence, const Entry* entry, QList<AutoTypeAction*>& actions);
QList<AutoTypeAction*> createActionFromTemplate(const QString& tmpl, const Entry* entry);
QString autoTypeSequence(const Entry* entry, const QString& windowTitle = QString());
bool windowMatchesTitle(const QString& windowTitle, const QString& resolvedTitle);
bool windowMatchesUrl(const QString& windowTitle, const QString& resolvedUrl);
bool windowMatches(const QString& windowTitle, const QString& windowPattern);
bool m_inAutoType;