mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-18 06:25:37 +00:00
Qt: Add game list exclude path UI
This commit is contained in:
parent
b2a5f35d44
commit
409c2b36ff
|
@ -14,6 +14,9 @@ public:
|
||||||
void Destroy();
|
void Destroy();
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
|
u8* GetCodePointer() const { return m_code_ptr; }
|
||||||
|
u32 GetTotalSize() const { return m_total_size; }
|
||||||
|
|
||||||
u8* GetFreeCodePointer() const { return m_free_code_ptr; }
|
u8* GetFreeCodePointer() const { return m_free_code_ptr; }
|
||||||
u32 GetFreeCodeSpace() const { return static_cast<u32>(m_code_size - m_code_used); }
|
u32 GetFreeCodeSpace() const { return static_cast<u32>(m_code_size - m_code_used); }
|
||||||
void CommitCode(u32 length);
|
void CommitCode(u32 length);
|
||||||
|
|
|
@ -39,12 +39,36 @@ GameListSettingsWidget::GameListSettingsWidget(QtHostInterface* host_interface,
|
||||||
&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.addExcludedPath, &QPushButton::clicked, this, &GameListSettingsWidget::onAddExcludedPathButtonClicked);
|
||||||
|
connect(m_ui.removeExcludedPath, &QPushButton::clicked, this,
|
||||||
|
&GameListSettingsWidget::onRemoveExcludedPathButtonClicked);
|
||||||
connect(m_ui.rescanAllGames, &QPushButton::clicked, this, &GameListSettingsWidget::onRescanAllGamesClicked);
|
connect(m_ui.rescanAllGames, &QPushButton::clicked, this, &GameListSettingsWidget::onRescanAllGamesClicked);
|
||||||
connect(m_ui.scanForNewGames, &QPushButton::clicked, this, &GameListSettingsWidget::onScanForNewGamesClicked);
|
connect(m_ui.scanForNewGames, &QPushButton::clicked, this, &GameListSettingsWidget::onScanForNewGamesClicked);
|
||||||
|
|
||||||
|
refreshExclusionList();
|
||||||
}
|
}
|
||||||
|
|
||||||
GameListSettingsWidget::~GameListSettingsWidget() = default;
|
GameListSettingsWidget::~GameListSettingsWidget() = default;
|
||||||
|
|
||||||
|
bool GameListSettingsWidget::addExcludedPath(const std::string& path)
|
||||||
|
{
|
||||||
|
if (!m_host_interface->AddValueToStringList("GameList", "ExcludedPaths", path.c_str()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_ui.excludedPaths->addItem(QString::fromStdString(path));
|
||||||
|
m_host_interface->refreshGameList();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameListSettingsWidget::refreshExclusionList()
|
||||||
|
{
|
||||||
|
m_ui.excludedPaths->clear();
|
||||||
|
|
||||||
|
const std::vector<std::string> paths(m_host_interface->GetSettingStringList("GameList", "ExcludedPaths"));
|
||||||
|
for (const std::string& path : paths)
|
||||||
|
m_ui.excludedPaths->addItem(QString::fromStdString(path));
|
||||||
|
}
|
||||||
|
|
||||||
void GameListSettingsWidget::resizeEvent(QResizeEvent* event)
|
void GameListSettingsWidget::resizeEvent(QResizeEvent* event)
|
||||||
{
|
{
|
||||||
QWidget::resizeEvent(event);
|
QWidget::resizeEvent(event);
|
||||||
|
@ -117,6 +141,29 @@ void GameListSettingsWidget::onRemoveSearchDirectoryButtonClicked()
|
||||||
m_search_directories_model->removeEntry(row);
|
m_search_directories_model->removeEntry(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameListSettingsWidget::onAddExcludedPathButtonClicked()
|
||||||
|
{
|
||||||
|
QString path =
|
||||||
|
QDir::toNativeSeparators(QFileDialog::getOpenFileName(QtUtils::GetRootWidget(this), tr("Select Path")));
|
||||||
|
if (path.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
addExcludedPath(path.toStdString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameListSettingsWidget::onRemoveExcludedPathButtonClicked()
|
||||||
|
{
|
||||||
|
const int row = m_ui.excludedPaths->currentRow();
|
||||||
|
QListWidgetItem* item = (row >= 0) ? m_ui.excludedPaths->takeItem(row) : 0;
|
||||||
|
if (!item)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_host_interface->RemoveValueFromStringList("GameList", "ExcludedPaths", item->text().toUtf8().constData());
|
||||||
|
delete item;
|
||||||
|
|
||||||
|
m_host_interface->refreshGameList();
|
||||||
|
}
|
||||||
|
|
||||||
void GameListSettingsWidget::onRescanAllGamesClicked()
|
void GameListSettingsWidget::onRescanAllGamesClicked()
|
||||||
{
|
{
|
||||||
m_host_interface->refreshGameList(true, false);
|
m_host_interface->refreshGameList(true, false);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <string>
|
||||||
#include <QtWidgets/QWidget>
|
#include <QtWidgets/QWidget>
|
||||||
|
|
||||||
#include "ui_gamelistsettingswidget.h"
|
#include "ui_gamelistsettingswidget.h"
|
||||||
|
@ -16,6 +16,9 @@ public:
|
||||||
GameListSettingsWidget(QtHostInterface* host_interface, QWidget* parent = nullptr);
|
GameListSettingsWidget(QtHostInterface* host_interface, QWidget* parent = nullptr);
|
||||||
~GameListSettingsWidget();
|
~GameListSettingsWidget();
|
||||||
|
|
||||||
|
bool addExcludedPath(const std::string& path);
|
||||||
|
void refreshExclusionList();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void addSearchDirectory(QWidget* parent_widget);
|
void addSearchDirectory(QWidget* parent_widget);
|
||||||
|
|
||||||
|
@ -24,6 +27,8 @@ private Q_SLOTS:
|
||||||
void onDirectoryListContextMenuRequested(const QPoint& point);
|
void onDirectoryListContextMenuRequested(const QPoint& point);
|
||||||
void onAddSearchDirectoryButtonClicked();
|
void onAddSearchDirectoryButtonClicked();
|
||||||
void onRemoveSearchDirectoryButtonClicked();
|
void onRemoveSearchDirectoryButtonClicked();
|
||||||
|
void onAddExcludedPathButtonClicked();
|
||||||
|
void onRemoveExcludedPathButtonClicked();
|
||||||
void onScanForNewGamesClicked();
|
void onScanForNewGamesClicked();
|
||||||
void onRescanAllGamesClicked();
|
void onRescanAllGamesClicked();
|
||||||
|
|
||||||
|
|
|
@ -6,14 +6,14 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>527</width>
|
<width>532</width>
|
||||||
<height>376</height>
|
<height>376</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,2,0,1,0">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
@ -26,8 +26,8 @@
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0">
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -36,92 +36,166 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTableView" name="searchDirectoryList"/>
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<widget class="QToolButton" name="addSearchDirectoryButton">
|
||||||
<item>
|
<property name="sizePolicy">
|
||||||
<widget class="QPushButton" name="addSearchDirectoryButton">
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
<property name="sizePolicy">
|
<horstretch>0</horstretch>
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
<verstretch>0</verstretch>
|
||||||
<horstretch>0</horstretch>
|
</sizepolicy>
|
||||||
<verstretch>0</verstretch>
|
</property>
|
||||||
</sizepolicy>
|
<property name="text">
|
||||||
</property>
|
<string>Add</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Add</string>
|
<property name="icon">
|
||||||
</property>
|
<iconset resource="resources/resources.qrc">
|
||||||
<property name="icon">
|
<normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset>
|
||||||
<iconset resource="resources/resources.qrc">
|
</property>
|
||||||
<normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
</widget>
|
<item>
|
||||||
</item>
|
<widget class="QToolButton" name="removeSearchDirectoryButton">
|
||||||
<item>
|
<property name="sizePolicy">
|
||||||
<widget class="QPushButton" name="removeSearchDirectoryButton">
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
<property name="sizePolicy">
|
<horstretch>0</horstretch>
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
<verstretch>0</verstretch>
|
||||||
<horstretch>0</horstretch>
|
</sizepolicy>
|
||||||
<verstretch>0</verstretch>
|
</property>
|
||||||
</sizepolicy>
|
<property name="text">
|
||||||
</property>
|
<string>Remove</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Remove</string>
|
<property name="icon">
|
||||||
</property>
|
<iconset resource="resources/resources.qrc">
|
||||||
<property name="icon">
|
<normaloff>:/icons/list-remove.png</normaloff>:/icons/list-remove.png</iconset>
|
||||||
<iconset resource="resources/resources.qrc">
|
</property>
|
||||||
<normaloff>:/icons/list-remove.png</normaloff>:/icons/list-remove.png</iconset>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
</widget>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<widget class="QTableView" name="searchDirectoryList"/>
|
||||||
<property name="orientation">
|
</item>
|
||||||
<enum>Qt::Horizontal</enum>
|
<item>
|
||||||
</property>
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<property name="sizeHint" stdset="0">
|
<item>
|
||||||
<size>
|
<widget class="QLabel" name="label_2">
|
||||||
<width>40</width>
|
<property name="text">
|
||||||
<height>20</height>
|
<string>Excluded Paths</string>
|
||||||
</size>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
</spacer>
|
</item>
|
||||||
</item>
|
<item>
|
||||||
<item>
|
<spacer name="horizontalSpacer_3">
|
||||||
<widget class="QPushButton" name="scanForNewGames">
|
<property name="orientation">
|
||||||
<property name="sizePolicy">
|
<enum>Qt::Horizontal</enum>
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
</property>
|
||||||
<horstretch>0</horstretch>
|
<property name="sizeHint" stdset="0">
|
||||||
<verstretch>0</verstretch>
|
<size>
|
||||||
</sizepolicy>
|
<width>40</width>
|
||||||
</property>
|
<height>20</height>
|
||||||
<property name="text">
|
</size>
|
||||||
<string>Scan New</string>
|
</property>
|
||||||
</property>
|
</spacer>
|
||||||
<property name="icon">
|
</item>
|
||||||
<iconset resource="resources/resources.qrc">
|
<item>
|
||||||
<normaloff>:/icons/folder-open.png</normaloff>:/icons/folder-open.png</iconset>
|
<widget class="QToolButton" name="addExcludedPath">
|
||||||
</property>
|
<property name="sizePolicy">
|
||||||
</widget>
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
</item>
|
<horstretch>0</horstretch>
|
||||||
<item>
|
<verstretch>0</verstretch>
|
||||||
<widget class="QPushButton" name="rescanAllGames">
|
</sizepolicy>
|
||||||
<property name="sizePolicy">
|
</property>
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
<property name="text">
|
||||||
<horstretch>0</horstretch>
|
<string>Add</string>
|
||||||
<verstretch>0</verstretch>
|
</property>
|
||||||
</sizepolicy>
|
<property name="icon">
|
||||||
</property>
|
<iconset resource="resources/resources.qrc">
|
||||||
<property name="text">
|
<normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset>
|
||||||
<string>Rescan All</string>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
<property name="icon">
|
</item>
|
||||||
<iconset resource="resources/resources.qrc">
|
<item>
|
||||||
<normaloff>:/icons/view-refresh.png</normaloff>:/icons/view-refresh.png</iconset>
|
<widget class="QToolButton" name="removeExcludedPath">
|
||||||
</property>
|
<property name="sizePolicy">
|
||||||
</widget>
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
</item>
|
<horstretch>0</horstretch>
|
||||||
</layout>
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Remove</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="resources/resources.qrc">
|
||||||
|
<normaloff>:/icons/list-remove.png</normaloff>:/icons/list-remove.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QListWidget" name="excludedPaths"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="scanForNewGames">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Scan For New Games</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="resources/resources.qrc">
|
||||||
|
<normaloff>:/icons/folder-open.png</normaloff>:/icons/folder-open.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="rescanAllGames">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Rescan All Games</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="resources/resources.qrc">
|
||||||
|
<normaloff>:/icons/view-refresh.png</normaloff>:/icons/view-refresh.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -693,6 +693,9 @@ void MainWindow::onGameListContextMenuRequested(const QPoint& point, const GameL
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connect(menu.addAction(tr("Exclude From List")), &QAction::triggered,
|
||||||
|
[this, entry]() { getSettingsDialog()->getGameListSettingsWidget()->addExcludedPath(entry->path); });
|
||||||
|
|
||||||
connect(menu.addAction(tr("Add Search Directory...")), &QAction::triggered,
|
connect(menu.addAction(tr("Add Search Directory...")), &QAction::triggered,
|
||||||
[this]() { getSettingsDialog()->getGameListSettingsWidget()->addSearchDirectory(this); });
|
[this]() { getSettingsDialog()->getGameListSettingsWidget()->addSearchDirectory(this); });
|
||||||
|
|
||||||
|
|
|
@ -236,6 +236,26 @@ void QtHostInterface::SetStringListSettingValue(const char* section, const char*
|
||||||
queueSettingsSave();
|
queueSettingsSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QtHostInterface::AddValueToStringList(const char* section, const char* key, const char* value)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::recursive_mutex> guard(m_settings_mutex);
|
||||||
|
if (!m_settings_interface->AddToStringList(section, key, value))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
queueSettingsSave();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QtHostInterface::RemoveValueFromStringList(const char* section, const char* key, const char* value)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::recursive_mutex> guard(m_settings_mutex);
|
||||||
|
if (!m_settings_interface->RemoveFromStringList(section, key, value))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
queueSettingsSave();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void QtHostInterface::RemoveSettingValue(const char* section, const char* key)
|
void QtHostInterface::RemoveSettingValue(const char* section, const char* key)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> guard(m_settings_mutex);
|
std::lock_guard<std::recursive_mutex> guard(m_settings_mutex);
|
||||||
|
|
|
@ -64,6 +64,8 @@ public:
|
||||||
void SetFloatSettingValue(const char* section, const char* key, float value);
|
void SetFloatSettingValue(const char* section, const char* key, float value);
|
||||||
void SetStringSettingValue(const char* section, const char* key, const char* value);
|
void SetStringSettingValue(const char* section, const char* key, const char* value);
|
||||||
void SetStringListSettingValue(const char* section, const char* key, const std::vector<std::string>& values);
|
void SetStringListSettingValue(const char* section, const char* key, const std::vector<std::string>& values);
|
||||||
|
bool AddValueToStringList(const char* section, const char* key, const char* value);
|
||||||
|
bool RemoveValueFromStringList(const char* section, const char* key, const char* value);
|
||||||
void RemoveSettingValue(const char* section, const char* key);
|
void RemoveSettingValue(const char* section, const char* key);
|
||||||
|
|
||||||
TinyString TranslateString(const char* context, const char* str, const char* disambiguation = nullptr,
|
TinyString TranslateString(const char* context, const char* str, const char* disambiguation = nullptr,
|
||||||
|
|
Loading…
Reference in a new issue