Allow configuring keyboard shortcuts (#9643)

Closes #2689

The design of the respective code is loosely based on KDE's KActionCollection. The ActionCollection manages all actions that can be shortcut configured. These actions are then exposed in the config and a user can assign a different shortcut.

Actions inside the MainWindow have been added to the ActionCollection.

---------

Co-authored-by: Jonathan White <support@dmapps.us>
This commit is contained in:
Waqar Ahmed
2024-02-04 16:29:04 +05:00
committed by GitHub
parent d03f5e4977
commit a472ef8a93
17 changed files with 1238 additions and 233 deletions

View File

@@ -21,6 +21,7 @@
#include "ui_ApplicationSettingsWidgetSecurity.h"
#include <QDesktopServices>
#include <QDir>
#include <QToolTip>
#include "config-keepassx.h"
@@ -138,6 +139,22 @@ ApplicationSettingsWidget::ApplicationSettingsWidget(QWidget* parent)
m_secUi->lockDatabaseMinimizeCheckBox->setEnabled(!state);
});
// Set Auto-Type shortcut when changed
connect(
m_generalUi->autoTypeShortcutWidget, &ShortcutWidget::shortcutChanged, this, [this](auto key, auto modifiers) {
QString error;
if (autoType()->registerGlobalShortcut(key, modifiers, &error)) {
m_generalUi->autoTypeShortcutWidget->setStyleSheet("");
} else {
QToolTip::showText(mapToGlobal(rect().bottomLeft()), error);
m_generalUi->autoTypeShortcutWidget->setStyleSheet("background-color: #FF9696;");
}
});
connect(m_generalUi->autoTypeShortcutWidget, &ShortcutWidget::shortcutReset, this, [this] {
autoType()->unregisterGlobalShortcut();
m_generalUi->autoTypeShortcutWidget->setStyleSheet("");
});
// Disable mouse wheel grab when scrolling
// This prevents combo box and spinner values from changing without explicit focus
auto mouseWheelFilter = new MouseWheelEventFilter(this);