mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-08-03 11:27:33 -04:00
Merge f27b6007d65e8f9d969341fcdcff3e55bddf0392 into 79b7e277f1f06f6b315e293b029423fe35e57431
This commit is contained in:
commit
8bd0759d42
@ -11,6 +11,7 @@ runs:
|
||||
sudo apt-get -y install \
|
||||
dpkg-dev \
|
||||
ninja-build extra-cmake-modules scdoc \
|
||||
libqrencode-dev \
|
||||
appstream libxcb-cursor-dev
|
||||
|
||||
- name: Setup AppImage tooling
|
||||
|
@ -14,7 +14,7 @@ runs:
|
||||
shell: bash
|
||||
run: |
|
||||
brew update
|
||||
brew install ninja extra-cmake-modules temurin@17
|
||||
brew install ninja extra-cmake-modules temurin@17 qrencode
|
||||
|
||||
- name: Set JAVA_HOME
|
||||
shell: bash
|
||||
|
@ -79,6 +79,7 @@ runs:
|
||||
qt6-5compat:p
|
||||
qt6-networkauth:p
|
||||
cmark:p
|
||||
qrencode:p
|
||||
tomlplusplus:p
|
||||
quazip-qt6:p
|
||||
|
||||
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -19,6 +19,3 @@
|
||||
[submodule "flatpak/shared-modules"]
|
||||
path = flatpak/shared-modules
|
||||
url = https://github.com/flathub/shared-modules.git
|
||||
[submodule "libraries/qrcodegenerator"]
|
||||
path = libraries/qrcodegenerator
|
||||
url = https://github.com/nayuki/QR-Code-generator
|
||||
|
@ -345,12 +345,24 @@ if(Launcher_QT_VERSION_MAJOR EQUAL 6)
|
||||
set(QT_LIBEXECS_DIR ${QT${QT_VERSION_MAJOR}_INSTALL_PREFIX}/${QT${QT_VERSION_MAJOR}_INSTALL_LIBEXECS})
|
||||
endif()
|
||||
|
||||
find_package(PkgConfig)
|
||||
|
||||
# Find libqrencode
|
||||
## NOTE(@getchoo): Never use pkg-config with MSVC since the vcpkg port makes our install bundle fail to find the dll
|
||||
if(PkgConfig_FOUND AND NOT MSVC)
|
||||
pkg_check_modules(libqrencode REQUIRED IMPORTED_TARGET libqrencode)
|
||||
else()
|
||||
find_path(LIBQRENCODE_INCLUDE_DIR qrencode.h REQUIRED)
|
||||
find_library(LIBQRENCODE_LIBRARY_RELEASE qrencode REQUIRED)
|
||||
find_library(LIBQRENCODE_LIBRARY_DEBUG qrencoded)
|
||||
set(LIBQRENCODE_LIBRARIES optimized ${LIBQRENCODE_LIBRARY_RELEASE} debug ${LIBQRENCODE_LIBRARY_DEBUG})
|
||||
endif()
|
||||
|
||||
if(NOT Launcher_FORCE_BUNDLED_LIBS)
|
||||
# Find toml++
|
||||
find_package(tomlplusplus 3.2.0 QUIET)
|
||||
# Fallback to pkg-config (if available) if CMake files aren't found
|
||||
if(NOT tomlplusplus_FOUND)
|
||||
find_package(PkgConfig)
|
||||
if(PkgConfig_FOUND)
|
||||
pkg_check_modules(tomlplusplus IMPORTED_TARGET tomlplusplus>=3.2.0)
|
||||
endif()
|
||||
@ -359,9 +371,6 @@ if(NOT Launcher_FORCE_BUNDLED_LIBS)
|
||||
|
||||
# Find cmark
|
||||
find_package(cmark QUIET)
|
||||
|
||||
# Find qrcodegencpp-cmake
|
||||
find_package(qrcodegencpp QUIET)
|
||||
endif()
|
||||
|
||||
include(ECMQtDeclareLoggingCategory)
|
||||
@ -523,18 +532,6 @@ if(NOT cmark_FOUND)
|
||||
else()
|
||||
message(STATUS "Using system cmark")
|
||||
endif()
|
||||
if(NOT qrcodegencpp_FOUND)
|
||||
set(QRCODE_SOURCES
|
||||
libraries/qrcodegenerator/cpp/qrcodegen.cpp
|
||||
libraries/qrcodegenerator/cpp/qrcodegen.hpp
|
||||
)
|
||||
add_library(qrcodegenerator STATIC ${QRCODE_SOURCES})
|
||||
target_include_directories(qrcodegenerator PUBLIC "libraries/qrcodegenerator/cpp/" )
|
||||
generate_export_header(qrcodegenerator)
|
||||
else()
|
||||
add_library(qrcodegenerator ALIAS qrcodegencpp::qrcodegencpp)
|
||||
message(STATUS "Using system qrcodegencpp-cmake")
|
||||
endif()
|
||||
add_subdirectory(libraries/gamemode)
|
||||
add_subdirectory(libraries/murmur2) # Hash for usage with the CurseForge API
|
||||
add_subdirectory(libraries/qdcss) # css parser
|
||||
|
@ -404,15 +404,6 @@
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
## QR-Code-generator (`libraries/qrcodegenerator`)
|
||||
|
||||
Copyright © 2024 Project Nayuki. (MIT License)
|
||||
https://www.nayuki.io/page/qr-code-generator-library
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
- The Software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the Software or the use or other dealings in the Software.
|
||||
|
||||
## vcpkg (`cmake/vcpkg-ports`)
|
||||
|
||||
MIT License
|
||||
|
3
cmake/vcpkg-ports/libpng/README.md
Normal file
3
cmake/vcpkg-ports/libpng/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
The only difference between this and the upstream vcpkg port is the addition of `target-specific-code.patch`. It's very annoying we need to bundle this entire tree to do that.
|
||||
|
||||
-@getchoo
|
92
cmake/vcpkg-ports/libpng/cmake.patch
Executable file
92
cmake/vcpkg-ports/libpng/cmake.patch
Executable file
@ -0,0 +1,92 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 1cf5b86e4..e79f8819c 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -143,6 +143,12 @@ find_package(ZLIB REQUIRED)
|
||||
if(UNIX
|
||||
AND NOT (APPLE OR BEOS OR HAIKU)
|
||||
AND NOT EMSCRIPTEN)
|
||||
+ block(SCOPE_FOR VARIABLES)
|
||||
+ if(VCPKG_CRT_LINKAGE STREQUAL "static")
|
||||
+ list(PREPEND CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
||||
+ endif()
|
||||
+ find_library(M_LIBRARY m PATHS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES})
|
||||
+ endblock()
|
||||
find_library(M_LIBRARY m)
|
||||
if(M_LIBRARY)
|
||||
set(M_LIBRARY m)
|
||||
@@ -236,9 +242,9 @@ if(PNG_HARDWARE_OPTIMIZATIONS)
|
||||
|
||||
# Set definitions and sources for MIPS.
|
||||
if(PNG_TARGET_ARCHITECTURE MATCHES "^(mipsel|mips64el)")
|
||||
- set(PNG_MIPS_MSA_POSSIBLE_VALUES on off)
|
||||
+ set(PNG_MIPS_MSA_POSSIBLE_VALUES on off check)
|
||||
set(PNG_MIPS_MSA
|
||||
- "on"
|
||||
+ "check"
|
||||
CACHE STRING "Enable MIPS_MSA optimizations: on|off; on is default")
|
||||
set_property(CACHE PNG_MIPS_MSA
|
||||
PROPERTY STRINGS ${PNG_MIPS_MSA_POSSIBLE_VALUES})
|
||||
@@ -271,6 +277,12 @@ if(PNG_HARDWARE_OPTIMIZATIONS)
|
||||
mips/filter_msa_intrinsics.c)
|
||||
add_definitions(-DPNG_MIPS_MSA_OPT=2)
|
||||
add_definitions(-DPNG_MIPS_MMI_OPT=0)
|
||||
+ elseif(PNG_MIPS_MSA STREQUAL "check")
|
||||
+ set(libpng_mips_sources
|
||||
+ mips/mips_init.c
|
||||
+ mips/filter_msa_intrinsics.c)
|
||||
+ add_definitions(-DPNG_MIPS_MSA_CHECK_SUPPORTED)
|
||||
+ add_definitions(-DPNG_MIPS_MMI_CHECK_SUPPORTED)
|
||||
elseif(PNG_MIPS_MMI STREQUAL "on")
|
||||
set(libpng_mips_sources
|
||||
mips/mips_init.c
|
||||
@@ -665,7 +677,7 @@ else()
|
||||
# We also need to use a custom suffix, in order to distinguish between the
|
||||
# shared import library name and the static library name.
|
||||
set(PNG_SHARED_OUTPUT_NAME "libpng${PNGLIB_ABI_VERSION}")
|
||||
- set(PNG_STATIC_OUTPUT_NAME "libpng${PNGLIB_ABI_VERSION}_static")
|
||||
+ set(PNG_STATIC_OUTPUT_NAME "libpng${PNGLIB_ABI_VERSION}")
|
||||
endif()
|
||||
|
||||
if(PNG_SHARED)
|
||||
@@ -943,10 +955,10 @@ if(PNG_TESTS AND PNG_SHARED)
|
||||
FILES ${PNGSUITE_PNGS})
|
||||
endif()
|
||||
|
||||
-if(PNG_SHARED AND PNG_TOOLS)
|
||||
+if(PNG_TOOLS)
|
||||
add_executable(pngfix ${pngfix_sources})
|
||||
target_link_libraries(pngfix
|
||||
- PRIVATE png_shared)
|
||||
+ PRIVATE $<TARGET_NAME_IF_EXISTS:png_shared> $<TARGET_NAME_IF_EXISTS:png_static>) # in vcpkg there's only one
|
||||
set(PNG_BIN_TARGETS pngfix)
|
||||
|
||||
add_executable(png-fix-itxt ${png_fix_itxt_sources})
|
||||
@@ -1030,12 +1042,15 @@ endif()
|
||||
# We use the same files like ./configure, so we have to set its vars.
|
||||
# Only do this on Windows for Cygwin - the files don't make much sense
|
||||
# outside of a UNIX look-alike.
|
||||
-if(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
+if(1)
|
||||
set(prefix ${CMAKE_INSTALL_PREFIX})
|
||||
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
|
||||
set(libdir ${CMAKE_INSTALL_FULL_LIBDIR})
|
||||
set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR})
|
||||
- set(LIBS "-lz -lm")
|
||||
+ set(LIBS "")
|
||||
+ if(M_LIBRARY)
|
||||
+ string(APPEND LIBS "-lm")
|
||||
+ endif()
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}.pc
|
||||
@ONLY)
|
||||
@@ -1094,6 +1109,9 @@ if(NOT SKIP_INSTALL_PROGRAMS AND NOT SKIP_INSTALL_ALL)
|
||||
endif()
|
||||
|
||||
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL)
|
||||
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}.pc
|
||||
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
+elseif(0)
|
||||
# Install the man pages.
|
||||
install(FILES libpng.3 libpngpf.3
|
||||
DESTINATION ${CMAKE_INSTALL_MANDIR}/man3)
|
12
cmake/vcpkg-ports/libpng/libpng-config.cmake
Executable file
12
cmake/vcpkg-ports/libpng/libpng-config.cmake
Executable file
@ -0,0 +1,12 @@
|
||||
file(READ "${CMAKE_CURRENT_LIST_DIR}/usage" usage)
|
||||
message(WARNING "find_package(libpng) is deprecated.\n${usage}")
|
||||
|
||||
include(CMakeFindDependencyMacro)
|
||||
find_dependency(PNG CONFIG)
|
||||
|
||||
if(NOT TARGET png_shared)
|
||||
add_library(png_shared ALIAS PNG::PNG)
|
||||
endif()
|
||||
if(NOT TARGET png_static)
|
||||
add_library(png_static ALIAS PNG::PNG)
|
||||
endif()
|
122
cmake/vcpkg-ports/libpng/portfile.cmake
Executable file
122
cmake/vcpkg-ports/libpng/portfile.cmake
Executable file
@ -0,0 +1,122 @@
|
||||
# Download the apng patch
|
||||
set(LIBPNG_APNG_PATCH_PATH "")
|
||||
if ("apng" IN_LIST FEATURES)
|
||||
if(VCPKG_HOST_IS_WINDOWS)
|
||||
# Get (g)awk and gzip installed
|
||||
vcpkg_acquire_msys(MSYS_ROOT PACKAGES gawk gzip)
|
||||
set(AWK_EXE_PATH "${MSYS_ROOT}/usr/bin")
|
||||
vcpkg_add_to_path("${AWK_EXE_PATH}")
|
||||
endif()
|
||||
|
||||
set(LIBPNG_APNG_PATCH_NAME "libpng-${VERSION}-apng.patch")
|
||||
vcpkg_download_distfile(LIBPNG_APNG_PATCH_ARCHIVE
|
||||
URLS "https://downloads.sourceforge.net/project/libpng-apng/libpng16/${VERSION}/${LIBPNG_APNG_PATCH_NAME}.gz"
|
||||
FILENAME "${LIBPNG_APNG_PATCH_NAME}.gz"
|
||||
SHA512 957810c235647bceaacc9754dcb25fdd36177f0f8255ed3eef862d681a53e80e2fc461f8dc083da4a07728b14cf9d2941286c1d745acc9fb131ef767630532f3
|
||||
)
|
||||
set(LIBPNG_APNG_PATCH_PATH "${CURRENT_BUILDTREES_DIR}/src/${LIBPNG_APNG_PATCH_NAME}")
|
||||
if (NOT EXISTS "${LIBPNG_APNG_PATCH_PATH}")
|
||||
file(INSTALL "${LIBPNG_APNG_PATCH_ARCHIVE}" DESTINATION "${CURRENT_BUILDTREES_DIR}/src")
|
||||
vcpkg_execute_required_process(
|
||||
COMMAND gzip -d "${LIBPNG_APNG_PATCH_NAME}.gz"
|
||||
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/src"
|
||||
ALLOW_IN_DOWNLOAD_MODE
|
||||
LOGNAME extract-patch.log
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
vcpkg_from_github(
|
||||
OUT_SOURCE_PATH SOURCE_PATH
|
||||
REPO pnggroup/libpng
|
||||
REF v${VERSION}
|
||||
SHA512 3a0006256abc6f23f5be1d67b201303ceaaa58ffa901f4659ad95f025b08f5e1c30d374cc251196a2ff1ee3ef4b37bd4d61c7779eabd86922d3bdd047264d9c1
|
||||
HEAD_REF master
|
||||
PATCHES
|
||||
"${LIBPNG_APNG_PATCH_PATH}"
|
||||
cmake.patch
|
||||
target-specific-code.patch
|
||||
)
|
||||
|
||||
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" PNG_SHARED)
|
||||
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" PNG_STATIC)
|
||||
|
||||
vcpkg_check_features(
|
||||
OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
FEATURES
|
||||
tools PNG_TOOLS
|
||||
INVERTED_FEATURES
|
||||
tools SKIP_INSTALL_PROGRAMS
|
||||
)
|
||||
|
||||
vcpkg_list(SET LIBPNG_HARDWARE_OPTIMIZATIONS_OPTION)
|
||||
if(VCPKG_TARGET_IS_IOS)
|
||||
vcpkg_list(APPEND LIBPNG_HARDWARE_OPTIMIZATIONS_OPTION "-DPNG_HARDWARE_OPTIMIZATIONS=OFF")
|
||||
endif()
|
||||
|
||||
vcpkg_list(SET LD_VERSION_SCRIPT_OPTION)
|
||||
if(VCPKG_TARGET_IS_ANDROID)
|
||||
vcpkg_list(APPEND LD_VERSION_SCRIPT_OPTION "-Dld-version-script=OFF")
|
||||
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")
|
||||
vcpkg_cmake_get_vars(cmake_vars_file)
|
||||
include("${cmake_vars_file}")
|
||||
if(VCPKG_DETECTED_CMAKE_ANDROID_ARM_NEON)
|
||||
vcpkg_list(APPEND LIBPNG_HARDWARE_OPTIMIZATIONS_OPTION "-DPNG_ARM_NEON=on")
|
||||
else()
|
||||
# for armeabi-v7a, check whether NEON is available
|
||||
vcpkg_list(APPEND LIBPNG_HARDWARE_OPTIMIZATIONS_OPTION "-DPNG_ARM_NEON=check")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64" AND VCPKG_TARGET_IS_LINUX)
|
||||
vcpkg_list(APPEND LIBPNG_HARDWARE_OPTIMIZATIONS_OPTION "-DPNG_ARM_NEON=on")
|
||||
endif()
|
||||
|
||||
vcpkg_cmake_configure(
|
||||
SOURCE_PATH "${SOURCE_PATH}"
|
||||
OPTIONS
|
||||
${LIBPNG_HARDWARE_OPTIMIZATIONS_OPTION}
|
||||
${LD_VERSION_SCRIPT_OPTION}
|
||||
-DPNG_STATIC=${PNG_STATIC}
|
||||
-DPNG_SHARED=${PNG_SHARED}
|
||||
-DPNG_FRAMEWORK=OFF
|
||||
-DPNG_TESTS=OFF
|
||||
-DSKIP_INSTALL_EXECUTABLES=ON
|
||||
-DSKIP_INSTALL_FILES=OFF
|
||||
${FEATURE_OPTIONS}
|
||||
OPTIONS_DEBUG
|
||||
-DSKIP_INSTALL_HEADERS=ON
|
||||
MAYBE_UNUSED_VARIABLES
|
||||
PNG_ARM_NEON
|
||||
)
|
||||
vcpkg_cmake_install()
|
||||
vcpkg_cmake_config_fixup(PACKAGE_NAME png CONFIG_PATH lib/cmake/PNG)
|
||||
vcpkg_cmake_config_fixup(CONFIG_PATH lib/libpng)
|
||||
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/png")
|
||||
|
||||
# unofficial legacy usage
|
||||
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/libpng-config.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
|
||||
|
||||
vcpkg_fixup_pkgconfig()
|
||||
if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
|
||||
if(NOT VCPKG_BUILD_TYPE)
|
||||
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/libpng16.pc" "-lpng16" "-llibpng16d")
|
||||
file(INSTALL "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/libpng16.pc" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig" RENAME "libpng.pc")
|
||||
endif()
|
||||
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/libpng16.pc" "-lpng16" "-llibpng16")
|
||||
elseif(NOT VCPKG_BUILD_TYPE)
|
||||
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/libpng16.pc" "-lpng16" "-lpng16d")
|
||||
file(INSTALL "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/libpng16.pc" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig" RENAME "libpng.pc")
|
||||
endif()
|
||||
file(INSTALL "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/libpng16.pc" DESTINATION "${CURRENT_PACKAGES_DIR}/lib/pkgconfig" RENAME "libpng.pc")
|
||||
|
||||
vcpkg_copy_pdbs()
|
||||
|
||||
if(PNG_TOOLS)
|
||||
vcpkg_copy_tools(TOOL_NAMES "pngfix" "png-fix-itxt" AUTO_CLEAN)
|
||||
endif()
|
||||
|
||||
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
|
||||
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
|
||||
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
|
3059
cmake/vcpkg-ports/libpng/target-specific-code.patch
Normal file
3059
cmake/vcpkg-ports/libpng/target-specific-code.patch
Normal file
File diff suppressed because it is too large
Load Diff
4
cmake/vcpkg-ports/libpng/usage
Executable file
4
cmake/vcpkg-ports/libpng/usage
Executable file
@ -0,0 +1,4 @@
|
||||
libpng provides CMake targets:
|
||||
|
||||
find_package(PNG REQUIRED)
|
||||
target_link_libraries(main PRIVATE PNG::PNG)
|
3
cmake/vcpkg-ports/libpng/vcpkg-cmake-wrapper.cmake
Executable file
3
cmake/vcpkg-ports/libpng/vcpkg-cmake-wrapper.cmake
Executable file
@ -0,0 +1,3 @@
|
||||
find_library(PNG_LIBRARY_RELEASE NAMES png16 libpng16 NAMES_PER_DIR PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib" NO_DEFAULT_PATH)
|
||||
find_library(PNG_LIBRARY_DEBUG NAMES png16d libpng16d NAMES_PER_DIR PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib" NO_DEFAULT_PATH)
|
||||
_find_package(${ARGS})
|
32
cmake/vcpkg-ports/libpng/vcpkg.json
Executable file
32
cmake/vcpkg-ports/libpng/vcpkg.json
Executable file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "libpng",
|
||||
"version": "1.6.48",
|
||||
"description": "libpng is a library implementing an interface for reading and writing PNG (Portable Network Graphics) format files",
|
||||
"homepage": "https://github.com/pnggroup/libpng",
|
||||
"license": "libpng-2.0",
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "vcpkg-cmake",
|
||||
"host": true
|
||||
},
|
||||
{
|
||||
"name": "vcpkg-cmake-config",
|
||||
"host": true
|
||||
},
|
||||
{
|
||||
"name": "vcpkg-cmake-get-vars",
|
||||
"host": true,
|
||||
"platform": "arm & android"
|
||||
},
|
||||
"zlib"
|
||||
],
|
||||
"features": {
|
||||
"apng": {
|
||||
"description": "This is backward compatible with the regular libpng, both in library usage and format"
|
||||
},
|
||||
"tools": {
|
||||
"description": "Build the libpng tools",
|
||||
"supports": "!android & !ios"
|
||||
}
|
||||
}
|
||||
}
|
19
flake.lock
generated
19
flake.lock
generated
@ -32,27 +32,10 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"qrcodegenerator": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1737616857,
|
||||
"narHash": "sha256-6SugPt0lp1Gz7nV23FLmsmpfzgFItkSw7jpGftsDPWc=",
|
||||
"owner": "nayuki",
|
||||
"repo": "QR-Code-generator",
|
||||
"rev": "2c9044de6b049ca25cb3cd1649ed7e27aa055138",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nayuki",
|
||||
"repo": "QR-Code-generator",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"libnbtplusplus": "libnbtplusplus",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"qrcodegenerator": "qrcodegenerator"
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -15,11 +15,6 @@
|
||||
url = "github:PrismLauncher/libnbtplusplus";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
qrcodegenerator = {
|
||||
url = "github:nayuki/QR-Code-generator";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
@ -27,7 +22,6 @@
|
||||
self,
|
||||
nixpkgs,
|
||||
libnbtplusplus,
|
||||
qrcodegenerator,
|
||||
}:
|
||||
|
||||
let
|
||||
@ -175,7 +169,6 @@
|
||||
prismlauncher-unwrapped = prev.callPackage ./nix/unwrapped.nix {
|
||||
inherit
|
||||
libnbtplusplus
|
||||
qrcodegenerator
|
||||
self
|
||||
;
|
||||
};
|
||||
|
@ -1321,8 +1321,15 @@ target_link_libraries(Launcher_logic
|
||||
qdcss
|
||||
BuildConfig
|
||||
Qt${QT_VERSION_MAJOR}::Widgets
|
||||
qrcodegenerator
|
||||
)
|
||||
|
||||
if(TARGET PkgConfig::libqrencode)
|
||||
target_link_libraries(Launcher_logic PkgConfig::libqrencode)
|
||||
else()
|
||||
target_include_directories(Launcher_logic PRIVATE ${LIBQRENCODE_INCLUDE_DIR})
|
||||
target_link_libraries(Launcher_logic ${LIBQRENCODE_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(TARGET PkgConfig::tomlplusplus)
|
||||
target_link_libraries(Launcher_logic PkgConfig::tomlplusplus)
|
||||
else()
|
||||
|
@ -50,7 +50,7 @@
|
||||
#include <QUrl>
|
||||
#include <QtWidgets/QPushButton>
|
||||
|
||||
#include "qrcodegen.hpp"
|
||||
#include "qrencode.h"
|
||||
|
||||
MSALoginDialog::MSALoginDialog(QWidget* parent) : QDialog(parent), ui(new Ui::MSALoginDialog)
|
||||
{
|
||||
@ -146,27 +146,32 @@ void MSALoginDialog::authorizeWithBrowser(const QUrl& url)
|
||||
m_url = url;
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/21400254/how-to-draw-a-qr-code-with-qt-in-native-c-c
|
||||
void paintQR(QPainter& painter, const QSize sz, const QString& data, QColor fg)
|
||||
void paintQR(QPainter& painter, const QSize canvasSize, const QString& data, QColor fg)
|
||||
{
|
||||
// NOTE: At this point you will use the API to get the encoding and format you want, instead of my hardcoded stuff:
|
||||
qrcodegen::QrCode qr = qrcodegen::QrCode::encodeText(data.toUtf8().constData(), qrcodegen::QrCode::Ecc::LOW);
|
||||
const int s = qr.getSize() > 0 ? qr.getSize() : 1;
|
||||
const double w = sz.width();
|
||||
const double h = sz.height();
|
||||
const double aspect = w / h;
|
||||
const double size = ((aspect > 1.0) ? h : w);
|
||||
const double scale = size / (s + 2);
|
||||
// NOTE: For performance reasons my implementation only draws the foreground parts in supplied color.
|
||||
// It expects background to be prepared already (in white or whatever is preferred).
|
||||
const auto* qr = QRcode_encodeString(data.toUtf8().constData(), 0, QRecLevel::QR_ECLEVEL_M, QRencodeMode::QR_MODE_8, 1);
|
||||
if(!qr) {
|
||||
qWarning() << "Unable to encode '" << data << "' as QR code";
|
||||
return;
|
||||
}
|
||||
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.setBrush(fg);
|
||||
for (int y = 0; y < s; y++) {
|
||||
for (int x = 0; x < s; x++) {
|
||||
const int color = qr.getModule(x, y); // 0 for white, 1 for black
|
||||
if (0 != color) {
|
||||
const double rx1 = (x + 1) * scale, ry1 = (y + 1) * scale;
|
||||
QRectF r(rx1, ry1, scale, scale);
|
||||
|
||||
// Make sure the QR code fits in the canvas with some padding
|
||||
const auto qrSize = qr->width;
|
||||
const auto canvasWidth = canvasSize.width();
|
||||
const auto canvasHeight = canvasSize.height();
|
||||
const auto scale = 0.8 * std::min(canvasWidth / qrSize, canvasHeight / qrSize);
|
||||
|
||||
// Find an offset to center it in the canvas
|
||||
const auto offsetX = (canvasWidth - qrSize * scale) / 2;
|
||||
const auto offsetY = (canvasHeight - qrSize * scale) / 2;
|
||||
|
||||
for (int y = 0; y < qrSize; y++) {
|
||||
for (int x = 0; x < qrSize; x++) {
|
||||
auto shouldFillIn = qr->data[y * qrSize + x] & 1;
|
||||
if (shouldFillIn) {
|
||||
QRectF r(offsetX + x * scale, offsetY + y * scale, scale, scale);
|
||||
painter.drawRects(&r, 1);
|
||||
}
|
||||
}
|
||||
|
@ -1 +0,0 @@
|
||||
Subproject commit 2c9044de6b049ca25cb3cd1649ed7e27aa055138
|
@ -9,8 +9,8 @@
|
||||
jdk17,
|
||||
kdePackages,
|
||||
libnbtplusplus,
|
||||
qrcodegenerator,
|
||||
ninja,
|
||||
qrencode,
|
||||
self,
|
||||
stripJavaArchivesHook,
|
||||
tomlplusplus,
|
||||
@ -63,9 +63,6 @@ stdenv.mkDerivation {
|
||||
postUnpack = ''
|
||||
rm -rf source/libraries/libnbtplusplus
|
||||
ln -s ${libnbtplusplus} source/libraries/libnbtplusplus
|
||||
|
||||
rm -rf source/libraries/qrcodegenerator
|
||||
ln -s ${qrcodegenerator} source/libraries/qrcodegenerator
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [
|
||||
@ -82,6 +79,7 @@ stdenv.mkDerivation {
|
||||
kdePackages.qtbase
|
||||
kdePackages.qtnetworkauth
|
||||
kdePackages.quazip
|
||||
qrencode
|
||||
tomlplusplus
|
||||
zlib
|
||||
]
|
||||
|
@ -3,6 +3,7 @@
|
||||
"bzip2",
|
||||
"cmark",
|
||||
{ "name": "ecm", "host": true },
|
||||
"libqrencode",
|
||||
{ "name": "pkgconf", "host": true },
|
||||
"tomlplusplus",
|
||||
"zlib"
|
||||
|
Loading…
x
Reference in New Issue
Block a user