Qt: Fix docs file not getting included on Linux/Mac

This commit is contained in:
Stenzek 2024-01-08 20:34:35 +10:00 committed by Connor McLaughlin
parent ab68c570a9
commit 0a0994b19c
2 changed files with 29 additions and 6 deletions

View File

@ -9,6 +9,7 @@
#include "common/FileSystem.h" #include "common/FileSystem.h"
#include "common/Path.h" #include "common/Path.h"
#include "common/SmallString.h"
#include <QtCore/QFile> #include <QtCore/QFile>
#include <QtCore/QString> #include <QtCore/QString>
@ -18,6 +19,20 @@
#include <QtWidgets/QPushButton> #include <QtWidgets/QPushButton>
#include <QtWidgets/QTextBrowser> #include <QtWidgets/QTextBrowser>
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) AboutDialog::AboutDialog(QWidget* parent)
: QDialog(parent) : QDialog(parent)
{ {
@ -66,16 +81,12 @@ QString AboutDialog::getGitHubRepositoryUrl()
QString AboutDialog::getLicenseUrl() QString AboutDialog::getLicenseUrl()
{ {
return QUrl::fromLocalFile(QString::fromUtf8(Path::Combine(EmuFolders::AppRoot, return GetDocFileUrl("GPL.html");
"docs" FS_OSPATH_SEPARATOR_STR "GPL.html")))
.toString();
} }
QString AboutDialog::getThirdPartyLicensesUrl() QString AboutDialog::getThirdPartyLicensesUrl()
{ {
return QUrl::fromLocalFile(QString::fromUtf8(Path::Combine(EmuFolders::AppRoot, return GetDocFileUrl("ThirdPartyLicenses.html");
"docs" FS_OSPATH_SEPARATOR_STR "ThirdPartyLicenses.html")))
.toString();
} }
QString AboutDialog::getDiscordServerUrl() QString AboutDialog::getDiscordServerUrl()

View File

@ -1223,6 +1223,18 @@ function(setup_main_executable target)
pcsx2_resource(${target} ${path} ${CMAKE_SOURCE_DIR}/bin/resources/) pcsx2_resource(${target} ${path} ${CMAKE_SOURCE_DIR}/bin/resources/)
endforeach() 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_SOURCE_DIR GLOBAL PROPERTY PCSX2_SOURCE_DIR)
get_property(PCSX2_METAL_SHADERS GLOBAL PROPERTY PCSX2_METAL_SHADERS) get_property(PCSX2_METAL_SHADERS GLOBAL PROPERTY PCSX2_METAL_SHADERS)