QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
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 QList< QgsTextFormat::Tab > mTabPositions;
175
177 QButtonGroup *mQuadrantBtnGrp = nullptr;
179 QButtonGroup *mDirectSymbBtnGrp = nullptr;
181 QButtonGroup *mUpsidedownBtnGrp = nullptr;
183 int mMinPixelLimit = 0;
184
186 QgsMapCanvas *mMapCanvas = nullptr;
187
190
193
195 QgsMapLayer *mLayer = nullptr;
196
197 QList<QgsSymbolLayerReference> mMaskedSymbolLayers;
198
201
202 protected slots:
203
205 void updateLinePlacementOptions();
206
208 void updatePlacementWidgets();
209
214 virtual void setFormatFromStyle( const QString &name, QgsStyle::StyleEntity type, const QString &stylePath );
215
219 virtual void saveFormat();
220
225 void updatePreview();
226
227#ifndef SIP_RUN
228
235 void populateDataDefinedButtons();
236#endif
237
238 private:
239 Mode mWidgetMode = Text;
240
241 QgsCharacterSelectorDialog *mCharDlg = nullptr;
242 std::unique_ptr< QgsPaintEffect > mBufferEffect;
243 std::unique_ptr< QgsPaintEffect > mMaskEffect;
244 std::unique_ptr< QgsPaintEffect > mBackgroundEffect;
245 QColor mPreviewBackgroundColor;
246
247 QFontDatabase mFontDB;
248
249 // background reference font
250 QFont mRefFont;
251 bool mDockMode = false;
252
253 bool mLoadSvgParams = false;
254 QgsExpressionContext mPreviewExpressionContext;
255
256 QMap<QgsPalLayerSettings::Property, QgsPropertyOverrideButton *> mButtons;
257
258 void initWidget();
259 void setWidgetMode( Mode mode );
260 void toggleDDButtons( bool visible );
261 void blockFontChangeSignals( bool blk );
262 void populateFontCapitalsComboBox();
263 void populateFontStyleComboBox();
264 void updateFont( const QFont &font );
265 void connectValueChanged( const QList<QWidget *> &widgets );
266
267 void registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsPalLayerSettings::Property key );
268
269 private slots:
270 void optionsStackedWidget_CurrentChanged( int indx );
271 void showBackgroundRadius( bool show );
272 void mShapeSVGPathLineEdit_textChanged( const QString &text );
273 void onSubstitutionsChanged( const QgsStringReplacementCollection &substitutions );
274 void previewScaleChanged( double scale );
275 void mFontSizeSpinBox_valueChanged( double d );
276 void mFontFamilyCmbBx_currentFontChanged( const QFont &f );
277 void mFontStyleComboBox_currentIndexChanged( const QString &text );
278 void mFontUnderlineBtn_toggled( bool ckd );
279 void mFontStrikethroughBtn_toggled( bool ckd );
280 void kerningToggled( bool checked );
281 void mFontWordSpacingSpinBox_valueChanged( double spacing );
282 void mFontLetterSpacingSpinBox_valueChanged( double spacing );
283 void mFontSizeUnitWidget_changed();
284 void mFontMinPixelSpinBox_valueChanged( int px );
285 void mFontMaxPixelSpinBox_valueChanged( int px );
286 void mBufferUnitWidget_changed();
287 void mMaskBufferUnitWidget_changed();
288 void mCoordXDDBtn_changed();
289 void mCoordXDDBtn_activated( bool isActive );
290 void mCoordYDDBtn_changed();
291 void mCoordYDDBtn_activated( bool isActive );
292 void mCoordPointDDBtn_changed();
293 void mCoordPointDDBtn_activated( bool isActive );
294 void mShapeTypeCmbBx_currentIndexChanged( int index );
295 void mShapeRotationCmbBx_currentIndexChanged( int index );
296 void mShapeSVGParamsBtn_clicked();
297 void mShapeSVGSelectorBtn_clicked();
298 void mPreviewTextEdit_textChanged( const QString &text );
299 void mPreviewTextBtn_clicked();
300 void mPreviewBackgroundBtn_colorChanged( const QColor &color );
301 void mDirectSymbLeftToolBtn_clicked();
302 void mDirectSymbRightToolBtn_clicked();
303 void chkLineOrientationDependent_toggled( bool active );
304 void mToolButtonConfigureSubstitutes_clicked();
305 void configureTabStops();
306 void collapseSample( bool collapse );
307 void changeTextColor( const QColor &color );
308 void changeBufferColor( const QColor &color );
309 void scrollPreview();
310 void updateSvgWidgets( const QString &svgPath );
311 void updateAvailableShadowPositions();
312 void updateProperty();
313 void createAuxiliaryField();
314 void updateShapeFrameStatus();
315 void updateBufferFrameStatus();
316 void updateShadowFrameStatus();
317 void updateCalloutFrameStatus();
318 void updateDataDefinedAlignment();
319 void overlapModeChanged();
320};
321
322
334class GUI_EXPORT QgsTextFormatDialog : public QDialog
335{
336 Q_OBJECT
337
338 public:
339
348 QgsTextFormatDialog( const QgsTextFormat &format, QgsMapCanvas *mapCanvas = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsMapLayer *layer = nullptr );
349
353 QgsTextFormat format() const;
354
359 void setContext( const QgsSymbolWidgetContext &context );
360
365 QDialogButtonBox *buttonBox() const;
366
367 private:
368
369 QgsTextFormatWidget *mFormatWidget = nullptr;
370 QDialogButtonBox *mButtonBox = nullptr;
371
372 private slots:
373 void showHelp();
374
375};
376
389{
390 Q_OBJECT
391
392 public:
393
401 QgsTextFormatPanelWidget( const QgsTextFormat &format, QgsMapCanvas *mapCanvas = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr, QgsMapLayer *layer = nullptr );
402
406 QgsTextFormat format() const;
407
413 void setFormat( const QgsTextFormat &format );
414
419 void setContext( const QgsSymbolWidgetContext &context );
420
421 void setDockMode( bool dockMode ) override;
422
423 private:
424
425 QgsTextFormatWidget *mFormatWidget = nullptr;
426 bool mBlockSignals = false;
427};
428
429#endif //QGSTEXTFORMATWIDGET_H
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:337
@ 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.
Base class for all map layer types.
Definition qgsmaplayer.h:76
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:203
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< QgsTextFormat::Tab > mTabPositions
Tab positions.
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.
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53