mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -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 );
|
void changeEffect( QgsPaintEffect* newEffect );
|
||||||
|
|
||||||
|
signals:
|
||||||
|
/**
|
||||||
|
* Emiited when something in the widget changes.
|
||||||
|
*/
|
||||||
|
void widgetChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/** Refreshes the widget to reflect the current state of the stack.
|
/** Refreshes the widget to reflect the current state of the stack.
|
||||||
@ -182,6 +188,13 @@ class QgsEffectStackCompactWidget : QWidget
|
|||||||
*/
|
*/
|
||||||
void setPreviewPicture( const QPicture& picture );
|
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:
|
signals:
|
||||||
|
|
||||||
/** Emitted when the paint effect properties change
|
/** Emitted when the paint effect properties change
|
||||||
|
@ -39,6 +39,18 @@ class QgsRendererV2PropertiesDialog : QDialog
|
|||||||
//! Apply and accept the changes for the dialog.
|
//! Apply and accept the changes for the dialog.
|
||||||
void onOK();
|
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:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Connect the given slot to the value changed event for the set of widgets
|
* Connect the given slot to the value changed event for the set of widgets
|
||||||
|
@ -39,12 +39,6 @@ class QgsRendererV2Widget : QWidget
|
|||||||
*/
|
*/
|
||||||
void applyChanges();
|
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:
|
signals:
|
||||||
/**
|
/**
|
||||||
* Emitted when expression context variables on the associated
|
* Emitted when expression context variables on the associated
|
||||||
@ -59,7 +53,12 @@ class QgsRendererV2Widget : QWidget
|
|||||||
*/
|
*/
|
||||||
void widgetChanged();
|
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 );
|
void panelOpened( bool opened );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Subclasses may provide the capability of changing multiple symbols at once by implementing the following two methods
|
/** 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&)*/
|
and by connecting the slot contextMenuViewCategories(const QPoint&)*/
|
||||||
|
@ -23,11 +23,32 @@ class QgsRendererWidgetContainer : QWidget
|
|||||||
QWidget* widget();
|
QWidget* widget();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Emitted when the container is accpeted and closed.
|
* @brief Emitted when the container is accpeted and closed.
|
||||||
* Listen to this to clean up the callers state.
|
* 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:
|
protected:
|
||||||
void keyPressEvent( QKeyEvent* event );
|
void keyPressEvent( QKeyEvent* event );
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "qgspainteffectwidget.h"
|
#include "qgspainteffectwidget.h"
|
||||||
#include "qgsapplication.h"
|
#include "qgsapplication.h"
|
||||||
#include "qgssymbollayerv2utils.h"
|
#include "qgssymbollayerv2utils.h"
|
||||||
|
#include "qgsrendererwidgetcontainer.h"
|
||||||
|
|
||||||
#include <QPicture>
|
#include <QPicture>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
@ -219,6 +220,7 @@ void QgsEffectStackPropertiesWidget::updatePreview()
|
|||||||
painter.end();
|
painter.end();
|
||||||
|
|
||||||
lblPreview->setPixmap( QPixmap::fromImage( previewImage ) );
|
lblPreview->setPixmap( QPixmap::fromImage( previewImage ) );
|
||||||
|
emit widgetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
EffectItem* QgsEffectStackPropertiesWidget::currentEffectItem()
|
EffectItem* QgsEffectStackPropertiesWidget::currentEffectItem()
|
||||||
@ -378,6 +380,7 @@ void QgsEffectStackPropertiesDialog::setPreviewPicture( const QPicture &picture
|
|||||||
|
|
||||||
QgsEffectStackCompactWidget::QgsEffectStackCompactWidget( QWidget *parent , QgsPaintEffect *effect )
|
QgsEffectStackCompactWidget::QgsEffectStackCompactWidget( QWidget *parent , QgsPaintEffect *effect )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
|
, mDockMode( false )
|
||||||
, mEnabledCheckBox( nullptr )
|
, mEnabledCheckBox( nullptr )
|
||||||
, mButton( nullptr )
|
, mButton( nullptr )
|
||||||
, mPreviewPicture( nullptr )
|
, mPreviewPicture( nullptr )
|
||||||
@ -447,6 +450,21 @@ void QgsEffectStackCompactWidget::showDialog()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
QgsEffectStack* clone = static_cast<QgsEffectStack*>( mStack->clone() );
|
QgsEffectStack* clone = static_cast<QgsEffectStack*>( mStack->clone() );
|
||||||
|
if ( mDockMode )
|
||||||
|
{
|
||||||
|
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 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
QgsEffectStackPropertiesDialog dialog( clone, this );
|
QgsEffectStackPropertiesDialog dialog( clone, this );
|
||||||
if ( mPreviewPicture )
|
if ( mPreviewPicture )
|
||||||
{
|
{
|
||||||
@ -459,6 +477,7 @@ void QgsEffectStackCompactWidget::showDialog()
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete clone;
|
delete clone;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsEffectStackCompactWidget::enableToggled( bool checked )
|
void QgsEffectStackCompactWidget::enableToggled( bool checked )
|
||||||
@ -472,3 +491,18 @@ void QgsEffectStackCompactWidget::enableToggled( bool checked )
|
|||||||
mButton->setEnabled( checked );
|
mButton->setEnabled( checked );
|
||||||
emit changed();
|
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 QgsPaintEffect;
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
class QToolButton;
|
class QToolButton;
|
||||||
|
class QgsRendererWidgetContainer;
|
||||||
|
|
||||||
/** \ingroup gui
|
/** \ingroup gui
|
||||||
* \class QgsEffectStackPropertiesWidget
|
* \class QgsEffectStackPropertiesWidget
|
||||||
@ -63,6 +64,12 @@ class GUI_EXPORT QgsEffectStackPropertiesWidget : public QWidget, private Ui::Qg
|
|||||||
*/
|
*/
|
||||||
void setPreviewPicture( const QPicture& picture );
|
void setPreviewPicture( const QPicture& picture );
|
||||||
|
|
||||||
|
signals:
|
||||||
|
/**
|
||||||
|
* Emiited when something in the widget changes.
|
||||||
|
*/
|
||||||
|
void widgetChanged();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
/** Moves the currently selected effect down in the stack.
|
/** 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( QWidget* parent = nullptr, QgsPaintEffect* effect = nullptr );
|
||||||
~QgsEffectStackCompactWidget();
|
~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
|
* @param effect QgsPaintEffect for modification by the widget. If the effect
|
||||||
* is not a QgsEffectStack, it will be automatically converted to an effect
|
* is not a QgsEffectStack, it will be automatically converted to an effect
|
||||||
* stack consisting of the original effect
|
* stack consisting of the original effect
|
||||||
@ -217,19 +224,32 @@ class GUI_EXPORT QgsEffectStackCompactWidget: public QWidget
|
|||||||
*/
|
*/
|
||||||
void setPreviewPicture( const QPicture &picture );
|
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:
|
signals:
|
||||||
|
|
||||||
/** Emitted when the paint effect properties change
|
/** Emitted when the paint effect properties change
|
||||||
*/
|
*/
|
||||||
void changed();
|
void changed();
|
||||||
|
|
||||||
|
void showPanel( QgsRendererWidgetContainer* widget );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void showDialog();
|
void showDialog();
|
||||||
|
|
||||||
void enableToggled( bool checked );
|
void enableToggled( bool checked );
|
||||||
|
|
||||||
|
void cleanUpContainer( QgsRendererWidgetContainer* container );
|
||||||
|
void updateFromContainer( QgsRendererWidgetContainer *container );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool mDockMode;
|
||||||
|
|
||||||
QgsEffectStack* mStack;
|
QgsEffectStack* mStack;
|
||||||
QCheckBox* mEnabledCheckBox;
|
QCheckBox* mEnabledCheckBox;
|
||||||
|
@ -119,6 +119,9 @@ QgsRendererV2PropertiesDialog::QgsRendererV2PropertiesDialog( QgsVectorLayer* la
|
|||||||
connect( checkboxEnableOrderBy, SIGNAL( toggled( bool ) ), btnOrderBy, SLOT( setEnabled( bool ) ) );
|
connect( checkboxEnableOrderBy, SIGNAL( toggled( bool ) ), btnOrderBy, SLOT( setEnabled( bool ) ) );
|
||||||
connect( checkboxEnableOrderBy, SIGNAL( toggled( bool ) ), lineEditOrderBy, SLOT( setEnabled( bool ) ) );
|
connect( checkboxEnableOrderBy, SIGNAL( toggled( bool ) ), lineEditOrderBy, SLOT( setEnabled( bool ) ) );
|
||||||
connect( btnOrderBy, SIGNAL( clicked( bool ) ), this, SLOT( showOrderByDialog() ) );
|
connect( btnOrderBy, SIGNAL( clicked( bool ) ), this, SLOT( showOrderByDialog() ) );
|
||||||
|
connect( mEffectWidget, SIGNAL( showPanel( QgsRendererWidgetContainer* ) ), this, SLOT( showPanel( QgsRendererWidgetContainer* ) ) );
|
||||||
|
|
||||||
|
mEffectWidget->setDockMode( true );
|
||||||
|
|
||||||
syncToLayer();
|
syncToLayer();
|
||||||
|
|
||||||
|
@ -79,6 +79,10 @@ class GUI_EXPORT QgsRendererV2PropertiesDialog : public QDialog, private Ui::Qgs
|
|||||||
*/
|
*/
|
||||||
void showPanel( QgsRendererWidgetContainer *container );
|
void showPanel( QgsRendererWidgetContainer *container );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the given panel in the stack of panels.
|
||||||
|
* @param container The container widget to close.
|
||||||
|
*/
|
||||||
void closePanel( QgsRendererWidgetContainer *container );
|
void closePanel( QgsRendererWidgetContainer *container );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -92,10 +92,9 @@ class GUI_EXPORT QgsRendererV2Widget : public QWidget
|
|||||||
*/
|
*/
|
||||||
void widgetChanged();
|
void widgetChanged();
|
||||||
|
|
||||||
/**
|
/** Shows a panel widget inside the renderer widget.
|
||||||
* @brief Emitted when a sub panel for the widget is opened.
|
* @param container widget panel to show
|
||||||
* The renderer can open inline sub panels instead of dialogs.
|
* @note added in QGIS 2.16
|
||||||
* @param opened True of the a sub panel is opened.
|
|
||||||
*/
|
*/
|
||||||
void showPanel( QgsRendererWidgetContainer* widget );
|
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.
|
* Listen to this to clean up the callers state.
|
||||||
*/
|
*/
|
||||||
void accepted( QgsRendererWidgetContainer* container );
|
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 );
|
void widgetChanged( QgsRendererWidgetContainer* conatiner );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accept the container. Causes accepted to be emiited.
|
||||||
|
*/
|
||||||
void accept();
|
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();
|
void emitWidgetChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user