mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
[styledock] inline effects widget
This commit is contained in:
parent
ad5f970a2b
commit
4556a0d288
@ -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
|
||||
|
@ -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
|
||||
|
@ -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&)*/
|
||||
|
@ -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 );
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "qgspainteffectwidget.h"
|
||||
#include "qgsapplication.h"
|
||||
#include "qgssymbollayerv2utils.h"
|
||||
#include "qgsrendererwidgetcontainer.h"
|
||||
|
||||
#include <QPicture>
|
||||
#include <QPainter>
|
||||
@ -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<QgsEffectStack*>( 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<QgsEffectStackPropertiesWidget*>( container->widget() );
|
||||
*mStack = *widget->stack();
|
||||
emit changed();
|
||||
// delete widget->stack();
|
||||
}
|
||||
|
||||
void QgsEffectStackCompactWidget::updateFromContainer( QgsRendererWidgetContainer *container )
|
||||
{
|
||||
QgsEffectStackPropertiesWidget* widget = qobject_cast<QgsEffectStackPropertiesWidget*>( container->widget() );
|
||||
*mStack = *widget->stack();
|
||||
emit changed();
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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 );
|
||||
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user