diff --git a/src/autotype/AutoType.cpp b/src/autotype/AutoType.cpp index e4618f74..319814a3 100644 --- a/src/autotype/AutoType.cpp +++ b/src/autotype/AutoType.cpp @@ -252,7 +252,8 @@ void AutoType::performAutoTypeFromGlobal(Entry* entry, const QString& sequence) m_plugin->raiseWindow(m_windowFromGlobal); m_inAutoType = false; - performAutoType(entry, nullptr, sequence, m_windowFromGlobal); + + performAutoTypeWithSyntaxCheckingDialog(entry, nullptr, sequence, m_windowFromGlobal); } void AutoType::resetInAutoType() @@ -714,3 +715,38 @@ bool AutoType::checkHighRepetition(const QString &string) highRepetition.setPatternSyntax(QRegExp::RegExp); return highRepetition.exactMatch(string); } + +void +AutoType::performAutoTypeWithSyntaxCheckingDialog(const Entry *entry, + QWidget *hideWindow, + const QString &customSequence, + WId window) +{ + if (!AutoType::checkSyntax(entry->effectiveAutoTypeSequence())) { + QMessageBox messageBox; + messageBox.critical(0, "AutoType", tr("The Syntax of your AutoType statement is incorrect!")); + return; + } + else if (AutoType::checkHighDelay(entry->effectiveAutoTypeSequence())) { + QMessageBox::StandardButton reply; + reply = QMessageBox::question(0, + "AutoType", + tr("This AutoType command contains a very long delay. Do you really want to execute it?")); + + if (reply == QMessageBox::No) { + return; + } + } + else if (AutoType::checkHighRepetition(entry->effectiveAutoTypeSequence())) { + QMessageBox::StandardButton reply; + reply = QMessageBox::question(0, + "AutoType", + tr("This AutoType command contains arguments which are repeated very often. Do you really want to execute it?")); + + if (reply == QMessageBox::No) { + return; + } + } + performAutoType(entry, hideWindow, customSequence, window); + +} diff --git a/src/autotype/AutoType.h b/src/autotype/AutoType.h index 92505b7d..90d12a7f 100644 --- a/src/autotype/AutoType.h +++ b/src/autotype/AutoType.h @@ -45,6 +45,10 @@ public: static bool checkSyntax(const QString &string); static bool checkHighRepetition(const QString &string); static bool checkHighDelay(const QString &string); + void performAutoTypeWithSyntaxCheckingDialog(const Entry *entry, + QWidget *hideWindow = nullptr, + const QString &customSequence = QString(), + WId window = 0); inline bool isAvailable() { return m_plugin; diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 3fe403fc..3f5222e1 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -584,32 +584,7 @@ void DatabaseWidget::performAutoType() return; } - if (!AutoType::checkSyntax(currentEntry->effectiveAutoTypeSequence())) { - QMessageBox messageBox; - messageBox.critical(0, "AutoType", tr("The Syntax of your AutoType statement is incorrect!")); - return; - } - else if (AutoType::checkHighDelay(currentEntry->effectiveAutoTypeSequence())) { - QMessageBox::StandardButton reply; - reply = QMessageBox::question(0, - "AutoType", - tr("This AutoType command contains a very long delay. Do you really want to execute it?")); - - if (reply == QMessageBox::No) { - return; - } - } - else if (AutoType::checkHighRepetition(currentEntry->effectiveAutoTypeSequence())) { - QMessageBox::StandardButton reply; - reply = QMessageBox::question(0, - "AutoType", - tr("This AutoType command contains arguments which are repeated very often. Do you really want to execute it?")); - - if (reply == QMessageBox::No) { - return; - } - } - autoType()->performAutoType(currentEntry, window()); + autoType()->performAutoTypeWithSyntaxCheckingDialog(currentEntry, window()); } void DatabaseWidget::openUrl() @@ -638,7 +613,7 @@ void DatabaseWidget::openUrlForEntry(Entry* entry) } return; } - + // otherwise ask user if (urlString.length() > 6) { QString cmdTruncated = urlString.mid(6); @@ -652,7 +627,7 @@ void DatabaseWidget::openUrlForEntry(Entry* entry) this ); msgbox.setDefaultButton(QMessageBox::No); - + QCheckBox* checkbox = new QCheckBox(tr("Remember my choice"), &msgbox); msgbox.setCheckBox(checkbox); bool remember = false; @@ -661,12 +636,12 @@ void DatabaseWidget::openUrlForEntry(Entry* entry) remember = true; } }); - + int result = msgbox.exec(); if (result == QMessageBox::Yes) { QProcess::startDetached(urlString.mid(6)); } - + if (remember) { entry->attributes()->set(EntryAttributes::RememberCmdExecAttr, result == QMessageBox::Yes ? "1" : "0");