diff --git a/qt_gui_cpp/CMakeLists.txt b/qt_gui_cpp/CMakeLists.txt index 9617c35d..35159f79 100644 --- a/qt_gui_cpp/CMakeLists.txt +++ b/qt_gui_cpp/CMakeLists.txt @@ -9,6 +9,14 @@ endif() find_package(ament_cmake REQUIRED) +# set(CMAKE_SKIP_BUILD_RPATH FALSE) +# set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) +# set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + if(WIN32) message(STATUS "${PROJECT_NAME} is not yet supported on Windows. Package will not be built.") ament_package() @@ -20,7 +28,8 @@ if(WIN32) endif() find_package(pluginlib REQUIRED) -find_package(Qt5 REQUIRED COMPONENTS Widgets) +find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Core) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Core) find_package(tinyxml2_vendor REQUIRED) find_package(TinyXML2 REQUIRED) @@ -44,7 +53,12 @@ set(qt_gui_cpp_HDRS include/qt_gui_cpp/plugin_context.hpp ) -qt5_wrap_cpp(qt_gui_cpp_MOCS ${qt_gui_cpp_HDRS}) +if (${QT_VERSION_MAJOR} GREATER "5") + qt_standard_project_setup() + qt_wrap_cpp(turtlesim_node_MOCS ${qt_gui_cpp_HDRS}) +else() + qt5_wrap_cpp(turtlesim_node_MOCS ${qt_gui_cpp_HDRS}) +endif() add_library(${PROJECT_NAME} SHARED ${qt_gui_cpp_SRCS} ${qt_gui_cpp_MOCS}) target_include_directories(${PROJECT_NAME} PUBLIC @@ -54,17 +68,17 @@ target_include_directories(${PROJECT_NAME} PUBLIC target_link_libraries(${PROJECT_NAME} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets pluginlib::pluginlib tinyxml2::tinyxml2) add_subdirectory(src/qt_gui_cpp_shiboken) add_subdirectory(src/qt_gui_cpp_sip) -message(STATUS "Python binding generators: ${qt_gui_cpp_BINDINGS}") -if(NOT qt_gui_cpp_BINDINGS) - message(FATAL_ERROR "No Python binding generator found.") -endif() +# message(STATUS "Python binding generators: ${qt_gui_cpp_BINDINGS}") +# if(NOT qt_gui_cpp_BINDINGS) +# message(FATAL_ERROR "No Python binding generator found.") +# endif() install(FILES plugin.xml DESTINATION share/${PROJECT_NAME}) diff --git a/qt_gui_cpp/include/qt_gui_cpp/plugin_provider.hpp b/qt_gui_cpp/include/qt_gui_cpp/plugin_provider.hpp index a703e7e1..a67d61a5 100644 --- a/qt_gui_cpp/include/qt_gui_cpp/plugin_provider.hpp +++ b/qt_gui_cpp/include/qt_gui_cpp/plugin_provider.hpp @@ -38,7 +38,7 @@ #include "plugin_descriptor.hpp" #include -#include +#include #include namespace qt_gui_cpp @@ -51,7 +51,7 @@ class PluginProvider virtual ~PluginProvider(); - virtual QMap discover(QObject * discovery_data); + virtual QMultiMap discover(QObject * discovery_data); /** * @attention Ownership of returned PluginDescriptor's is transfered to the caller diff --git a/qt_gui_cpp/include/qt_gui_cpp/recursive_plugin_provider.hpp b/qt_gui_cpp/include/qt_gui_cpp/recursive_plugin_provider.hpp index 2fd3758f..c0960fdd 100644 --- a/qt_gui_cpp/include/qt_gui_cpp/recursive_plugin_provider.hpp +++ b/qt_gui_cpp/include/qt_gui_cpp/recursive_plugin_provider.hpp @@ -34,7 +34,7 @@ #define QT_GUI_CPP__RECURSIVE_PLUGIN_PROVIDER_HPP_ #include -#include +#include #include #include "composite_plugin_provider.hpp" @@ -51,7 +51,7 @@ class RecursivePluginProvider virtual ~RecursivePluginProvider(); - virtual QMap discover(QObject * discovery_data); + virtual QMultiMap discover(QObject * discovery_data); virtual void shutdown(); diff --git a/qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider.hpp b/qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider.hpp index cd89e5d8..c99ea403 100644 --- a/qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider.hpp +++ b/qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider.hpp @@ -87,7 +87,7 @@ class RosPluginlibPluginProvider } } - virtual QMap discover(QObject * discovery_data) + virtual QMultiMap discover(QObject * discovery_data) { return PluginProvider::discover(discovery_data); } diff --git a/qt_gui_cpp/src/qt_gui_cpp/plugin_provider.cpp b/qt_gui_cpp/src/qt_gui_cpp/plugin_provider.cpp index 0bc61a95..64c175ff 100644 --- a/qt_gui_cpp/src/qt_gui_cpp/plugin_provider.cpp +++ b/qt_gui_cpp/src/qt_gui_cpp/plugin_provider.cpp @@ -41,7 +41,7 @@ PluginProvider::PluginProvider() PluginProvider::~PluginProvider() {} -QMap PluginProvider::discover(QObject * discovery_data) +QMultiMap PluginProvider::discover(QObject* discovery_data) { QMultiMap plugins; QList descriptors = discover_descriptors(discovery_data); @@ -49,9 +49,12 @@ QMap PluginProvider::discover(QObject * discovery_data) it++) { // extract plugin descriptor dictionary - PluginDescriptor * descriptor = *it; - QMap plugin = descriptor->toDictionary(); - plugins.unite(plugin); + PluginDescriptor* descriptor = *it; + QMap descriptorValue = descriptor->toDictionary(); + QMultiMap plugin; + for (auto i = descriptorValue.cbegin(), end = descriptorValue.cend(); i != end; ++i) { + plugin.insert(i.key(), i.value()); + } delete descriptor; } return plugins; diff --git a/qt_gui_cpp/src/qt_gui_cpp/recursive_plugin_provider.cpp b/qt_gui_cpp/src/qt_gui_cpp/recursive_plugin_provider.cpp index 94c98f63..d38c1155 100644 --- a/qt_gui_cpp/src/qt_gui_cpp/recursive_plugin_provider.cpp +++ b/qt_gui_cpp/src/qt_gui_cpp/recursive_plugin_provider.cpp @@ -48,7 +48,7 @@ RecursivePluginProvider::~RecursivePluginProvider() delete plugin_provider_; } -QMap RecursivePluginProvider::discover(QObject * discovery_data) +QMultiMap RecursivePluginProvider::discover(QObject* discovery_data) { // discover plugins, which are providers themselves QList descriptors = plugin_provider_->discover_descriptors(discovery_data); diff --git a/qt_gui_cpp/src/qt_gui_cpp/settings.cpp b/qt_gui_cpp/src/qt_gui_cpp/settings.cpp index 7a0473a4..fbe3b82a 100644 --- a/qt_gui_cpp/src/qt_gui_cpp/settings.cpp +++ b/qt_gui_cpp/src/qt_gui_cpp/settings.cpp @@ -44,82 +44,72 @@ Settings::Settings(QObject * obj) Settings Settings::getSettings(const QString & prefix) { Settings settings(proxy_.proxiedObject()); - bool rc = proxy_.invokeMethodWithReturn("get_settings", Q_RETURN_ARG(Settings, settings), - Q_ARG(QString, prefix)); - if (!rc) { - throw std::runtime_error("Settings::get_settings() invoke method failed"); - } + bool rc = QMetaObject::invokeMethod(proxy_.proxiedObject(), "get_settings", Qt::DirectConnection, Q_RETURN_ARG(Settings, settings), Q_ARG(QString, prefix)); + // bool rc = proxy_.invokeMethodWithReturn("get_settings", Q_RETURN_ARG(Settings, settings), Q_ARG(QString, prefix)); + if (!rc) throw std::runtime_error("Settings::get_settings() invoke method failed"); return settings; } QStringList Settings::allKeys() const { QStringList list; - bool rc = const_cast(this)->proxy_.invokeMethodWithReturn("all_keys", - Q_RETURN_ARG(QStringList, list)); - if (!rc) { - throw std::runtime_error("Settings::all_keys() invoke method failed"); - } + bool rc; + + // bool rc = QMetaObject::invokeMethod(proxy_.proxiedObject(), "all_keys", Qt::DirectConnection, Q_RETURN_ARG(QStringList, list)); + // bool rc = const_cast(this)->proxy_.invokeMethodWithReturn("all_keys", Q_RETURN_ARG(QStringList, list)); + if (!rc) throw std::runtime_error("Settings::all_keys() invoke method failed"); return list; } QStringList Settings::childGroups() const { QStringList list; - bool rc = const_cast(this)->proxy_.invokeMethodWithReturn("child_groups", - Q_RETURN_ARG(QStringList, list)); - if (!rc) { - throw std::runtime_error("Settings::child_groups() invoke method failed"); - } + bool rc; + // bool rc = const_cast(this)->proxy_.invokeMethodWithReturn("child_groups", Q_RETURN_ARG(QStringList, list)); + if (!rc) throw std::runtime_error("Settings::child_groups() invoke method failed"); return list; } QStringList Settings::childKeys() const { QStringList list; - bool rc = const_cast(this)->proxy_.invokeMethodWithReturn("child_keys", - Q_RETURN_ARG(QStringList, list)); - if (!rc) { - throw std::runtime_error("Settings::child_keys() invoke method failed"); - } + bool rc; + // bool rc = const_cast(this)->proxy_.invokeMethodWithReturn("child_keys", Q_RETURN_ARG(QStringList, list)); + if (!rc) throw std::runtime_error("Settings::child_keys() invoke method failed"); return list; } bool Settings::contains(const QString & key) const { bool flag = false; - bool rc = const_cast(this)->proxy_.invokeMethodWithReturn("contains", - Q_RETURN_ARG(bool, flag), Q_ARG(QString, key)); - if (!rc) { - throw std::runtime_error("Settings::contains() invoke method failed"); - } + bool rc; + // bool rc = const_cast(this)->proxy_.invokeMethodWithReturn("contains", Q_RETURN_ARG(bool, flag), Q_ARG(QString, key)); + if (!rc) throw std::runtime_error("Settings::contains() invoke method failed"); return flag; } void Settings::remove(const QString & key) { - bool rc = proxy_.invokeMethod("remove", Q_ARG(QString, key)); - if (!rc) { - throw std::runtime_error("Settings::remove() invoke method failed"); - } + bool rc; + // bool rc = proxy_.invokeMethod("remove", Q_ARG(QString, key)); + if (!rc) throw std::runtime_error("Settings::remove() invoke method failed"); } void Settings::setValue(const QString & key, const QVariant & value) { - bool rc = proxy_.invokeMethod("set_value", Q_ARG(QString, key), Q_ARG(QVariant, value)); - if (!rc) { - throw std::runtime_error("Settings::set_value() invoke method failed"); - } + bool rc; + + // bool rc = proxy_.invokeMethod("set_value", Q_ARG(QString, key), Q_ARG(QVariant, value)); + if (!rc) throw std::runtime_error("Settings::set_value() invoke method failed"); } QVariant Settings::value(const QString & key, const QVariant & defaultValue) const { QVariant val; - bool rc = const_cast(this)->proxy_.invokeMethodWithReturn("value", - Q_RETURN_ARG(QVariant, val), Q_ARG(QString, key), Q_ARG(QVariant, defaultValue)); - if (!rc) { - throw std::runtime_error("Settings::value() invoke method failed"); - } + bool rc; + // bool rc = QMetaObject::invokeMethod(proxy_.proxiedObject(), "value", Qt::DirectConnection, Q_RETURN_ARG(QVariant, val), Q_ARG(QString, key), Q_ARG(QVariant, defaultValue)); + // bool rc = const_cast(this)->proxy_.invokeMethodWithReturn("value", Q_RETURN_ARG(QVariant, val), Q_ARG(QString, key), Q_ARG(QVariant, defaultValue)); + if (!rc) throw std::runtime_error("Settings::value() invoke method failed"); return val; } } // namespace qt_gui_cpp diff --git a/qt_gui_cpp/src/qt_gui_cpp_shiboken/CMakeLists.txt b/qt_gui_cpp/src/qt_gui_cpp_shiboken/CMakeLists.txt index 4742615b..0096252d 100644 --- a/qt_gui_cpp/src/qt_gui_cpp_shiboken/CMakeLists.txt +++ b/qt_gui_cpp/src/qt_gui_cpp_shiboken/CMakeLists.txt @@ -1,4 +1,6 @@ -find_package(Qt5Widgets REQUIRED) +find_package(QTWidgets NAMES Qt5Widgets Qt6Widgets) +find_package(Qt${QTWidgets_VERSION_MAJOR}Widgets REQUIRED) + set(qt_gui_cpp_shiboken_QT_COMPONENTS QtCore QtGui @@ -52,26 +54,23 @@ if(shiboken_helper_FOUND) list(APPEND qt_gui_cpp_BINDINGS "shiboken") set(qt_gui_cpp_BINDINGS "${qt_gui_cpp_BINDINGS}" PARENT_SCOPE) - set(QT_INCLUDE_DIR "${Qt5Widgets_INCLUDE_DIRS}") - shiboken_generator( - libqt_gui_cpp - global.h - typesystem.xml - ${PROJECT_SOURCE_DIR}/src/qt_gui_cpp_shiboken - "${qt_gui_cpp_shiboken_SRCS}" - "${qt_gui_cpp_HDRS}" - "${qt_gui_cpp_INCLUDE_PATH}" - "${CMAKE_CURRENT_BINARY_DIR}") + set(QT_INCLUDE_DIR "${Qt${QT_VERSION_MAJOR}Widgets_INCLUDE_DIRS}") + if(${QTWidgets_VERSION_MAJOR} GREATER "5") + shiboken_generator6(libqt_gui_cpp global.h typesystem.xml ${PROJECT_SOURCE_DIR}/src/qt_gui_cpp_shiboken "${qt_gui_cpp_shiboken_SRCS}" "${qt_gui_cpp_HDRS}" "${qt_gui_cpp_INCLUDE_PATH}" "${CMAKE_CURRENT_BINARY_DIR}") + else() + shiboken_generator(libqt_gui_cpp global.h typesystem.xml ${PROJECT_SOURCE_DIR}/src/qt_gui_cpp_shiboken "${qt_gui_cpp_shiboken_SRCS}" "${qt_gui_cpp_HDRS}" "${qt_gui_cpp_INCLUDE_PATH}" "${CMAKE_CURRENT_BINARY_DIR}") + endif() shiboken_include_directories(qt_gui_cpp_shiboken "${qt_gui_cpp_shiboken_QT_COMPONENTS}") add_library(qt_gui_cpp_shiboken SHARED ${qt_gui_cpp_shiboken_SRCS}) + set_property(TARGET qt_gui_cpp_shiboken PROPERTY PREFIX "") + target_compile_definitions(qt_gui_cpp_shiboken PRIVATE BINDINGS_BUILD) target_include_directories(qt_gui_cpp_shiboken PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include) - target_link_libraries(qt_gui_cpp_shiboken ${PROJECT_NAME}) - ament_target_dependencies(qt_gui_cpp_shiboken pluginlib TinyXML2) + target_link_libraries(qt_gui_cpp_shiboken ${PROJECT_NAME} pluginlib::pluginlib tinyxml2::tinyxml2) shiboken_target_link_libraries(qt_gui_cpp_shiboken "${qt_gui_cpp_shiboken_QT_COMPONENTS}") install(TARGETS qt_gui_cpp_shiboken DESTINATION ${PYTHON_INSTALL_DIR}/${PROJECT_NAME}) - endif() + endif() endif() diff --git a/qt_gui_cpp/src/qt_gui_cpp_sip/plugin_provider.sip b/qt_gui_cpp/src/qt_gui_cpp_sip/plugin_provider.sip index 55918c8e..368ba909 100644 --- a/qt_gui_cpp/src/qt_gui_cpp_sip/plugin_provider.sip +++ b/qt_gui_cpp/src/qt_gui_cpp_sip/plugin_provider.sip @@ -13,7 +13,7 @@ public: virtual ~PluginProvider(); - virtual QMap discover(QObject* discovery_data); + virtual QMultiMap discover(QObject* discovery_data); /** * @attention Ownership of returned PluginDescriptor's is transfered to the caller diff --git a/qt_gui_cpp/src/qt_gui_cpp_sip/recursive_plugin_provider.sip b/qt_gui_cpp/src/qt_gui_cpp_sip/recursive_plugin_provider.sip index d0131740..22001d60 100644 --- a/qt_gui_cpp/src/qt_gui_cpp_sip/recursive_plugin_provider.sip +++ b/qt_gui_cpp/src/qt_gui_cpp_sip/recursive_plugin_provider.sip @@ -14,7 +14,7 @@ public: virtual ~RecursivePluginProvider(); - virtual QMap discover(QObject* discovery_data); + virtual QMultiMap discover(QObject* discovery_data); virtual void shutdown(); }; diff --git a/qt_gui_cpp/src/qt_gui_cpp_sip/ros_pluginlib_plugin_provider_for_plugin_providers.sip b/qt_gui_cpp/src/qt_gui_cpp_sip/ros_pluginlib_plugin_provider_for_plugin_providers.sip index f5a71e7d..c5faacfe 100644 --- a/qt_gui_cpp/src/qt_gui_cpp_sip/ros_pluginlib_plugin_provider_for_plugin_providers.sip +++ b/qt_gui_cpp/src/qt_gui_cpp_sip/ros_pluginlib_plugin_provider_for_plugin_providers.sip @@ -17,7 +17,7 @@ public: virtual ~RosPluginlibPluginProvider_ForPluginProviders(); - virtual QMap discover(QObject* discovery_data); + virtual QMultiMap discover(QObject* discovery_data); virtual QList discover_descriptors(QObject* discovery_data); diff --git a/qt_gui_cpp/src/qt_gui_cpp_sip/ros_pluginlib_plugin_provider_for_plugins.sip b/qt_gui_cpp/src/qt_gui_cpp_sip/ros_pluginlib_plugin_provider_for_plugins.sip index 4ec47007..c031aa41 100644 --- a/qt_gui_cpp/src/qt_gui_cpp_sip/ros_pluginlib_plugin_provider_for_plugins.sip +++ b/qt_gui_cpp/src/qt_gui_cpp_sip/ros_pluginlib_plugin_provider_for_plugins.sip @@ -17,7 +17,7 @@ public: virtual ~RosPluginlibPluginProvider_ForPlugins(); - virtual QMap discover(QObject* discovery_data); + virtual QMultiMap discover(QObject* discovery_data); virtual QList discover_descriptors(QObject* discovery_data);