Merge pull request #5886 from JosJuice/rename-list-table

DolphinQt2: Rename "Table"/"List" to "List View"/"Grid View"
This commit is contained in:
Anthony 2017-08-06 09:07:52 -07:00 committed by GitHub
commit 7a74e8ad0b
15 changed files with 155 additions and 157 deletions

View File

@ -63,8 +63,8 @@ set(SRCS
GameList/GameList.cpp GameList/GameList.cpp
GameList/GameListModel.cpp GameList/GameListModel.cpp
GameList/GameTracker.cpp GameList/GameTracker.cpp
GameList/GridProxyModel.cpp
GameList/ListProxyModel.cpp GameList/ListProxyModel.cpp
GameList/TableProxyModel.cpp
QtUtils/BlockUserInputFilter.cpp QtUtils/BlockUserInputFilter.cpp
QtUtils/DoubleClickEventFilter.cpp QtUtils/DoubleClickEventFilter.cpp
QtUtils/ElidedButton.cpp QtUtils/ElidedButton.cpp

View File

@ -84,8 +84,8 @@
<QtMoc Include="GameList\GameList.h" /> <QtMoc Include="GameList\GameList.h" />
<QtMoc Include="GameList\GameListModel.h" /> <QtMoc Include="GameList\GameListModel.h" />
<QtMoc Include="GameList\GameTracker.h" /> <QtMoc Include="GameList\GameTracker.h" />
<QtMoc Include="GameList\GridProxyModel.h" />
<QtMoc Include="GameList\ListProxyModel.h" /> <QtMoc Include="GameList\ListProxyModel.h" />
<QtMoc Include="GameList\TableProxyModel.h" />
<QtMoc Include="Host.h" /> <QtMoc Include="Host.h" />
<QtMoc Include="HotkeyScheduler.h" /> <QtMoc Include="HotkeyScheduler.h" />
<QtMoc Include="InDevelopmentWarning.h" /> <QtMoc Include="InDevelopmentWarning.h" />
@ -126,8 +126,8 @@
<ClCompile Include="$(QtMocOutPrefix)InfoWidget.cpp" /> <ClCompile Include="$(QtMocOutPrefix)InfoWidget.cpp" />
<ClCompile Include="$(QtMocOutPrefix)InterfacePane.cpp" /> <ClCompile Include="$(QtMocOutPrefix)InterfacePane.cpp" />
<ClCompile Include="$(QtMocOutPrefix)IOWindow.cpp" /> <ClCompile Include="$(QtMocOutPrefix)IOWindow.cpp" />
<ClCompile Include="$(QtMocOutPrefix)GridProxyModel.cpp" />
<ClCompile Include="$(QtMocOutPrefix)ListProxyModel.cpp" /> <ClCompile Include="$(QtMocOutPrefix)ListProxyModel.cpp" />
<ClCompile Include="$(QtMocOutPrefix)TableProxyModel.cpp" />
<ClCompile Include="$(QtMocOutPrefix)LoggerWidget.cpp" /> <ClCompile Include="$(QtMocOutPrefix)LoggerWidget.cpp" />
<ClCompile Include="$(QtMocOutPrefix)MainWindow.cpp" /> <ClCompile Include="$(QtMocOutPrefix)MainWindow.cpp" />
<ClCompile Include="$(QtMocOutPrefix)MappingButton.cpp" /> <ClCompile Include="$(QtMocOutPrefix)MappingButton.cpp" />
@ -181,8 +181,8 @@
<ClCompile Include="GameList\GameList.cpp" /> <ClCompile Include="GameList\GameList.cpp" />
<ClCompile Include="GameList\GameListModel.cpp" /> <ClCompile Include="GameList\GameListModel.cpp" />
<ClCompile Include="GameList\GameTracker.cpp" /> <ClCompile Include="GameList\GameTracker.cpp" />
<ClCompile Include="GameList\GridProxyModel.cpp" />
<ClCompile Include="GameList\ListProxyModel.cpp" /> <ClCompile Include="GameList\ListProxyModel.cpp" />
<ClCompile Include="GameList\TableProxyModel.cpp" />
<ClCompile Include="HotkeyScheduler.cpp" /> <ClCompile Include="HotkeyScheduler.cpp" />
<ClCompile Include="Host.cpp" /> <ClCompile Include="Host.cpp" />
<ClCompile Include="InDevelopmentWarning.cpp" /> <ClCompile Include="InDevelopmentWarning.cpp" />

View File

@ -25,8 +25,8 @@
#include "DolphinQt2/Config/PropertiesDialog.h" #include "DolphinQt2/Config/PropertiesDialog.h"
#include "DolphinQt2/GameList/GameList.h" #include "DolphinQt2/GameList/GameList.h"
#include "DolphinQt2/GameList/GridProxyModel.h"
#include "DolphinQt2/GameList/ListProxyModel.h" #include "DolphinQt2/GameList/ListProxyModel.h"
#include "DolphinQt2/GameList/TableProxyModel.h"
#include "DolphinQt2/QtUtils/DoubleClickEventFilter.h" #include "DolphinQt2/QtUtils/DoubleClickEventFilter.h"
#include "DolphinQt2/Settings.h" #include "DolphinQt2/Settings.h"
@ -35,59 +35,59 @@ static bool CompressCB(const std::string&, float, void*);
GameList::GameList(QWidget* parent) : QStackedWidget(parent) GameList::GameList(QWidget* parent) : QStackedWidget(parent)
{ {
m_model = new GameListModel(this); m_model = new GameListModel(this);
m_table_proxy = new TableProxyModel(this);
m_table_proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
m_table_proxy->setSortRole(Qt::InitialSortOrderRole);
m_table_proxy->setSourceModel(m_model);
m_list_proxy = new ListProxyModel(this); m_list_proxy = new ListProxyModel(this);
m_list_proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
m_list_proxy->setSortRole(Qt::InitialSortOrderRole);
m_list_proxy->setSourceModel(m_model); m_list_proxy->setSourceModel(m_model);
m_grid_proxy = new GridProxyModel(this);
m_grid_proxy->setSourceModel(m_model);
MakeTableView();
MakeListView(); MakeListView();
MakeGridView();
MakeEmptyView(); MakeEmptyView();
connect(m_table, &QTableView::doubleClicked, this, &GameList::GameSelected); connect(m_list, &QTableView::doubleClicked, this, &GameList::GameSelected);
connect(m_list, &QListView::doubleClicked, this, &GameList::GameSelected); connect(m_grid, &QListView::doubleClicked, this, &GameList::GameSelected);
connect(&Settings::Instance(), &Settings::PathAdded, m_model, &GameListModel::DirectoryAdded); connect(&Settings::Instance(), &Settings::PathAdded, m_model, &GameListModel::DirectoryAdded);
connect(&Settings::Instance(), &Settings::PathRemoved, m_model, &GameListModel::DirectoryRemoved); connect(&Settings::Instance(), &Settings::PathRemoved, m_model, &GameListModel::DirectoryRemoved);
connect(m_model, &QAbstractItemModel::rowsInserted, this, &GameList::ConsiderViewChange); connect(m_model, &QAbstractItemModel::rowsInserted, this, &GameList::ConsiderViewChange);
connect(m_model, &QAbstractItemModel::rowsRemoved, this, &GameList::ConsiderViewChange); connect(m_model, &QAbstractItemModel::rowsRemoved, this, &GameList::ConsiderViewChange);
addWidget(m_table);
addWidget(m_list); addWidget(m_list);
addWidget(m_grid);
addWidget(m_empty); addWidget(m_empty);
m_prefer_table = Settings::Instance().GetPreferredView(); m_prefer_list = Settings::Instance().GetPreferredView();
ConsiderViewChange(); ConsiderViewChange();
} }
void GameList::MakeTableView() void GameList::MakeListView()
{ {
m_table = new QTableView(this); m_list = new QTableView(this);
m_table->setModel(m_table_proxy); m_list->setModel(m_list_proxy);
m_table->setSelectionMode(QAbstractItemView::SingleSelection); m_list->setSelectionMode(QAbstractItemView::SingleSelection);
m_table->setSelectionBehavior(QAbstractItemView::SelectRows); m_list->setSelectionBehavior(QAbstractItemView::SelectRows);
m_table->setAlternatingRowColors(true); m_list->setAlternatingRowColors(true);
m_table->setShowGrid(false); m_list->setShowGrid(false);
m_table->setSortingEnabled(true); m_list->setSortingEnabled(true);
m_table->setCurrentIndex(QModelIndex()); m_list->setCurrentIndex(QModelIndex());
m_table->setContextMenuPolicy(Qt::CustomContextMenu); m_list->setContextMenuPolicy(Qt::CustomContextMenu);
m_table->setWordWrap(false); m_list->setWordWrap(false);
connect(m_table, &QTableView::customContextMenuRequested, this, &GameList::ShowContextMenu); connect(m_list, &QTableView::customContextMenuRequested, this, &GameList::ShowContextMenu);
m_table->setColumnHidden(GameListModel::COL_PLATFORM, !SConfig::GetInstance().m_showSystemColumn); m_list->setColumnHidden(GameListModel::COL_PLATFORM, !SConfig::GetInstance().m_showSystemColumn);
m_table->setColumnHidden(GameListModel::COL_ID, !SConfig::GetInstance().m_showIDColumn); m_list->setColumnHidden(GameListModel::COL_ID, !SConfig::GetInstance().m_showIDColumn);
m_table->setColumnHidden(GameListModel::COL_BANNER, !SConfig::GetInstance().m_showBannerColumn); m_list->setColumnHidden(GameListModel::COL_BANNER, !SConfig::GetInstance().m_showBannerColumn);
m_table->setColumnHidden(GameListModel::COL_TITLE, !SConfig::GetInstance().m_showTitleColumn); m_list->setColumnHidden(GameListModel::COL_TITLE, !SConfig::GetInstance().m_showTitleColumn);
m_table->setColumnHidden(GameListModel::COL_DESCRIPTION, m_list->setColumnHidden(GameListModel::COL_DESCRIPTION,
!SConfig::GetInstance().m_showDescriptionColumn); !SConfig::GetInstance().m_showDescriptionColumn);
m_table->setColumnHidden(GameListModel::COL_MAKER, !SConfig::GetInstance().m_showMakerColumn); m_list->setColumnHidden(GameListModel::COL_MAKER, !SConfig::GetInstance().m_showMakerColumn);
m_table->setColumnHidden(GameListModel::COL_SIZE, !SConfig::GetInstance().m_showSizeColumn); m_list->setColumnHidden(GameListModel::COL_SIZE, !SConfig::GetInstance().m_showSizeColumn);
m_table->setColumnHidden(GameListModel::COL_COUNTRY, !SConfig::GetInstance().m_showRegionColumn); m_list->setColumnHidden(GameListModel::COL_COUNTRY, !SConfig::GetInstance().m_showRegionColumn);
m_table->setColumnHidden(GameListModel::COL_RATING, !SConfig::GetInstance().m_showStateColumn); m_list->setColumnHidden(GameListModel::COL_RATING, !SConfig::GetInstance().m_showStateColumn);
QHeaderView* hor_header = m_table->horizontalHeader(); QHeaderView* hor_header = m_list->horizontalHeader();
connect(hor_header, &QHeaderView::sortIndicatorChanged, this, &GameList::OnHeaderViewChanged); connect(hor_header, &QHeaderView::sortIndicatorChanged, this, &GameList::OnHeaderViewChanged);
connect(hor_header, &QHeaderView::sectionResized, this, &GameList::OnHeaderViewChanged); connect(hor_header, &QHeaderView::sectionResized, this, &GameList::OnHeaderViewChanged);
@ -107,8 +107,8 @@ void GameList::MakeTableView()
hor_header->setSectionResizeMode(GameListModel::COL_DESCRIPTION, QHeaderView::Stretch); hor_header->setSectionResizeMode(GameListModel::COL_DESCRIPTION, QHeaderView::Stretch);
hor_header->setSectionResizeMode(GameListModel::COL_RATING, QHeaderView::ResizeToContents); hor_header->setSectionResizeMode(GameListModel::COL_RATING, QHeaderView::ResizeToContents);
m_table->verticalHeader()->hide(); m_list->verticalHeader()->hide();
m_table->setFrameStyle(QFrame::NoFrame); m_list->setFrameStyle(QFrame::NoFrame);
} }
void GameList::MakeEmptyView() void GameList::MakeEmptyView()
@ -128,16 +128,16 @@ void GameList::MakeEmptyView()
}); });
} }
void GameList::MakeListView() void GameList::MakeGridView()
{ {
m_list = new QListView(this); m_grid = new QListView(this);
m_list->setModel(m_list_proxy); m_grid->setModel(m_grid_proxy);
m_list->setViewMode(QListView::IconMode); m_grid->setViewMode(QListView::IconMode);
m_list->setResizeMode(QListView::Adjust); m_grid->setResizeMode(QListView::Adjust);
m_list->setUniformItemSizes(true); m_grid->setUniformItemSizes(true);
m_list->setContextMenuPolicy(Qt::CustomContextMenu); m_grid->setContextMenuPolicy(Qt::CustomContextMenu);
m_list->setFrameStyle(QFrame::NoFrame); m_grid->setFrameStyle(QFrame::NoFrame);
connect(m_list, &QTableView::customContextMenuRequested, this, &GameList::ShowContextMenu); connect(m_grid, &QTableView::customContextMenuRequested, this, &GameList::ShowContextMenu);
} }
void GameList::ShowContextMenu(const QPoint&) void GameList::ShowContextMenu(const QPoint&)
@ -383,16 +383,16 @@ QString GameList::GetSelectedGame() const
{ {
QAbstractItemView* view; QAbstractItemView* view;
QSortFilterProxyModel* proxy; QSortFilterProxyModel* proxy;
if (currentWidget() == m_table) if (currentWidget() == m_list)
{
view = m_table;
proxy = m_table_proxy;
}
else
{ {
view = m_list; view = m_list;
proxy = m_list_proxy; proxy = m_list_proxy;
} }
else
{
view = m_grid;
proxy = m_grid_proxy;
}
QItemSelectionModel* sel_model = view->selectionModel(); QItemSelectionModel* sel_model = view->selectionModel();
if (sel_model->hasSelection()) if (sel_model->hasSelection())
{ {
@ -402,10 +402,10 @@ QString GameList::GetSelectedGame() const
return QStringLiteral(""); return QStringLiteral("");
} }
void GameList::SetPreferredView(bool table) void GameList::SetPreferredView(bool list)
{ {
m_prefer_table = table; m_prefer_list = list;
Settings::Instance().SetPreferredView(table); Settings::Instance().SetPreferredView(list);
ConsiderViewChange(); ConsiderViewChange();
} }
@ -413,10 +413,10 @@ void GameList::ConsiderViewChange()
{ {
if (m_model->rowCount(QModelIndex()) > 0) if (m_model->rowCount(QModelIndex()) > 0)
{ {
if (m_prefer_table) if (m_prefer_list)
setCurrentWidget(m_table);
else
setCurrentWidget(m_list); setCurrentWidget(m_list);
else
setCurrentWidget(m_grid);
} }
else else
{ {
@ -444,13 +444,13 @@ void GameList::OnColumnVisibilityToggled(const QString& row, bool visible)
{tr("Title"), GameListModel::COL_TITLE}, {tr("Title"), GameListModel::COL_TITLE},
{tr("State"), GameListModel::COL_RATING}}; {tr("State"), GameListModel::COL_RATING}};
m_table->setColumnHidden(rowname_to_col_index[row], !visible); m_list->setColumnHidden(rowname_to_col_index[row], !visible);
} }
void GameList::OnGameListVisibilityChanged() void GameList::OnGameListVisibilityChanged()
{ {
m_table_proxy->invalidate();
m_list_proxy->invalidate(); m_list_proxy->invalidate();
m_grid_proxy->invalidate();
} }
static bool CompressCB(const std::string& text, float percent, void* ptr) static bool CompressCB(const std::string& text, float percent, void* ptr)
@ -466,5 +466,5 @@ static bool CompressCB(const std::string& text, float percent, void* ptr)
void GameList::OnHeaderViewChanged() void GameList::OnHeaderViewChanged()
{ {
QSettings().setValue(QStringLiteral("tableheader/state"), QSettings().setValue(QStringLiteral("tableheader/state"),
m_table->horizontalHeader()->saveState()); m_list->horizontalHeader()->saveState());
} }

View File

@ -21,9 +21,9 @@ public:
explicit GameList(QWidget* parent = nullptr); explicit GameList(QWidget* parent = nullptr);
QString GetSelectedGame() const; QString GetSelectedGame() const;
void SetTableView() { SetPreferredView(true); } void SetListView() { SetPreferredView(true); }
void SetListView() { SetPreferredView(false); } void SetGridView() { SetPreferredView(false); }
void SetViewColumn(int col, bool view) { m_table->setColumnHidden(col, !view); } void SetViewColumn(int col, bool view) { m_list->setColumnHidden(col, !view); }
void OnColumnVisibilityToggled(const QString& row, bool visible); void OnColumnVisibilityToggled(const QString& row, bool visible);
void OnGameListVisibilityChanged(); void OnGameListVisibilityChanged();
@ -46,21 +46,21 @@ private:
void CompressISO(); void CompressISO();
void OnHeaderViewChanged(); void OnHeaderViewChanged();
void MakeTableView();
void MakeListView(); void MakeListView();
void MakeGridView();
void MakeEmptyView(); void MakeEmptyView();
// We only have two views, just use a bool to distinguish. // We only have two views, just use a bool to distinguish.
void SetPreferredView(bool table); void SetPreferredView(bool list);
void ConsiderViewChange(); void ConsiderViewChange();
GameListModel* m_model; GameListModel* m_model;
QSortFilterProxyModel* m_table_proxy;
QSortFilterProxyModel* m_list_proxy; QSortFilterProxyModel* m_list_proxy;
QSortFilterProxyModel* m_grid_proxy;
QListView* m_list; QListView* m_grid;
QTableView* m_table; QTableView* m_list;
QLabel* m_empty; QLabel* m_empty;
bool m_prefer_table; bool m_prefer_list;
protected: protected:
void keyReleaseEvent(QKeyEvent* event) override; void keyReleaseEvent(QKeyEvent* event) override;

View File

@ -0,0 +1,42 @@
// Copyright 2015 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <QSize>
#include "DolphinQt2/GameList/GameListModel.h"
#include "DolphinQt2/GameList/GridProxyModel.h"
const QSize LARGE_BANNER_SIZE(144, 48);
GridProxyModel::GridProxyModel(QObject* parent) : QSortFilterProxyModel(parent)
{
setSortCaseSensitivity(Qt::CaseInsensitive);
sort(GameListModel::COL_TITLE);
}
QVariant GridProxyModel::data(const QModelIndex& i, int role) const
{
QModelIndex source_index = mapToSource(i);
if (role == Qt::DisplayRole)
{
return sourceModel()->data(sourceModel()->index(source_index.row(), GameListModel::COL_TITLE),
Qt::DisplayRole);
}
else if (role == Qt::DecorationRole)
{
auto pixmap = sourceModel()
->data(sourceModel()->index(source_index.row(), GameListModel::COL_BANNER),
Qt::DecorationRole)
.value<QPixmap>();
return pixmap.scaled(LARGE_BANNER_SIZE * pixmap.devicePixelRatio(), Qt::KeepAspectRatio,
Qt::SmoothTransformation);
}
return QVariant();
}
bool GridProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
{
GameListModel* glm = qobject_cast<GameListModel*>(sourceModel());
return glm->ShouldDisplayGameListItem(source_row);
}

View File

@ -0,0 +1,19 @@
// Copyright 2015 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <QSortFilterProxyModel>
// This subclass of QSortFilterProxyModel transforms the raw data into a
// single-column large icon + name to be displayed in a QListView.
class GridProxyModel final : public QSortFilterProxyModel
{
Q_OBJECT
public:
explicit GridProxyModel(QObject* parent = nullptr);
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override;
};

View File

@ -1,38 +1,12 @@
// Copyright 2015 Dolphin Emulator Project // Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+ // Licensed under GPLv2+
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <QSize>
#include "DolphinQt2/GameList/GameListModel.h"
#include "DolphinQt2/GameList/ListProxyModel.h" #include "DolphinQt2/GameList/ListProxyModel.h"
#include "DolphinQt2/GameList/GameListModel.h"
const QSize LARGE_BANNER_SIZE(144, 48);
ListProxyModel::ListProxyModel(QObject* parent) : QSortFilterProxyModel(parent) ListProxyModel::ListProxyModel(QObject* parent) : QSortFilterProxyModel(parent)
{ {
setSortCaseSensitivity(Qt::CaseInsensitive);
sort(GameListModel::COL_TITLE);
}
QVariant ListProxyModel::data(const QModelIndex& i, int role) const
{
QModelIndex source_index = mapToSource(i);
if (role == Qt::DisplayRole)
{
return sourceModel()->data(sourceModel()->index(source_index.row(), GameListModel::COL_TITLE),
Qt::DisplayRole);
}
else if (role == Qt::DecorationRole)
{
auto pixmap = sourceModel()
->data(sourceModel()->index(source_index.row(), GameListModel::COL_BANNER),
Qt::DecorationRole)
.value<QPixmap>();
return pixmap.scaled(LARGE_BANNER_SIZE * pixmap.devicePixelRatio(), Qt::KeepAspectRatio,
Qt::SmoothTransformation);
}
return QVariant();
} }
bool ListProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const bool ListProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const

View File

@ -1,4 +1,4 @@
// Copyright 2015 Dolphin Emulator Project // Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+ // Licensed under GPLv2+
// Refer to the license.txt file included. // Refer to the license.txt file included.
@ -6,14 +6,12 @@
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
// This subclass of QSortFilterProxyModel transforms the raw data into a // This subclass of QSortFilterProxyModel allows the data to be filtered by the view.
// single-column large icon + name to be displayed in a QListView.
class ListProxyModel final : public QSortFilterProxyModel class ListProxyModel final : public QSortFilterProxyModel
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit ListProxyModel(QObject* parent = nullptr); explicit ListProxyModel(QObject* parent = nullptr);
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override; bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override;
}; };

View File

@ -1,16 +0,0 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinQt2/GameList/TableProxyModel.h"
#include "DolphinQt2/GameList/GameListModel.h"
TableProxyModel::TableProxyModel(QObject* parent) : QSortFilterProxyModel(parent)
{
}
bool TableProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
{
GameListModel* glm = qobject_cast<GameListModel*>(sourceModel());
return glm->ShouldDisplayGameListItem(source_row);
}

View File

@ -1,17 +0,0 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <QSortFilterProxyModel>
// This subclass of QSortFilterProxyModel allows the data to be filtered by the view.
class TableProxyModel final : public QSortFilterProxyModel
{
Q_OBJECT
public:
explicit TableProxyModel(QObject* parent = nullptr);
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override;
};

View File

@ -197,8 +197,8 @@ void MainWindow::ConnectMenuBar()
connect(m_menu_bar, &MenuBar::BootWiiSystemMenu, this, &MainWindow::BootWiiSystemMenu); connect(m_menu_bar, &MenuBar::BootWiiSystemMenu, this, &MainWindow::BootWiiSystemMenu);
// View // View
connect(m_menu_bar, &MenuBar::ShowTable, m_game_list, &GameList::SetTableView);
connect(m_menu_bar, &MenuBar::ShowList, m_game_list, &GameList::SetListView); connect(m_menu_bar, &MenuBar::ShowList, m_game_list, &GameList::SetListView);
connect(m_menu_bar, &MenuBar::ShowGrid, m_game_list, &GameList::SetGridView);
connect(m_menu_bar, &MenuBar::ColumnVisibilityToggled, m_game_list, connect(m_menu_bar, &MenuBar::ColumnVisibilityToggled, m_game_list,
&GameList::OnColumnVisibilityToggled); &GameList::OnColumnVisibilityToggled);

View File

@ -215,7 +215,7 @@ void MenuBar::AddViewMenu()
AddGameListTypeSection(view_menu); AddGameListTypeSection(view_menu);
view_menu->addSeparator(); view_menu->addSeparator();
AddTableColumnsMenu(view_menu); AddListColumnsMenu(view_menu);
view_menu->addSeparator(); view_menu->addSeparator();
AddShowPlatformsMenu(view_menu); AddShowPlatformsMenu(view_menu);
AddShowRegionsMenu(view_menu); AddShowRegionsMenu(view_menu);
@ -253,27 +253,25 @@ void MenuBar::AddHelpMenu()
void MenuBar::AddGameListTypeSection(QMenu* view_menu) void MenuBar::AddGameListTypeSection(QMenu* view_menu)
{ {
// i18n: When this option is enabled, the game list is displayed as a table QAction* list_view = view_menu->addAction(tr("List View"));
QAction* table_view = view_menu->addAction(tr("Table"));
table_view->setCheckable(true);
// i18n: When this option is enabled, the game list is displayed as a list
QAction* list_view = view_menu->addAction(tr("List"));
list_view->setCheckable(true); list_view->setCheckable(true);
QAction* grid_view = view_menu->addAction(tr("Grid View"));
grid_view->setCheckable(true);
QActionGroup* list_group = new QActionGroup(this); QActionGroup* list_group = new QActionGroup(this);
list_group->addAction(table_view);
list_group->addAction(list_view); list_group->addAction(list_view);
list_group->addAction(grid_view);
bool prefer_table = Settings::Instance().GetPreferredView(); bool prefer_list = Settings::Instance().GetPreferredView();
table_view->setChecked(prefer_table); list_view->setChecked(prefer_list);
list_view->setChecked(!prefer_table); grid_view->setChecked(!prefer_list);
connect(table_view, &QAction::triggered, this, &MenuBar::ShowTable);
connect(list_view, &QAction::triggered, this, &MenuBar::ShowList); connect(list_view, &QAction::triggered, this, &MenuBar::ShowList);
connect(grid_view, &QAction::triggered, this, &MenuBar::ShowGrid);
} }
void MenuBar::AddTableColumnsMenu(QMenu* view_menu) void MenuBar::AddListColumnsMenu(QMenu* view_menu)
{ {
static const QMap<QString, bool*> columns{ static const QMap<QString, bool*> columns{
{tr("Platform"), &SConfig::GetInstance().m_showSystemColumn}, {tr("Platform"), &SConfig::GetInstance().m_showSystemColumn},
@ -287,7 +285,7 @@ void MenuBar::AddTableColumnsMenu(QMenu* view_menu)
{tr("State"), &SConfig::GetInstance().m_showStateColumn}}; {tr("State"), &SConfig::GetInstance().m_showStateColumn}};
QActionGroup* column_group = new QActionGroup(this); QActionGroup* column_group = new QActionGroup(this);
QMenu* cols_menu = view_menu->addMenu(tr("Table Columns")); QMenu* cols_menu = view_menu->addMenu(tr("List Columns"));
column_group->setExclusive(false); column_group->setExclusive(false);
for (const auto& key : columns.keys()) for (const auto& key : columns.keys())

View File

@ -60,8 +60,8 @@ signals:
void ConfigureHotkeys(); void ConfigureHotkeys();
// View // View
void ShowTable();
void ShowList(); void ShowList();
void ShowGrid();
void ColumnVisibilityToggled(const QString& row, bool visible); void ColumnVisibilityToggled(const QString& row, bool visible);
void GameListPlatformVisibilityToggled(const QString& row, bool visible); void GameListPlatformVisibilityToggled(const QString& row, bool visible);
void GameListRegionVisibilityToggled(const QString& row, bool visible); void GameListRegionVisibilityToggled(const QString& row, bool visible);
@ -78,7 +78,7 @@ private:
void AddViewMenu(); void AddViewMenu();
void AddGameListTypeSection(QMenu* view_menu); void AddGameListTypeSection(QMenu* view_menu);
void AddTableColumnsMenu(QMenu* view_menu); void AddListColumnsMenu(QMenu* view_menu);
void AddShowPlatformsMenu(QMenu* view_menu); void AddShowPlatformsMenu(QMenu* view_menu);
void AddShowRegionsMenu(QMenu* view_menu); void AddShowRegionsMenu(QMenu* view_menu);

View File

@ -77,9 +77,9 @@ bool Settings::GetPreferredView() const
return QSettings().value(QStringLiteral("PreferredView"), true).toBool(); return QSettings().value(QStringLiteral("PreferredView"), true).toBool();
} }
void Settings::SetPreferredView(bool table) void Settings::SetPreferredView(bool list)
{ {
QSettings().setValue(QStringLiteral("PreferredView"), table); QSettings().setValue(QStringLiteral("PreferredView"), list);
} }
int Settings::GetStateSlot() const int Settings::GetStateSlot() const

View File

@ -41,7 +41,7 @@ public:
void AddPath(const QString& path); void AddPath(const QString& path);
void RemovePath(const QString& path); void RemovePath(const QString& path);
bool GetPreferredView() const; bool GetPreferredView() const;
void SetPreferredView(bool table); void SetPreferredView(bool list);
// Emulation // Emulation
int GetStateSlot() const; int GetStateSlot() const;