diff --git a/CMakeLists.txt b/CMakeLists.txt index a20b96fbb..37613cc2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,8 +81,8 @@ set(GZ_TOOLS_VER 2) #-------------------------------------- # Find QT -set(QT_MAJOR_VERSION 5) -set(QT_MINOR_VERSION 15) +set(QT_MAJOR_VERSION 6) +set(QT_MINOR_VERSION 4) gz_find_package (Qt${QT_MAJOR_VERSION} VERSION ${QT_MAJOR_VERSION}.${QT_MINOR_VERSION} COMPONENTS @@ -94,7 +94,16 @@ gz_find_package (Qt${QT_MAJOR_VERSION} REQUIRED PKGCONFIG_VER_COMPARISON >= PKGCONFIG "Qt${QT_MAJOR_VERSION}Core Qt${QT_MAJOR_VERSION}Quick Qt${QT_MAJOR_VERSION}QuickControls2 Qt${QT_MAJOR_VERSION}Widgets") + add_compile_definitions(QT_DISABLE_DEPRECATED_UP_TO=0x050F00) +set(CMAKE_AUTOMOC TRUE) +set(CMAKE_AUTOUIC TRUE) +set(CMAKE_AUTORCC TRUE) +if(POLICY CMP0100) + cmake_policy(SET CMP0100 NEW) +endif() + +qt_standard_project_setup() set(GZ_GUI_PLUGIN_RELATIVE_INSTALL_DIR ${GZ_LIB_INSTALL_DIR}/gz-${GZ_DESIGNATION}-${PROJECT_VERSION_MAJOR}/plugins diff --git a/examples/config/scene3d.config b/examples/config/scene3d.config index 26719cb40..119d1a90e 100644 --- a/examples/config/scene3d.config +++ b/examples/config/scene3d.config @@ -72,46 +72,3 @@ false - - - Controls - false - false - 72 - 121 - 1 - - floating - - - - - - true - true - false - /world_control - /world_stats - - - - - Stats - false - false - 110 - 290 - 1 - - floating - - - - - - true - true - true - true - /world_stats - diff --git a/examples/plugin/custom_context_menu/CustomContext.qml b/examples/plugin/custom_context_menu/CustomContext.qml index bf0f0d15a..9bdcd9b8e 100644 --- a/examples/plugin/custom_context_menu/CustomContext.qml +++ b/examples/plugin/custom_context_menu/CustomContext.qml @@ -14,8 +14,8 @@ * limitations under the License. * */ -import QtQuick 2.0 -import QtQuick.Controls 2.0 +import QtQuick +import QtQuick.Controls Rectangle { id: customContext diff --git a/examples/plugin/dialog_from_plugin/DialogFromPlugin.qml b/examples/plugin/dialog_from_plugin/DialogFromPlugin.qml index f1bd575b9..5ca8aa72f 100644 --- a/examples/plugin/dialog_from_plugin/DialogFromPlugin.qml +++ b/examples/plugin/dialog_from_plugin/DialogFromPlugin.qml @@ -14,10 +14,10 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Dialogs 1.0 -import QtQuick.Window 2.2 +import QtQuick +import QtQuick.Controls +import QtQuick.Dialogs +import QtQuick.Window Rectangle { id: customPlugin diff --git a/examples/plugin/gz_components/GzComponents.qml b/examples/plugin/gz_components/GzComponents.qml index 7a7fd7997..73c22f5e1 100644 --- a/examples/plugin/gz_components/GzComponents.qml +++ b/examples/plugin/gz_components/GzComponents.qml @@ -14,9 +14,9 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.0 -import gz.gui 1.0 +import QtQuick +import QtQuick.Controls +import gz.gui Column { anchors.fill: parent diff --git a/examples/plugin/hello_plugin/HelloPlugin.qml b/examples/plugin/hello_plugin/HelloPlugin.qml index 4d4dafc7a..acaf6629d 100644 --- a/examples/plugin/hello_plugin/HelloPlugin.qml +++ b/examples/plugin/hello_plugin/HelloPlugin.qml @@ -14,8 +14,8 @@ * limitations under the License. * */ -import QtQuick 2.0 -import QtQuick.Controls 2.0 +import QtQuick +import QtQuick.Controls Rectangle { color: "transparent" anchors.fill: parent diff --git a/examples/plugin/multiple_qml/MultipleQml.qml b/examples/plugin/multiple_qml/MultipleQml.qml index 2063565c2..2d9892485 100644 --- a/examples/plugin/multiple_qml/MultipleQml.qml +++ b/examples/plugin/multiple_qml/MultipleQml.qml @@ -14,8 +14,8 @@ * limitations under the License. * */ -import QtQuick 2.0 -import QtQuick.Controls 2.0 +import QtQuick +import QtQuick.Controls import "qrc:/MultipleQml_qml" Column { diff --git a/examples/standalone/custom_drawer/CustomDrawer.qml b/examples/standalone/custom_drawer/CustomDrawer.qml index dcbf089a5..e6d2b05b0 100644 --- a/examples/standalone/custom_drawer/CustomDrawer.qml +++ b/examples/standalone/custom_drawer/CustomDrawer.qml @@ -14,9 +14,9 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.1 +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material /** * Custom drawer diff --git a/examples/standalone/start_dialog/start_dialog.qml b/examples/standalone/start_dialog/start_dialog.qml index a07f4ff52..645a0c5b4 100644 --- a/examples/standalone/start_dialog/start_dialog.qml +++ b/examples/standalone/start_dialog/start_dialog.qml @@ -14,8 +14,8 @@ * limitations under the License. * */ -import QtQuick 2.0 -import QtQuick.Controls 2.0 +import QtQuick +import QtQuick.Controls Rectangle { color: "green" anchors.fill: parent diff --git a/include/gz/gui/CMakeLists.txt b/include/gz/gui/CMakeLists.txt index 5e15317d6..e291ea1a5 100644 --- a/include/gz/gui/CMakeLists.txt +++ b/include/gz/gui/CMakeLists.txt @@ -1,9 +1,3 @@ -if(POLICY CMP0100) - cmake_policy(SET CMP0100 NEW) -endif() - -set (CMAKE_AUTOMOC ON) - set (qt_headers Application.hh Dialog.hh @@ -20,19 +14,101 @@ set (headers gz.hh qt.h SearchModel.hh - System.hh ) -set (resources resources.qrc) - -qt_wrap_cpp(headers_MOC ${qt_headers}) -qt_add_resources(resources_RCC ${resources}) +set(qml_files + qml/Chart.qml + qml/GzCard.qml + qml/GzCardSettings.qml + qml/GzColor.qml + qml/GzHelpers.qml + qml/GzPlotIcon.qml + qml/GzPose.qml + qml/GzRulers.qml + qml/GzSnackBar.qml + qml/GzSortFilterModel.qml + qml/GzSpinBox.qml + qml/GzSplit.qml + qml/GzVector3.qml + qml/Main.qml + qml/PlottingInterface.qml + qml/PluginMenu.qml + qml/SideDrawer.qml + qml/StandaloneDialog.qml + qml/StyleDialog.qml +) -gz_create_core_library(SOURCES - ${sources} - ${headers_MOC} - ${resources_RCC} +set(resources + qml/images/drawer.png + qml/images/export_icon.png + qml/images/gazebo_logo.png + qml/images/menu.png + qml/images/plottable_icon.svg + qml/images/search.svg ) + +if (QT_MAJOR_VERSION EQUAL 6) + qt_add_qml_module(${PROJECT_LIBRARY_TARGET_NAME} + URI gz.gui + VERSION 9.0.0 + SOURCES ${sources} ${qt_headers} ${headers} + QML_FILES ${qml_files} + RESOURCES ${resources} + ) + + include(GenerateExportHeader) + generate_export_header(${PROJECT_LIBRARY_TARGET_NAME} + BASE_NAME GZ_GUI + EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/include/gz/gui/detail/Export.hh + EXPORT_MACRO_NAME DETAIL_GZ_GUI_VISIBLE + NO_EXPORT_MACRO_NAME DETAIL_GZ_GUI_HIDDEN + DEPRECATED_MACRO_NAME GZ_DEPRECATED_ALL_VERSIONS) + + set(include_dir "gz/gui") + set(export_base "GZ_GUI") + configure_file( + "${GZ_CMAKE_DIR}/Export.hh.in" + "${PROJECT_BINARY_DIR}/include/gz/gui/Export.hh") + + install( + FILES "${PROJECT_BINARY_DIR}/include/gz/gui/Export.hh" + DESTINATION ${GZ_INCLUDE_INSTALL_DIR_FULL}/gz/gui/ + COMPONENT headers) + + install( + FILES "${PROJECT_BINARY_DIR}/include/gz/gui/detail/Export.hh" + DESTINATION ${GZ_INCLUDE_INSTALL_DIR_FULL}/gz/gui/detail/ + COMPONENT headers) + + target_include_directories(${PROJECT_LIBRARY_TARGET_NAME} + PUBLIC + $ + $ + ) + + install( + TARGETS ${PROJECT_LIBRARY_TARGET_NAME} + EXPORT ${PROJECT_LIBRARY_TARGET_NAME} + LIBRARY DESTINATION ${GZ_LIB_INSTALL_DIR} + ARCHIVE DESTINATION ${GZ_LIB_INSTALL_DIR} + RUNTIME DESTINATION ${GZ_BIN_INSTALL_DIR} + COMPONENT libraries) + + _gz_create_cmake_package() + _gz_create_pkgconfig() + +else() + set (resources resources.qrc) + qt_wrap_cpp(headers_MOC ${qt_headers}) + qt_add_resources(resources_RCC ${resources}) + + gz_create_core_library(SOURCES + ${sources} + ${headers_MOC} + ${resources_RCC} + ) +endif() + gz_add_get_install_prefix_impl(GET_INSTALL_PREFIX_FUNCTION gz::gui::getInstallPrefix GET_INSTALL_PREFIX_HEADER gz/gui/InstallationDirectories.hh OVERRIDE_INSTALL_PREFIX_ENV_VARIABLE GZ_GUI_INSTALL_PREFIX) diff --git a/include/gz/gui/Plugin.hh b/include/gz/gui/Plugin.hh index f4066ea8b..34c99ec31 100644 --- a/include/gz/gui/Plugin.hh +++ b/include/gz/gui/Plugin.hh @@ -49,7 +49,7 @@ namespace gz::gui Q_OBJECT /// \brief Constructor - public: Plugin(); + public: Plugin(QObject *_parent=nullptr); /// \brief Destructor public: virtual ~Plugin(); diff --git a/include/gz/gui/qml/Chart.qml b/include/gz/gui/qml/Chart.qml index cd3a259d7..a0506e9ff 100644 --- a/include/gz/gui/qml/Chart.qml +++ b/include/gz/gui/qml/Chart.qml @@ -14,12 +14,11 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtCharts 2.2 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Styles 1.4 -import QtQuick.Controls.Material 2.1 -import QtQuick.Layouts 1.3 +import QtQuick +import QtCharts +import QtQuick.Controls +import QtQuick.Controls.Style +import QtQuick.Layouts Rectangle { id: main diff --git a/include/gz/gui/qml/GzCard.qml b/include/gz/gui/qml/GzCard.qml index c6c4464e6..ef96527d1 100644 --- a/include/gz/gui/qml/GzCard.qml +++ b/include/gz/gui/qml/GzCard.qml @@ -14,16 +14,16 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 1.4 as QQC1 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.1 -import QtQuick.Layouts 1.3 -import QtQuick.Window 2.2 -import "qrc:/qml" +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Layouts +import QtQuick.Window +import "qrc:/gz/gui/qml" // TODO: don't use "parent" Pane { + clip: true /** * Minimum length of each dimension */ @@ -158,6 +158,8 @@ Pane { */ objectName: "plugin" + Math.floor(Math.random() * 100000); + anchors.fill: parent + // Stop scroll propagation to widgets below MouseArea { anchors.fill: parent @@ -174,9 +176,9 @@ Pane { return; // Bind anchors - anchors.fill = Qt.binding(function() {return parent}) - parent.height = Qt.binding(function() {return height}) - parent.width = Qt.binding(function() {return width}) + // anchors.fill = Qt.binding(function() {return parent}) + // parent.height = Qt.binding(function() {return height}) + // parent.width = Qt.binding(function() {return width}) // Keep a reference to the background // TODO(louise) This feels hacky, the card shouldn't care about the background, @@ -196,16 +198,16 @@ Pane { * any knowledge of splits */ function syncTheFamily() { - var parentSplit = helpers.ancestorByName(cardPane, /^split_item/); - - if (undefined == parentSplit) - return; - - if (content.children.length != 1) - return; - - parentSplit.Layout.minimumWidth = content.children[0].Layout.minimumWidth; - parentSplit.Layout.minimumHeight = content.children[0].Layout.minimumHeight; + // var parentSplit = helpers.ancestorByName(cardPane, /^split_item/); + // + // if (undefined == parentSplit) + // return; + // + // if (content.children.length != 1) + // return; + // + // parentSplit.Layout.minimumWidth = content.children[0].Layout.minimumWidth; + // parentSplit.Layout.minimumHeight = content.children[0].Layout.minimumHeight; } /** @@ -416,7 +418,7 @@ Pane { { const collapsed = cardPane.parent.Layout.minimumHeight === 50; // Reparent to main window's background - cardPane.parent = backgroundItem + cardPane.parent = backgroundItem.contentChildren[0] // Resize to minimum size cardPane.clearAnchors(); @@ -450,7 +452,7 @@ Pane { */ function recalculateSplitSizes() { - backgroundItem.recalculateMinimumSizes(); + // backgroundItem.recalculateMinimumSizes(); } // TODO(louise): re-enable window state support @@ -670,21 +672,31 @@ Pane { Rectangle { objectName: "content" id: content + // anchors.horizontalCenter: parent.horizontalCenter + anchors.fill: parent anchors.topMargin: cardPane.showTitleBar ? 50 : 0 + // height: 100 + // implicitHeight: 123 clip: true color: cardBackground onChildrenChanged: { // Set the height and width of the cardPane when child plugin is attached + // if (children.length > 0) { + // cardMinimumWidth = content.children[0].Layout.minimumWidth; + // cardMinimumHeight = content.children[0].Layout.minimumHeight; + // cardPane.width = cardMinimumWidth + // cardPane.height = cardMinimumHeight + // } + // + // cardPane.syncTheFamily() if (children.length > 0) { cardMinimumWidth = content.children[0].Layout.minimumWidth; cardMinimumHeight = content.children[0].Layout.minimumHeight; - cardPane.width = cardMinimumWidth - cardPane.height = cardMinimumHeight + cardPane.Layout.minimumWidth = cardMinimumWidth + cardPane.Layout.minimumHeight = cardMinimumHeight } - - cardPane.syncTheFamily() } /** diff --git a/include/gz/gui/qml/GzCardSettings.qml b/include/gz/gui/qml/GzCardSettings.qml index 0bf9423d9..cde4c4bbf 100644 --- a/include/gz/gui/qml/GzCardSettings.qml +++ b/include/gz/gui/qml/GzCardSettings.qml @@ -14,12 +14,12 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Layouts 1.3 -import QtQuick.Window 2.2 -import QtQuick.Dialogs 1.0 -import "qrc:/qml" +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import QtQuick.Window +import QtQuick.Dialogs +import "qrc:/gz/gui/qml" Dialog { id: settingsDialog @@ -208,7 +208,7 @@ Dialog { ColorDialog { id: colorDialog title: "Please choose a color" - showAlphaChannel : true + options: ColorDialog.ShowAlphaChannel onAccepted: { content.color = colorDialog.color bgColor.color = colorDialog.color diff --git a/include/gz/gui/qml/GzColor.qml b/include/gz/gui/qml/GzColor.qml index a04162d22..327ebd1eb 100644 --- a/include/gz/gui/qml/GzColor.qml +++ b/include/gz/gui/qml/GzColor.qml @@ -14,11 +14,10 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.1 -import QtQuick.Dialogs 1.0 -import QtQuick.Layouts 1.3 -import QtQuick.Controls.Material 2.1 +import QtQuick +import QtQuick.Controls +import QtQuick.Dialogs +import QtQuick.Layouts // RGBA using range 0 - 1.0 @@ -56,7 +55,9 @@ Item { id: gzColorDialog title: "Choose a color" visible: false - showAlphaChannel: true + options: { + ShowAlphaChannel: true + } onAccepted: { r = gzColorDialog.color.r g = gzColorDialog.color.g @@ -70,4 +71,3 @@ Item { } } } - diff --git a/include/gz/gui/qml/GzHelpers.qml b/include/gz/gui/qml/GzHelpers.qml index 9938872f8..991c44f44 100644 --- a/include/gz/gui/qml/GzHelpers.qml +++ b/include/gz/gui/qml/GzHelpers.qml @@ -14,9 +14,10 @@ * limitations under the License. * */ -import QtQuick 2.9 +import QtQuick Item { + visible: false /** * Helper function to get an item's ancestor by name. * @param _item Item whose parent we're looking for. @@ -56,4 +57,12 @@ Item { return 4 } + function dump(object, indent, depth) { + console.log(indent + object) + if (depth > 0) { + for (const i in object.children) + dump(object.children[i], indent + " ", depth - 1) + } + } + } diff --git a/include/gz/gui/qml/GzPlotIcon.qml b/include/gz/gui/qml/GzPlotIcon.qml index 3167d20ae..72d36b00a 100644 --- a/include/gz/gui/qml/GzPlotIcon.qml +++ b/include/gz/gui/qml/GzPlotIcon.qml @@ -14,7 +14,7 @@ * limitations under the License. * */ -import QtQuick 2.9 +import QtQuick /** * Item for a draggable plotting icon @@ -32,7 +32,7 @@ import QtQuick 2.9 * sourceComponent: gzploticon * } * Component.onCompleted: { - * plotLoader.item.gzMimeData = {"text/plain" : "Component," + entityFromCpp + "," + typeIdFromCpp + ",x," + typeNameFromCpp} + * plotLoader.item.gzMimeData = {"text/plain" : "Component," + entityFromCpp + "," + typeIdFromCpp + ",x," + typeNameFromCpp} * } * } * } diff --git a/include/gz/gui/qml/GzPose.qml b/include/gz/gui/qml/GzPose.qml index 63112fdec..5037258b0 100644 --- a/include/gz/gui/qml/GzPose.qml +++ b/include/gz/gui/qml/GzPose.qml @@ -14,11 +14,8 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.1 -import QtQuick.Layouts 1.3 -import QtQuick.Controls.Styles 1.4 +import QtQuick +import QtQuick.Layouts /** * Item displaying 3D pose information. diff --git a/include/gz/gui/qml/GzRulers.qml b/include/gz/gui/qml/GzRulers.qml index 1595389cd..2b129f0bb 100644 --- a/include/gz/gui/qml/GzRulers.qml +++ b/include/gz/gui/qml/GzRulers.qml @@ -14,8 +14,8 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 +import QtQuick +import QtQuick.Controls /** * Rulers which can be dragged to resize a target. diff --git a/include/gz/gui/qml/GzSnackBar.qml b/include/gz/gui/qml/GzSnackBar.qml index f4f2dc3c8..de5f75863 100644 --- a/include/gz/gui/qml/GzSnackBar.qml +++ b/include/gz/gui/qml/GzSnackBar.qml @@ -15,13 +15,14 @@ * */ -import QtGraphicalEffects 1.0 -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.2 -import QtQuick.Dialogs 1.0 -import QtQuick.Layouts 1.3 -import QtQuick.Window 2.2 +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Dialogs +import QtQuick.Layouts +import QtQuick.Window + +import Qt5Compat.GraphicalEffects as Effects /* To use the snackbar you need to call the methods in the MainWindow class: @@ -70,7 +71,7 @@ Popup { background: Rectangle { color: Material.background layer.enabled: true - layer.effect: DropShadow { + layer.effect: Effects.DropShadow { color: "#aa000000" samples: 9 spread: 0 diff --git a/include/gz/gui/qml/GzSortFilterModel.qml b/include/gz/gui/qml/GzSortFilterModel.qml index f127d27ab..e60f6f094 100644 --- a/include/gz/gui/qml/GzSortFilterModel.qml +++ b/include/gz/gui/qml/GzSortFilterModel.qml @@ -18,8 +18,8 @@ // Borrowed from // https://martin.rpdev.net/2019/01/15/using-delegatemodel-in-qml-for-sorting-and-filtering.html -import QtQuick 2.9 -import QtQml.Models 2.3 +import QtQuick +import QtQml.Models DelegateModel { /** @@ -83,4 +83,3 @@ DelegateModel { filterOnGroup: "visible" } - diff --git a/include/gz/gui/qml/GzSpinBox.qml b/include/gz/gui/qml/GzSpinBox.qml index 800db5e11..1ee4f6314 100644 --- a/include/gz/gui/qml/GzSpinBox.qml +++ b/include/gz/gui/qml/GzSpinBox.qml @@ -14,16 +14,72 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 1.4 -import QtQuick.Controls.Styles 1.4 +import QtQuick +import QtQuick.Controls + +Item { + id: root + property int decimals: 2 + property real value: 0.0 + property real from: 0.0 + property real to: 100.0 + property alias minimumValue: root.from + property alias maximumValue: root.to + property real stepSize: 1.0 + signal editingFinished(real _value) + implicitWidth: spinbox.implicitWidth + implicitHeight: spinbox.implicitHeight + // Timer { + // interval: 50; running: true; repeat: true + // onTriggered: { + // console.log("root. w: ", root.parent.objectName, spinbox.objectName, " = ", root.width, root.height, root.implicitWidth, root.implicitHeight) + // } + // } + + + function decimalToInt(decimal) { + return Math.round(decimal * spinbox.factor) + } + + readonly property int maxInt32: Math.pow( 2, 31 ) - 1; + clip: true + + SpinBox{ + id: spinbox + anchors.fill: parent + property real factor: Math.pow(10, root.decimals) + stepSize: decimalToInt(root.stepSize) + value: decimalToInt(root.value) + to : Math.min(decimalToInt(root.to), maxInt32) + from : Math.max(decimalToInt(root.from), -maxInt32) + editable: true + clip: true + topPadding: 0 + bottomPadding: 0 + + validator: DoubleValidator { + bottom: Math.min(spinbox.from, spinbox.to) + top: Math.max(spinbox.from, spinbox.to) + } + + textFromValue: function(value, locale) { + return Number(value / factor).toLocaleString(locale, 'f', root.decimals) + } + + valueFromText: function(text, locale) { + return decimalToInt(Number.fromLocaleString(locale, text)) + } + + onValueModified: { + root.value = spinbox.value / spinbox.factor + // console.log("val mod: ", root.value) + root.editingFinished(root.value) + } -SpinBox { - style: SpinBoxStyle{ background: Rectangle { - implicitWidth: 70 - implicitHeight: 40 - border.color: "gray" + implicitWidth: 80 + implicitHeight: 80 + border.color: "red" } } } diff --git a/include/gz/gui/qml/GzSplit.qml b/include/gz/gui/qml/GzSplit.qml index 87e521a71..a5fd00915 100644 --- a/include/gz/gui/qml/GzSplit.qml +++ b/include/gz/gui/qml/GzSplit.qml @@ -14,11 +14,10 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 1.1 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.1 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Layouts /** * Main split view, which provides functions to add and remove child items @@ -28,6 +27,7 @@ SplitView { id: background objectName: "background" + clip: true GzHelpers { id: helpers @@ -43,19 +43,11 @@ SplitView { */ property variant childSplits: new Object() - /** - * Callback when the height changed. - */ - onHeightChanged: - { - background.recalculateMinimumSizes(); - } - Rectangle { id: startLabel; - visible: MainWindow.pluginCount === 0 + visible: false; //MainWindow.pluginCount === 0 anchors.fill: parent - color: Material.background + color: "red" //Material.background Label { text: "Insert plugins to start!" anchors.fill: parent @@ -64,6 +56,7 @@ SplitView { verticalAlignment: Label.AlignVCenter wrapMode: Label.Wrap } + SplitView.fillWidth: true } /** @@ -89,35 +82,40 @@ SplitView { */ function addSplitItem() { - var itemName = ""; - + var addedItem = ""; // First section goes in the top level SplitView, which is Qt.Horizontal // 2 for helpers and startLabel - if (background.__items.length <= 2) + console.log("bg count:", background.count, background.contentChildren.length, Object.keys(childSplits).length) + if (background.contentChildren.length <= 2) { - itemName = _addNewItem(background); + console.log("Add to bg split") + addedItem = _addNewItem(background); } // The next one adds a Qt.Vertical split to the right else if (Object.keys(childSplits).length === 0) { + console.log("Creating side split") // Add the split var split = _addNewSplit(background); - split.split.orientation = Qt.Vertical; + console.log("Created ", split.objectName) + // Then add a new item to the newly created split - itemName = _addNewItem(split); + addedItem = _addNewItem(split); } // All subsequent ones are added to the vertical child split on the right else { + console.log("Adding side split") // Get desired split (for now we have only one) var firstChildSplit = childSplits[Object.keys(childSplits)[0]]; // Then add a new item to it - itemName = _addNewItem(firstChildSplit); + addedItem = _addNewItem(firstChildSplit); } - return itemName + helpers.dump(background, "", 5) + return addedItem } /** @@ -126,6 +124,7 @@ SplitView { */ function removeSplitItem(_name) { + console.log("Removing ", _name) // Remove from split _removeFromSplits(childItems[_name]); @@ -155,18 +154,15 @@ SplitView { if (_split === background) { _split.addItem(item); + item.SplitView.fillWidth = true; } else { - _split.split.addItem(item); - - // Make sure that changes to the item's minimum size get propagated to the - // split. - item.minimumSizeChanged.connect(function(){ - _split.split.recalculateMinimumSize() - }); + _split.addItem(item); } + console.log(itemName, item.objectName, "size: ", item.width, item.height) + // return childItems[itemName]; return itemName; } @@ -189,7 +185,7 @@ SplitView { childSplits[splitName] = splitWrapper; // Add to parent - _parentSplit.addItem(splitWrapper); + // _parentSplit.addItem(splitWrapper); return splitWrapper; } @@ -206,6 +202,7 @@ SplitView { return; var split = helpers.ancestorByName(_item, /^split_|^background$/); + console.log("Ancestor ", split.objectName) if (!split) { @@ -215,15 +212,21 @@ SplitView { if (split === background) { + console.log("Final remove ", _item.objectName, " from bg") split.removeItem(_item); + for (var i in split.contentChildren) + { + console.log(" ", split.contentChildren[i]) + } } else { - split.split.removeItem(_item); + split.removeItem(_item); // If split is now empty, remove split - if (split.split.__items.length === 0) - { + // if (split.contentChildren.length === 0) + // { + console.log("Removing side split from bg", split.objectName) // Remove from array delete childSplits[split.objectName] @@ -232,11 +235,12 @@ SplitView { // Destroy split.destroy(); - } - else - { - split.split.recalculateMinimumSize(); - } + helpers.dump(background, "", 5) + // } + // else + // { + // split.recalculateMinimumSize(); + // } } } @@ -246,48 +250,11 @@ SplitView { Component { id: newItem - Rectangle { - Layout.minimumWidth: 100 - Layout.minimumHeight: 100 - Layout.fillHeight: false - Layout.fillWidth: true - color: Material.background - - /** - * Notifies that its minimum size has changed. - */ - signal minimumSizeChanged(); - - /** - * Callback when the layout's minimum width changes. - */ - Layout.onMinimumWidthChanged: { - minimumSizeChanged(); - } - - /** - * Callback when the layout's minimum height changes. - */ - Layout.onMinimumHeightChanged: { - minimumSizeChanged(); - } - - /** - * Callback when the children array has been changed. - */ - onChildrenChanged: { - // Propagate child's minimum size changes to the item. - newItem.Layout.minimumWidth = Qt.binding(function() { - if (children.length === 0 || children[0] === undefined) - return 0; - return children[0].Layout.minimumWidth - }); - newItem.Layout.minimumHeight = Qt.binding(function() { - if (children.length === 0 || children[0] === undefined) - return 0; - return children[0].Layout.minimumHeight - }); - } + ColumnLayout { + id: rectContainer + SplitView.minimumWidth: children[0]? children[0].Layout.minimumWidth : 0 + SplitView.minimumHeight: children[0]? children[0].Layout.minimumHeight : 0 + clip: true } } @@ -296,90 +263,11 @@ SplitView { */ Component { id: newSplit - - /** - * For some reason, the scroll view doesn't work well within a split view, - * so we wrap it in a rectangle. - */ - Rectangle { - id: splitWrapper - color: "transparent" - - /** - * Expose the split view. - */ - property var split: split - - /** - * Offset of 17 to accommodate for ScrollView scroll bar - */ - property var scrollBarWidth: 17 - - Layout.minimumWidth: split.Layout.minimumWidth + scrollBarWidth - Layout.minimumHeight: split.Layout.minimumHeight - - ScrollView { - contentHeight: split.height - contentWidth: split.width + scrollBarWidth - - ScrollBar.vertical.policy: ScrollBar.AlwaysOn - - // TODO(louise) This only works for a very specific split - height: window.height - window.header.height - - SplitView { - id: split - width: splitWrapper.width - scrollBarWidth - height: Math.max(childItems[Object.keys(childItems)[0]].height, - split.Layout.minimumHeight) - - /** - * Iterate over all current child items and update the split's minimum - * width accordingly. - */ - function recalculateMinimumSize() - { - // TODO(louise): generalize to support horizontal splits - if (orientation === Qt.Horizontal) - { - return; - } - - // Sync minimum sizes - var heightSum = 0; - var minHeightSum = 0; - for (var i = 0; i < __items.length; i++) - { - var child = __items[i]; - - // Minimum width matches the largest minimum width among children - if (child.Layout.minimumWidth > Layout.minimumWidth) - { - Layout.minimumWidth = child.Layout.minimumWidth; - } - heightSum += child.height; - - var collapsed = child.Layout.maximumHeight == 50 - minHeightSum += collapsed ? child.height : child.Layout.minimumHeight - } - - // Minimum height to show all children - Layout.minimumHeight = minHeightSum; - split.height = Math.max(minHeightSum, background.height); - - // Squish all children if there's no slack - if (heightSum > background.height) - { - for (var i = 0; i < __items.length; i++) - { - var child = __items[i]; - child.height = child.Layout.minimumHeight; - } - } - } - } - } + SplitView { + id: __split + orientation: Qt.Vertical + clip: true + SplitView.minimumWidth: __split.contentChildren[0]? __split.contentChildren[0].SplitView.minimumWidth : 0 } } } - diff --git a/include/gz/gui/qml/GzVector3.qml b/include/gz/gui/qml/GzVector3.qml index 94752f4c5..e0c5b9e40 100644 --- a/include/gz/gui/qml/GzVector3.qml +++ b/include/gz/gui/qml/GzVector3.qml @@ -14,9 +14,8 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls.Material 2.1 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Layouts /** * Item displaying a 3D vector diff --git a/include/gz/gui/qml/Main.qml b/include/gz/gui/qml/Main.qml index c18154f29..651335971 100644 --- a/include/gz/gui/qml/Main.qml +++ b/include/gz/gui/qml/Main.qml @@ -14,13 +14,14 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.1 -import QtQuick.Dialogs 1.0 -import QtQuick.Layouts 1.3 -import ExitAction 1.0 -import "qrc:/qml" +import QtCore +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Dialogs +import QtQuick.Layouts +import ExitAction +import "qrc:/gz/gui/qml/" ApplicationWindow { @@ -85,7 +86,7 @@ ApplicationWindow } // Handler for window closing - onClosing: { + onClosing: (close) => { close.accepted = !showDialogOnExit if(showDialogOnExit){ if (closingFromDialog) { @@ -295,10 +296,9 @@ ApplicationWindow FileDialog { id: loadFileDialog title: "Load configuration" - folder: shortcuts.home + fileMode: FileDialog.OpenFile + currentFolder: StandardPaths.writableLocation(StandardPaths.HomeLocation) nameFilters: [ "Config files (*.config)" ] - selectMultiple: false - selectExisting: true onAccepted: { MainWindow.OnLoadConfig(fileUrl) } @@ -310,10 +310,9 @@ ApplicationWindow FileDialog { id: saveFileDialog title: "Save configuration" - folder: shortcuts.home + fileMode: FileDialog.SaveFile + currentFolder: StandardPaths.writableLocation(StandardPaths.HomeLocation) nameFilters: [ "Config files (*.config)" ] - selectMultiple: false - selectExisting: false onAccepted: { var selected = fileUrl.toString(); diff --git a/include/gz/gui/qml/PlottingInterface.qml b/include/gz/gui/qml/PlottingInterface.qml index 168d3a862..c3e834909 100644 --- a/include/gz/gui/qml/PlottingInterface.qml +++ b/include/gz/gui/qml/PlottingInterface.qml @@ -14,14 +14,13 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtCharts 2.2 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Styles 1.4 -import QtQuick.Controls.Material 2.1 -import QtQuick.Layouts 1.3 -import Qt.labs.platform 1.0 -import "qrc:/qml" +import QtQuick +import QtCharts +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Layouts +import Qt.labs.platform +import "qrc:/gz/gui/qml" Rectangle { diff --git a/include/gz/gui/qml/PluginMenu.qml b/include/gz/gui/qml/PluginMenu.qml index 890a7e7d4..7f393b3a0 100644 --- a/include/gz/gui/qml/PluginMenu.qml +++ b/include/gz/gui/qml/PluginMenu.qml @@ -14,11 +14,10 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.2 -import QtQuick.Controls.Material.impl 2.2 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Layouts Popup { id: pluginMenu @@ -87,7 +86,7 @@ Popup { } Keys.onUpPressed: { pluginMenuListView.decrementCurrentIndex(); - } + } } } } @@ -138,4 +137,3 @@ Popup { } } } - diff --git a/include/gz/gui/qml/SideDrawer.qml b/include/gz/gui/qml/SideDrawer.qml index 3b6c63c9f..66eb8653e 100644 --- a/include/gz/gui/qml/SideDrawer.qml +++ b/include/gz/gui/qml/SideDrawer.qml @@ -14,9 +14,9 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.1 +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material /** * Side menu diff --git a/include/gz/gui/qml/StandaloneDialog.qml b/include/gz/gui/qml/StandaloneDialog.qml index a55864499..a9cb0ed9f 100644 --- a/include/gz/gui/qml/StandaloneDialog.qml +++ b/include/gz/gui/qml/StandaloneDialog.qml @@ -14,8 +14,8 @@ * limitations under the License. * */ -import QtQuick 2.3 -import QtQuick.Controls 1.2 +import QtQuick +import QtQuick.Controls ApplicationWindow { id: dialog diff --git a/include/gz/gui/qml/StyleDialog.qml b/include/gz/gui/qml/StyleDialog.qml index f8566b0ca..2c2447a64 100644 --- a/include/gz/gui/qml/StyleDialog.qml +++ b/include/gz/gui/qml/StyleDialog.qml @@ -14,10 +14,11 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.1 -import QtQuick.Dialogs 1.0 +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Dialogs +import Qt.labs.platform as Platform /** * Style dialog @@ -309,28 +310,16 @@ Dialog { text: modelData width: parent.width } - onCurrentTextChanged: { - updateTheme(); - } } Label { text: "Primary" } - ColorDialog { + Platform.ColorDialog { id: materialPrimaryDialog title: "Primary color" // options: ColorDialog.NoButtons - onCurrentColorChanged: { - - // Avoiding pure black because for some reason it is set to that as the - // dialog opens - if (currentColor == "#000000") - return; - - updatePrimary(colorToHex(currentColor)) - } } Row { @@ -364,19 +353,10 @@ Dialog { text: "Accent" } - ColorDialog { + Platform.ColorDialog { id: materialAccentDialog title: "Accent color" // options: ColorDialog.NoButtons - onCurrentColorChanged: { - - // Avoiding pure black because for some reason it is set to that as the - // dialog opens - if (currentColor == "#000000") - return; - - updateAccent(colorToHex(currentColor)) - } } Row { diff --git a/src/Application.cc b/src/Application.cc index 5427a67c3..a767286e9 100644 --- a/src/Application.cc +++ b/src/Application.cc @@ -81,7 +81,7 @@ class Application::Implementation const QMessageLogContext &_context, const QString &_msg); }; -enum class GZ_COMMON_HIDDEN AvailableAPIs +enum class GZ_COMMON_HIDDEN AvailableAPIs { OpenGL, Vulkan, @@ -153,8 +153,6 @@ Application::Application(int &_argc, char **_argv, const WindowType _type, if (api == AvailableAPIs::Vulkan) { - gzdbg << "Qt using Vulkan graphics interface" << std::endl; - # ifdef GZ_USE_VULKAN_DEBUG_EXT qputenv("QT_VULKAN_INSTANCE_EXTENSIONS", "VK_EXT_debug_report;VK_EXT_debug_utils"); @@ -172,6 +170,7 @@ Application::Application(int &_argc, char **_argv, const WindowType _type, #else QQuickWindow::setSceneGraphBackend(QSGRendererInterface::VulkanRhi); #endif + gzdbg << "Qt using Vulkan graphics interface" << std::endl; } else { @@ -214,14 +213,14 @@ Application::Application(int &_argc, char **_argv, const WindowType _type, switch (api) { default: - case AvailableAPIs::OpenGL: - this->dataPtr->mainWin->setProperty("renderEngineBackendApiName", - "opengl"); - break; case AvailableAPIs::Vulkan: this->dataPtr->mainWin->setProperty("renderEngineBackendApiName", "vulkan"); break; + case AvailableAPIs::OpenGL: + this->dataPtr->mainWin->setProperty("renderEngineBackendApiName", + "opengl"); + break; case AvailableAPIs::Metal: this->dataPtr->mainWin->setProperty("renderEngineBackendApiName", "metal"); @@ -266,6 +265,9 @@ Application::~Application() } this->dataPtr->dialogs.clear(); + this->dataPtr->engine->clearComponentCache(); + this->dataPtr->engine->clearSingletons(); + delete this->dataPtr->engine; std::queue> empty; @@ -890,6 +892,8 @@ void Application::Implementation::MessageHandler(QtMsgType _type, const QMessageLogContext &_context, const QString &_msg) { std::string msg = "[QT] " + _msg.toStdString(); + if (_context.file) + msg += std::string("[") + _context.file + ":" + std::to_string(_context.line) + "]"; if (_context.function) msg += std::string("(") + _context.function + ")"; @@ -915,3 +919,5 @@ void Application::Implementation::MessageHandler(QtMsgType _type, } } } // namespace gz::gui + +#include "moc_Application.cpp" diff --git a/src/Application_TEST.cc b/src/Application_TEST.cc index f23ce8ab0..1344bf322 100644 --- a/src/Application_TEST.cc +++ b/src/Application_TEST.cc @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -35,15 +36,28 @@ char* g_argv[] = using namespace gz; using namespace gui; +class ApplicationTest: public ::testing::Test +{ + protected: + void SetUp() override + { + common::Console::SetVerbosity(4); + // No Qt app + ASSERT_EQ(nullptr, qGuiApp); + ASSERT_EQ(nullptr, App()); + } +}; + + // See https://github.com/gazebosim/gz-gui/issues/75 ////////////////////////////////////////////////// -TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Constructor)) +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Constructor)) { - common::Console::SetVerbosity(4); - // No Qt app - ASSERT_EQ(nullptr, qGuiApp); - ASSERT_EQ(nullptr, App()); + QDirIterator it(":", QDirIterator::Subdirectories); + while (it.hasNext()) { + std::cout << it.next().toStdString() << "\n"; + } // One app construct - destruct { @@ -63,23 +77,16 @@ TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Constructor)) } ////////////////////////////////////////////////// -TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadPlugin)) +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadPlugin)) { - gz::common::Console::SetVerbosity(4); - - // No Qt app - ASSERT_EQ(nullptr, qGuiApp); Application app(g_argc, g_argv); EXPECT_TRUE(app.LoadPlugin("Publisher")); } ////////////////////////////////////////////////// -TEST(ApplicationTest, +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadNonexistantPlugin)) { - gz::common::Console::SetVerbosity(4); - // No Qt app - ASSERT_EQ(nullptr, qGuiApp); Application app(g_argc, g_argv); EXPECT_FALSE(app.LoadPlugin("_doesnt_exist")); @@ -87,12 +94,10 @@ TEST(ApplicationTest, } ////////////////////////////////////////////////// -TEST(ApplicationTest, +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadProgrammaticPlugin)) { - gz::common::Console::SetVerbosity(4); // No Qt app - ASSERT_EQ(nullptr, qGuiApp); Application app(g_argc, g_argv); std::string pluginName; @@ -117,11 +122,8 @@ TEST(ApplicationTest, } ////////////////////////////////////////////////// -TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadEnvPlugin)) +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadEnvPlugin)) { - gz::common::Console::SetVerbosity(4); - // No Qt app - ASSERT_EQ(nullptr, qGuiApp); Application app(g_argc, g_argv); setenv("TEST_ENV_VAR", @@ -131,12 +133,9 @@ TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadEnvPlugin)) } ////////////////////////////////////////////////// -TEST(ApplicationTest, +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadBadInheritancePlugin)) { - gz::common::Console::SetVerbosity(4); - // No Qt app - ASSERT_EQ(nullptr, qGuiApp); Application app(g_argc, g_argv); app.AddPluginPath(std::string(PROJECT_BINARY_PATH) + "/lib"); @@ -144,12 +143,9 @@ TEST(ApplicationTest, } ////////////////////////////////////////////////// -TEST(ApplicationTest, +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadNotRegisteredPlugin)) { - gz::common::Console::SetVerbosity(4); - // No Qt app - ASSERT_EQ(nullptr, qGuiApp); Application app(g_argc, g_argv); app.AddPluginPath(std::string(PROJECT_BINARY_PATH) + "/lib"); @@ -157,12 +153,9 @@ TEST(ApplicationTest, } ////////////////////////////////////////////////// -TEST(ApplicationTest, +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadInvalidQmlPlugin)) { - gz::common::Console::SetVerbosity(4); - // No Qt app - ASSERT_EQ(nullptr, qGuiApp); Application app(g_argc, g_argv); app.AddPluginPath(std::string(PROJECT_BINARY_PATH) + "/lib"); @@ -170,12 +163,8 @@ TEST(ApplicationTest, } ////////////////////////////////////////////////// -TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadConfig)) +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadConfig)) { - common::Console::SetVerbosity(4); - - ASSERT_EQ(nullptr, qGuiApp); - // Empty string { Application app(g_argc, g_argv); @@ -220,12 +209,8 @@ TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadConfig)) } ////////////////////////////////////////////////// -TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadDefaultConfig)) +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadDefaultConfig)) { - common::Console::SetVerbosity(4); - - ASSERT_EQ(nullptr, qGuiApp); - // Test config file { Application app(g_argc, g_argv); @@ -245,83 +230,89 @@ TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadDefaultConfig)) } ////////////////////////////////////////////////// -TEST(ApplicationTest, - GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(InitializeMainWindow)) +TEST_F(ApplicationTest, + GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(InitializeMainWindowSimple)) { - common::Console::SetVerbosity(4); - - ASSERT_EQ(nullptr, qGuiApp); - // No plugins - { - Application app(g_argc, g_argv); + Application app(g_argc, g_argv); - auto wins = app.allWindows(); - ASSERT_EQ(wins.size(), 1); + auto wins = app.allWindows(); + ASSERT_EQ(wins.size(), 1); - // Close window after some time - QTimer::singleShot(300, wins[0], SLOT(close())); + // Close window after some time + QObject::connect(&app, &QGuiApplication::applicationStateChanged, + [&wins](auto /*state*/){ + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + wins[0]->close(); + }); - // Show window - app.exec(); - } + // Show window + gz::gui::Application::exec(); +} - // Load plugin - { - Application app(g_argc, g_argv); +////////////////////////////////////////////////// +TEST_F(ApplicationTest, + GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(InitializeMainWindowPlugin)) +{ + Application app(g_argc, g_argv); - EXPECT_TRUE(app.LoadPlugin("Publisher")); + EXPECT_TRUE(app.LoadPlugin("Publisher")); - auto win = App()->findChild(); - ASSERT_NE(nullptr, win); + auto *win = App()->findChild(); + ASSERT_NE(nullptr, win); - // Check plugin count - auto plugins = win->findChildren(); - EXPECT_EQ(1, plugins.count()); + // Check plugin count + auto plugins = win->findChildren(); + EXPECT_EQ(1, plugins.count()); - // Close window after some time - QTimer::singleShot(300, win->QuickWindow(), SLOT(close())); + QObject::connect(&app, &QGuiApplication::applicationStateChanged, + [&win](auto /*state*/){ + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + win->QuickWindow()->close(); + }); - // Show window - app.exec(); - } + // Show window + gz::gui::Application::exec(); +} +////////////////////////////////////////////////// +TEST_F(ApplicationTest, + GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(InitializeMainWindowConfig)) +{ // Test config auto testBuildPath = std::string(PROJECT_BINARY_PATH) + "/lib/"; auto testSourcePath = std::string(PROJECT_SOURCE_PATH) + "/test/"; // Load config - { - Application app(g_argc, g_argv); + Application app(g_argc, g_argv); - // Add test plugin to path (referenced in config) - app.AddPluginPath(testBuildPath); + // Add test plugin to path (referenced in config) + app.AddPluginPath(testBuildPath); - // Load test config file - EXPECT_TRUE(app.LoadConfig(testSourcePath + "config/test.config")); + // Load test config file + EXPECT_TRUE(app.LoadConfig(testSourcePath + "config/test.config")); - auto win = App()->findChild(); - ASSERT_NE(nullptr, win); + auto *win = App()->findChild(); + ASSERT_NE(nullptr, win); - // Check plugin count - auto plugins = win->findChildren(); - EXPECT_EQ(1, plugins.count()); + // Check plugin count + auto plugins = win->findChildren(); + EXPECT_EQ(1, plugins.count()); - // Close window after some time - QTimer::singleShot(300, win->QuickWindow(), SLOT(close())); + // Close window after some time + QObject::connect(&app, &QGuiApplication::applicationStateChanged, + [&win](auto /*state*/){ + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + win->QuickWindow()->close(); + }); - // Show window - app.exec(); - } + // Show window + gz::gui::Application::exec(); } ////////////////////////////////////////////////// -TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Dialog)) +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Dialog)) { - common::Console::SetVerbosity(4); - - ASSERT_EQ(nullptr, qGuiApp); - // Single dialog { Application app(g_argc, g_argv, WindowType::kDialog); @@ -336,21 +327,23 @@ TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Dialog)) // Close dialog after some time auto closed = false; - QTimer::singleShot(300, &app, [&] { - auto ds = app.allWindows(); - // The main dialog - some systems return more, not sure why - ASSERT_GE(ds.size(), 1); - - EXPECT_TRUE(qobject_cast(ds[0])); - - // Close - ds[0]->close(); - closed = true; + // Close window after some time + QObject::connect(&app, &QGuiApplication::applicationStateChanged, + [&closed](auto /*state*/){ + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + auto ds = gz::gui::Application::allWindows(); + + // The main diaog - some systems return more, not sure why + ASSERT_GE(ds.size(), 1); + EXPECT_TRUE(qobject_cast(ds[0])); + // Close + ds[0]->close(); + closed = true; }); - // Exec dialog - app.exec(); + // Show window + gz::gui::Application::exec(); // Make sure timer was triggered EXPECT_TRUE(closed); @@ -371,19 +364,21 @@ TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Dialog)) // Close dialogs after some time auto closed = false; - QTimer::singleShot(300, &app, [&] { - auto ds = app.allWindows(); + QObject::connect(&app, &QGuiApplication::applicationStateChanged, + [&closed](auto /*state*/){ + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + auto ds = gz::gui::Application::allWindows(); - // 2 dialog - some systems return more, not sure why - EXPECT_GE(ds.size(), 2); + // 2 dialog - some systems return more, not sure why + ASSERT_GE(ds.size(), 2); - for (auto dialog : ds) - dialog->close(); - closed = true; - }); + for (auto *dialog : ds) + dialog->close(); + closed = true; + }); // Exec dialog - app.exec(); + gz::gui::Application::exec(); // Make sure timer was triggered EXPECT_TRUE(closed); @@ -391,12 +386,8 @@ TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Dialog)) } ///////////////////////////////////////////////// -TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(messageHandler)) +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(messageHandler)) { - common::Console::SetVerbosity(4); - - ASSERT_EQ(nullptr, qGuiApp); - Application app(g_argc, g_argv); // \todo Verify output, see commmon::Console_TEST for example diff --git a/src/Dialog.cc b/src/Dialog.cc index 7701c2cfd..2da5a7665 100644 --- a/src/Dialog.cc +++ b/src/Dialog.cc @@ -22,6 +22,11 @@ #include "gz/gui/Application.hh" #include "gz/gui/Dialog.hh" +namespace +{ +constexpr const char* kQmlUri ="qrc:gz/gui/qml/StandaloneDialog.qml"; +} // namespace + namespace gz::gui { class Dialog::Implementation @@ -35,16 +40,15 @@ Dialog::Dialog() : dataPtr(gz::utils::MakeUniqueImpl()) { // Load QML and keep pointer to generated QQuickWindow - std::string qmlFile("qrc:qml/StandaloneDialog.qml"); - App()->Engine()->load(QUrl(QString::fromStdString(qmlFile))); + App()->Engine()->load(QUrl(QString(kQmlUri))); this->dataPtr->quickWindow = qobject_cast( App()->Engine()->rootObjects().value(0)); - if (!this->dataPtr->quickWindow) + if (this->dataPtr->quickWindow == nullptr) { // We'd only get here if the QML file is malformed // LCOV_EXCL_START - gzerr << "Internal error: Failed to instantiate QML file [" << qmlFile + gzerr << "Internal error: Failed to instantiate QML file [" << kQmlUri << "]" << std::endl; // LCOV_EXCL_STOP } @@ -62,8 +66,8 @@ QQuickWindow *Dialog::QuickWindow() const ///////////////////////////////////////////////// QQuickItem *Dialog::RootItem() const { - auto dialogItem = this->dataPtr->quickWindow->findChild(); - if (!dialogItem) + auto *dialogItem = this->dataPtr->quickWindow->findChild(); + if (dialogItem == nullptr) { // We'd only get here if the QML file is malformed // LCOV_EXCL_START @@ -96,7 +100,7 @@ bool Dialog::UpdateConfigAttribute(const std::string &_path, // Update attribute value for the correct dialog bool updated{false}; - for (auto dialogElem = doc.FirstChildElement("dialog"); + for (auto *dialogElem = doc.FirstChildElement("dialog"); dialogElem != nullptr; dialogElem = dialogElem->NextSiblingElement("dialog")) { @@ -110,7 +114,7 @@ bool Dialog::UpdateConfigAttribute(const std::string &_path, // Create new if missing if (!updated) { - auto dialogElem = doc.NewElement("dialog"); + auto *dialogElem = doc.NewElement("dialog"); dialogElem->SetAttribute("name", this->objectName().toStdString().c_str()); dialogElem->SetAttribute(_attribute.c_str(), _value); doc.InsertEndChild(dialogElem); @@ -169,3 +173,5 @@ std::string Dialog::ReadConfigAttribute(const std::string &_path, return std::string(); } } // namespace gz::gui + +#include "moc_Dialog.cpp" diff --git a/src/Helpers.cc b/src/Helpers.cc index d6164e7d6..42ca922f3 100644 --- a/src/Helpers.cc +++ b/src/Helpers.cc @@ -172,6 +172,8 @@ std::string uniqueFilePath(const std::string &_pathAndName, ///////////////////////////////////////////////// QStringList worldNames() { + auto app = gz::gui::App(); + auto win = App()->findChild(); if (nullptr == win) return {}; diff --git a/src/MainWindow.cc b/src/MainWindow.cc index bff0186a9..043de7c23 100644 --- a/src/MainWindow.cc +++ b/src/MainWindow.cc @@ -101,7 +101,7 @@ MainWindow::MainWindow() App()->Engine()->rootContext()->setContextProperty("MainWindow", this); // Load QML and keep pointer to generated QQuickWindow - std::string qmlFile("qrc:qml/Main.qml"); + std::string qmlFile("qrc:gz/gui/qml/Main.qml"); App()->Engine()->load(QUrl(QString::fromStdString(qmlFile))); this->dataPtr->quickWindow = qobject_cast( @@ -1023,3 +1023,5 @@ void MainWindow::SetServerControlService(const std::string &_service) this->dataPtr->controlService = _service; } } // namespace gz::gui + +#include "moc_MainWindow.cpp" diff --git a/src/PlottingInterface.cc b/src/PlottingInterface.cc index b44ffcb10..e99e97238 100644 --- a/src/PlottingInterface.cc +++ b/src/PlottingInterface.cc @@ -668,3 +668,5 @@ bool PlottingInterface::exportCSV(QString _path, int _chart, return true; } } // namespace gz::gui + +#include "moc_PlottingInterface.cpp" diff --git a/src/Plugin.cc b/src/Plugin.cc index c36f36dd3..0731aaa81 100644 --- a/src/Plugin.cc +++ b/src/Plugin.cc @@ -87,7 +87,9 @@ class Plugin::Implementation }; ///////////////////////////////////////////////// -Plugin::Plugin() : dataPtr(gz::utils::MakeUniqueImpl()) +Plugin::Plugin(QObject *_parent) : + QObject(_parent), + dataPtr(gz::utils::MakeUniqueImpl()) { } @@ -121,27 +123,22 @@ void Plugin::Load(const tinyxml2::XMLElement *_pluginElem) } // Qml file - std::string filename = _pluginElem->Attribute("filename"); - - // This let's .qml use functions and properties - this->dataPtr->context = new QQmlContext(App()->Engine()->rootContext()); - this->dataPtr->context->setContextProperty(QString::fromStdString(filename), - this); + auto filename = QString::fromStdString(_pluginElem->Attribute("filename")); // Instantiate plugin QML file into a component - std::string qmlFile(":/" + filename + "/" + filename + ".qml"); - if (!QFile(QString::fromStdString(qmlFile)).exists()) + auto qmlFile = ":/" + filename + "/" + filename + ".qml"; + if (!QFile(qmlFile).exists()) { - gzerr << "Can't find [" << qmlFile + gzerr << "Can't find [" << qmlFile.toStdString() << "]. Are you sure it was added to the .qrc file?" << std::endl; return; } - QQmlComponent component(App()->Engine(), QString::fromStdString(qmlFile)); + QQmlComponent component(App()->Engine(), qmlFile); if (component.isError()) { std::stringstream errors; - errors << "Failed to instantiate QML file [" << qmlFile << "]." + errors << "Failed to instantiate QML file [" << qmlFile.toStdString() << "]." << std::endl; // Qt considers range-based for loops over temporary objects // potentially dangerous, so explicitly create a container. @@ -155,18 +152,26 @@ void Plugin::Load(const tinyxml2::XMLElement *_pluginElem) } if (!component.isReady()) { - gzerr << "Component from QML file [" << qmlFile + gzerr << "Component from QML file [" << qmlFile.toStdString() << "] is not ready. Progress: " << component.progress() << " / 1.0" << std::endl; return; } + // This let's .qml use functions and properties + this->dataPtr->context = new QQmlContext(App()->Engine()->rootContext()); + this->dataPtr->context->setContextProperty(filename, this); + this->dataPtr->context->setContextProperty("module", this); + // Create an item for the plugin - this->dataPtr->pluginItem = - qobject_cast(component.create(this->dataPtr->context)); + auto *plugin = component.beginCreate(this->dataPtr->context); + this->dataPtr->pluginItem = qobject_cast(plugin); + this->dataPtr->pluginItem->setParent(this); + component.completeCreate(); + if (!this->dataPtr->pluginItem) { - gzerr << "Failed to instantiate QML file [" << qmlFile << "]." << std::endl + gzerr << "Failed to instantiate QML file [" << qmlFile.toStdString() << "]." << std::endl << "Are you sure the file is valid QML? " << "You can check with the `qmlscene` tool" << std::endl; return; @@ -421,13 +426,14 @@ QQuickItem *Plugin::CardItem() const return this->dataPtr->cardItem; // Instantiate a card - std::string qmlFile(":qml/GzCard.qml"); + std::string qmlFile("qrc:gz/gui/qml/GzCard.qml"); QQmlComponent cardComp(App()->Engine(), QString::fromStdString(qmlFile)); auto *cardItem = qobject_cast(cardComp.create()); - if (!cardItem) + if (cardItem == nullptr) { gzerr << "Internal error: Failed to instantiate QML file [" << qmlFile << "]" << std::endl; + qWarning() << cardComp.errors(); return nullptr; } @@ -599,3 +605,5 @@ void Plugin::ApplyAnchors() this->CardItem()->setProperty("anchored", true); } } // namespace gz::gui + +#include "moc_Plugin.cpp" diff --git a/src/cmd/CMakeLists.txt b/src/cmd/CMakeLists.txt index 821cd4acf..abe327531 100644 --- a/src/cmd/CMakeLists.txt +++ b/src/cmd/CMakeLists.txt @@ -1,3 +1,10 @@ +add_executable(gui_main gui_main.cc) + +target_link_libraries(gui_main + ${PROJECT_LIBRARY_TARGET_NAME} + gz-utils${GZ_UTILS_VER}::cli +) + #=============================================================================== # Generate the ruby script for internal testing. # Note that the major version of the library is included in the name. diff --git a/src/cmd/gui_main.cc b/src/cmd/gui_main.cc new file mode 100644 index 000000000..ef1fa14fa --- /dev/null +++ b/src/cmd/gui_main.cc @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2023 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include +#include + +#include +#include + + +////////////////////////////////////////////////// +/// \brief Enumeration of available commands +enum class GuiCommand +{ + kNone, + kGuiStandalone, +}; + +////////////////////////////////////////////////// +struct GuiOptions +{ + GuiCommand command {GuiCommand::kNone}; +}; + +////////////////////////////////////////////////// +void startConsoleLog() +{ + std::string home; + gz::common::env(GZ_HOMEDIR, home); + + std::string logPathMod = gz::common::joinPaths(home, + ".gz", "gui", "log", + gz::common::timeToIso(GZ_SYSTEM_TIME())); + gzLogInit(logPathMod, "console.log"); + + gz::common::Console::SetVerbosity(4); +} + +////////////////////////////////////////////////// +void runGuiCommand(const GuiOptions &_opt) +{ + startConsoleLog(); + + int g_argc = 1; + char* g_argv[] = {"./gz"}; + gz::gui::Application app(g_argc, g_argv); + + auto *mainWindow = app.findChild(); + // Set the render engine GUI name + mainWindow->SetRenderEngine("ogre2"); + app.LoadPlugin("MinimalScene"); + + gz::gui::Application::exec(); +} + +////////////////////////////////////////////////// +void addGuiFlags(CLI::App &_app) +{ + auto opt = std::make_shared(); + _app.callback([opt](){runGuiCommand(*opt); }); +} + +int main(int argc, char** argv) +{ + CLI::App app{"Gazebo GUI"}; + addGuiFlags(app); + app.formatter(std::make_shared(&app)); + CLI11_PARSE(app, argc, argv); +} diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index f5bcf98f1..6b7f6e2c6 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -40,6 +40,7 @@ function(gz_gui_add_library library_name) ) endfunction() + ################################################# # gz_gui_add_plugin( # SOURCES @@ -60,7 +61,7 @@ endfunction() # # [PRIVATE_LINK_LIBS]: Specify a list of libraries to be privately linked. # -function(gz_gui_add_plugin plugin_name) +function(gz_gui_add_plugin_qt5 plugin_name) set(options) set(oneValueArgs) set(multiValueArgs @@ -70,19 +71,19 @@ function(gz_gui_add_plugin plugin_name) PUBLIC_LINK_LIBS PRIVATE_LINK_LIBS ) - cmake_parse_arguments(gz_gui_add_plugin "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments(gz_gui_add_plugin_qt5 "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) gz_gui_add_library(${plugin_name} - SOURCES ${gz_gui_add_plugin_SOURCES} - QT_HEADERS ${gz_gui_add_plugin_QT_HEADERS} - PUBLIC_LINK_LIBS ${gz_gui_add_plugin_PUBLIC_LINK_LIBS} - PRIVATE_LINK_LIBS ${gz_gui_add_plugin_PRIVATE_LINK_LIBS} gz-plugin${GZ_PLUGIN_VER}::register + SOURCES ${gz_gui_add_plugin_qt5_SOURCES} + QT_HEADERS ${gz_gui_add_plugin_qt5_QT_HEADERS} + PUBLIC_LINK_LIBS ${gz_gui_add_plugin_qt5_PUBLIC_LINK_LIBS} + PRIVATE_LINK_LIBS ${gz_gui_add_plugin_qt5_PRIVATE_LINK_LIBS} gz-plugin${GZ_PLUGIN_VER}::register ) - if(gz_gui_add_plugin_TEST_SOURCES) + if(gz_gui_add_plugin_qt5_TEST_SOURCES) gz_build_tests(TYPE UNIT SOURCES - ${gz_gui_add_plugin_TEST_SOURCES} + ${gz_gui_add_plugin_qt5_TEST_SOURCES} LIB_DEPS ${GZ-GUI_LIBRARIES} TINYXML2::TINYXML2 @@ -105,33 +106,121 @@ function(gz_gui_add_plugin plugin_name) # warning is not important since those members do not need to be interfaced # with. set_source_files_properties( - ${gz_gui_add_plugin_SOURCES} - ${gz_gui_add_plugin_TEST_SOURCES} + ${gz_gui_add_plugin_qt5_SOURCES} + ${gz_gui_add_plugin_qt5_TEST_SOURCES} COMPILE_FLAGS "/wd4251") endif() install (TARGETS ${plugin_name} DESTINATION ${GZ_GUI_PLUGIN_INSTALL_DIR}) endfunction() +function(gz_gui_add_plugin_qt6 plugin_name) + set(options) + set(oneValueArgs) + set(multiValueArgs + SOURCES + QML_SOURCES + QML_URI + QT_HEADERS + TEST_SOURCES + PUBLIC_LINK_LIBS + PRIVATE_LINK_LIBS + ) + cmake_parse_arguments(gz_gui_add_plugin_qt6 "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + qt_add_qml_module(${plugin_name} + URI ${gz_gui_add_plugin_QML_URI} + VERSION 1.0 + SOURCES ${gz_gui_add_plugin_qt6_SOURCES} ${qt_gui_add_plugin_qt6_QT_HEADERS} + QML_FILES ${gz_gui_add_plugin_qt6_QML_SOURCES} + ) + + target_link_libraries(${plugin_name} + PUBLIC + ${PROJECT_LIBRARY_TARGET_NAME} + ${gz_gui_add_plugin_qt6_PUBLIC_LINK_LIBS} + PRIVATE + ${gz_gui_add_plugin_qt6_PRIVATE_LINK_LIBS} + ) + install (TARGETS ${plugin_name} DESTINATION ${GZ_GUI_PLUGIN_INSTALL_DIR}) + + if (gz_gui_add_plugin_qt6_TEST_SOURCES) + gz_build_tests(TYPE UNIT + SOURCES + ${gz_gui_add_plugin_qt6_TEST_SOURCES} + LIB_DEPS + ${GZ-GUI_LIBRARIES} + TINYXML2::TINYXML2 + ${plugin_name} + INCLUDE_DIRS + # Used to make internal source file headers visible to the unit tests + ${CMAKE_CURRENT_SOURCE_DIR} + # Used to make test-directory headers visible to the unit tests + ${PROJECT_SOURCE_DIR} + # Used to make test_config.h visible to the unit tests + ${PROJECT_BINARY_DIR} + ENVIRONMENT + GZ_GUI_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}) + endif() +endfunction() + + +function(gz_gui_add_plugin plugin_name) + set(options) + set(oneValueArgs) + set(multiValueArgs + SOURCES + QML_SOURCES + QML_URI + QT_HEADERS + TEST_SOURCES + PUBLIC_LINK_LIBS + PRIVATE_LINK_LIBS + ) + cmake_parse_arguments(gz_gui_add_plugin "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if (QT_MAJOR_VERSION EQUAL 6) + gz_gui_add_plugin_qt6(${plugin_name} + SOURCES ${gz_gui_add_plugin_SOURCES} + QML_URI ${gz_gui_add_plugin_QML_URI} + QML_SOURCES ${gz_gui_add_plugin_QML_SOURCES} + QT_HEADERS ${gz_gui_add_plugin_QT_HEADERS} + TEST_SOURCES ${gz_gui_add_plugin_TEST_SOURCES} + PUBLIC_LINK_LIBS ${gz_gui_add_plugin_PUBLIC_LINK_LIBS} + PRIVATE_LINK_LIBS ${gz_gui_add_plugin_PRIVATE_LINK_LIBS} + ) + else() + gz_gui_add_plugin_qt5(${plugin_name} + SOURCES ${gz_gui_add_plugin_SOURCES} + QT_HEADERS ${gz_gui_add_plugin_QT_HEADERS} + TEST_SOURCES ${gz_gui_add_plugin_TEST_SOURCES} + PUBLIC_LINK_LIBS ${gz_gui_add_plugin_PUBLIC_LINK_LIBS} + PRIVATE_LINK_LIBS ${gz_gui_add_plugin_PRIVATE_LINK_LIBS} + ) + endif() +endfunction() + + # Plugins -add_subdirectory(camera_fps) -add_subdirectory(camera_tracking) -add_subdirectory(grid_config) -add_subdirectory(image_display) -add_subdirectory(interactive_view_control) -add_subdirectory(key_publisher) -add_subdirectory(plotting) -add_subdirectory(point_cloud) -add_subdirectory(publisher) -add_subdirectory(marker_manager) -add_subdirectory(minimal_scene) -add_subdirectory(navsat_map) -add_subdirectory(screenshot) -add_subdirectory(shutdown_button) -add_subdirectory(tape_measure) -add_subdirectory(teleop) -add_subdirectory(topic_echo) -add_subdirectory(topic_viewer) -add_subdirectory(transport_scene_manager) -add_subdirectory(world_control) -add_subdirectory(world_stats) + +add_subdirectory(CameraFps) +add_subdirectory(CameraTracking) +add_subdirectory(GridConfig) +add_subdirectory(ImageDisplay) +add_subdirectory(InteractiveViewControl) +add_subdirectory(KeyPublisher) +add_subdirectory(MarkerManager) +add_subdirectory(MinimalScene) +add_subdirectory(NavsatMap) +add_subdirectory(Plotting) +add_subdirectory(PointCloud) +add_subdirectory(Publisher) +add_subdirectory(Screenshot) +add_subdirectory(ShutdownButton) +add_subdirectory(TapeMeasure) +add_subdirectory(Teleop) +add_subdirectory(TopicEcho) +add_subdirectory(TopicViewer) +add_subdirectory(TransportSceneManager) +add_subdirectory(WorldControl) +add_subdirectory(WorldStats) diff --git a/src/plugins/camera_fps/CMakeLists.txt b/src/plugins/CameraFps/CMakeLists.txt similarity index 75% rename from src/plugins/camera_fps/CMakeLists.txt rename to src/plugins/CameraFps/CMakeLists.txt index e9f053158..2c2eea5f6 100644 --- a/src/plugins/camera_fps/CMakeLists.txt +++ b/src/plugins/CameraFps/CMakeLists.txt @@ -3,7 +3,10 @@ gz_gui_add_plugin(CameraFps CameraFps.cc QT_HEADERS CameraFps.hh + QML_SOURCES + CameraFps.qml + QML_URI + CameraFps PUBLIC_LINK_LIBS gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} ) - diff --git a/src/plugins/camera_fps/CameraFps.cc b/src/plugins/CameraFps/CameraFps.cc similarity index 100% rename from src/plugins/camera_fps/CameraFps.cc rename to src/plugins/CameraFps/CameraFps.cc diff --git a/src/plugins/camera_fps/CameraFps.hh b/src/plugins/CameraFps/CameraFps.hh similarity index 100% rename from src/plugins/camera_fps/CameraFps.hh rename to src/plugins/CameraFps/CameraFps.hh diff --git a/src/plugins/camera_fps/CameraFps.qml b/src/plugins/CameraFps/CameraFps.qml similarity index 93% rename from src/plugins/camera_fps/CameraFps.qml rename to src/plugins/CameraFps/CameraFps.qml index 87c42f9e6..c4aa0b7f4 100644 --- a/src/plugins/camera_fps/CameraFps.qml +++ b/src/plugins/CameraFps/CameraFps.qml @@ -15,9 +15,9 @@ * */ -import QtQuick 2.9 -import QtQuick.Controls 2.1 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts Rectangle { id: cameraFps diff --git a/src/plugins/camera_tracking/CMakeLists.txt b/src/plugins/CameraTracking/CMakeLists.txt similarity index 77% rename from src/plugins/camera_tracking/CMakeLists.txt rename to src/plugins/CameraTracking/CMakeLists.txt index cf71123aa..19249ae7b 100644 --- a/src/plugins/camera_tracking/CMakeLists.txt +++ b/src/plugins/CameraTracking/CMakeLists.txt @@ -3,8 +3,10 @@ gz_gui_add_plugin(CameraTracking CameraTracking.cc QT_HEADERS CameraTracking.hh - TEST_SOURCES - # CameraTracking_TEST.cc + QML_SOURCES + CameraTracking.qml + QML_URI + CameraTracking PUBLIC_LINK_LIBS gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} gz-common${GZ_COMMON_VER}::profiler diff --git a/src/plugins/camera_tracking/CameraTracking.cc b/src/plugins/CameraTracking/CameraTracking.cc similarity index 100% rename from src/plugins/camera_tracking/CameraTracking.cc rename to src/plugins/CameraTracking/CameraTracking.cc diff --git a/src/plugins/camera_tracking/CameraTracking.hh b/src/plugins/CameraTracking/CameraTracking.hh similarity index 100% rename from src/plugins/camera_tracking/CameraTracking.hh rename to src/plugins/CameraTracking/CameraTracking.hh diff --git a/src/plugins/camera_tracking/CameraTracking.qml b/src/plugins/CameraTracking/CameraTracking.qml similarity index 93% rename from src/plugins/camera_tracking/CameraTracking.qml rename to src/plugins/CameraTracking/CameraTracking.qml index 09c339f0b..87315fa3f 100644 --- a/src/plugins/camera_tracking/CameraTracking.qml +++ b/src/plugins/CameraTracking/CameraTracking.qml @@ -15,9 +15,9 @@ * */ -import QtQuick 2.9 -import QtQuick.Controls 2.1 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts ColumnLayout { Layout.minimumWidth: 350 diff --git a/src/plugins/camera_tracking/CameraTracking.qrc b/src/plugins/CameraTracking/CameraTracking.qrc similarity index 100% rename from src/plugins/camera_tracking/CameraTracking.qrc rename to src/plugins/CameraTracking/CameraTracking.qrc diff --git a/src/plugins/GridConfig/CMakeLists.txt b/src/plugins/GridConfig/CMakeLists.txt new file mode 100644 index 000000000..02144f0a5 --- /dev/null +++ b/src/plugins/GridConfig/CMakeLists.txt @@ -0,0 +1,12 @@ +gz_gui_add_plugin(GridConfig + SOURCES + GridConfig.cc + QT_HEADERS + GridConfig.hh + QML_SOURCES + GridConfig.qml + QML_URI + GridConfig + PUBLIC_LINK_LIBS + gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} +) diff --git a/src/plugins/grid_config/GridConfig.cc b/src/plugins/GridConfig/GridConfig.cc similarity index 100% rename from src/plugins/grid_config/GridConfig.cc rename to src/plugins/GridConfig/GridConfig.cc diff --git a/src/plugins/grid_config/GridConfig.hh b/src/plugins/GridConfig/GridConfig.hh similarity index 100% rename from src/plugins/grid_config/GridConfig.hh rename to src/plugins/GridConfig/GridConfig.hh diff --git a/src/plugins/grid_config/GridConfig.qml b/src/plugins/GridConfig/GridConfig.qml similarity index 96% rename from src/plugins/grid_config/GridConfig.qml rename to src/plugins/GridConfig/GridConfig.qml index 36e46b7d0..245f03daf 100644 --- a/src/plugins/grid_config/GridConfig.qml +++ b/src/plugins/GridConfig/GridConfig.qml @@ -14,12 +14,12 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.1 -import QtQuick.Controls.Material 2.1 -import QtQuick.Dialogs 1.0 -import QtQuick.Layouts 1.3 -import "qrc:/qml" +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Dialogs +import QtQuick.Layouts +import "qrc:/gz/gui/qml" GridLayout { columns: 4 @@ -154,7 +154,7 @@ GridLayout { Layout.fillWidth: true id: cellLength maximumValue: Number.MAX_VALUE - minimumValue: 0.0000001 + minimumValue: 0 value: 1.00 decimals: gzHelpers.getDecimals(cellLength.width) stepSize: 0.01 diff --git a/src/plugins/grid_config/GridConfig.qrc b/src/plugins/GridConfig/GridConfig.qrc similarity index 100% rename from src/plugins/grid_config/GridConfig.qrc rename to src/plugins/GridConfig/GridConfig.qrc diff --git a/src/plugins/image_display/CMakeLists.txt b/src/plugins/ImageDisplay/CMakeLists.txt similarity index 60% rename from src/plugins/image_display/CMakeLists.txt rename to src/plugins/ImageDisplay/CMakeLists.txt index 40794224a..2d8273cf0 100644 --- a/src/plugins/image_display/CMakeLists.txt +++ b/src/plugins/ImageDisplay/CMakeLists.txt @@ -3,8 +3,13 @@ gz_gui_add_plugin(ImageDisplay ImageDisplay.cc QT_HEADERS ImageDisplay.hh - PUBLIC_LINK_LIBS - gz-common${GZ_COMMON_VER}::graphics + QML_SOURCES + ImageDisplay.qml + QML_URI + ImageDisplay TEST_SOURCES ImageDisplay_TEST.cc + PUBLIC_LINK_LIBS + gz-common${GZ_COMMON_VER}::graphics ) + diff --git a/src/plugins/image_display/ImageDisplay.cc b/src/plugins/ImageDisplay/ImageDisplay.cc similarity index 100% rename from src/plugins/image_display/ImageDisplay.cc rename to src/plugins/ImageDisplay/ImageDisplay.cc diff --git a/src/plugins/image_display/ImageDisplay.hh b/src/plugins/ImageDisplay/ImageDisplay.hh similarity index 100% rename from src/plugins/image_display/ImageDisplay.hh rename to src/plugins/ImageDisplay/ImageDisplay.hh diff --git a/src/plugins/image_display/ImageDisplay.qml b/src/plugins/ImageDisplay/ImageDisplay.qml similarity index 95% rename from src/plugins/image_display/ImageDisplay.qml rename to src/plugins/ImageDisplay/ImageDisplay.qml index 48d1191a6..0e6f5e47b 100644 --- a/src/plugins/image_display/ImageDisplay.qml +++ b/src/plugins/ImageDisplay/ImageDisplay.qml @@ -14,10 +14,10 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.1 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Layouts Rectangle { id: "imageDisplay" diff --git a/src/plugins/image_display/ImageDisplay.qrc b/src/plugins/ImageDisplay/ImageDisplay.qrc similarity index 100% rename from src/plugins/image_display/ImageDisplay.qrc rename to src/plugins/ImageDisplay/ImageDisplay.qrc diff --git a/src/plugins/image_display/ImageDisplay_TEST.cc b/src/plugins/ImageDisplay/ImageDisplay_TEST.cc similarity index 100% rename from src/plugins/image_display/ImageDisplay_TEST.cc rename to src/plugins/ImageDisplay/ImageDisplay_TEST.cc diff --git a/src/plugins/interactive_view_control/CMakeLists.txt b/src/plugins/InteractiveViewControl/CMakeLists.txt similarity index 72% rename from src/plugins/interactive_view_control/CMakeLists.txt rename to src/plugins/InteractiveViewControl/CMakeLists.txt index 6796a58dd..54088e542 100644 --- a/src/plugins/interactive_view_control/CMakeLists.txt +++ b/src/plugins/InteractiveViewControl/CMakeLists.txt @@ -3,8 +3,10 @@ gz_gui_add_plugin(InteractiveViewControl InteractiveViewControl.cc QT_HEADERS InteractiveViewControl.hh - TEST_SOURCES - # ViewControl_TEST.cc + QML_SOURCES + InteractiveViewControl.qml + QML_URI + InteractiveViewControl PUBLIC_LINK_LIBS gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} ) diff --git a/src/plugins/interactive_view_control/InteractiveViewControl.cc b/src/plugins/InteractiveViewControl/InteractiveViewControl.cc similarity index 100% rename from src/plugins/interactive_view_control/InteractiveViewControl.cc rename to src/plugins/InteractiveViewControl/InteractiveViewControl.cc diff --git a/src/plugins/interactive_view_control/InteractiveViewControl.hh b/src/plugins/InteractiveViewControl/InteractiveViewControl.hh similarity index 100% rename from src/plugins/interactive_view_control/InteractiveViewControl.hh rename to src/plugins/InteractiveViewControl/InteractiveViewControl.hh diff --git a/src/plugins/interactive_view_control/InteractiveViewControl.qml b/src/plugins/InteractiveViewControl/InteractiveViewControl.qml similarity index 93% rename from src/plugins/interactive_view_control/InteractiveViewControl.qml rename to src/plugins/InteractiveViewControl/InteractiveViewControl.qml index c75206185..a2b9fe1f9 100644 --- a/src/plugins/interactive_view_control/InteractiveViewControl.qml +++ b/src/plugins/InteractiveViewControl/InteractiveViewControl.qml @@ -15,9 +15,9 @@ * */ -import QtQuick 2.9 -import QtQuick.Controls 2.1 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts ColumnLayout { Layout.minimumWidth: 350 diff --git a/src/plugins/interactive_view_control/InteractiveViewControl.qrc b/src/plugins/InteractiveViewControl/InteractiveViewControl.qrc similarity index 100% rename from src/plugins/interactive_view_control/InteractiveViewControl.qrc rename to src/plugins/InteractiveViewControl/InteractiveViewControl.qrc diff --git a/src/plugins/key_publisher/CMakeLists.txt b/src/plugins/KeyPublisher/CMakeLists.txt similarity index 68% rename from src/plugins/key_publisher/CMakeLists.txt rename to src/plugins/KeyPublisher/CMakeLists.txt index 1b2561530..3266dcee5 100644 --- a/src/plugins/key_publisher/CMakeLists.txt +++ b/src/plugins/KeyPublisher/CMakeLists.txt @@ -3,6 +3,10 @@ gz_gui_add_plugin(KeyPublisher KeyPublisher.cc QT_HEADERS KeyPublisher.hh + QML_SOURCES + KeyPublisher.qml + QML_URI + KeyPublisher TEST_SOURCES KeyPublisher_TEST.cc ) diff --git a/src/plugins/key_publisher/KeyPublisher.cc b/src/plugins/KeyPublisher/KeyPublisher.cc similarity index 100% rename from src/plugins/key_publisher/KeyPublisher.cc rename to src/plugins/KeyPublisher/KeyPublisher.cc diff --git a/src/plugins/key_publisher/KeyPublisher.hh b/src/plugins/KeyPublisher/KeyPublisher.hh similarity index 100% rename from src/plugins/key_publisher/KeyPublisher.hh rename to src/plugins/KeyPublisher/KeyPublisher.hh diff --git a/src/plugins/key_publisher/KeyPublisher.qml b/src/plugins/KeyPublisher/KeyPublisher.qml similarity index 93% rename from src/plugins/key_publisher/KeyPublisher.qml rename to src/plugins/KeyPublisher/KeyPublisher.qml index e08a9eedd..499ff4744 100644 --- a/src/plugins/key_publisher/KeyPublisher.qml +++ b/src/plugins/KeyPublisher/KeyPublisher.qml @@ -15,9 +15,9 @@ * */ -import QtQuick 2.9 -import QtQuick.Controls 2.1 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts GridLayout { columns: 1 diff --git a/src/plugins/key_publisher/KeyPublisher.qrc b/src/plugins/KeyPublisher/KeyPublisher.qrc similarity index 100% rename from src/plugins/key_publisher/KeyPublisher.qrc rename to src/plugins/KeyPublisher/KeyPublisher.qrc diff --git a/src/plugins/key_publisher/KeyPublisher_TEST.cc b/src/plugins/KeyPublisher/KeyPublisher_TEST.cc similarity index 100% rename from src/plugins/key_publisher/KeyPublisher_TEST.cc rename to src/plugins/KeyPublisher/KeyPublisher_TEST.cc diff --git a/src/plugins/marker_manager/CMakeLists.txt b/src/plugins/MarkerManager/CMakeLists.txt similarity index 74% rename from src/plugins/marker_manager/CMakeLists.txt rename to src/plugins/MarkerManager/CMakeLists.txt index 391868b65..4cfce1ec3 100644 --- a/src/plugins/marker_manager/CMakeLists.txt +++ b/src/plugins/MarkerManager/CMakeLists.txt @@ -3,6 +3,10 @@ gz_gui_add_plugin(MarkerManager MarkerManager.cc QT_HEADERS MarkerManager.hh + QML_SOURCES + MarkerManager.qml + QML_URI + MarkerManager PUBLIC_LINK_LIBS gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} ) diff --git a/src/plugins/marker_manager/MarkerManager.cc b/src/plugins/MarkerManager/MarkerManager.cc similarity index 100% rename from src/plugins/marker_manager/MarkerManager.cc rename to src/plugins/MarkerManager/MarkerManager.cc diff --git a/src/plugins/marker_manager/MarkerManager.hh b/src/plugins/MarkerManager/MarkerManager.hh similarity index 100% rename from src/plugins/marker_manager/MarkerManager.hh rename to src/plugins/MarkerManager/MarkerManager.hh diff --git a/src/plugins/marker_manager/MarkerManager.qml b/src/plugins/MarkerManager/MarkerManager.qml similarity index 94% rename from src/plugins/marker_manager/MarkerManager.qml rename to src/plugins/MarkerManager/MarkerManager.qml index a2cd4b0ca..45b2d2c67 100644 --- a/src/plugins/marker_manager/MarkerManager.qml +++ b/src/plugins/MarkerManager/MarkerManager.qml @@ -15,9 +15,9 @@ * */ -import QtQuick 2.9 -import QtQuick.Controls 2.1 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts ColumnLayout { Layout.minimumWidth: 350 diff --git a/src/plugins/marker_manager/MarkerManager.qrc b/src/plugins/MarkerManager/MarkerManager.qrc similarity index 100% rename from src/plugins/marker_manager/MarkerManager.qrc rename to src/plugins/MarkerManager/MarkerManager.qrc diff --git a/src/plugins/MinimalScene/CMakeLists.txt b/src/plugins/MinimalScene/CMakeLists.txt new file mode 100644 index 000000000..e0a767e38 --- /dev/null +++ b/src/plugins/MinimalScene/CMakeLists.txt @@ -0,0 +1,20 @@ +gz_gui_add_plugin(MinimalScene + SOURCES + MinimalScene.cc + MinimalSceneRhi.cc + MinimalSceneRhiOpenGL.cc + MinimalSceneRhiVulkan.cc + EngineToQtInterface.cc + QT_HEADERS + MinimalScene.hh + MinimalSceneRhi.hh + MinimalSceneRhiOpenGL.hh + MinimalSceneRhiVulkan.hh + EngineToQtInterface.hh + QML_SOURCES + MinimalScene.qml + QML_URI + MinimalScene + PUBLIC_LINK_LIBS + gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} +) diff --git a/src/plugins/minimal_scene/EngineToQtInterface.cc b/src/plugins/MinimalScene/EngineToQtInterface.cc similarity index 100% rename from src/plugins/minimal_scene/EngineToQtInterface.cc rename to src/plugins/MinimalScene/EngineToQtInterface.cc diff --git a/src/plugins/minimal_scene/EngineToQtInterface.hh b/src/plugins/MinimalScene/EngineToQtInterface.hh similarity index 100% rename from src/plugins/minimal_scene/EngineToQtInterface.hh rename to src/plugins/MinimalScene/EngineToQtInterface.hh diff --git a/src/plugins/minimal_scene/MinimalScene.cc b/src/plugins/MinimalScene/MinimalScene.cc similarity index 98% rename from src/plugins/minimal_scene/MinimalScene.cc rename to src/plugins/MinimalScene/MinimalScene.cc index 2405b56d2..fba7f0295 100644 --- a/src/plugins/minimal_scene/MinimalScene.cc +++ b/src/plugins/MinimalScene/MinimalScene.cc @@ -17,9 +17,10 @@ #include #include +#include #include "MinimalScene.hh" -#include "MinimalSceneRhi.hh" +#include "MinimalSceneConfig.hh" #include "MinimalSceneRhiMetal.hh" #include "MinimalSceneRhiOpenGL.hh" #include "MinimalSceneRhiVulkan.hh" @@ -38,8 +39,11 @@ #include #include #include -#include + + +#include #include +#include #include #include #include @@ -218,7 +222,9 @@ class gz::gui::plugins::RenderWindowItem::Implementation public: gz::rendering::GraphicsAPI graphicsAPI = #if GZ_GUI_HAVE_METAL rendering::GraphicsAPI::METAL; -#else +#elif GZ_GUI_HAVE_VULKAN + rendering::GraphicsAPI::VULKAN; +#elif MINIMAL_SCENE_HAVE_OPENGL rendering::GraphicsAPI::OPENGL; #endif // GZ_GUI_HAVE_METAL @@ -305,9 +311,9 @@ GzRenderer::GzRenderer() : dataPtr(utils::MakeUniqueImpl()) { const std::string backendApiName = gz::gui::renderEngineBackendApiName(); - if (backendApiName == "vulkan") + if (backendApiName == "opengl") { - this->SetGraphicsAPI(rendering::GraphicsAPI::VULKAN); + this->SetGraphicsAPI(rendering::GraphicsAPI::OPENGL); } else if (backendApiName == "metal") { @@ -315,7 +321,7 @@ GzRenderer::GzRenderer() } else { - this->SetGraphicsAPI(rendering::GraphicsAPI::OPENGL); + this->SetGraphicsAPI(rendering::GraphicsAPI::VULKAN); } } @@ -717,8 +723,9 @@ std::string GzRenderer::Initialize(RenderThreadRhi &_rhi) this->dataPtr->rhiParams["external_device"] = std::to_string(reinterpret_cast(&externalDevice)); } -#endif +#endif // MINIMAL_SCENE_HAVE_VULKAN + std::cout << "Loading engine: " << this->engineName << std::endl; engine = rendering::engine(this->engineName, this->dataPtr->rhiParams); } else @@ -803,16 +810,14 @@ void GzRenderer::SetGraphicsAPI(const rendering::GraphicsAPI &_graphicsAPI) this->dataPtr->rhiParams["useCurrentGLContext"] = "1"; this->dataPtr->rhi = std::make_unique(); } +#if GZ_GUI_HAVE_VULKAN else if (_graphicsAPI == rendering::GraphicsAPI::VULKAN) { gzdbg << "Creating gz-rendering interface for Vulkan" << std::endl; this->dataPtr->rhiParams["vulkan"] = "1"; -#if GZ_GUI_HAVE_VULKAN this->dataPtr->rhi = std::make_unique(); -#else - this->dataPtr->rhi = std::make_unique(); -#endif } +#endif // GZ_GUI_HAVE_VULKAN #if GZ_GUI_HAVE_METAL else if (_graphicsAPI == rendering::GraphicsAPI::METAL) { @@ -820,7 +825,7 @@ void GzRenderer::SetGraphicsAPI(const rendering::GraphicsAPI &_graphicsAPI) this->dataPtr->rhiParams["metal"] = "1"; this->dataPtr->rhi = std::make_unique(); } -#endif +#endif // GZ_GUI_HAVE_METAL } ///////////////////////////////////////////////// @@ -881,9 +886,9 @@ RenderThread::RenderThread() { // Set default graphics API to OpenGL const std::string backendApiName = gz::gui::renderEngineBackendApiName(); - if (backendApiName == "vulkan") + if (backendApiName == "opengl") { - this->SetGraphicsAPI(rendering::GraphicsAPI::VULKAN); + this->SetGraphicsAPI(rendering::GraphicsAPI::OPENGL); } else if (backendApiName == "metal") { @@ -891,7 +896,7 @@ RenderThread::RenderThread() } else { - this->SetGraphicsAPI(rendering::GraphicsAPI::OPENGL); + this->SetGraphicsAPI(rendering::GraphicsAPI::VULKAN); } RenderWindowItem::Implementation::threads << this; @@ -979,7 +984,6 @@ void RenderThread::SetGraphicsAPI(const rendering::GraphicsAPI &_graphicsAPI) gzdbg << "Creating render thread interface for OpenGL" << std::endl; this->rhi = std::make_unique(&this->gzRenderer); } - #if GZ_GUI_HAVE_VULKAN else if (_graphicsAPI == rendering::GraphicsAPI::VULKAN) { @@ -1095,6 +1099,7 @@ void TextureNode::PrepareNode() RenderWindowItem::RenderWindowItem(QQuickItem *_parent) : QQuickItem(_parent), dataPtr(utils::MakeUniqueImpl()) { + std::cout << "RenderWindowItem::RenderWindowItem" << std::endl; this->setAcceptedMouseButtons(Qt::AllButtons); this->setFlag(ItemHasContents); this->dataPtr->renderThread = new RenderThread(); @@ -1103,6 +1108,7 @@ RenderWindowItem::RenderWindowItem(QQuickItem *_parent) ///////////////////////////////////////////////// RenderWindowItem::~RenderWindowItem() { + std::cout << "RenderWindowItem::~RenderWindowItem" << std::endl; this->StopRendering(); } @@ -1345,7 +1351,7 @@ void RenderWindowItem::SetCameraViewController( ///////////////////////////////////////////////// MinimalScene::MinimalScene() - : Plugin(), dataPtr(utils::MakeUniqueImpl()) + : dataPtr(utils::MakeUniqueImpl()) { qmlRegisterType("RenderWindow", 1, 0, "RenderWindow"); } @@ -1368,6 +1374,8 @@ void MinimalScene::LoadConfig(const tinyxml2::XMLElement *_pluginElem) this->title = "3D Scene"; std::string cmdRenderEngine = gui::renderEngineName(); + std::cout << "MinimalScene::LoadConfig " << cmdRenderEngine << std::endl; + // Custom parameters if (_pluginElem) { diff --git a/src/plugins/minimal_scene/MinimalScene.hh b/src/plugins/MinimalScene/MinimalScene.hh similarity index 98% rename from src/plugins/minimal_scene/MinimalScene.hh rename to src/plugins/MinimalScene/MinimalScene.hh index e7edf343d..5002dc01d 100644 --- a/src/plugins/minimal_scene/MinimalScene.hh +++ b/src/plugins/MinimalScene/MinimalScene.hh @@ -206,7 +206,7 @@ namespace gz::gui::plugins private: void BroadcastKeyPress(); /// \brief Render engine to use - public: std::string engineName = "ogre"; + public: std::string engineName = "ogre2"; /// \brief Unique scene name public: std::string sceneName = "scene"; @@ -428,11 +428,11 @@ namespace gz::gui::plugins /// \internal /// \brief Pointer to private data. GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) - }; +}; - /// \brief Texture node for displaying the render texture from gz-renderer - class TextureNode : public QObject, public QSGSimpleTextureNode - { +/// \brief Texture node for displaying the render texture from gz-renderer +class TextureNode : public QObject, public QSGSimpleTextureNode +{ Q_OBJECT /// \brief Constructor @@ -481,7 +481,7 @@ namespace gz::gui::plugins /// \brief Pointer to render interface to handle OpenGL/Metal compatibility private: std::unique_ptr rhi; - }; +}; } // namespace gz::gui::plugins #endif // GZ_GUI_PLUGINS_MINIMALSCENE_HH_ diff --git a/src/plugins/minimal_scene/MinimalScene.qml b/src/plugins/MinimalScene/MinimalScene.qml similarity index 81% rename from src/plugins/minimal_scene/MinimalScene.qml rename to src/plugins/MinimalScene/MinimalScene.qml index 5969a31c6..1980fd17b 100644 --- a/src/plugins/minimal_scene/MinimalScene.qml +++ b/src/plugins/MinimalScene/MinimalScene.qml @@ -14,11 +14,12 @@ * limitations under the License. * */ -import QtGraphicalEffects 1.0 -import QtQuick 2.9 -import QtQuick.Controls 2.0 -import QtQuick.Layouts 1.3 -import RenderWindow 1.0 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import RenderWindow + +import Qt5Compat.GraphicalEffects Rectangle { Layout.minimumWidth: 200 @@ -38,7 +39,7 @@ Rectangle { anchors.fill: parent hoverEnabled: true acceptedButtons: Qt.NoButton - visible: MinimalScene.loadingError.length == 0 + visible: MinimalScene.loadingError? MinimalScene.loadingError.length === 0: false onEntered: { MinimalScene.OnFocusWindow() } @@ -51,7 +52,7 @@ Rectangle { id: renderWindow objectName: "rw" anchors.fill: parent - visible: MinimalScene.loadingError.length == 0 + // visible: MinimalScene.loadingError.length == 0 } /* @@ -83,8 +84,8 @@ Rectangle { Label { anchors.fill: parent anchors.margins: 10 - text: MinimalScene.loadingError - visible: (MinimalScene.loadingError.length > 0); + text: MinimalScene.loadingError? MinimalScene.loadingError: "" + visible: MinimalScene.loadingError? (MinimalScene.loadingError.length > 0): true; wrapMode: Text.WordWrap } } diff --git a/src/plugins/minimal_scene/MinimalScene.qrc b/src/plugins/MinimalScene/MinimalScene.qrc similarity index 100% rename from src/plugins/minimal_scene/MinimalScene.qrc rename to src/plugins/MinimalScene/MinimalScene.qrc diff --git a/src/plugins/MinimalScene/MinimalSceneConfig.hh b/src/plugins/MinimalScene/MinimalSceneConfig.hh new file mode 100644 index 000000000..f9fafe6fe --- /dev/null +++ b/src/plugins/MinimalScene/MinimalSceneConfig.hh @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2017 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#include +#include + +#define MINIMAL_SCENE_HAVE_OPENGL true + +#define MINIMAL_SCENE_HAVE_VULKAN \ + QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) + +#if defined(__APPLE__) +#define MINIMAL_SCENE_HAVE_METAL 1 +#else +#define MINIMAL_SCENE_HAVE_METAL 0 +#endif + +constexpr bool kMinimalSceneHaveOpenGl = MINIMAL_SCENE_HAVE_OPENGL; +constexpr bool kMinimalSceneHaveVulkan = MINIMAL_SCENE_HAVE_VULKAN; +constexpr bool kMinimalSceneHaveMETAL = MINIMAL_SCENE_HAVE_METAL; diff --git a/src/plugins/minimal_scene/MinimalSceneRhi.cc b/src/plugins/MinimalScene/MinimalSceneRhi.cc similarity index 100% rename from src/plugins/minimal_scene/MinimalSceneRhi.cc rename to src/plugins/MinimalScene/MinimalSceneRhi.cc diff --git a/src/plugins/minimal_scene/MinimalSceneRhi.hh b/src/plugins/MinimalScene/MinimalSceneRhi.hh similarity index 100% rename from src/plugins/minimal_scene/MinimalSceneRhi.hh rename to src/plugins/MinimalScene/MinimalSceneRhi.hh diff --git a/src/plugins/minimal_scene/MinimalSceneRhiMetal.hh b/src/plugins/MinimalScene/MinimalSceneRhiMetal.hh similarity index 100% rename from src/plugins/minimal_scene/MinimalSceneRhiMetal.hh rename to src/plugins/MinimalScene/MinimalSceneRhiMetal.hh diff --git a/src/plugins/minimal_scene/MinimalSceneRhiMetal.mm b/src/plugins/MinimalScene/MinimalSceneRhiMetal.mm similarity index 100% rename from src/plugins/minimal_scene/MinimalSceneRhiMetal.mm rename to src/plugins/MinimalScene/MinimalSceneRhiMetal.mm diff --git a/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc b/src/plugins/MinimalScene/MinimalSceneRhiOpenGL.cc similarity index 99% rename from src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc rename to src/plugins/MinimalScene/MinimalSceneRhiOpenGL.cc index 732259907..fcb7ead2c 100644 --- a/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc +++ b/src/plugins/MinimalScene/MinimalSceneRhiOpenGL.cc @@ -16,6 +16,7 @@ */ #include "MinimalSceneRhiOpenGL.hh" +#include #include "EngineToQtInterface.hh" #include "MinimalScene.hh" diff --git a/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.hh b/src/plugins/MinimalScene/MinimalSceneRhiOpenGL.hh similarity index 100% rename from src/plugins/minimal_scene/MinimalSceneRhiOpenGL.hh rename to src/plugins/MinimalScene/MinimalSceneRhiOpenGL.hh diff --git a/src/plugins/minimal_scene/MinimalSceneRhiVulkan.cc b/src/plugins/MinimalScene/MinimalSceneRhiVulkan.cc similarity index 98% rename from src/plugins/minimal_scene/MinimalSceneRhiVulkan.cc rename to src/plugins/MinimalScene/MinimalSceneRhiVulkan.cc index 6670eef33..48e8e018f 100644 --- a/src/plugins/minimal_scene/MinimalSceneRhiVulkan.cc +++ b/src/plugins/MinimalScene/MinimalSceneRhiVulkan.cc @@ -225,6 +225,7 @@ bool TextureNodeRhiVulkan::HasNewTexture() const void TextureNodeRhiVulkan::NewTexture( void* _texturePtr, const QSize &_size) { + std::cout << "NewTexture" << std::endl; this->dataPtr->mutex.lock(); this->dataPtr->textureId = reinterpret_cast(_texturePtr); this->dataPtr->size = _size; @@ -234,6 +235,7 @@ void TextureNodeRhiVulkan::NewTexture( ///////////////////////////////////////////////// void TextureNodeRhiVulkan::PrepareNode() { + std::cout << "PrepareNode" << std::endl; this->dataPtr->mutex.lock(); this->dataPtr->newTextureId = this->dataPtr->textureId; this->dataPtr->newSize = this->dataPtr->size; diff --git a/src/plugins/minimal_scene/MinimalSceneRhiVulkan.hh b/src/plugins/MinimalScene/MinimalSceneRhiVulkan.hh similarity index 100% rename from src/plugins/minimal_scene/MinimalSceneRhiVulkan.hh rename to src/plugins/MinimalScene/MinimalSceneRhiVulkan.hh diff --git a/src/plugins/navsat_map/CMakeLists.txt b/src/plugins/NavsatMap/CMakeLists.txt similarity index 60% rename from src/plugins/navsat_map/CMakeLists.txt rename to src/plugins/NavsatMap/CMakeLists.txt index 887601742..cd488b788 100644 --- a/src/plugins/navsat_map/CMakeLists.txt +++ b/src/plugins/NavsatMap/CMakeLists.txt @@ -3,5 +3,8 @@ gz_gui_add_plugin(NavSatMap NavSatMap.cc QT_HEADERS NavSatMap.hh + QML_SOURCES + NavSatMap.qml + QML_URI + NavSatMap ) - diff --git a/src/plugins/navsat_map/NavSatMap.cc b/src/plugins/NavsatMap/NavSatMap.cc similarity index 100% rename from src/plugins/navsat_map/NavSatMap.cc rename to src/plugins/NavsatMap/NavSatMap.cc diff --git a/src/plugins/navsat_map/NavSatMap.hh b/src/plugins/NavsatMap/NavSatMap.hh similarity index 100% rename from src/plugins/navsat_map/NavSatMap.hh rename to src/plugins/NavsatMap/NavSatMap.hh diff --git a/src/plugins/navsat_map/NavSatMap.qml b/src/plugins/NavsatMap/NavSatMap.qml similarity index 95% rename from src/plugins/navsat_map/NavSatMap.qml rename to src/plugins/NavsatMap/NavSatMap.qml index 3e7659b29..8720d678f 100644 --- a/src/plugins/navsat_map/NavSatMap.qml +++ b/src/plugins/NavsatMap/NavSatMap.qml @@ -14,12 +14,12 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Layouts 1.3 -import QtQuick.Controls.Material 2.1 -import QtLocation 5.6 -import QtPositioning 5.6 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import QtQuick.Controls.Material +import QtLocation +import QtPositioning Item { id: navSatMap diff --git a/src/plugins/navsat_map/NavSatMap.qrc b/src/plugins/NavsatMap/NavSatMap.qrc similarity index 100% rename from src/plugins/navsat_map/NavSatMap.qrc rename to src/plugins/NavsatMap/NavSatMap.qrc diff --git a/src/plugins/plotting/CMakeLists.txt b/src/plugins/Plotting/CMakeLists.txt similarity index 60% rename from src/plugins/plotting/CMakeLists.txt rename to src/plugins/Plotting/CMakeLists.txt index 91c66ee89..acb035389 100644 --- a/src/plugins/plotting/CMakeLists.txt +++ b/src/plugins/Plotting/CMakeLists.txt @@ -3,7 +3,8 @@ gz_gui_add_plugin(TransportPlotting TransportPlotting.cc QT_HEADERS TransportPlotting.hh - TEST_SOURCES - PUBLIC_LINK_LIBS - # ${} + QML_SOURCES + TransportPlotting.qml + QML_URI + TransportPlotting ) diff --git a/src/plugins/plotting/TransportPlotting.cc b/src/plugins/Plotting/TransportPlotting.cc similarity index 100% rename from src/plugins/plotting/TransportPlotting.cc rename to src/plugins/Plotting/TransportPlotting.cc diff --git a/src/plugins/plotting/TransportPlotting.hh b/src/plugins/Plotting/TransportPlotting.hh similarity index 100% rename from src/plugins/plotting/TransportPlotting.hh rename to src/plugins/Plotting/TransportPlotting.hh diff --git a/src/plugins/plotting/TransportPlotting.qml b/src/plugins/Plotting/TransportPlotting.qml similarity index 88% rename from src/plugins/plotting/TransportPlotting.qml rename to src/plugins/Plotting/TransportPlotting.qml index cfafbba10..8ae9ae0e6 100644 --- a/src/plugins/plotting/TransportPlotting.qml +++ b/src/plugins/Plotting/TransportPlotting.qml @@ -14,11 +14,11 @@ * limitations under the License. * */ -import QtQuick 2.0 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts -import "qrc:/qml" +import "qrc:/gz/gui/qml" PlottingInterface { Layout.minimumWidth: 600 diff --git a/src/plugins/plotting/TransportPlotting.qrc b/src/plugins/Plotting/TransportPlotting.qrc similarity index 100% rename from src/plugins/plotting/TransportPlotting.qrc rename to src/plugins/Plotting/TransportPlotting.qrc diff --git a/src/plugins/point_cloud/CMakeLists.txt b/src/plugins/PointCloud/CMakeLists.txt similarity index 78% rename from src/plugins/point_cloud/CMakeLists.txt rename to src/plugins/PointCloud/CMakeLists.txt index f37bd25ac..60c845ab3 100644 --- a/src/plugins/point_cloud/CMakeLists.txt +++ b/src/plugins/PointCloud/CMakeLists.txt @@ -3,8 +3,12 @@ gz_gui_add_plugin(PointCloud PointCloud.cc QT_HEADERS PointCloud.hh + QML_SOURCES + PointCloud.qml PUBLIC_LINK_LIBS gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} TEST_SOURCES PointCloud_TEST.cc + QML_URI + PointCloud ) diff --git a/src/plugins/point_cloud/PointCloud.cc b/src/plugins/PointCloud/PointCloud.cc similarity index 100% rename from src/plugins/point_cloud/PointCloud.cc rename to src/plugins/PointCloud/PointCloud.cc diff --git a/src/plugins/point_cloud/PointCloud.hh b/src/plugins/PointCloud/PointCloud.hh similarity index 100% rename from src/plugins/point_cloud/PointCloud.hh rename to src/plugins/PointCloud/PointCloud.hh diff --git a/src/plugins/point_cloud/PointCloud.qml b/src/plugins/PointCloud/PointCloud.qml similarity index 96% rename from src/plugins/point_cloud/PointCloud.qml rename to src/plugins/PointCloud/PointCloud.qml index 9aa248092..6b1024919 100644 --- a/src/plugins/point_cloud/PointCloud.qml +++ b/src/plugins/PointCloud/PointCloud.qml @@ -15,13 +15,13 @@ * */ -import QtQuick 2.9 -import QtQuick.Controls 2.1 -import QtQuick.Dialogs 1.0 -import QtQuick.Controls.Material 2.1 -import QtQuick.Layouts 1.3 -import gz.gui 1.0 -import "qrc:/qml" +import QtQuick +import QtQuick.Controls +import QtQuick.Dialogs +import QtQuick.Controls.Material +import QtQuick.Layouts +import gz.gui +import "qrc:/gz/gui/qml" ColumnLayout { spacing: 10 @@ -122,8 +122,9 @@ ColumnLayout { id: pointSizeSpin value: PointCloud.pointSize minimumValue: 1 - maximumValue: 1000 + maximumValue: 1 decimals: 0 + to: 1000 onEditingFinished: { PointCloud.SetPointSize(pointSizeSpin.value) } diff --git a/src/plugins/point_cloud/PointCloud.qrc b/src/plugins/PointCloud/PointCloud.qrc similarity index 100% rename from src/plugins/point_cloud/PointCloud.qrc rename to src/plugins/PointCloud/PointCloud.qrc diff --git a/src/plugins/point_cloud/PointCloud_TEST.cc b/src/plugins/PointCloud/PointCloud_TEST.cc similarity index 100% rename from src/plugins/point_cloud/PointCloud_TEST.cc rename to src/plugins/PointCloud/PointCloud_TEST.cc diff --git a/src/plugins/publisher/CMakeLists.txt b/src/plugins/Publisher/CMakeLists.txt similarity index 68% rename from src/plugins/publisher/CMakeLists.txt rename to src/plugins/Publisher/CMakeLists.txt index b1c9df011..f02673a5a 100644 --- a/src/plugins/publisher/CMakeLists.txt +++ b/src/plugins/Publisher/CMakeLists.txt @@ -3,7 +3,10 @@ gz_gui_add_plugin(Publisher Publisher.cc QT_HEADERS Publisher.hh + QML_SOURCES + Publisher.qml + QML_URI + Publisher TEST_SOURCES Publisher_TEST.cc ) - diff --git a/src/plugins/publisher/Publisher.cc b/src/plugins/Publisher/Publisher.cc similarity index 97% rename from src/plugins/publisher/Publisher.cc rename to src/plugins/Publisher/Publisher.cc index 25fec4f8d..2ca96ef7d 100644 --- a/src/plugins/publisher/Publisher.cc +++ b/src/plugins/Publisher/Publisher.cc @@ -51,8 +51,9 @@ class Publisher::Implementation }; ///////////////////////////////////////////////// -Publisher::Publisher() - : dataPtr(gz::utils::MakeUniqueImpl()) +Publisher::Publisher(QObject *_parent) + : gz::gui::Plugin(_parent), + dataPtr(gz::utils::MakeUniqueImpl()) { } @@ -199,3 +200,5 @@ void Publisher::SetFrequency(const double _frequency) // Register this plugin GZ_ADD_PLUGIN(gz::gui::plugins::Publisher, gz::gui::Plugin) + +#include "moc_Publisher.cpp" diff --git a/src/plugins/publisher/Publisher.hh b/src/plugins/Publisher/Publisher.hh similarity index 98% rename from src/plugins/publisher/Publisher.hh rename to src/plugins/Publisher/Publisher.hh index 081c030ad..864485066 100644 --- a/src/plugins/publisher/Publisher.hh +++ b/src/plugins/Publisher/Publisher.hh @@ -42,6 +42,7 @@ namespace gz::gui::plugins class Publisher_EXPORTS_API Publisher : public Plugin { Q_OBJECT + QML_ELEMENT /// \brief Message type Q_PROPERTY( @@ -76,7 +77,7 @@ namespace gz::gui::plugins ) /// \brief Constructor - public: Publisher(); + public: Publisher(QObject *_parent = nullptr); /// \brief Destructor public: virtual ~Publisher(); diff --git a/src/plugins/publisher/Publisher.qml b/src/plugins/Publisher/Publisher.qml similarity index 84% rename from src/plugins/publisher/Publisher.qml rename to src/plugins/Publisher/Publisher.qml index c31149e1a..a33b31c09 100644 --- a/src/plugins/publisher/Publisher.qml +++ b/src/plugins/Publisher/Publisher.qml @@ -14,9 +14,9 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts Rectangle { id: publisher @@ -38,7 +38,7 @@ Rectangle { TextField { id: msgTypeField - text: Publisher.msgType + text: module.msgType selectByMouse: true } @@ -48,7 +48,7 @@ Rectangle { TextField { id: topicField - text: Publisher.topic + text: module.topic selectByMouse: true } @@ -58,7 +58,7 @@ Rectangle { TextArea { id: msgDataField - text: Publisher.msgData + text: module.msgData selectByMouse: true } @@ -90,12 +90,12 @@ Rectangle { onToggled: { // Is there a way to 2-way bind properties, or is this needed? - Publisher.msgType = msgTypeField.text - Publisher.topic = topicField.text - Publisher.msgData = msgDataField.text - Publisher.frequency = frequencyField.value + module.msgType = msgTypeField.text + module.topic = topicField.text + module.msgData = msgDataField.text + module.frequency = frequencyField.value - Publisher.OnPublish(checked); + module.OnPublish(checked); } ToolTip.visible: hovered ToolTip.delay: tooltipDelay diff --git a/src/plugins/publisher/Publisher.qrc b/src/plugins/Publisher/Publisher.qrc similarity index 100% rename from src/plugins/publisher/Publisher.qrc rename to src/plugins/Publisher/Publisher.qrc diff --git a/src/plugins/publisher/Publisher_TEST.cc b/src/plugins/Publisher/Publisher_TEST.cc similarity index 100% rename from src/plugins/publisher/Publisher_TEST.cc rename to src/plugins/Publisher/Publisher_TEST.cc diff --git a/src/plugins/screenshot/CMakeLists.txt b/src/plugins/Screenshot/CMakeLists.txt similarity index 78% rename from src/plugins/screenshot/CMakeLists.txt rename to src/plugins/Screenshot/CMakeLists.txt index c63cc6956..9a64146f8 100644 --- a/src/plugins/screenshot/CMakeLists.txt +++ b/src/plugins/Screenshot/CMakeLists.txt @@ -3,8 +3,12 @@ gz_gui_add_plugin(Screenshot Screenshot.cc QT_HEADERS Screenshot.hh + QML_SOURCES + Screenshot.qml PUBLIC_LINK_LIBS gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} TEST_SOURCES Screenshot_TEST.cc + QML_URI + Screenshot ) diff --git a/src/plugins/screenshot/Screenshot.cc b/src/plugins/Screenshot/Screenshot.cc similarity index 100% rename from src/plugins/screenshot/Screenshot.cc rename to src/plugins/Screenshot/Screenshot.cc diff --git a/src/plugins/screenshot/Screenshot.hh b/src/plugins/Screenshot/Screenshot.hh similarity index 100% rename from src/plugins/screenshot/Screenshot.hh rename to src/plugins/Screenshot/Screenshot.hh diff --git a/src/plugins/screenshot/Screenshot.qml b/src/plugins/Screenshot/Screenshot.qml similarity index 81% rename from src/plugins/screenshot/Screenshot.qml rename to src/plugins/Screenshot/Screenshot.qml index 97c6347b6..f680c449a 100644 --- a/src/plugins/screenshot/Screenshot.qml +++ b/src/plugins/Screenshot/Screenshot.qml @@ -14,13 +14,12 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.1 -import QtQuick.Controls.Material 2.2 -import QtQuick.Controls.Material.impl 2.2 -import QtQuick.Layouts 1.3 -import QtQuick.Controls.Styles 1.4 -import QtQuick.Dialogs 1.0 +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Controls.Material.impl +import QtQuick.Layouts +import QtQuick.Dialogs ToolBar { Layout.minimumWidth: 200 @@ -65,18 +64,16 @@ ToolBar { sourceSize.height: 40 } onClicked: { - fileDialog.open() + folderDialog.open() } } - FileDialog { - id: fileDialog + FolderDialog { + id: folderDialog title: "Save screenshots" - folder: Screenshot.directory - selectExisting: false - selectFolder: true + currentFolder: Screenshot.directory onAccepted: { - Screenshot.SetDirectory(fileDialog.folder) + Screenshot.SetDirectory(folderDialog.folder) close() } } diff --git a/src/plugins/screenshot/Screenshot.qrc b/src/plugins/Screenshot/Screenshot.qrc similarity index 100% rename from src/plugins/screenshot/Screenshot.qrc rename to src/plugins/Screenshot/Screenshot.qrc diff --git a/src/plugins/screenshot/Screenshot_TEST.cc b/src/plugins/Screenshot/Screenshot_TEST.cc similarity index 100% rename from src/plugins/screenshot/Screenshot_TEST.cc rename to src/plugins/Screenshot/Screenshot_TEST.cc diff --git a/src/plugins/screenshot/folder.png b/src/plugins/Screenshot/folder.png similarity index 100% rename from src/plugins/screenshot/folder.png rename to src/plugins/Screenshot/folder.png diff --git a/src/plugins/screenshot/screenshot.png b/src/plugins/Screenshot/screenshot.png similarity index 100% rename from src/plugins/screenshot/screenshot.png rename to src/plugins/Screenshot/screenshot.png diff --git a/src/plugins/shutdown_button/CMakeLists.txt b/src/plugins/ShutdownButton/CMakeLists.txt similarity index 68% rename from src/plugins/shutdown_button/CMakeLists.txt rename to src/plugins/ShutdownButton/CMakeLists.txt index e4fc601c8..867ebda64 100644 --- a/src/plugins/shutdown_button/CMakeLists.txt +++ b/src/plugins/ShutdownButton/CMakeLists.txt @@ -3,7 +3,10 @@ gz_gui_add_plugin(ShutdownButton ShutdownButton.cc QT_HEADERS ShutdownButton.hh + QML_SOURCES + ShutdownButton.qml TEST_SOURCES ShutdownButton_TEST.cc + QML_URI + ShutdownButton ) - diff --git a/src/plugins/shutdown_button/ShutdownButton.cc b/src/plugins/ShutdownButton/ShutdownButton.cc similarity index 100% rename from src/plugins/shutdown_button/ShutdownButton.cc rename to src/plugins/ShutdownButton/ShutdownButton.cc diff --git a/src/plugins/shutdown_button/ShutdownButton.hh b/src/plugins/ShutdownButton/ShutdownButton.hh similarity index 100% rename from src/plugins/shutdown_button/ShutdownButton.hh rename to src/plugins/ShutdownButton/ShutdownButton.hh diff --git a/src/plugins/shutdown_button/ShutdownButton.qml b/src/plugins/ShutdownButton/ShutdownButton.qml similarity index 92% rename from src/plugins/shutdown_button/ShutdownButton.qml rename to src/plugins/ShutdownButton/ShutdownButton.qml index 8fbf5424c..e38800c34 100644 --- a/src/plugins/shutdown_button/ShutdownButton.qml +++ b/src/plugins/ShutdownButton/ShutdownButton.qml @@ -14,10 +14,10 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.1 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Layouts RowLayout { id: shutdownButton diff --git a/src/plugins/shutdown_button/ShutdownButton.qrc b/src/plugins/ShutdownButton/ShutdownButton.qrc similarity index 100% rename from src/plugins/shutdown_button/ShutdownButton.qrc rename to src/plugins/ShutdownButton/ShutdownButton.qrc diff --git a/src/plugins/shutdown_button/ShutdownButton_TEST.cc b/src/plugins/ShutdownButton/ShutdownButton_TEST.cc similarity index 100% rename from src/plugins/shutdown_button/ShutdownButton_TEST.cc rename to src/plugins/ShutdownButton/ShutdownButton_TEST.cc diff --git a/src/plugins/shutdown_button/test.config b/src/plugins/ShutdownButton/test.config similarity index 100% rename from src/plugins/shutdown_button/test.config rename to src/plugins/ShutdownButton/test.config diff --git a/src/plugins/tape_measure/CMakeLists.txt b/src/plugins/TapeMeasure/CMakeLists.txt similarity index 50% rename from src/plugins/tape_measure/CMakeLists.txt rename to src/plugins/TapeMeasure/CMakeLists.txt index 5988f7268..9cd077723 100644 --- a/src/plugins/tape_measure/CMakeLists.txt +++ b/src/plugins/TapeMeasure/CMakeLists.txt @@ -1,6 +1,12 @@ gz_gui_add_plugin(TapeMeasure - SOURCES TapeMeasure.cc - QT_HEADERS TapeMeasure.hh + SOURCES + TapeMeasure.cc + QT_HEADERS + TapeMeasure.hh + QML_SOURCES + TapeMeasure.qml PRIVATE_LINK_LIBS gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} + QML_URI + TapeMeasure ) diff --git a/src/plugins/tape_measure/TapeMeasure.cc b/src/plugins/TapeMeasure/TapeMeasure.cc similarity index 100% rename from src/plugins/tape_measure/TapeMeasure.cc rename to src/plugins/TapeMeasure/TapeMeasure.cc diff --git a/src/plugins/tape_measure/TapeMeasure.hh b/src/plugins/TapeMeasure/TapeMeasure.hh similarity index 100% rename from src/plugins/tape_measure/TapeMeasure.hh rename to src/plugins/TapeMeasure/TapeMeasure.hh diff --git a/src/plugins/tape_measure/TapeMeasure.qml b/src/plugins/TapeMeasure/TapeMeasure.qml similarity index 89% rename from src/plugins/tape_measure/TapeMeasure.qml rename to src/plugins/TapeMeasure/TapeMeasure.qml index 29362bcf0..f914cd21f 100644 --- a/src/plugins/tape_measure/TapeMeasure.qml +++ b/src/plugins/TapeMeasure/TapeMeasure.qml @@ -14,21 +14,20 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Window 2.2 -import QtQuick.Controls 2.1 -import QtQuick.Controls.Material 2.2 -import QtQuick.Controls.Material.impl 2.2 -import QtQuick.Layouts 1.3 -import QtQuick.Controls.Styles 1.4 -import "qrc:/qml" +import QtQuick +import QtQuick.Window +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Controls.Material.impl +import QtQuick.Layouts +import "qrc:/gz/gui/qml" ToolBar { id: tapeMeasure Layout.minimumWidth: 250 Layout.minimumHeight: 100 - property var distance: 0.0 + property real distance: 0.0 function updateDistance() { distance = TapeMeasure.Distance(); diff --git a/src/plugins/tape_measure/TapeMeasure.qrc b/src/plugins/TapeMeasure/TapeMeasure.qrc similarity index 100% rename from src/plugins/tape_measure/TapeMeasure.qrc rename to src/plugins/TapeMeasure/TapeMeasure.qrc diff --git a/src/plugins/tape_measure/tape_measure.png b/src/plugins/TapeMeasure/tape_measure.png similarity index 100% rename from src/plugins/tape_measure/tape_measure.png rename to src/plugins/TapeMeasure/tape_measure.png diff --git a/src/plugins/tape_measure/trashcan.png b/src/plugins/TapeMeasure/trashcan.png similarity index 100% rename from src/plugins/tape_measure/trashcan.png rename to src/plugins/TapeMeasure/trashcan.png diff --git a/src/plugins/teleop/CMakeLists.txt b/src/plugins/Teleop/CMakeLists.txt similarity index 69% rename from src/plugins/teleop/CMakeLists.txt rename to src/plugins/Teleop/CMakeLists.txt index 775fbbf99..2a71762b1 100644 --- a/src/plugins/teleop/CMakeLists.txt +++ b/src/plugins/Teleop/CMakeLists.txt @@ -3,6 +3,10 @@ gz_gui_add_plugin(Teleop Teleop.cc QT_HEADERS Teleop.hh + QML_SOURCES + Teleop.qml TEST_SOURCES Teleop_TEST.cc + QML_URI + Teleop ) diff --git a/src/plugins/teleop/Teleop.cc b/src/plugins/Teleop/Teleop.cc similarity index 100% rename from src/plugins/teleop/Teleop.cc rename to src/plugins/Teleop/Teleop.cc diff --git a/src/plugins/teleop/Teleop.hh b/src/plugins/Teleop/Teleop.hh similarity index 100% rename from src/plugins/teleop/Teleop.hh rename to src/plugins/Teleop/Teleop.hh diff --git a/src/plugins/teleop/Teleop.qml b/src/plugins/Teleop/Teleop.qml similarity index 98% rename from src/plugins/teleop/Teleop.qml rename to src/plugins/Teleop/Teleop.qml index 4a4fc06e8..db84829a9 100644 --- a/src/plugins/teleop/Teleop.qml +++ b/src/plugins/Teleop/Teleop.qml @@ -15,12 +15,12 @@ * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.1 -import QtQuick.Controls.Styles 1.4 -import QtQuick.Layouts 1.3 -import gz.gui 1.0 +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Layouts +import gz.gui +import "qrc:/gz/gui/qml" ColumnLayout { Layout.minimumWidth: 400 @@ -127,7 +127,7 @@ ColumnLayout { minimumValue: 0.0 decimals: 2 stepSize: 0.10 - onEditingFinished:{ + onEditingFinished: { Teleop.SetMaxForwardVel(value) } } @@ -166,7 +166,7 @@ ColumnLayout { decimals: 2 stepSize: 0.10 onEditingFinished:{ - Teleop.SetMaxYawVel(value) + Teleop.SetMaxYawVel(1.0) } } } diff --git a/src/plugins/teleop/Teleop.qrc b/src/plugins/Teleop/Teleop.qrc similarity index 100% rename from src/plugins/teleop/Teleop.qrc rename to src/plugins/Teleop/Teleop.qrc diff --git a/src/plugins/teleop/Teleop_TEST.cc b/src/plugins/Teleop/Teleop_TEST.cc similarity index 100% rename from src/plugins/teleop/Teleop_TEST.cc rename to src/plugins/Teleop/Teleop_TEST.cc diff --git a/src/plugins/topic_echo/CMakeLists.txt b/src/plugins/TopicEcho/CMakeLists.txt similarity index 68% rename from src/plugins/topic_echo/CMakeLists.txt rename to src/plugins/TopicEcho/CMakeLists.txt index 92a8151b2..f1327d52b 100644 --- a/src/plugins/topic_echo/CMakeLists.txt +++ b/src/plugins/TopicEcho/CMakeLists.txt @@ -3,6 +3,10 @@ gz_gui_add_plugin(TopicEcho TopicEcho.cc QT_HEADERS TopicEcho.hh + QML_SOURCES + TopicEcho.qml TEST_SOURCES TopicEcho_TEST.cc + QML_URI + TopicEcho ) diff --git a/src/plugins/topic_echo/TopicEcho.cc b/src/plugins/TopicEcho/TopicEcho.cc similarity index 100% rename from src/plugins/topic_echo/TopicEcho.cc rename to src/plugins/TopicEcho/TopicEcho.cc diff --git a/src/plugins/topic_echo/TopicEcho.hh b/src/plugins/TopicEcho/TopicEcho.hh similarity index 100% rename from src/plugins/topic_echo/TopicEcho.hh rename to src/plugins/TopicEcho/TopicEcho.hh diff --git a/src/plugins/topic_echo/TopicEcho.qml b/src/plugins/TopicEcho/TopicEcho.qml similarity index 97% rename from src/plugins/topic_echo/TopicEcho.qml rename to src/plugins/TopicEcho/TopicEcho.qml index ceef81322..8419bad0e 100644 --- a/src/plugins/topic_echo/TopicEcho.qml +++ b/src/plugins/TopicEcho/TopicEcho.qml @@ -14,9 +14,9 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts Rectangle { id: topicEcho diff --git a/src/plugins/topic_echo/TopicEcho.qrc b/src/plugins/TopicEcho/TopicEcho.qrc similarity index 100% rename from src/plugins/topic_echo/TopicEcho.qrc rename to src/plugins/TopicEcho/TopicEcho.qrc diff --git a/src/plugins/topic_echo/TopicEcho_TEST.cc b/src/plugins/TopicEcho/TopicEcho_TEST.cc similarity index 100% rename from src/plugins/topic_echo/TopicEcho_TEST.cc rename to src/plugins/TopicEcho/TopicEcho_TEST.cc diff --git a/src/plugins/topic_viewer/CMakeLists.txt b/src/plugins/TopicViewer/CMakeLists.txt similarity index 72% rename from src/plugins/topic_viewer/CMakeLists.txt rename to src/plugins/TopicViewer/CMakeLists.txt index bdb5e564a..fce4be279 100644 --- a/src/plugins/topic_viewer/CMakeLists.txt +++ b/src/plugins/TopicViewer/CMakeLists.txt @@ -3,8 +3,12 @@ gz_gui_add_plugin(TopicViewer TopicViewer.cc QT_HEADERS TopicViewer.hh + QML_SOURCES + TopicViewer.qml TEST_SOURCES TopicViewer_TEST.cc PUBLIC_LINK_LIBS # ${} + QML_URI + TopicViewer ) diff --git a/src/plugins/topic_viewer/TopicViewer.cc b/src/plugins/TopicViewer/TopicViewer.cc similarity index 100% rename from src/plugins/topic_viewer/TopicViewer.cc rename to src/plugins/TopicViewer/TopicViewer.cc diff --git a/src/plugins/topic_viewer/TopicViewer.hh b/src/plugins/TopicViewer/TopicViewer.hh similarity index 100% rename from src/plugins/topic_viewer/TopicViewer.hh rename to src/plugins/TopicViewer/TopicViewer.hh diff --git a/src/plugins/TopicViewer/TopicViewer.qml b/src/plugins/TopicViewer/TopicViewer.qml new file mode 100644 index 000000000..be1790047 --- /dev/null +++ b/src/plugins/TopicViewer/TopicViewer.qml @@ -0,0 +1,254 @@ +/* + * Copyright (C) 2020 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ +import QtQml.Models +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts + +TreeView { + objectName: "treeView" + id:tree + model: TopicsModel + + Layout.minimumHeight: 400 + Layout.minimumWidth: 300 + anchors.fill: parent + + property int itemHeight: 30; + + // =========== Colors =========== + property color oddColor: (Material.theme == Material.Light) ? + Material.color(Material.Grey, Material.Shade100): + Material.color(Material.Grey, Material.Shade800); + + property color evenColor: (Material.theme == Material.Light) ? + Material.color(Material.Grey, Material.Shade200): + Material.color(Material.Grey, Material.Shade900); + + property color highlightColor: Material.accentColor; + + + // verticalScrollBarPolicy: Qt.ScrollBarAsNeeded + // horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff + // headerVisible: false + // headerDelegate: Rectangle { + // visible: false + // } + // backgroundVisible: false; + // TableViewColumn + // { + // role: "name"; + // } + + // =========== Selection =========== + // selection: ItemSelectionModel { + // model: tree.model + // } + // selectionMode: SelectionMode.SingleSelection + // selectionModel: ItemSelectionModel {} + + // =========== Delegates ============ + // delegate: Rectangle + // { + // id: row + // color: (styleData.selected)? highlightColor : + // (styleData.row % 2 == 0) ? evenColor : oddColor + // height: itemHeight; + // } + + delegate: TreeViewDelegate {} + + // delegate: Item { + // id: item +// + // // for fixing the item position + // // item pos changes randomly when drag happens (with the copy drag) + // anchors.top: parent.top + // anchors.right: parent.right +// + // Drag.mimeData: { "text/plain" : (model === null) ? "" : model.topic + "," + model.path } + // + // Drag.dragType: Drag.Automatic + // Drag.supportedActions : Qt.CopyAction + // Drag.active: dragMouse.drag.active + // // a point to drag from + // Drag.hotSpot.x: 0 + // Drag.hotSpot.y: itemHeight + // + // // used by DropArea that accepts the dragged items + // function itemData () + // { + // return { + // "name": model.name, + // "type": model.type, + // "path": model.path, + // "topic": model.topic + // } + // } +// + // MouseArea { + // id: dragMouse + // anchors.fill: parent + // + // // only plottable items are dragable + // drag.target: (model === null) ? null : + // (model.plottable) ? parent : null + // + // // get a copy image of the dragged item + // onPressed: parent.grabToImage(function(result) { + // parent.Drag.imageSource = result.url + // }) + // + // onReleased: + // { + // // emit drop event to notify the DropArea (must manually) + // parent.Drag.drop(); + // } + // + // hoverEnabled: true + // propagateComposedEvents: true + // // make the cursor with a drag shape at the plottable items + // cursorShape: (model === null) ? Qt.ArrowCursor : (model.plottable) ? + // Qt.DragCopyCursor : Qt.ArrowCursor + // + // onClicked: { + // // change the selection of the tree by clearing the prev, select a new one + // tree.selection.select(styleData.index,ItemSelectionModel.ClearAndSelect) + // + // // set the selection index to the index of the clicked item (must set manually) + // tree.selection.setCurrentIndex(styleData.index,ItemSelectionModel.ClearAndSelect) + // + // // the currentIndex of the tree.selection is not the same + // // of the tree.currentIndex, so set the tree.currentIndex. + // // this is the way to access it as it is read-only + // tree.__currentRow = styleData.row + // + // // set the focus to the selected item to receive the keyboard events + // // this is useful to enable navigating with keyboard from the right position + // item.forceActiveFocus(); + // + // tree.expandCollapseMsg(tree.currentIndex); + // } + // } + // + // Image { + // id: icon + // source: "images/plottable_icon.svg" + // height: itemHeight * 0.6 + // width: itemHeight * 0.6 + // y : itemHeight * 0.2 + // visible: (model === null) ? false : model.plottable + // } + // + // Text { + // id : field + // text: (model === null) ? "" : model.name + // color: (Material.theme == Material.Light || styleData.selected) ? + // Material.color(Material.Grey, Material.Shade800): + // Material.color(Material.Grey, Material.Shade400); + // + // font.pointSize: 12 + // anchors.leftMargin: 5 + // anchors.left: icon.right + // anchors.right: parent.right + // elide: Text.ElideMiddle + // y: icon.y + // } + // + // ToolTip { + // id: tool_tip + // delay: 200 + // timeout: 2000 + // text: (model === null) ? "Type ?" : "Type: " + model.type; + // visible: dragMouse.containsMouse + // y: -itemHeight + // x: dragMouse.mouseX + // enter: null + // exit: null + // } + // } + + property int y_pos: 0 + + // style: TreeViewStyle { + // branchDelegate: Rectangle { + // height: itemHeight + // width: itemHeight + // color: "transparent" + // Image { + // id: branchImage + // fillMode: Image.Pad + // anchors.right: parent.right + // anchors.verticalCenter: parent.verticalCenter + // sourceSize.height: itemHeight * 0.4 + // sourceSize.width: itemHeight * 0.4 + // source: styleData.isExpanded ? "minus.png" : "plus.png" + // } + // MouseArea { + // anchors.fill: parent + // hoverEnabled: true + // propagateComposedEvents: true + // onClicked: { + // mouse.accepted = true + // + // // set the current index & current selection and active focus for keyboard + // // the reason for that to make the branch selection just like the item selection + // // and to fix the animation as it ueses item selection's info + // tree.selection.select(styleData.index,ItemSelectionModel.ClearAndSelect) + // tree.selection.setCurrentIndex(styleData.index,ItemSelectionModel.ClearAndSelect) + // tree.__currentRow = styleData.row + // item.forceActiveFocus(); + // + // expandCollapseMsg(styleData.index); + // } + // } + // } + // } + + function expandCollapseMsg(index){ + if (tree.isExpanded(index)) + tree.collapse(index) + else + tree.expand(index); + } + + // Transition { + // id: expandTransition + // NumberAnimation { + // property: "y"; + // from: (tree.__listView.currentItem) ? tree.__listView.currentItem.y : 0; + // duration: 200; + // easing.type: Easing.OutQuad + // } + // } +// + // Transition { + // id: displacedTransition + // NumberAnimation { + // property: "y"; + // duration: 200; + // easing.type: Easing.OutQuad; + // } + // } + + // Component.onCompleted: { + // tree.__listView.add = expandTransition; + // tree.__listView.displaced = displacedTransition; + // tree.__listView.removeDisplaced = displacedTransition; + // } + +} diff --git a/src/plugins/topic_viewer/TopicViewer.qrc b/src/plugins/TopicViewer/TopicViewer.qrc similarity index 100% rename from src/plugins/topic_viewer/TopicViewer.qrc rename to src/plugins/TopicViewer/TopicViewer.qrc diff --git a/src/plugins/topic_viewer/TopicViewer_TEST.cc b/src/plugins/TopicViewer/TopicViewer_TEST.cc similarity index 100% rename from src/plugins/topic_viewer/TopicViewer_TEST.cc rename to src/plugins/TopicViewer/TopicViewer_TEST.cc diff --git a/src/plugins/topic_viewer/minus.png b/src/plugins/TopicViewer/minus.png similarity index 100% rename from src/plugins/topic_viewer/minus.png rename to src/plugins/TopicViewer/minus.png diff --git a/src/plugins/topic_viewer/plottable_icon.svg b/src/plugins/TopicViewer/plottable_icon.svg similarity index 100% rename from src/plugins/topic_viewer/plottable_icon.svg rename to src/plugins/TopicViewer/plottable_icon.svg diff --git a/src/plugins/topic_viewer/plus.png b/src/plugins/TopicViewer/plus.png similarity index 100% rename from src/plugins/topic_viewer/plus.png rename to src/plugins/TopicViewer/plus.png diff --git a/src/plugins/transport_scene_manager/CMakeLists.txt b/src/plugins/TransportSceneManager/CMakeLists.txt similarity index 56% rename from src/plugins/transport_scene_manager/CMakeLists.txt rename to src/plugins/TransportSceneManager/CMakeLists.txt index 31bef19dd..a4b19cfc5 100644 --- a/src/plugins/transport_scene_manager/CMakeLists.txt +++ b/src/plugins/TransportSceneManager/CMakeLists.txt @@ -3,9 +3,12 @@ gz_gui_add_plugin(TransportSceneManager TransportSceneManager.cc QT_HEADERS TransportSceneManager.hh + QML_SOURCES + TransportSceneManager.qml TEST_SOURCES # TransportSceneManager_TEST.cc PUBLIC_LINK_LIBS - gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} + gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} + QML_URI + TransportSceneManager ) - diff --git a/src/plugins/transport_scene_manager/TransportSceneManager.cc b/src/plugins/TransportSceneManager/TransportSceneManager.cc similarity index 100% rename from src/plugins/transport_scene_manager/TransportSceneManager.cc rename to src/plugins/TransportSceneManager/TransportSceneManager.cc diff --git a/src/plugins/transport_scene_manager/TransportSceneManager.hh b/src/plugins/TransportSceneManager/TransportSceneManager.hh similarity index 100% rename from src/plugins/transport_scene_manager/TransportSceneManager.hh rename to src/plugins/TransportSceneManager/TransportSceneManager.hh diff --git a/src/plugins/transport_scene_manager/TransportSceneManager.qml b/src/plugins/TransportSceneManager/TransportSceneManager.qml similarity index 94% rename from src/plugins/transport_scene_manager/TransportSceneManager.qml rename to src/plugins/TransportSceneManager/TransportSceneManager.qml index adfbf7a85..af27bc3f1 100644 --- a/src/plugins/transport_scene_manager/TransportSceneManager.qml +++ b/src/plugins/TransportSceneManager/TransportSceneManager.qml @@ -15,9 +15,9 @@ * */ -import QtQuick 2.9 -import QtQuick.Controls 2.1 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts GridLayout { columns: 1 diff --git a/src/plugins/transport_scene_manager/TransportSceneManager.qrc b/src/plugins/TransportSceneManager/TransportSceneManager.qrc similarity index 100% rename from src/plugins/transport_scene_manager/TransportSceneManager.qrc rename to src/plugins/TransportSceneManager/TransportSceneManager.qrc diff --git a/src/plugins/world_control/CMakeLists.txt b/src/plugins/WorldControl/CMakeLists.txt similarity index 71% rename from src/plugins/world_control/CMakeLists.txt rename to src/plugins/WorldControl/CMakeLists.txt index 5d64eae5d..4745253f5 100644 --- a/src/plugins/world_control/CMakeLists.txt +++ b/src/plugins/WorldControl/CMakeLists.txt @@ -3,11 +3,15 @@ if (NOT MSVC) SOURCES WorldControl.cc WorldControlEventListener.cc + QML_SOURCES + WorldControl.qml QT_HEADERS WorldControl.hh WorldControlEventListener.hh TEST_SOURCES WorldControl_TEST.cc + QML_URI + WorldControl ) else() gz_gui_add_plugin(WorldControl @@ -15,5 +19,9 @@ else() WorldControl.cc QT_HEADERS WorldControl.hh + QML_URI + WorldControl + QML_SOURCES + WorldControl.qml ) endif() diff --git a/src/plugins/world_control/WorldControl.cc b/src/plugins/WorldControl/WorldControl.cc similarity index 100% rename from src/plugins/world_control/WorldControl.cc rename to src/plugins/WorldControl/WorldControl.cc diff --git a/src/plugins/world_control/WorldControl.hh b/src/plugins/WorldControl/WorldControl.hh similarity index 100% rename from src/plugins/world_control/WorldControl.hh rename to src/plugins/WorldControl/WorldControl.hh diff --git a/src/plugins/world_control/WorldControl.qml b/src/plugins/WorldControl/WorldControl.qml similarity index 97% rename from src/plugins/world_control/WorldControl.qml rename to src/plugins/WorldControl/WorldControl.qml index 9cf54c98e..a10f2bff6 100644 --- a/src/plugins/world_control/WorldControl.qml +++ b/src/plugins/WorldControl/WorldControl.qml @@ -14,11 +14,11 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.5 -import QtQuick.Controls.Material 2.1 -import QtQuick.Layouts 1.3 -import "qrc:/qml" +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Layouts +import "qrc:/gz/gui/qml" RowLayout { id: worldControl diff --git a/src/plugins/world_control/WorldControl.qrc b/src/plugins/WorldControl/WorldControl.qrc similarity index 100% rename from src/plugins/world_control/WorldControl.qrc rename to src/plugins/WorldControl/WorldControl.qrc diff --git a/src/plugins/world_control/WorldControlEventListener.cc b/src/plugins/WorldControl/WorldControlEventListener.cc similarity index 100% rename from src/plugins/world_control/WorldControlEventListener.cc rename to src/plugins/WorldControl/WorldControlEventListener.cc diff --git a/src/plugins/world_control/WorldControlEventListener.hh b/src/plugins/WorldControl/WorldControlEventListener.hh similarity index 100% rename from src/plugins/world_control/WorldControlEventListener.hh rename to src/plugins/WorldControl/WorldControlEventListener.hh diff --git a/src/plugins/world_control/WorldControl_TEST.cc b/src/plugins/WorldControl/WorldControl_TEST.cc similarity index 100% rename from src/plugins/world_control/WorldControl_TEST.cc rename to src/plugins/WorldControl/WorldControl_TEST.cc diff --git a/src/plugins/world_stats/CMakeLists.txt b/src/plugins/WorldStats/CMakeLists.txt similarity index 68% rename from src/plugins/world_stats/CMakeLists.txt rename to src/plugins/WorldStats/CMakeLists.txt index d4de14064..adf2f48d8 100644 --- a/src/plugins/world_stats/CMakeLists.txt +++ b/src/plugins/WorldStats/CMakeLists.txt @@ -3,7 +3,10 @@ gz_gui_add_plugin(WorldStats WorldStats.cc QT_HEADERS WorldStats.hh + QML_SOURCES + WorldStats.qml TEST_SOURCES WorldStats_TEST.cc + QML_URI + WorldStats ) - diff --git a/src/plugins/world_stats/WorldStats.cc b/src/plugins/WorldStats/WorldStats.cc similarity index 100% rename from src/plugins/world_stats/WorldStats.cc rename to src/plugins/WorldStats/WorldStats.cc diff --git a/src/plugins/world_stats/WorldStats.hh b/src/plugins/WorldStats/WorldStats.hh similarity index 100% rename from src/plugins/world_stats/WorldStats.hh rename to src/plugins/WorldStats/WorldStats.hh diff --git a/src/plugins/world_stats/WorldStats.qml b/src/plugins/WorldStats/WorldStats.qml similarity index 98% rename from src/plugins/world_stats/WorldStats.qml rename to src/plugins/WorldStats/WorldStats.qml index ef8cf673f..e7e360ec7 100644 --- a/src/plugins/world_stats/WorldStats.qml +++ b/src/plugins/WorldStats/WorldStats.qml @@ -14,10 +14,10 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.1 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Layouts Rectangle { id: worldStats diff --git a/src/plugins/world_stats/WorldStats.qrc b/src/plugins/WorldStats/WorldStats.qrc similarity index 100% rename from src/plugins/world_stats/WorldStats.qrc rename to src/plugins/WorldStats/WorldStats.qrc diff --git a/src/plugins/world_stats/WorldStats_TEST.cc b/src/plugins/WorldStats/WorldStats_TEST.cc similarity index 100% rename from src/plugins/world_stats/WorldStats_TEST.cc rename to src/plugins/WorldStats/WorldStats_TEST.cc diff --git a/src/plugins/camera_fps/CameraFps.qrc b/src/plugins/camera_fps/CameraFps.qrc deleted file mode 100644 index 57549c350..000000000 --- a/src/plugins/camera_fps/CameraFps.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - CameraFps.qml - - diff --git a/src/plugins/grid_config/CMakeLists.txt b/src/plugins/grid_config/CMakeLists.txt deleted file mode 100644 index 101e6edee..000000000 --- a/src/plugins/grid_config/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -gz_gui_add_plugin(GridConfig - SOURCES - GridConfig.cc - QT_HEADERS - GridConfig.hh - PUBLIC_LINK_LIBS - gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} -) - -# Also install as Grid3D, which was a legacy plugin with a subset of features -install ( - FILES $ - RENAME ${CMAKE_SHARED_LIBRARY_PREFIX}Grid3D${CMAKE_SHARED_LIBRARY_SUFFIX} - DESTINATION ${GZ_GUI_PLUGIN_INSTALL_DIR}) diff --git a/src/plugins/minimal_scene/CMakeLists.txt b/src/plugins/minimal_scene/CMakeLists.txt deleted file mode 100644 index f037a862b..000000000 --- a/src/plugins/minimal_scene/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ -set(SOURCES - MinimalScene.cc - MinimalSceneRhi.cc - MinimalSceneRhiOpenGL.cc - MinimalSceneRhiVulkan.cc - EngineToQtInterface.cc -) - -set(PROJECT_LINK_LIBS "") - -# Objective-C sources for macOS -if (APPLE) - set(SOURCES - ${SOURCES} - MinimalSceneRhiMetal.mm - ) - - set(PROJECT_LINK_LIBS - "-framework AppKit" - "-framework Metal" - ) -endif() - -gz_gui_add_plugin(MinimalScene - SOURCES - ${SOURCES} - EngineToQtInterface.hh - QT_HEADERS - MinimalScene.hh - PUBLIC_LINK_LIBS - gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} - gz-transport${GZ_TRANSPORT_VER}::gz-transport${GZ_TRANSPORT_VER} - ${PROJECT_LINK_LIBS} -) - -# Enable ARC on selected source files -if (APPLE) - set_source_files_properties( - MinimalSceneRhiMetal.mm - PROPERTIES - COMPILE_FLAGS - "-fobjc-arc -Wno-nullability-completeness" - ) -endif() diff --git a/src/plugins/topic_viewer/TopicViewer.qml b/src/plugins/topic_viewer/TopicViewer.qml deleted file mode 100644 index 53ccd37ff..000000000 --- a/src/plugins/topic_viewer/TopicViewer.qml +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Copyright (C) 2020 Open Source Robotics Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * -*/ -import QtQml.Models 2.2 -import QtQuick 2.0 -import QtQuick.Controls 1.4 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Styles 1.4 -import QtQuick.Controls.Material 2.1 -import QtQuick.Layouts 1.3 - -TreeView { - objectName: "treeView" - id:tree - model: TopicsModel - - Layout.minimumHeight: 400 - Layout.minimumWidth: 300 - anchors.fill: parent - - property int itemHeight: 30; - - // =========== Colors =========== - property color oddColor: (Material.theme == Material.Light) ? - Material.color(Material.Grey, Material.Shade100): - Material.color(Material.Grey, Material.Shade800); - - property color evenColor: (Material.theme == Material.Light) ? - Material.color(Material.Grey, Material.Shade200): - Material.color(Material.Grey, Material.Shade900); - - property color highlightColor: Material.accentColor; - - - verticalScrollBarPolicy: Qt.ScrollBarAsNeeded - horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff - headerVisible: false - headerDelegate: Rectangle { - visible: false - } - backgroundVisible: false; - TableViewColumn - { - role: "name"; - } - - // =========== Selection =========== - selection: ItemSelectionModel { - model: tree.model - } - selectionMode: SelectionMode.SingleSelection - - // =========== Delegates ============ - rowDelegate: Rectangle - { - id: row - color: (styleData.selected)? highlightColor : - (styleData.row % 2 == 0) ? evenColor : oddColor - height: itemHeight; - } - - itemDelegate: Item { - id: item - - // for fixing the item position - // item pos changes randomly when drag happens (with the copy drag) - anchors.top: parent.top - anchors.right: parent.right - - Drag.mimeData: { "text/plain" : (model === null) ? "" : model.topic + "," + model.path } - - Drag.dragType: Drag.Automatic - Drag.supportedActions : Qt.CopyAction - Drag.active: dragMouse.drag.active - // a point to drag from - Drag.hotSpot.x: 0 - Drag.hotSpot.y: itemHeight - - // used by DropArea that accepts the dragged items - function itemData () - { - return { - "name": model.name, - "type": model.type, - "path": model.path, - "topic": model.topic - } - } - - MouseArea { - id: dragMouse - anchors.fill: parent - - // only plottable items are dragable - drag.target: (model === null) ? null : - (model.plottable) ? parent : null - - // get a copy image of the dragged item - onPressed: parent.grabToImage(function(result) { - parent.Drag.imageSource = result.url - }) - - onReleased: - { - // emit drop event to notify the DropArea (must manually) - parent.Drag.drop(); - } - - hoverEnabled: true - propagateComposedEvents: true - // make the cursor with a drag shape at the plottable items - cursorShape: (model === null) ? Qt.ArrowCursor : (model.plottable) ? - Qt.DragCopyCursor : Qt.ArrowCursor - - onClicked: { - // change the selection of the tree by clearing the prev, select a new one - tree.selection.select(styleData.index,ItemSelectionModel.ClearAndSelect) - - // set the selection index to the index of the clicked item (must set manually) - tree.selection.setCurrentIndex(styleData.index,ItemSelectionModel.ClearAndSelect) - - // the currentIndex of the tree.selection is not the same - // of the tree.currentIndex, so set the tree.currentIndex. - // this is the way to access it as it is read-only - tree.__currentRow = styleData.row - - // set the focus to the selected item to receive the keyboard events - // this is useful to enable navigating with keyboard from the right position - item.forceActiveFocus(); - - tree.expandCollapseMsg(tree.currentIndex); - } - } - - Image { - id: icon - source: "plottable_icon.svg" - height: itemHeight * 0.6 - width: itemHeight * 0.6 - y : itemHeight * 0.2 - visible: (model === null) ? false : model.plottable - } - - Text { - id : field - text: (model === null) ? "" : model.name - color: (Material.theme == Material.Light || styleData.selected) ? - Material.color(Material.Grey, Material.Shade800): - Material.color(Material.Grey, Material.Shade400); - - font.pointSize: 12 - anchors.leftMargin: 5 - anchors.left: icon.right - anchors.right: parent.right - elide: Text.ElideMiddle - y: icon.y - } - - ToolTip { - id: tool_tip - delay: 200 - timeout: 2000 - text: (model === null) ? "Type ?" : "Type: " + model.type; - visible: dragMouse.containsMouse - y: -itemHeight - x: dragMouse.mouseX - enter: null - exit: null - } - } - - property int y_pos: 0 - - style: TreeViewStyle { - branchDelegate: Rectangle { - height: itemHeight - width: itemHeight - color: "transparent" - Image { - id: branchImage - fillMode: Image.Pad - anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter - sourceSize.height: itemHeight * 0.4 - sourceSize.width: itemHeight * 0.4 - source: styleData.isExpanded ? "minus.png" : "plus.png" - } - MouseArea { - anchors.fill: parent - hoverEnabled: true - propagateComposedEvents: true - onClicked: { - mouse.accepted = true - - // set the current index & current selection and active focus for keyboard - // the reason for that to make the branch selection just like the item selection - // and to fix the animation as it ueses item selection's info - tree.selection.select(styleData.index,ItemSelectionModel.ClearAndSelect) - tree.selection.setCurrentIndex(styleData.index,ItemSelectionModel.ClearAndSelect) - tree.__currentRow = styleData.row - item.forceActiveFocus(); - - expandCollapseMsg(styleData.index); - } - } - } - } - - function expandCollapseMsg(index){ - if (tree.isExpanded(index)) - tree.collapse(index) - else - tree.expand(index); - } - - Transition { - id: expandTransition - NumberAnimation { - property: "y"; - from: (tree.__listView.currentItem) ? tree.__listView.currentItem.y : 0; - duration: 200; - easing.type: Easing.OutQuad - } - } - - Transition { - id: displacedTransition - NumberAnimation { - property: "y"; - duration: 200; - easing.type: Easing.OutQuad; - } - } - - Component.onCompleted: { - tree.__listView.add = expandTransition; - tree.__listView.displaced = displacedTransition; - tree.__listView.removeDisplaced = displacedTransition; - } - -} diff --git a/test/plugins/TestInvalidQmlPlugin.qml b/test/plugins/TestInvalidQmlPlugin.qml index 17cdc890e..4e3f55a52 100644 --- a/test/plugins/TestInvalidQmlPlugin.qml +++ b/test/plugins/TestInvalidQmlPlugin.qml @@ -14,7 +14,7 @@ * limitations under the License. * */ -import QtQuick 2.9 +import QtQuick Rectangle { banana: fail diff --git a/test/plugins/TestPlugin.qml b/test/plugins/TestPlugin.qml index be4596d8f..2c57d9827 100644 --- a/test/plugins/TestPlugin.qml +++ b/test/plugins/TestPlugin.qml @@ -14,7 +14,7 @@ * limitations under the License. * */ -import QtQuick 2.9 +import QtQuick Rectangle { color: "red"