QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
qgstextformatwidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgstextformatwidget.h
3 ---------------------
4 begin : June 2009
5 copyright : (C) Martin Dobias
6 email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16
17#ifndef QGSTEXTFORMATWIDGET_H
18#define QGSTEXTFORMATWIDGET_H
19
20#include "ui_qgstextformatwidgetbase.h"
21#include "qgis_sip.h"
22#include "qgstextformat.h"
23#include "qgsstringutils.h"
24#include "qgsguiutils.h"
26#include <QFontDatabase>
27#include "qgis_gui.h"
28
29class QgsMapCanvas;
31
32
49class GUI_EXPORT QgsTextFormatWidget : public QWidget, public QgsExpressionContextGenerator, protected Ui::QgsTextFormatWidgetBase
50{
51 Q_OBJECT
52 Q_PROPERTY( QgsTextFormat format READ format )
53
54 public:
55
63 QgsTextFormatWidget( const QgsTextFormat &format = QgsTextFormat(), QgsMapCanvas *mapCanvas = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr,
64 QgsMapLayer *layer = nullptr );
65
66 ~QgsTextFormatWidget() override;
67
74 QgsTextFormat format( bool includeDataDefinedProperties = true ) const;
75
80 void setFormat( const QgsTextFormat &format );
81
87 virtual void setContext( const QgsSymbolWidgetContext &context );
88
94 QgsSymbolWidgetContext context() const;
95
103 void deactivateField( QgsPalLayerSettings::Property key );
104
105 public slots:
106
111 void setDockMode( bool enabled );
112
113 signals:
114
117
123
124 protected:
125
127 enum Mode
128 {
129 Text = 0,
131 };
132
140 QgsTextFormatWidget( QgsMapCanvas *mapCanvas, QWidget *parent SIP_TRANSFERTHIS, Mode mode, QgsMapLayer *layer = nullptr );
141
146 void updateWidgetForFormat( const QgsTextFormat &format );
147
152 void setPreviewBackground( const QColor &color );
153
159 Q_DECL_DEPRECATED void enableDataDefinedAlignment( bool enable ) SIP_DEPRECATED { Q_UNUSED( enable ) }
160
162
169 Qgis::GeometryType labelGeometryType() const;
170
174 QButtonGroup *mQuadrantBtnGrp = nullptr;
176 QButtonGroup *mDirectSymbBtnGrp = nullptr;
178 QButtonGroup *mUpsidedownBtnGrp = nullptr;
180 int mMinPixelLimit = 0;
181
183 QgsMapCanvas *mMapCanvas = nullptr;
184
187
190
192 QgsMapLayer *mLayer = nullptr;
193
194 QList<QgsSymbolLayerReference> mMaskedSymbolLayers;
195
198
199 protected slots:
200
202 void updateLinePlacementOptions();
203
205 void updatePlacementWidgets();
206
211 virtual void setFormatFromStyle( const QString &name, QgsStyle::StyleEntity type, const QString &stylePath );
212
216 virtual void saveFormat();
217
222 void updatePreview();
223
224#ifndef SIP_RUN
225
232 void populateDataDefinedButtons();
233#endif
234
235 private:
236 Mode mWidgetMode = Text;
237
238 QgsCharacterSelectorDialog *mCharDlg = nullptr;
239 std::unique_ptr< QgsPaintEffect > mBufferEffect;
240 std::unique_ptr< QgsPaintEffect > mMaskEffect;
241 std::unique_ptr< QgsPaintEffect > mBackgroundEffect;
242 QColor mPreviewBackgroundColor;
243
244 QFontDatabase mFontDB;
245
246 // background reference font
247 QFont mRefFont;
248 bool mDockMode = false;
249
250 bool mLoadSvgParams = false;
251 QgsExpressionContext mPreviewExpressionContext;
252
253 QMap<QgsPalLayerSettings::Property, QgsPropertyOverrideButton *> mButtons;
254
255 void initWidget();
256 void setWidgetMode( Mode mode );
257 void toggleDDButtons( bool visible );
258 void blockFontChangeSignals( bool blk );
259 void populateFontCapitalsComboBox();
260 void populateFontStyleComboBox();
261 void updateFont( const QFont &font );
262 void connectValueChanged( const QList<QWidget *> &widgets, const char *slot );
263
264 void registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsPalLayerSettings::Property key );
265
266 private slots:
267 void optionsStackedWidget_CurrentChanged( int indx );
268 void showBackgroundRadius( bool show );
269 void mShapeSVGPathLineEdit_textChanged( const QString &text );
270 void onSubstitutionsChanged( const QgsStringReplacementCollection &substitutions );
271 void previewScaleChanged( double scale );
272 void mFontSizeSpinBox_valueChanged( double d );
273 void mFontFamilyCmbBx_currentFontChanged( const QFont &f );
274 void mFontStyleComboBox_currentIndexChanged( const QString &text );
275 void mFontUnderlineBtn_toggled( bool ckd );
276 void mFontStrikethroughBtn_toggled( bool ckd );
277 void kerningToggled( bool checked );
278 void mFontWordSpacingSpinBox_valueChanged( double spacing );
279 void mFontLetterSpacingSpinBox_valueChanged( double spacing );
280 void mFontSizeUnitWidget_changed();
281 void mFontMinPixelSpinBox_valueChanged( int px );
282 void mFontMaxPixelSpinBox_valueChanged( int px );
283 void mBufferUnitWidget_changed();
284 void mMaskBufferUnitWidget_changed();
285 void mCoordXDDBtn_changed();
286 void mCoordXDDBtn_activated( bool isActive );
287 void mCoordYDDBtn_changed();
288 void mCoordYDDBtn_activated( bool isActive );
289 void mCoordPointDDBtn_changed();
290 void mCoordPointDDBtn_activated( bool isActive );
291 void mShapeTypeCmbBx_currentIndexChanged( int index );
292 void mShapeRotationCmbBx_currentIndexChanged( int index );
293 void mShapeSVGParamsBtn_clicked();
294 void mShapeSVGSelectorBtn_clicked();
295 void mPreviewTextEdit_textChanged( const QString &text );
296 void mPreviewTextBtn_clicked();
297 void mPreviewBackgroundBtn_colorChanged( const QColor &color );
298 void mDirectSymbLeftToolBtn_clicked();
299 void mDirectSymbRightToolBtn_clicked();
300 void chkLineOrientationDependent_toggled( bool active );
301 void mToolButtonConfigureSubstitutes_clicked();
302 void collapseSample( bool collapse );
303 void changeTextColor( const QColor &color );
304 void changeBufferColor( const QColor &color );
305 void scrollPreview();
306 void updateSvgWidgets( const QString &svgPath );
307 void updateAvailableShadowPositions();
308 void updateProperty();
309 void createAuxiliaryField();
310 void updateShapeFrameStatus();
311 void updateBufferFrameStatus();
312 void updateShadowFrameStatus();
313 void updateCalloutFrameStatus();
314 void updateDataDefinedAlignment();
315 void overlapModeChanged();
316};
317
318
330class GUI_EXPORT QgsTextFormatDialog : public QDialog
331{
332 Q_OBJECT
333
334 public:
335
344 QgsTextFormatDialog( const QgsTextFormat &format, QgsMapCanvas *mapCanvas = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsMapLayer *layer = nullptr );
345
349 QgsTextFormat format() const;
350
355 void setContext( const QgsSymbolWidgetContext &context );
356
361 QDialogButtonBox *buttonBox() const;
362
363 private:
364
365 QgsTextFormatWidget *mFormatWidget = nullptr;
366 QDialogButtonBox *mButtonBox = nullptr;
367
368 private slots:
369 void showHelp();
370
371};
372
385{
386 Q_OBJECT
387
388 public:
389
397 QgsTextFormatPanelWidget( const QgsTextFormat &format, QgsMapCanvas *mapCanvas = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr, QgsMapLayer *layer = nullptr );
398
402 QgsTextFormat format() const;
403
409 void setFormat( const QgsTextFormat &format );
410
415 void setContext( const QgsSymbolWidgetContext &context );
416
417 void setDockMode( bool dockMode ) override;
418
419 private:
420
421 QgsTextFormatWidget *mFormatWidget = nullptr;
422 bool mBlockSignals = false;
423};
424
425#endif //QGSTEXTFORMATWIDGET_H
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition: qgis.h:255
@ Unknown
Unknown types.
A dialog for selecting a single character from a single font.
Abstract interface for generating an expression context.
virtual QgsExpressionContext createExpressionContext() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:93
Base class for all map layer types.
Definition: qgsmaplayer.h:75
Property
Data definable properties.
Wrapper widget for existing widgets which can't have the inheritance tree changed,...
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
A button for controlling property overrides which may apply to a widget.
A collection of string replacements (specified using QgsStringReplacement objects).
StyleEntity
Enum for Entities involved in a style.
Definition: qgsstyle.h:179
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
A simple dialog for customizing text formatting settings.
A panel widget for customizing text formatting settings.
A widget for customizing text formatting settings.
QList< QgsSymbolLayerReference > mMaskedSymbolLayers
void widgetChanged()
Emitted when the text format defined by the widget changes.
Q_DECL_DEPRECATED void enableDataDefinedAlignment(bool enable)
Update the enabled state of the data defined alignment buttons.
QgsSymbolWidgetContext mContext
Context in which widget is shown.
void auxiliaryFieldCreated()
Emitted when an auxiliary field is created in the widget.
QgsStringReplacementCollection mSubstitutions
Text substitution list.
@ Labeling
Show labeling settings in addition to text formatting settings.
QgsPropertyCollection mDataDefinedProperties
Data defined properties as defined in the widget.
Container for all settings relating to text rendering.
Definition: qgstextformat.h:41
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53