diff --git a/python/gui/effects/qgseffectstackpropertieswidget.sip b/python/gui/effects/qgseffectstackpropertieswidget.sip index 1e019d85351..75e4c31ba9b 100644 --- a/python/gui/effects/qgseffectstackpropertieswidget.sip +++ b/python/gui/effects/qgseffectstackpropertieswidget.sip @@ -66,6 +66,12 @@ class QgsEffectStackPropertiesWidget : QWidget */ void changeEffect( QgsPaintEffect* newEffect ); + signals: + /** + * Emiited when something in the widget changes. + */ + void widgetChanged(); + protected: /** Refreshes the widget to reflect the current state of the stack. @@ -182,6 +188,13 @@ class QgsEffectStackCompactWidget : QWidget */ void setPreviewPicture( const QPicture& picture ); + /** + * Set the widget in dock mode. In dock mode the widget will emit a signal + * to show the effects selector instead of opening a dialog. + * @param dockMode True to enable dock mode. + */ + void setDockMode( bool dockMode ); + signals: /** Emitted when the paint effect properties change diff --git a/python/gui/symbology-ng/qgsrendererv2propertiesdialog.sip b/python/gui/symbology-ng/qgsrendererv2propertiesdialog.sip index 713b4f3bdae..01be315e6e4 100644 --- a/python/gui/symbology-ng/qgsrendererv2propertiesdialog.sip +++ b/python/gui/symbology-ng/qgsrendererv2propertiesdialog.sip @@ -39,6 +39,18 @@ class QgsRendererV2PropertiesDialog : QDialog //! Apply and accept the changes for the dialog. void onOK(); + /** Shows a panel widget inside the renderer widget. + * @param container widget panel to show + * @note added in QGIS 2.16 + */ + void showPanel( QgsRendererWidgetContainer *container ); + + /** + * Closes the given panel in the stack of panels. + * @param container The container widget to close. + */ + void closePanel( QgsRendererWidgetContainer *container ); + protected: /** * Connect the given slot to the value changed event for the set of widgets diff --git a/python/gui/symbology-ng/qgsrendererv2widget.sip b/python/gui/symbology-ng/qgsrendererv2widget.sip index 858f5b75c28..59883cf3cd9 100644 --- a/python/gui/symbology-ng/qgsrendererv2widget.sip +++ b/python/gui/symbology-ng/qgsrendererv2widget.sip @@ -39,12 +39,6 @@ class QgsRendererV2Widget : QWidget */ void applyChanges(); - /** Shows a panel widget inside the renderer widget. - * @param container widget panel to show - * @note added in QGIS 2.16 - */ - void showPanel( QWidget *container ); - signals: /** * Emitted when expression context variables on the associated @@ -59,7 +53,12 @@ class QgsRendererV2Widget : QWidget */ void widgetChanged(); + /** Shows a panel widget inside the renderer widget. + * @param container widget panel to show + * @note added in QGIS 2.16 + */ void panelOpened( bool opened ); + protected: /** Subclasses may provide the capability of changing multiple symbols at once by implementing the following two methods and by connecting the slot contextMenuViewCategories(const QPoint&)*/ diff --git a/python/gui/symbology-ng/qgsrendererwidgetcontainer.sip b/python/gui/symbology-ng/qgsrendererwidgetcontainer.sip index bd63aeb57e8..62cb20c8a9e 100644 --- a/python/gui/symbology-ng/qgsrendererwidgetcontainer.sip +++ b/python/gui/symbology-ng/qgsrendererwidgetcontainer.sip @@ -23,11 +23,32 @@ class QgsRendererWidgetContainer : QWidget QWidget* widget(); signals: + /** * @brief Emitted when the container is accpeted and closed. * Listen to this to clean up the callers state. */ - void accepted(); + void accepted( QgsRendererWidgetContainer* container ); + + /** + * Emiited when the internal widget changes state. + * @param conatiner The container holding the widget that changed state. + */ + void widgetChanged( QgsRendererWidgetContainer* conatiner ); + + public slots: + + /** + * Accept the container. Causes accepted to be emiited. + */ + void accept(); + + /** + * Fire the widgetChanged event on the container. Connect your widgets dirty signal to + * this slot to fire the and listen to widgetChanged to handle the event. + */ + void emitWidgetChanged(); + protected: void keyPressEvent( QKeyEvent* event ); diff --git a/src/gui/effects/qgseffectstackpropertieswidget.cpp b/src/gui/effects/qgseffectstackpropertieswidget.cpp index 7f6175fe37d..f3dfb771ea1 100644 --- a/src/gui/effects/qgseffectstackpropertieswidget.cpp +++ b/src/gui/effects/qgseffectstackpropertieswidget.cpp @@ -21,6 +21,7 @@ #include "qgspainteffectwidget.h" #include "qgsapplication.h" #include "qgssymbollayerv2utils.h" +#include "qgsrendererwidgetcontainer.h" #include #include @@ -219,6 +220,7 @@ void QgsEffectStackPropertiesWidget::updatePreview() painter.end(); lblPreview->setPixmap( QPixmap::fromImage( previewImage ) ); + emit widgetChanged(); } EffectItem* QgsEffectStackPropertiesWidget::currentEffectItem() @@ -378,6 +380,7 @@ void QgsEffectStackPropertiesDialog::setPreviewPicture( const QPicture &picture QgsEffectStackCompactWidget::QgsEffectStackCompactWidget( QWidget *parent , QgsPaintEffect *effect ) : QWidget( parent ) + , mDockMode( false ) , mEnabledCheckBox( nullptr ) , mButton( nullptr ) , mPreviewPicture( nullptr ) @@ -447,18 +450,34 @@ void QgsEffectStackCompactWidget::showDialog() return; QgsEffectStack* clone = static_cast( mStack->clone() ); - QgsEffectStackPropertiesDialog dialog( clone, this ); - if ( mPreviewPicture ) + if ( mDockMode ) { - dialog.setPreviewPicture( *mPreviewPicture ); + QgsEffectStackPropertiesWidget* widget = new QgsEffectStackPropertiesWidget( clone, nullptr ); + if ( mPreviewPicture ) + { + widget->setPreviewPicture( *mPreviewPicture ); + } + QgsRendererWidgetContainer* container = new QgsRendererWidgetContainer( widget, tr( "Effects Properties" ), nullptr ); + connect( widget, SIGNAL( widgetChanged() ), container, SLOT( emitWidgetChanged() ) ); + connect( container, SIGNAL( widgetChanged( QgsRendererWidgetContainer* ) ), this, SLOT( updateFromContainer( QgsRendererWidgetContainer* ) ) ); + connect( container, SIGNAL( accepted( QgsRendererWidgetContainer* ) ), this, SLOT( cleanUpContainer( QgsRendererWidgetContainer* ) ) ); + emit showPanel( container ); } - if ( dialog.exec() == QDialog::Accepted ) + else { - *mStack = *clone; - emit changed(); - } + QgsEffectStackPropertiesDialog dialog( clone, this ); + if ( mPreviewPicture ) + { + dialog.setPreviewPicture( *mPreviewPicture ); + } + if ( dialog.exec() == QDialog::Accepted ) + { + *mStack = *clone; + emit changed(); + } - delete clone; + delete clone; + } } void QgsEffectStackCompactWidget::enableToggled( bool checked ) @@ -472,3 +491,18 @@ void QgsEffectStackCompactWidget::enableToggled( bool checked ) mButton->setEnabled( checked ); emit changed(); } + +void QgsEffectStackCompactWidget::cleanUpContainer( QgsRendererWidgetContainer *container ) +{ + QgsEffectStackPropertiesWidget* widget = qobject_cast( container->widget() ); + *mStack = *widget->stack(); + emit changed(); +// delete widget->stack(); +} + +void QgsEffectStackCompactWidget::updateFromContainer( QgsRendererWidgetContainer *container ) +{ + QgsEffectStackPropertiesWidget* widget = qobject_cast( container->widget() ); + *mStack = *widget->stack(); + emit changed(); +} diff --git a/src/gui/effects/qgseffectstackpropertieswidget.h b/src/gui/effects/qgseffectstackpropertieswidget.h index 8167ee45f66..2fd21bb88f4 100644 --- a/src/gui/effects/qgseffectstackpropertieswidget.h +++ b/src/gui/effects/qgseffectstackpropertieswidget.h @@ -27,6 +27,7 @@ class EffectItem; class QgsPaintEffect; class QCheckBox; class QToolButton; +class QgsRendererWidgetContainer; /** \ingroup gui * \class QgsEffectStackPropertiesWidget @@ -63,6 +64,12 @@ class GUI_EXPORT QgsEffectStackPropertiesWidget : public QWidget, private Ui::Qg */ void setPreviewPicture( const QPicture& picture ); + signals: + /** + * Emiited when something in the widget changes. + */ + void widgetChanged(); + public slots: /** Moves the currently selected effect down in the stack. @@ -198,7 +205,7 @@ class GUI_EXPORT QgsEffectStackCompactWidget: public QWidget QgsEffectStackCompactWidget( QWidget* parent = nullptr, QgsPaintEffect* effect = nullptr ); ~QgsEffectStackCompactWidget(); - /** Sets paint effect attached to the widget + /** Sets paint effect attached to the widget, * @param effect QgsPaintEffect for modification by the widget. If the effect * is not a QgsEffectStack, it will be automatically converted to an effect * stack consisting of the original effect @@ -217,19 +224,32 @@ class GUI_EXPORT QgsEffectStackCompactWidget: public QWidget */ void setPreviewPicture( const QPicture &picture ); + /** + * Set the widget in dock mode. In dock mode the widget will emit a signal + * to show the effects selector instead of opening a dialog. + * @param dockMode True to enable dock mode. + */ + void setDockMode( bool dockMode ) { mDockMode = dockMode; } + signals: /** Emitted when the paint effect properties change */ void changed(); + void showPanel( QgsRendererWidgetContainer* widget ); + private slots: void showDialog(); void enableToggled( bool checked ); + void cleanUpContainer( QgsRendererWidgetContainer* container ); + void updateFromContainer( QgsRendererWidgetContainer *container ); + private: + bool mDockMode; QgsEffectStack* mStack; QCheckBox* mEnabledCheckBox; diff --git a/src/gui/symbology-ng/qgsrendererv2propertiesdialog.cpp b/src/gui/symbology-ng/qgsrendererv2propertiesdialog.cpp index dd7859c85c8..cdd3a9124ea 100644 --- a/src/gui/symbology-ng/qgsrendererv2propertiesdialog.cpp +++ b/src/gui/symbology-ng/qgsrendererv2propertiesdialog.cpp @@ -119,6 +119,9 @@ QgsRendererV2PropertiesDialog::QgsRendererV2PropertiesDialog( QgsVectorLayer* la connect( checkboxEnableOrderBy, SIGNAL( toggled( bool ) ), btnOrderBy, SLOT( setEnabled( bool ) ) ); connect( checkboxEnableOrderBy, SIGNAL( toggled( bool ) ), lineEditOrderBy, SLOT( setEnabled( bool ) ) ); connect( btnOrderBy, SIGNAL( clicked( bool ) ), this, SLOT( showOrderByDialog() ) ); + connect( mEffectWidget, SIGNAL( showPanel( QgsRendererWidgetContainer* ) ), this, SLOT( showPanel( QgsRendererWidgetContainer* ) ) ); + + mEffectWidget->setDockMode( true ); syncToLayer(); diff --git a/src/gui/symbology-ng/qgsrendererv2propertiesdialog.h b/src/gui/symbology-ng/qgsrendererv2propertiesdialog.h index 3578e92f260..010a421860e 100644 --- a/src/gui/symbology-ng/qgsrendererv2propertiesdialog.h +++ b/src/gui/symbology-ng/qgsrendererv2propertiesdialog.h @@ -79,6 +79,10 @@ class GUI_EXPORT QgsRendererV2PropertiesDialog : public QDialog, private Ui::Qgs */ void showPanel( QgsRendererWidgetContainer *container ); + /** + * Closes the given panel in the stack of panels. + * @param container The container widget to close. + */ void closePanel( QgsRendererWidgetContainer *container ); private slots: diff --git a/src/gui/symbology-ng/qgsrendererv2widget.h b/src/gui/symbology-ng/qgsrendererv2widget.h index 8d2761810d9..046d020fab6 100644 --- a/src/gui/symbology-ng/qgsrendererv2widget.h +++ b/src/gui/symbology-ng/qgsrendererv2widget.h @@ -92,10 +92,9 @@ class GUI_EXPORT QgsRendererV2Widget : public QWidget */ void widgetChanged(); - /** - * @brief Emitted when a sub panel for the widget is opened. - * The renderer can open inline sub panels instead of dialogs. - * @param opened True of the a sub panel is opened. + /** Shows a panel widget inside the renderer widget. + * @param container widget panel to show + * @note added in QGIS 2.16 */ void showPanel( QgsRendererWidgetContainer* widget ); diff --git a/src/gui/symbology-ng/qgsrendererwidgetcontainer.h b/src/gui/symbology-ng/qgsrendererwidgetcontainer.h index 0ff641e13e9..3b65a770146 100644 --- a/src/gui/symbology-ng/qgsrendererwidgetcontainer.h +++ b/src/gui/symbology-ng/qgsrendererwidgetcontainer.h @@ -49,11 +49,24 @@ class GUI_EXPORT QgsRendererWidgetContainer : public QWidget, private Ui::QgsRen * Listen to this to clean up the callers state. */ void accepted( QgsRendererWidgetContainer* container ); + + /** + * Emiited when the internal widget changes state. + * @param conatiner The container holding the widget that changed state. + */ void widgetChanged( QgsRendererWidgetContainer* conatiner ); public slots: + /** + * Accept the container. Causes accepted to be emiited. + */ void accept(); + + /** + * Fire the widgetChanged event on the container. Connect your widgets dirty signal to + * this slot to fire the and listen to widgetChanged to handle the event. + */ void emitWidgetChanged(); protected: