Navigation Menu

Skip to content

Commit

Permalink
Use a checkable groupbox instead of an intermediate checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
DelazJ authored and github-actions[bot] committed Oct 31, 2021
1 parent 95f7829 commit 1008b1e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
21 changes: 5 additions & 16 deletions src/gui/vector/qgsvectorlayerlegendwidget.cpp
Expand Up @@ -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 );
Expand All @@ -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();
Expand Down Expand Up @@ -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() );
Expand Down Expand Up @@ -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 )
{
Expand Down
3 changes: 0 additions & 3 deletions src/gui/vector/qgsvectorlayerlegendwidget.h
Expand Up @@ -24,7 +24,6 @@
#include "qgstextformat.h"
#include "qgis_gui.h"

class QCheckBox;
class QgsImageSourceLineEdit;
class QLabel;
class QPushButton;
Expand Down Expand Up @@ -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:
Expand All @@ -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;
Expand Down

0 comments on commit 1008b1e

Please sign in to comment.