QGIS API Documentation 3.41.0-Master (af5edcb665c)
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:
62 QgsTextFormatWidget( const QgsTextFormat &format = QgsTextFormat(), QgsMapCanvas *mapCanvas = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr, QgsMapLayer *layer = nullptr );
63
64 ~QgsTextFormatWidget() override;
65
72 QgsTextFormat format( bool includeDataDefinedProperties = true ) const;
73
78 void setFormat( const QgsTextFormat &format );
79
85 virtual void setContext( const QgsSymbolWidgetContext &context );
86
92 QgsSymbolWidgetContext context() const;
93
101 void deactivateField( QgsPalLayerSettings::Property key );
102
103 public slots:
104
109 void setDockMode( bool enabled );
110
111 signals:
112
115
121
122 protected:
124 enum Mode
125 {
126 Text = 0,
128 };
129
137 QgsTextFormatWidget( QgsMapCanvas *mapCanvas, QWidget *parent SIP_TRANSFERTHIS, Mode mode, QgsMapLayer *layer = nullptr );
138
143 void updateWidgetForFormat( const QgsTextFormat &format );
144
149 void setPreviewBackground( const QColor &color );
150
156 Q_DECL_DEPRECATED void enableDataDefinedAlignment( bool enable ) SIP_DEPRECATED { Q_UNUSED( enable ) }
157
159
166 Qgis::GeometryType labelGeometryType() const;
167
173 void setPropertyOverrideButtonsVisible( bool visible );
174
178 QList<QgsTextFormat::Tab> mTabPositions;
179
181 QButtonGroup *mQuadrantBtnGrp = nullptr;
183 QButtonGroup *mDirectSymbBtnGrp = nullptr;
185 QButtonGroup *mUpsidedownBtnGrp = nullptr;
187 int mMinPixelLimit = 0;
188
190 QgsMapCanvas *mMapCanvas = nullptr;
191
194
197
199 QgsMapLayer *mLayer = nullptr;
200
201 QList<QgsSymbolLayerReference> mMaskedSymbolLayers;
202
205
207 QListWidgetItem *mTextItem = nullptr;
209 QListWidgetItem *mFormattingItem = nullptr;
211 QListWidgetItem *mBufferItem = nullptr;
213 QListWidgetItem *mMaskItem = nullptr;
215 QListWidgetItem *mBackgroundItem = nullptr;
217 QListWidgetItem *mShadowItem = nullptr;
219 QListWidgetItem *mCalloutItem = nullptr;
221 QListWidgetItem *mPlacementItem = nullptr;
223 QListWidgetItem *mRenderingItem = nullptr;
224
225 protected slots:
226
228 void updateLinePlacementOptions();
229
231 void updatePlacementWidgets();
232
237 virtual void setFormatFromStyle( const QString &name, QgsStyle::StyleEntity type, const QString &stylePath );
238
242 virtual void saveFormat();
243
248 void updatePreview();
249
250#ifndef SIP_RUN
251
258 void populateDataDefinedButtons();
259#endif
260
261 private:
262 Mode mWidgetMode = Text;
263
264 QgsCharacterSelectorDialog *mCharDlg = nullptr;
265 std::unique_ptr<QgsPaintEffect> mBufferEffect;
266 std::unique_ptr<QgsPaintEffect> mMaskEffect;
267 std::unique_ptr<QgsPaintEffect> mBackgroundEffect;
268 QColor mPreviewBackgroundColor;
269
270 QFontDatabase mFontDB;
271
272 // background reference font
273 QFont mRefFont;
274 bool mDockMode = false;
275
276 bool mLoadSvgParams = false;
277 QgsExpressionContext mPreviewExpressionContext;
278
279 QMap<QgsPalLayerSettings::Property, QgsPropertyOverrideButton *> mButtons;
280
281 void initWidget();
282 void setWidgetMode( Mode mode );
283 void blockFontChangeSignals( bool blk );
284 void populateFontCapitalsComboBox();
285 void populateFontStyleComboBox();
286 void updateFont( const QFont &font );
287 void connectValueChanged( const QList<QWidget *> &widgets );
288
289 void registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsPalLayerSettings::Property key );
290
291 private slots:
292 void optionsStackedWidget_CurrentChanged( int indx );
293 void showBackgroundRadius( bool show );
294 void mShapeSVGPathLineEdit_textChanged( const QString &text );
295 void onSubstitutionsChanged( const QgsStringReplacementCollection &substitutions );
296 void previewScaleChanged( double scale );
297 void mFontSizeSpinBox_valueChanged( double d );
298 void mFontFamilyCmbBx_currentFontChanged( const QFont &f );
299 void mFontStyleComboBox_currentIndexChanged( const QString &text );
300 void mFontUnderlineBtn_toggled( bool ckd );
301 void mFontStrikethroughBtn_toggled( bool ckd );
302 void kerningToggled( bool checked );
303 void mFontWordSpacingSpinBox_valueChanged( double spacing );
304 void mFontLetterSpacingSpinBox_valueChanged( double spacing );
305 void mFontSizeUnitWidget_changed();
306 void mFontMinPixelSpinBox_valueChanged( int px );
307 void mFontMaxPixelSpinBox_valueChanged( int px );
308 void mBufferUnitWidget_changed();
309 void mMaskBufferUnitWidget_changed();
310 void mCoordXDDBtn_changed();
311 void mCoordXDDBtn_activated( bool isActive );
312 void mCoordYDDBtn_changed();
313 void mCoordYDDBtn_activated( bool isActive );
314 void mCoordPointDDBtn_changed();
315 void mCoordPointDDBtn_activated( bool isActive );
316 void mShapeTypeCmbBx_currentIndexChanged( int index );
317 void mShapeRotationCmbBx_currentIndexChanged( int index );
318 void mShapeSVGParamsBtn_clicked();
319 void mShapeSVGSelectorBtn_clicked();
320 void mPreviewTextEdit_textChanged( const QString &text );
321 void mPreviewTextBtn_clicked();
322 void mPreviewBackgroundBtn_colorChanged( const QColor &color );
323 void mDirectSymbLeftToolBtn_clicked();
324 void mDirectSymbRightToolBtn_clicked();
325 void chkLineOrientationDependent_toggled( bool active );
326 void mToolButtonConfigureSubstitutes_clicked();
327 void configureTabStops();
328 void collapseSample( bool collapse );
329 void changeTextColor( const QColor &color );
330 void changeBufferColor( const QColor &color );
331 void scrollPreview();
332 void updateSvgWidgets( const QString &svgPath );
333 void updateAvailableShadowPositions();
334 void updateProperty();
335 void createAuxiliaryField();
336 void updateShapeFrameStatus();
337 void updateBufferFrameStatus();
338 void updateShadowFrameStatus();
339 void updateCalloutFrameStatus();
340 void updateDataDefinedAlignment();
341 void overlapModeChanged();
342};
343
344
356class GUI_EXPORT QgsTextFormatDialog : public QDialog
357{
358 Q_OBJECT
359
360 public:
369 QgsTextFormatDialog( const QgsTextFormat &format, QgsMapCanvas *mapCanvas = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsMapLayer *layer = nullptr );
370
374 QgsTextFormat format() const;
375
380 void setContext( const QgsSymbolWidgetContext &context );
381
386 QDialogButtonBox *buttonBox() const;
387
388 private:
389 QgsTextFormatWidget *mFormatWidget = nullptr;
390 QDialogButtonBox *mButtonBox = nullptr;
391
392 private slots:
393 void showHelp();
394};
395
408{
409 Q_OBJECT
410
411 public:
419 QgsTextFormatPanelWidget( const QgsTextFormat &format, QgsMapCanvas *mapCanvas = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr, QgsMapLayer *layer = nullptr );
420
424 QgsTextFormat format() const;
425
431 void setFormat( const QgsTextFormat &format );
432
437 void setContext( const QgsSymbolWidgetContext &context );
438
439 void setDockMode( bool dockMode ) override;
440
441 private:
442 QgsTextFormatWidget *mFormatWidget = nullptr;
443 bool mBlockSignals = false;
444};
445
446#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< 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.
QList< QgsTextFormat::Tab > mTabPositions
Tab positions.
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