mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-22 13:02:10 -04:00
fix codestyle
This commit is contained in:
parent
a02a49a184
commit
3d5ff723e9
2 changed files with 104 additions and 160 deletions
|
@ -20,8 +20,8 @@
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QPluginLoader>
|
#include <QPluginLoader>
|
||||||
#include <iostream>
|
|
||||||
#include <QtWidgets/QErrorMessage>
|
#include <QtWidgets/QErrorMessage>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include "config-keepassx.h"
|
#include "config-keepassx.h"
|
||||||
|
|
||||||
|
@ -56,8 +56,7 @@ AutoType::AutoType(QObject* parent, bool test)
|
||||||
QString pluginName = "keepassx-autotype-";
|
QString pluginName = "keepassx-autotype-";
|
||||||
if (!test) {
|
if (!test) {
|
||||||
pluginName += QApplication::platformName();
|
pluginName += QApplication::platformName();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
pluginName += "test";
|
pluginName += "test";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,8 +92,7 @@ void AutoType::loadPlugin(const QString& pluginPath)
|
||||||
if (m_plugin->isAvailable()) {
|
if (m_plugin->isAvailable()) {
|
||||||
m_executor = m_plugin->createExecutor();
|
m_executor = m_plugin->createExecutor();
|
||||||
connect(pluginInstance, SIGNAL(globalShortcutTriggered()), SIGNAL(globalShortcutTriggered()));
|
connect(pluginInstance, SIGNAL(globalShortcutTriggered()), SIGNAL(globalShortcutTriggered()));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
unloadPlugin();
|
unloadPlugin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,8 +138,7 @@ void AutoType::_performAutoType(const Entry* entry, QWidget* hideWindow, const Q
|
||||||
QString sequence;
|
QString sequence;
|
||||||
if (customSequence.isEmpty()) {
|
if (customSequence.isEmpty()) {
|
||||||
sequence = autoTypeSequence(entry);
|
sequence = autoTypeSequence(entry);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
sequence = customSequence;
|
sequence = customSequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,16 +220,14 @@ void AutoType::performGlobalAutoType(const QList<Database*>& dbList)
|
||||||
message.append("\n\n");
|
message.append("\n\n");
|
||||||
message.append(windowTitle);
|
message.append(windowTitle);
|
||||||
MessageBox::information(nullptr, tr("Auto-Type - KeePassXC"), message);
|
MessageBox::information(nullptr, tr("Auto-Type - KeePassXC"), message);
|
||||||
}
|
} else if ((entryList.size() == 1) && !config()->get("security/autotypeask").toBool()) {
|
||||||
else if ((entryList.size() == 1) && !config()->get("security/autotypeask").toBool()) {
|
|
||||||
m_inAutoType = false;
|
m_inAutoType = false;
|
||||||
performAutoType(entryList.first(), nullptr, sequenceHash[entryList.first()]);
|
performAutoType(entryList.first(), nullptr, sequenceHash[entryList.first()]);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
m_windowFromGlobal = m_plugin->activeWindow();
|
m_windowFromGlobal = m_plugin->activeWindow();
|
||||||
AutoTypeSelectDialog* selectDialog = new AutoTypeSelectDialog();
|
AutoTypeSelectDialog* selectDialog = new AutoTypeSelectDialog();
|
||||||
connect(selectDialog, SIGNAL(entryActivated(Entry*,QString)),
|
connect(
|
||||||
SLOT(performAutoTypeFromGlobal(Entry*,QString)));
|
selectDialog, SIGNAL(entryActivated(Entry*, QString)), SLOT(performAutoTypeFromGlobal(Entry*, QString)));
|
||||||
connect(selectDialog, SIGNAL(rejected()), SLOT(resetInAutoType()));
|
connect(selectDialog, SIGNAL(rejected()), SLOT(resetInAutoType()));
|
||||||
selectDialog->setEntries(entryList, sequenceHash);
|
selectDialog->setEntries(entryList, sequenceHash);
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
|
@ -301,12 +296,10 @@ bool AutoType::registerGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifie
|
||||||
m_currentGlobalKey = key;
|
m_currentGlobalKey = key;
|
||||||
m_currentGlobalModifiers = modifiers;
|
m_currentGlobalModifiers = modifiers;
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -333,33 +326,28 @@ bool AutoType::parseActions(const QString& sequence, const Entry* entry, QList<A
|
||||||
bool inTmpl = false;
|
bool inTmpl = false;
|
||||||
m_autoTypeDelay = config()->get("AutoTypeDelay").toInt();
|
m_autoTypeDelay = config()->get("AutoTypeDelay").toInt();
|
||||||
|
|
||||||
for (const QChar &ch : sequence) {
|
for (const QChar& ch : sequence) {
|
||||||
if (inTmpl) {
|
if (inTmpl) {
|
||||||
if (ch == '{') {
|
if (ch == '{') {
|
||||||
qWarning("Syntax error in auto-type sequence.");
|
qWarning("Syntax error in auto-type sequence.");
|
||||||
return false;
|
return false;
|
||||||
}
|
} else if (ch == '}') {
|
||||||
else if (ch == '}') {
|
QList<AutoTypeAction*> autoType = createActionFromTemplate(tmpl, entry);
|
||||||
QList<AutoTypeAction *> autoType = createActionFromTemplate(tmpl, entry);
|
|
||||||
if (autoType.isEmpty()) {
|
if (autoType.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
actions.append(autoType);
|
actions.append(autoType);
|
||||||
inTmpl = false;
|
inTmpl = false;
|
||||||
tmpl.clear();
|
tmpl.clear();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
tmpl += ch;
|
tmpl += ch;
|
||||||
}
|
}
|
||||||
}
|
} else if (ch == '{') {
|
||||||
else if (ch == '{') {
|
|
||||||
inTmpl = true;
|
inTmpl = true;
|
||||||
}
|
} else if (ch == '}') {
|
||||||
else if (ch == '}') {
|
|
||||||
qWarning("Syntax error in auto-type sequence.");
|
qWarning("Syntax error in auto-type sequence.");
|
||||||
return false;
|
return false;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
actions.append(new AutoTypeChar(ch));
|
actions.append(new AutoTypeChar(ch));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -402,104 +390,72 @@ QList<AutoTypeAction*> AutoType::createActionFromTemplate(const QString& tmpl, c
|
||||||
|
|
||||||
if (tmplName.compare("tab", Qt::CaseInsensitive) == 0) {
|
if (tmplName.compare("tab", Qt::CaseInsensitive) == 0) {
|
||||||
list.append(new AutoTypeKey(Qt::Key_Tab));
|
list.append(new AutoTypeKey(Qt::Key_Tab));
|
||||||
}
|
} else if (tmplName.compare("enter", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("enter", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeKey(Qt::Key_Enter));
|
list.append(new AutoTypeKey(Qt::Key_Enter));
|
||||||
}
|
} else if (tmplName.compare("space", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("space", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeKey(Qt::Key_Space));
|
list.append(new AutoTypeKey(Qt::Key_Space));
|
||||||
}
|
} else if (tmplName.compare("up", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("up", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeKey(Qt::Key_Up));
|
list.append(new AutoTypeKey(Qt::Key_Up));
|
||||||
}
|
} else if (tmplName.compare("down", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("down", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeKey(Qt::Key_Down));
|
list.append(new AutoTypeKey(Qt::Key_Down));
|
||||||
}
|
} else if (tmplName.compare("left", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("left", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeKey(Qt::Key_Left));
|
list.append(new AutoTypeKey(Qt::Key_Left));
|
||||||
}
|
} else if (tmplName.compare("right", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("right", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeKey(Qt::Key_Right));
|
list.append(new AutoTypeKey(Qt::Key_Right));
|
||||||
}
|
} else if (tmplName.compare("insert", Qt::CaseInsensitive) == 0 ||
|
||||||
else if (tmplName.compare("insert", Qt::CaseInsensitive) == 0 ||
|
tmplName.compare("ins", Qt::CaseInsensitive) == 0) {
|
||||||
tmplName.compare("ins", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeKey(Qt::Key_Insert));
|
list.append(new AutoTypeKey(Qt::Key_Insert));
|
||||||
}
|
} else if (tmplName.compare("delete", Qt::CaseInsensitive) == 0 ||
|
||||||
else if (tmplName.compare("delete", Qt::CaseInsensitive) == 0 ||
|
tmplName.compare("del", Qt::CaseInsensitive) == 0) {
|
||||||
tmplName.compare("del", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeKey(Qt::Key_Delete));
|
list.append(new AutoTypeKey(Qt::Key_Delete));
|
||||||
}
|
} else if (tmplName.compare("home", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("home", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeKey(Qt::Key_Home));
|
list.append(new AutoTypeKey(Qt::Key_Home));
|
||||||
}
|
} else if (tmplName.compare("end", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("end", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeKey(Qt::Key_End));
|
list.append(new AutoTypeKey(Qt::Key_End));
|
||||||
}
|
} else if (tmplName.compare("pgup", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("pgup", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeKey(Qt::Key_PageUp));
|
list.append(new AutoTypeKey(Qt::Key_PageUp));
|
||||||
}
|
} else if (tmplName.compare("pgdown", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("pgdown", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeKey(Qt::Key_PageDown));
|
list.append(new AutoTypeKey(Qt::Key_PageDown));
|
||||||
}
|
} else if (tmplName.compare("backspace", Qt::CaseInsensitive) == 0 ||
|
||||||
else if (tmplName.compare("backspace", Qt::CaseInsensitive) == 0 ||
|
tmplName.compare("bs", Qt::CaseInsensitive) == 0 || tmplName.compare("bksp", Qt::CaseInsensitive) == 0) {
|
||||||
tmplName.compare("bs", Qt::CaseInsensitive) == 0 ||
|
|
||||||
tmplName.compare("bksp", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeKey(Qt::Key_Backspace));
|
list.append(new AutoTypeKey(Qt::Key_Backspace));
|
||||||
}
|
} else if (tmplName.compare("break", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("break", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeKey(Qt::Key_Pause));
|
list.append(new AutoTypeKey(Qt::Key_Pause));
|
||||||
}
|
} else if (tmplName.compare("capslock", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("capslock", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeKey(Qt::Key_CapsLock));
|
list.append(new AutoTypeKey(Qt::Key_CapsLock));
|
||||||
}
|
} else if (tmplName.compare("esc", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("esc", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeKey(Qt::Key_Escape));
|
list.append(new AutoTypeKey(Qt::Key_Escape));
|
||||||
}
|
} else if (tmplName.compare("help", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("help", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeKey(Qt::Key_Help));
|
list.append(new AutoTypeKey(Qt::Key_Help));
|
||||||
}
|
} else if (tmplName.compare("numlock", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("numlock", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeKey(Qt::Key_NumLock));
|
list.append(new AutoTypeKey(Qt::Key_NumLock));
|
||||||
}
|
} else if (tmplName.compare("ptrsc", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("ptrsc", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeKey(Qt::Key_Print));
|
list.append(new AutoTypeKey(Qt::Key_Print));
|
||||||
}
|
} else if (tmplName.compare("scrolllock", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("scrolllock", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeKey(Qt::Key_ScrollLock));
|
list.append(new AutoTypeKey(Qt::Key_ScrollLock));
|
||||||
}
|
}
|
||||||
// Qt doesn't know about keypad keys so use the normal ones instead
|
// Qt doesn't know about keypad keys so use the normal ones instead
|
||||||
else if (tmplName.compare("add", Qt::CaseInsensitive) == 0 ||
|
else if (tmplName.compare("add", Qt::CaseInsensitive) == 0 || tmplName.compare("+", Qt::CaseInsensitive) == 0) {
|
||||||
tmplName.compare("+", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeChar('+'));
|
list.append(new AutoTypeChar('+'));
|
||||||
}
|
} else if (tmplName.compare("subtract", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("subtract", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeChar('-'));
|
list.append(new AutoTypeChar('-'));
|
||||||
}
|
} else if (tmplName.compare("multiply", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("multiply", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeChar('*'));
|
list.append(new AutoTypeChar('*'));
|
||||||
}
|
} else if (tmplName.compare("divide", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("divide", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeChar('/'));
|
list.append(new AutoTypeChar('/'));
|
||||||
}
|
} else if (tmplName.compare("^", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("^", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeChar('^'));
|
list.append(new AutoTypeChar('^'));
|
||||||
}
|
} else if (tmplName.compare("%", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("%", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeChar('%'));
|
list.append(new AutoTypeChar('%'));
|
||||||
}
|
} else if (tmplName.compare("~", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("~", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeChar('~'));
|
list.append(new AutoTypeChar('~'));
|
||||||
}
|
} else if (tmplName.compare("(", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("(", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeChar('('));
|
list.append(new AutoTypeChar('('));
|
||||||
}
|
} else if (tmplName.compare(")", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare(")", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeChar(')'));
|
list.append(new AutoTypeChar(')'));
|
||||||
}
|
} else if (tmplName.compare("leftbrace", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("leftbrace", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeChar('{'));
|
list.append(new AutoTypeChar('{'));
|
||||||
}
|
} else if (tmplName.compare("rightbrace", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("rightbrace", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeChar('}'));
|
list.append(new AutoTypeChar('}'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,14 +476,11 @@ QList<AutoTypeAction*> AutoType::createActionFromTemplate(const QString& tmpl, c
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (tmplName.compare("delay", Qt::CaseInsensitive) == 0 && num > 0) {
|
if (tmplName.compare("delay", Qt::CaseInsensitive) == 0 && num > 0) {
|
||||||
list.append(new AutoTypeDelay(num));
|
list.append(new AutoTypeDelay(num));
|
||||||
}
|
} else if (tmplName.compare("clearfield", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("clearfield", Qt::CaseInsensitive) == 0) {
|
|
||||||
list.append(new AutoTypeClearField());
|
list.append(new AutoTypeClearField());
|
||||||
}
|
} else if (tmplName.compare("totp", Qt::CaseInsensitive) == 0) {
|
||||||
else if (tmplName.compare("totp", Qt::CaseInsensitive) == 0) {
|
|
||||||
QString totp = entry->totp();
|
QString totp = entry->totp();
|
||||||
if (!totp.isEmpty()) {
|
if (!totp.isEmpty()) {
|
||||||
for (const QChar& ch : totp) {
|
for (const QChar& ch : totp) {
|
||||||
|
@ -546,11 +499,9 @@ QList<AutoTypeAction*> AutoType::createActionFromTemplate(const QString& tmpl, c
|
||||||
for (const QChar& ch : resolved) {
|
for (const QChar& ch : resolved) {
|
||||||
if (ch == '\n') {
|
if (ch == '\n') {
|
||||||
list.append(new AutoTypeKey(Qt::Key_Enter));
|
list.append(new AutoTypeKey(Qt::Key_Enter));
|
||||||
}
|
} else if (ch == '\t') {
|
||||||
else if (ch == '\t') {
|
|
||||||
list.append(new AutoTypeKey(Qt::Key_Tab));
|
list.append(new AutoTypeKey(Qt::Key_Tab));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
list.append(new AutoTypeChar(ch));
|
list.append(new AutoTypeChar(ch));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -575,8 +526,7 @@ QString AutoType::autoTypeSequence(const Entry* entry, const QString& windowTitl
|
||||||
if (windowMatches(windowTitle, window)) {
|
if (windowMatches(windowTitle, window)) {
|
||||||
if (!assoc.sequence.isEmpty()) {
|
if (!assoc.sequence.isEmpty()) {
|
||||||
sequence = assoc.sequence;
|
sequence = assoc.sequence;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
sequence = entry->defaultAutoTypeSequence();
|
sequence = entry->defaultAutoTypeSequence();
|
||||||
}
|
}
|
||||||
match = true;
|
match = true;
|
||||||
|
@ -584,14 +534,14 @@ QString AutoType::autoTypeSequence(const Entry* entry, const QString& windowTitl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!match && config()->get("AutoTypeEntryTitleMatch").toBool()
|
if (!match && config()->get("AutoTypeEntryTitleMatch").toBool() &&
|
||||||
&& windowMatchesTitle(windowTitle, entry->resolvePlaceholder(entry->title()))) {
|
windowMatchesTitle(windowTitle, entry->resolvePlaceholder(entry->title()))) {
|
||||||
sequence = entry->defaultAutoTypeSequence();
|
sequence = entry->defaultAutoTypeSequence();
|
||||||
match = true;
|
match = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!match && config()->get("AutoTypeEntryURLMatch").toBool()
|
if (!match && config()->get("AutoTypeEntryURLMatch").toBool() &&
|
||||||
&& windowMatchesUrl(windowTitle, entry->resolvePlaceholder(entry->url()))) {
|
windowMatchesUrl(windowTitle, entry->resolvePlaceholder(entry->url()))) {
|
||||||
sequence = entry->defaultAutoTypeSequence();
|
sequence = entry->defaultAutoTypeSequence();
|
||||||
match = true;
|
match = true;
|
||||||
}
|
}
|
||||||
|
@ -599,18 +549,16 @@ QString AutoType::autoTypeSequence(const Entry* entry, const QString& windowTitl
|
||||||
if (!match) {
|
if (!match) {
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
sequence = entry->defaultAutoTypeSequence();
|
sequence = entry->defaultAutoTypeSequence();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Group *group = entry->group();
|
const Group* group = entry->group();
|
||||||
do {
|
do {
|
||||||
if (!enableSet) {
|
if (!enableSet) {
|
||||||
if (group->autoTypeEnabled() == Group::Disable) {
|
if (group->autoTypeEnabled() == Group::Disable) {
|
||||||
return QString();
|
return QString();
|
||||||
}
|
} else if (group->autoTypeEnabled() == Group::Enable) {
|
||||||
else if (group->autoTypeEnabled() == Group::Enable) {
|
|
||||||
enableSet = true;
|
enableSet = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -622,15 +570,13 @@ QString AutoType::autoTypeSequence(const Entry* entry, const QString& windowTitl
|
||||||
group = group->parentGroup();
|
group = group->parentGroup();
|
||||||
} while (group && (!enableSet || sequence.isEmpty()));
|
} while (group && (!enableSet || sequence.isEmpty()));
|
||||||
|
|
||||||
if (sequence.isEmpty() && (!entry->resolvePlaceholder(entry->username()).isEmpty()
|
if (sequence.isEmpty() && (!entry->resolvePlaceholder(entry->username()).isEmpty() ||
|
||||||
|| !entry->resolvePlaceholder(entry->password()).isEmpty())) {
|
!entry->resolvePlaceholder(entry->password()).isEmpty())) {
|
||||||
if (entry->resolvePlaceholder(entry->username()).isEmpty()) {
|
if (entry->resolvePlaceholder(entry->username()).isEmpty()) {
|
||||||
sequence = "{PASSWORD}{ENTER}";
|
sequence = "{PASSWORD}{ENTER}";
|
||||||
}
|
} else if (entry->resolvePlaceholder(entry->password()).isEmpty()) {
|
||||||
else if (entry->resolvePlaceholder(entry->password()).isEmpty()) {
|
|
||||||
sequence = "{USERNAME}{ENTER}";
|
sequence = "{USERNAME}{ENTER}";
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
sequence = "{USERNAME}{TAB}{PASSWORD}{ENTER}";
|
sequence = "{USERNAME}{TAB}{PASSWORD}{ENTER}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -643,8 +589,7 @@ bool AutoType::windowMatches(const QString& windowTitle, const QString& windowPa
|
||||||
if (windowPattern.startsWith("//") && windowPattern.endsWith("//") && windowPattern.size() >= 4) {
|
if (windowPattern.startsWith("//") && windowPattern.endsWith("//") && windowPattern.size() >= 4) {
|
||||||
QRegExp regExp(windowPattern.mid(2, windowPattern.size() - 4), Qt::CaseInsensitive, QRegExp::RegExp2);
|
QRegExp regExp(windowPattern.mid(2, windowPattern.size() - 4), Qt::CaseInsensitive, QRegExp::RegExp2);
|
||||||
return (regExp.indexIn(windowTitle) != -1);
|
return (regExp.indexIn(windowTitle) != -1);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return WildcardMatcher(windowTitle).match(windowPattern);
|
return WildcardMatcher(windowTitle).match(windowPattern);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -668,11 +613,11 @@ bool AutoType::windowMatchesUrl(const QString& windowTitle, const QString& resol
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AutoType::checkSyntax(const QString &string)
|
bool AutoType::checkSyntax(const QString& string)
|
||||||
{
|
{
|
||||||
//checks things like {word 23}{F1 23}{~ 23}{% 23}{^}{F12}{(}{) 23}{[}{[}{]}{Delay=23}{+}{-}~+%@fixedstring
|
// checks things like {word 23}{F1 23}{~ 23}{% 23}{^}{F12}{(}{) 23}{[}{[}{]}{Delay=23}{+}{-}~+%@fixedstring
|
||||||
QString allowRepetition = "(\\s\\d*){0,1}";
|
QString allowRepetition = "(\\s\\d*){0,1}";
|
||||||
QString normalCommands = "[A-Z:]*" + allowRepetition; //the ":" allows custom commands
|
QString normalCommands = "[A-Z:]*" + allowRepetition; // the ":" allows custom commands
|
||||||
QString specialLiterals = "[\\^\\%\\(\\)~\\{\\}\\[\\]\\+-]" + allowRepetition;
|
QString specialLiterals = "[\\^\\%\\(\\)~\\{\\}\\[\\]\\+-]" + allowRepetition;
|
||||||
QString functionKeys = "(F[1-9]" + allowRepetition + "|F1[0-2])" + allowRepetition;
|
QString functionKeys = "(F[1-9]" + allowRepetition + "|F1[0-2])" + allowRepetition;
|
||||||
QString numpad = "NUMPAD\\d" + allowRepetition;
|
QString numpad = "NUMPAD\\d" + allowRepetition;
|
||||||
|
@ -680,63 +625,57 @@ bool AutoType::checkSyntax(const QString &string)
|
||||||
QString beep = "BEEP\\s\\d*\\s\\d*";
|
QString beep = "BEEP\\s\\d*\\s\\d*";
|
||||||
QString vkey = "VKEY(-[EN]X){0,1}" + allowRepetition;
|
QString vkey = "VKEY(-[EN]X){0,1}" + allowRepetition;
|
||||||
|
|
||||||
//these arent in parenthesis
|
// these arent in parenthesis
|
||||||
QString shortcutKeys = "[\\^\\%~\\+@]";
|
QString shortcutKeys = "[\\^\\%~\\+@]";
|
||||||
QString fixedStrings = "[^\\^\\%~\\+@\\{\\}]*";
|
QString fixedStrings = "[^\\^\\%~\\+@\\{\\}]*";
|
||||||
|
|
||||||
QRegExp autoTypeSyntax
|
QRegExp autoTypeSyntax("(" + shortcutKeys + "|" + fixedStrings + "|\\{(" + normalCommands + "|" + specialLiterals +
|
||||||
("(" + shortcutKeys + "|" + fixedStrings + "|\\{(" + normalCommands + "|" + specialLiterals + "|"
|
"|" + functionKeys + "|" + numpad + "|" + delay + "|" + beep + "|" + vkey + ")\\})*");
|
||||||
+ functionKeys
|
|
||||||
+ "|" + numpad + "|" + delay + "|" + beep + "|" + vkey + ")\\})*");
|
|
||||||
autoTypeSyntax.setCaseSensitivity(Qt::CaseInsensitive);
|
autoTypeSyntax.setCaseSensitivity(Qt::CaseInsensitive);
|
||||||
autoTypeSyntax.setPatternSyntax(QRegExp::RegExp);
|
autoTypeSyntax.setPatternSyntax(QRegExp::RegExp);
|
||||||
return autoTypeSyntax.exactMatch(string);
|
return autoTypeSyntax.exactMatch(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AutoType::checkHighDelay(const QString &string)
|
bool AutoType::checkHighDelay(const QString& string)
|
||||||
{
|
{
|
||||||
QRegExp highDelay("\\{DELAY\\s\\d{5,}\\}"); //5 digit numbers(10 seconds) are too much
|
QRegExp highDelay("\\{DELAY\\s\\d{5,}\\}"); // 5 digit numbers(10 seconds) are too much
|
||||||
highDelay.setCaseSensitivity(Qt::CaseInsensitive);
|
highDelay.setCaseSensitivity(Qt::CaseInsensitive);
|
||||||
highDelay.setPatternSyntax(QRegExp::RegExp);
|
highDelay.setPatternSyntax(QRegExp::RegExp);
|
||||||
return highDelay.exactMatch(string);
|
return highDelay.exactMatch(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AutoType::checkHighRepetition(const QString &string)
|
bool AutoType::checkHighRepetition(const QString& string)
|
||||||
{
|
{
|
||||||
QRegExp highRepetition("\\{(?!DELAY\\s)\\w*\\s\\d{3,}\\}"); //3 digit numbers are too much
|
QRegExp highRepetition("\\{(?!DELAY\\s)\\w*\\s\\d{3,}\\}"); // 3 digit numbers are too much
|
||||||
highRepetition.setCaseSensitivity(Qt::CaseInsensitive);
|
highRepetition.setCaseSensitivity(Qt::CaseInsensitive);
|
||||||
highRepetition.setPatternSyntax(QRegExp::RegExp);
|
highRepetition.setPatternSyntax(QRegExp::RegExp);
|
||||||
return highRepetition.exactMatch(string);
|
return highRepetition.exactMatch(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void AutoType::performAutoType(const Entry* entry, QWidget* hideWindow, const QString& customSequence, WId window)
|
||||||
AutoType::performAutoType(const Entry *entry, QWidget *hideWindow, const QString &customSequence, WId window)
|
|
||||||
{
|
{
|
||||||
if (!AutoType::checkSyntax(entry->effectiveAutoTypeSequence())) {
|
if (!AutoType::checkSyntax(entry->effectiveAutoTypeSequence())) {
|
||||||
QMessageBox messageBox;
|
QMessageBox messageBox;
|
||||||
messageBox.critical(0, "AutoType", tr("The Syntax of your AutoType statement is incorrect!"));
|
messageBox.critical(0, tr("AutoType"), tr("The Syntax of your AutoType statement is incorrect!"));
|
||||||
return;
|
return;
|
||||||
}
|
} else if (AutoType::checkHighDelay(entry->effectiveAutoTypeSequence())) {
|
||||||
else if (AutoType::checkHighDelay(entry->effectiveAutoTypeSequence())) {
|
|
||||||
QMessageBox::StandardButton reply;
|
QMessageBox::StandardButton reply;
|
||||||
reply = QMessageBox::question(0,
|
reply = QMessageBox::question(
|
||||||
"AutoType",
|
0,
|
||||||
tr("This AutoType command contains a very long delay. Do you really want to execute it?"));
|
tr("AutoType"),
|
||||||
|
tr("This AutoType command contains a very long delay. Do you really want to execute it?"));
|
||||||
|
|
||||||
if (reply == QMessageBox::No) {
|
if (reply == QMessageBox::No) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else if (AutoType::checkHighRepetition(entry->effectiveAutoTypeSequence())) {
|
||||||
else if (AutoType::checkHighRepetition(entry->effectiveAutoTypeSequence())) {
|
|
||||||
QMessageBox::StandardButton reply;
|
QMessageBox::StandardButton reply;
|
||||||
reply = QMessageBox::question(0,
|
reply = QMessageBox::question(0, tr("AutoType"), tr("This AutoType command contains arguments which are "
|
||||||
"AutoType",
|
"repeated very often. Do you really want to execute it?"));
|
||||||
tr("This AutoType command contains arguments which are repeated very often. Do you really want to execute it?"));
|
|
||||||
|
|
||||||
if (reply == QMessageBox::No) {
|
if (reply == QMessageBox::No) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_performAutoType(entry, hideWindow, customSequence, window);
|
_performAutoType(entry, hideWindow, customSequence, window);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,21 +34,25 @@ class AutoType : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QStringList windowTitles();
|
QStringList windowTitles();
|
||||||
void _performAutoType(const Entry* entry, QWidget* hideWindow = nullptr,
|
void _performAutoType(const Entry* entry,
|
||||||
const QString& customSequence = QString(), WId window = 0);
|
QWidget* hideWindow = nullptr,
|
||||||
|
const QString& customSequence = QString(),
|
||||||
|
WId window = 0);
|
||||||
bool registerGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers);
|
bool registerGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers);
|
||||||
void unregisterGlobalShortcut();
|
void unregisterGlobalShortcut();
|
||||||
int callEventFilter(void* event);
|
int callEventFilter(void* event);
|
||||||
static bool checkSyntax(const QString &string);
|
static bool checkSyntax(const QString& string);
|
||||||
static bool checkHighRepetition(const QString &string);
|
static bool checkHighRepetition(const QString& string);
|
||||||
static bool checkHighDelay(const QString &string);
|
static bool checkHighDelay(const QString& string);
|
||||||
void performAutoType(const Entry *entry, QWidget *hideWindow = nullptr,
|
void performAutoType(const Entry* entry,
|
||||||
const QString &customSequence = QString(), WId window = 0);
|
QWidget* hideWindow = nullptr,
|
||||||
|
const QString& customSequence = QString(),
|
||||||
|
WId window = 0);
|
||||||
|
|
||||||
inline bool isAvailable() {
|
inline bool isAvailable()
|
||||||
|
{
|
||||||
return m_plugin;
|
return m_plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +95,8 @@ private:
|
||||||
Q_DISABLE_COPY(AutoType)
|
Q_DISABLE_COPY(AutoType)
|
||||||
};
|
};
|
||||||
|
|
||||||
inline AutoType* autoType() {
|
inline AutoType* autoType()
|
||||||
|
{
|
||||||
return AutoType::instance();
|
return AutoType::instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue