From 3a72328d55fe6c4a8ce65649b6d86196fac50736 Mon Sep 17 00:00:00 2001 From: TheTechnician27 Date: Fri, 19 Jul 2024 17:52:46 -0500 Subject: [PATCH] Qt: Add per-game link to PCSX2 Wiki pages on right-click --- pcsx2-qt/MainWindow.cpp | 10 ++++++++++ pcsx2-qt/MainWindow.h | 1 + pcsx2-qt/Settings/GameSummaryWidget.cpp | 7 +++++++ pcsx2-qt/Settings/GameSummaryWidget.h | 1 + pcsx2-qt/Settings/GameSummaryWidget.ui | 24 +++++++++++++++++++----- 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/pcsx2-qt/MainWindow.cpp b/pcsx2-qt/MainWindow.cpp index 51571e4d68314..3e5d9b4d4feb6 100644 --- a/pcsx2-qt/MainWindow.cpp +++ b/pcsx2-qt/MainWindow.cpp @@ -1356,6 +1356,11 @@ void MainWindow::onGameListEntryContextMenuRequested(const QPoint& point) connect(menu.addAction(tr("Reset Play Time")), &QAction::triggered, [this, entry]() { clearGameListEntryPlayTime(entry); }); + if (!entry->serial.empty()) + { + connect(menu.addAction(tr("Check Wiki Page")), &QAction::triggered, [this, entry]() { goToWikiPage(entry); }); + } + menu.addSeparator(); if (!s_vm_valid) @@ -2719,6 +2724,11 @@ void MainWindow::clearGameListEntryPlayTime(const GameList::Entry* entry) m_game_list_widget->refresh(false); } +void MainWindow::goToWikiPage(const GameList::Entry* entry) +{ + QtUtils::OpenURL(this, fmt::format("https://wiki.pcsx2.net/{}", entry->serial).c_str()); +} + std::optional MainWindow::promptForResumeState(const QString& save_state_path) { if (save_state_path.isEmpty()) diff --git a/pcsx2-qt/MainWindow.h b/pcsx2-qt/MainWindow.h index d4a1815312b37..9baf1382a63b2 100644 --- a/pcsx2-qt/MainWindow.h +++ b/pcsx2-qt/MainWindow.h @@ -267,6 +267,7 @@ private Q_SLOTS: const GameList::Entry* entry, std::optional save_slot = std::nullopt, std::optional fast_boot = std::nullopt); void setGameListEntryCoverImage(const GameList::Entry* entry); void clearGameListEntryPlayTime(const GameList::Entry* entry); + void goToWikiPage(const GameList::Entry* entry); std::optional promptForResumeState(const QString& save_state_path); void loadSaveStateSlot(s32 slot); diff --git a/pcsx2-qt/Settings/GameSummaryWidget.cpp b/pcsx2-qt/Settings/GameSummaryWidget.cpp index 5c768a8ba4ee6..f18169385388e 100644 --- a/pcsx2-qt/Settings/GameSummaryWidget.cpp +++ b/pcsx2-qt/Settings/GameSummaryWidget.cpp @@ -49,11 +49,13 @@ GameSummaryWidget::GameSummaryWidget(const GameList::Entry* entry, SettingsWindo connect(m_ui.inputProfile, &QComboBox::currentIndexChanged, this, &GameSummaryWidget::onInputProfileChanged); connect(m_ui.verify, &QAbstractButton::clicked, this, &GameSummaryWidget::onVerifyClicked); connect(m_ui.searchHash, &QAbstractButton::clicked, this, &GameSummaryWidget::onSearchHashClicked); + connect(m_ui.checkWiki, &QAbstractButton::clicked, this, [this, entry]() { onCheckWikiClicked(entry); }); bool has_custom_title = false, has_custom_region = false; GameList::CheckCustomAttributesForPath(m_entry_path, has_custom_title, has_custom_region); m_ui.restoreTitle->setEnabled(has_custom_title); m_ui.restoreRegion->setEnabled(has_custom_region); + m_ui.checkWiki->setEnabled(!entry->serial.empty()); } GameSummaryWidget::~GameSummaryWidget() = default; @@ -348,6 +350,11 @@ void GameSummaryWidget::onSearchHashClicked() QtUtils::OpenURL(this, fmt::format("http://redump.org/discs/quicksearch/{}", m_redump_search_keyword).c_str()); } +void GameSummaryWidget::onCheckWikiClicked(const GameList::Entry* entry) +{ + QtUtils::OpenURL(this, fmt::format("https://wiki.pcsx2.net/{}", entry->serial).c_str()); +} + void GameSummaryWidget::setVerifyResult(QString error) { m_ui.verify->setVisible(false); diff --git a/pcsx2-qt/Settings/GameSummaryWidget.h b/pcsx2-qt/Settings/GameSummaryWidget.h index ff8684ae67a34..2b87b84e1716f 100644 --- a/pcsx2-qt/Settings/GameSummaryWidget.h +++ b/pcsx2-qt/Settings/GameSummaryWidget.h @@ -28,6 +28,7 @@ private Q_SLOTS: void onDiscPathBrowseClicked(); void onVerifyClicked(); void onSearchHashClicked(); + void onCheckWikiClicked(const GameList::Entry* entry); private: void populateInputProfiles(); diff --git a/pcsx2-qt/Settings/GameSummaryWidget.ui b/pcsx2-qt/Settings/GameSummaryWidget.ui index d1a244dbaded1..9a9289d8f5b84 100644 --- a/pcsx2-qt/Settings/GameSummaryWidget.ui +++ b/pcsx2-qt/Settings/GameSummaryWidget.ui @@ -104,11 +104,25 @@ - - - true - - + + + + + true + + + + + + + false + + + Check Wiki + + + +