Skip to content

Commit

Permalink
Revert "Remove dedicated "show editing toolbar" action from 3d windows"
Browse files Browse the repository at this point in the history
This reverts commit 0225742.
  • Loading branch information
Withalion authored Feb 3, 2025
1 parent 0a87489 commit 6a50a4f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 47 deletions.
44 changes: 2 additions & 42 deletions src/app/3d/qgs3dmapcanvaswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked )
{
const QgsSettings setting;

mToolbarMenu = new QMenu( tr( "Toolbars" ), this );
mToolbarMenu->setObjectName( QStringLiteral( "mToolbarMenu" ) );

QToolBar *toolBar = new QToolBar( this );
toolBar->setIconSize( QgisApp::instance()->iconSize( isDocked ) );

Expand All @@ -82,7 +79,6 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked )

// Editing toolbar
mEditingToolBar = new QToolBar( this );
mEditingToolBar->setWindowTitle( tr( "Editing Toolbar" ) );
mEditingToolBar->setVisible( false );

QAction *actionPointCloudChangeAttributeTool = mEditingToolBar->addAction( QIcon( QgsApplication::iconPath( "mActionSelectPolygon.svg" ) ), tr( "Change Point Cloud Attribute" ), this, &Qgs3DMapCanvasWidget::changePointCloudAttribute );
Expand All @@ -94,6 +90,8 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked )
mSpinChangeAttributeValue = new QgsDoubleSpinBox();
mEditingToolBar->addWidget( new QLabel( tr( "Value" ) ) );
mEditingToolBar->addWidget( mSpinChangeAttributeValue );
QAction *actionEditingToolbar = toolBar->addAction( QIcon( QgsApplication::iconPath( "mIconPointCloudLayer.svg" ) ), tr( "Show Editing Toolbar" ), this, [this] { mEditingToolBar->setVisible( !mEditingToolBar->isVisible() ); } );
actionEditingToolbar->setCheckable( true );
connect( mCboChangeAttribute, qOverload<int>( &QComboBox::currentIndexChanged ), this, [this]( int ) { onPointCloudChangeAttributeSettingsChanged(); } );
connect( mSpinChangeAttributeValue, qOverload<double>( &QgsDoubleSpinBox::valueChanged ), this, [this]( double ) { onPointCloudChangeAttributeSettingsChanged(); } );

Expand Down Expand Up @@ -344,24 +342,6 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked )
} );

updateLayerRelatedActions( QgisApp::instance()->activeLayer() );

QList<QAction *> toolbarMenuActions;
// Set action names so that they can be used in customization
for ( QToolBar *toolBar : { mEditingToolBar } )
{
toolBar->toggleViewAction()->setObjectName( "mActionToggle" + toolBar->objectName().mid( 1 ) );
toolbarMenuActions << toolBar->toggleViewAction();
}

// sort actions in toolbar menu
std::sort( toolbarMenuActions.begin(), toolbarMenuActions.end(), []( QAction *a, QAction *b ) {
return QString::localeAwareCompare( a->text(), b->text() ) < 0;
} );

mToolbarMenu->addActions( toolbarMenuActions );

toolBar->installEventFilter( this );
mEditingToolBar->installEventFilter( this );
}

Qgs3DMapCanvasWidget::~Qgs3DMapCanvasWidget()
Expand Down Expand Up @@ -474,26 +454,6 @@ void Qgs3DMapCanvasWidget::updateLayerRelatedActions( QgsMapLayer *layer )
enableEditingTools( pcLayer->isEditable() );
}

bool Qgs3DMapCanvasWidget::eventFilter( QObject *watched, QEvent *event )
{
if ( qobject_cast< QToolBar * >( watched ) )
{
if ( event->type() != QEvent::MouseButtonPress )
return QObject::eventFilter( watched, event );

QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent *>( event );
if ( !mouseEvent )
return QObject::eventFilter( watched, event );

if ( mouseEvent->button() != Qt::RightButton )
return QObject::eventFilter( watched, event );

mToolbarMenu->exec( mouseEvent->globalPos() );
return false;
}
return QObject::eventFilter( watched, event );
}

void Qgs3DMapCanvasWidget::toggleNavigationWidget( bool visibility )
{
mNavigationWidget->setVisible( visibility );
Expand Down
5 changes: 0 additions & 5 deletions src/app/3d/qgs3dmapcanvaswidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ class APP_EXPORT Qgs3DMapCanvasWidget : public QWidget

void updateLayerRelatedActions( QgsMapLayer *layer );

bool eventFilter( QObject *watched, QEvent *event ) override;


private slots:
void resetView();
void configure();
Expand Down Expand Up @@ -164,8 +161,6 @@ class APP_EXPORT Qgs3DMapCanvasWidget : public QWidget
QToolBar *mEditingToolBar = nullptr;
QComboBox *mCboChangeAttribute = nullptr;
QgsDoubleSpinBox *mSpinChangeAttributeValue = nullptr;

QMenu *mToolbarMenu = nullptr;
};

#endif // QGS3DMAPCANVASWIDGET_H

0 comments on commit 6a50a4f

Please sign in to comment.