Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add config widget for polygon/polyline items
- Loading branch information
1 parent
44fe2a8
commit d92b067
Showing
9 changed files
with
532 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/*************************************************************************** | ||
qgslayoutpolygonwidget.cpp | ||
begin : March 2016 | ||
copyright : (C) 2016 Paul Blottiere, Oslandia | ||
email : paul dot blottiere at oslandia dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgslayoutpolygonwidget.h" | ||
#include "qgssymbolselectordialog.h" | ||
#include "qgsstyle.h" | ||
#include "qgslayout.h" | ||
#include "qgssymbollayerutils.h" | ||
#include "qgslayoutitemregistry.h" | ||
|
||
QgsLayoutPolygonWidget::QgsLayoutPolygonWidget( QgsLayoutItemPolygon *polygon ) | ||
: QgsLayoutItemBaseWidget( nullptr, polygon ) | ||
, mPolygon( polygon ) | ||
{ | ||
setupUi( this ); | ||
setPanelTitle( tr( "Polygon properties" ) ); | ||
|
||
//add widget for general composer item properties | ||
mItemPropertiesWidget = new QgsLayoutItemPropertiesWidget( this, polygon ); | ||
//shapes don't use background or frame, since the symbol style is set through a QgsSymbolSelectorWidget | ||
mItemPropertiesWidget->showBackgroundGroup( false ); | ||
mItemPropertiesWidget->showFrameGroup( false ); | ||
mainLayout->addWidget( mItemPropertiesWidget ); | ||
|
||
mPolygonStyleButton->setSymbolType( QgsSymbol::Fill ); | ||
connect( mPolygonStyleButton, &QgsSymbolButton::changed, this, &QgsLayoutPolygonWidget::symbolChanged ); | ||
|
||
if ( mPolygon ) | ||
{ | ||
connect( mPolygon, &QgsLayoutObject::changed, this, &QgsLayoutPolygonWidget::setGuiElementValues ); | ||
} | ||
|
||
setGuiElementValues(); | ||
#if 0 //TODO | ||
mShapeStyleButton->setLayer( atlasCoverageLayer() ); | ||
#endif | ||
} | ||
|
||
bool QgsLayoutPolygonWidget::setNewItem( QgsLayoutItem *item ) | ||
{ | ||
if ( item->type() != QgsLayoutItemRegistry::LayoutPolygon ) | ||
return false; | ||
|
||
mPolygon = qobject_cast< QgsLayoutItemPolygon * >( item ); | ||
mItemPropertiesWidget->setItem( mPolygon ); | ||
|
||
setGuiElementValues(); | ||
|
||
return true; | ||
} | ||
|
||
void QgsLayoutPolygonWidget::setGuiElementValues() | ||
{ | ||
if ( !mPolygon ) | ||
{ | ||
return; | ||
} | ||
|
||
whileBlocking( mPolygonStyleButton )->setSymbol( mPolygon->symbol()->clone() ); | ||
} | ||
|
||
void QgsLayoutPolygonWidget::symbolChanged() | ||
{ | ||
if ( !mPolygon ) | ||
return; | ||
|
||
mPolygon->layout()->undoStack()->beginCommand( mPolygon, tr( "Change Shape Style" ), QgsLayoutItem::UndoShapeStyle ); | ||
mPolygon->setSymbol( mPolygonStyleButton->clonedSymbol<QgsFillSymbol>() ); | ||
mPolygon->layout()->undoStack()->endCommand(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/*************************************************************************** | ||
qgslayoutpolygonwidget.h | ||
begin : March 2016 | ||
copyright : (C) 2016 Paul Blottiere, Oslandia | ||
email : paul dot blottiere at oslandia dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSLAYOUTPOLYGONWIDGET_H | ||
#define QGSLAYOUTPOLYGONWIDGET_H | ||
|
||
#include "ui_qgslayoutpolygonwidgetbase.h" | ||
#include "qgslayoutitemwidget.h" | ||
#include "qgslayoutitempolygon.h" | ||
|
||
/** | ||
* Input widget for QgsLayoutItemPolygon | ||
*/ | ||
class QgsLayoutPolygonWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayoutPolygonWidgetBase | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit QgsLayoutPolygonWidget( QgsLayoutItemPolygon *polygon ); | ||
|
||
protected: | ||
|
||
bool setNewItem( QgsLayoutItem *item ) override; | ||
|
||
private: | ||
QgsLayoutItemPolygon *mPolygon = nullptr; | ||
QgsLayoutItemPropertiesWidget *mItemPropertiesWidget = nullptr; | ||
|
||
//! Sets the GUI elements to the currentValues of mComposerShape | ||
void setGuiElementValues(); | ||
|
||
private slots: | ||
void symbolChanged(); | ||
}; | ||
|
||
#endif // QGSLAYOUTPOLYGONWIDGET_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/*************************************************************************** | ||
qgslayoutpolylinewidget.cpp | ||
begin : March 2016 | ||
copyright : (C) 2016 Paul Blottiere, Oslandia | ||
email : paul dot blottiere at oslandia dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgslayoutpolylinewidget.h" | ||
#include "qgssymbolselectordialog.h" | ||
#include "qgsstyle.h" | ||
#include "qgssymbollayerutils.h" | ||
#include "qgslayoutitemregistry.h" | ||
#include "qgslayout.h" | ||
|
||
QgsLayoutPolylineWidget::QgsLayoutPolylineWidget( QgsLayoutItemPolyline *polyline ) | ||
: QgsLayoutItemBaseWidget( nullptr, polyline ) | ||
, mPolyline( polyline ) | ||
{ | ||
setupUi( this ); | ||
setPanelTitle( tr( "Polyline properties" ) ); | ||
|
||
//add widget for general composer item properties | ||
mItemPropertiesWidget = new QgsLayoutItemPropertiesWidget( this, polyline ); | ||
//shapes don't use background or frame, since the symbol style is set through a QgsSymbolSelectorWidget | ||
mItemPropertiesWidget->showBackgroundGroup( false ); | ||
mItemPropertiesWidget->showFrameGroup( false ); | ||
mainLayout->addWidget( mItemPropertiesWidget ); | ||
|
||
mLineStyleButton->setSymbolType( QgsSymbol::Line ); | ||
connect( mLineStyleButton, &QgsSymbolButton::changed, this, &QgsLayoutPolylineWidget::symbolChanged ); | ||
|
||
if ( mPolyline ) | ||
{ | ||
connect( mPolyline, &QgsLayoutObject::changed, this, &QgsLayoutPolylineWidget::setGuiElementValues ); | ||
} | ||
setGuiElementValues(); | ||
|
||
#if 0 //TODO | ||
mShapeStyleButton->setLayer( atlasCoverageLayer() ); | ||
#endif | ||
} | ||
|
||
bool QgsLayoutPolylineWidget::setNewItem( QgsLayoutItem *item ) | ||
{ | ||
if ( item->type() != QgsLayoutItemRegistry::LayoutPolyline ) | ||
return false; | ||
|
||
mPolyline = qobject_cast< QgsLayoutItemPolyline * >( item ); | ||
mItemPropertiesWidget->setItem( mPolyline ); | ||
|
||
setGuiElementValues(); | ||
|
||
return true; | ||
} | ||
|
||
|
||
void QgsLayoutPolylineWidget::setGuiElementValues() | ||
{ | ||
if ( !mPolyline ) | ||
return; | ||
|
||
whileBlocking( mLineStyleButton )->setSymbol( mPolyline->symbol()->clone() ); | ||
} | ||
|
||
void QgsLayoutPolylineWidget::symbolChanged() | ||
{ | ||
if ( !mPolyline ) | ||
return; | ||
|
||
mPolyline->layout()->undoStack()->beginCommand( mPolyline, tr( "Change Shape Style" ), QgsLayoutItem::UndoShapeStyle ); | ||
mPolyline->setSymbol( mLineStyleButton->clonedSymbol<QgsLineSymbol>() ); | ||
mPolyline->layout()->undoStack()->endCommand(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/*************************************************************************** | ||
qgslayoutpolylinewidget.h | ||
begin : March 2016 | ||
copyright : (C) 2016 Paul Blottiere, Oslandia | ||
email : paul dot blottiere at oslandia dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSLAYOUTPOLYLINEWIDGET_H | ||
#define QGSLAYOUTPOLYLINEWIDGET_H | ||
|
||
#include "ui_qgslayoutpolylinewidgetbase.h" | ||
#include "qgslayoutitemwidget.h" | ||
#include "qgslayoutitempolyline.h" | ||
|
||
/** | ||
* Input widget for QgsLayoutItemPolyline | ||
*/ | ||
class QgsLayoutPolylineWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayoutPolylineWidgetBase | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit QgsLayoutPolylineWidget( QgsLayoutItemPolyline *polyline ); | ||
|
||
protected: | ||
|
||
bool setNewItem( QgsLayoutItem *item ) override; | ||
|
||
private: | ||
QgsLayoutItemPolyline *mPolyline = nullptr; | ||
QgsLayoutItemPropertiesWidget *mItemPropertiesWidget = nullptr; | ||
|
||
private slots: | ||
|
||
//! Sets the GUI elements to the currentValues of mComposerShape | ||
void setGuiElementValues(); | ||
|
||
private slots: | ||
void symbolChanged(); | ||
}; | ||
|
||
#endif // QGSLAYOUTPOLYLINEWIDGET_H |
Oops, something went wrong.