Skip to content

Commit f6a344c

Browse files
committedOct 24, 2016
Add QgsTextFormatPanelWidget for text format control inside panel
1 parent 8fa8167 commit f6a344c

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed
 

‎python/gui/qgstextformatwidget.sip

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,36 @@ class QgsTextFormatDialog : QDialog
119119
*/
120120
QgsTextFormat format() const;
121121
};
122+
123+
/** \class QgsTextFormatPanelWidget
124+
* \ingroup gui
125+
* A panel widget for customising text formatting settings.
126+
*
127+
* QgsTextFormatPanelWidget provides a panel widget for controlling the appearance of text rendered
128+
* using QgsTextRenderer. The dialog includes all settings contained within
129+
* a QgsTextFormat, including shadow, background and buffer.
130+
*
131+
* @note Added in QGIS 3.0
132+
*/
133+
134+
class QgsTextFormatPanelWidget : QgsPanelWidgetWrapper
135+
{
136+
%TypeHeaderCode
137+
#include <qgstextformatwidget.h>
138+
%End
139+
public:
140+
141+
/** Constructor for QgsTextFormatPanelWidget.
142+
* @param format initial format settings to show in dialog
143+
* @param mapCanvas optional associated map canvas
144+
* @param parent parent widget
145+
*/
146+
QgsTextFormatPanelWidget( const QgsTextFormat& format, QgsMapCanvas* mapCanvas = nullptr, QWidget* parent /TransferThis/ = nullptr );
147+
148+
/** Returns the current formatting settings defined by the widget.
149+
*/
150+
QgsTextFormat format() const;
151+
152+
virtual void setDockMode( bool dockMode );
153+
154+
};

‎src/gui/qgstextformatwidget.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,3 +1413,21 @@ QgsTextFormat QgsTextFormatDialog::format() const
14131413
{
14141414
return mFormatWidget->format();
14151415
}
1416+
1417+
QgsTextFormatPanelWidget::QgsTextFormatPanelWidget( const QgsTextFormat& format, QgsMapCanvas* mapCanvas, QWidget* parent )
1418+
: QgsPanelWidgetWrapper( new QgsTextFormatWidget( format, mapCanvas ), parent )
1419+
{
1420+
mFormatWidget = qobject_cast< QgsTextFormatWidget* >( widget() );
1421+
connect( mFormatWidget, SIGNAL( widgetChanged() ), this, SIGNAL( widgetChanged() ) );
1422+
}
1423+
1424+
QgsTextFormat QgsTextFormatPanelWidget::format() const
1425+
{
1426+
return mFormatWidget->format();
1427+
}
1428+
1429+
void QgsTextFormatPanelWidget::setDockMode( bool dockMode )
1430+
{
1431+
mFormatWidget->setDockMode( dockMode );
1432+
QgsPanelWidgetWrapper::setDockMode( dockMode );
1433+
}

‎src/gui/qgstextformatwidget.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,41 @@ class GUI_EXPORT QgsTextFormatDialog : public QDialog
231231
QgsTextFormatWidget* mFormatWidget;
232232
};
233233

234+
/** \class QgsTextFormatPanelWidget
235+
* \ingroup gui
236+
* A panel widget for customising text formatting settings.
237+
*
238+
* QgsTextFormatPanelWidget provides a panel widget for controlling the appearance of text rendered
239+
* using QgsTextRenderer. The dialog includes all settings contained within
240+
* a QgsTextFormat, including shadow, background and buffer.
241+
*
242+
* @note Added in QGIS 3.0
243+
*/
244+
245+
class GUI_EXPORT QgsTextFormatPanelWidget : public QgsPanelWidgetWrapper
246+
{
247+
Q_OBJECT
248+
249+
public:
250+
251+
/** Constructor for QgsTextFormatPanelWidget.
252+
* @param format initial format settings to show in dialog
253+
* @param mapCanvas optional associated map canvas
254+
* @param parent parent widget
255+
*/
256+
QgsTextFormatPanelWidget( const QgsTextFormat& format, QgsMapCanvas* mapCanvas = nullptr, QWidget* parent = nullptr );
257+
258+
/** Returns the current formatting settings defined by the widget.
259+
*/
260+
QgsTextFormat format() const;
261+
262+
virtual void setDockMode( bool dockMode ) override;
263+
264+
private:
265+
266+
QgsTextFormatWidget* mFormatWidget;
267+
};
268+
234269
#endif //QGSTEXTFORMATWIDGET_H
235270

236271

0 commit comments

Comments
 (0)
Please sign in to comment.