108 lines
3.7 KiB
Diff
108 lines
3.7 KiB
Diff
From 76f4b381971eead6ff31b8bf3bb64bb5717469c3 Mon Sep 17 00:00:00 2001
|
|
From: Damir Porobic <damir_porobic@live.com>
|
|
Date: Thu, 22 Feb 2024 12:18:14 +0100
|
|
Subject: [PATCH] Fix build against kImageAnnotator and kColorPicker that use
|
|
qt5 and qt6
|
|
|
|
---
|
|
CMakeLists.txt | 18 +++++++++++++-----
|
|
src/CMakeLists.txt | 2 +-
|
|
src/gui/operations/CopyAsDataUriOperation.cpp | 9 ++++-----
|
|
tests/CMakeLists.txt | 2 +-
|
|
4 files changed, 19 insertions(+), 12 deletions(-)
|
|
|
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index 2613ac42..f8088dd7 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -44,6 +44,14 @@ endif ()
|
|
set(QT_COMPONENTS Core Widgets Network Xml PrintSupport DBus Svg)
|
|
set(QT_MIN_VERSION 5.9.4)
|
|
|
|
+option(BUILD_WITH_QT6 "Build against Qt6" OFF)
|
|
+
|
|
+if (BUILD_WITH_QT6)
|
|
+ set(QT_MAJOR_VERSION 6)
|
|
+else()
|
|
+ set(QT_MAJOR_VERSION 5)
|
|
+endif()
|
|
+
|
|
if (UNIX AND NOT APPLE)
|
|
list(APPEND QT_COMPONENTS Concurrent)
|
|
endif()
|
|
@@ -58,13 +66,13 @@ if (BUILD_TESTS)
|
|
list(APPEND QT_COMPONENTS Test)
|
|
endif()
|
|
|
|
-find_package(Qt5 ${QT_MIN_VERSION} REQUIRED ${QT_COMPONENTS})
|
|
+find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED ${QT_COMPONENTS})
|
|
|
|
-set(KIMAGEANNOTATOR_MIN_VERSION 0.6.1)
|
|
-find_package(kImageAnnotator ${KIMAGEANNOTATOR_MIN_VERSION} REQUIRED)
|
|
+set(KIMAGEANNOTATOR_MIN_VERSION 0.7.0)
|
|
+find_package(kImageAnnotator-Qt${QT_MAJOR_VERSION} ${KIMAGEANNOTATOR_MIN_VERSION} REQUIRED)
|
|
|
|
-set(KCOLORPICKER_MIN_VERSION 0.2.0)
|
|
-find_package(kColorPicker ${KCOLORPICKER_MIN_VERSION} REQUIRED)
|
|
+set(KCOLORPICKER_MIN_VERSION 0.3.0)
|
|
+find_package(kColorPicker-Qt${QT_MAJOR_VERSION} ${KCOLORPICKER_MIN_VERSION} REQUIRED)
|
|
|
|
set(BASEPATH "${CMAKE_SOURCE_DIR}")
|
|
include_directories("${BASEPATH}")
|
|
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
|
|
index e60d4bba..5a637411 100644
|
|
--- a/src/CMakeLists.txt
|
|
+++ b/src/CMakeLists.txt
|
|
@@ -293,7 +293,7 @@ elseif (UNIX)
|
|
elseif (WIN32)
|
|
list(APPEND DEPENDENCY_LIBRARIES
|
|
Qt5::WinExtras
|
|
- kImageAnnotator
|
|
+ kImageAnnotator::kImageAnnotator
|
|
kColorPicker
|
|
Dwmapi
|
|
)
|
|
diff --git a/src/gui/operations/CopyAsDataUriOperation.cpp b/src/gui/operations/CopyAsDataUriOperation.cpp
|
|
index 7c9b6eef..100aa4fd 100644
|
|
--- a/src/gui/operations/CopyAsDataUriOperation.cpp
|
|
+++ b/src/gui/operations/CopyAsDataUriOperation.cpp
|
|
@@ -34,14 +34,13 @@ CopyAsDataUriOperation::CopyAsDataUriOperation(
|
|
bool CopyAsDataUriOperation::execute()
|
|
{
|
|
QByteArray byteArray;
|
|
-
|
|
QBuffer buffer(&byteArray);
|
|
buffer.open(QIODevice::WriteOnly);
|
|
- auto saved = mImage.save(&buffer, "PNG");
|
|
+ auto isSaved = mImage.save(&buffer, mConfig->saveFormat().toLatin1());
|
|
buffer.close();
|
|
|
|
- if (saved) {
|
|
- QByteArray output = "data:image/png;base64,";
|
|
+ if (isSaved) {
|
|
+ QByteArray output = "data:image/" + mConfig->saveFormat().toLatin1() +";base64,";
|
|
output.append(byteArray.toBase64());
|
|
mClipboardService->setText(output);
|
|
notifySuccess();
|
|
@@ -49,7 +48,7 @@ bool CopyAsDataUriOperation::execute()
|
|
notifyFailure();
|
|
}
|
|
|
|
- return saved;
|
|
+ return isSaved;
|
|
}
|
|
|
|
void CopyAsDataUriOperation::notifyFailure() const
|
|
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
|
|
index f4a49ffd..da19ce93 100644
|
|
--- a/tests/CMakeLists.txt
|
|
+++ b/tests/CMakeLists.txt
|
|
@@ -73,6 +73,6 @@ endif ()
|
|
foreach (UnitTest ${UNITTEST_SRC})
|
|
get_filename_component(UnitTestName ${UnitTest} NAME_WE)
|
|
add_executable(${UnitTestName} ${UnitTest} ${TESTUTILS_SRC})
|
|
- target_link_libraries(${UnitTestName} KSNIP_STATIC GTest::gmock Qt5::Test)
|
|
+ target_link_libraries(${UnitTestName} KSNIP_STATIC GTest::gmock Qt${QT_MAJOR_VERSION}::Test)
|
|
add_test(${UnitTestName} ${UnitTestName})
|
|
endforeach (UnitTest)
|