Skip to content

Commit

Permalink
Implement a iface function for plugins to add actions to the new dash…
Browse files Browse the repository at this point in the history
…board actions toolbar
  • Loading branch information
nirvn committed Jan 23, 2025
1 parent b7d11f8 commit 2fbb936
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
14 changes: 14 additions & 0 deletions src/core/appinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<QQuickItem *>( QStringLiteral( "dashboardActionsToolbar" ) );
item->setParentItem( toolbar );
}
}

void AppInterface::addItemToMainMenuActionsToolbar( QQuickItem *item ) const
{
addItemToDashboardActionsToolbar( item );
}

QObject *AppInterface::mainWindow() const
{
if ( !mApp->rootObjects().isEmpty() )
Expand Down
14 changes: 13 additions & 1 deletion src/core/appinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
9 changes: 5 additions & 4 deletions src/qml/DashBoard.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -105,8 +106,8 @@ Drawer {

Row {
id: buttonsRow
anchors.topMargin: mainWindow.sceneTopMargin
height: 56
objectName: "dashboardActionsToolbar"
height: 48
spacing: 1

QfToolButton {
Expand Down

0 comments on commit 2fbb936

Please sign in to comment.