From 7bc5427908a0e2985bd354446e4bfeeedd4cd45b Mon Sep 17 00:00:00 2001 From: Stenzek Date: Tue, 7 May 2024 01:50:24 +1000 Subject: [PATCH] Qt: Fix remove game directory button being enabled w/o selection --- common/Linux/LnxHostSys.cpp | 2 +- common/Windows/WinHostSys.cpp | 2 +- pcsx2-qt/Settings/GameListSettingsWidget.cpp | 28 ++++++++++++++------ pcsx2-qt/Settings/GameListSettingsWidget.h | 2 ++ pcsx2-qt/SetupWizardDialog.cpp | 16 ++++++----- pcsx2-qt/SetupWizardDialog.h | 1 + 6 files changed, 35 insertions(+), 16 deletions(-) diff --git a/common/Linux/LnxHostSys.cpp b/common/Linux/LnxHostSys.cpp index c10ebdc14dcaa..397cfa24e07e0 100644 --- a/common/Linux/LnxHostSys.cpp +++ b/common/Linux/LnxHostSys.cpp @@ -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 diff --git a/common/Windows/WinHostSys.cpp b/common/Windows/WinHostSys.cpp index 8278f7ebc3fb0..23eea6cbcb167 100644 --- a/common/Windows/WinHostSys.cpp +++ b/common/Windows/WinHostSys.cpp @@ -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) { diff --git a/pcsx2-qt/Settings/GameListSettingsWidget.cpp b/pcsx2-qt/Settings/GameListSettingsWidget.cpp index 04e690395ce48..8b5dd37a8ae60 100644 --- a/pcsx2-qt/Settings/GameListSettingsWidget.cpp +++ b/pcsx2-qt/Settings/GameListSettingsWidget.cpp @@ -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); @@ -77,6 +75,8 @@ void GameListSettingsWidget::refreshExclusionList() const std::vector 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) @@ -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) @@ -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 = @@ -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); diff --git a/pcsx2-qt/Settings/GameListSettingsWidget.h b/pcsx2-qt/Settings/GameListSettingsWidget.h index b25f0dadf723b..5cc2cdaea7bdd 100644 --- a/pcsx2-qt/Settings/GameListSettingsWidget.h +++ b/pcsx2-qt/Settings/GameListSettingsWidget.h @@ -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(); diff --git a/pcsx2-qt/SetupWizardDialog.cpp b/pcsx2-qt/SetupWizardDialog.cpp index 8831a00d3b9ba..079f2e76dc84d 100644 --- a/pcsx2-qt/SetupWizardDialog.cpp +++ b/pcsx2-qt/SetupWizardDialog.cpp @@ -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(); } @@ -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"))); @@ -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() diff --git a/pcsx2-qt/SetupWizardDialog.h b/pcsx2-qt/SetupWizardDialog.h index 2be48675e8c32..13b0ba7345249 100644 --- a/pcsx2-qt/SetupWizardDialog.h +++ b/pcsx2-qt/SetupWizardDialog.h @@ -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();