mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-09-22 13:54:41 -04:00
Prevent mouse wheel scroll on entry edit username field (#12398)
* Reported by shawnkhu via Matrix, thank you!
This commit is contained in:
parent
544f983bad
commit
606cf37952
4 changed files with 32 additions and 22 deletions
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "autotype/AutoType.h"
|
||||
#include "core/Translator.h"
|
||||
#include "gui/GuiTools.h"
|
||||
#include "gui/Icons.h"
|
||||
#include "gui/MainWindow.h"
|
||||
#include "gui/osutils/OSUtils.h"
|
||||
|
@ -62,28 +63,6 @@ private:
|
|||
QWidget* widget;
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper class to ignore mouse wheel events on non-focused widgets
|
||||
* NOTE: The widget must NOT have a focus policy of "WHEEL"
|
||||
*/
|
||||
class MouseWheelEventFilter : public QObject
|
||||
{
|
||||
public:
|
||||
explicit MouseWheelEventFilter(QObject* parent)
|
||||
: QObject(parent){};
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject* obj, QEvent* event) override
|
||||
{
|
||||
const auto* widget = qobject_cast<QWidget*>(obj);
|
||||
if (event->type() == QEvent::Wheel && widget && !widget->hasFocus()) {
|
||||
event->ignore();
|
||||
return true;
|
||||
}
|
||||
return QObject::eventFilter(obj, event);
|
||||
}
|
||||
};
|
||||
|
||||
ApplicationSettingsWidget::ApplicationSettingsWidget(QWidget* parent)
|
||||
: EditWidget(parent)
|
||||
, m_secWidget(new QWidget())
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#ifndef KEEPASSXC_GUITOOLS_H
|
||||
#define KEEPASSXC_GUITOOLS_H
|
||||
|
||||
#include <QEvent>
|
||||
#include <QList>
|
||||
#include <QWidget>
|
||||
|
||||
|
@ -29,4 +30,27 @@ namespace GuiTools
|
|||
bool confirmDeletePluginData(QWidget* parent, const QList<Entry*>& entries);
|
||||
size_t deleteEntriesResolveReferences(QWidget* parent, const QList<Entry*>& entries, bool permanent);
|
||||
} // namespace GuiTools
|
||||
|
||||
/**
|
||||
* Helper class to ignore mouse wheel events on non-focused widgets
|
||||
* NOTE: The widget must NOT have a focus policy of "WHEEL"
|
||||
*/
|
||||
class MouseWheelEventFilter : public QObject
|
||||
{
|
||||
public:
|
||||
explicit MouseWheelEventFilter(QObject* parent)
|
||||
: QObject(parent){};
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject* obj, QEvent* event) override
|
||||
{
|
||||
const auto* widget = qobject_cast<QWidget*>(obj);
|
||||
if (event->type() == QEvent::Wheel && widget && !widget->hasFocus()) {
|
||||
event->ignore();
|
||||
return true;
|
||||
}
|
||||
return QObject::eventFilter(obj, event);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // KEEPASSXC_GUITOOLS_H
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "gui/EditWidgetProperties.h"
|
||||
#include "gui/FileDialog.h"
|
||||
#include "gui/Font.h"
|
||||
#include "gui/GuiTools.h"
|
||||
#include "gui/Icons.h"
|
||||
#include "gui/MessageBox.h"
|
||||
#include "gui/entry/AutoTypeAssociationsModel.h"
|
||||
|
@ -185,7 +186,10 @@ void EditEntryWidget::setupMain()
|
|||
m_mainUi->setupUi(m_mainWidget);
|
||||
addPage(tr("Entry"), icons()->icon("document-edit"), m_mainWidget);
|
||||
|
||||
// Disable mouse wheel grab when scrolling
|
||||
m_mainUi->usernameComboBox->installEventFilter(new MouseWheelEventFilter(this));
|
||||
m_mainUi->usernameComboBox->setEditable(true);
|
||||
m_mainUi->usernameComboBox->lineEdit()->setFocusPolicy(Qt::StrongFocus);
|
||||
m_usernameCompleter->setCompletionMode(QCompleter::InlineCompletion);
|
||||
m_usernameCompleter->setCaseSensitivity(Qt::CaseSensitive);
|
||||
m_usernameCompleter->setModel(m_usernameCompleterModel);
|
||||
|
|
|
@ -140,6 +140,9 @@
|
|||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="usernameComboBox">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string>Username field</string>
|
||||
</property>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue