Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show Auto-Type select dialog even if window title is empty #11603

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 21 additions & 30 deletions src/autotype/AutoType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ AutoType::AutoType(QObject* parent, bool test)
#endif
}

connect(this, SIGNAL(autotypeFinished()), SLOT(resetAutoTypeState()));
connect(qApp, SIGNAL(aboutToQuit()), SLOT(unloadPlugin()));
}

Expand Down Expand Up @@ -353,7 +354,6 @@ void AutoType::executeAutoTypeActions(const Entry* entry,
}
}

resetAutoTypeState();
m_inAutoType.unlock();
emit autotypeFinished();
}
Expand Down Expand Up @@ -434,38 +434,33 @@ void AutoType::startGlobalAutoType(const QString& search)
*/
void AutoType::performGlobalAutoType(const QList<QSharedPointer<Database>>& dbList, const QString& search)
{
if (!m_plugin) {
return;
}

if (!m_inGlobalAutoTypeDialog.tryLock()) {
return;
}

if (m_windowTitleForGlobal.isEmpty()) {
m_inGlobalAutoTypeDialog.unlock();
if (!m_plugin || !m_inGlobalAutoTypeDialog.tryLock()) {
return;
}

QList<AutoTypeMatch> matchList;
bool hideExpired = config()->get(Config::AutoTypeHideExpiredEntry).toBool();

for (const auto& db : dbList) {
const QList<Entry*> dbEntries = db->rootGroup()->entriesRecursive();
for (auto entry : dbEntries) {
auto group = entry->group();
if (!group || !group->resolveAutoTypeEnabled() || !entry->autoTypeEnabled()) {
continue;
}
// Generate entry/sequence match list if there is a valid window title
if (!m_windowTitleForGlobal.isEmpty()) {
bool hideExpired = config()->get(Config::AutoTypeHideExpiredEntry).toBool();
for (const auto& db : dbList) {
const QList<Entry*> dbEntries = db->rootGroup()->entriesRecursive();
for (auto entry : dbEntries) {
auto group = entry->group();
if (!group || !group->resolveAutoTypeEnabled() || !entry->autoTypeEnabled()) {
continue;
}

if (hideExpired && entry->isExpired()) {
continue;
}
const QSet<QString> sequences = Tools::asSet(entry->autoTypeSequences(m_windowTitleForGlobal));
for (const auto& sequence : sequences) {
matchList << AutoTypeMatch(entry, sequence);
if (hideExpired && entry->isExpired()) {
continue;
}
const QSet<QString> sequences = Tools::asSet(entry->autoTypeSequences(m_windowTitleForGlobal));
for (const auto& sequence : sequences) {
matchList << AutoTypeMatch(entry, sequence);
}
}
}
} else {
qWarning() << "Auto-Type: Window title was empty from the operating system";
}

// Show the selection dialog if we always ask, have multiple matches, or no matches
Expand Down Expand Up @@ -493,11 +488,9 @@ void AutoType::performGlobalAutoType(const QList<QSharedPointer<Database>>& dbLi
m_windowForGlobal,
virtualMode ? AutoTypeExecutor::Mode::VIRTUAL
: AutoTypeExecutor::Mode::NORMAL);
resetAutoTypeState();
});
connect(selectDialog, &QDialog::rejected, this, [this] {
restoreWindowState();
resetAutoTypeState();
emit autotypeFinished();
});

Expand All @@ -511,10 +504,8 @@ void AutoType::performGlobalAutoType(const QList<QSharedPointer<Database>>& dbLi
} else if (!matchList.isEmpty()) {
// Only one match and not asking, do it!
executeAutoTypeActions(matchList.first().first, matchList.first().second, m_windowForGlobal);
resetAutoTypeState();
} else {
// We should never get here
resetAutoTypeState();
emit autotypeFinished();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/autotype/AutoType.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public slots:
private slots:
void startGlobalAutoType(const QString& search);
void unloadPlugin();
void resetAutoTypeState();

private:
enum WindowState
Expand All @@ -83,7 +84,6 @@ private slots:
WId window = 0,
AutoTypeExecutor::Mode mode = AutoTypeExecutor::Mode::NORMAL);
void restoreWindowState();
void resetAutoTypeState();

static QList<QSharedPointer<AutoTypeAction>>
parseSequence(const QString& entrySequence, const Entry* entry, QString& error, bool syntaxOnly = false);
Expand Down
Loading