mirror of
https://github.com/PCSX2/pcsx2.git
synced 2025-12-16 04:08:48 +00:00
GameList: Add an option to exclude entire directories
This commit is contained in:
parent
023e4774a1
commit
be22b7349d
@ -51,6 +51,7 @@ GameListSettingsWidget::GameListSettingsWidget(SettingsDialog* dialog, QWidget*
|
|||||||
&GameListSettingsWidget::onAddSearchDirectoryButtonClicked);
|
&GameListSettingsWidget::onAddSearchDirectoryButtonClicked);
|
||||||
connect(m_ui.removeSearchDirectoryButton, &QPushButton::clicked, this,
|
connect(m_ui.removeSearchDirectoryButton, &QPushButton::clicked, this,
|
||||||
&GameListSettingsWidget::onRemoveSearchDirectoryButtonClicked);
|
&GameListSettingsWidget::onRemoveSearchDirectoryButtonClicked);
|
||||||
|
connect(m_ui.addExcludedFile, &QPushButton::clicked, this, &GameListSettingsWidget::onAddExcludedFileButtonClicked);
|
||||||
connect(m_ui.addExcludedPath, &QPushButton::clicked, this, &GameListSettingsWidget::onAddExcludedPathButtonClicked);
|
connect(m_ui.addExcludedPath, &QPushButton::clicked, this, &GameListSettingsWidget::onAddExcludedPathButtonClicked);
|
||||||
connect(m_ui.removeExcludedPath, &QPushButton::clicked, this,
|
connect(m_ui.removeExcludedPath, &QPushButton::clicked, this,
|
||||||
&GameListSettingsWidget::onRemoveExcludedPathButtonClicked);
|
&GameListSettingsWidget::onRemoveExcludedPathButtonClicked);
|
||||||
@ -215,10 +216,21 @@ void GameListSettingsWidget::onRemoveSearchDirectoryButtonClicked()
|
|||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameListSettingsWidget::onAddExcludedFileButtonClicked()
|
||||||
|
{
|
||||||
|
QString path =
|
||||||
|
QDir::toNativeSeparators(QFileDialog::getOpenFileName(QtUtils::GetRootWidget(this), tr("Select File")));
|
||||||
|
if (path.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
addExcludedPath(path.toStdString());
|
||||||
|
}
|
||||||
|
|
||||||
void GameListSettingsWidget::onAddExcludedPathButtonClicked()
|
void GameListSettingsWidget::onAddExcludedPathButtonClicked()
|
||||||
{
|
{
|
||||||
QString path =
|
QString path =
|
||||||
QDir::toNativeSeparators(QFileDialog::getOpenFileName(QtUtils::GetRootWidget(this), tr("Select Path")));
|
QDir::toNativeSeparators(QFileDialog::getExistingDirectory(QtUtils::GetRootWidget(this), tr("Select Directory")));
|
||||||
|
|
||||||
if (path.isEmpty())
|
if (path.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@ -39,6 +39,7 @@ private Q_SLOTS:
|
|||||||
void onDirectoryListContextMenuRequested(const QPoint& point);
|
void onDirectoryListContextMenuRequested(const QPoint& point);
|
||||||
void onAddSearchDirectoryButtonClicked();
|
void onAddSearchDirectoryButtonClicked();
|
||||||
void onRemoveSearchDirectoryButtonClicked();
|
void onRemoveSearchDirectoryButtonClicked();
|
||||||
|
void onAddExcludedFileButtonClicked();
|
||||||
void onAddExcludedPathButtonClicked();
|
void onAddExcludedPathButtonClicked();
|
||||||
void onRemoveExcludedPathButtonClicked();
|
void onRemoveExcludedPathButtonClicked();
|
||||||
void onScanForNewGamesClicked();
|
void onScanForNewGamesClicked();
|
||||||
|
|||||||
@ -57,12 +57,15 @@
|
|||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add</string>
|
<string>Add...</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="folder-add-line">
|
<iconset theme="folder-add-line">
|
||||||
<normaloff>.</normaloff>.</iconset>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolButtonStyle">
|
||||||
|
<enum>Qt::ToolButtonTextBesideIcon</enum>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -80,6 +83,9 @@
|
|||||||
<iconset theme="folder-reduce-line">
|
<iconset theme="folder-reduce-line">
|
||||||
<normaloff>.</normaloff>.</iconset>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolButtonStyle">
|
||||||
|
<enum>Qt::ToolButtonTextBesideIcon</enum>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -129,12 +135,35 @@
|
|||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add</string>
|
<string>Directory...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="folder-add-line">
|
||||||
|
<normaloff>.</normaloff>.</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="toolButtonStyle">
|
||||||
|
<enum>Qt::ToolButtonTextBesideIcon</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="addExcludedFile">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>File...</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="file-add-line">
|
<iconset theme="file-add-line">
|
||||||
<normaloff>.</normaloff>.</iconset>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolButtonStyle">
|
||||||
|
<enum>Qt::ToolButtonTextBesideIcon</enum>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -152,6 +181,9 @@
|
|||||||
<iconset theme="file-reduce-line">
|
<iconset theme="file-reduce-line">
|
||||||
<normaloff>.</normaloff>.</iconset>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolButtonStyle">
|
||||||
|
<enum>Qt::ToolButtonTextBesideIcon</enum>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|||||||
@ -371,12 +371,15 @@
|
|||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add</string>
|
<string>Add...</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="folder-add-line">
|
<iconset theme="folder-add-line">
|
||||||
<normaloff>.</normaloff>.</iconset>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolButtonStyle">
|
||||||
|
<enum>Qt::ToolButtonTextBesideIcon</enum>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -394,6 +397,9 @@
|
|||||||
<iconset theme="folder-reduce-line">
|
<iconset theme="folder-reduce-line">
|
||||||
<normaloff>.</normaloff>.</iconset>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolButtonStyle">
|
||||||
|
<enum>Qt::ToolButtonTextBesideIcon</enum>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|||||||
@ -582,7 +582,7 @@ void GameList::RewriteCacheFile()
|
|||||||
|
|
||||||
static bool IsPathExcluded(const std::vector<std::string>& excluded_paths, const std::string& path)
|
static bool IsPathExcluded(const std::vector<std::string>& excluded_paths, const std::string& path)
|
||||||
{
|
{
|
||||||
return (std::find(excluded_paths.begin(), excluded_paths.end(), path) != excluded_paths.end());
|
return std::find_if(excluded_paths.begin(), excluded_paths.end(), [&path](const std::string& entry) { return path.starts_with(entry); }) != excluded_paths.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameList::ScanDirectory(const char* path, bool recursive, bool only_cache, const std::vector<std::string>& excluded_paths,
|
void GameList::ScanDirectory(const char* path, bool recursive, bool only_cache, const std::vector<std::string>& excluded_paths,
|
||||||
@ -596,7 +596,7 @@ void GameList::ScanDirectory(const char* path, bool recursive, bool only_cache,
|
|||||||
FileSystem::FindResultsArray files;
|
FileSystem::FindResultsArray files;
|
||||||
FileSystem::FindFiles(path, "*",
|
FileSystem::FindFiles(path, "*",
|
||||||
recursive ? (FILESYSTEM_FIND_FILES | FILESYSTEM_FIND_HIDDEN_FILES | FILESYSTEM_FIND_RECURSIVE) :
|
recursive ? (FILESYSTEM_FIND_FILES | FILESYSTEM_FIND_HIDDEN_FILES | FILESYSTEM_FIND_RECURSIVE) :
|
||||||
(FILESYSTEM_FIND_FILES | FILESYSTEM_FIND_HIDDEN_FILES),
|
(FILESYSTEM_FIND_FILES | FILESYSTEM_FIND_HIDDEN_FILES),
|
||||||
&files);
|
&files);
|
||||||
|
|
||||||
u32 files_scanned = 0;
|
u32 files_scanned = 0;
|
||||||
@ -808,7 +808,7 @@ bool GameList::RescanPath(const std::string& path)
|
|||||||
{
|
{
|
||||||
// cancel if excluded
|
// cancel if excluded
|
||||||
const std::vector<std::string> excluded_paths(Host::GetBaseStringListSetting("GameList", "ExcludedPaths"));
|
const std::vector<std::string> excluded_paths(Host::GetBaseStringListSetting("GameList", "ExcludedPaths"));
|
||||||
if (std::find(excluded_paths.begin(), excluded_paths.end(), path) != excluded_paths.end())
|
if (IsPathExcluded(excluded_paths, path))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user