diff --git a/.gitmodules b/.gitmodules
index 0c56d8768..0a0a50bee 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -19,6 +19,6 @@
[submodule "flatpak/shared-modules"]
path = flatpak/shared-modules
url = https://github.com/flathub/shared-modules.git
-[submodule "libraries/qt-qrcodegenerator/QR-Code-generator"]
- path = libraries/qt-qrcodegenerator/QR-Code-generator
+[submodule "libraries/qrcodegenerator"]
+ path = libraries/qrcodegenerator
url = https://github.com/nayuki/QR-Code-generator
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 68d900c27..ce3d433fb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -475,7 +475,6 @@ add_subdirectory(libraries/libnbtplusplus)
add_subdirectory(libraries/systeminfo) # system information library
add_subdirectory(libraries/launcher) # java based launcher part for Minecraft
add_subdirectory(libraries/javacheck) # java compatibility checker
-add_subdirectory(libraries/qt-qrcodegenerator) # qr code generator
if(FORCE_BUNDLED_ZLIB)
message(STATUS "Using bundled zlib")
@@ -533,6 +532,15 @@ add_subdirectory(libraries/gamemode)
add_subdirectory(libraries/murmur2) # Hash for usage with the CurseForge API
add_subdirectory(libraries/qdcss) # css parser
+# qr code generator
+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)
+
############################### Built Artifacts ###############################
add_subdirectory(buildconfig)
diff --git a/COPYING.md b/COPYING.md
index 1ebde116f..f9b905351 100644
--- a/COPYING.md
+++ b/COPYING.md
@@ -404,7 +404,7 @@
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see .
-## qt-qrcodegenerator (`libraries/qt-qrcodegenerator`)
+## QR-Code-generator (`libraries/qrcodegenerator`)
Copyright © 2024 Project Nayuki. (MIT License)
https://www.nayuki.io/page/qr-code-generator-library
diff --git a/flake.lock b/flake.lock
index 5418557a3..a0057327e 100644
--- a/flake.lock
+++ b/flake.lock
@@ -32,7 +32,7 @@
"type": "github"
}
},
- "qt-qrcodegenerator": {
+ "qrcodegenerator": {
"flake": false,
"locked": {
"lastModified": 1737616857,
@@ -52,7 +52,7 @@
"inputs": {
"libnbtplusplus": "libnbtplusplus",
"nixpkgs": "nixpkgs",
- "qt-qrcodegenerator": "qt-qrcodegenerator"
+ "qrcodegenerator": "qrcodegenerator"
}
}
},
diff --git a/flake.nix b/flake.nix
index 69abd78dd..751ef2eeb 100644
--- a/flake.nix
+++ b/flake.nix
@@ -16,7 +16,7 @@
flake = false;
};
- qt-qrcodegenerator = {
+ qrcodegenerator = {
url = "github:nayuki/QR-Code-generator";
flake = false;
};
@@ -27,7 +27,7 @@
self,
nixpkgs,
libnbtplusplus,
- qt-qrcodegenerator,
+ qrcodegenerator,
}:
let
@@ -175,7 +175,7 @@
prismlauncher-unwrapped = prev.callPackage ./nix/unwrapped.nix {
inherit
libnbtplusplus
- qt-qrcodegenerator
+ qrcodegenerator
self
;
};
diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt
index 4f8b9018a..aa26b3544 100644
--- a/launcher/CMakeLists.txt
+++ b/launcher/CMakeLists.txt
@@ -1302,7 +1302,7 @@ target_link_libraries(Launcher_logic
qdcss
BuildConfig
Qt${QT_VERSION_MAJOR}::Widgets
- qrcode
+ qrcodegenerator
)
if (UNIX AND NOT CYGWIN AND NOT APPLE)
diff --git a/launcher/ui/dialogs/MSALoginDialog.cpp b/launcher/ui/dialogs/MSALoginDialog.cpp
index 83f46294d..14ec672e0 100644
--- a/launcher/ui/dialogs/MSALoginDialog.cpp
+++ b/launcher/ui/dialogs/MSALoginDialog.cpp
@@ -36,7 +36,6 @@
#include "MSALoginDialog.h"
#include "Application.h"
-#include "qr.h"
#include "ui_MSALoginDialog.h"
#include "DesktopServices.h"
@@ -44,10 +43,15 @@
#include
#include
+#include
+#include
#include
+#include
#include
#include
+#include "qrcodegen.hpp"
+
MSALoginDialog::MSALoginDialog(QWidget* parent) : QDialog(parent), ui(new Ui::MSALoginDialog)
{
ui->setupUi(this);
@@ -139,6 +143,33 @@ 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)
+{
+ // 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).
+ 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);
+ painter.drawRects(&r, 1);
+ }
+ }
+ }
+}
+
void MSALoginDialog::authorizeWithBrowserWithExtra(QString url, QString code, [[maybe_unused]] int expiresIn)
{
ui->stackedWidget->setCurrentIndex(1);
diff --git a/libraries/README.md b/libraries/README.md
index 5f7b685e5..be41e549f 100644
--- a/libraries/README.md
+++ b/libraries/README.md
@@ -99,7 +99,7 @@ Canonical implementation of the murmur2 hash, taken from [SMHasher](https://gith
Public domain (the author disclaimed the copyright).
-## qt-qrcodegenerator
+## QR-Code-generator
A simple library for generating QR codes
diff --git a/libraries/qrcodegenerator b/libraries/qrcodegenerator
new file mode 160000
index 000000000..2c9044de6
--- /dev/null
+++ b/libraries/qrcodegenerator
@@ -0,0 +1 @@
+Subproject commit 2c9044de6b049ca25cb3cd1649ed7e27aa055138
diff --git a/libraries/qt-qrcodegenerator/CMakeLists.txt b/libraries/qt-qrcodegenerator/CMakeLists.txt
deleted file mode 100644
index e18da0e71..000000000
--- a/libraries/qt-qrcodegenerator/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-cmake_minimum_required(VERSION 3.6)
-
-project(qrcode)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_CXX_STANDARD_REQUIRED true)
-set(CMAKE_C_STANDARD_REQUIRED true)
-set(CMAKE_CXX_STANDARD 11)
-set(CMAKE_C_STANDARD 11)
-
-
-if(QT_VERSION_MAJOR EQUAL 5)
- find_package(Qt5 COMPONENTS Core Gui REQUIRED)
-elseif(Launcher_QT_VERSION_MAJOR EQUAL 6)
- find_package(Qt6 COMPONENTS Core Gui Core5Compat REQUIRED)
- list(APPEND systeminfo_LIBS Qt${QT_VERSION_MAJOR}::Core5Compat)
-endif()
-
-add_library(qrcode STATIC qr.h qr.cpp QR-Code-generator/cpp/qrcodegen.cpp QR-Code-generator/cpp/qrcodegen.hpp )
-
-target_link_libraries(qrcode Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui ${systeminfo_LIBS})
-
-
-# needed for statically linked qrcode in shared libs on x86_64
-set_target_properties(qrcode
- PROPERTIES POSITION_INDEPENDENT_CODE TRUE
-)
-
-target_include_directories(qrcode PUBLIC ./ PRIVATE QR-Code-generator/cpp/)
-
diff --git a/libraries/qt-qrcodegenerator/QR-Code-generator b/libraries/qt-qrcodegenerator/QR-Code-generator
deleted file mode 160000
index f40366c40..000000000
--- a/libraries/qt-qrcodegenerator/QR-Code-generator
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit f40366c40d8d1956081f7ec643d240c02a81df52
diff --git a/libraries/qt-qrcodegenerator/qr.cpp b/libraries/qt-qrcodegenerator/qr.cpp
deleted file mode 100644
index 69bfb6da5..000000000
--- a/libraries/qt-qrcodegenerator/qr.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-
-#include "qr.h"
-#include "qrcodegen.hpp"
-
-void paintQR(QPainter& painter, const QSize sz, 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).
- 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);
- painter.drawRects(&r, 1);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/libraries/qt-qrcodegenerator/qr.h b/libraries/qt-qrcodegenerator/qr.h
deleted file mode 100644
index 290d49001..000000000
--- a/libraries/qt-qrcodegenerator/qr.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#pragma once
-
-#include
-#include
-#include
-
-// 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);
diff --git a/nix/unwrapped.nix b/nix/unwrapped.nix
index b5b02b101..d9144410f 100644
--- a/nix/unwrapped.nix
+++ b/nix/unwrapped.nix
@@ -9,7 +9,7 @@
jdk17,
kdePackages,
libnbtplusplus,
- qt-qrcodegenerator,
+ qrcodegenerator,
ninja,
self,
stripJavaArchivesHook,
@@ -64,8 +64,8 @@ stdenv.mkDerivation {
rm -rf source/libraries/libnbtplusplus
ln -s ${libnbtplusplus} source/libraries/libnbtplusplus
- rm -rf source/libraries/qt-qrcodegenerator/QR-Code-generator
- ln -s ${qt-qrcodegenerator} source/libraries/qt-qrcodegenerator/QR-Code-generator
+ rm -rf source/libraries/qrcodegenerator
+ ln -s ${qrcodegenerator} source/libraries/qrcodegenerator
'';
nativeBuildInputs = [