Skip to content
Permalink
Browse files

[composer] Port remaining symbol pickers to inline panels

  • Loading branch information
nyalldawson committed Oct 11, 2016
1 parent c36c242 commit 44546e8ebb3658fd9d0c4599ac5f2c4549d33708
@@ -575,6 +575,8 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
mGeneralDock = new QgsDockWidget( tr( "Composition" ), this );
mGeneralDock->setObjectName( "CompositionDock" );
mGeneralDock->setMinimumWidth( minDockWidth );
mGeneralPropertiesStack = new QgsPanelWidgetStack();
mGeneralDock->setWidget( mGeneralPropertiesStack );
mPanelMenu->addAction( mGeneralDock->toggleViewAction() );
mItemDock = new QgsDockWidget( tr( "Item properties" ), this );
mItemDock->setObjectName( "ItemDock" );
@@ -925,7 +927,7 @@ bool QgsComposer::loadFromTemplate( const QDomDocument& templateDoc, bool clearE
if ( result )
{
// update composition widget
QgsCompositionWidget* oldCompositionWidget = qobject_cast<QgsCompositionWidget *>( mGeneralDock->widget() );
QgsCompositionWidget* oldCompositionWidget = qobject_cast<QgsCompositionWidget *>( mGeneralPropertiesStack->takeMainPanel() );
delete oldCompositionWidget;
createCompositionWidget();
}
@@ -1548,7 +1550,7 @@ void QgsComposer::setComposition( QgsComposition* composition )
}

//delete composition widget
QgsCompositionWidget* oldCompositionWidget = qobject_cast<QgsCompositionWidget *>( mGeneralDock->widget() );
QgsCompositionWidget* oldCompositionWidget = qobject_cast<QgsCompositionWidget *>( mGeneralPropertiesStack->takeMainPanel() );
delete oldCompositionWidget;

deleteItemWidgets();
@@ -3514,10 +3516,11 @@ void QgsComposer::createCompositionWidget()
}

QgsCompositionWidget* compositionWidget = new QgsCompositionWidget( mGeneralDock, mComposition );
compositionWidget->setDockMode( true );
connect( mComposition, SIGNAL( paperSizeChanged() ), compositionWidget, SLOT( displayCompositionWidthHeight() ) );
connect( this, SIGNAL( printAsRasterChanged( bool ) ), compositionWidget, SLOT( setPrintAsRasterCheckBox( bool ) ) );
connect( compositionWidget, SIGNAL( pageOrientationChanged( QString ) ), this, SLOT( pageOrientationChanged( QString ) ) );
mGeneralDock->setWidget( compositionWidget );
mGeneralPropertiesStack->setMainPanel( compositionWidget );
}

void QgsComposer::readXml( const QDomElement& composerElem, const QDomDocument& doc, bool fromTemplate )
@@ -3532,7 +3535,7 @@ void QgsComposer::readXml( const QDomElement& composerElem, const QDomDocument&
}

//delete composition widget
QgsCompositionWidget* oldCompositionWidget = qobject_cast<QgsCompositionWidget *>( mGeneralDock->widget() );
QgsCompositionWidget* oldCompositionWidget = qobject_cast<QgsCompositionWidget *>( mGeneralPropertiesStack->takeMainPanel() );
delete oldCompositionWidget;

deleteItemWidgets();
@@ -602,6 +602,7 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
QgsPanelWidgetStack* mItemPropertiesStack;
QgsDockWidget* mUndoDock;
QgsDockWidget* mGeneralDock;
QgsPanelWidgetStack* mGeneralPropertiesStack;
QgsDockWidget* mAtlasDock;
QgsDockWidget* mItemsDock;

@@ -169,6 +169,24 @@ void QgsComposerArrowWidget::setGuiElementValues()
blockAllSignals( false );
}

void QgsComposerArrowWidget::updateLineStyleFromWidget()
{
QgsSymbolSelectorWidget* w = qobject_cast<QgsSymbolSelectorWidget*>( sender() );
mArrow->setLineSymbol( dynamic_cast< QgsLineSymbol* >( w->symbol()->clone() ) );
mArrow->update();
}

void QgsComposerArrowWidget::cleanUpLineStyleSelector( QgsPanelWidget* container )
{
QgsSymbolSelectorWidget* w = qobject_cast<QgsSymbolSelectorWidget*>( container );
if ( !w )
return;

delete w->symbol();
updateLineSymbolMarker();
mArrow->endCommand();
}

void QgsComposerArrowWidget::enableSvgInputElements( bool enable )
{
mStartMarkerLineEdit->setEnabled( enable );
@@ -310,25 +328,21 @@ void QgsComposerArrowWidget::on_mLineStyleButton_clicked()
return;
}

// use the atlas coverage layer, if any
QgsVectorLayer* coverageLayer = atlasCoverageLayer();

QgsLineSymbol* newSymbol = mArrow->lineSymbol()->clone();
QgsSymbolSelectorDialog d( newSymbol, QgsStyle::defaultStyle(), nullptr, this );
QgsExpressionContext context = mArrow->createExpressionContext();

QgsSymbolSelectorWidget* d = new QgsSymbolSelectorWidget( newSymbol, QgsStyle::defaultStyle(), coverageLayer, nullptr );
QgsSymbolWidgetContext symbolContext;
symbolContext.setExpressionContext( &context );
d.setContext( symbolContext );
d->setContext( symbolContext );

if ( d.exec() == QDialog::Accepted )
{
mArrow->beginCommand( tr( "Arrow line style changed" ) );
mArrow->setLineSymbol( newSymbol );
updateLineSymbolMarker();
mArrow->endCommand();
mArrow->update();
}
else
{
delete newSymbol;
}
connect( d, SIGNAL( widgetChanged() ), this, SLOT( updateLineStyleFromWidget() ) );
connect( d, SIGNAL( panelAccepted( QgsPanelWidget* ) ), this, SLOT( cleanUpLineStyleSelector( QgsPanelWidget* ) ) );
openPanel( d );
mArrow->beginCommand( tr( "Arrow line style changed" ) );
}

void QgsComposerArrowWidget::updateLineSymbolMarker()
@@ -57,6 +57,9 @@ class QgsComposerArrowWidget: public QgsComposerItemBaseWidget, private Ui::QgsC
void on_mLineStyleButton_clicked();

void setGuiElementValues();

void updateLineStyleFromWidget();
void cleanUpLineStyleSelector( QgsPanelWidget* container );
};

#endif // QGSCOMPOSERARROWWIDGET_H
@@ -31,7 +31,7 @@ QgsComposerPolygonWidget::QgsComposerPolygonWidget( QgsComposerPolygon* composer
//add widget for general composer item properties
QgsComposerItemWidget* itemPropertiesWidget = new QgsComposerItemWidget( this, composerPolygon );

//shapes don't use background or frame, since the symbol style is set through a QgsSymbolSelectorDialog
//shapes don't use background or frame, since the symbol style is set through a QgsSymbolSelectorWidget
itemPropertiesWidget->showBackgroundGroup( false );
itemPropertiesWidget->showFrameGroup( false );
mainLayout->addWidget( itemPropertiesWidget );
@@ -59,23 +59,18 @@ void QgsComposerPolygonWidget::on_mPolygonStyleButton_clicked()
// use the atlas coverage layer, if any
QgsVectorLayer* coverageLayer = atlasCoverageLayer();

QScopedPointer<QgsFillSymbol> newSymbol;
newSymbol.reset( mComposerPolygon->polygonStyleSymbol()->clone() );

QgsFillSymbol* newSymbol = mComposerPolygon->polygonStyleSymbol()->clone();
QgsExpressionContext context = mComposerPolygon->createExpressionContext();
QgsSymbolSelectorDialog d( newSymbol.data(), QgsStyle::defaultStyle(),
coverageLayer, this );

QgsSymbolSelectorWidget* d = new QgsSymbolSelectorWidget( newSymbol, QgsStyle::defaultStyle(), coverageLayer, nullptr );
QgsSymbolWidgetContext symbolContext;
symbolContext.setExpressionContext( &context );
d.setContext( symbolContext );
d->setContext( symbolContext );

if ( d.exec() == QDialog::Accepted )
{
mComposerPolygon->beginCommand( tr( "Polygon style changed" ) );
mComposerPolygon->setPolygonStyleSymbol( newSymbol.data() );
updatePolygonStyle();
mComposerPolygon->endCommand();
}
connect( d, SIGNAL( widgetChanged() ), this, SLOT( updateStyleFromWidget() ) );
connect( d, SIGNAL( panelAccepted( QgsPanelWidget* ) ), this, SLOT( cleanUpStyleSelector( QgsPanelWidget* ) ) );
openPanel( d );
mComposerPolygon->beginCommand( tr( "Polygon style changed" ) );
}

void QgsComposerPolygonWidget::setGuiElementValues()
@@ -88,6 +83,24 @@ void QgsComposerPolygonWidget::setGuiElementValues()
updatePolygonStyle();
}

void QgsComposerPolygonWidget::updateStyleFromWidget()
{
QgsSymbolSelectorWidget* w = qobject_cast<QgsSymbolSelectorWidget*>( sender() );
mComposerPolygon->setPolygonStyleSymbol( dynamic_cast< QgsFillSymbol* >( w->symbol() ) );
mComposerPolygon->update();
}

void QgsComposerPolygonWidget::cleanUpStyleSelector( QgsPanelWidget* container )
{
QgsSymbolSelectorWidget* w = qobject_cast<QgsSymbolSelectorWidget*>( container );
if ( !w )
return;

delete w->symbol();
updatePolygonStyle();
mComposerPolygon->endCommand();
}

void QgsComposerPolygonWidget::updatePolygonStyle()
{
if ( mComposerPolygon )
@@ -43,6 +43,9 @@ class QgsComposerPolygonWidget: public QgsComposerItemBaseWidget, private Ui::Qg

/** Sets the GUI elements to the currentValues of mComposerShape*/
void setGuiElementValues();

void updateStyleFromWidget();
void cleanUpStyleSelector( QgsPanelWidget* container );
};

#endif // QGSCOMPOSERPOLYGONWIDGET_H
@@ -51,23 +51,21 @@ void QgsComposerPolylineWidget::on_mLineStyleButton_clicked()
if ( !mComposerPolyline )
return;

QScopedPointer<QgsLineSymbol> newSymbol;
newSymbol.reset( mComposerPolyline->polylineStyleSymbol()->clone() );
// use the atlas coverage layer, if any
QgsVectorLayer* coverageLayer = atlasCoverageLayer();

QgsLineSymbol* newSymbol = mComposerPolyline->polylineStyleSymbol()->clone();
QgsExpressionContext context = mComposerPolyline->createExpressionContext();
QgsSymbolSelectorDialog d( newSymbol.data(), QgsStyle::defaultStyle(),
nullptr, this );

QgsSymbolSelectorWidget* d = new QgsSymbolSelectorWidget( newSymbol, QgsStyle::defaultStyle(), coverageLayer, nullptr );
QgsSymbolWidgetContext symbolContext;
symbolContext.setExpressionContext( &context );
d.setContext( symbolContext );
d->setContext( symbolContext );

if ( d.exec() == QDialog::Accepted )
{
mComposerPolyline->beginCommand( tr( "Polyline style changed" ) );
mComposerPolyline->setPolylineStyleSymbol( newSymbol.data() );
updatePolylineStyle();
mComposerPolyline->endCommand();
}
connect( d, SIGNAL( widgetChanged() ), this, SLOT( updateStyleFromWidget() ) );
connect( d, SIGNAL( panelAccepted( QgsPanelWidget* ) ), this, SLOT( cleanUpStyleSelector( QgsPanelWidget* ) ) );
openPanel( d );
mComposerPolyline->beginCommand( tr( "Polyline style changed" ) );
}

void QgsComposerPolylineWidget::setGuiElementValues()
@@ -78,6 +76,24 @@ void QgsComposerPolylineWidget::setGuiElementValues()
updatePolylineStyle();
}

void QgsComposerPolylineWidget::updateStyleFromWidget()
{
QgsSymbolSelectorWidget* w = qobject_cast<QgsSymbolSelectorWidget*>( sender() );
mComposerPolyline->setPolylineStyleSymbol( dynamic_cast< QgsLineSymbol* >( w->symbol() ) );
mComposerPolyline->update();
}

void QgsComposerPolylineWidget::cleanUpStyleSelector( QgsPanelWidget* container )
{
QgsSymbolSelectorWidget* w = qobject_cast<QgsSymbolSelectorWidget*>( container );
if ( !w )
return;

delete w->symbol();
updatePolylineStyle();
mComposerPolyline->endCommand();
}

void QgsComposerPolylineWidget::updatePolylineStyle()
{
if ( mComposerPolyline )
@@ -43,6 +43,9 @@ class QgsComposerPolylineWidget: public QgsComposerItemBaseWidget, private Ui::Q

/** Sets the GUI elements to the currentValues of mComposerShape*/
void setGuiElementValues();

void updateStyleFromWidget();
void cleanUpStyleSelector( QgsPanelWidget* container );
};

#endif // QGSCOMPOSERPOLYLINEWIDGET_H
@@ -28,9 +28,13 @@
#include <QWidget>
#include <QPrinter> //for screen resolution

QgsCompositionWidget::QgsCompositionWidget( QWidget* parent, QgsComposition* c ): QWidget( parent ), mComposition( c )
QgsCompositionWidget::QgsCompositionWidget( QWidget* parent, QgsComposition* c )\
:
QgsPanelWidget( parent )
, mComposition( c )
{
setupUi( this );
setPanelTitle( tr( "Composition properties" ) );
blockSignals( true );
createPaperEntries();

@@ -133,7 +137,9 @@ QgsCompositionWidget::QgsCompositionWidget( QWidget* parent, QgsComposition* c )
blockSignals( false );
}

QgsCompositionWidget::QgsCompositionWidget(): QWidget( nullptr ), mComposition( nullptr )
QgsCompositionWidget::QgsCompositionWidget()
: QgsPanelWidget( nullptr )
, mComposition( nullptr )
{
setupUi( this );
}
@@ -247,6 +253,23 @@ QgsComposerObject::DataDefinedProperty QgsCompositionWidget::ddPropertyForWidget
return QgsComposerObject::NoProperty;
}

void QgsCompositionWidget::updateStyleFromWidget()
{
QgsSymbolSelectorWidget* w = qobject_cast<QgsSymbolSelectorWidget*>( sender() );
mComposition->setPageStyleSymbol( dynamic_cast< QgsFillSymbol* >( w->symbol() ) );
mComposition->update();
}

void QgsCompositionWidget::cleanUpStyleSelector( QgsPanelWidget* container )
{
QgsSymbolSelectorWidget* w = qobject_cast<QgsSymbolSelectorWidget*>( container );
if ( !w )
return;

delete w->symbol();
updatePageStyle();
}

void QgsCompositionWidget::updateDataDefinedProperty()
{
QgsDataDefinedButton* ddButton = dynamic_cast<QgsDataDefinedButton*>( sender() );
@@ -572,17 +595,15 @@ void QgsCompositionWidget::on_mPageStyleButton_clicked()
newSymbol = new QgsFillSymbol();
}
QgsExpressionContext context = mComposition->createExpressionContext();
QgsSymbolSelectorDialog d( newSymbol, QgsStyle::defaultStyle(), coverageLayer, this );

QgsSymbolSelectorWidget* d = new QgsSymbolSelectorWidget( newSymbol, QgsStyle::defaultStyle(), coverageLayer, nullptr );
QgsSymbolWidgetContext symbolContext;
symbolContext.setExpressionContext( &context );
d.setContext( symbolContext );
d->setContext( symbolContext );

if ( d.exec() == QDialog::Accepted )
{
mComposition->setPageStyleSymbol( newSymbol );
updatePageStyle();
}
delete newSymbol;
connect( d, SIGNAL( widgetChanged() ), this, SLOT( updateStyleFromWidget() ) );
connect( d, SIGNAL( panelAccepted( QgsPanelWidget* ) ), this, SLOT( cleanUpStyleSelector( QgsPanelWidget* ) ) );
openPanel( d );
}

void QgsCompositionWidget::on_mResizePageButton_clicked()
@@ -15,6 +15,7 @@
***************************************************************************/

#include "ui_qgscompositionwidgetbase.h"
#include "qgspanelwidget.h"

class QgsComposition;
class QgsComposerMap;
@@ -34,7 +35,7 @@ struct QgsCompositionPaper
/** \ingroup app
* Input widget for QgsComposition
*/
class QgsCompositionWidget: public QWidget, private Ui::QgsCompositionWidgetBase
class QgsCompositionWidget: public QgsPanelWidget, private Ui::QgsCompositionWidgetBase
{
Q_OBJECT
public:
@@ -85,6 +86,9 @@ class QgsCompositionWidget: public QWidget, private Ui::QgsCompositionWidgetBase

void updateVariables();

void updateStyleFromWidget();
void cleanUpStyleSelector( QgsPanelWidget* container );

private:
QgsComposition* mComposition;
QMap<QString, QgsCompositionPaper> mPaperMap;
@@ -115,4 +119,5 @@ class QgsCompositionWidget: public QWidget, private Ui::QgsCompositionWidgetBase
/** Returns the data defined property corresponding to a data defined button widget*/
virtual QgsComposerObject::DataDefinedProperty ddPropertyForWidget( QgsDataDefinedButton* widget );


};

0 comments on commit 44546e8

Please sign in to comment.
You can’t perform that action at this time.