Skip to content

Commit

Permalink
Qt: Fix remove game directory button being enabled w/o selection
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed May 7, 2024
1 parent 1881139 commit 7bc5427
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 16 deletions.
2 changes: 1 addition & 1 deletion common/Linux/LnxHostSys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

static std::recursive_mutex s_exception_handler_mutex;
static bool s_in_exception_handler = false;
static bool s_exception_handler_installed = true;
static bool s_exception_handler_installed = false;

#ifdef __APPLE__
#include <mach/task.h>
Expand Down
2 changes: 1 addition & 1 deletion common/Windows/WinHostSys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

static std::recursive_mutex s_exception_handler_mutex;
static bool s_in_exception_handler = false;
static bool s_exception_handler_installed = true;
static bool s_exception_handler_installed = false;

long __stdcall SysPageFaultExceptionFilter(EXCEPTION_POINTERS* eps)
{
Expand Down
28 changes: 20 additions & 8 deletions pcsx2-qt/Settings/GameListSettingsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,14 @@ GameListSettingsWidget::GameListSettingsWidget(SettingsWindow* dialog, QWidget*
m_ui.searchDirectoryList->setCurrentIndex({});
m_ui.searchDirectoryList->setContextMenuPolicy(Qt::ContextMenuPolicy::CustomContextMenu);

connect(m_ui.searchDirectoryList, &QTableWidget::customContextMenuRequested, this,
&GameListSettingsWidget::onDirectoryListContextMenuRequested);
connect(m_ui.addSearchDirectoryButton, &QPushButton::clicked, this,
&GameListSettingsWidget::onAddSearchDirectoryButtonClicked);
connect(m_ui.removeSearchDirectoryButton, &QPushButton::clicked, this,
&GameListSettingsWidget::onRemoveSearchDirectoryButtonClicked);
connect(m_ui.searchDirectoryList, &QTableWidget::customContextMenuRequested, this, &GameListSettingsWidget::onDirectoryListContextMenuRequested);
connect(m_ui.searchDirectoryList, &QTableWidget::itemSelectionChanged, this, &GameListSettingsWidget::onDirectoryListSelectionChanged);
connect(m_ui.addSearchDirectoryButton, &QPushButton::clicked, this, &GameListSettingsWidget::onAddSearchDirectoryButtonClicked);
connect(m_ui.removeSearchDirectoryButton, &QPushButton::clicked, this, &GameListSettingsWidget::onRemoveSearchDirectoryButtonClicked);
connect(m_ui.addExcludedFile, &QPushButton::clicked, this, &GameListSettingsWidget::onAddExcludedFileButtonClicked);
connect(m_ui.addExcludedPath, &QPushButton::clicked, this, &GameListSettingsWidget::onAddExcludedPathButtonClicked);
connect(m_ui.removeExcludedPath, &QPushButton::clicked, this,
&GameListSettingsWidget::onRemoveExcludedPathButtonClicked);
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);

Expand Down Expand Up @@ -77,6 +75,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);
}

bool GameListSettingsWidget::event(QEvent* event)
Expand Down Expand Up @@ -142,6 +142,8 @@ void GameListSettingsWidget::refreshDirectoryList()
addPathToTable(entry, true);

m_ui.searchDirectoryList->sortByColumn(0, Qt::AscendingOrder);

m_ui.removeSearchDirectoryButton->setEnabled(false);
}

void GameListSettingsWidget::addSearchDirectory(const QString& path, bool recursive)
Expand Down Expand Up @@ -185,6 +187,11 @@ void GameListSettingsWidget::onDirectoryListContextMenuRequested(const QPoint& p
menu.exec(m_ui.searchDirectoryList->mapToGlobal(point));
}

void GameListSettingsWidget::onDirectoryListSelectionChanged()
{
m_ui.removeSearchDirectoryButton->setEnabled(m_ui.searchDirectoryList->selectionModel()->hasSelection());
}

void GameListSettingsWidget::addSearchDirectory(QWidget* parent_widget)
{
QString dir =
Expand Down Expand Up @@ -258,6 +265,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);
Expand Down
2 changes: 2 additions & 0 deletions pcsx2-qt/Settings/GameListSettingsWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ public Q_SLOTS:

private Q_SLOTS:
void onDirectoryListContextMenuRequested(const QPoint& point);
void onDirectoryListSelectionChanged();
void onAddSearchDirectoryButtonClicked();
void onRemoveSearchDirectoryButtonClicked();
void onAddExcludedFileButtonClicked();
void onAddExcludedPathButtonClicked();
void onRemoveExcludedPathButtonClicked();
void onExcludedPathsSelectionChanged();
void onScanForNewGamesClicked();
void onRescanAllGamesClicked();

Expand Down
16 changes: 10 additions & 6 deletions pcsx2-qt/SetupWizardDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,10 @@ void SetupWizardDialog::setupGameListPage()
m_ui.searchDirectoryList->setCurrentIndex({});
m_ui.searchDirectoryList->setContextMenuPolicy(Qt::ContextMenuPolicy::CustomContextMenu);

connect(m_ui.searchDirectoryList, &QTableWidget::customContextMenuRequested, this,
&SetupWizardDialog::onDirectoryListContextMenuRequested);
connect(m_ui.addSearchDirectoryButton, &QPushButton::clicked, this,
&SetupWizardDialog::onAddSearchDirectoryButtonClicked);
connect(m_ui.removeSearchDirectoryButton, &QPushButton::clicked, this,
&SetupWizardDialog::onRemoveSearchDirectoryButtonClicked);
connect(m_ui.searchDirectoryList, &QTableWidget::customContextMenuRequested, this, &SetupWizardDialog::onDirectoryListContextMenuRequested);
connect(m_ui.searchDirectoryList, &QTableWidget::itemSelectionChanged, this, &SetupWizardDialog::onDirectoryListSelectionChanged);
connect(m_ui.addSearchDirectoryButton, &QPushButton::clicked, this, &SetupWizardDialog::onAddSearchDirectoryButtonClicked);
connect(m_ui.removeSearchDirectoryButton, &QPushButton::clicked, this, &SetupWizardDialog::onRemoveSearchDirectoryButtonClicked);

refreshDirectoryList();
}
Expand All @@ -263,6 +261,11 @@ void SetupWizardDialog::onDirectoryListContextMenuRequested(const QPoint& point)
menu.exec(m_ui.searchDirectoryList->mapToGlobal(point));
}

void SetupWizardDialog::onDirectoryListSelectionChanged()
{
m_ui.removeSearchDirectoryButton->setEnabled(!m_ui.searchDirectoryList->selectedItems().isEmpty());
}

void SetupWizardDialog::onAddSearchDirectoryButtonClicked()
{
QString dir = QDir::toNativeSeparators(QFileDialog::getExistingDirectory(this, tr("Select Search Directory")));
Expand Down Expand Up @@ -349,6 +352,7 @@ void SetupWizardDialog::refreshDirectoryList()
addPathToTable(entry, true);

m_ui.searchDirectoryList->sortByColumn(0, Qt::AscendingOrder);
m_ui.removeSearchDirectoryButton->setEnabled(false);
}

void SetupWizardDialog::resizeDirectoryListColumns()
Expand Down
1 change: 1 addition & 0 deletions pcsx2-qt/SetupWizardDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ private Q_SLOTS:
void biosListItemChanged(const QTreeWidgetItem* current, const QTreeWidgetItem* previous);

void onDirectoryListContextMenuRequested(const QPoint& point);
void onDirectoryListSelectionChanged();
void onAddSearchDirectoryButtonClicked();
void onRemoveSearchDirectoryButtonClicked();
void refreshDirectoryList();
Expand Down

0 comments on commit 7bc5427

Please sign in to comment.