Skip to content
Permalink
Browse files
Use a checkable groupbox instead of an intermediate checkbox
  • Loading branch information
DelazJ committed Oct 31, 2021
1 parent 9322dc6 commit e6ba470a01a7106e7df19f0d3fca752e0e5cb271
Showing with 5 additions and 19 deletions.
  1. +5 −16 src/gui/vector/qgsvectorlayerlegendwidget.cpp
  2. +0 −3 src/gui/vector/qgsvectorlayerlegendwidget.h
@@ -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 );
@@ -85,22 +83,12 @@ QgsVectorLayerLegendWidget::QgsVectorLayerLegendWidget( QWidget *parent )
layout->setContentsMargins( 0, 0, 0, 0 );
layout->addWidget( mPlaceholderImageLabel );
layout->addWidget( mImageSourceLineEdit );
layout->addWidget( mShowLabelLegendCheckBox );
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 +116,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() );
@@ -227,7 +216,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;

0 comments on commit e6ba470

Please sign in to comment.