From 0a0994b19cd25ea14124383cd5108686d54f2727 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Mon, 8 Jan 2024 20:34:35 +1000 Subject: [PATCH] Qt: Fix docs file not getting included on Linux/Mac --- pcsx2-qt/AboutDialog.cpp | 23 +++++++++++++++++------ pcsx2/CMakeLists.txt | 12 ++++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/pcsx2-qt/AboutDialog.cpp b/pcsx2-qt/AboutDialog.cpp index 626b40967a..48e080f690 100644 --- a/pcsx2-qt/AboutDialog.cpp +++ b/pcsx2-qt/AboutDialog.cpp @@ -9,6 +9,7 @@ #include "common/FileSystem.h" #include "common/Path.h" +#include "common/SmallString.h" #include #include @@ -18,6 +19,20 @@ #include #include +static QString GetDocFileUrl(std::string_view name) +{ +#ifdef _WIN32 + // Windows uses the docs directory in bin. + const std::string path = Path::Combine(EmuFolders::AppRoot, + TinyString::from_fmt("docs" FS_OSPATH_SEPARATOR_STR "{}", name)); +#else + // Linux/Mac has this in the Resources directory. + const std::string path = Path::Combine(EmuFolders::Resources, + TinyString::from_fmt("docs" FS_OSPATH_SEPARATOR_STR "{}", name)); +#endif + return QUrl::fromLocalFile(QString::fromStdString(path)).toString(); +} + AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent) { @@ -66,16 +81,12 @@ QString AboutDialog::getGitHubRepositoryUrl() QString AboutDialog::getLicenseUrl() { - return QUrl::fromLocalFile(QString::fromUtf8(Path::Combine(EmuFolders::AppRoot, - "docs" FS_OSPATH_SEPARATOR_STR "GPL.html"))) - .toString(); + return GetDocFileUrl("GPL.html"); } QString AboutDialog::getThirdPartyLicensesUrl() { - return QUrl::fromLocalFile(QString::fromUtf8(Path::Combine(EmuFolders::AppRoot, - "docs" FS_OSPATH_SEPARATOR_STR "ThirdPartyLicenses.html"))) - .toString(); + return GetDocFileUrl("ThirdPartyLicenses.html"); } QString AboutDialog::getDiscordServerUrl() diff --git a/pcsx2/CMakeLists.txt b/pcsx2/CMakeLists.txt index 475a3d3cf9..168ae9e847 100644 --- a/pcsx2/CMakeLists.txt +++ b/pcsx2/CMakeLists.txt @@ -1223,6 +1223,18 @@ function(setup_main_executable target) pcsx2_resource(${target} ${path} ${CMAKE_SOURCE_DIR}/bin/resources/) endforeach() + # Add docs to resources for not-Windows, since they don't use the bin directory. + if(NOT WIN32) + file(GLOB_RECURSE DOCS_FILES ${CMAKE_SOURCE_DIR}/bin/docs/*) + foreach(path IN LISTS DOCS_FILES) + get_filename_component(file ${path} NAME) + if("${file}" MATCHES "^\\.") # Don't copy macOS garbage (mainly Finder's .DS_Store files) into application + continue() + endif() + pcsx2_resource(${target} ${path} ${CMAKE_SOURCE_DIR}/bin/) + endforeach() + endif() + get_property(PCSX2_SOURCE_DIR GLOBAL PROPERTY PCSX2_SOURCE_DIR) get_property(PCSX2_METAL_SHADERS GLOBAL PROPERTY PCSX2_METAL_SHADERS)