48ee112ceb
* common: Move settings to common from core. - Removes a dependency on core and input_common from common. * code: Wrap settings values * Port from yuzu to allow per game settings * citra_qt: Initial per-game settings dialog * citra_qt: Use new API for read/save of config values * citra_qt: Per game audio settings * citra_qt: Per game graphics settings * citra_qt: Per game system settings * citra_qt: Per game general settings * citra_qt: Document and run clang format * citra_qt: Make icon smaller and centered * citra_qt: Remove version number * Not sure how to extract that, can always add it back later * citra_qt: Wrap UISettings * citra_qt: Fix unthottled fps setting * citra_qt: Remove margin in emulation tab * citra_qt: Implement some suggestions * Bring back speed switch hotkey * Allow configuration when game is running * Rename/adjust UI stuff * citra_qt: Fix build with separate windows * citra_qt: Address feedback * citra_qt: Log per-game settings before launching games * citra_qt: Add shader cache options * Also fix android build * citra_qt: Add DLC menu option * citra_qt: Run clang-format * citra_qt: Adjust for time offset * citra_qt: Implement suggestions * Run clang-format Co-authored-by: bunnei <bunneidev@gmail.com>
96 lines
4.1 KiB
C++
96 lines
4.1 KiB
C++
// Copyright 2020 yuzu Emulator Project
|
|
// Licensed under GPLv2 or any later version
|
|
// Refer to the license.txt file included.
|
|
|
|
#include <QCheckBox>
|
|
#include <QObject>
|
|
#include <QString>
|
|
#include "citra_qt/configuration/configuration_shared.h"
|
|
#include "citra_qt/configuration/configure_per_game.h"
|
|
#include "common/settings.h"
|
|
|
|
void ConfigurationShared::ApplyPerGameSetting(Settings::SwitchableSetting<bool>* setting,
|
|
const QCheckBox* checkbox,
|
|
const CheckState& tracker) {
|
|
if (Settings::IsConfiguringGlobal() && setting->UsingGlobal()) {
|
|
setting->SetValue(checkbox->checkState());
|
|
} else if (!Settings::IsConfiguringGlobal()) {
|
|
if (tracker == CheckState::Global) {
|
|
setting->SetGlobal(true);
|
|
} else {
|
|
setting->SetGlobal(false);
|
|
setting->SetValue(checkbox->checkState());
|
|
}
|
|
}
|
|
}
|
|
|
|
void ConfigurationShared::SetPerGameSetting(QCheckBox* checkbox,
|
|
const Settings::SwitchableSetting<bool>* setting) {
|
|
if (setting->UsingGlobal()) {
|
|
checkbox->setCheckState(Qt::PartiallyChecked);
|
|
} else {
|
|
checkbox->setCheckState(setting->GetValue() ? Qt::Checked : Qt::Unchecked);
|
|
}
|
|
}
|
|
|
|
void ConfigurationShared::SetHighlight(QWidget* widget, bool highlighted) {
|
|
if (highlighted) {
|
|
widget->setStyleSheet(QStringLiteral("QWidget#%1 { background-color:rgba(0,203,255,0.5) }")
|
|
.arg(widget->objectName()));
|
|
} else {
|
|
widget->setStyleSheet(QStringLiteral("QWidget#%1 { background-color:rgba(0,0,0,0) }")
|
|
.arg(widget->objectName()));
|
|
}
|
|
widget->show();
|
|
}
|
|
|
|
void ConfigurationShared::SetColoredTristate(QCheckBox* checkbox,
|
|
const Settings::SwitchableSetting<bool>& setting,
|
|
CheckState& tracker) {
|
|
if (setting.UsingGlobal()) {
|
|
tracker = CheckState::Global;
|
|
} else {
|
|
tracker = (setting.GetValue() == setting.GetValue(true)) ? CheckState::On : CheckState::Off;
|
|
}
|
|
SetHighlight(checkbox, tracker != CheckState::Global);
|
|
QObject::connect(checkbox, &QCheckBox::clicked, checkbox, [checkbox, setting, &tracker] {
|
|
tracker = static_cast<CheckState>((static_cast<int>(tracker) + 1) %
|
|
static_cast<int>(CheckState::Count));
|
|
if (tracker == CheckState::Global) {
|
|
checkbox->setChecked(setting.GetValue(true));
|
|
}
|
|
SetHighlight(checkbox, tracker != CheckState::Global);
|
|
});
|
|
}
|
|
|
|
void ConfigurationShared::SetColoredTristate(QCheckBox* checkbox, bool global, bool state,
|
|
bool global_state, CheckState& tracker) {
|
|
if (global) {
|
|
tracker = CheckState::Global;
|
|
} else {
|
|
tracker = (state == global_state) ? CheckState::On : CheckState::Off;
|
|
}
|
|
SetHighlight(checkbox, tracker != CheckState::Global);
|
|
QObject::connect(checkbox, &QCheckBox::clicked, checkbox, [checkbox, global_state, &tracker] {
|
|
tracker = static_cast<CheckState>((static_cast<int>(tracker) + 1) %
|
|
static_cast<int>(CheckState::Count));
|
|
if (tracker == CheckState::Global) {
|
|
checkbox->setChecked(global_state);
|
|
}
|
|
SetHighlight(checkbox, tracker != CheckState::Global);
|
|
});
|
|
}
|
|
|
|
void ConfigurationShared::SetColoredComboBox(QComboBox* combobox, QWidget* target, int global) {
|
|
InsertGlobalItem(combobox, global);
|
|
QObject::connect(combobox, qOverload<int>(&QComboBox::activated), target,
|
|
[target](int index) { SetHighlight(target, index != 0); });
|
|
}
|
|
|
|
void ConfigurationShared::InsertGlobalItem(QComboBox* combobox, int global_index) {
|
|
const QString use_global_text =
|
|
ConfigurePerGame::tr("Use global configuration (%1)").arg(combobox->itemText(global_index));
|
|
combobox->insertItem(ConfigurationShared::USE_GLOBAL_INDEX, use_global_text);
|
|
combobox->insertSeparator(ConfigurationShared::USE_GLOBAL_SEPARATOR_INDEX);
|
|
}
|