diff --git a/.gitignore b/.gitignore index 6d51d27d..32698b35 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ qskinny.pro.user *.log html tags +.vscode diff --git a/CMakeLists.txt b/CMakeLists.txt index ff5ccf6c..ae1d52f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20) +cmake_minimum_required(VERSION 3.16.3) project(qskinny VERSION 999.99.9) # TODO get from git branch name or @@ -8,21 +8,63 @@ set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) -# force include Qt's private headers -set(Qt5Core_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) -set(Qt5Gui_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) -set(Qt5OpenGL_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) -set(Qt5Quick_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) -set(Qt5QuickWidgets_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) -set(Qt5Svg_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) -set(Qt5WebEngine_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) -set(Qt5WebEngineCore_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) -set(Qt5Widgets_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) +if("${Qt5_DIR}" STREQUAL "" AND "${Qt6_DIR}" STREQUAL "") + message(FATAL_ERROR "Neither Qt5_DIR nor Qt6_DIR defined!") +else() + # force include Qt's private headers + if(NOT "${Qt5_DIR}" STREQUAL "") + set(Qt5Core_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + set(Qt5Gui_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + set(Qt5OpenGL_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + set(Qt5Quick_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + set(Qt5QuickWidgets_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + set(Qt5Svg_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + set(Qt5WebEngine_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + set(Qt5WebEngineCore_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + set(Qt5Widgets_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + elseif(NOT "${Qt6_DIR}" STREQUAL "") + #set(Qt6Core_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + #set(Qt6Gui_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + set(Qt6OpenGL_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + #set(Qt6Quick_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + #set(Qt6QuickWidgets_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + #set(Qt6Svg_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + set(Qt6WebEngine_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + set(Qt6WebEngineCore_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + set(Qt6WebEngineQuick_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + #set(Qt6Widgets_FIND_COMPONENTS Private CACHE STRING "force include private headers" FORCE) + endif() +endif() -set(Qt5_DIR "C:/Qt/5.15.2/msvc2019_64/lib/cmake/Qt5" CACHE PATH "") # TODO pass in externally -find_package(Qt5 REQUIRED COMPONENTS Core Gui Opengl Quick Quickwidgets Svg Webengine WebengineCore Widgets) +if("${Qt5_DIR}" STREQUAL "" AND "${Qt6_DIR}" STREQUAL "") + message(FATAL_ERROR "Neither Qt5_DIR nor Qt6_DIR defined!") +else() + if(NOT "${Qt5_DIR}" STREQUAL "") + find_package(Qt5 REQUIRED COMPONENTS Core Gui OpenGL Quick Quickwidgets Svg Webengine WebengineCore Widgets) + set(Qt Qt${Qt5_VERSION_MAJOR}) # TODO find better solution for Qt namespace + set(Qt_VERSION ${Qt5_VERSION}) + set(Qt_VERSION_MAJOR ${Qt5_VERSION_MAJOR}) + set(Qt_VERSION_MINOR ${Qt5_VERSION_MINOR}) + set(Qt_VERSION_PATCH ${Qt5_VERSION_PATCH}) + elseif(NOT "${Qt6_DIR}" STREQUAL "") + find_package(Qt6 REQUIRED COMPONENTS Core Gui OpenGL Quick Quickwidgets Svg WebEngineCore WebEngineQuick Widgets) + set(Qt Qt${Qt6_VERSION_MAJOR}) # TODO find better solution for Qt namespace + set(Qt_VERSION ${Qt6_VERSION}) + set(Qt_VERSION_MAJOR ${Qt6_VERSION_MAJOR}) + set(Qt_VERSION_MINOR ${Qt6_VERSION_MINOR}) + set(Qt_VERSION_PATCH ${Qt6_VERSION_PATCH}) + endif() +endif() + +if(TRUE) + message(STATUS "\${Qt} : ${Qt}") + message(STATUS "\${Qt_VERSION_MAJOR}: ${Qt_VERSION_MAJOR}") + message(STATUS "\${Qt_VERSION_MINOR}: ${Qt_VERSION_MINOR}") + message(STATUS "\${Qt_VERSION_PATCH}: ${Qt_VERSION_PATCH}") +endif() # define install directories + set(QSK_INSTALL_DOCS doc) set(QSK_INSTALL_HEADERS include) set(QSK_INSTALL_LIBS lib) diff --git a/examples/iotdashboard/CMakeLists.txt b/examples/iotdashboard/CMakeLists.txt index 3a52c3b6..d3545c78 100644 --- a/examples/iotdashboard/CMakeLists.txt +++ b/examples/iotdashboard/CMakeLists.txt @@ -84,4 +84,4 @@ target_link_libraries(${TARGET_NAME} PRIVATE qskinny qsktestsupport - Qt5::Svg) \ No newline at end of file + ${Qt}::Svg) \ No newline at end of file diff --git a/features/qskconfig.cmake b/features/qskconfig.cmake index 951b59c4..e1181b60 100644 --- a/features/qskconfig.cmake +++ b/features/qskconfig.cmake @@ -50,6 +50,8 @@ set(OBJECTS_DIR obj) set(RCC_DIR rcc) option(BUILD_QSKDLL "build qskinny as shared library" ON) +option(ENABLE_PINYIN "enable romanization system for standard mandarin chinese" ON) +option(ENABLE_HUNSPELL "enable spell checker" ON) if(UNIX AND NOT APPLE) set(LINUX TRUE) diff --git a/inputcontext/CMakeLists.txt b/inputcontext/CMakeLists.txt index 0d3c6dc0..8987b5e8 100644 --- a/inputcontext/CMakeLists.txt +++ b/inputcontext/CMakeLists.txt @@ -13,6 +13,30 @@ list(APPEND TARGET_SOURCES list(APPEND TARGET_OTHER_FILES metadata.json) +if(ENABLE_PINYIN) + if(UNIX) + # TODO CONFIG += link_pkgconfig PKGCONFIG += pinyin + list(APPEND TARGET_HEADERS + QskPinyinTextPredictor.h) + list(APPEND TARGET_SOURCES + QskPinyinTextPredictor.cpp) + else() + message(WARNING "Feature 'pinyin' currently only available for UNIX!") + endif() +endif() + +if(ENABLE_HUNSPELL) + if(UNIX) + # TODO CONFIG += link_pkgconfig PKGCONFIG += hunspell + list(APPEND TARGET_HEADERS + QskHunspellTextPredictor.h) + list(APPEND TARGET_SOURCES + QskHunspellTextPredictor.cpp) + else() + message(WARNING "Feature 'hunspell' currently only available for UNIX!") + endif() +endif() + add_library(${TARGET_NAME} SHARED ${TARGET_SOURCES} ${TARGET_HEADERS} ${TARGET_OTHER_FILES}) if(BUILD_QSKDLL) @@ -24,33 +48,9 @@ endif() target_link_libraries(${TARGET_NAME} PRIVATE qskinny - Qt5::GuiPrivate) + ${Qt}::GuiPrivate) set_target_properties(${TARGET_NAME} PROPERTIES AUTOMOC ON) -install(TARGETS ${TARGET_NAME} DESTINATION ${QSK_INSTALL_PLUGINS}/platforminputcontexts) - -# TODO -# pinyin { -# unix -# { -# CONFIG += link_pkgconfig PKGCONFIG += pinyin -# -# HEADERS += QskPinyinTextPredictor.h -# -# SOURCES += QskPinyinTextPredictor.cpp -# } -# } -# -# hunspell { -# unix -# { -# CONFIG += link_pkgconfig PKGCONFIG += hunspell -# -# HEADERS += QskHunspellTextPredictor.h -# -# SOURCES += QskHunspellTextPredictor.cpp -# } -# -# } \ No newline at end of file +install(TARGETS ${TARGET_NAME} DESTINATION ${QSK_INSTALL_PLUGINS}/platforminputcontexts) \ No newline at end of file diff --git a/playground/CMakeLists.txt b/playground/CMakeLists.txt index 75e9f70b..75150bbb 100644 --- a/playground/CMakeLists.txt +++ b/playground/CMakeLists.txt @@ -6,12 +6,12 @@ add_subdirectory(inputpanel) add_subdirectory(images) add_subdirectory(shadows) -# if(TARGET Qt5::WebEngine) # TODO check how to add optionally +# if(TARGET ${Qt}::WebEngine) # TODO check how to add optionally if(TRUE) add_subdirectory(webview) endif() -# if(TARGET Qt5::QuickWidgets) # TODO check how to add optionally +# if(TARGET ${Qt}::QuickWidgets) # TODO check how to add optionally if(TRUE) add_subdirectory(grids) endif() diff --git a/playground/grids/CMakeLists.txt b/playground/grids/CMakeLists.txt index 3768aa1c..e7bdc1ad 100644 --- a/playground/grids/CMakeLists.txt +++ b/playground/grids/CMakeLists.txt @@ -35,7 +35,7 @@ target_link_libraries(${TARGET_NAME} PRIVATE qskinny qsktestsupport - Qt5::QuickWidgets) + ${Qt}::QuickWidgets) set_target_properties(${TARGET_NAME} PROPERTIES diff --git a/playground/webview/CMakeLists.txt b/playground/webview/CMakeLists.txt index 8bd5b756..b2c83ff5 100644 --- a/playground/webview/CMakeLists.txt +++ b/playground/webview/CMakeLists.txt @@ -10,9 +10,19 @@ add_executable(${TARGET_NAME} target_link_libraries(${TARGET_NAME} PRIVATE qskinny - qsktestsupport - Qt5::WebEngine - Qt5::WebEnginePrivate) + qsktestsupport) + +if (Qt_VERSION_MAJOR VERSION_GREATER "5") + target_link_libraries(${TARGET_NAME} + PRIVATE + ${Qt}::WebEngineQuick + ${Qt}::WebEngineQuickPrivate) +else() + target_link_libraries(${TARGET_NAME} + PRIVATE + ${Qt}::WebEngine + ${Qt}::WebEnginePrivate) +endif() set_target_properties(${TARGET_NAME} PROPERTIES diff --git a/playground/webview/main.cpp b/playground/webview/main.cpp index 454e3639..2e1437fa 100644 --- a/playground/webview/main.cpp +++ b/playground/webview/main.cpp @@ -37,7 +37,10 @@ int main( int argc, char* argv[] ) QskObjectCounter counter( true ); #endif +#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) + // namespace QtWebEngine doesn't exist in Qt6: https://doc.qt.io/qt-5/qtwebengine.html QtWebEngine::initialize(); +#endif QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app( argc, argv ); diff --git a/scripts/cmake/qskinny-macros.cmake b/scripts/cmake/qskinny-macros.cmake index b107c169..5ad3c467 100644 --- a/scripts/cmake/qskinny-macros.cmake +++ b/scripts/cmake/qskinny-macros.cmake @@ -1,4 +1,4 @@ -if(TARGET Qt5::Svg) +if(TARGET ${Qt}::Svg) ## @param SVG_FILENAME absolute filename to the svg ## @param QVG_FILENAME absolute filename to the qvg function(svg2qvg SVG_FILENAME QVG_FILENAME) @@ -8,7 +8,7 @@ if(TARGET Qt5::Svg) COMMAND svg2qvg ${SVG_FILENAME} ${QVG_FILENAME} OUTPUT ${QVG_FILENAME} DEPENDS ${SVG_FILENAME} - WORKING_DIRECTORY $ + WORKING_DIRECTORY $ COMMENT "Compiling ${SVG_FILENAME} to ${QVG_FILENAME}") endfunction() endif() \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b8920622..9fd4deb5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,14 +1,6 @@ include(${CMAKE_SOURCE_DIR}/features/qskconfig.cmake) include(${CMAKE_SOURCE_DIR}/scripts/cmake/qskinny-macros.cmake) -#TODO -#QSK_SUBDIRS = common graphic nodes controls layouts dialogs inputpanel -#INCLUDEPATH *= $${QSK_SUBDIRS} -#DEPENDPATH *= $${QSK_SUBDIRS} - -#CONFIG += pinyin -#CONFIG += hunspell - list(APPEND TARGET_HEADERS common/QskArcMetrics.h common/QskAspect.h @@ -65,7 +57,7 @@ list(APPEND TARGET_SOURCES common/QskTextColors.cpp common/QskTextOptions.cpp) -list(APPEND TARGET_HEADERS #TODO why separate +list(APPEND TARGET_HEADERS graphic/QskColorFilter.h graphic/QskGraphic.h graphic/QskGraphicImageProvider.h @@ -370,41 +362,31 @@ list(APPEND TARGET_SOURCES inputpanel/QskInputPredictionBar.cpp inputpanel/QskVirtualKeyboard.cpp) -#TODO -#pinyin { -# -#unix { -# -#target_compile_definitions(${TARGET_NAME} PRIVATE PINYIN) -# -#CONFIG += link_pkgconfig -#PKGCONFIG += pinyin -# -#HEADERS += -#inputpanel/QskPinyinTextPredictor.h -# -#SOURCES += -#inputpanel/QskPinyinTextPredictor.cpp -#} -#} +if(ENABLE_PINYIN) + if(UNIX) + target_compile_definitions(${TARGET_NAME} PRIVATE PINYIN) # TODO required? + # TODO CONFIG += link_pkgconfig PKGCONFIG += pinyin + list(APPEND TARGET_HEADERS + inputpanel/QskPinyinTextPredictor.h) -#TODO -#hunspell { -# -#unix { -# -#target_compile_definitions(${TARGET_NAME} PRIVATE HUNSPELL) -# -#CONFIG += link_pkgconfig -#PKGCONFIG += hunspell -# -#HEADERS += -#inputpanel/QskHunspellTextPredictor.h -# -#SOURCES += -#inputpanel/QskHunspellTextPredictor.cpp -#} -#} + list(APPEND TARGET_SOURCES + inputpanel/QskPinyinTextPredictor.cpp) + else() + message(WARNING "Feature 'pinyin' currently only available for UNIX!") + endif() +endif() + +if(ENABLE_HUNSPELL) + if(UNIX) + # TODO CONFIG += link_pkgconfig PKGCONFIG += hunspell + list(APPEND TARGET_HEADERS + inputpanel/QskHunspellTextPredictor.h) + list(APPEND TARGET_SOURCES + inputpanel/QskHunspellTextPredictor.cpp) + else() + message(WARNING "Feature 'hunspell' currently only available for UNIX!") + endif() +endif() set(TARGET_NAME qskinny) @@ -414,10 +396,6 @@ else() add_library(${TARGET_NAME} STATIC ${TARGET_SOURCES} ${TARGET_HEADERS} ${TARGET_RESSOURCES}) endif() -if (Qt5_VERSION_MAJOR VERSION_GREATER "5") - target_link_libraries(${TARGET_NAME} PRIVATE Qt5::Opengl) -endif() - if(BUILD_QSKDLL) target_compile_definitions(${TARGET_NAME} PUBLIC @@ -438,10 +416,17 @@ target_include_directories(${TARGET_NAME} target_link_libraries(${TARGET_NAME} PUBLIC - Qt5::Core - Qt5::CorePrivate - Qt5::Quick - Qt5::QuickPrivate) + ${Qt}::Core + ${Qt}::CorePrivate + ${Qt}::Quick + ${Qt}::QuickPrivate) + +if (Qt_VERSION_MAJOR VERSION_GREATER "5") + target_link_libraries(${TARGET_NAME} + PUBLIC + ${Qt}::OpenGL + ${Qt}::OpenGLPrivate) +endif() set_target_properties(${TARGET_NAME} PROPERTIES diff --git a/src/common/QskNamespace.h b/src/common/QskNamespace.h index 3f274d12..357246ec 100644 --- a/src/common/QskNamespace.h +++ b/src/common/QskNamespace.h @@ -11,7 +11,11 @@ namespace Qsk { +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + Q_NAMESPACE_EXPORT(QSK_EXPORT) +#else QSK_EXPORT Q_NAMESPACE +#endif enum Direction { diff --git a/src/graphic/QskStandardSymbol.h b/src/graphic/QskStandardSymbol.h index 385ec670..5ead9f49 100644 --- a/src/graphic/QskStandardSymbol.h +++ b/src/graphic/QskStandardSymbol.h @@ -13,7 +13,11 @@ class QskGraphic; namespace QskStandardSymbol { +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + Q_NAMESPACE_EXPORT(QSK_EXPORT) +#else QSK_EXPORT Q_NAMESPACE +#endif enum Type { diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index fbf09b88..bc768dd1 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,3 +1,3 @@ -if(TARGET Qt5::Svg) +if(TARGET ${Qt}::Svg) add_subdirectory(svg2qvg) endif() \ No newline at end of file diff --git a/tools/svg2qvg/CMakeLists.txt b/tools/svg2qvg/CMakeLists.txt index 87fc8dfe..24c5d369 100644 --- a/tools/svg2qvg/CMakeLists.txt +++ b/tools/svg2qvg/CMakeLists.txt @@ -26,14 +26,14 @@ if(BUILD_SVG2QVG_STANDALONE) target_link_libraries(${TARGET_NAME} PRIVATE - Qt5::Gui - Qt5::GuiPrivate - Qt5::Svg) + ${Qt}::Gui + ${Qt}::GuiPrivate + ${Qt}::Svg) else() target_link_libraries(${TARGET_NAME} PRIVATE qskinny - Qt5::Svg) + ${Qt}::Svg) endif() install(TARGETS ${TARGET_NAME} DESTINATION ${TARGET_INSTALL_SUFFIX})