Commit 2175db75 authored by Dominik Charousset's avatar Dominik Charousset

Port Qt examples to Qt 6

parent 7831c888
...@@ -3,6 +3,13 @@ ...@@ -3,6 +3,13 @@
All notable changes to this project will be documented in this file. The format All notable changes to this project will be documented in this file. The format
is based on [Keep a Changelog](https://keepachangelog.com). is based on [Keep a Changelog](https://keepachangelog.com).
## [Unreleased]
### Changed
- Since support of Qt 5 expired, we have ported the Qt examples to version 6.
Hence, building the Qt examples now requires Qt in version 6.
## [0.18.5] - 2021-07-16 ## [0.18.5] - 2021-07-16
### Fixed ### Fixed
......
...@@ -23,7 +23,7 @@ option(THREADS_PREFER_PTHREAD_FLAG "Prefer -pthread flag if available " ON) ...@@ -23,7 +23,7 @@ option(THREADS_PREFER_PTHREAD_FLAG "Prefer -pthread flag if available " ON)
option(CAF_ENABLE_CURL_EXAMPLES "Build examples with libcurl" OFF) option(CAF_ENABLE_CURL_EXAMPLES "Build examples with libcurl" OFF)
option(CAF_ENABLE_PROTOBUF_EXAMPLES "Build examples with Google Protobuf" OFF) option(CAF_ENABLE_PROTOBUF_EXAMPLES "Build examples with Google Protobuf" OFF)
option(CAF_ENABLE_QT5_EXAMPLES "Build examples with the Qt5 framework" OFF) option(CAF_ENABLE_QT6_EXAMPLES "Build examples with the Qt6 framework" OFF)
option(CAF_ENABLE_RUNTIME_CHECKS "Build CAF with extra runtime assertions" OFF) option(CAF_ENABLE_RUNTIME_CHECKS "Build CAF with extra runtime assertions" OFF)
option(CAF_ENABLE_UTILITY_TARGETS "Include targets like consistency-check" OFF) option(CAF_ENABLE_UTILITY_TARGETS "Include targets like consistency-check" OFF)
option(CAF_ENABLE_ACTOR_PROFILER "Enable experimental profiler API" OFF) option(CAF_ENABLE_ACTOR_PROFILER "Enable experimental profiler API" OFF)
......
...@@ -115,9 +115,9 @@ config = [ ...@@ -115,9 +115,9 @@ config = [
extraBuildFlags: [ extraBuildFlags: [
'CAF_ENABLE_CURL_EXAMPLES:BOOL=ON', 'CAF_ENABLE_CURL_EXAMPLES:BOOL=ON',
'CAF_ENABLE_PROTOBUF_EXAMPLES:BOOL=ON', 'CAF_ENABLE_PROTOBUF_EXAMPLES:BOOL=ON',
'CAF_ENABLE_QT5_EXAMPLES:BOOL=ON', 'CAF_ENABLE_QT6_EXAMPLES:BOOL=ON',
'OPENSSL_ROOT_DIR:PATH=/usr/local/opt/openssl', 'OPENSSL_ROOT_DIR:PATH=/usr/local/opt/openssl',
'Qt5_DIR:PATH=/usr/local/opt/qt/lib/cmake/Qt5', 'Qt6_DIR:PATH=/usr/local/opt/qt/lib/cmake/Qt6',
], ],
extraDebugBuildFlags: [ extraDebugBuildFlags: [
'CAF_SANITIZERS:STRING=address', 'CAF_SANITIZERS:STRING=address',
......
...@@ -55,7 +55,7 @@ Flags (use --enable-<name> to activate and --disable-<name> to deactivate): ...@@ -55,7 +55,7 @@ Flags (use --enable-<name> to activate and --disable-<name> to deactivate):
prefer-pthread-flag prefer -pthread flag if available [ON] prefer-pthread-flag prefer -pthread flag if available [ON]
curl-examples build examples with libcurl [OFF] curl-examples build examples with libcurl [OFF]
protobuf-examples build examples with Google Protobuf [OFF] protobuf-examples build examples with Google Protobuf [OFF]
qt5-examples build examples with the Qt5 framework [OFF] qt6-examples build examples with the Qt6 framework [OFF]
runtime-checks build CAF with extra runtime assertions [OFF] runtime-checks build CAF with extra runtime assertions [OFF]
utility-targets include targets like consistency-check [OFF] utility-targets include targets like consistency-check [OFF]
actor-profiler enable experimental proiler API [OFF] actor-profiler enable experimental proiler API [OFF]
...@@ -101,7 +101,7 @@ set_build_flag() { ...@@ -101,7 +101,7 @@ set_build_flag() {
prefer-pthread-flag) FlagName='THREADS_PREFER_PTHREAD_FLAG' ;; prefer-pthread-flag) FlagName='THREADS_PREFER_PTHREAD_FLAG' ;;
curl-examples) FlagName='CAF_ENABLE_CURL_EXAMPLES' ;; curl-examples) FlagName='CAF_ENABLE_CURL_EXAMPLES' ;;
protobuf-examples) FlagName='CAF_ENABLE_PROTOBUF_EXAMPLES' ;; protobuf-examples) FlagName='CAF_ENABLE_PROTOBUF_EXAMPLES' ;;
qt5-examples) FlagName='CAF_ENABLE_QT5_EXAMPLES' ;; qt6-examples) FlagName='CAF_ENABLE_QT6_EXAMPLES' ;;
runtime-checks) FlagName='CAF_ENABLE_RUNTIME_CHECKS' ;; runtime-checks) FlagName='CAF_ENABLE_RUNTIME_CHECKS' ;;
utility-targets) FlagName='CAF_ENABLE_UTILITY_TARGETS' ;; utility-targets) FlagName='CAF_ENABLE_UTILITY_TARGETS' ;;
actor-profiler) FlagName='CAF_ENABLE_ACTOR_PROFILER' ;; actor-profiler) FlagName='CAF_ENABLE_ACTOR_PROFILER' ;;
......
...@@ -81,10 +81,10 @@ if(TARGET CAF::io) ...@@ -81,10 +81,10 @@ if(TARGET CAF::io)
add_dependencies(protobuf_broker all_examples) add_dependencies(protobuf_broker all_examples)
endif() endif()
if(CAF_ENABLE_QT5_EXAMPLES) if(CAF_ENABLE_QT6_EXAMPLES)
find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED) find_package(Qt6 COMPONENTS Core Gui Widgets REQUIRED)
qt5_wrap_ui(GROUP_CHAT_UI_HDR qtsupport/chatwindow.ui) qt6_wrap_ui(GROUP_CHAT_UI_HDR qtsupport/chatwindow.ui)
qt5_wrap_cpp(GROUP_CHAT_MOC_SRC qtsupport/chatwidget.hpp) qt6_wrap_cpp(GROUP_CHAT_MOC_SRC qtsupport/chatwidget.hpp)
# generated headers will be in cmake build directory # generated headers will be in cmake build directory
add_executable(qt_group_chat add_executable(qt_group_chat
qtsupport/qt_group_chat.cpp qtsupport/qt_group_chat.cpp
...@@ -94,17 +94,17 @@ if(TARGET CAF::io) ...@@ -94,17 +94,17 @@ if(TARGET CAF::io)
target_link_libraries(qt_group_chat target_link_libraries(qt_group_chat
CAF::io CAF::io
CAF::internal CAF::internal
Qt5::Core Qt6::Core
Qt5::Gui Qt6::Gui
Qt5::Widgets) Qt6::Widgets)
target_include_directories(qt_group_chat PRIVATE target_include_directories(qt_group_chat PRIVATE
qtsupport qtsupport
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
${Qt5Core_INCLUDE_DIRS} ${Qt6Core_INCLUDE_DIRS}
${Qt5Gui_INCLUDE_DIRS} ${Qt6Gui_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}) ${Qt6Widgets_INCLUDE_DIRS})
if (CMAKE_VERSION VERSION_LESS 3.8) if (CMAKE_VERSION VERSION_LESS 3.8)
message(STATUS "Note: build fails if Qt5 sets incompatible -std=ARG flag") message(STATUS "Note: build fails if Qt6 sets incompatible -std=ARG flag")
else() else()
set_property(TARGET qt_group_chat PROPERTY CXX_STANDARD 17) set_property(TARGET qt_group_chat PROPERTY CXX_STANDARD 17)
endif() endif()
......
...@@ -75,7 +75,7 @@ void ChatWidget::sendChatMessage() { ...@@ -75,7 +75,7 @@ void ChatWidget::sendChatMessage() {
// Ignore empty lines. // Ignore empty lines.
} else if (line.startsWith('/')) { } else if (line.startsWith('/')) {
vector<string> words; vector<string> words;
auto utf8 = line.midRef(1).toUtf8(); auto utf8 = QStringView{line}.mid(1).toUtf8();
auto sv = caf::string_view{utf8.constData(), auto sv = caf::string_view{utf8.constData(),
static_cast<size_t>(utf8.size())}; static_cast<size_t>(utf8.size())};
split(words, sv, is_any_of(" ")); split(words, sv, is_any_of(" "));
...@@ -126,7 +126,7 @@ void ChatWidget::joinGroup() { ...@@ -126,7 +126,7 @@ void ChatWidget::joinGroup() {
return; return;
} }
string mod = gname.left(pos).toUtf8().constData(); string mod = gname.left(pos).toUtf8().constData();
string gid = gname.midRef(pos+1).toUtf8().constData(); string gid = QStringView{gname}.mid(pos+1).toUtf8().constData();
auto x = system().groups().get(mod, gid); auto x = system().groups().get(mod, gid);
if (! x) if (! x)
QMessageBox::critical(this, "Error", to_string(x.error()).c_str()); QMessageBox::critical(this, "Error", to_string(x.error()).c_str());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment