mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 19:45:20 +00:00
Qt: enable hiding on game list and optimize the game list filter
This commit is contained in:
parent
17d2124a71
commit
5492e0eae1
5 changed files with 105 additions and 59 deletions
|
@ -33,6 +33,7 @@ game_list_frame::game_list_frame(std::shared_ptr<gui_settings> guiSettings, std:
|
|||
m_Icon_Color = xgui_settings->GetValue(gui::gl_iconColor).value<QColor>();
|
||||
m_colSortOrder = xgui_settings->GetValue(gui::gl_sortAsc).toBool() ? Qt::AscendingOrder : Qt::DescendingOrder;
|
||||
m_sortColumn = xgui_settings->GetValue(gui::gl_sortCol).toInt();
|
||||
m_hidden_list = xgui_settings->GetValue(gui::gl_hidden_list).toStringList().toSet();
|
||||
|
||||
m_oldLayoutIsList = m_isListLayout;
|
||||
|
||||
|
@ -251,23 +252,17 @@ void game_list_frame::OnColClicked(int col)
|
|||
SortGameList();
|
||||
}
|
||||
|
||||
// Filter for Categories
|
||||
void game_list_frame::FilterData()
|
||||
// Get visibility of entries
|
||||
bool game_list_frame::IsEntryVisible(const GUI_GameInfo& game)
|
||||
{
|
||||
for (auto& game : m_game_data)
|
||||
auto matches_category = [&]()
|
||||
{
|
||||
bool match = false;
|
||||
const QString category = qstr(game.info.category);
|
||||
for (const auto& filter : m_categoryFilters)
|
||||
{
|
||||
if (category.contains(filter))
|
||||
{
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
game.isVisible = match && SearchMatchesApp(game.info.name, game.info.serial);
|
||||
}
|
||||
if (m_isListLayout)
|
||||
return m_categoryFilters.contains(qstr(game.info.category));
|
||||
return category::CategoryInMap(game.info.category, category::cat_boot);
|
||||
};
|
||||
bool is_visible = m_show_hidden || !m_hidden_list.contains(qstr(game.info.serial));
|
||||
return is_visible && matches_category() && SearchMatchesApp(game.info.name, game.info.serial);
|
||||
}
|
||||
|
||||
void game_list_frame::SortGameList()
|
||||
|
@ -314,6 +309,8 @@ void game_list_frame::Refresh(const bool fromDrive, const bool scrollAfter)
|
|||
// Used to remove duplications from the list (serial -> set of cats)
|
||||
std::map<std::string, std::set<std::string>> serial_cat;
|
||||
|
||||
QSet<QString> serials;
|
||||
|
||||
for (const auto& dir : path_list) { try
|
||||
{
|
||||
const std::string sfb = dir + "/PS3_DISC.SFB";
|
||||
|
@ -344,6 +341,8 @@ void game_list_frame::Refresh(const bool fromDrive, const bool scrollAfter)
|
|||
continue;
|
||||
}
|
||||
|
||||
serials.insert(qstr(game.serial));
|
||||
|
||||
bool bootable = false;
|
||||
auto cat = category::cat_boot.find(game.category);
|
||||
if (cat != category::cat_boot.end())
|
||||
|
@ -387,7 +386,7 @@ void game_list_frame::Refresh(const bool fromDrive, const bool scrollAfter)
|
|||
|
||||
QPixmap pxmap = PaintedPixmap(img, hasCustomConfig);
|
||||
|
||||
m_game_data.push_back({ game, m_game_compat->GetCompatibility(game.serial), img, pxmap, true, bootable, hasCustomConfig });
|
||||
m_game_data.push_back({ game, m_game_compat->GetCompatibility(game.serial), img, pxmap, bootable, hasCustomConfig });
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
|
@ -403,6 +402,10 @@ void game_list_frame::Refresh(const bool fromDrive, const bool scrollAfter)
|
|||
|
||||
// Sort by name at the very least.
|
||||
std::sort(m_game_data.begin(), m_game_data.end(), op);
|
||||
|
||||
// clean up hidden games list
|
||||
m_hidden_list.intersect(serials);
|
||||
xgui_settings->SetValue(gui::gl_hidden_list, QStringList(m_hidden_list.toList()));
|
||||
}
|
||||
|
||||
// Fill Game List / Game Grid
|
||||
|
@ -410,7 +413,6 @@ void game_list_frame::Refresh(const bool fromDrive, const bool scrollAfter)
|
|||
if (m_isListLayout)
|
||||
{
|
||||
int scroll_position = m_gameList->verticalScrollBar()->value();
|
||||
FilterData();
|
||||
int row = PopulateGameList();
|
||||
m_gameList->selectRow(row);
|
||||
SortGameList();
|
||||
|
@ -538,6 +540,7 @@ void game_list_frame::ShowSpecifiedContextMenu(const QPoint &pos, int row)
|
|||
}
|
||||
|
||||
GameInfo currGame = m_game_data[row].info;
|
||||
const QString serial = qstr(currGame.serial);
|
||||
|
||||
// Make Actions
|
||||
QMenu myMenu;
|
||||
|
@ -547,6 +550,10 @@ void game_list_frame::ShowSpecifiedContextMenu(const QPoint &pos, int row)
|
|||
boot->setFont(f);
|
||||
QAction* configure = myMenu.addAction(tr("&Configure"));
|
||||
myMenu.addSeparator();
|
||||
QAction* hide_serial = myMenu.addAction(tr("&Hide From Game List"));
|
||||
hide_serial->setCheckable(true);
|
||||
hide_serial->setChecked(m_hidden_list.contains(serial));
|
||||
myMenu.addSeparator();
|
||||
QAction* removeGame = myMenu.addAction(tr("&Remove %1").arg(qstr(currGame.category)));
|
||||
QAction* removeConfig = myMenu.addAction(tr("&Remove Custom Configuration"));
|
||||
QAction* deleteShadersCache = myMenu.addAction(tr("&Delete Shaders Cache"));
|
||||
|
@ -574,6 +581,16 @@ void game_list_frame::ShowSpecifiedContextMenu(const QPoint &pos, int row)
|
|||
});
|
||||
dlg.exec();
|
||||
});
|
||||
connect(hide_serial, &QAction::triggered, [=](bool checked)
|
||||
{
|
||||
if (checked)
|
||||
m_hidden_list.insert(serial);
|
||||
else
|
||||
m_hidden_list.remove(serial);
|
||||
|
||||
xgui_settings->SetValue(gui::gl_hidden_list, QStringList(m_hidden_list.toList()));
|
||||
Refresh();
|
||||
});
|
||||
connect(removeGame, &QAction::triggered, [=]
|
||||
{
|
||||
QMessageBox* mb = new QMessageBox(QMessageBox::Question, tr("Confirm %1 Removal").arg(qstr(currGame.category)), tr("Permanently remove %1 from drive?").arg(qstr(currGame.name)), QMessageBox::Yes | QMessageBox::No, this);
|
||||
|
@ -785,6 +802,11 @@ void game_list_frame::RepaintIcons(const bool& fromSettings)
|
|||
Refresh();
|
||||
}
|
||||
|
||||
void game_list_frame::SetShowHidden(bool show)
|
||||
{
|
||||
m_show_hidden = show;
|
||||
}
|
||||
|
||||
void game_list_frame::SetListMode(const bool& isList)
|
||||
{
|
||||
m_oldLayoutIsList = m_isListLayout;
|
||||
|
@ -882,10 +904,8 @@ int game_list_frame::PopulateGameList()
|
|||
{
|
||||
index++;
|
||||
|
||||
if (!game.isVisible)
|
||||
{
|
||||
if (!IsEntryVisible(game))
|
||||
continue;
|
||||
}
|
||||
|
||||
// Icon
|
||||
QTableWidgetItem* icon_item = new QTableWidgetItem;
|
||||
|
@ -959,7 +979,7 @@ void game_list_frame::PopulateGameGrid(int maxCols, const QSize& image_size, con
|
|||
|
||||
for (uint i = 0; i < m_game_data.size(); i++)
|
||||
{
|
||||
if (category::CategoryInMap(m_game_data[i].info.category, category::cat_boot) && SearchMatchesApp(m_game_data[i].info.name, m_game_data[i].info.serial))
|
||||
if (IsEntryVisible(m_game_data[i]))
|
||||
{
|
||||
matching_apps.append(QPair<GUI_GameInfo*, int>(&m_game_data[i], i));
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <QToolBar>
|
||||
#include <QLineEdit>
|
||||
#include <QStackedWidget>
|
||||
#include <QSet>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
@ -165,7 +166,6 @@ struct GUI_GameInfo
|
|||
Compat_Status compat;
|
||||
QImage icon;
|
||||
QPixmap pxmap;
|
||||
bool isVisible;
|
||||
bool bootable;
|
||||
bool hasCustomConfig;
|
||||
};
|
||||
|
@ -196,6 +196,8 @@ public:
|
|||
/** Repaint Gamelist Icons with new background color */
|
||||
void RepaintIcons(const bool& fromSettings = false);
|
||||
|
||||
void SetShowHidden(bool show);
|
||||
|
||||
public Q_SLOTS:
|
||||
void SetListMode(const bool& isList);
|
||||
void SetSearchText(const QString& text);
|
||||
|
@ -220,7 +222,7 @@ protected:
|
|||
private:
|
||||
QPixmap PaintedPixmap(const QImage& img, bool paintConfigIcon = false);
|
||||
void PopulateGameGrid(int maxCols, const QSize& image_size, const QColor& image_color);
|
||||
void FilterData();
|
||||
bool IsEntryVisible(const GUI_GameInfo& game);
|
||||
void SortGameList();
|
||||
|
||||
int PopulateGameList();
|
||||
|
@ -254,6 +256,8 @@ private:
|
|||
std::shared_ptr<gui_settings> xgui_settings;
|
||||
std::shared_ptr<emu_settings> xemu_settings;
|
||||
std::vector<GUI_GameInfo> m_game_data;
|
||||
QSet<QString> m_hidden_list;
|
||||
bool m_show_hidden{false};
|
||||
|
||||
// Search
|
||||
QString m_search_text;
|
||||
|
|
|
@ -128,43 +128,45 @@ namespace gui
|
|||
const gui_save rg_freeze = gui_save(main_window, "recentGamesFrozen", false);
|
||||
const gui_save rg_entries = gui_save(main_window, "recentGamesNames", QVariant::fromValue(q_pair_list()));
|
||||
|
||||
const gui_save ib_pkg_success = gui_save(main_window, "infoBoxEnabledInstallPKG", true );
|
||||
const gui_save ib_pup_success = gui_save(main_window, "infoBoxEnabledInstallPUP", true );
|
||||
const gui_save ib_show_welcome = gui_save(main_window, "infoBoxEnabledWelcome", true );
|
||||
const gui_save ib_pkg_success = gui_save(main_window, "infoBoxEnabledInstallPKG", true);
|
||||
const gui_save ib_pup_success = gui_save(main_window, "infoBoxEnabledInstallPUP", true);
|
||||
const gui_save ib_show_welcome = gui_save(main_window, "infoBoxEnabledWelcome", true);
|
||||
|
||||
const gui_save fd_install_pkg = gui_save(main_window, "lastExplorePathPKG", "" );
|
||||
const gui_save fd_install_pup = gui_save(main_window, "lastExplorePathPUP", "" );
|
||||
const gui_save fd_boot_elf = gui_save(main_window, "lastExplorePathELF", "" );
|
||||
const gui_save fd_boot_game = gui_save(main_window, "lastExplorePathGAME", "" );
|
||||
const gui_save fd_decrypt_sprx = gui_save(main_window, "lastExplorePathSPRX", "" );
|
||||
const gui_save fd_cg_disasm = gui_save(main_window, "lastExplorePathCGD", "" );
|
||||
const gui_save fd_install_pkg = gui_save(main_window, "lastExplorePathPKG", "");
|
||||
const gui_save fd_install_pup = gui_save(main_window, "lastExplorePathPUP", "");
|
||||
const gui_save fd_boot_elf = gui_save(main_window, "lastExplorePathELF", "");
|
||||
const gui_save fd_boot_game = gui_save(main_window, "lastExplorePathGAME", "");
|
||||
const gui_save fd_decrypt_sprx = gui_save(main_window, "lastExplorePathSPRX", "");
|
||||
const gui_save fd_cg_disasm = gui_save(main_window, "lastExplorePathCGD", "");
|
||||
|
||||
const gui_save mw_debugger = gui_save(main_window, "debuggerVisible", false );
|
||||
const gui_save mw_logger = gui_save(main_window, "loggerVisible", true );
|
||||
const gui_save mw_gamelist = gui_save(main_window, "gamelistVisible", true );
|
||||
const gui_save mw_toolBarVisible = gui_save(main_window, "toolBarVisible", true );
|
||||
const gui_save mw_debugger = gui_save(main_window, "debuggerVisible", false);
|
||||
const gui_save mw_logger = gui_save(main_window, "loggerVisible", true);
|
||||
const gui_save mw_gamelist = gui_save(main_window, "gamelistVisible", true);
|
||||
const gui_save mw_toolBarVisible = gui_save(main_window, "toolBarVisible", true);
|
||||
const gui_save mw_toolBarColor = gui_save(main_window, "toolBarColor", mw_tool_bar_color);
|
||||
const gui_save mw_toolIconColor = gui_save(main_window, "toolIconColor", mw_tool_icon_color);
|
||||
const gui_save mw_geometry = gui_save(main_window, "geometry", QByteArray() );
|
||||
const gui_save mw_windowState = gui_save(main_window, "windowState", QByteArray() );
|
||||
const gui_save mw_mwState = gui_save(main_window, "wwState", QByteArray() );
|
||||
const gui_save mw_geometry = gui_save(main_window, "geometry", QByteArray());
|
||||
const gui_save mw_windowState = gui_save(main_window, "windowState", QByteArray());
|
||||
const gui_save mw_mwState = gui_save(main_window, "wwState", QByteArray());
|
||||
|
||||
const gui_save cat_hdd_game = gui_save(game_list, "categoryVisibleHDDGame", true );
|
||||
const gui_save cat_disc_game = gui_save(game_list, "categoryVisibleDiscGame", true );
|
||||
const gui_save cat_home = gui_save(game_list, "categoryVisibleHome", true );
|
||||
const gui_save cat_audio_video = gui_save(game_list, "categoryVisibleAudioVideo", true );
|
||||
const gui_save cat_game_data = gui_save(game_list, "categoryVisibleGameData", false );
|
||||
const gui_save cat_unknown = gui_save(game_list, "categoryVisibleUnknown", true );
|
||||
const gui_save cat_other = gui_save(game_list, "categoryVisibleOther", true );
|
||||
const gui_save cat_hdd_game = gui_save(game_list, "categoryVisibleHDDGame", true);
|
||||
const gui_save cat_disc_game = gui_save(game_list, "categoryVisibleDiscGame", true);
|
||||
const gui_save cat_home = gui_save(game_list, "categoryVisibleHome", true);
|
||||
const gui_save cat_audio_video = gui_save(game_list, "categoryVisibleAudioVideo", true);
|
||||
const gui_save cat_game_data = gui_save(game_list, "categoryVisibleGameData", false);
|
||||
const gui_save cat_unknown = gui_save(game_list, "categoryVisibleUnknown", true);
|
||||
const gui_save cat_other = gui_save(game_list, "categoryVisibleOther", true);
|
||||
|
||||
const gui_save gl_sortAsc = gui_save(game_list, "sortAsc", true );
|
||||
const gui_save gl_sortCol = gui_save(game_list, "sortCol", 1 );
|
||||
const gui_save gl_state = gui_save(game_list, "state", QByteArray() );
|
||||
const gui_save gl_iconSize = gui_save(game_list, "iconSize", get_Index(gl_icon_size_small));
|
||||
const gui_save gl_iconColor = gui_save(game_list, "iconColor", gl_icon_color);
|
||||
const gui_save gl_listMode = gui_save(game_list, "listMode", true );
|
||||
const gui_save gl_textFactor = gui_save(game_list, "textFactor", (qreal) 2.0 );
|
||||
const gui_save gl_marginFactor = gui_save(game_list, "marginFactor", (qreal) 0.09 );
|
||||
const gui_save gl_sortAsc = gui_save(game_list, "sortAsc", true);
|
||||
const gui_save gl_sortCol = gui_save(game_list, "sortCol", 1);
|
||||
const gui_save gl_state = gui_save(game_list, "state", QByteArray());
|
||||
const gui_save gl_iconSize = gui_save(game_list, "iconSize", get_Index(gl_icon_size_small));
|
||||
const gui_save gl_iconColor = gui_save(game_list, "iconColor", gl_icon_color);
|
||||
const gui_save gl_listMode = gui_save(game_list, "listMode", true);
|
||||
const gui_save gl_textFactor = gui_save(game_list, "textFactor", (qreal) 2.0);
|
||||
const gui_save gl_marginFactor = gui_save(game_list, "marginFactor", (qreal) 0.09);
|
||||
const gui_save gl_show_hidden = gui_save(game_list, "show_hidden", false);
|
||||
const gui_save gl_hidden_list = gui_save(game_list, "hidden_list", QStringList());
|
||||
|
||||
const gui_save fs_emulator_dir_list = gui_save(fs, "emulator_dir_list", QStringList());
|
||||
const gui_save fs_dev_hdd0_list = gui_save(fs, "dev_hdd0_list", QStringList());
|
||||
|
@ -172,12 +174,12 @@ namespace gui
|
|||
const gui_save fs_dev_flash_list = gui_save(fs, "dev_flash_list", QStringList());
|
||||
const gui_save fs_dev_usb000_list = gui_save(fs, "dev_usb000_list", QStringList());
|
||||
|
||||
const gui_save l_tty = gui_save(logger, "TTY", true );
|
||||
const gui_save l_level = gui_save(logger, "level", (uint)(logs::level::success) );
|
||||
const gui_save l_stack = gui_save(logger, "stack", true );
|
||||
const gui_save l_tty = gui_save(logger, "TTY", true);
|
||||
const gui_save l_level = gui_save(logger, "level", (uint)(logs::level::success));
|
||||
const gui_save l_stack = gui_save(logger, "stack", true);
|
||||
|
||||
const gui_save d_splitterState = gui_save(debugger, "splitterState", QByteArray());
|
||||
const gui_save d_centerPC = gui_save(debugger, "centerPC", false);
|
||||
const gui_save d_centerPC = gui_save(debugger, "centerPC", false);
|
||||
|
||||
const gui_save m_currentConfig = gui_save(meta, "currentConfig", QObject::tr("CurrentSettings"));
|
||||
const gui_save m_currentStylesheet = gui_save(meta, "currentStylesheet", Default);
|
||||
|
|
|
@ -1186,6 +1186,13 @@ void main_window::CreateConnects()
|
|||
guiSettings->SetValue(gui::mw_toolBarVisible, checked);
|
||||
});
|
||||
|
||||
connect(ui->showHiddenEntriesAct, &QAction::triggered, [=](bool checked)
|
||||
{
|
||||
guiSettings->SetValue(gui::gl_show_hidden, checked);
|
||||
m_gameListFrame->SetShowHidden(checked);
|
||||
m_gameListFrame->Refresh();
|
||||
});
|
||||
|
||||
connect(ui->refreshGameListAct, &QAction::triggered, [=]
|
||||
{
|
||||
m_gameListFrame->Refresh(true);
|
||||
|
@ -1411,6 +1418,9 @@ void main_window::ConfigureGuiFromSettings(bool configure_all)
|
|||
|
||||
RepaintToolbar();
|
||||
|
||||
ui->showHiddenEntriesAct->setChecked(guiSettings->GetValue(gui::gl_show_hidden).toBool());
|
||||
m_gameListFrame->SetShowHidden(ui->showHiddenEntriesAct->isChecked()); // prevent GetValue in m_gameListFrame->LoadSettings
|
||||
|
||||
ui->showCatHDDGameAct->setChecked(guiSettings->GetCategoryVisibility(Category::Non_Disc_Game));
|
||||
ui->showCatDiscGameAct->setChecked(guiSettings->GetCategoryVisibility(Category::Disc_Game));
|
||||
ui->showCatHomeAct->setChecked(guiSettings->GetCategoryVisibility(Category::Home));
|
||||
|
|
|
@ -141,7 +141,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1058</width>
|
||||
<height>38</height>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
|
@ -261,6 +261,8 @@
|
|||
<addaction name="separator"/>
|
||||
<addaction name="showGameListAct"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="showHiddenEntriesAct"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="refreshGameListAct"/>
|
||||
<addaction name="menuGame_List_Mode"/>
|
||||
<addaction name="menuGame_List_Icons"/>
|
||||
|
@ -941,6 +943,14 @@
|
|||
<string>Show Game Tool Bar</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="showHiddenEntriesAct">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show Hidden Entries</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources>
|
||||
|
|
Loading…
Add table
Reference in a new issue