Skip to content

Commit

Permalink
Fix label button not opening label dock panel (fix #15144)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 27, 2016
1 parent 8dc8952 commit 5b166a9
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5819,6 +5819,7 @@ void QgisApp::labeling()
}

mapStyleDock( true );
mMapStyleWidget->setCurrentPage( QgsLayerStylingWidget::VectorLabeling );
}

void QgisApp::setMapStyleDockLayer( QgsMapLayer* layer )
Expand Down
39 changes: 32 additions & 7 deletions src/app/qgslayerstylingwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,27 +144,39 @@ void QgsLayerStylingWidget::setLayer( QgsMapLayer *layer )
mUserPages.clear();
if ( layer->type() == QgsMapLayer::VectorLayer )
{
mOptionsListWidget->addItem( new QListWidgetItem( QgsApplication::getThemeIcon( "propertyicons/symbology.svg" ), "" ) );
mOptionsListWidget->addItem( new QListWidgetItem( QgsApplication::getThemeIcon( "labelingSingle.svg" ), "" ) );
QListWidgetItem* symbolItem = new QListWidgetItem( QgsApplication::getThemeIcon( "propertyicons/symbology.svg" ), QString() );
symbolItem->setData( Qt::UserRole, Symbology );
mOptionsListWidget->addItem( symbolItem );
QListWidgetItem* labelItem = new QListWidgetItem( QgsApplication::getThemeIcon( "labelingSingle.svg" ), QString() );
labelItem->setData( Qt::UserRole, VectorLabeling );
mOptionsListWidget->addItem( labelItem );
}
else if ( layer->type() == QgsMapLayer::RasterLayer )
{
mOptionsListWidget->addItem( new QListWidgetItem( QgsApplication::getThemeIcon( "propertyicons/symbology.svg" ), "" ) );
mOptionsListWidget->addItem( new QListWidgetItem( QgsApplication::getThemeIcon( "propertyicons/transparency.png" ), "" ) );
mOptionsListWidget->addItem( new QListWidgetItem( QgsApplication::getThemeIcon( "propertyicons/histogram.png" ), "" ) );
QListWidgetItem* symbolItem = new QListWidgetItem( QgsApplication::getThemeIcon( "propertyicons/symbology.svg" ), QString() );
symbolItem->setData( Qt::UserRole, Symbology );
mOptionsListWidget->addItem( symbolItem );
QListWidgetItem* transparencyItem = new QListWidgetItem( QgsApplication::getThemeIcon( "propertyicons/transparency.png" ), QString() );
transparencyItem->setData( Qt::UserRole, RasterTransparency );
mOptionsListWidget->addItem( transparencyItem );
QListWidgetItem* histogramItem = new QListWidgetItem( QgsApplication::getThemeIcon( "propertyicons/histogram.png" ), QString() );
histogramItem->setData( Qt::UserRole, RasterHistogram );
mOptionsListWidget->addItem( histogramItem );
}

Q_FOREACH ( QgsLayerStylingPanelFactory* factory, mPageFactories )
{
if ( factory->supportsLayer( layer ) )
{
QListWidgetItem* item = new QListWidgetItem( factory->icon(), "" );
QListWidgetItem* item = new QListWidgetItem( factory->icon(), QString() );
mOptionsListWidget->addItem( item );
int row = mOptionsListWidget->row( item );
mUserPages[row] = factory;
}
}
mOptionsListWidget->addItem( new QListWidgetItem( QgsApplication::getThemeIcon( "mActionHistory.svg" ), "" ) );
QListWidgetItem* historyItem = new QListWidgetItem( QgsApplication::getThemeIcon( "mActionHistory.svg" ), QString() );
historyItem->setData( Qt::UserRole, History );
mOptionsListWidget->addItem( historyItem );
mOptionsListWidget->blockSignals( false );

if ( sameLayerType )
Expand Down Expand Up @@ -395,6 +407,19 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer()
mBlockAutoApply = false;
}

void QgsLayerStylingWidget::setCurrentPage( QgsLayerStylingWidget::Page page )
{
for ( int i = 0; i < mOptionsListWidget->count(); ++i )
{
int data = mOptionsListWidget->item( i )->data( Qt::UserRole ).toInt();
if ( data == static_cast< int >( page ) )
{
mOptionsListWidget->setCurrentRow( i );
return;
}
}
}

void QgsLayerStylingWidget::layerAboutToBeRemoved( QgsMapLayer* layer )
{
if ( layer == mCurrentLayer )
Expand Down
15 changes: 15 additions & 0 deletions src/app/qgslayerstylingwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ class APP_EXPORT QgsLayerStylingWidget : public QWidget, private Ui::QgsLayerSty
{
Q_OBJECT
public:

enum Page
{
Symbology = 1,
VectorLabeling,
RasterTransparency,
RasterHistogram,
History,
};

QgsLayerStylingWidget( QgsMapCanvas *canvas, QList<QgsLayerStylingPanelFactory *> pages, QWidget *parent = 0 );
~QgsLayerStylingWidget();
QgsMapLayer* layer() { return mCurrentLayer; }
Expand All @@ -90,6 +100,11 @@ class APP_EXPORT QgsLayerStylingWidget : public QWidget, private Ui::QgsLayerSty
void redo();
void updateCurrentWidgetLayer();

/** Sets the current visible page in the widget.
* @param page standard page to display
*/
void setCurrentPage( Page page );

private slots:

void layerAboutToBeRemoved( QgsMapLayer* layer );
Expand Down

2 comments on commit 5b166a9

@nirvn
Copy link
Contributor

@nirvn nirvn commented on 5b166a9 Jun 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haaa.

@NathanW2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nyalldawson

Please sign in to comment.