configuration: Use buttons instead of highlights
Only for updated configs at the moment
This commit is contained in:
parent
d72ff01726
commit
39a1ffbb91
@ -2,119 +2,151 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <QBoxLayout>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QPushButton>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QStyle>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <qabstractbutton.h>
|
||||||
#include <qcheckbox.h>
|
#include <qcheckbox.h>
|
||||||
|
#include <qcombobox.h>
|
||||||
#include <qnamespace.h>
|
#include <qnamespace.h>
|
||||||
|
#include <qsizepolicy.h>
|
||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
#include "yuzu/configuration/configuration_shared.h"
|
#include "yuzu/configuration/configuration_shared.h"
|
||||||
#include "yuzu/configuration/configure_per_game.h"
|
#include "yuzu/configuration/configure_per_game.h"
|
||||||
#include "yuzu/configuration/shared_translation.h"
|
#include "yuzu/configuration/shared_translation.h"
|
||||||
|
|
||||||
namespace ConfigurationShared {
|
namespace ConfigurationShared {
|
||||||
|
|
||||||
|
static QPushButton* CreateClearGlobalButton(QWidget* parent, Settings::BasicSetting* setting) {
|
||||||
|
QStyle* style = parent->style();
|
||||||
|
QIcon* icon = new QIcon(style->standardIcon(QStyle::SP_DialogResetButton));
|
||||||
|
QPushButton* button = new QPushButton(*icon, QStringLiteral(""), parent);
|
||||||
|
button->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding);
|
||||||
|
|
||||||
|
QSizePolicy sp_retain = button->sizePolicy();
|
||||||
|
sp_retain.setRetainSizeWhenHidden(true);
|
||||||
|
button->setSizePolicy(sp_retain);
|
||||||
|
|
||||||
|
button->setEnabled(!setting->UsingGlobal());
|
||||||
|
button->setVisible(!setting->UsingGlobal());
|
||||||
|
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
static std::pair<QWidget*, std::function<void()>> CreateCheckBox(Settings::BasicSetting* setting,
|
static std::pair<QWidget*, std::function<void()>> CreateCheckBox(Settings::BasicSetting* setting,
|
||||||
const QString& label,
|
const QString& label,
|
||||||
QWidget* parent,
|
QWidget* parent,
|
||||||
std::list<CheckState>& trackers) {
|
std::list<CheckState>& trackers) {
|
||||||
|
QWidget* widget = new QWidget(parent);
|
||||||
|
QHBoxLayout* layout = new QHBoxLayout(widget);
|
||||||
|
|
||||||
QCheckBox* checkbox = new QCheckBox(label, parent);
|
QCheckBox* checkbox = new QCheckBox(label, parent);
|
||||||
checkbox->setObjectName(QString::fromStdString(setting->GetLabel()));
|
checkbox->setObjectName(QString::fromStdString(setting->GetLabel()));
|
||||||
checkbox->setCheckState(setting->ToString() == "true" ? Qt::CheckState::Checked
|
checkbox->setCheckState(setting->ToString() == "true" ? Qt::CheckState::Checked
|
||||||
: Qt::CheckState::Unchecked);
|
: Qt::CheckState::Unchecked);
|
||||||
|
|
||||||
CheckState* tracker{};
|
std::function<void()> load_func;
|
||||||
|
|
||||||
// Per-game config highlight
|
layout->addWidget(checkbox);
|
||||||
if (setting->Switchable() && !Settings::IsConfiguringGlobal()) {
|
|
||||||
bool global_state = setting->ToStringGlobal() == "true";
|
|
||||||
bool state = setting->ToString() == "true";
|
|
||||||
bool global = setting->UsingGlobal();
|
|
||||||
tracker = &trackers.emplace_front(CheckState{});
|
|
||||||
SetColoredTristate(checkbox, global, state, global_state, *tracker);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto load_func = [checkbox, setting, tracker]() {
|
|
||||||
if (Settings::IsConfiguringGlobal()) {
|
if (Settings::IsConfiguringGlobal()) {
|
||||||
|
load_func = [setting, checkbox]() {
|
||||||
setting->LoadString(checkbox->checkState() == Qt::Checked ? "true" : "false");
|
setting->LoadString(checkbox->checkState() == Qt::Checked ? "true" : "false");
|
||||||
}
|
};
|
||||||
|
|
||||||
if (Settings::IsConfiguringGlobal() || !setting->Switchable()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*tracker != CheckState::Global) {
|
|
||||||
setting->SetGlobal(false);
|
|
||||||
setting->LoadString(checkbox->checkState() == Qt::Checked ? "true" : "false");
|
|
||||||
} else {
|
} else {
|
||||||
setting->SetGlobal(true);
|
auto* button = CreateClearGlobalButton(parent, setting);
|
||||||
|
layout->addWidget(button);
|
||||||
|
|
||||||
|
QObject::connect(checkbox, &QCheckBox::stateChanged, [button](int) {
|
||||||
|
button->setVisible(true);
|
||||||
|
button->setEnabled(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
QObject::connect(button, &QAbstractButton::clicked, [checkbox, setting, button](bool) {
|
||||||
|
checkbox->setCheckState(setting->ToStringGlobal() == "true" ? Qt::Checked
|
||||||
|
: Qt::Unchecked);
|
||||||
|
button->setEnabled(false);
|
||||||
|
button->setVisible(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
load_func = [setting, checkbox, button]() {
|
||||||
|
bool using_global = !button->isEnabled();
|
||||||
|
setting->SetGlobal(using_global);
|
||||||
|
if (!using_global) {
|
||||||
|
setting->LoadString(checkbox->checkState() == Qt::Checked ? "true" : "false");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return {checkbox, load_func};
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
|
return {widget, load_func};
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::tuple<QWidget*, void*, std::function<void()>> CreateCombobox(
|
static std::tuple<QWidget*, QComboBox*, QPushButton*, std::function<void()>> CreateCombobox(
|
||||||
Settings::BasicSetting* setting, const QString& label, QWidget* parent, bool managed) {
|
Settings::BasicSetting* setting, const QString& label, QWidget* parent, bool managed) {
|
||||||
const auto type = setting->TypeId();
|
const auto type = setting->TypeId();
|
||||||
|
|
||||||
QWidget* group = new QWidget(parent);
|
QWidget* group = new QWidget(parent);
|
||||||
group->setObjectName(QString::fromStdString(setting->GetLabel()));
|
group->setObjectName(QString::fromStdString(setting->GetLabel()));
|
||||||
QLayout* combobox_layout = new QHBoxLayout(group);
|
QLayout* layout = new QHBoxLayout(group);
|
||||||
|
|
||||||
QLabel* qt_label = new QLabel(label, parent);
|
QLabel* qt_label = new QLabel(label, parent);
|
||||||
QComboBox* combobox = new QComboBox(parent);
|
QComboBox* combobox = new QComboBox(parent);
|
||||||
|
|
||||||
|
QPushButton* button{nullptr};
|
||||||
|
|
||||||
std::forward_list<QString> combobox_enumerations = ComboboxEnumeration(type, parent);
|
std::forward_list<QString> combobox_enumerations = ComboboxEnumeration(type, parent);
|
||||||
for (const auto& item : combobox_enumerations) {
|
for (const auto& item : combobox_enumerations) {
|
||||||
combobox->addItem(item);
|
combobox->addItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
combobox_layout->addWidget(qt_label);
|
layout->addWidget(qt_label);
|
||||||
combobox_layout->addWidget(combobox);
|
layout->addWidget(combobox);
|
||||||
|
|
||||||
combobox_layout->setSpacing(6);
|
layout->setSpacing(6);
|
||||||
combobox_layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
if (setting->Switchable() && !Settings::IsConfiguringGlobal() && managed) {
|
|
||||||
int current = std::stoi(setting->ToString());
|
|
||||||
int global_value = std::stoi(setting->ToStringGlobal());
|
|
||||||
SetColoredComboBox(combobox, group, global_value);
|
|
||||||
if (setting->UsingGlobal()) {
|
|
||||||
combobox->setCurrentIndex(USE_GLOBAL_INDEX);
|
|
||||||
} else {
|
|
||||||
SetHighlight(group, true);
|
|
||||||
combobox->setCurrentIndex(current + USE_GLOBAL_OFFSET);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
combobox->setCurrentIndex(std::stoi(setting->ToString()));
|
combobox->setCurrentIndex(std::stoi(setting->ToString()));
|
||||||
}
|
|
||||||
|
|
||||||
std::function<void()> load_func = []() {};
|
std::function<void()> load_func = []() {};
|
||||||
if (managed) {
|
|
||||||
load_func = [combobox, setting]() {
|
if (Settings::IsConfiguringGlobal() && managed) {
|
||||||
if (Settings::IsConfiguringGlobal()) {
|
load_func = [setting, combobox]() {
|
||||||
setting->LoadString(std::to_string(combobox->currentIndex()));
|
setting->LoadString(std::to_string(combobox->currentIndex()));
|
||||||
}
|
};
|
||||||
|
} else if (managed) {
|
||||||
|
button = CreateClearGlobalButton(parent, setting);
|
||||||
|
layout->addWidget(button);
|
||||||
|
|
||||||
if (Settings::IsConfiguringGlobal() || !setting->Switchable()) {
|
QObject::connect(button, &QAbstractButton::clicked, [button, combobox, setting](bool) {
|
||||||
return;
|
button->setEnabled(false);
|
||||||
}
|
button->setVisible(false);
|
||||||
|
|
||||||
bool using_global = combobox->currentIndex() == USE_GLOBAL_INDEX;
|
combobox->setCurrentIndex(std::stoi(setting->ToStringGlobal()));
|
||||||
int index = combobox->currentIndex() - USE_GLOBAL_OFFSET;
|
});
|
||||||
|
|
||||||
|
QObject::connect(combobox, QOverload<int>::of(&QComboBox::activated), [=](int) {
|
||||||
|
button->setEnabled(true);
|
||||||
|
button->setVisible(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
load_func = [setting, combobox, button]() {
|
||||||
|
bool using_global = !button->isEnabled();
|
||||||
setting->SetGlobal(using_global);
|
setting->SetGlobal(using_global);
|
||||||
if (!using_global) {
|
if (!using_global) {
|
||||||
setting->LoadString(std::to_string(index));
|
setting->LoadString(std::to_string(combobox->currentIndex()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {group, combobox, load_func};
|
return {group, combobox, button, load_func};
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::tuple<QWidget*, void*, std::function<void()>> CreateLineEdit(
|
static std::tuple<QWidget*, void*, std::function<void()>> CreateLineEdit(
|
||||||
@ -136,7 +168,7 @@ static std::tuple<QWidget*, void*, std::function<void()>> CreateLineEdit(
|
|||||||
q_label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
q_label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
layout->addWidget(q_label);
|
layout->addWidget(q_label);
|
||||||
|
|
||||||
load_func = [&]() {
|
load_func = [line_edit, setting]() {
|
||||||
std::string load_text = line_edit->text().toStdString();
|
std::string load_text = line_edit->text().toStdString();
|
||||||
setting->LoadString(load_text);
|
setting->LoadString(load_text);
|
||||||
};
|
};
|
||||||
@ -157,7 +189,7 @@ static std::tuple<QWidget*, void*, std::function<void()>> CreateLineEdit(
|
|||||||
checkbox->setCheckState(setting->UsingGlobal() ? Qt::Unchecked : Qt::Checked);
|
checkbox->setCheckState(setting->UsingGlobal() ? Qt::Unchecked : Qt::Checked);
|
||||||
highlight_func(checkbox->checkState());
|
highlight_func(checkbox->checkState());
|
||||||
|
|
||||||
load_func = [&]() {
|
load_func = [checkbox, setting, line_edit]() {
|
||||||
if (checkbox->checkState() == Qt::Checked) {
|
if (checkbox->checkState() == Qt::Checked) {
|
||||||
setting->SetGlobal(false);
|
setting->SetGlobal(false);
|
||||||
|
|
||||||
@ -176,12 +208,15 @@ static std::tuple<QWidget*, void*, std::function<void()>> CreateLineEdit(
|
|||||||
return {widget, line_edit, load_func};
|
return {widget, line_edit, load_func};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<QWidget*, void*> CreateWidget(Settings::BasicSetting* setting,
|
std::tuple<QWidget*, void*, QPushButton*> CreateWidget(
|
||||||
const TranslationMap& translations, QWidget* parent,
|
Settings::BasicSetting* setting, const TranslationMap& translations, QWidget* parent,
|
||||||
bool runtime_lock,
|
bool runtime_lock, std::forward_list<std::function<void(bool)>>& apply_funcs,
|
||||||
std::forward_list<std::function<void(bool)>>& apply_funcs,
|
std::list<CheckState>& trackers, RequestType request, bool managed) {
|
||||||
std::list<CheckState>& trackers, RequestType request,
|
if (!Settings::IsConfiguringGlobal() && !setting->Switchable()) {
|
||||||
bool managed) {
|
LOG_DEBUG(Frontend, "\"{}\" is not switchable, skipping...", setting->GetLabel());
|
||||||
|
return {nullptr, nullptr, nullptr};
|
||||||
|
}
|
||||||
|
|
||||||
const auto type = setting->TypeId();
|
const auto type = setting->TypeId();
|
||||||
const int id = setting->Id();
|
const int id = setting->Id();
|
||||||
QWidget* widget{nullptr};
|
QWidget* widget{nullptr};
|
||||||
@ -201,9 +236,11 @@ std::pair<QWidget*, void*> CreateWidget(Settings::BasicSetting* setting,
|
|||||||
if (label == QStringLiteral("")) {
|
if (label == QStringLiteral("")) {
|
||||||
LOG_DEBUG(Frontend, "Translation table has emtpy entry for \"{}\", skipping...",
|
LOG_DEBUG(Frontend, "Translation table has emtpy entry for \"{}\", skipping...",
|
||||||
setting->GetLabel());
|
setting->GetLabel());
|
||||||
return {nullptr, nullptr};
|
return {nullptr, nullptr, nullptr};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPushButton* button;
|
||||||
|
|
||||||
if (type == typeid(bool)) {
|
if (type == typeid(bool)) {
|
||||||
auto pair = CreateCheckBox(setting, label, parent, trackers);
|
auto pair = CreateCheckBox(setting, label, parent, trackers);
|
||||||
widget = pair.first;
|
widget = pair.first;
|
||||||
@ -212,7 +249,8 @@ std::pair<QWidget*, void*> CreateWidget(Settings::BasicSetting* setting,
|
|||||||
auto tuple = CreateCombobox(setting, label, parent, managed);
|
auto tuple = CreateCombobox(setting, label, parent, managed);
|
||||||
widget = std::get<0>(tuple);
|
widget = std::get<0>(tuple);
|
||||||
extra = std::get<1>(tuple);
|
extra = std::get<1>(tuple);
|
||||||
load_func = std::get<2>(tuple);
|
button = std::get<2>(tuple);
|
||||||
|
load_func = std::get<3>(tuple);
|
||||||
} else if (type == typeid(u32) || type == typeid(int)) {
|
} else if (type == typeid(u32) || type == typeid(int)) {
|
||||||
switch (request) {
|
switch (request) {
|
||||||
case RequestType::Default: {
|
case RequestType::Default: {
|
||||||
@ -226,7 +264,8 @@ std::pair<QWidget*, void*> CreateWidget(Settings::BasicSetting* setting,
|
|||||||
auto tuple = CreateCombobox(setting, label, parent, managed);
|
auto tuple = CreateCombobox(setting, label, parent, managed);
|
||||||
widget = std::get<0>(tuple);
|
widget = std::get<0>(tuple);
|
||||||
extra = std::get<1>(tuple);
|
extra = std::get<1>(tuple);
|
||||||
load_func = std::get<2>(tuple);
|
button = std::get<2>(tuple);
|
||||||
|
load_func = std::get<3>(tuple);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RequestType::SpinBox:
|
case RequestType::SpinBox:
|
||||||
@ -238,7 +277,7 @@ std::pair<QWidget*, void*> CreateWidget(Settings::BasicSetting* setting,
|
|||||||
|
|
||||||
if (widget == nullptr) {
|
if (widget == nullptr) {
|
||||||
LOG_ERROR(Frontend, "No widget was created for \"{}\"", setting->GetLabel());
|
LOG_ERROR(Frontend, "No widget was created for \"{}\"", setting->GetLabel());
|
||||||
return {nullptr, nullptr};
|
return {nullptr, nullptr, nullptr};
|
||||||
}
|
}
|
||||||
|
|
||||||
apply_funcs.push_front([load_func, setting](bool powered_on) {
|
apply_funcs.push_front([load_func, setting](bool powered_on) {
|
||||||
@ -257,7 +296,7 @@ std::pair<QWidget*, void*> CreateWidget(Settings::BasicSetting* setting,
|
|||||||
|
|
||||||
widget->setToolTip(tooltip);
|
widget->setToolTip(tooltip);
|
||||||
|
|
||||||
return {widget, extra};
|
return {widget, extra, button};
|
||||||
}
|
}
|
||||||
|
|
||||||
Tab::Tab(std::shared_ptr<std::forward_list<Tab*>> group_, QWidget* parent)
|
Tab::Tab(std::shared_ptr<std::forward_list<Tab*>> group_, QWidget* parent)
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
#include "yuzu/configuration/shared_translation.h"
|
#include "yuzu/configuration/shared_translation.h"
|
||||||
|
|
||||||
|
class QPushButton;
|
||||||
|
|
||||||
namespace ConfigurationShared {
|
namespace ConfigurationShared {
|
||||||
|
|
||||||
class Tab : public QWidget {
|
class Tab : public QWidget {
|
||||||
@ -49,12 +51,10 @@ enum class RequestType {
|
|||||||
MaxEnum,
|
MaxEnum,
|
||||||
};
|
};
|
||||||
|
|
||||||
std::pair<QWidget*, void*> CreateWidget(Settings::BasicSetting* setting,
|
std::tuple<QWidget*, void*, QPushButton*> CreateWidget(
|
||||||
const TranslationMap& translations, QWidget* parent,
|
Settings::BasicSetting* setting, const TranslationMap& translations, QWidget* parent,
|
||||||
bool runtime_lock,
|
bool runtime_lock, std::forward_list<std::function<void(bool)>>& apply_funcs,
|
||||||
std::forward_list<std::function<void(bool)>>& apply_funcs,
|
std::list<CheckState>& trackers, RequestType request = RequestType::Default,
|
||||||
std::list<CheckState>& trackers,
|
|
||||||
RequestType request = RequestType::Default,
|
|
||||||
bool managed = true);
|
bool managed = true);
|
||||||
|
|
||||||
// Global-aware apply and set functions
|
// Global-aware apply and set functions
|
||||||
|
@ -139,8 +139,8 @@ void ConfigureGeneral::SetupPerGameUI() {
|
|||||||
|
|
||||||
ui->button_reset_defaults->setVisible(false);
|
ui->button_reset_defaults->setVisible(false);
|
||||||
|
|
||||||
ConfigurationShared::SetColoredTristate(ui->toggle_speed_limit,
|
// ConfigurationShared::SetColoredTristate(ui->toggle_speed_limit,
|
||||||
Settings::values.use_speed_limit, use_speed_limit);
|
// Settings::values.use_speed_limit, use_speed_limit);
|
||||||
ConfigurationShared::SetColoredTristate(ui->use_multi_core, Settings::values.use_multi_core,
|
ConfigurationShared::SetColoredTristate(ui->use_multi_core, Settings::values.use_multi_core,
|
||||||
use_multi_core);
|
use_multi_core);
|
||||||
|
|
||||||
|
@ -20,8 +20,11 @@
|
|||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
#include <QStringLiteral>
|
#include <QStringLiteral>
|
||||||
#include <QtCore/qobjectdefs.h>
|
#include <QtCore/qobjectdefs.h>
|
||||||
|
#include <qabstractbutton.h>
|
||||||
|
#include <qboxlayout.h>
|
||||||
#include <qcoreevent.h>
|
#include <qcoreevent.h>
|
||||||
#include <qglobal.h>
|
#include <qglobal.h>
|
||||||
|
#include <qgridlayout.h>
|
||||||
#include <vulkan/vulkan_core.h>
|
#include <vulkan/vulkan_core.h>
|
||||||
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
@ -112,7 +115,7 @@ ConfigureGraphics::ConfigureGraphics(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(api_combobox, qOverload<int>(&QComboBox::currentIndexChanged), this, [this] {
|
connect(api_combobox, qOverload<int>(&QComboBox::activated), this, [this] {
|
||||||
UpdateAPILayout();
|
UpdateAPILayout();
|
||||||
PopulateVSyncModeSelection();
|
PopulateVSyncModeSelection();
|
||||||
});
|
});
|
||||||
@ -146,6 +149,10 @@ ConfigureGraphics::ConfigureGraphics(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureGraphics::PopulateVSyncModeSelection() {
|
void ConfigureGraphics::PopulateVSyncModeSelection() {
|
||||||
|
if (!Settings::IsConfiguringGlobal()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const Settings::RendererBackend backend{GetCurrentGraphicsBackend()};
|
const Settings::RendererBackend backend{GetCurrentGraphicsBackend()};
|
||||||
if (backend == Settings::RendererBackend::Null) {
|
if (backend == Settings::RendererBackend::Null) {
|
||||||
vsync_mode_combobox->setEnabled(false);
|
vsync_mode_combobox->setEnabled(false);
|
||||||
@ -204,7 +211,12 @@ ConfigureGraphics::~ConfigureGraphics() = default;
|
|||||||
|
|
||||||
void ConfigureGraphics::SetConfiguration() {
|
void ConfigureGraphics::SetConfiguration() {
|
||||||
const bool runtime_lock = !system.IsPoweredOn();
|
const bool runtime_lock = !system.IsPoweredOn();
|
||||||
QLayout& api_layout = *ui->api_widget->layout();
|
QLayout* api_layout = ui->api_widget->layout();
|
||||||
|
QWidget* api_grid_widget = new QWidget(this);
|
||||||
|
QVBoxLayout* api_grid_layout = new QVBoxLayout(api_grid_widget);
|
||||||
|
api_grid_layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
api_layout->addWidget(api_grid_widget);
|
||||||
|
|
||||||
QLayout& graphics_layout = *ui->graphics_widget->layout();
|
QLayout& graphics_layout = *ui->graphics_widget->layout();
|
||||||
|
|
||||||
std::map<bool, std::map<std::string, QWidget*>> hold_graphics;
|
std::map<bool, std::map<std::string, QWidget*>> hold_graphics;
|
||||||
@ -213,7 +225,7 @@ void ConfigureGraphics::SetConfiguration() {
|
|||||||
for (const auto setting : Settings::values.linkage.by_category[Settings::Category::Renderer]) {
|
for (const auto setting : Settings::values.linkage.by_category[Settings::Category::Renderer]) {
|
||||||
const auto& setting_label = setting->GetLabel();
|
const auto& setting_label = setting->GetLabel();
|
||||||
|
|
||||||
auto [widget, extra] = [&]() {
|
auto [widget, extra, button] = [&]() {
|
||||||
if (setting->Id() == Settings::values.vulkan_device.Id() ||
|
if (setting->Id() == Settings::values.vulkan_device.Id() ||
|
||||||
setting->Id() == Settings::values.shader_backend.Id() ||
|
setting->Id() == Settings::values.shader_backend.Id() ||
|
||||||
setting->Id() == Settings::values.vsync_mode.Id()) {
|
setting->Id() == Settings::values.vsync_mode.Id()) {
|
||||||
@ -230,8 +242,20 @@ void ConfigureGraphics::SetConfiguration() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setting->Id() == Settings::values.vulkan_device.Id()) {
|
if (setting->Id() == Settings::values.renderer_backend.Id()) {
|
||||||
api_layout.addWidget(widget);
|
api_grid_layout->addWidget(widget);
|
||||||
|
api_combobox = reinterpret_cast<QComboBox*>(extra);
|
||||||
|
api_restore_global_button = button;
|
||||||
|
|
||||||
|
if (!Settings::IsConfiguringGlobal()) {
|
||||||
|
QObject::connect(api_restore_global_button, &QAbstractButton::clicked,
|
||||||
|
[=](bool) { UpdateAPILayout(); });
|
||||||
|
|
||||||
|
widget->layout()->removeWidget(api_restore_global_button);
|
||||||
|
api_layout->addWidget(api_restore_global_button);
|
||||||
|
}
|
||||||
|
} else if (setting->Id() == Settings::values.vulkan_device.Id()) {
|
||||||
|
api_layout->addWidget(widget);
|
||||||
api_combobox = reinterpret_cast<QComboBox*>(extra);
|
api_combobox = reinterpret_cast<QComboBox*>(extra);
|
||||||
} else if (setting->Id() == Settings::values.vulkan_device.Id()) {
|
} else if (setting->Id() == Settings::values.vulkan_device.Id()) {
|
||||||
hold_api.push_front(widget);
|
hold_api.push_front(widget);
|
||||||
@ -256,7 +280,7 @@ void ConfigureGraphics::SetConfiguration() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (auto widget : hold_api) {
|
for (auto widget : hold_api) {
|
||||||
api_layout.addWidget(widget);
|
api_grid_layout->addWidget(widget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,6 +321,25 @@ void ConfigureGraphics::ApplyConfiguration() {
|
|||||||
const auto vsync_mode = PresentModeToSetting(mode);
|
const auto vsync_mode = PresentModeToSetting(mode);
|
||||||
Settings::values.vsync_mode.SetValue(vsync_mode);
|
Settings::values.vsync_mode.SetValue(vsync_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Settings::values.shader_backend.SetGlobal(true);
|
||||||
|
Settings::values.vulkan_device.SetGlobal(true);
|
||||||
|
if (!Settings::IsConfiguringGlobal() && api_restore_global_button->isEnabled()) {
|
||||||
|
auto backend = static_cast<Settings::RendererBackend>(api_combobox->currentIndex());
|
||||||
|
switch (backend) {
|
||||||
|
case Settings::RendererBackend::OpenGL:
|
||||||
|
Settings::values.shader_backend.SetGlobal(false);
|
||||||
|
Settings::values.shader_backend.SetValue(
|
||||||
|
static_cast<Settings::ShaderBackend>(shader_backend_combobox->currentIndex()));
|
||||||
|
break;
|
||||||
|
case Settings::RendererBackend::Vulkan:
|
||||||
|
Settings::values.vulkan_device.SetGlobal(false);
|
||||||
|
Settings::values.vulkan_device.SetValue(vulkan_device_combobox->currentIndex());
|
||||||
|
break;
|
||||||
|
case Settings::RendererBackend::Null:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureGraphics::changeEvent(QEvent* event) {
|
void ConfigureGraphics::changeEvent(QEvent* event) {
|
||||||
@ -322,8 +365,7 @@ void ConfigureGraphics::UpdateBackgroundColorButton(QColor color) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureGraphics::UpdateAPILayout() {
|
void ConfigureGraphics::UpdateAPILayout() {
|
||||||
if (!Settings::IsConfiguringGlobal() &&
|
if (!Settings::IsConfiguringGlobal() && !api_restore_global_button->isEnabled()) {
|
||||||
api_combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) {
|
|
||||||
vulkan_device = Settings::values.vulkan_device.GetValue(true);
|
vulkan_device = Settings::values.vulkan_device.GetValue(true);
|
||||||
shader_backend = Settings::values.shader_backend.GetValue(true);
|
shader_backend = Settings::values.shader_backend.GetValue(true);
|
||||||
vulkan_device_widget->setEnabled(false);
|
vulkan_device_widget->setEnabled(false);
|
||||||
@ -371,15 +413,8 @@ void ConfigureGraphics::RetrieveVulkanDevices() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Settings::RendererBackend ConfigureGraphics::GetCurrentGraphicsBackend() const {
|
Settings::RendererBackend ConfigureGraphics::GetCurrentGraphicsBackend() const {
|
||||||
if (Settings::IsConfiguringGlobal()) {
|
if (!Settings::IsConfiguringGlobal() && !api_restore_global_button->isEnabled()) {
|
||||||
|
return Settings::values.renderer_backend.GetValue(true);
|
||||||
|
}
|
||||||
return static_cast<Settings::RendererBackend>(api_combobox->currentIndex());
|
return static_cast<Settings::RendererBackend>(api_combobox->currentIndex());
|
||||||
}
|
|
||||||
|
|
||||||
if (api_combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) {
|
|
||||||
Settings::values.renderer_backend.SetGlobal(true);
|
|
||||||
return Settings::values.renderer_backend.GetValue();
|
|
||||||
}
|
|
||||||
Settings::values.renderer_backend.SetGlobal(false);
|
|
||||||
return static_cast<Settings::RendererBackend>(api_combobox->currentIndex() -
|
|
||||||
ConfigurationShared::USE_GLOBAL_OFFSET);
|
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,7 @@ private:
|
|||||||
const Core::System& system;
|
const Core::System& system;
|
||||||
const ConfigurationShared::TranslationMap& translations;
|
const ConfigurationShared::TranslationMap& translations;
|
||||||
|
|
||||||
|
QPushButton* api_restore_global_button;
|
||||||
QComboBox* vulkan_device_combobox;
|
QComboBox* vulkan_device_combobox;
|
||||||
QComboBox* api_combobox;
|
QComboBox* api_combobox;
|
||||||
QComboBox* shader_backend_combobox;
|
QComboBox* shader_backend_combobox;
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" name="api_widget" native="true">
|
<widget class="QWidget" name="api_widget" native="true">
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
@ -40,9 +40,6 @@
|
|||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="horizontalSpacing">
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -63,7 +60,20 @@
|
|||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" name="graphics_widget" native="true">
|
<widget class="QWidget" name="graphics_widget" native="true">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout"/>
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -32,7 +32,7 @@ void ConfigureGraphicsAdvanced::SetConfiguration() {
|
|||||||
|
|
||||||
for (auto setting :
|
for (auto setting :
|
||||||
Settings::values.linkage.by_category[Settings::Category::RendererAdvanced]) {
|
Settings::values.linkage.by_category[Settings::Category::RendererAdvanced]) {
|
||||||
auto [widget, extra] = ConfigurationShared::CreateWidget(
|
auto [widget, extra, button] = ConfigurationShared::CreateWidget(
|
||||||
setting, translations, this, runtime_lock, apply_funcs, trackers);
|
setting, translations, this, runtime_lock, apply_funcs, trackers);
|
||||||
|
|
||||||
if (widget == nullptr) {
|
if (widget == nullptr) {
|
||||||
|
@ -27,7 +27,20 @@
|
|||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" name="populate_target" native="true">
|
<widget class="QWidget" name="populate_target" native="true">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout"/>
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -93,6 +93,9 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent) {
|
|||||||
"Enable compute pipelines, required by some games.\nThis setting only exists for Intel "
|
"Enable compute pipelines, required by some games.\nThis setting only exists for Intel "
|
||||||
"proprietary drivers, and may crash if enabled.\nCompute pipelines are always enabled "
|
"proprietary drivers, and may crash if enabled.\nCompute pipelines are always enabled "
|
||||||
"on all other drivers.");
|
"on all other drivers.");
|
||||||
|
INSERT(use_reactive_flushing, "Enable Reactive Flushing",
|
||||||
|
"Uses reactive flushing instead of predictive flushing, allowing more accurate memory "
|
||||||
|
"syncing.");
|
||||||
|
|
||||||
// Renderer (Debug)
|
// Renderer (Debug)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user