Skip to content
Permalink
Browse files
Merge pull request #45756 from DelazJ/labelLegendGroupBox
Remove the unnecessary checkbox for the Label legend group box
  • Loading branch information
m-kuhn committed Oct 31, 2021
2 parents 9322dc6 + 547dee8 commit 469d387bdebd2640fbe3e05cccdef8a2365d4ade
Showing with 56 additions and 34 deletions.
  1. +10 −19 src/gui/vector/qgsvectorlayerlegendwidget.cpp
  2. +0 −3 src/gui/vector/qgsvectorlayerlegendwidget.h
  3. +34 −12 src/ui/qgsrasterlayerpropertiesbase.ui
  4. +12 −0 src/ui/qgsvectorlayerpropertiesbase.ui
@@ -60,11 +60,9 @@ QgsVectorLayerLegendWidget::QgsVectorLayerLegendWidget( QWidget *parent )
mTextOnSymbolGroupBox->setLayout( groupLayout );
mTextOnSymbolGroupBox->setCollapsed( false );

mShowLabelLegendCheckBox = new QCheckBox( tr( "Show label legend" ) );
connect( mShowLabelLegendCheckBox, &QCheckBox::toggled, this, &QgsVectorLayerLegendWidget::enableLabelLegendGroupBox );
mLabelLegendGroupBox = new QgsCollapsibleGroupBox;
mLabelLegendGroupBox->setVisible( false );
mLabelLegendGroupBox->setTitle( tr( "Label legend" ) );
mLabelLegendGroupBox->setCheckable( true );
mLabelLegendGroupBox->setTitle( tr( "Show Label Legend" ) );

mLabelLegendTreeWidget = new QTreeWidget;
connect( mLabelLegendTreeWidget, &QTreeWidget::itemDoubleClicked, this, &QgsVectorLayerLegendWidget::labelLegendTreeWidgetItemDoubleClicked );
@@ -80,27 +78,19 @@ QgsVectorLayerLegendWidget::QgsVectorLayerLegendWidget( QWidget *parent )
mImageSourceLineEdit->setSource( mLayer->legendPlaceholderImage() );
}

QHBoxLayout *placeholderLayout = new QHBoxLayout;
placeholderLayout->addWidget( mPlaceholderImageLabel );
placeholderLayout->addWidget( mImageSourceLineEdit );

QVBoxLayout *layout = new QVBoxLayout;
layout->setContentsMargins( 0, 0, 0, 0 );
layout->addWidget( mPlaceholderImageLabel );
layout->addWidget( mImageSourceLineEdit );
layout->addWidget( mShowLabelLegendCheckBox );
layout->addLayout( placeholderLayout );
layout->addWidget( mLabelLegendGroupBox );
layout->addWidget( mTextOnSymbolGroupBox );

setLayout( layout );
}

void QgsVectorLayerLegendWidget::enableLabelLegendGroupBox( bool enable )
{
mLabelLegendGroupBox->setVisible( enable );
if ( enable )
{
populateLabelLegendTreeWidget();
}
}

void QgsVectorLayerLegendWidget::labelLegendTreeWidgetItemDoubleClicked( QTreeWidgetItem *item, int column )
{
const Qt::ItemFlags flags = item->flags();
@@ -128,7 +118,8 @@ void QgsVectorLayerLegendWidget::setLayer( QgsVectorLayer *layer )
if ( !legend )
return;

mShowLabelLegendCheckBox->setChecked( legend->showLabelLegend() );
mLabelLegendGroupBox->setChecked( legend->showLabelLegend() );
populateLabelLegendTreeWidget();
mTextOnSymbolGroupBox->setChecked( legend->textOnSymbolEnabled() );
mTextOnSymbolFormatButton->setTextFormat( legend->textOnSymbolTextFormat() );
populateLegendTreeView( legend->textOnSymbolContent() );
@@ -142,7 +133,7 @@ void QgsVectorLayerLegendWidget::populateLabelLegendTreeWidget()
{
mLabelLegendTreeWidget->clear();
mLabelLegendTreeWidget->setColumnCount( 2 );
QTreeWidgetItem *headerItem = new QTreeWidgetItem( QStringList() << tr( "Description" ) << tr( "LegendText" ) );
QTreeWidgetItem *headerItem = new QTreeWidgetItem( QStringList() << tr( "Description" ) << tr( "Legend Text" ) );
mLabelLegendTreeWidget->setHeaderItem( headerItem );

const QgsAbstractVectorLayerLabeling *labeling = mLayer->labeling();
@@ -227,7 +218,7 @@ void QgsVectorLayerLegendWidget::applyToLayer()
}
legend->setTextOnSymbolContent( content );

const bool showLabelLegend = mShowLabelLegendCheckBox->isChecked();
const bool showLabelLegend = mLabelLegendGroupBox->isChecked();
legend->setShowLabelLegend( showLabelLegend );
if ( showLabelLegend )
{
@@ -24,7 +24,6 @@
#include "qgstextformat.h"
#include "qgis_gui.h"

class QCheckBox;
class QgsImageSourceLineEdit;
class QLabel;
class QPushButton;
@@ -60,7 +59,6 @@ class GUI_EXPORT QgsVectorLayerLegendWidget : public QWidget

private slots:
void labelsFromExpression();
void enableLabelLegendGroupBox( bool enable );
void labelLegendTreeWidgetItemDoubleClicked( QTreeWidgetItem *item, int column );

private:
@@ -74,7 +72,6 @@ class GUI_EXPORT QgsVectorLayerLegendWidget : public QWidget
QPushButton *mTextOnSymbolFromExpressionButton = nullptr;
QgsCollapsibleGroupBox *mTextOnSymbolGroupBox = nullptr;
QLabel *mTextOnSymbolLabel = nullptr;
QCheckBox *mShowLabelLegendCheckBox = nullptr;
QgsCollapsibleGroupBox *mLabelLegendGroupBox = nullptr;
QTreeWidget *mLabelLegendTreeWidget = nullptr;
QLabel *mPlaceholderImageLabel = nullptr;
@@ -1385,8 +1385,28 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
<widget class="QWidget" name="mOptsPage_Legend">
<layout class="QGridLayout" name="gridLayout_15">
<item row="2" column="0">
<layout class="QVBoxLayout" name="verticalLayout_151">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="mLegendPlaceholderLabel">
<property name="text">
<string>Legend placeholder image</string>
</property>
</widget>
</item>
<item>
<widget class="QgsImageSourceLineEdit" name="mLegendPlaceholderWidget" native="true"/>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
@@ -1398,22 +1418,24 @@ p, li { white-space: pre-wrap; }
<string>Embedded Widgets in Legend</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_17">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QgsLayerTreeEmbeddedConfigWidget" name="mLegendConfigEmbeddedWidget" native="true"/>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QgsImageSourceLineEdit" name="mLegendPlaceholderWidget" native="true"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="mLegendPlaceholderLabel">
<property name="text">
<string>Legend placeholder image</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="mOptsPage_Server">
@@ -2059,6 +2059,18 @@
<string>Embedded Widgets in Legend</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_22">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QgsLayerTreeEmbeddedConfigWidget" name="mLegendConfigEmbeddedWidget" native="true"/>
</item>

0 comments on commit 469d387

Please sign in to comment.