Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Split QgsLabelingGui off into QgsTextFormatWidget
New widget allows for setting just the formatting properties of text
- Loading branch information
Showing
with
2,471 additions
and 1,896 deletions.
- +2 −0 python/gui/gui.sip
- +73 −0 python/gui/qgssubstitutionlistwidget.sip
- +88 −0 python/gui/qgstextformatwidget.sip
- +0 −2 src/app/CMakeLists.txt
- +23 −1,321 src/app/qgslabelinggui.cpp
- +6 −95 src/app/qgslabelinggui.h
- +4 −0 src/gui/CMakeLists.txt
- 0 src/{app → gui}/qgssubstitutionlistwidget.cpp
- +5 −4 src/{app → gui}/qgssubstitutionlistwidget.h
- +1,378 −0 src/gui/qgstextformatwidget.cpp
- +198 −0 src/gui/qgstextformatwidget.h
- +504 −474 src/ui/{qgslabelingguibase.ui → qgstextformatwidgetbase.ui}
- +1 −0 tests/src/python/CMakeLists.txt
- +189 −0 tests/src/python/test_qgstextformatwidget.py
@@ -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; | ||
|
||
}; |
@@ -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(); | ||
}; |
Oops, something went wrong.