DolphinQt: Reset TAS input slider to default on right-click

This is a feature which existed in DolphinWX. Seems like it got
implemented in DolphinQt for IRWidget/StickWidget but not sliders.
This commit is contained in:
JosJuice
2020-10-18 13:47:00 +02:00
parent 16f5a50cfc
commit 6670226a44
8 changed files with 96 additions and 42 deletions

View File

@ -48,24 +48,27 @@ WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : TASInputWindow(
ir_x_shortcut_key_sequence.toString(QKeySequence::NativeText),
ir_y_shortcut_key_sequence.toString(QKeySequence::NativeText)));
const int ir_x_default = static_cast<int>(std::round(ir_max_x / 2.));
const int ir_y_default = static_cast<int>(std::round(ir_max_y / 2.));
auto* x_layout = new QHBoxLayout;
m_ir_x_value = CreateSliderValuePair(x_layout, ir_max_x, ir_x_shortcut_key_sequence,
m_ir_x_value = CreateSliderValuePair(x_layout, ir_x_default, ir_max_x, ir_x_shortcut_key_sequence,
Qt::Horizontal, m_ir_box, true);
auto* y_layout = new QVBoxLayout;
m_ir_y_value = CreateSliderValuePair(y_layout, ir_max_y, ir_y_shortcut_key_sequence, Qt::Vertical,
m_ir_box, true);
m_ir_y_value = CreateSliderValuePair(y_layout, ir_y_default, ir_max_y, ir_y_shortcut_key_sequence,
Qt::Vertical, m_ir_box, true);
m_ir_y_value->setMaximumWidth(60);
auto* visual = new IRWidget(this);
visual->SetX(ir_x_default);
visual->SetY(ir_y_default);
connect(m_ir_x_value, qOverload<int>(&QSpinBox::valueChanged), visual, &IRWidget::SetX);
connect(m_ir_y_value, qOverload<int>(&QSpinBox::valueChanged), visual, &IRWidget::SetY);
connect(visual, &IRWidget::ChangedX, m_ir_x_value, &QSpinBox::setValue);
connect(visual, &IRWidget::ChangedY, m_ir_y_value, &QSpinBox::setValue);
m_ir_x_value->setValue(static_cast<int>(std::round(ir_max_x / 2.)));
m_ir_y_value->setValue(static_cast<int>(std::round(ir_max_y / 2.)));
auto* visual_ar = new AspectRatioWidget(visual, ir_max_x, ir_max_y);
auto* visual_layout = new QHBoxLayout;
@ -103,21 +106,17 @@ WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : TASInputWindow(
auto* remote_orientation_x_layout =
// i18n: Refers to a 3D axis (used when mapping motion controls)
CreateSliderValuePairLayout(tr("X"), m_remote_orientation_x_value, 1023, Qt::Key_Q,
CreateSliderValuePairLayout(tr("X"), m_remote_orientation_x_value, 512, 1023, Qt::Key_Q,
m_remote_orientation_box);
auto* remote_orientation_y_layout =
// i18n: Refers to a 3D axis (used when mapping motion controls)
CreateSliderValuePairLayout(tr("Y"), m_remote_orientation_y_value, 1023, Qt::Key_W,
CreateSliderValuePairLayout(tr("Y"), m_remote_orientation_y_value, 512, 1023, Qt::Key_W,
m_remote_orientation_box);
auto* remote_orientation_z_layout =
// i18n: Refers to a 3D axis (used when mapping motion controls)
CreateSliderValuePairLayout(tr("Z"), m_remote_orientation_z_value, 1023, Qt::Key_E,
CreateSliderValuePairLayout(tr("Z"), m_remote_orientation_z_value, 616, 1023, Qt::Key_E,
m_remote_orientation_box);
m_remote_orientation_x_value->setValue(512);
m_remote_orientation_y_value->setValue(512);
m_remote_orientation_z_value->setValue(616);
auto* remote_orientation_layout = new QVBoxLayout;
remote_orientation_layout->addLayout(remote_orientation_x_layout);
remote_orientation_layout->addLayout(remote_orientation_y_layout);
@ -128,21 +127,17 @@ WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : TASInputWindow(
auto* nunchuk_orientation_x_layout =
// i18n: Refers to a 3D axis (used when mapping motion controls)
CreateSliderValuePairLayout(tr("X"), m_nunchuk_orientation_x_value, 1023, Qt::Key_I,
CreateSliderValuePairLayout(tr("X"), m_nunchuk_orientation_x_value, 512, 1023, Qt::Key_I,
m_nunchuk_orientation_box);
auto* nunchuk_orientation_y_layout =
// i18n: Refers to a 3D axis (used when mapping motion controls)
CreateSliderValuePairLayout(tr("Y"), m_nunchuk_orientation_y_value, 1023, Qt::Key_O,
CreateSliderValuePairLayout(tr("Y"), m_nunchuk_orientation_y_value, 512, 1023, Qt::Key_O,
m_nunchuk_orientation_box);
auto* nunchuk_orientation_z_layout =
// i18n: Refers to a 3D axis (used when mapping motion controls)
CreateSliderValuePairLayout(tr("Z"), m_nunchuk_orientation_z_value, 1023, Qt::Key_P,
CreateSliderValuePairLayout(tr("Z"), m_nunchuk_orientation_z_value, 512, 1023, Qt::Key_P,
m_nunchuk_orientation_box);
m_nunchuk_orientation_x_value->setValue(512);
m_nunchuk_orientation_y_value->setValue(512);
m_nunchuk_orientation_z_value->setValue(512);
auto* nunchuk_orientation_layout = new QVBoxLayout;
nunchuk_orientation_layout->addLayout(nunchuk_orientation_x_layout);
nunchuk_orientation_layout->addLayout(nunchuk_orientation_y_layout);
@ -150,9 +145,9 @@ WiiTASInputWindow::WiiTASInputWindow(QWidget* parent, int num) : TASInputWindow(
m_nunchuk_orientation_box->setLayout(nunchuk_orientation_layout);
m_triggers_box = new QGroupBox(tr("Triggers"));
auto* l_trigger_layout =
CreateSliderValuePairLayout(tr("Left"), m_left_trigger_value, 31, Qt::Key_N, m_triggers_box);
auto* r_trigger_layout = CreateSliderValuePairLayout(tr("Right"), m_right_trigger_value, 31,
auto* l_trigger_layout = CreateSliderValuePairLayout(tr("Left"), m_left_trigger_value, 0, 31,
Qt::Key_N, m_triggers_box);
auto* r_trigger_layout = CreateSliderValuePairLayout(tr("Right"), m_right_trigger_value, 0, 31,
Qt::Key_M, m_triggers_box);
auto* triggers_layout = new QVBoxLayout;