Merge pull request #5786 from grimpunch/qt_viewoptions
Qt: Implement Show Platforms / Show Regions
This commit is contained in:
commit
be8324380d
|
@ -63,6 +63,7 @@ set(SRCS
|
||||||
GameList/GameListModel.cpp
|
GameList/GameListModel.cpp
|
||||||
GameList/GameTracker.cpp
|
GameList/GameTracker.cpp
|
||||||
GameList/ListProxyModel.cpp
|
GameList/ListProxyModel.cpp
|
||||||
|
GameList/TableProxyModel.cpp
|
||||||
QtUtils/DoubleClickEventFilter.cpp
|
QtUtils/DoubleClickEventFilter.cpp
|
||||||
QtUtils/ElidedButton.cpp
|
QtUtils/ElidedButton.cpp
|
||||||
QtUtils/ListTabWidget.cpp
|
QtUtils/ListTabWidget.cpp
|
||||||
|
|
|
@ -84,6 +84,7 @@
|
||||||
<QtMoc Include="GameList\GameListModel.h" />
|
<QtMoc Include="GameList\GameListModel.h" />
|
||||||
<QtMoc Include="GameList\GameTracker.h" />
|
<QtMoc Include="GameList\GameTracker.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" />
|
||||||
|
@ -125,6 +126,7 @@
|
||||||
<ClCompile Include="$(QtMocOutPrefix)InterfacePane.cpp" />
|
<ClCompile Include="$(QtMocOutPrefix)InterfacePane.cpp" />
|
||||||
<ClCompile Include="$(QtMocOutPrefix)IOWindow.cpp" />
|
<ClCompile Include="$(QtMocOutPrefix)IOWindow.cpp" />
|
||||||
<ClCompile Include="$(QtMocOutPrefix)ListProxyModel.cpp" />
|
<ClCompile Include="$(QtMocOutPrefix)ListProxyModel.cpp" />
|
||||||
|
<ClCompile Include="$(QtMocOutPrefix)TableProxyModel.cpp" />
|
||||||
<ClCompile Include="$(QtMocOutPrefix)MainWindow.cpp" />
|
<ClCompile Include="$(QtMocOutPrefix)MainWindow.cpp" />
|
||||||
<ClCompile Include="$(QtMocOutPrefix)MappingButton.cpp" />
|
<ClCompile Include="$(QtMocOutPrefix)MappingButton.cpp" />
|
||||||
<ClCompile Include="$(QtMocOutPrefix)MappingWidget.cpp" />
|
<ClCompile Include="$(QtMocOutPrefix)MappingWidget.cpp" />
|
||||||
|
@ -177,6 +179,7 @@
|
||||||
<ClCompile Include="GameList\GameListModel.cpp" />
|
<ClCompile Include="GameList\GameListModel.cpp" />
|
||||||
<ClCompile Include="GameList\GameTracker.cpp" />
|
<ClCompile Include="GameList\GameTracker.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" />
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "DolphinQt2/Config/PropertiesDialog.h"
|
#include "DolphinQt2/Config/PropertiesDialog.h"
|
||||||
#include "DolphinQt2/GameList/GameList.h"
|
#include "DolphinQt2/GameList/GameList.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"
|
||||||
|
|
||||||
|
@ -34,7 +35,7 @@ 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 QSortFilterProxyModel(this);
|
m_table_proxy = new TableProxyModel(this);
|
||||||
m_table_proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
|
m_table_proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||||
m_table_proxy->setSortRole(Qt::InitialSortOrderRole);
|
m_table_proxy->setSortRole(Qt::InitialSortOrderRole);
|
||||||
m_table_proxy->setSourceModel(m_model);
|
m_table_proxy->setSourceModel(m_model);
|
||||||
|
@ -446,6 +447,12 @@ void GameList::OnColumnVisibilityToggled(const QString& row, bool visible)
|
||||||
m_table->setColumnHidden(rowname_to_col_index[row], !visible);
|
m_table->setColumnHidden(rowname_to_col_index[row], !visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameList::OnGameListVisibilityChanged()
|
||||||
|
{
|
||||||
|
m_table_proxy->invalidate();
|
||||||
|
m_list_proxy->invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
static bool CompressCB(const std::string& text, float percent, void* ptr)
|
static bool CompressCB(const std::string& text, float percent, void* ptr)
|
||||||
{
|
{
|
||||||
if (ptr == nullptr)
|
if (ptr == nullptr)
|
||||||
|
|
|
@ -25,6 +25,7 @@ public:
|
||||||
void SetListView() { SetPreferredView(false); }
|
void SetListView() { SetPreferredView(false); }
|
||||||
void SetViewColumn(int col, bool view) { m_table->setColumnHidden(col, !view); }
|
void SetViewColumn(int col, bool view) { m_table->setColumnHidden(col, !view); }
|
||||||
void OnColumnVisibilityToggled(const QString& row, bool visible);
|
void OnColumnVisibilityToggled(const QString& row, bool visible);
|
||||||
|
void OnGameListVisibilityChanged();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void GameSelected();
|
void GameSelected();
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "DolphinQt2/GameList/GameListModel.h"
|
#include "DolphinQt2/GameList/GameListModel.h"
|
||||||
|
#include "Core/ConfigManager.h"
|
||||||
#include "DiscIO/Enums.h"
|
#include "DiscIO/Enums.h"
|
||||||
#include "DolphinQt2/Resources.h"
|
#include "DolphinQt2/Resources.h"
|
||||||
#include "DolphinQt2/Settings.h"
|
#include "DolphinQt2/Settings.h"
|
||||||
|
@ -138,6 +138,63 @@ int GameListModel::columnCount(const QModelIndex& parent) const
|
||||||
return NUM_COLS;
|
return NUM_COLS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GameListModel::ShouldDisplayGameListItem(int index) const
|
||||||
|
{
|
||||||
|
QSharedPointer<GameFile> game = m_games[index];
|
||||||
|
|
||||||
|
const bool show_platform = [&game] {
|
||||||
|
switch (game->GetPlatformID())
|
||||||
|
{
|
||||||
|
case DiscIO::Platform::GAMECUBE_DISC:
|
||||||
|
return SConfig::GetInstance().m_ListGC;
|
||||||
|
case DiscIO::Platform::WII_DISC:
|
||||||
|
return SConfig::GetInstance().m_ListWii;
|
||||||
|
case DiscIO::Platform::WII_WAD:
|
||||||
|
return SConfig::GetInstance().m_ListWad;
|
||||||
|
case DiscIO::Platform::ELF_DOL:
|
||||||
|
return SConfig::GetInstance().m_ListElfDol;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
if (!show_platform)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
switch (game->GetCountryID())
|
||||||
|
{
|
||||||
|
case DiscIO::Country::COUNTRY_AUSTRALIA:
|
||||||
|
return SConfig::GetInstance().m_ListAustralia;
|
||||||
|
case DiscIO::Country::COUNTRY_EUROPE:
|
||||||
|
return SConfig::GetInstance().m_ListPal;
|
||||||
|
case DiscIO::Country::COUNTRY_FRANCE:
|
||||||
|
return SConfig::GetInstance().m_ListFrance;
|
||||||
|
case DiscIO::Country::COUNTRY_GERMANY:
|
||||||
|
return SConfig::GetInstance().m_ListGermany;
|
||||||
|
case DiscIO::Country::COUNTRY_ITALY:
|
||||||
|
return SConfig::GetInstance().m_ListItaly;
|
||||||
|
case DiscIO::Country::COUNTRY_JAPAN:
|
||||||
|
return SConfig::GetInstance().m_ListJap;
|
||||||
|
case DiscIO::Country::COUNTRY_KOREA:
|
||||||
|
return SConfig::GetInstance().m_ListKorea;
|
||||||
|
case DiscIO::Country::COUNTRY_NETHERLANDS:
|
||||||
|
return SConfig::GetInstance().m_ListNetherlands;
|
||||||
|
case DiscIO::Country::COUNTRY_RUSSIA:
|
||||||
|
return SConfig::GetInstance().m_ListRussia;
|
||||||
|
case DiscIO::Country::COUNTRY_SPAIN:
|
||||||
|
return SConfig::GetInstance().m_ListSpain;
|
||||||
|
case DiscIO::Country::COUNTRY_TAIWAN:
|
||||||
|
return SConfig::GetInstance().m_ListTaiwan;
|
||||||
|
case DiscIO::Country::COUNTRY_USA:
|
||||||
|
return SConfig::GetInstance().m_ListUsa;
|
||||||
|
case DiscIO::Country::COUNTRY_WORLD:
|
||||||
|
return SConfig::GetInstance().m_ListWorld;
|
||||||
|
case DiscIO::Country::COUNTRY_UNKNOWN:
|
||||||
|
default:
|
||||||
|
return SConfig::GetInstance().m_ListUnknown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GameListModel::UpdateGame(QSharedPointer<GameFile> game)
|
void GameListModel::UpdateGame(QSharedPointer<GameFile> game)
|
||||||
{
|
{
|
||||||
QString path = game->GetFilePath();
|
QString path = game->GetFilePath();
|
||||||
|
|
|
@ -27,6 +27,7 @@ public:
|
||||||
|
|
||||||
// Path of the Game at the specified index.
|
// Path of the Game at the specified index.
|
||||||
QString GetPath(int index) const { return m_games[index]->GetFilePath(); }
|
QString GetPath(int index) const { return m_games[index]->GetFilePath(); }
|
||||||
|
bool ShouldDisplayGameListItem(int index) const;
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
COL_PLATFORM = 0,
|
COL_PLATFORM = 0,
|
||||||
|
|
|
@ -34,3 +34,9 @@ QVariant ListProxyModel::data(const QModelIndex& i, int role) const
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ListProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
|
||||||
|
{
|
||||||
|
GameListModel* glm = qobject_cast<GameListModel*>(sourceModel());
|
||||||
|
return glm->ShouldDisplayGameListItem(source_row);
|
||||||
|
}
|
||||||
|
|
|
@ -15,4 +15,5 @@ class ListProxyModel final : public QSortFilterProxyModel
|
||||||
public:
|
public:
|
||||||
explicit ListProxyModel(QObject* parent = nullptr);
|
explicit ListProxyModel(QObject* parent = nullptr);
|
||||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||||
|
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
// 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);
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
// Copyright 2017 Dolphin Emulator Project
|
||||||
|
// Licensed under GPLv2+
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#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;
|
||||||
|
};
|
|
@ -199,6 +199,10 @@ void MainWindow::ConnectMenuBar()
|
||||||
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::ColumnVisibilityToggled, m_game_list,
|
connect(m_menu_bar, &MenuBar::ColumnVisibilityToggled, m_game_list,
|
||||||
&GameList::OnColumnVisibilityToggled);
|
&GameList::OnColumnVisibilityToggled);
|
||||||
|
connect(m_menu_bar, &MenuBar::GameListPlatformVisibilityToggled, m_game_list,
|
||||||
|
&GameList::OnGameListVisibilityChanged);
|
||||||
|
connect(m_menu_bar, &MenuBar::GameListRegionVisibilityToggled, m_game_list,
|
||||||
|
&GameList::OnGameListVisibilityChanged);
|
||||||
connect(m_menu_bar, &MenuBar::ShowAboutDialog, this, &MainWindow::ShowAboutDialog);
|
connect(m_menu_bar, &MenuBar::ShowAboutDialog, this, &MainWindow::ShowAboutDialog);
|
||||||
|
|
||||||
connect(this, &MainWindow::EmulationStarted, m_menu_bar, &MenuBar::EmulationStarted);
|
connect(this, &MainWindow::EmulationStarted, m_menu_bar, &MenuBar::EmulationStarted);
|
||||||
|
|
|
@ -191,6 +191,9 @@ void MenuBar::AddViewMenu()
|
||||||
AddGameListTypeSection(view_menu);
|
AddGameListTypeSection(view_menu);
|
||||||
view_menu->addSeparator();
|
view_menu->addSeparator();
|
||||||
AddTableColumnsMenu(view_menu);
|
AddTableColumnsMenu(view_menu);
|
||||||
|
view_menu->addSeparator();
|
||||||
|
AddShowPlatformsMenu(view_menu);
|
||||||
|
AddShowRegionsMenu(view_menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuBar::AddOptionsMenu()
|
void MenuBar::AddOptionsMenu()
|
||||||
|
@ -273,6 +276,66 @@ void MenuBar::AddTableColumnsMenu(QMenu* view_menu)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MenuBar::AddShowPlatformsMenu(QMenu* view_menu)
|
||||||
|
{
|
||||||
|
static const QMap<QString, bool*> platform_map{
|
||||||
|
{tr("Show Wii"), &SConfig::GetInstance().m_ListWii},
|
||||||
|
{tr("Show GameCube"), &SConfig::GetInstance().m_ListGC},
|
||||||
|
{tr("Show WAD"), &SConfig::GetInstance().m_ListWad},
|
||||||
|
{tr("Show ELF/DOL"), &SConfig::GetInstance().m_ListElfDol}};
|
||||||
|
|
||||||
|
QActionGroup* platform_group = new QActionGroup(this);
|
||||||
|
QMenu* plat_menu = view_menu->addMenu(tr("Show Platforms"));
|
||||||
|
platform_group->setExclusive(false);
|
||||||
|
|
||||||
|
for (const auto& key : platform_map.keys())
|
||||||
|
{
|
||||||
|
bool* config = platform_map[key];
|
||||||
|
QAction* action = platform_group->addAction(plat_menu->addAction(key));
|
||||||
|
action->setCheckable(true);
|
||||||
|
action->setChecked(*config);
|
||||||
|
connect(action, &QAction::toggled, [this, config, key](bool value) {
|
||||||
|
*config = value;
|
||||||
|
emit GameListPlatformVisibilityToggled(key, value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuBar::AddShowRegionsMenu(QMenu* view_menu)
|
||||||
|
{
|
||||||
|
static const QMap<QString, bool*> region_map{
|
||||||
|
{tr("Show JAP"), &SConfig::GetInstance().m_ListJap},
|
||||||
|
{tr("Show PAL"), &SConfig::GetInstance().m_ListPal},
|
||||||
|
{tr("Show USA"), &SConfig::GetInstance().m_ListUsa},
|
||||||
|
{tr("Show Australia"), &SConfig::GetInstance().m_ListAustralia},
|
||||||
|
{tr("Show France"), &SConfig::GetInstance().m_ListFrance},
|
||||||
|
{tr("Show Germany"), &SConfig::GetInstance().m_ListGermany},
|
||||||
|
{tr("Show Italy"), &SConfig::GetInstance().m_ListItaly},
|
||||||
|
{tr("Show Korea"), &SConfig::GetInstance().m_ListKorea},
|
||||||
|
{tr("Show Netherlands"), &SConfig::GetInstance().m_ListNetherlands},
|
||||||
|
{tr("Show Russia"), &SConfig::GetInstance().m_ListRussia},
|
||||||
|
{tr("Show Spain"), &SConfig::GetInstance().m_ListSpain},
|
||||||
|
{tr("Show Taiwan"), &SConfig::GetInstance().m_ListTaiwan},
|
||||||
|
{tr("Show World"), &SConfig::GetInstance().m_ListWorld},
|
||||||
|
{tr("Show Unknown"), &SConfig::GetInstance().m_ListUnknown}};
|
||||||
|
|
||||||
|
QActionGroup* region_group = new QActionGroup(this);
|
||||||
|
QMenu* region_menu = view_menu->addMenu(tr("Show Regions"));
|
||||||
|
region_group->setExclusive(false);
|
||||||
|
|
||||||
|
for (const auto& key : region_map.keys())
|
||||||
|
{
|
||||||
|
bool* config = region_map[key];
|
||||||
|
QAction* action = region_group->addAction(region_menu->addAction(key));
|
||||||
|
action->setCheckable(true);
|
||||||
|
action->setChecked(*config);
|
||||||
|
connect(action, &QAction::toggled, [this, config, key](bool value) {
|
||||||
|
*config = value;
|
||||||
|
emit GameListRegionVisibilityToggled(key, value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MenuBar::UpdateToolsMenu(bool emulation_started)
|
void MenuBar::UpdateToolsMenu(bool emulation_started)
|
||||||
{
|
{
|
||||||
m_boot_sysmenu->setEnabled(!emulation_started);
|
m_boot_sysmenu->setEnabled(!emulation_started);
|
||||||
|
|
|
@ -63,6 +63,8 @@ signals:
|
||||||
void ShowTable();
|
void ShowTable();
|
||||||
void ShowList();
|
void ShowList();
|
||||||
void ColumnVisibilityToggled(const QString& row, bool visible);
|
void ColumnVisibilityToggled(const QString& row, bool visible);
|
||||||
|
void GameListPlatformVisibilityToggled(const QString& row, bool visible);
|
||||||
|
void GameListRegionVisibilityToggled(const QString& row, bool visible);
|
||||||
|
|
||||||
void ShowAboutDialog();
|
void ShowAboutDialog();
|
||||||
|
|
||||||
|
@ -77,6 +79,8 @@ private:
|
||||||
void AddViewMenu();
|
void AddViewMenu();
|
||||||
void AddGameListTypeSection(QMenu* view_menu);
|
void AddGameListTypeSection(QMenu* view_menu);
|
||||||
void AddTableColumnsMenu(QMenu* view_menu);
|
void AddTableColumnsMenu(QMenu* view_menu);
|
||||||
|
void AddShowPlatformsMenu(QMenu* view_menu);
|
||||||
|
void AddShowRegionsMenu(QMenu* view_menu);
|
||||||
|
|
||||||
void AddOptionsMenu();
|
void AddOptionsMenu();
|
||||||
void AddToolsMenu();
|
void AddToolsMenu();
|
||||||
|
|
Loading…
Reference in New Issue