Skip to content

Commit

Permalink
Split QgsLabelingGui off into QgsTextFormatWidget
Browse files Browse the repository at this point in the history
New widget allows for setting just the formatting properties
of text
  • Loading branch information
nyalldawson committed Oct 24, 2016
1 parent 169b367 commit 76c12ba
Show file tree
Hide file tree
Showing 14 changed files with 2,471 additions and 1,896 deletions.
2 changes: 2 additions & 0 deletions python/gui/gui.sip
Expand Up @@ -156,11 +156,13 @@
%Include qgsslider.sip
%Include qgssourceselectdialog.sip
%Include qgssublayersdialog.sip
%Include qgssubstitutionlistwidget.sip
%Include qgssvgannotationitem.sip
%Include qgstablewidgetbase.sip
%Include qgstabwidget.sip
%Include qgstablewidgetitem.sip
%Include qgstextannotationitem.sip
%Include qgstextformatwidget.sip
%Include qgstextpreview.sip
%Include qgstrackedvectorlayertools.sip
%Include qgstreewidgetitem.sip
Expand Down
73 changes: 73 additions & 0 deletions python/gui/qgssubstitutionlistwidget.sip
@@ -0,0 +1,73 @@
/** \class QgsSubstitutionListWidget
* \ingroup gui
* A widget which allows users to specify a list of substitutions to apply to a string, with
* options for exporting and importing substitution lists.
* \note added in QGIS 3.0
* \see QgsSubstitutionListDialog
*/

class QgsSubstitutionListWidget : public QgsPanelWidget
{
%TypeHeaderCode
#include <qgssubstitutionlistwidget.h>
%End

public:

/** Constructor for QgsSubstitutionListWidget.
* @param parent parent widget
*/
QgsSubstitutionListWidget( QWidget* parent /TransferThis/ = nullptr );

/** Sets the list of substitutions to show in the widget.
* @param substitutions substitution list
* @see substitutions()
*/
void setSubstitutions( const QgsStringReplacementCollection& substitutions );

/** Returns the list of substitutions currently defined by the widget.
* @see setSubstitutions()
*/
QgsStringReplacementCollection substitutions() const;

signals:

//! Emitted when the substitution definitions change.
void substitutionsChanged( const QgsStringReplacementCollection& substitutions );

};



/** \class QgsSubstitutionListDialog
* \ingroup gui
* A dialog which allows users to specify a list of substitutions to apply to a string, with
* options for exporting and importing substitution lists.
* \see QgsSubstitutionListWidget
*/

class QgsSubstitutionListDialog : public QDialog
{
%TypeHeaderCode
#include <qgssubstitutionlistwidget.h>
%End

public:

/** Constructor for QgsSubstitutionListDialog.
* @param parent parent widget
*/
QgsSubstitutionListDialog( QWidget* parent /TransferThis/ = nullptr );

/** Sets the list of substitutions to show in the dialog.
* @param substitutions substitution list
* @see substitutions()
*/
void setSubstitutions( const QgsStringReplacementCollection& substitutions );

/** Returns the list of substitutions currently defined by the dialog.
* @see setSubstitutions()
*/
QgsStringReplacementCollection substitutions() const;

};
88 changes: 88 additions & 0 deletions python/gui/qgstextformatwidget.sip
@@ -0,0 +1,88 @@
/** \class QgsTextFormatWidget
* \ingroup gui
* A widget for customising text formatting settings.
*
* QgsTextFormatWidget provides a widget for controlling the appearance of text rendered
* using QgsTextRenderer. The preview includes all settings contained within
* a QgsTextFormat, including shadow, background and buffer.
*
* Additionally, the widget can handle labeling settings due to the large overlap between
* the text renderer settings and the labeling settings. This mode is possible by
* subclassing QgsTextFormatWidget and calling the protected constructor with a mode
* of Labeling.
*
* @note Added in QGIS 3.0
*/

class QgsTextFormatWidget : public QgsPanelWidget
{
%TypeHeaderCode
#include <qgstextformatwidget.h>
%End

public:

/** Constructor for QgsTextFormatWidget.
* @param format initial formatting settings to show in widget
* @param mapCanvas associated map canvas
* @param parent parent widget
*/
QgsTextFormatWidget( const QgsTextFormat& format = QgsTextFormat(), QgsMapCanvas* mapCanvas = nullptr, QWidget* parent /TransferThis/ = nullptr );

~QgsTextFormatWidget();

/** Returns the current formatting settings defined by the widget.
*/
QgsTextFormat format() const;

public slots:

/** Sets whether the widget should be shown in a compact dock mode.
* @param enabled set to true to show in dock mode.
*/
void setDockMode( bool enabled );

signals:

//! Emitted when the text format defined by the widget changes
void widgetChanged();

protected:

//! Widget mode
enum Mode
{
Text, //!< Default mode, show text formatting settings only
Labeling, //!< Show labeling settings in addition to text formatting settings
};

/** Constructor for QgsTextFormatWidget.
* @param mapCanvas associated map canvas
* @param parent parent widget
* @param mode widget mode
*/
QgsTextFormatWidget( QgsMapCanvas* mapCanvas, QWidget* parent /TransferThis/, Mode mode );

/** Updates the widget's state to reflect the settings in a QgsTextFormat.
* @param format source format
*/
void updateWidgetForFormat( const QgsTextFormat& format );

/** Sets the background color for the text preview widget.
* @param color background color
*/
void setPreviewBackground( const QColor& color );

/** Controls whether data defined alignment buttons are enabled.
* @param enable set to true to enable alignment controls
*/
void enableDataDefinedAlignment( bool enable );

protected slots:

//! Updates line placement options to reflect current state of widget
void updateLinePlacementOptions();

//! Updates label placement options to reflect current state of widget
void updatePlacementWidgets();
};
2 changes: 0 additions & 2 deletions src/app/CMakeLists.txt
Expand Up @@ -116,7 +116,6 @@ SET(QGIS_APP_SRCS
qgsrelationadddlg.cpp
qgsselectbyformdialog.cpp
qgsstatisticalsummarydockwidget.cpp
qgssubstitutionlistwidget.cpp
qgstextannotationdialog.cpp
qgssvgannotationdialog.cpp
qgsundowidget.cpp
Expand Down Expand Up @@ -293,7 +292,6 @@ SET (QGIS_APP_MOC_HDRS
qgsselectbyformdialog.h
qgssponsors.h
qgsstatisticalsummarydockwidget.h
qgssubstitutionlistwidget.h
qgssvgannotationdialog.h
qgstextannotationdialog.h
qgstipgui.h
Expand Down

0 comments on commit 76c12ba

Please sign in to comment.