Skip to content
Permalink
Browse files

Fix label button not opening label dock panel (fix #15144)

  • Loading branch information
nyalldawson committed Jun 27, 2016
1 parent 8dc8952 commit 5b166a9d6b37c64938039885af70d7af2528a7f5
Showing with 48 additions and 7 deletions.
  1. +1 −0 src/app/qgisapp.cpp
  2. +32 −7 src/app/qgslayerstylingwidget.cpp
  3. +15 −0 src/app/qgslayerstylingwidget.h
@@ -5819,6 +5819,7 @@ void QgisApp::labeling()
}

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

void QgisApp::setMapStyleDockLayer( QgsMapLayer* layer )
@@ -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 )
@@ -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 )
@@ -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; }
@@ -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 );

2 comments on commit 5b166a9

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn replied Jun 27, 2016

Haaa.

@NathanW2

This comment has been minimized.

Copy link
Member

@NathanW2 NathanW2 replied Jun 27, 2016

Thanks @nyalldawson

Please sign in to comment.
You can’t perform that action at this time.