@@ -933,7 +933,7 @@ QgisApp::QgisApp()
933
933
, mMacrosWarn ( 0 )
934
934
, mUserInputDockWidget ( 0 )
935
935
, mVectorLayerTools ( 0 )
936
- , mBtnFilterLegend ( 0 )
936
+ , mActionFilterLegend ( 0 )
937
937
, mSnappingUtils ( 0 )
938
938
, mProjectLastModified ()
939
939
{
@@ -2454,12 +2454,11 @@ void QgisApp::initLayerTreeView()
2454
2454
connect ( QgsProject::instance ()->layerTreeRegistryBridge (), SIGNAL ( addedLayersToLayerTree ( QList<QgsMapLayer*> ) ),
2455
2455
this , SLOT ( autoSelectAddedLayer ( QList<QgsMapLayer*> ) ) );
2456
2456
2457
- // add group tool button
2458
- QToolButton* btnAddGroup = new QToolButton;
2459
- btnAddGroup->setAutoRaise ( true );
2460
- btnAddGroup->setIcon ( QgsApplication::getThemeIcon ( " /mActionFolder.svg" ) );
2461
- btnAddGroup->setToolTip ( tr ( " Add Group" ) );
2462
- connect ( btnAddGroup, SIGNAL ( clicked () ), mLayerTreeView ->defaultActions (), SLOT ( addGroup () ) );
2457
+ // add group action
2458
+ QAction* actionAddGroup = new QAction ( tr ( " Add Group" ), this );
2459
+ actionAddGroup->setIcon ( QgsApplication::getThemeIcon ( " /mActionFolder.svg" ) );
2460
+ actionAddGroup->setToolTip ( tr ( " Add Group" ) );
2461
+ connect ( actionAddGroup, SIGNAL ( triggered ( bool ) ), mLayerTreeView ->defaultActions (), SLOT ( addGroup () ) );
2463
2462
2464
2463
// visibility groups tool button
2465
2464
QToolButton* btnVisibilityPresets = new QToolButton;
@@ -2469,43 +2468,35 @@ void QgisApp::initLayerTreeView()
2469
2468
btnVisibilityPresets->setPopupMode ( QToolButton::InstantPopup );
2470
2469
btnVisibilityPresets->setMenu ( QgsVisibilityPresets::instance ()->menu () );
2471
2470
2472
- // filter legend tool button
2473
- mBtnFilterLegend = new QToolButton;
2474
- mBtnFilterLegend ->setAutoRaise ( true );
2475
- mBtnFilterLegend ->setCheckable ( true );
2476
- mBtnFilterLegend ->setToolTip ( tr ( " Filter Legend By Map Content" ) );
2477
- mBtnFilterLegend ->setIcon ( QgsApplication::getThemeIcon ( " /mActionFilter2.svg" ) );
2478
- connect ( mBtnFilterLegend , SIGNAL ( clicked () ), this , SLOT ( toggleFilterLegendByMap () ) );
2471
+ // filter legend action
2472
+ mActionFilterLegend = new QAction ( tr ( " Filter Legend By Map Content" ), this );
2473
+ mActionFilterLegend ->setCheckable ( true );
2474
+ mActionFilterLegend ->setToolTip ( tr ( " Filter Legend By Map Content" ) );
2475
+ mActionFilterLegend ->setIcon ( QgsApplication::getThemeIcon ( " /mActionFilter2.svg" ) );
2476
+ connect ( mActionFilterLegend , SIGNAL ( triggered ( bool ) ), this , SLOT ( toggleFilterLegendByMap () ) );
2479
2477
2480
2478
// expand / collapse tool buttons
2481
- QToolButton* btnExpandAll = new QToolButton;
2482
- btnExpandAll->setAutoRaise ( true );
2483
- btnExpandAll->setIcon ( QgsApplication::getThemeIcon ( " /mActionExpandTree.svg" ) );
2484
- btnExpandAll->setToolTip ( tr ( " Expand All" ) );
2485
- connect ( btnExpandAll, SIGNAL ( clicked () ), mLayerTreeView , SLOT ( expandAll () ) );
2486
- QToolButton* btnCollapseAll = new QToolButton;
2487
- btnCollapseAll->setAutoRaise ( true );
2488
- btnCollapseAll->setIcon ( QgsApplication::getThemeIcon ( " /mActionCollapseTree.svg" ) );
2489
- btnCollapseAll->setToolTip ( tr ( " Collapse All" ) );
2490
- connect ( btnCollapseAll, SIGNAL ( clicked () ), mLayerTreeView , SLOT ( collapseAll () ) );
2491
-
2492
- QToolButton* btnRemoveItem = new QToolButton;
2493
- btnRemoveItem->setDefaultAction ( this ->mActionRemoveLayer );
2494
- btnRemoveItem->setAutoRaise ( true );
2495
-
2496
- QHBoxLayout* toolbarLayout = new QHBoxLayout;
2497
- toolbarLayout->setContentsMargins ( QMargins ( 5 , 0 , 5 , 0 ) );
2498
- toolbarLayout->addWidget ( btnAddGroup );
2499
- toolbarLayout->addWidget ( btnVisibilityPresets );
2500
- toolbarLayout->addWidget ( mBtnFilterLegend );
2501
- toolbarLayout->addWidget ( btnExpandAll );
2502
- toolbarLayout->addWidget ( btnCollapseAll );
2503
- toolbarLayout->addWidget ( btnRemoveItem );
2504
- toolbarLayout->addStretch ();
2479
+ QAction* actionExpandAll = new QAction ( tr ( " Expand All" ), this );
2480
+ actionExpandAll->setIcon ( QgsApplication::getThemeIcon ( " /mActionExpandTree.svg" ) );
2481
+ actionExpandAll->setToolTip ( tr ( " Expand All" ) );
2482
+ connect ( actionExpandAll, SIGNAL ( triggered ( bool ) ), mLayerTreeView , SLOT ( expandAll () ) );
2483
+ QAction* actionCollapseAll = new QAction ( tr ( " Collapse All" ), this );
2484
+ actionCollapseAll->setIcon ( QgsApplication::getThemeIcon ( " /mActionCollapseTree.svg" ) );
2485
+ actionCollapseAll->setToolTip ( tr ( " Collapse All" ) );
2486
+ connect ( actionCollapseAll, SIGNAL ( triggered ( bool ) ), mLayerTreeView , SLOT ( collapseAll () ) );
2487
+
2488
+ QToolBar* toolbar = new QToolBar ();
2489
+ toolbar->setIconSize ( QSize ( 16 , 16 ) );
2490
+ toolbar->addAction ( actionAddGroup );
2491
+ toolbar->addWidget ( btnVisibilityPresets );
2492
+ toolbar->addAction ( mActionFilterLegend );
2493
+ toolbar->addAction ( actionExpandAll );
2494
+ toolbar->addAction ( actionCollapseAll );
2495
+ toolbar->addAction ( mActionRemoveLayer );
2505
2496
2506
2497
QVBoxLayout* vboxLayout = new QVBoxLayout;
2507
2498
vboxLayout->setMargin ( 0 );
2508
- vboxLayout->addLayout ( toolbarLayout );
2499
+ vboxLayout->addWidget ( toolbar );
2509
2500
vboxLayout->addWidget ( mLayerTreeView );
2510
2501
2511
2502
QWidget* w = new QWidget;
@@ -4495,7 +4486,7 @@ void QgisApp::setFilterLegendByMapEnabled( bool enabled )
4495
4486
if ( wasEnabled == enabled )
4496
4487
return ; // no change
4497
4488
4498
- mBtnFilterLegend ->setChecked ( enabled );
4489
+ mActionFilterLegend ->setChecked ( enabled );
4499
4490
4500
4491
if ( enabled )
4501
4492
{
0 commit comments