Skip to content

Commit 56620e2

Browse files
committedMay 31, 2015
Switch layer panel to toolbar
1 parent fb3f953 commit 56620e2

File tree

2 files changed

+32
-41
lines changed

2 files changed

+32
-41
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 31 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ QgisApp::QgisApp()
933933
, mMacrosWarn( 0 )
934934
, mUserInputDockWidget( 0 )
935935
, mVectorLayerTools( 0 )
936-
, mBtnFilterLegend( 0 )
936+
, mActionFilterLegend( 0 )
937937
, mSnappingUtils( 0 )
938938
, mProjectLastModified()
939939
{
@@ -2454,12 +2454,11 @@ void QgisApp::initLayerTreeView()
24542454
connect( QgsProject::instance()->layerTreeRegistryBridge(), SIGNAL( addedLayersToLayerTree( QList<QgsMapLayer*> ) ),
24552455
this, SLOT( autoSelectAddedLayer( QList<QgsMapLayer*> ) ) );
24562456

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() ) );
24632462

24642463
// visibility groups tool button
24652464
QToolButton* btnVisibilityPresets = new QToolButton;
@@ -2469,43 +2468,35 @@ void QgisApp::initLayerTreeView()
24692468
btnVisibilityPresets->setPopupMode( QToolButton::InstantPopup );
24702469
btnVisibilityPresets->setMenu( QgsVisibilityPresets::instance()->menu() );
24712470

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() ) );
24792477

24802478
// 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 );
25052496

25062497
QVBoxLayout* vboxLayout = new QVBoxLayout;
25072498
vboxLayout->setMargin( 0 );
2508-
vboxLayout->addLayout( toolbarLayout );
2499+
vboxLayout->addWidget( toolbar );
25092500
vboxLayout->addWidget( mLayerTreeView );
25102501

25112502
QWidget* w = new QWidget;
@@ -4495,7 +4486,7 @@ void QgisApp::setFilterLegendByMapEnabled( bool enabled )
44954486
if ( wasEnabled == enabled )
44964487
return; // no change
44974488

4498-
mBtnFilterLegend->setChecked( enabled );
4489+
mActionFilterLegend->setChecked( enabled );
44994490

45004491
if ( enabled )
45014492
{

‎src/app/qgisapp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1662,7 +1662,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
16621662

16631663
QgsVectorLayerTools* mVectorLayerTools;
16641664

1665-
QToolButton* mBtnFilterLegend;
1665+
QAction* mActionFilterLegend;
16661666

16671667
QgsSnappingUtils* mSnappingUtils;
16681668

0 commit comments

Comments
 (0)
Please sign in to comment.