citra_qt\game_list: Make columns hideable (#6467)
This commit is contained in:
parent
8eebb83c2c
commit
bbf833bceb
4 changed files with 63 additions and 0 deletions
|
@ -772,6 +772,11 @@ void Config::ReadUIGameListValues() {
|
||||||
ReadBasicSetting(UISettings::values.game_list_hide_no_icon);
|
ReadBasicSetting(UISettings::values.game_list_hide_no_icon);
|
||||||
ReadBasicSetting(UISettings::values.game_list_single_line_mode);
|
ReadBasicSetting(UISettings::values.game_list_single_line_mode);
|
||||||
|
|
||||||
|
ReadBasicSetting(UISettings::values.show_compat_column);
|
||||||
|
ReadBasicSetting(UISettings::values.show_region_column);
|
||||||
|
ReadBasicSetting(UISettings::values.show_type_column);
|
||||||
|
ReadBasicSetting(UISettings::values.show_size_column);
|
||||||
|
|
||||||
qt_config->endGroup();
|
qt_config->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1230,6 +1235,11 @@ void Config::SaveUIGameListValues() {
|
||||||
WriteBasicSetting(UISettings::values.game_list_hide_no_icon);
|
WriteBasicSetting(UISettings::values.game_list_hide_no_icon);
|
||||||
WriteBasicSetting(UISettings::values.game_list_single_line_mode);
|
WriteBasicSetting(UISettings::values.game_list_single_line_mode);
|
||||||
|
|
||||||
|
WriteBasicSetting(UISettings::values.show_compat_column);
|
||||||
|
WriteBasicSetting(UISettings::values.show_region_column);
|
||||||
|
WriteBasicSetting(UISettings::values.show_type_column);
|
||||||
|
WriteBasicSetting(UISettings::values.show_size_column);
|
||||||
|
|
||||||
qt_config->endGroup();
|
qt_config->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// 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 <QActionGroup>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
@ -307,6 +308,9 @@ GameList::GameList(GMainWindow* parent) : QWidget{parent} {
|
||||||
tree_view->setEditTriggers(QHeaderView::NoEditTriggers);
|
tree_view->setEditTriggers(QHeaderView::NoEditTriggers);
|
||||||
tree_view->setContextMenuPolicy(Qt::CustomContextMenu);
|
tree_view->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
tree_view->setStyleSheet(QStringLiteral("QTreeView{ border: none; }"));
|
tree_view->setStyleSheet(QStringLiteral("QTreeView{ border: none; }"));
|
||||||
|
tree_view->header()->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
|
UpdateColumnVisibility();
|
||||||
|
|
||||||
item_model->insertColumns(0, COLUMN_COUNT);
|
item_model->insertColumns(0, COLUMN_COUNT);
|
||||||
RetranslateUI();
|
RetranslateUI();
|
||||||
|
@ -317,6 +321,8 @@ GameList::GameList(GMainWindow* parent) : QWidget{parent} {
|
||||||
connect(tree_view, &QTreeView::customContextMenuRequested, this, &GameList::PopupContextMenu);
|
connect(tree_view, &QTreeView::customContextMenuRequested, this, &GameList::PopupContextMenu);
|
||||||
connect(tree_view, &QTreeView::expanded, this, &GameList::OnItemExpanded);
|
connect(tree_view, &QTreeView::expanded, this, &GameList::OnItemExpanded);
|
||||||
connect(tree_view, &QTreeView::collapsed, this, &GameList::OnItemExpanded);
|
connect(tree_view, &QTreeView::collapsed, this, &GameList::OnItemExpanded);
|
||||||
|
connect(tree_view->header(), &QHeaderView::customContextMenuRequested, this,
|
||||||
|
&GameList::PopupHeaderContextMenu);
|
||||||
|
|
||||||
// We must register all custom types with the Qt Automoc system so that we are able to use
|
// We must register all custom types with the Qt Automoc system so that we are able to use
|
||||||
// it with signals/slots. In this case, QList falls under the umbrells of custom types.
|
// it with signals/slots. In this case, QList falls under the umbrells of custom types.
|
||||||
|
@ -471,6 +477,41 @@ void GameList::PopupContextMenu(const QPoint& menu_location) {
|
||||||
context_menu.exec(tree_view->viewport()->mapToGlobal(menu_location));
|
context_menu.exec(tree_view->viewport()->mapToGlobal(menu_location));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameList::PopupHeaderContextMenu(const QPoint& menu_location) {
|
||||||
|
const QModelIndex item = tree_view->indexAt(menu_location);
|
||||||
|
if (!item.isValid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMenu context_menu;
|
||||||
|
static const QMap<QString, Settings::Setting<bool>*> columns{
|
||||||
|
{tr("Compatibility"), &UISettings::values.show_compat_column},
|
||||||
|
{tr("Region"), &UISettings::values.show_region_column},
|
||||||
|
{tr("File type"), &UISettings::values.show_type_column},
|
||||||
|
{tr("Size"), &UISettings::values.show_size_column}};
|
||||||
|
|
||||||
|
QActionGroup* column_group = new QActionGroup(this);
|
||||||
|
column_group->setExclusive(false);
|
||||||
|
for (const auto& key : columns.keys()) {
|
||||||
|
QAction* action = column_group->addAction(context_menu.addAction(key));
|
||||||
|
action->setCheckable(true);
|
||||||
|
action->setChecked(columns[key]->GetValue());
|
||||||
|
connect(action, &QAction::toggled, [this, key](bool value) {
|
||||||
|
*columns[key] = !columns[key]->GetValue();
|
||||||
|
UpdateColumnVisibility();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
context_menu.exec(tree_view->viewport()->mapToGlobal(menu_location));
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameList::UpdateColumnVisibility() {
|
||||||
|
tree_view->setColumnHidden(COLUMN_COMPATIBILITY, !UISettings::values.show_compat_column);
|
||||||
|
tree_view->setColumnHidden(COLUMN_REGION, !UISettings::values.show_region_column);
|
||||||
|
tree_view->setColumnHidden(COLUMN_FILE_TYPE, !UISettings::values.show_type_column);
|
||||||
|
tree_view->setColumnHidden(COLUMN_SIZE, !UISettings::values.show_size_column);
|
||||||
|
}
|
||||||
|
|
||||||
void ForEachOpenGLCacheFile(u64 program_id, auto func) {
|
void ForEachOpenGLCacheFile(u64 program_id, auto func) {
|
||||||
for (const std::string_view cache_type : {"separable", "conventional"}) {
|
for (const std::string_view cache_type : {"separable", "conventional"}) {
|
||||||
const std::string path = fmt::format("{}opengl/precompiled/{}/{:016X}.bin",
|
const std::string path = fmt::format("{}opengl/precompiled/{}/{:016X}.bin",
|
||||||
|
@ -750,6 +791,10 @@ QStandardItemModel* GameList::GetModel() const {
|
||||||
|
|
||||||
void GameList::PopulateAsync(QVector<UISettings::GameDir>& game_dirs) {
|
void GameList::PopulateAsync(QVector<UISettings::GameDir>& game_dirs) {
|
||||||
tree_view->setEnabled(false);
|
tree_view->setEnabled(false);
|
||||||
|
|
||||||
|
// Update the columns in case UISettings has changed
|
||||||
|
UpdateColumnVisibility();
|
||||||
|
|
||||||
// Delete any rows that might already exist if we're repopulating
|
// Delete any rows that might already exist if we're repopulating
|
||||||
item_model->removeRows(0, item_model->rowCount());
|
item_model->removeRows(0, item_model->rowCount());
|
||||||
search_field->clear();
|
search_field->clear();
|
||||||
|
|
|
@ -104,9 +104,11 @@ private:
|
||||||
void DonePopulating(const QStringList& watch_list);
|
void DonePopulating(const QStringList& watch_list);
|
||||||
|
|
||||||
void PopupContextMenu(const QPoint& menu_location);
|
void PopupContextMenu(const QPoint& menu_location);
|
||||||
|
void PopupHeaderContextMenu(const QPoint& menu_location);
|
||||||
void AddGamePopup(QMenu& context_menu, const QString& path, u64 program_id, u64 extdata_id);
|
void AddGamePopup(QMenu& context_menu, const QString& path, u64 program_id, u64 extdata_id);
|
||||||
void AddCustomDirPopup(QMenu& context_menu, QModelIndex selected);
|
void AddCustomDirPopup(QMenu& context_menu, QModelIndex selected);
|
||||||
void AddPermDirPopup(QMenu& context_menu, QModelIndex selected);
|
void AddPermDirPopup(QMenu& context_menu, QModelIndex selected);
|
||||||
|
void UpdateColumnVisibility();
|
||||||
|
|
||||||
QString FindGameByProgramID(QStandardItem* current_item, u64 program_id, int role);
|
QString FindGameByProgramID(QStandardItem* current_item, u64 program_id, int role);
|
||||||
|
|
||||||
|
|
|
@ -97,6 +97,12 @@ struct Values {
|
||||||
Settings::Setting<bool> game_list_hide_no_icon{false, "hideNoIcon"};
|
Settings::Setting<bool> game_list_hide_no_icon{false, "hideNoIcon"};
|
||||||
Settings::Setting<bool> game_list_single_line_mode{false, "singleLineMode"};
|
Settings::Setting<bool> game_list_single_line_mode{false, "singleLineMode"};
|
||||||
|
|
||||||
|
// Compatibility List
|
||||||
|
Settings::Setting<bool> show_compat_column{true, "show_compat_column"};
|
||||||
|
Settings::Setting<bool> show_region_column{true, "show_region_column"};
|
||||||
|
Settings::Setting<bool> show_type_column{true, "show_type_column"};
|
||||||
|
Settings::Setting<bool> show_size_column{true, "show_size_column"};
|
||||||
|
|
||||||
Settings::Setting<u16> screenshot_resolution_factor{0, "screenshot_resolution_factor"};
|
Settings::Setting<u16> screenshot_resolution_factor{0, "screenshot_resolution_factor"};
|
||||||
Settings::SwitchableSetting<std::string> screenshot_path{"", "screenshotPath"};
|
Settings::SwitchableSetting<std::string> screenshot_path{"", "screenshotPath"};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue