From 2fbb93689e1e0e74227cc79644818aacf4af9efa Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Thu, 23 Jan 2025 14:38:16 +0700 Subject: [PATCH] Implement a iface function for plugins to add actions to the new dashboard actions toolbar --- src/core/appinterface.cpp | 14 ++++++++++++++ src/core/appinterface.h | 14 +++++++++++++- src/qml/DashBoard.qml | 9 +++++---- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/core/appinterface.cpp b/src/core/appinterface.cpp index f90b164ffd..5453b3fb40 100644 --- a/src/core/appinterface.cpp +++ b/src/core/appinterface.cpp @@ -68,6 +68,20 @@ void AppInterface::addItemToCanvasActionsToolbar( QQuickItem *item ) const } } +void AppInterface::addItemToDashboardActionsToolbar( QQuickItem *item ) const +{ + if ( !mApp->rootObjects().isEmpty() ) + { + QQuickItem *toolbar = mApp->rootObjects().at( 0 )->findChild( QStringLiteral( "dashboardActionsToolbar" ) ); + item->setParentItem( toolbar ); + } +} + +void AppInterface::addItemToMainMenuActionsToolbar( QQuickItem *item ) const +{ + addItemToDashboardActionsToolbar( item ); +} + QObject *AppInterface::mainWindow() const { if ( !mApp->rootObjects().isEmpty() ) diff --git a/src/core/appinterface.h b/src/core/appinterface.h index f395cedacb..a911bd09cb 100644 --- a/src/core/appinterface.h +++ b/src/core/appinterface.h @@ -110,10 +110,22 @@ class AppInterface : public QObject Q_INVOKABLE void addItemToPluginsToolbar( QQuickItem *item ) const; /** - * Adds an \a item in the main menu action toolbar container + * Adds an \a item in the map canvas menu's action toolbar container */ Q_INVOKABLE void addItemToCanvasActionsToolbar( QQuickItem *item ) const; + /** + * Adds an \a item in the dashboard's action toolbar container + */ + Q_INVOKABLE void addItemToDashboardActionsToolbar( QQuickItem *item ) const; + + /** + * Adds an \a item in the dashboard's action toolbar container + * \note This function is deprecated and will be removed in the future, use + * the addItemToDashboardActionsToolbar function instead + */ + Q_INVOKABLE void addItemToMainMenuActionsToolbar( QQuickItem *item ) const; + /** * Returns the main window. */ diff --git a/src/qml/DashBoard.qml b/src/qml/DashBoard.qml index 6ff9eb52ce..c7498589bd 100644 --- a/src/qml/DashBoard.qml +++ b/src/qml/DashBoard.qml @@ -67,7 +67,7 @@ Drawer { anchors.fill: parent Rectangle { - height: mainWindow.sceneTopMargin + Math.max(buttonsRow.height, buttonsRow.childrenRect.height) + height: mainWindow.sceneTopMargin + Math.max(buttonsRow.height + 8, buttonsRow.childrenRect.height) Layout.fillWidth: true Layout.preferredHeight: height @@ -88,7 +88,8 @@ Drawer { anchors.left: closeButton.right anchors.right: menuButton.left anchors.top: parent.top - anchors.topMargin: mainWindow.sceneTopMargin + anchors.topMargin: mainWindow.sceneTopMargin + 4 + anchors.bottomMargin: 4 height: buttonsRow.height contentWidth: buttonsRow.width contentHeight: buttonsRow.height @@ -105,8 +106,8 @@ Drawer { Row { id: buttonsRow - anchors.topMargin: mainWindow.sceneTopMargin - height: 56 + objectName: "dashboardActionsToolbar" + height: 48 spacing: 1 QfToolButton {