mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 18:53:28 +01:00
Qt: add Refresh button to gamepad settings, minor cleanup
This commit is contained in:
parent
4b11a62b4d
commit
2db2114a45
@ -20,7 +20,7 @@ keyboard_pad_handler::keyboard_pad_handler() : QObject()
|
|||||||
|
|
||||||
void keyboard_pad_handler::ConfigController(std::string device)
|
void keyboard_pad_handler::ConfigController(std::string device)
|
||||||
{
|
{
|
||||||
pad_settings_dialog dlg(this);
|
pad_settings_dialog dlg;
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,34 @@ gamepads_settings_dialog::gamepads_settings_dialog(QWidget* parent)
|
|||||||
resizeComboBoxView(combo);
|
resizeComboBoxView(combo);
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int i = 0; i < 7; i++)
|
auto configure_combos = [=]
|
||||||
|
{
|
||||||
|
//Set the values from config
|
||||||
|
for (int i = 0; i < MAX_PLAYERS; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < co_inputtype[i]->count(); j++)
|
||||||
|
{
|
||||||
|
if (co_inputtype[i]->itemText(j).toStdString() == input_cfg.player_input[i].to_string())
|
||||||
|
{
|
||||||
|
co_inputtype[i]->setCurrentIndex(j);
|
||||||
|
ChangeInputType(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = 0; j < co_deviceID[i]->count(); j++)
|
||||||
|
{
|
||||||
|
if (co_deviceID[i]->itemText(j).toStdString() == input_cfg.player_device[i]->to_string())
|
||||||
|
{
|
||||||
|
co_deviceID[i]->setCurrentIndex(j);
|
||||||
|
ChangeDevice(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i = 0; i < MAX_PLAYERS; i++)
|
||||||
{
|
{
|
||||||
QGroupBox *grp_player = new QGroupBox(QString(tr("Player %1").arg(i+1)));
|
QGroupBox *grp_player = new QGroupBox(QString(tr("Player %1").arg(i+1)));
|
||||||
|
|
||||||
@ -101,8 +128,10 @@ gamepads_settings_dialog::gamepads_settings_dialog(QWidget* parent)
|
|||||||
|
|
||||||
QHBoxLayout *buttons_layout = new QHBoxLayout();
|
QHBoxLayout *buttons_layout = new QHBoxLayout();
|
||||||
QPushButton *ok_button = new QPushButton(tr("OK"));
|
QPushButton *ok_button = new QPushButton(tr("OK"));
|
||||||
buttons_layout->addWidget(ok_button);
|
|
||||||
QPushButton *cancel_button = new QPushButton(tr("Cancel"));
|
QPushButton *cancel_button = new QPushButton(tr("Cancel"));
|
||||||
|
QPushButton *refresh_button = new QPushButton(tr("Refresh"));
|
||||||
|
buttons_layout->addWidget(ok_button);
|
||||||
|
buttons_layout->addWidget(refresh_button);
|
||||||
buttons_layout->addWidget(cancel_button);
|
buttons_layout->addWidget(cancel_button);
|
||||||
buttons_layout->addStretch();
|
buttons_layout->addStretch();
|
||||||
dialog_layout->addLayout(buttons_layout);
|
dialog_layout->addLayout(buttons_layout);
|
||||||
@ -110,31 +139,9 @@ gamepads_settings_dialog::gamepads_settings_dialog(QWidget* parent)
|
|||||||
setLayout(dialog_layout);
|
setLayout(dialog_layout);
|
||||||
layout()->setSizeConstraint(QLayout::SetFixedSize);
|
layout()->setSizeConstraint(QLayout::SetFixedSize);
|
||||||
|
|
||||||
//Set the values from config
|
configure_combos();
|
||||||
for (int i = 0; i < 7; i++)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < co_inputtype[i]->count(); j++)
|
|
||||||
{
|
|
||||||
if (co_inputtype[i]->itemText(j).toStdString() == input_cfg.player_input[i].to_string())
|
|
||||||
{
|
|
||||||
co_inputtype[i]->setCurrentIndex(j);
|
|
||||||
ChangeInputType(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int j = 0; j < co_deviceID[i]->count(); j++)
|
for (int i = 0; i < MAX_PLAYERS; i++)
|
||||||
{
|
|
||||||
if (co_deviceID[i]->itemText(j).toStdString() == input_cfg.player_device[i]->to_string())
|
|
||||||
{
|
|
||||||
co_deviceID[i]->setCurrentIndex(j);
|
|
||||||
ChangeDevice(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < 7; i++)
|
|
||||||
{
|
{
|
||||||
connect(co_inputtype[i], &QComboBox::currentTextChanged, [=] { ChangeInputType(i); });
|
connect(co_inputtype[i], &QComboBox::currentTextChanged, [=] { ChangeInputType(i); });
|
||||||
connect(co_deviceID[i], &QComboBox::currentTextChanged, [=] { ChangeDevice(i); });
|
connect(co_deviceID[i], &QComboBox::currentTextChanged, [=] { ChangeDevice(i); });
|
||||||
@ -142,12 +149,13 @@ gamepads_settings_dialog::gamepads_settings_dialog(QWidget* parent)
|
|||||||
}
|
}
|
||||||
connect(ok_button, &QPushButton::pressed, this, &gamepads_settings_dialog::SaveExit);
|
connect(ok_button, &QPushButton::pressed, this, &gamepads_settings_dialog::SaveExit);
|
||||||
connect(cancel_button, &QPushButton::pressed, this, &gamepads_settings_dialog::CancelExit);
|
connect(cancel_button, &QPushButton::pressed, this, &gamepads_settings_dialog::CancelExit);
|
||||||
|
connect(refresh_button, &QPushButton::pressed, [=] { configure_combos(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void gamepads_settings_dialog::SaveExit()
|
void gamepads_settings_dialog::SaveExit()
|
||||||
{
|
{
|
||||||
//Check for invalid selection
|
//Check for invalid selection
|
||||||
for (int i = 0; i < 7; i++)
|
for (int i = 0; i < MAX_PLAYERS; i++)
|
||||||
{
|
{
|
||||||
if (co_deviceID[i]->currentData() == -1)
|
if (co_deviceID[i]->currentData() == -1)
|
||||||
{
|
{
|
||||||
|
@ -60,6 +60,8 @@ extern input_config input_cfg;
|
|||||||
|
|
||||||
class gamepads_settings_dialog : public QDialog
|
class gamepads_settings_dialog : public QDialog
|
||||||
{
|
{
|
||||||
|
const int MAX_PLAYERS = 7;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::shared_ptr<PadHandlerBase> GetHandler(pad_handler type);
|
std::shared_ptr<PadHandlerBase> GetHandler(pad_handler type);
|
||||||
void ChangeInputType(int player);
|
void ChangeInputType(int player);
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#include "debugger_frame.h"
|
#include "debugger_frame.h"
|
||||||
#include "log_frame.h"
|
#include "log_frame.h"
|
||||||
#include "settings_dialog.h"
|
#include "settings_dialog.h"
|
||||||
#include "pad_settings_dialog.h"
|
|
||||||
#include "auto_pause_settings_dialog.h"
|
#include "auto_pause_settings_dialog.h"
|
||||||
#include "cg_disasm_window.h"
|
#include "cg_disasm_window.h"
|
||||||
#include "memory_string_searcher.h"
|
#include "memory_string_searcher.h"
|
||||||
|
@ -18,7 +18,7 @@ static const int PadButtonWidth = 60;
|
|||||||
|
|
||||||
extern keyboard_pad_config g_kbpad_config;
|
extern keyboard_pad_config g_kbpad_config;
|
||||||
|
|
||||||
pad_settings_dialog::pad_settings_dialog(keyboard_pad_handler *keyhandler, QWidget *parent) : QDialog(parent), ui(new Ui::pad_settings_dialog)
|
pad_settings_dialog::pad_settings_dialog(QWidget *parent) : QDialog(parent), ui(new Ui::pad_settings_dialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
@ -62,15 +62,17 @@ pad_settings_dialog::pad_settings_dialog(keyboard_pad_handler *keyhandler, QWidg
|
|||||||
padButtons->addButton(ui->b_ok, 26);
|
padButtons->addButton(ui->b_ok, 26);
|
||||||
padButtons->addButton(ui->b_cancel, 27);
|
padButtons->addButton(ui->b_cancel, 27);
|
||||||
|
|
||||||
connect(padButtons, SIGNAL(buttonClicked(int)), this, SLOT(OnPadButtonClicked(int)));
|
connect(padButtons, static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, &pad_settings_dialog::OnPadButtonClicked);
|
||||||
|
|
||||||
g_kbpad_config.load();
|
g_kbpad_config.load();
|
||||||
UpdateLabel();
|
UpdateLabel();
|
||||||
|
|
||||||
gui_settings settings(this);
|
gui_settings settings(this);
|
||||||
|
|
||||||
|
// repaint and resize controller image
|
||||||
ui->l_controller->setPixmap(settings.colorizedPixmap(*ui->l_controller->pixmap(), QColor(), GUI::get_Label_Color("l_controller"), false, true));
|
ui->l_controller->setPixmap(settings.colorizedPixmap(*ui->l_controller->pixmap(), QColor(), GUI::get_Label_Color("l_controller"), false, true));
|
||||||
ui->l_controller->setMaximumSize(ui->gb_description->sizeHint().width(), ui->l_controller->maximumHeight() * ui->gb_description->sizeHint().width() / ui->l_controller->maximumWidth());
|
ui->l_controller->setMaximumSize(ui->gb_description->sizeHint().width(), ui->l_controller->maximumHeight() * ui->gb_description->sizeHint().width() / ui->l_controller->maximumWidth());
|
||||||
|
|
||||||
layout()->setSizeConstraint(QLayout::SetFixedSize);
|
layout()->setSizeConstraint(QLayout::SetFixedSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,12 +65,10 @@ private:
|
|||||||
u32 m_seconds;
|
u32 m_seconds;
|
||||||
u32 m_button_id;
|
u32 m_button_id;
|
||||||
bool m_key_pressed;
|
bool m_key_pressed;
|
||||||
QAction *onButtonClickedAct;
|
|
||||||
Ui::pad_settings_dialog *ui;
|
Ui::pad_settings_dialog *ui;
|
||||||
keyboard_pad_handler* keyhdlr;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit pad_settings_dialog(keyboard_pad_handler* keyhandler, QWidget *parent = nullptr);
|
explicit pad_settings_dialog(QWidget *parent = nullptr);
|
||||||
~pad_settings_dialog();
|
~pad_settings_dialog();
|
||||||
void keyPressEvent(QKeyEvent *keyEvent) override;
|
void keyPressEvent(QKeyEvent *keyEvent) override;
|
||||||
void UpdateLabel();
|
void UpdateLabel();
|
||||||
|
Loading…
Reference in New Issue
Block a user