Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/autotype/AutoType.cpp')
-rw-r--r--src/autotype/AutoType.cpp58
1 files changed, 46 insertions, 12 deletions
diff --git a/src/autotype/AutoType.cpp b/src/autotype/AutoType.cpp
index 80a2268ec..01ef9d762 100644
--- a/src/autotype/AutoType.cpp
+++ b/src/autotype/AutoType.cpp
@@ -31,14 +31,15 @@
#include "core/Config.h"
#include "core/Database.h"
#include "core/Entry.h"
-#include "core/FilePath.h"
#include "core/Group.h"
#include "core/ListDeleter.h"
+#include "core/Resources.h"
#include "core/Tools.h"
+#include "gui/MainWindow.h"
#include "gui/MessageBox.h"
#ifdef Q_OS_MAC
-#include "gui/macutils/MacUtils.h"
+#include "gui/osutils/macutils/MacUtils.h"
#endif
AutoType* AutoType::m_instance = nullptr;
@@ -51,6 +52,7 @@ AutoType::AutoType(QObject* parent, bool test)
, m_pluginLoader(new QPluginLoader(this))
, m_plugin(nullptr)
, m_executor(nullptr)
+ , m_windowState(WindowState::Normal)
, m_windowForGlobal(0)
{
// prevent crash when the plugin has unresolved symbols
@@ -63,7 +65,7 @@ AutoType::AutoType(QObject* parent, bool test)
pluginName += "test";
}
- QString pluginPath = filePath()->pluginPath(pluginName);
+ QString pluginPath = resources()->pluginPath(pluginName);
if (!pluginPath.isEmpty()) {
#ifdef WITH_XC_AUTOTYPE
@@ -227,6 +229,7 @@ void AutoType::executeAutoTypeActions(const Entry* entry, QWidget* hideWindow, c
"KeePassXC."));
return;
}
+
macUtils()->raiseLastActiveWindow();
m_plugin->hideOwnWindow();
#else
@@ -234,7 +237,7 @@ void AutoType::executeAutoTypeActions(const Entry* entry, QWidget* hideWindow, c
#endif
}
- Tools::wait(qMax(100, config()->get("AutoTypeStartDelay", 500).toInt()));
+ Tools::wait(qMax(100, config()->get(Config::AutoTypeStartDelay).toInt()));
// Used only for selected entry auto-type
if (!window) {
@@ -286,6 +289,18 @@ void AutoType::startGlobalAutoType()
{
m_windowForGlobal = m_plugin->activeWindow();
m_windowTitleForGlobal = m_plugin->activeWindowTitle();
+#ifdef Q_OS_MACOS
+ m_windowState = WindowState::Normal;
+ if (getMainWindow()) {
+ if (getMainWindow()->isMinimized()) {
+ m_windowState = WindowState::Minimized;
+ }
+ if (getMainWindow()->isHidden()) {
+ m_windowState = WindowState::Hidden;
+ }
+ }
+#endif
+
emit globalAutoTypeTriggered();
}
@@ -332,14 +347,17 @@ void AutoType::performGlobalAutoType(const QList<QSharedPointer<Database>>& dbLi
.append(m_windowTitleForGlobal));
msgBox->setIcon(QMessageBox::Information);
msgBox->setStandardButtons(QMessageBox::Ok);
- msgBox->show();
- msgBox->raise();
- msgBox->activateWindow();
+#ifdef Q_OS_MACOS
+ m_plugin->raiseOwnWindow();
+ Tools::wait(200);
+#endif
+ msgBox->exec();
+ restoreWindowState();
}
m_inGlobalAutoTypeDialog.unlock();
emit autotypeRejected();
- } else if ((matchList.size() == 1) && !config()->get("security/autotypeask").toBool()) {
+ } else if ((matchList.size() == 1) && !config()->get(Config::Security_AutoTypeAsk).toBool()) {
executeAutoTypeActions(matchList.first().entry, nullptr, matchList.first().sequence, m_windowForGlobal);
m_inGlobalAutoTypeDialog.unlock();
} else {
@@ -361,8 +379,23 @@ void AutoType::performGlobalAutoType(const QList<QSharedPointer<Database>>& dbLi
}
}
+void AutoType::restoreWindowState()
+{
+#ifdef Q_OS_MAC
+ if (getMainWindow()) {
+ if (m_windowState == WindowState::Minimized) {
+ getMainWindow()->showMinimized();
+ } else if (m_windowState == WindowState::Hidden) {
+ getMainWindow()->hideWindow();
+ }
+ }
+#endif
+}
+
void AutoType::performAutoTypeFromGlobal(AutoTypeMatch match)
{
+ restoreWindowState();
+
m_plugin->raiseWindow(m_windowForGlobal);
executeAutoTypeActions(match.entry, nullptr, match.sequence, m_windowForGlobal);
@@ -380,6 +413,7 @@ void AutoType::autoTypeRejectedFromGlobal()
m_windowForGlobal = 0;
m_windowTitleForGlobal.clear();
+ restoreWindowState();
emit autotypeRejected();
}
@@ -390,7 +424,7 @@ bool AutoType::parseActions(const QString& actionSequence, const Entry* entry, Q
{
QString tmpl;
bool inTmpl = false;
- m_autoTypeDelay = qMax(config()->get("AutoTypeDelay").toInt(), 0);
+ m_autoTypeDelay = qMax(config()->get(Config::AutoTypeDelay).toInt(), 0);
QString sequence = actionSequence;
sequence.replace("{{}", "{LEFTBRACE}");
@@ -617,12 +651,12 @@ QList<QString> AutoType::autoTypeSequences(const Entry* entry, const QString& wi
}
}
- if (config()->get("AutoTypeEntryTitleMatch").toBool()
+ if (config()->get(Config::AutoTypeEntryTitleMatch).toBool()
&& windowMatchesTitle(windowTitle, entry->resolvePlaceholder(entry->title()))) {
sequenceList.append(entry->effectiveAutoTypeSequence());
}
- if (config()->get("AutoTypeEntryURLMatch").toBool()
+ if (config()->get(Config::AutoTypeEntryURLMatch).toBool()
&& windowMatchesUrl(windowTitle, entry->resolvePlaceholder(entry->url()))) {
sequenceList.append(entry->effectiveAutoTypeSequence());
}
@@ -684,7 +718,7 @@ bool AutoType::checkSyntax(const QString& string)
QString allowRepetition = "(?:\\s\\d+)?";
// the ":" allows custom commands with syntax S:Field
// exclude BEEP otherwise will be checked as valid
- QString normalCommands = "(?!BEEP\\s)[A-Z:]*" + allowRepetition;
+ QString normalCommands = "(?!BEEP\\s)[A-Z:_]*" + allowRepetition;
QString specialLiterals = "[\\^\\%\\(\\)~\\{\\}\\[\\]\\+]" + allowRepetition;
QString functionKeys = "(?:F[1-9]" + allowRepetition + "|F1[0-2])" + allowRepetition;
QString numpad = "NUMPAD\\d" + allowRepetition;