mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-04-22 04:24:44 +00:00
make more generic so translations can be supported in combobox
This commit is contained in:
parent
ea5c3aede9
commit
cad54771ea
5 changed files with 54 additions and 29 deletions
|
@ -41,7 +41,7 @@ static std::string logFilter;
|
|||
static std::string logType = "async";
|
||||
static std::string userName = "shadPS4";
|
||||
static std::string updateChannel;
|
||||
static std::string backButtonBehavior = "Touchpad Left";
|
||||
static std::string backButtonBehavior = "left";
|
||||
static bool useSpecialPad = false;
|
||||
static int specialPadClass = 1;
|
||||
static bool isDebugDump = false;
|
||||
|
@ -444,7 +444,7 @@ void load(const std::filesystem::path& path) {
|
|||
}
|
||||
isShowSplash = toml::find_or<bool>(general, "showSplash", true);
|
||||
isAutoUpdate = toml::find_or<bool>(general, "autoUpdate", false);
|
||||
backButtonBehavior = toml::find_or<std::string>(general, "backButtonBehavior", "Touchpad Left");
|
||||
backButtonBehavior = toml::find_or<std::string>(general, "backButtonBehavior", "left");
|
||||
}
|
||||
|
||||
if (data.contains("Input")) {
|
||||
|
@ -602,7 +602,7 @@ void setDefaultValues() {
|
|||
} else {
|
||||
updateChannel = "Nightly";
|
||||
}
|
||||
backButtonBehavior = "Touchpad Left";
|
||||
backButtonBehavior = "left";
|
||||
useSpecialPad = false;
|
||||
specialPadClass = 1;
|
||||
isDebugDump = false;
|
||||
|
|
|
@ -98,6 +98,15 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices, QWidge
|
|||
ui->buttonBox->button(QDialogButtonBox::RestoreDefaults)->setText(tr("Restore Defaults"));
|
||||
ui->buttonBox->button(QDialogButtonBox::Close)->setText(tr("Close"));
|
||||
|
||||
ui->backButtonBehaviorComboBox->addItem(tr("Touchpad Left"), "left");
|
||||
ui->backButtonBehaviorComboBox->addItem(tr("Touchpad Center"), "center");
|
||||
ui->backButtonBehaviorComboBox->addItem(tr("Touchpad Right"), "right");
|
||||
ui->backButtonBehaviorComboBox->addItem(tr("None"), "none");
|
||||
|
||||
QString currentBackButtonBehavior = QString::fromStdString(Config::getBackButtonBehavior());
|
||||
int index = ui->backButtonBehaviorComboBox->findData(currentBackButtonBehavior);
|
||||
ui->backButtonBehaviorComboBox->setCurrentIndex(index != -1 ? index : 0);
|
||||
|
||||
connect(ui->tabWidgetSettings, &QTabWidget::currentChanged, this,
|
||||
[this]() { ui->buttonBox->button(QDialogButtonBox::Close)->setFocus(); });
|
||||
|
||||
|
@ -152,8 +161,12 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices, QWidge
|
|||
BackgroundMusicPlayer::getInstance().setVolume(val);
|
||||
});
|
||||
|
||||
connect(ui->backButtonBehaviorComboBox, &QComboBox::currentTextChanged, this, [](const QString& text) {
|
||||
Config::setBackButtonBehavior(text.toStdString());
|
||||
connect(ui->backButtonBehaviorComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this, [this](int index) {
|
||||
if (index >= 0 && index < ui->backButtonBehaviorComboBox->count()) {
|
||||
QString data = ui->backButtonBehaviorComboBox->itemData(index).toString();
|
||||
Config::setBackButtonBehavior(data.toStdString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -264,7 +277,9 @@ void SettingsDialog::LoadValuesFromConfig() {
|
|||
}
|
||||
ui->updateComboBox->setCurrentText(QString::fromStdString(updateChannel));
|
||||
|
||||
ui->backButtonBehaviorComboBox->setCurrentText(QString::fromStdString(Config::getBackButtonBehavior()));
|
||||
QString backButtonBehavior = QString::fromStdString(Config::getBackButtonBehavior());
|
||||
int index = ui->backButtonBehaviorComboBox->findData(backButtonBehavior);
|
||||
ui->backButtonBehaviorComboBox->setCurrentIndex(index != -1 ? index : 0);
|
||||
}
|
||||
|
||||
void SettingsDialog::InitializeEmulatorLanguages() {
|
||||
|
|
|
@ -475,26 +475,6 @@
|
|||
<height>28</height>
|
||||
</rect>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Touchpad Left</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Touchpad Right</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Touchpad Center</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
|
|
@ -539,6 +539,16 @@
|
|||
<source>Volume</source>
|
||||
<translation>Volume</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="455"/>
|
||||
<source>Controller Settings</source>
|
||||
<translation>Controller Settings</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.ui" line="467"/>
|
||||
<source>Back Button Behavior</source>
|
||||
<translation>Back Button Behavior</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MainWindow</name>
|
||||
|
@ -1029,10 +1039,30 @@
|
|||
<translation>Play Title Music:\nIf a game supports it, enable playing special music when selecting the game in the GUI.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.cpp" line="329"/>
|
||||
<location filename="../settings_dialog.cpp" line="330"/>
|
||||
<source>backButtonBehaviorGroupBox</source>
|
||||
<translation>Back Button Behavior:\nAllows setting which part of the touchpad the back button will emulate a touch on.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.cpp" line="101"/>
|
||||
<source>Touchpad Left</source>
|
||||
<translation>Touchpad Left</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.cpp" line="102"/>
|
||||
<source>Touchpad Right</source>
|
||||
<translation>Touchpad Right</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.cpp" line="103"/>
|
||||
<source>Touchpad Center</source>
|
||||
<translation>Touchpad Center</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.cpp" line="104"/>
|
||||
<source>None</source>
|
||||
<translation>None</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settings_dialog.cpp" line="312"/>
|
||||
<source>graphicsAdapterGroupBox</source>
|
||||
|
|
|
@ -332,8 +332,8 @@ void WindowSDL::onGamepadEvent(const SDL_Event* event) {
|
|||
if (button != 0) {
|
||||
if (event->gbutton.button == SDL_GAMEPAD_BUTTON_BACK) {
|
||||
std::string backButtonBehavior = Config::getBackButtonBehavior();
|
||||
if (backButtonBehavior != "None") {
|
||||
float x = backButtonBehavior == "Touchpad Left" ? 0.25f : (backButtonBehavior == "Touchpad Right" ? 0.75f : 0.5f);
|
||||
if (backButtonBehavior != "none") {
|
||||
float x = backButtonBehavior == "left" ? 0.25f : (backButtonBehavior == "right" ? 0.75f : 0.5f);
|
||||
// trigger a touchpad event so that the touchpad emulation for back button works
|
||||
controller->SetTouchpadState(0, true, x, 0.5f);
|
||||
controller->CheckButton(0, button, event->type == SDL_EVENT_GAMEPAD_BUTTON_DOWN);
|
||||
|
|
Loading…
Add table
Reference in a new issue