From c6da772b249526659b267e812ac4734d0388acc0 Mon Sep 17 00:00:00 2001 From: spycrab Date: Thu, 6 Sep 2018 19:59:25 +0200 Subject: Qt/Configure: Use sidebar to divide tabs into smaller groups --- src/yuzu/configuration/configure.ui | 138 ++++++++++++++++------------ src/yuzu/configuration/configure_dialog.cpp | 43 +++++++++ src/yuzu/configuration/configure_dialog.h | 2 + 3 files changed, 124 insertions(+), 59 deletions(-) (limited to 'src') diff --git a/src/yuzu/configuration/configure.ui b/src/yuzu/configuration/configure.ui index 8706b80d2..ce833b6c8 100644 --- a/src/yuzu/configuration/configure.ui +++ b/src/yuzu/configuration/configure.ui @@ -6,8 +6,8 @@ 0 0 - 461 - 659 + 382 + 241 @@ -15,51 +15,71 @@ - - - 0 - - - - General - - - - - Game List - - - - - System - - - - - Input - - - - - Graphics - - - - - Audio - - - - - Debug - - - - - Web - - - + + + + + + 150 + 0 + + + + + 150 + 16777215 + + + + + + + + 0 + + + + General + + + + + Game List + + + + + System + + + + + Input + + + + + Graphics + + + + + Audio + + + + + Debug + + + + + Web + + + + + @@ -77,12 +97,6 @@
configuration/configure_general.h
1 - - ConfigureGameList - QWidget -
configuration/configure_gamelist.h
- 1 -
ConfigureSystem QWidget @@ -101,12 +115,6 @@
configuration/configure_debug.h
1
- - ConfigureInputSimple - QWidget -
configuration/configure_input_simple.h
- 1 -
ConfigureGraphics QWidget @@ -119,6 +127,18 @@
configuration/configure_web.h
1
+ + ConfigureGameList + QWidget +
configuration/configure_gamelist.h
+ 1 +
+ + ConfigureInputSimple + QWidget +
configuration/configure_input_simple.h
+ 1 +
diff --git a/src/yuzu/configuration/configure_dialog.cpp b/src/yuzu/configuration/configure_dialog.cpp index 3905423e9..90d7c6372 100644 --- a/src/yuzu/configuration/configure_dialog.cpp +++ b/src/yuzu/configuration/configure_dialog.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include +#include #include "core/settings.h" #include "ui_configure.h" #include "yuzu/configuration/config.h" @@ -13,6 +15,13 @@ ConfigureDialog::ConfigureDialog(QWidget* parent, const HotkeyRegistry& registry ui->setupUi(this); ui->generalTab->PopulateHotkeyList(registry); this->setConfiguration(); + this->PopulateSelectionList(); + connect(ui->selectorList, &QListWidget::itemSelectionChanged, this, + &ConfigureDialog::UpdateVisibleTabs); + + adjustSize(); + + ui->selectorList->setCurrentRow(0); } ConfigureDialog::~ConfigureDialog() = default; @@ -30,3 +39,37 @@ void ConfigureDialog::applyConfiguration() { ui->webTab->applyConfiguration(); Settings::Apply(); } + +void ConfigureDialog::PopulateSelectionList() { + const std::array, 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 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); +} diff --git a/src/yuzu/configuration/configure_dialog.h b/src/yuzu/configuration/configure_dialog.h index f6df7b827..243d9fa09 100644 --- a/src/yuzu/configuration/configure_dialog.h +++ b/src/yuzu/configuration/configure_dialog.h @@ -24,6 +24,8 @@ public: private: void setConfiguration(); + void UpdateVisibleTabs(); + void PopulateSelectionList(); std::unique_ptr ui; }; -- cgit v1.2.3