2017-06-15 23:42:12 +00:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2017-06-15 23:42:12 +00:00
|
|
|
|
2018-07-06 22:40:15 +00:00
|
|
|
#include "DolphinQt/Config/Graphics/GraphicsWindow.h"
|
2017-06-15 23:42:12 +00:00
|
|
|
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
#include <QEvent>
|
|
|
|
#include <QGroupBox>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QTabWidget>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
2020-05-03 23:21:51 +00:00
|
|
|
#include "Common/Config/Config.h"
|
|
|
|
#include "Core/Config/MainSettings.h"
|
2017-06-15 23:42:12 +00:00
|
|
|
#include "Core/ConfigManager.h"
|
2018-05-19 15:44:22 +00:00
|
|
|
|
2018-07-06 22:40:15 +00:00
|
|
|
#include "DolphinQt/Config/Graphics/AdvancedWidget.h"
|
|
|
|
#include "DolphinQt/Config/Graphics/EnhancementsWidget.h"
|
|
|
|
#include "DolphinQt/Config/Graphics/GeneralWidget.h"
|
|
|
|
#include "DolphinQt/Config/Graphics/HacksWidget.h"
|
|
|
|
#include "DolphinQt/Config/Graphics/SoftwareRendererWidget.h"
|
|
|
|
#include "DolphinQt/MainWindow.h"
|
|
|
|
#include "DolphinQt/QtUtils/WrapInScrollArea.h"
|
2018-05-19 15:44:22 +00:00
|
|
|
|
|
|
|
#include "VideoCommon/VideoBackendBase.h"
|
2018-05-08 15:20:08 +00:00
|
|
|
#include "VideoCommon/VideoConfig.h"
|
2017-06-15 23:42:12 +00:00
|
|
|
|
|
|
|
GraphicsWindow::GraphicsWindow(X11Utils::XRRConfiguration* xrr_config, MainWindow* parent)
|
|
|
|
: QDialog(parent), m_xrr_config(xrr_config)
|
|
|
|
{
|
|
|
|
CreateMainLayout();
|
|
|
|
|
|
|
|
setWindowTitle(tr("Graphics"));
|
2017-09-04 17:50:24 +00:00
|
|
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
2017-06-15 23:42:12 +00:00
|
|
|
|
2020-05-03 23:21:51 +00:00
|
|
|
OnBackendChanged(QString::fromStdString(Config::Get(Config::MAIN_GFX_BACKEND)));
|
2017-06-15 23:42:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsWindow::CreateMainLayout()
|
|
|
|
{
|
|
|
|
auto* main_layout = new QVBoxLayout();
|
|
|
|
m_tab_widget = new QTabWidget();
|
2018-03-20 09:12:11 +00:00
|
|
|
m_button_box = new QDialogButtonBox(QDialogButtonBox::Close);
|
|
|
|
|
|
|
|
connect(m_button_box, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
2017-06-15 23:42:12 +00:00
|
|
|
|
|
|
|
main_layout->addWidget(m_tab_widget);
|
|
|
|
main_layout->addWidget(m_button_box);
|
|
|
|
|
2017-06-15 23:43:14 +00:00
|
|
|
m_general_widget = new GeneralWidget(m_xrr_config, this);
|
|
|
|
m_enhancements_widget = new EnhancementsWidget(this);
|
|
|
|
m_hacks_widget = new HacksWidget(this);
|
|
|
|
m_advanced_widget = new AdvancedWidget(this);
|
|
|
|
m_software_renderer = new SoftwareRendererWidget(this);
|
2017-06-15 23:42:12 +00:00
|
|
|
|
2017-06-15 23:43:14 +00:00
|
|
|
connect(m_general_widget, &GeneralWidget::BackendChanged, this,
|
|
|
|
&GraphicsWindow::OnBackendChanged);
|
|
|
|
connect(m_software_renderer, &SoftwareRendererWidget::BackendChanged, this,
|
|
|
|
&GraphicsWindow::OnBackendChanged);
|
2017-06-15 23:42:12 +00:00
|
|
|
|
2020-10-21 03:14:06 +00:00
|
|
|
m_wrapped_general = GetWrappedWidget(m_general_widget, this, 50, 100);
|
|
|
|
m_wrapped_enhancements = GetWrappedWidget(m_enhancements_widget, this, 50, 100);
|
|
|
|
m_wrapped_hacks = GetWrappedWidget(m_hacks_widget, this, 50, 100);
|
|
|
|
m_wrapped_advanced = GetWrappedWidget(m_advanced_widget, this, 50, 100);
|
|
|
|
m_wrapped_software = GetWrappedWidget(m_software_renderer, this, 50, 100);
|
2018-05-08 15:39:03 +00:00
|
|
|
|
2020-05-03 23:21:51 +00:00
|
|
|
if (Config::Get(Config::MAIN_GFX_BACKEND) != "Software Renderer")
|
2017-06-15 23:43:14 +00:00
|
|
|
{
|
2018-05-08 15:39:03 +00:00
|
|
|
m_tab_widget->addTab(m_wrapped_general, tr("General"));
|
|
|
|
m_tab_widget->addTab(m_wrapped_enhancements, tr("Enhancements"));
|
|
|
|
m_tab_widget->addTab(m_wrapped_hacks, tr("Hacks"));
|
|
|
|
m_tab_widget->addTab(m_wrapped_advanced, tr("Advanced"));
|
2017-06-15 23:43:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-05-08 15:39:03 +00:00
|
|
|
m_tab_widget->addTab(m_wrapped_software, tr("Software Renderer"));
|
2017-06-15 23:43:14 +00:00
|
|
|
}
|
2017-06-15 23:42:12 +00:00
|
|
|
|
|
|
|
setLayout(main_layout);
|
|
|
|
}
|
|
|
|
|
2018-05-19 15:52:53 +00:00
|
|
|
void GraphicsWindow::OnBackendChanged(const QString& backend_name)
|
2017-06-15 23:42:12 +00:00
|
|
|
{
|
2020-05-03 23:21:51 +00:00
|
|
|
Config::SetBase(Config::MAIN_GFX_BACKEND, backend_name.toStdString());
|
|
|
|
VideoBackendBase::PopulateBackendInfoFromUI();
|
2018-05-19 15:52:53 +00:00
|
|
|
|
2018-06-30 08:28:45 +00:00
|
|
|
setWindowTitle(
|
|
|
|
tr("%1 Graphics Configuration").arg(tr(g_video_backend->GetDisplayName().c_str())));
|
2018-05-19 15:52:53 +00:00
|
|
|
if (backend_name == QStringLiteral("Software Renderer") && m_tab_widget->count() > 1)
|
2017-06-15 23:43:14 +00:00
|
|
|
{
|
|
|
|
m_tab_widget->clear();
|
2018-05-08 15:39:03 +00:00
|
|
|
m_tab_widget->addTab(m_wrapped_software, tr("Software Renderer"));
|
2017-06-15 23:43:14 +00:00
|
|
|
}
|
|
|
|
|
2018-05-19 15:52:53 +00:00
|
|
|
if (backend_name != QStringLiteral("Software Renderer") && m_tab_widget->count() == 1)
|
2017-06-15 23:43:14 +00:00
|
|
|
{
|
|
|
|
m_tab_widget->clear();
|
2018-05-08 15:39:03 +00:00
|
|
|
m_tab_widget->addTab(m_wrapped_general, tr("General"));
|
|
|
|
m_tab_widget->addTab(m_wrapped_enhancements, tr("Enhancements"));
|
|
|
|
m_tab_widget->addTab(m_wrapped_hacks, tr("Hacks"));
|
|
|
|
m_tab_widget->addTab(m_wrapped_advanced, tr("Advanced"));
|
2017-06-15 23:43:14 +00:00
|
|
|
}
|
|
|
|
|
2018-05-19 15:52:53 +00:00
|
|
|
emit BackendChanged(backend_name);
|
2017-06-15 23:42:12 +00:00
|
|
|
}
|