[neon/backports-noble/kcolorpicker-noble/Neon/unstable] /: New upstream version 0.3.0
Boyuan Yang
null at kde.org
Wed Jul 3 15:10:16 BST 2024
Git commit d36126a581d832cd6589d0bdb9b5bb2bfc1aa2b3 by Boyuan Yang.
Committed on 17/02/2024 at 21:32.
Pushed by jriddell into branch 'Neon/unstable'.
New upstream version 0.3.0
M +35 -25 CMakeLists.txt
M +11 -4 README.md
A +9 -0 cmake/kColorPicker-Qt5Config.cmake.in
A +9 -0 cmake/kColorPicker-Qt6Config.cmake.in
D +0 -9 cmake/kColorPickerConfig.cmake.in
M +1 -1 example/CMakeLists.txt
M +2 -2 example/main.cpp
M +1 -1 include/kColorPicker/KColorPicker.h
M +1 -1 src/KColorPicker.cpp
M +2 -2 src/PopupMenu.cpp
M +3 -3 tests/CMakeLists.txt
https://invent.kde.org/neon/backports-noble/kcolorpicker-noble/-/commit/d36126a581d832cd6589d0bdb9b5bb2bfc1aa2b3
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d412f33..6ba8f15 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.5)
-project(kColorPicker LANGUAGES CXX VERSION 0.2.0)
+project(kColorPicker LANGUAGES CXX VERSION 0.3.0)
set(QT_MIN_VERSION "5.9.4")
@@ -13,7 +13,17 @@ set(CMAKE_AUTORCC ON)
option(BUILD_TESTS "Build Unit Tests" OFF)
option(BUILD_EXAMPLE "Build Example Application" ON)
-find_package(Qt5 ${QT_MIN_VERSION} REQUIRED Widgets)
+option(BUILD_WITH_QT6 "Build with Qt6" OFF)
+if(BUILD_WITH_QT6)
+ set(CMAKE_CXX_STANDARD 17)
+ set(QT_MAJOR_VERSION 6)
+ set(kColorPicker_LIB_NAME "kColorPicker-Qt6")
+else()
+ set(QT_MAJOR_VERSION 5)
+ set(kColorPicker_LIB_NAME "kColorPicker-Qt5")
+endif()
+
+find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED Widgets)
include(GNUInstallDirs)
include(FeatureSummary)
@@ -27,33 +37,33 @@ if (BUILD_EXAMPLE)
endif (BUILD_EXAMPLE)
if (BUILD_TESTS)
- find_package(Qt5 ${QT_MIN_VERSION} REQUIRED Test)
+ find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED Test)
enable_testing()
add_subdirectory(tests)
endif (BUILD_TESTS)
include(CMakePackageConfigHelpers)
-add_library(kColorPicker
+add_library(${kColorPicker_LIB_NAME}
${KCOLORPICKER_SRCS}
${CMAKE_CURRENT_SOURCE_DIR}/include/kColorPicker/KColorPicker.h
${CMAKE_CURRENT_SOURCE_DIR}/icons/kColorPicker_icons.qrc
)
-add_library(kColorPicker::kColorPicker ALIAS kColorPicker)
+#add_library(kColorPicker::kColorPicker ALIAS kColorPicker)
-target_include_directories(kColorPicker
+target_include_directories(${kColorPicker_LIB_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
- $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>/${kColorPicker_LIB_NAME}
)
-target_link_libraries(kColorPicker PUBLIC Qt5::Widgets)
+target_link_libraries(${kColorPicker_LIB_NAME} PUBLIC Qt${QT_MAJOR_VERSION}::Widgets)
-target_compile_definitions(kColorPicker PRIVATE KIMAGEANNOTATOR_LIB)
+target_compile_definitions(${kColorPicker_LIB_NAME} PRIVATE KIMAGEANNOTATOR_LIB)
-set_target_properties(kColorPicker
+set_target_properties(${kColorPicker_LIB_NAME}
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib
@@ -62,43 +72,43 @@ set_target_properties(kColorPicker
SOVERSION 0
)
-install(TARGETS kColorPicker
- EXPORT kColorPicker-targets
+install(TARGETS ${kColorPicker_LIB_NAME}
+ EXPORT ${kColorPicker_LIB_NAME}-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/kColorPicker
- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${kColorPicker_LIB_NAME}
)
-configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/kColorPickerConfig.cmake.in
- ${CMAKE_CURRENT_BINARY_DIR}/cmake/kColorPickerConfig.cmake
- INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kColorPicker
+configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/${kColorPicker_LIB_NAME}Config.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/cmake/${kColorPicker_LIB_NAME}Config.cmake
+ INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${kColorPicker_LIB_NAME}
)
-write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/cmake/kColorPickerConfig-version.cmake
+write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/cmake/${kColorPicker_LIB_NAME}Config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
install(FILES
- ${CMAKE_CURRENT_BINARY_DIR}/cmake/kColorPickerConfig.cmake
- ${CMAKE_CURRENT_BINARY_DIR}/cmake/kColorPickerConfig-version.cmake
- DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kColorPicker
+ ${CMAKE_CURRENT_BINARY_DIR}/cmake/${kColorPicker_LIB_NAME}Config.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/cmake/${kColorPicker_LIB_NAME}Config-version.cmake
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${kColorPicker_LIB_NAME}
)
-export(EXPORT kColorPicker-targets
- FILE ${CMAKE_CURRENT_BINARY_DIR}/cmake/kColorPicker-targets.cmake
+export(EXPORT ${kColorPicker_LIB_NAME}-targets
+ FILE ${CMAKE_CURRENT_BINARY_DIR}/cmake/${kColorPicker_LIB_NAME}-targets.cmake
NAMESPACE kColorPicker::
)
-install(EXPORT kColorPicker-targets
- FILE kColorPicker-targets.cmake
+install(EXPORT ${kColorPicker_LIB_NAME}-targets
+ FILE ${kColorPicker_LIB_NAME}-targets.cmake
NAMESPACE kColorPicker::
- DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kColorPicker
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${kColorPicker_LIB_NAME}
)
# uninstall target
diff --git a/README.md b/README.md
index c126451..292494a 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# kColorPicker [![Build Status][github-badge]][github-url]
QToolButton with color popup menu with lets you select a color. The popup features a color dialog button which can be used to add custom colors to the popup menu.
-Version 0.2.0
+Version 0.3.0
![kColorPicker](https://i.imgur.com/VkhUvFa.png "kColorPicker")
@@ -14,6 +14,7 @@ Version 0.2.0
`$ mkdir build && cd build`
4. Create the makefile and build the project:
`$ cmake .. && make`
+ to build with Qt6, pass `-DBUILD_WITH_QT6=true` to the `cmake` command
5. Install shared library (not required when only using the example):
`$ sudo make install`
6. Run the example application:
@@ -30,11 +31,17 @@ only build as static library.
1. Let cmake find the shared library, optionally with version
`set(KCOLORPICKER_MIN_VERSION "0.x.x")`
- `find_package(kColorPicker ${KCOLORPICKER_MIN_VERSION} REQUIRED)`
+ to build with Qt5:
+ `find_package(kColorPicker-Qt5 ${KCOLORPICKER_MIN_VERSION} REQUIRED)`
+ to build with Qt6:
+ `find_package(kColorPicker-Qt6 ${KCOLORPICKER_MIN_VERSION} REQUIRED)`
2. Link the library with your application
- `target_link_libraries(myApp kColorPicker)`
+ if you built with Qt5:
+ `target_link_libraries(myApp kColorPicker-Qt5)`
+ if you built with Qt6:
+ `target_link_libraries(myApp kColorPicker-Qt6)`
[github-badge]: https://github.com/ksnip/kColorPicker/actions/workflows/build.yml/badge.svg
-[github-url]: https://github.com/ksnip/kColorPicker/actions
\ No newline at end of file
+[github-url]: https://github.com/ksnip/kColorPicker/actions
diff --git a/cmake/kColorPicker-Qt5Config.cmake.in b/cmake/kColorPicker-Qt5Config.cmake.in
new file mode 100644
index 0000000..6d3cac1
--- /dev/null
+++ b/cmake/kColorPicker-Qt5Config.cmake.in
@@ -0,0 +1,9 @@
+include(CMakeFindDependencyMacro)
+
+ at PACKAGE_INIT@
+
+find_dependency(Qt5 @QT_MIN_VERSION@ COMPONENTS Widgets)
+
+if(NOT TARGET kColorPicker::kColorPicker-Qt5)
+ include("${CMAKE_CURRENT_LIST_DIR}/kColorPicker-Qt5-targets.cmake")
+endif()
diff --git a/cmake/kColorPicker-Qt6Config.cmake.in b/cmake/kColorPicker-Qt6Config.cmake.in
new file mode 100644
index 0000000..d3e2d3c
--- /dev/null
+++ b/cmake/kColorPicker-Qt6Config.cmake.in
@@ -0,0 +1,9 @@
+include(CMakeFindDependencyMacro)
+
+ at PACKAGE_INIT@
+
+find_dependency(Qt6 @QT_MIN_VERSION@ COMPONENTS Widgets)
+
+if(NOT TARGET kColorPicker::kColorPicker-Qt6)
+ include("${CMAKE_CURRENT_LIST_DIR}/kColorPicker-Qt6-targets.cmake")
+endif()
diff --git a/cmake/kColorPickerConfig.cmake.in b/cmake/kColorPickerConfig.cmake.in
deleted file mode 100644
index 30037e3..0000000
--- a/cmake/kColorPickerConfig.cmake.in
+++ /dev/null
@@ -1,9 +0,0 @@
-include(CMakeFindDependencyMacro)
-
- at PACKAGE_INIT@
-
-find_dependency(Qt5 @QT_MIN_VERSION@ COMPONENTS Widgets)
-
-if(NOT TARGET kColorPicker::kColorPicker)
- include("${CMAKE_CURRENT_LIST_DIR}/kColorPicker-targets.cmake")
-endif()
\ No newline at end of file
diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt
index ef8a50b..34a8cbb 100644
--- a/example/CMakeLists.txt
+++ b/example/CMakeLists.txt
@@ -1,3 +1,3 @@
add_executable(kColorPicker-example main.cpp)
-target_link_libraries(kColorPicker-example kColorPicker)
\ No newline at end of file
+target_link_libraries(kColorPicker-example ${kColorPicker_LIB_NAME})
diff --git a/example/main.cpp b/example/main.cpp
index c562cf2..17fe5a2 100644
--- a/example/main.cpp
+++ b/example/main.cpp
@@ -19,7 +19,7 @@
#include <QApplication>
#include <QVBoxLayout>
-#include <kColorPicker/KColorPicker.h>
+#include "kColorPicker/KColorPicker.h"
using kColorPicker::KColorPicker;
@@ -37,4 +37,4 @@ int main(int argc, char **argv)
widget->show();
return app.exec();
-}
\ No newline at end of file
+}
diff --git a/include/kColorPicker/KColorPicker.h b/include/kColorPicker/KColorPicker.h
index 9309bb3..2213a61 100644
--- a/include/kColorPicker/KColorPicker.h
+++ b/include/kColorPicker/KColorPicker.h
@@ -24,7 +24,7 @@
#include <QColor>
#include <QList>
-#include <kColorPicker/KColorPickerExport.h>
+#include "kColorPicker/KColorPickerExport.h"
namespace kColorPicker {
diff --git a/src/KColorPicker.cpp b/src/KColorPicker.cpp
index bc7344a..1b83c9e 100644
--- a/src/KColorPicker.cpp
+++ b/src/KColorPicker.cpp
@@ -17,7 +17,7 @@
* Boston, MA 02110-1301, USA.
*/
-#include <kColorPicker/KColorPicker.h>
+#include "kColorPicker/KColorPicker.h"
#include "IconCreator.h"
#include "PopupMenu.h"
diff --git a/src/PopupMenu.cpp b/src/PopupMenu.cpp
index 3a1296e..19916ea 100644
--- a/src/PopupMenu.cpp
+++ b/src/PopupMenu.cpp
@@ -28,7 +28,7 @@ PopupMenu::PopupMenu(bool showAlphaChannel, QWidget *parent) :
mColorDialogButton(new ColorDialogButton(QIcon(QLatin1String(":/icons/ellipsis")), showAlphaChannel))
{
mLayout->setSpacing(0);
- mLayout->setMargin(5);
+ mLayout->setContentsMargins(5, 5, 5, 5);
setLayout(mLayout);
connect(mColorDialogButton, &AbstractPopupMenuButton::colorSelected, this, &PopupMenu::colorSelected);
@@ -136,4 +136,4 @@ QSize PopupMenu::sizeHint() const
return mLayout->sizeHint();
}
-} // namespace kColorPicker
\ No newline at end of file
+} // namespace kColorPicker
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 5a15d7c..7aa0df1 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -4,11 +4,11 @@ set(UNITTEST_SRC
add_library(KCOLORPICKER_STATIC STATIC ${KCOLORPICKER_SRCS})
-target_link_libraries(KCOLORPICKER_STATIC Qt5::Widgets kColorPicker)
+target_link_libraries(KCOLORPICKER_STATIC Qt${QT_MAJOR_VERSION}::Widgets ${kColorPicker_LIB_NAME})
foreach (UnitTest ${UNITTEST_SRC})
get_filename_component(UnitTestName ${UnitTest} NAME_WE)
add_executable(${UnitTestName} ${UnitTest})
- target_link_libraries(${UnitTestName} KCOLORPICKER_STATIC Qt5::Test)
+ target_link_libraries(${UnitTestName} KCOLORPICKER_STATIC Qt${QT_MAJOR_VERSION}::Test)
add_test(${UnitTestName} ${UnitTestName})
-endforeach (UnitTest)
\ No newline at end of file
+endforeach (UnitTest)
More information about the Neon-commits
mailing list