Showing with 53 additions and 8 deletions.
  1. +19 −0 src/app/qgslabelinggui.cpp
  2. +1 −0 src/app/qgslabelinggui.h
  3. +5 −5 src/gui/qgscollapsiblegroupbox.cpp
  4. +2 −1 src/gui/qgscollapsiblegroupbox.h
  5. +26 −2 src/ui/qgslabelingguibase.ui
19 changes: 19 additions & 0 deletions src/app/qgslabelinggui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,31 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM
mBufferAttributesPropertiesGroupBox->setCollapsed( true );
mFontAttributePropertiesGroupBox->setCollapsed( true );

connect( groupBox_mPreview,
SIGNAL( collapsedStateChanged( QgsCollapsibleGroupBox* ) ),
this,
SLOT( collapseSample( QgsCollapsibleGroupBox* ) ) );
}

QgsLabelingGui::~QgsLabelingGui()
{
}

void QgsLabelingGui::collapseSample( QgsCollapsibleGroupBox* grpbx )
{
if ( grpbx->isCollapsed() )
{
QList<int> splitSizes = mFontPreviewSplitter->sizes();
if ( splitSizes[0] > grpbx->height() )
{
int delta = splitSizes[0] - grpbx->height();
splitSizes[0] -= delta;
splitSizes[1] += delta;
mFontPreviewSplitter->setSizes( splitSizes );
}
}
}

void QgsLabelingGui::apply()
{
QgsPalLayerSettings settings = layerSettings();
Expand Down
1 change: 1 addition & 0 deletions src/app/qgslabelinggui.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class QgsLabelingGui : public QWidget, private Ui::QgsLabelingGuiBase
QgsPalLayerSettings layerSettings();

public slots:
void collapseSample( QgsCollapsibleGroupBox* grpbx );
void apply();
void changeTextColor();
void changeTextFont();
Expand Down
10 changes: 5 additions & 5 deletions src/gui/qgscollapsiblegroupbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ void QgsCollapsibleGroupBox::showEvent( QShowEvent * event )
event->accept();
return;
}
mShown = true;

// check if groupbox was set to flat in Designer or in code
mInitFlat = isFlat();
Expand All @@ -111,11 +110,12 @@ void QgsCollapsibleGroupBox::showEvent( QShowEvent * event )
}
else
{
/* manually expanding (already default) on show may scroll scroll areas;
still emit signal for connections using expanded state */
// emit signal for connections using expanded state
emit collapsedStateChanged( this );
}

// set mShown after first setCollapsed call or expanded groupboxes
// will scroll scroll areas when first shown
mShown = true;
event->accept();
}

Expand Down Expand Up @@ -292,7 +292,7 @@ void QgsCollapsibleGroupBox::setCollapsed( bool collapse )
mCollapseButton->setIcon( collapse ? mExpandIcon : mCollapseIcon );

// if expanding and is in a QScrollArea, scroll down to make entire widget visible
if ( mScrollOnExpand && !collapse && mParentScrollArea )
if ( mShown && mScrollOnExpand && !collapse && mParentScrollArea )
{
// process events so entire widget is shown
QApplication::processEvents();
Expand Down
3 changes: 2 additions & 1 deletion src/gui/qgscollapsiblegroupbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class GUI_EXPORT QgsCollapsibleGroupBox : public QGroupBox
void setScrollOnExpand( bool scroll ) { mScrollOnExpand = scroll; }

signals:
void collapsedStateChanged( QWidget* );
/** Signal emitted when groupbox collapsed/expanded state is changed, and when first shown */
void collapsedStateChanged( QgsCollapsibleGroupBox* );

public slots:
void checkToggled( bool ckd );
Expand Down
28 changes: 26 additions & 2 deletions src/ui/qgslabelingguibase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@
<item row="0" column="0">
<widget class="QFrame" name="frameLabelWith">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<item>
<widget class="QCheckBox" name="chkEnableLabeling">
<property name="text">
Expand Down Expand Up @@ -154,10 +163,13 @@
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="handleWidth">
<number>10</number>
</property>
<property name="childrenCollapsible">
<bool>false</bool>
</property>
<widget class="QGroupBox" name="groupBox_mPreview">
<widget class="QgsCollapsibleGroupBox" name="groupBox_mPreview">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
Expand All @@ -173,11 +185,23 @@
<property name="title">
<string>Sample</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
Expand Down