mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-25 12:30:15 +00:00
Input GUI: Add 5 second timeout to button click.
This commit is contained in:
parent
a0b9ea36fc
commit
ee8b3cba8c
@ -45,11 +45,14 @@ ConfigureInput::ConfigureInput(QWidget* parent) :
|
||||
}
|
||||
connect(ui->btnRestoreDefaults, SIGNAL(released()), this, SLOT(restoreDefaults()));
|
||||
setFocusPolicy(Qt::ClickFocus);
|
||||
timer->setSingleShot(true);
|
||||
connect(timer, &QTimer::timeout, this, [&]() { key_pressed = Qt::Key_Escape; setKey(); });
|
||||
this->setConfiguration();
|
||||
}
|
||||
|
||||
ConfigureInput::~ConfigureInput()
|
||||
{
|
||||
delete timer;
|
||||
}
|
||||
|
||||
/// Event handler for all button released() event.
|
||||
@ -62,6 +65,7 @@ void ConfigureInput::handleClick()
|
||||
grabKeyboard();
|
||||
grabMouse();
|
||||
changing_button = sender;
|
||||
timer->start(5000); //Cancel after 5 seconds
|
||||
}
|
||||
|
||||
/// Save all button configurations to settings file
|
||||
@ -89,6 +93,7 @@ void ConfigureInput::keyPressEvent(QKeyEvent* event)
|
||||
if (changing_button != nullptr && event->key() != Qt::Key_unknown)
|
||||
{
|
||||
key_pressed = event->key();
|
||||
timer->stop();
|
||||
setKey();
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <memory>
|
||||
#include <QWidget>
|
||||
#include <QKeyEvent>
|
||||
#include <QTimer>
|
||||
|
||||
#include "citra_qt/config.h"
|
||||
#include "core/settings.h"
|
||||
@ -37,11 +38,13 @@ private:
|
||||
int key_pressed;
|
||||
QPushButton* changing_button = nullptr; /// button currently waiting for key press.
|
||||
QString previous_mapping;
|
||||
QTimer* timer = new QTimer();
|
||||
|
||||
void setConfiguration();
|
||||
void setKey();
|
||||
void removeDuplicates(const QString& newValue);
|
||||
void keyPressEvent(QKeyEvent* event) override;
|
||||
QString getKeyName(int key_code) const;
|
||||
Qt::Key getKeyValue(const QString& text) const;
|
||||
private Q_SLOTS:
|
||||
void setKey();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user