Add Autotype Entry-Attributes, Fix Group default sequence (#107)

This commit is contained in:
TheZ3ro 2016-11-25 18:26:59 +01:00 committed by Jonathan White
parent 0dfd2003f9
commit 405b82588b
7 changed files with 114 additions and 49 deletions

View file

@ -356,18 +356,18 @@ bool AutoType::parseActions(const QString& sequence, const Entry* entry, QList<A
QList<AutoTypeAction*> AutoType::createActionFromTemplate(const QString& tmpl, const Entry* entry)
{
QString tmplName = tmpl.toLower();
QString tmplName = tmpl;
int num = -1;
QList<AutoTypeAction*> list;
QRegExp delayRegEx("delay=(\\d+)", Qt::CaseSensitive, QRegExp::RegExp2);
QRegExp delayRegEx("delay=(\\d+)", Qt::CaseInsensitive, QRegExp::RegExp2);
if (delayRegEx.exactMatch(tmplName)) {
num = delayRegEx.cap(1).toInt();
m_autoTypeDelay = std::max(0, std::min(num, 10000));
return list;
}
QRegExp repeatRegEx("(.+) (\\d+)", Qt::CaseSensitive, QRegExp::RegExp2);
QRegExp repeatRegEx("(.+) (\\d+)", Qt::CaseInsensitive, QRegExp::RegExp2);
if (repeatRegEx.exactMatch(tmplName)) {
tmplName = repeatRegEx.cap(1);
num = repeatRegEx.cap(2).toInt();
@ -376,7 +376,7 @@ QList<AutoTypeAction*> AutoType::createActionFromTemplate(const QString& tmpl, c
return list;
}
// some safety checks
else if (tmplName == "delay") {
else if (tmplName.compare("delay",Qt::CaseInsensitive)==0) {
if (num > 10000) {
return list;
}
@ -386,98 +386,103 @@ QList<AutoTypeAction*> AutoType::createActionFromTemplate(const QString& tmpl, c
}
}
if (tmplName == "tab") {
if (tmplName.compare("tab",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeKey(Qt::Key_Tab));
}
else if (tmplName == "enter") {
else if (tmplName.compare("enter",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeKey(Qt::Key_Enter));
}
else if (tmplName == "up") {
else if (tmplName.compare("up",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeKey(Qt::Key_Up));
}
else if (tmplName == "down") {
else if (tmplName.compare("down",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeKey(Qt::Key_Down));
}
else if (tmplName == "left") {
else if (tmplName.compare("left",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeKey(Qt::Key_Left));
}
else if (tmplName == "right") {
else if (tmplName.compare("right",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeKey(Qt::Key_Right));
}
else if (tmplName == "insert" || tmplName == "ins") {
else if (tmplName.compare("insert",Qt::CaseInsensitive)==0 ||
tmplName.compare("ins",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeKey(Qt::Key_Insert));
}
else if (tmplName == "delete" || tmplName == "del") {
else if (tmplName.compare("delete",Qt::CaseInsensitive)==0 ||
tmplName.compare("del",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeKey(Qt::Key_Delete));
}
else if (tmplName == "home") {
else if (tmplName.compare("home",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeKey(Qt::Key_Home));
}
else if (tmplName == "end") {
else if (tmplName.compare("end",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeKey(Qt::Key_End));
}
else if (tmplName == "pgup") {
else if (tmplName.compare("pgup",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeKey(Qt::Key_PageUp));
}
else if (tmplName == "pgdown") {
else if (tmplName.compare("pgdown",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeKey(Qt::Key_PageDown));
}
else if (tmplName == "backspace" || tmplName == "bs" || tmplName == "bksp") {
else if (tmplName.compare("backspace",Qt::CaseInsensitive)==0 ||
tmplName.compare("bs",Qt::CaseInsensitive)==0 ||
tmplName.compare("bksp",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeKey(Qt::Key_Backspace));
}
else if (tmplName == "break") {
else if (tmplName.compare("break",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeKey(Qt::Key_Pause));
}
else if (tmplName == "capslock") {
else if (tmplName.compare("capslock",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeKey(Qt::Key_CapsLock));
}
else if (tmplName == "esc") {
else if (tmplName.compare("esc",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeKey(Qt::Key_Escape));
}
else if (tmplName == "help") {
else if (tmplName.compare("help",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeKey(Qt::Key_Help));
}
else if (tmplName == "numlock") {
else if (tmplName.compare("numlock",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeKey(Qt::Key_NumLock));
}
else if (tmplName == "ptrsc") {
else if (tmplName.compare("ptrsc",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeKey(Qt::Key_Print));
}
else if (tmplName == "scrolllock") {
else if (tmplName.compare("scrolllock",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeKey(Qt::Key_ScrollLock));
}
// Qt doesn't know about keypad keys so use the normal ones instead
else if (tmplName == "add" || tmplName == "+") {
else if (tmplName.compare("add",Qt::CaseInsensitive)==0 ||
tmplName.compare("+",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeChar('+'));
}
else if (tmplName == "subtract") {
else if (tmplName.compare("subtract",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeChar('-'));
}
else if (tmplName == "multiply") {
else if (tmplName.compare("multiply",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeChar('*'));
}
else if (tmplName == "divide") {
else if (tmplName.compare("divide",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeChar('/'));
}
else if (tmplName == "^") {
else if (tmplName.compare("^",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeChar('^'));
}
else if (tmplName == "%") {
else if (tmplName.compare("%",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeChar('%'));
}
else if (tmplName == "~") {
else if (tmplName.compare("~",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeChar('~'));
}
else if (tmplName == "(") {
else if (tmplName.compare("(",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeChar('('));
}
else if (tmplName == ")") {
else if (tmplName.compare(")",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeChar(')'));
}
else if (tmplName == "{") {
else if (tmplName.compare("{",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeChar('{'));
}
else if (tmplName == "}") {
else if (tmplName.compare("}",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeChar('}'));
}
else {
@ -499,10 +504,10 @@ QList<AutoTypeAction*> AutoType::createActionFromTemplate(const QString& tmpl, c
}
if (tmplName == "delay" && num > 0) {
if (tmplName.compare("delay",Qt::CaseInsensitive)==0 && num > 0) {
list.append(new AutoTypeDelay(num));
}
else if (tmplName == "clearfield") {
else if (tmplName.compare("clearfield",Qt::CaseInsensitive)==0) {
list.append(new AutoTypeClearField());
}
@ -510,9 +515,8 @@ QList<AutoTypeAction*> AutoType::createActionFromTemplate(const QString& tmpl, c
return list;
}
const QString placeholder = QString("{%1}").arg(tmplName);
const QString resolved = entry->resolvePlaceholders(placeholder);
const QString resolved = entry->resolvePlaceholder(placeholder);
if (placeholder != resolved) {
for (const QChar& ch : resolved) {
if (ch == '\n') {