Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add QgsTextFormatPanelWidget for text format control inside panel
  • Loading branch information
nyalldawson committed Oct 24, 2016
1 parent 8fa8167 commit f6a344c
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
33 changes: 33 additions & 0 deletions python/gui/qgstextformatwidget.sip
Expand Up @@ -119,3 +119,36 @@ class QgsTextFormatDialog : QDialog
*/
QgsTextFormat format() const;
};

/** \class QgsTextFormatPanelWidget
* \ingroup gui
* A panel widget for customising text formatting settings.
*
* QgsTextFormatPanelWidget provides a panel widget for controlling the appearance of text rendered
* using QgsTextRenderer. The dialog includes all settings contained within
* a QgsTextFormat, including shadow, background and buffer.
*
* @note Added in QGIS 3.0
*/

class QgsTextFormatPanelWidget : QgsPanelWidgetWrapper
{
%TypeHeaderCode
#include <qgstextformatwidget.h>
%End
public:

/** Constructor for QgsTextFormatPanelWidget.
* @param format initial format settings to show in dialog
* @param mapCanvas optional associated map canvas
* @param parent parent widget
*/
QgsTextFormatPanelWidget( const QgsTextFormat& format, QgsMapCanvas* mapCanvas = nullptr, QWidget* parent /TransferThis/ = nullptr );

/** Returns the current formatting settings defined by the widget.
*/
QgsTextFormat format() const;

virtual void setDockMode( bool dockMode );

};
18 changes: 18 additions & 0 deletions src/gui/qgstextformatwidget.cpp
Expand Up @@ -1413,3 +1413,21 @@ QgsTextFormat QgsTextFormatDialog::format() const
{
return mFormatWidget->format();
}

QgsTextFormatPanelWidget::QgsTextFormatPanelWidget( const QgsTextFormat& format, QgsMapCanvas* mapCanvas, QWidget* parent )
: QgsPanelWidgetWrapper( new QgsTextFormatWidget( format, mapCanvas ), parent )
{
mFormatWidget = qobject_cast< QgsTextFormatWidget* >( widget() );
connect( mFormatWidget, SIGNAL( widgetChanged() ), this, SIGNAL( widgetChanged() ) );
}

QgsTextFormat QgsTextFormatPanelWidget::format() const
{
return mFormatWidget->format();
}

void QgsTextFormatPanelWidget::setDockMode( bool dockMode )
{
mFormatWidget->setDockMode( dockMode );
QgsPanelWidgetWrapper::setDockMode( dockMode );
}
35 changes: 35 additions & 0 deletions src/gui/qgstextformatwidget.h
Expand Up @@ -231,6 +231,41 @@ class GUI_EXPORT QgsTextFormatDialog : public QDialog
QgsTextFormatWidget* mFormatWidget;
};

/** \class QgsTextFormatPanelWidget
* \ingroup gui
* A panel widget for customising text formatting settings.
*
* QgsTextFormatPanelWidget provides a panel widget for controlling the appearance of text rendered
* using QgsTextRenderer. The dialog includes all settings contained within
* a QgsTextFormat, including shadow, background and buffer.
*
* @note Added in QGIS 3.0
*/

class GUI_EXPORT QgsTextFormatPanelWidget : public QgsPanelWidgetWrapper
{
Q_OBJECT

public:

/** Constructor for QgsTextFormatPanelWidget.
* @param format initial format settings to show in dialog
* @param mapCanvas optional associated map canvas
* @param parent parent widget
*/
QgsTextFormatPanelWidget( const QgsTextFormat& format, QgsMapCanvas* mapCanvas = nullptr, QWidget* parent = nullptr );

/** Returns the current formatting settings defined by the widget.
*/
QgsTextFormat format() const;

virtual void setDockMode( bool dockMode ) override;

private:

QgsTextFormatWidget* mFormatWidget;
};

#endif //QGSTEXTFORMATWIDGET_H


0 comments on commit f6a344c

Please sign in to comment.