mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-22 22:05:38 +00:00
Qt: Add support for clearing input bindings with right click
This commit is contained in:
parent
29a09a3685
commit
45050709f2
|
@ -4,6 +4,7 @@
|
|||
#include "qthostinterface.h"
|
||||
#include "qtutils.h"
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtGui/QMouseEvent>
|
||||
#include <QtGui/QKeyEvent>
|
||||
#include <cmath>
|
||||
|
||||
|
@ -34,6 +35,17 @@ bool InputBindingWidget::eventFilter(QObject* watched, QEvent* event)
|
|||
return false;
|
||||
}
|
||||
|
||||
void InputBindingWidget::mouseReleaseEvent(QMouseEvent* e)
|
||||
{
|
||||
if (e->button() == Qt::RightButton)
|
||||
{
|
||||
clearBinding();
|
||||
return;
|
||||
}
|
||||
|
||||
QPushButton::mouseReleaseEvent(e);
|
||||
}
|
||||
|
||||
void InputBindingWidget::setNewBinding()
|
||||
{
|
||||
if (m_new_binding_value.isEmpty())
|
||||
|
@ -46,6 +58,14 @@ void InputBindingWidget::setNewBinding()
|
|||
m_new_binding_value.clear();
|
||||
}
|
||||
|
||||
void InputBindingWidget::clearBinding()
|
||||
{
|
||||
m_current_binding_value.clear();
|
||||
m_host_interface->removeSettingValue(m_setting_name);
|
||||
m_host_interface->updateInputMap();
|
||||
setText(m_current_binding_value);
|
||||
}
|
||||
|
||||
void InputBindingWidget::onPressed()
|
||||
{
|
||||
if (isListeningForInput())
|
||||
|
|
|
@ -16,6 +16,7 @@ public:
|
|||
|
||||
protected:
|
||||
virtual bool eventFilter(QObject* watched, QEvent* event) override;
|
||||
virtual void mouseReleaseEvent(QMouseEvent* e) override;
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onPressed();
|
||||
|
@ -27,6 +28,7 @@ protected:
|
|||
|
||||
bool isListeningForInput() const { return m_input_listen_timer != nullptr; }
|
||||
void setNewBinding();
|
||||
void clearBinding();
|
||||
|
||||
QtHostInterface* m_host_interface;
|
||||
QString m_setting_name;
|
||||
|
|
Loading…
Reference in a new issue