yuzu-emu
/
yuzu-android
Archived
1
0
Fork 0

Merge pull request #1944 from FearlessTobi/port-4187

Port citra-emu/citra#4187: "Qt/Configure: Use sidebar to divide tabs into smaller groups"
This commit is contained in:
bunnei 2019-01-02 17:24:38 -05:00 committed by GitHub
commit 6a0e258dde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 124 additions and 59 deletions

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>461</width> <width>382</width>
<height>659</height> <height>241</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -15,51 +15,71 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="currentIndex"> <item>
<number>0</number> <widget class="QListWidget" name="selectorList">
</property> <property name="minimumSize">
<widget class="ConfigureGeneral" name="generalTab"> <size>
<attribute name="title"> <width>150</width>
<string>General</string> <height>0</height>
</attribute> </size>
</widget> </property>
<widget class="ConfigureGameList" name="gameListTab"> <property name="maximumSize">
<attribute name="title"> <size>
<string>Game List</string> <width>150</width>
</attribute> <height>16777215</height>
</widget> </size>
<widget class="ConfigureSystem" name="systemTab"> </property>
<attribute name="title"> </widget>
<string>System</string> </item>
</attribute> <item>
</widget> <widget class="QTabWidget" name="tabWidget">
<widget class="ConfigureInputSimple" name="inputTab"> <property name="currentIndex">
<attribute name="title"> <number>0</number>
<string>Input</string> </property>
</attribute> <widget class="ConfigureGeneral" name="generalTab">
</widget> <attribute name="title">
<widget class="ConfigureGraphics" name="graphicsTab"> <string>General</string>
<attribute name="title"> </attribute>
<string>Graphics</string> </widget>
</attribute> <widget class="ConfigureGameList" name="gameListTab">
</widget> <attribute name="title">
<widget class="ConfigureAudio" name="audioTab"> <string>Game List</string>
<attribute name="title"> </attribute>
<string>Audio</string> </widget>
</attribute> <widget class="ConfigureSystem" name="systemTab">
</widget> <attribute name="title">
<widget class="ConfigureDebug" name="debugTab"> <string>System</string>
<attribute name="title"> </attribute>
<string>Debug</string> </widget>
</attribute> <widget class="ConfigureInputSimple" name="inputTab">
</widget> <attribute name="title">
<widget class="ConfigureWeb" name="webTab"> <string>Input</string>
<attribute name="title"> </attribute>
<string>Web</string> </widget>
</attribute> <widget class="ConfigureGraphics" name="graphicsTab">
</widget> <attribute name="title">
</widget> <string>Graphics</string>
</attribute>
</widget>
<widget class="ConfigureAudio" name="audioTab">
<attribute name="title">
<string>Audio</string>
</attribute>
</widget>
<widget class="ConfigureDebug" name="debugTab">
<attribute name="title">
<string>Debug</string>
</attribute>
</widget>
<widget class="ConfigureWeb" name="webTab">
<attribute name="title">
<string>Web</string>
</attribute>
</widget>
</widget>
</item>
</layout>
</item> </item>
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
@ -77,12 +97,6 @@
<header>configuration/configure_general.h</header> <header>configuration/configure_general.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>ConfigureGameList</class>
<extends>QWidget</extends>
<header>configuration/configure_gamelist.h</header>
<container>1</container>
</customwidget>
<customwidget> <customwidget>
<class>ConfigureSystem</class> <class>ConfigureSystem</class>
<extends>QWidget</extends> <extends>QWidget</extends>
@ -101,12 +115,6 @@
<header>configuration/configure_debug.h</header> <header>configuration/configure_debug.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>ConfigureInputSimple</class>
<extends>QWidget</extends>
<header>configuration/configure_input_simple.h</header>
<container>1</container>
</customwidget>
<customwidget> <customwidget>
<class>ConfigureGraphics</class> <class>ConfigureGraphics</class>
<extends>QWidget</extends> <extends>QWidget</extends>
@ -119,6 +127,18 @@
<header>configuration/configure_web.h</header> <header>configuration/configure_web.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>ConfigureGameList</class>
<extends>QWidget</extends>
<header>configuration/configure_gamelist.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ConfigureInputSimple</class>
<extends>QWidget</extends>
<header>configuration/configure_input_simple.h</header>
<container>1</container>
</customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections> <connections>

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <QHash>
#include <QListWidgetItem>
#include "core/settings.h" #include "core/settings.h"
#include "ui_configure.h" #include "ui_configure.h"
#include "yuzu/configuration/config.h" #include "yuzu/configuration/config.h"
@ -13,6 +15,13 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, const HotkeyRegistry& registry
ui->setupUi(this); ui->setupUi(this);
ui->generalTab->PopulateHotkeyList(registry); ui->generalTab->PopulateHotkeyList(registry);
this->setConfiguration(); this->setConfiguration();
this->PopulateSelectionList();
connect(ui->selectorList, &QListWidget::itemSelectionChanged, this,
&ConfigureDialog::UpdateVisibleTabs);
adjustSize();
ui->selectorList->setCurrentRow(0);
} }
ConfigureDialog::~ConfigureDialog() = default; ConfigureDialog::~ConfigureDialog() = default;
@ -30,3 +39,37 @@ void ConfigureDialog::applyConfiguration() {
ui->webTab->applyConfiguration(); ui->webTab->applyConfiguration();
Settings::Apply(); Settings::Apply();
} }
void ConfigureDialog::PopulateSelectionList() {
const std::array<std::pair<QString, QStringList>, 4> items{
{{tr("General"), {tr("General"), tr("Web"), tr("Debug"), tr("Game List")}},
{tr("System"), {tr("System"), tr("Audio")}},
{tr("Graphics"), {tr("Graphics")}},
{tr("Controls"), {tr("Input")}}}};
for (const auto& entry : items) {
auto* const item = new QListWidgetItem(entry.first);
item->setData(Qt::UserRole, entry.second);
ui->selectorList->addItem(item);
}
}
void ConfigureDialog::UpdateVisibleTabs() {
const auto items = ui->selectorList->selectedItems();
if (items.isEmpty())
return;
const std::map<QString, QWidget*> widgets = {
{tr("General"), ui->generalTab}, {tr("System"), ui->systemTab},
{tr("Input"), ui->inputTab}, {tr("Graphics"), ui->graphicsTab},
{tr("Audio"), ui->audioTab}, {tr("Debug"), ui->debugTab},
{tr("Web"), ui->webTab}, {tr("Game List"), ui->gameListTab}};
ui->tabWidget->clear();
const QStringList tabs = items[0]->data(Qt::UserRole).toStringList();
for (const auto& tab : tabs)
ui->tabWidget->addTab(widgets.find(tab)->second, tab);
}

View File

@ -24,6 +24,8 @@ public:
private: private:
void setConfiguration(); void setConfiguration();
void UpdateVisibleTabs();
void PopulateSelectionList();
std::unique_ptr<Ui::ConfigureDialog> ui; std::unique_ptr<Ui::ConfigureDialog> ui;
}; };