Implement Auto-Type {PICKCHARS}

* Closes #725

Support Auto-Type {PICKCHARS} placeholder. Open a dialog that lets you pick characters of an entry's password by their position. Supports typing {TAB} in between characters to move between fields (if necessary). Also supports using arrow keys to quickly navigate around the choice grid.
This commit is contained in:
Jonathan White
2021-02-13 22:08:29 -05:00
parent 027ff9f2bf
commit 813ab47e29
6 changed files with 335 additions and 0 deletions

View File

@@ -27,6 +27,7 @@
#include "autotype/AutoTypePlatformPlugin.h"
#include "autotype/AutoTypeSelectDialog.h"
#include "autotype/PickcharsDialog.h"
#include "core/Config.h"
#include "core/Database.h"
#include "core/Entry.h"
@@ -564,6 +565,27 @@ AutoType::parseActions(const QString& entrySequence, const Entry* entry, QString
for (const auto& ch : totp) {
actions << QSharedPointer<AutoTypeKey>::create(ch);
}
} else if (placeholder == "pickchars") {
if (error) {
// Ignore this if we are syntax checking
continue;
}
// Show pickchars dialog for entry's password
auto password = entry->resolvePlaceholder(entry->password());
if (!password.isEmpty()) {
PickcharsDialog pickcharsDialog(password);
if (pickcharsDialog.exec() == QDialog::Accepted && !pickcharsDialog.selectedChars().isEmpty()) {
auto chars = pickcharsDialog.selectedChars();
auto iter = chars.begin();
while (iter != chars.end()) {
actions << QSharedPointer<AutoTypeKey>::create(*iter);
++iter;
if (pickcharsDialog.pressTab() && iter != chars.end()) {
actions << QSharedPointer<AutoTypeKey>::create(g_placeholderToKey["tab"]);
}
}
}
}
} else if (placeholder == "beep" || placeholder.startsWith("vkey")
|| placeholder.startsWith("appactivate")) {
// Ignore these commands