summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Bartosz Kaszubowski2020-01-19 21:56:49 +0100
committerGravatar bunnei2020-01-19 15:56:49 -0500
commit9ac33c26205d9a05f756cea115778a36b8a5a9ab (patch)
treebeb8d3b8199c85ce35ff9950c84e4cea39bbf3f9 /src
parentMerge pull request #3317 from ReinUsesLisp/gl-decomp-cc-decomp (diff)
downloadyuzu-9ac33c26205d9a05f756cea115778a36b8a5a9ab.tar.gz
yuzu-9ac33c26205d9a05f756cea115778a36b8a5a9ab.tar.xz
yuzu-9ac33c26205d9a05f756cea115778a36b8a5a9ab.zip
GUI/gamelist: add "None" as an option for second row and remove dynamically duplicate row options (#3309)
* GUI/gamelist: add "None" as an option for second row and remove duplicated row options * fix clang-format warnings
Diffstat (limited to 'src')
-rw-r--r--src/yuzu/configuration/configure_gamelist.cpp53
-rw-r--r--src/yuzu/configuration/configure_gamelist.h3
-rw-r--r--src/yuzu/game_list_p.h11
3 files changed, 53 insertions, 14 deletions
diff --git a/src/yuzu/configuration/configure_gamelist.cpp b/src/yuzu/configuration/configure_gamelist.cpp
index daedbc33e..e43e84d39 100644
--- a/src/yuzu/configuration/configure_gamelist.cpp
+++ b/src/yuzu/configuration/configure_gamelist.cpp
@@ -21,10 +21,8 @@ constexpr std::array default_icon_sizes{
21}; 21};
22 22
23constexpr std::array row_text_names{ 23constexpr std::array row_text_names{
24 QT_TR_NOOP("Filename"), 24 QT_TR_NOOP("Filename"), QT_TR_NOOP("Filetype"), QT_TR_NOOP("Title ID"),
25 QT_TR_NOOP("Filetype"), 25 QT_TR_NOOP("Title Name"), QT_TR_NOOP("None"),
26 QT_TR_NOOP("Title ID"),
27 QT_TR_NOOP("Title Name"),
28}; 26};
29} // Anonymous namespace 27} // Anonymous namespace
30 28
@@ -46,6 +44,12 @@ ConfigureGameList::ConfigureGameList(QWidget* parent)
46 &ConfigureGameList::RequestGameListUpdate); 44 &ConfigureGameList::RequestGameListUpdate);
47 connect(ui->row_2_text_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, 45 connect(ui->row_2_text_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
48 &ConfigureGameList::RequestGameListUpdate); 46 &ConfigureGameList::RequestGameListUpdate);
47
48 // Update text ComboBoxes after user interaction.
49 connect(ui->row_1_text_combobox, QOverload<int>::of(&QComboBox::activated),
50 [=]() { ConfigureGameList::UpdateSecondRowComboBox(); });
51 connect(ui->row_2_text_combobox, QOverload<int>::of(&QComboBox::activated),
52 [=]() { ConfigureGameList::UpdateFirstRowComboBox(); });
49} 53}
50 54
51ConfigureGameList::~ConfigureGameList() = default; 55ConfigureGameList::~ConfigureGameList() = default;
@@ -68,10 +72,6 @@ void ConfigureGameList::SetConfiguration() {
68 ui->show_add_ons->setChecked(UISettings::values.show_add_ons); 72 ui->show_add_ons->setChecked(UISettings::values.show_add_ons);
69 ui->icon_size_combobox->setCurrentIndex( 73 ui->icon_size_combobox->setCurrentIndex(
70 ui->icon_size_combobox->findData(UISettings::values.icon_size)); 74 ui->icon_size_combobox->findData(UISettings::values.icon_size));
71 ui->row_1_text_combobox->setCurrentIndex(
72 ui->row_1_text_combobox->findData(UISettings::values.row_1_text_id));
73 ui->row_2_text_combobox->setCurrentIndex(
74 ui->row_2_text_combobox->findData(UISettings::values.row_2_text_id));
75} 75}
76 76
77void ConfigureGameList::changeEvent(QEvent* event) { 77void ConfigureGameList::changeEvent(QEvent* event) {
@@ -104,10 +104,43 @@ void ConfigureGameList::InitializeIconSizeComboBox() {
104} 104}
105 105
106void ConfigureGameList::InitializeRowComboBoxes() { 106void ConfigureGameList::InitializeRowComboBoxes() {
107 for (std::size_t i = 0; i < row_text_names.size(); ++i) { 107 UpdateFirstRowComboBox(true);
108 const QString row_text_name = QString::fromUtf8(row_text_names[i]); 108 UpdateSecondRowComboBox(true);
109}
110
111void ConfigureGameList::UpdateFirstRowComboBox(bool init) {
112 const int currentIndex =
113 init ? UISettings::values.row_1_text_id
114 : ui->row_1_text_combobox->findData(ui->row_1_text_combobox->currentData());
109 115
116 ui->row_1_text_combobox->clear();
117
118 for (std::size_t i = 0; i < row_text_names.size(); i++) {
119 const QString row_text_name = QString::fromUtf8(row_text_names[i]);
110 ui->row_1_text_combobox->addItem(row_text_name, QVariant::fromValue(i)); 120 ui->row_1_text_combobox->addItem(row_text_name, QVariant::fromValue(i));
121 }
122
123 ui->row_1_text_combobox->setCurrentIndex(ui->row_1_text_combobox->findData(currentIndex));
124
125 ui->row_1_text_combobox->removeItem(4); // None
126 ui->row_1_text_combobox->removeItem(
127 ui->row_1_text_combobox->findData(ui->row_2_text_combobox->currentData()));
128}
129
130void ConfigureGameList::UpdateSecondRowComboBox(bool init) {
131 const int currentIndex =
132 init ? UISettings::values.row_2_text_id
133 : ui->row_2_text_combobox->findData(ui->row_2_text_combobox->currentData());
134
135 ui->row_2_text_combobox->clear();
136
137 for (std::size_t i = 0; i < row_text_names.size(); ++i) {
138 const QString row_text_name = QString::fromUtf8(row_text_names[i]);
111 ui->row_2_text_combobox->addItem(row_text_name, QVariant::fromValue(i)); 139 ui->row_2_text_combobox->addItem(row_text_name, QVariant::fromValue(i));
112 } 140 }
141
142 ui->row_2_text_combobox->setCurrentIndex(ui->row_2_text_combobox->findData(currentIndex));
143
144 ui->row_2_text_combobox->removeItem(
145 ui->row_2_text_combobox->findData(ui->row_1_text_combobox->currentData()));
113} 146}
diff --git a/src/yuzu/configuration/configure_gamelist.h b/src/yuzu/configuration/configure_gamelist.h
index e11822919..ecd3fa174 100644
--- a/src/yuzu/configuration/configure_gamelist.h
+++ b/src/yuzu/configuration/configure_gamelist.h
@@ -31,5 +31,8 @@ private:
31 void InitializeIconSizeComboBox(); 31 void InitializeIconSizeComboBox();
32 void InitializeRowComboBoxes(); 32 void InitializeRowComboBoxes();
33 33
34 void UpdateFirstRowComboBox(bool init = false);
35 void UpdateSecondRowComboBox(bool init = false);
36
34 std::unique_ptr<Ui::ConfigureGameList> ui; 37 std::unique_ptr<Ui::ConfigureGameList> ui;
35}; 38};
diff --git a/src/yuzu/game_list_p.h b/src/yuzu/game_list_p.h
index 1c2b37afd..7cde72d1b 100644
--- a/src/yuzu/game_list_p.h
+++ b/src/yuzu/game_list_p.h
@@ -108,11 +108,14 @@ public:
108 }}; 108 }};
109 109
110 const auto& row1 = row_data.at(UISettings::values.row_1_text_id); 110 const auto& row1 = row_data.at(UISettings::values.row_1_text_id);
111 const auto& row2 = row_data.at(UISettings::values.row_2_text_id); 111 const int row2_id = UISettings::values.row_2_text_id;
112 112
113 if (row1.isEmpty() || row1 == row2) 113 if (row2_id == 4) // None
114 return row2; 114 return row1;
115 if (row2.isEmpty()) 115
116 const auto& row2 = row_data.at(row2_id);
117
118 if (row1 == row2)
116 return row1; 119 return row1;
117 120
118 return QString(row1 + QStringLiteral("\n ") + row2); 121 return QString(row1 + QStringLiteral("\n ") + row2);