mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-22 13:55:38 +00:00
Qt: Add game list excluded folders as well as files
Backport of https://github.com/PCSX2/pcsx2/pull/9730
This commit is contained in:
parent
4ca7753720
commit
ffb5682b43
|
@ -479,7 +479,8 @@ void GameList::DeleteCacheFile()
|
|||
|
||||
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,
|
||||
|
|
|
@ -44,9 +44,15 @@ GameListSettingsWidget::GameListSettingsWidget(SettingsWindow* dialog, QWidget*
|
|||
&GameListSettingsWidget::onAddSearchDirectoryButtonClicked);
|
||||
connect(m_ui.removeSearchDirectoryButton, &QPushButton::clicked, this,
|
||||
&GameListSettingsWidget::onRemoveSearchDirectoryButtonClicked);
|
||||
connect(m_ui.addExcludedPath, &QPushButton::clicked, this, &GameListSettingsWidget::onAddExcludedPathButtonClicked);
|
||||
connect(m_ui.searchDirectoryList->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||
&GameListSettingsWidget::onSearchDirectoriesSelectionChanged);
|
||||
connect(m_ui.addExcludedFile, &QPushButton::clicked, this, &GameListSettingsWidget::onAddExcludedFileButtonClicked);
|
||||
connect(m_ui.addExcludedFolder, &QPushButton::clicked, this,
|
||||
&GameListSettingsWidget::onAddExcludedFolderButtonClicked);
|
||||
connect(m_ui.removeExcludedPath, &QPushButton::clicked, this,
|
||||
&GameListSettingsWidget::onRemoveExcludedPathButtonClicked);
|
||||
connect(m_ui.excludedPaths, &QListWidget::itemSelectionChanged, this,
|
||||
&GameListSettingsWidget::onExcludedPathsSelectionChanged);
|
||||
connect(m_ui.rescanAllGames, &QPushButton::clicked, this, &GameListSettingsWidget::onRescanAllGamesClicked);
|
||||
connect(m_ui.scanForNewGames, &QPushButton::clicked, this, &GameListSettingsWidget::onScanForNewGamesClicked);
|
||||
|
||||
|
@ -73,6 +79,8 @@ void GameListSettingsWidget::refreshExclusionList()
|
|||
const std::vector<std::string> paths(Host::GetBaseStringListSetting("GameList", "ExcludedPaths"));
|
||||
for (const std::string& path : paths)
|
||||
m_ui.excludedPaths->addItem(QString::fromStdString(path));
|
||||
|
||||
m_ui.removeExcludedPath->setEnabled(false);
|
||||
}
|
||||
|
||||
void GameListSettingsWidget::resizeEvent(QResizeEvent* event)
|
||||
|
@ -147,7 +155,12 @@ void GameListSettingsWidget::onRemoveSearchDirectoryButtonClicked()
|
|||
m_search_directories_model->removeEntry(row);
|
||||
}
|
||||
|
||||
void GameListSettingsWidget::onAddExcludedPathButtonClicked()
|
||||
void GameListSettingsWidget::onSearchDirectoriesSelectionChanged()
|
||||
{
|
||||
m_ui.removeSearchDirectoryButton->setEnabled(m_ui.searchDirectoryList->selectionModel()->hasSelection());
|
||||
}
|
||||
|
||||
void GameListSettingsWidget::onAddExcludedFileButtonClicked()
|
||||
{
|
||||
QString path =
|
||||
QDir::toNativeSeparators(QFileDialog::getOpenFileName(QtUtils::GetRootWidget(this), tr("Select Path")));
|
||||
|
@ -157,6 +170,16 @@ void GameListSettingsWidget::onAddExcludedPathButtonClicked()
|
|||
addExcludedPath(path.toStdString());
|
||||
}
|
||||
|
||||
void GameListSettingsWidget::onAddExcludedFolderButtonClicked()
|
||||
{
|
||||
QString path =
|
||||
QDir::toNativeSeparators(QFileDialog::getExistingDirectory(QtUtils::GetRootWidget(this), tr("Select Directory")));
|
||||
if (path.isEmpty())
|
||||
return;
|
||||
|
||||
addExcludedPath(path.toStdString());
|
||||
}
|
||||
|
||||
void GameListSettingsWidget::onRemoveExcludedPathButtonClicked()
|
||||
{
|
||||
const int row = m_ui.excludedPaths->currentRow();
|
||||
|
@ -171,6 +194,11 @@ void GameListSettingsWidget::onRemoveExcludedPathButtonClicked()
|
|||
g_main_window->refreshGameList(false);
|
||||
}
|
||||
|
||||
void GameListSettingsWidget::onExcludedPathsSelectionChanged()
|
||||
{
|
||||
m_ui.removeExcludedPath->setEnabled(!m_ui.excludedPaths->selectedItems().isEmpty());
|
||||
}
|
||||
|
||||
void GameListSettingsWidget::onRescanAllGamesClicked()
|
||||
{
|
||||
g_main_window->refreshGameList(true);
|
||||
|
|
|
@ -29,8 +29,11 @@ private Q_SLOTS:
|
|||
void onDirectoryListContextMenuRequested(const QPoint& point);
|
||||
void onAddSearchDirectoryButtonClicked();
|
||||
void onRemoveSearchDirectoryButtonClicked();
|
||||
void onAddExcludedPathButtonClicked();
|
||||
void onSearchDirectoriesSelectionChanged();
|
||||
void onAddExcludedFileButtonClicked();
|
||||
void onAddExcludedFolderButtonClicked();
|
||||
void onRemoveExcludedPathButtonClicked();
|
||||
void onExcludedPathsSelectionChanged();
|
||||
void onScanForNewGamesClicked();
|
||||
void onRescanAllGamesClicked();
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@
|
|||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="addExcludedPath">
|
||||
<widget class="QToolButton" name="addExcludedFile">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -113,11 +113,33 @@
|
|||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
<string>File...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="file-add-line"/>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextBesideIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="addExcludedFolder">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Folder...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="folder-add-line"/>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextBesideIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -134,6 +156,9 @@
|
|||
<property name="icon">
|
||||
<iconset theme="folder-reduce-line"/>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextBesideIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -251,6 +251,8 @@ void SetupWizardDialog::setupGameListPage()
|
|||
&SetupWizardDialog::onAddSearchDirectoryButtonClicked);
|
||||
connect(m_ui.removeSearchDirectoryButton, &QPushButton::clicked, this,
|
||||
&SetupWizardDialog::onRemoveSearchDirectoryButtonClicked);
|
||||
connect(m_ui.searchDirectoryList, &QTableWidget::itemSelectionChanged, this,
|
||||
&SetupWizardDialog::onSearchDirectoryListSelectionChanged);
|
||||
|
||||
refreshDirectoryList();
|
||||
}
|
||||
|
@ -314,6 +316,11 @@ void SetupWizardDialog::onRemoveSearchDirectoryButtonClicked()
|
|||
refreshDirectoryList();
|
||||
}
|
||||
|
||||
void SetupWizardDialog::onSearchDirectoryListSelectionChanged()
|
||||
{
|
||||
m_ui.removeSearchDirectoryButton->setEnabled(!m_ui.searchDirectoryList->selectedItems().isEmpty());
|
||||
}
|
||||
|
||||
void SetupWizardDialog::addPathToTable(const std::string& path, bool recursive)
|
||||
{
|
||||
const int row = m_ui.searchDirectoryList->rowCount();
|
||||
|
@ -359,6 +366,7 @@ void SetupWizardDialog::refreshDirectoryList()
|
|||
addPathToTable(entry, true);
|
||||
|
||||
m_ui.searchDirectoryList->sortByColumn(0, Qt::AscendingOrder);
|
||||
m_ui.removeSearchDirectoryButton->setEnabled(false);
|
||||
}
|
||||
|
||||
void SetupWizardDialog::resizeDirectoryListColumns()
|
||||
|
|
|
@ -38,6 +38,7 @@ private Q_SLOTS:
|
|||
void onDirectoryListContextMenuRequested(const QPoint& point);
|
||||
void onAddSearchDirectoryButtonClicked();
|
||||
void onRemoveSearchDirectoryButtonClicked();
|
||||
void onSearchDirectoryListSelectionChanged();
|
||||
void refreshDirectoryList();
|
||||
void resizeDirectoryListColumns();
|
||||
|
||||
|
|
Loading…
Reference in a new issue