QGIS API Documentation  3.4.15-Madeira (e83d02e274)
Public Types | Public Slots | Signals | Public Member Functions | Protected Member Functions | Properties | List of all members
QgsFontButton Class Reference

A button for customizing QgsTextFormat settings. More...

#include <qgsfontbutton.h>

Inheritance diagram for QgsFontButton:
Inheritance graph
[legend]

Public Types

enum  Mode { ModeTextRenderer, ModeQFont }
 Available button modes. More...
 

Public Slots

void copyColor ()
 Copies the current text color to the clipboard. More...
 
void copyFormat ()
 Copies the current text format to the clipboard. More...
 
void pasteColor ()
 Pastes a color from the clipboard to the text format. More...
 
void pasteFormat ()
 Pastes a format from the clipboard. More...
 
void setColor (const QColor &color)
 Sets the current color for the text. More...
 
void setCurrentFont (const QFont &font)
 Sets the current text font to show in the widget. More...
 
void setTextFormat (const QgsTextFormat &format)
 Sets the current text format to show in the widget. More...
 

Signals

void changed ()
 Emitted when the widget's text format settings are changed. More...
 

Public Member Functions

 QgsFontButton (QWidget *parent=nullptr, const QString &dialogTitle=QString())
 Construct a new font button. More...
 
QFont currentFont () const
 Returns the current QFont set by the widget. More...
 
QString dialogTitle () const
 Returns the title for the text settings dialog window. More...
 
QgsMapCanvasmapCanvas () const
 Returns the map canvas associated with the widget. More...
 
QSize minimumSizeHint () const override
 
QgsFontButton::Mode mode () const
 Returns the current button mode. More...
 
void setDialogTitle (const QString &title)
 Sets the title for the text settings dialog window. More...
 
void setMapCanvas (QgsMapCanvas *canvas)
 Sets a map canvas to associate with the widget. More...
 
void setMode (Mode mode)
 Sets the current button mode. More...
 
QSize sizeHint () const override
 
QgsTextFormat textFormat () const
 Returns the current text formatting set by the widget. More...
 

Protected Member Functions

void changeEvent (QEvent *e) override
 
void dragEnterEvent (QDragEnterEvent *e) override
 
void dragLeaveEvent (QDragLeaveEvent *e) override
 
void dropEvent (QDropEvent *e) override
 
bool event (QEvent *e) override
 
void mouseMoveEvent (QMouseEvent *e) override
 
void mousePressEvent (QMouseEvent *e) override
 
void resizeEvent (QResizeEvent *event) override
 
void showEvent (QShowEvent *e) override
 
void wheelEvent (QWheelEvent *event) override
 

Properties

QFont currentFont
 
QString dialogTitle
 
Mode mode
 
QgsTextFormat textFormat
 

Detailed Description

A button for customizing QgsTextFormat settings.

The button will open a detailed text format settings dialog when clicked. An attached drop-down menu allows for copying and pasting text styles, picking colors for the text, and for dropping colors from other color widgets.

The button can be used in two different modes(). The default behavior is to include all settings used for configuring QgsTextFormat/QgsTextRenderer classes. A cut down mode (without settings for color) is also available when the resultant font is used only in a QFont object.

Since
QGIS 3.0

Definition at line 42 of file qgsfontbutton.h.

Member Enumeration Documentation

Available button modes.

Enumerator
ModeTextRenderer 

Configure font settings for use with QgsTextRenderer.

ModeQFont 

Configure font settings for use with QFont objects.

Definition at line 54 of file qgsfontbutton.h.

Constructor & Destructor Documentation

QgsFontButton::QgsFontButton ( QWidget *  parent = nullptr,
const QString &  dialogTitle = QString() 
)

Construct a new font button.

Use parent to attach a parent QWidget to the dialog. Use dialogTitle string to define the title to show in the text settings dialog.

Definition at line 34 of file qgsfontbutton.cpp.

Member Function Documentation

void QgsFontButton::changed ( )
signal

Emitted when the widget's text format settings are changed.

void QgsFontButton::changeEvent ( QEvent *  e)
overrideprotected

Definition at line 725 of file qgsfontbutton.cpp.

void QgsFontButton::copyColor ( )
slot

Copies the current text color to the clipboard.

This is only used when mode() is ModeTextRenderer.

See also
pasteColor()

Definition at line 866 of file qgsfontbutton.cpp.

void QgsFontButton::copyFormat ( )
slot

Copies the current text format to the clipboard.

See also
pasteFormat()

Definition at line 142 of file qgsfontbutton.cpp.

QFont QgsFontButton::currentFont ( ) const

Returns the current QFont set by the widget.

This is only used when mode() is ModeQFont.

See also
setCurrentFont()
QString QgsFontButton::dialogTitle ( ) const

Returns the title for the text settings dialog window.

See also
setDialogTitle()
void QgsFontButton::dragEnterEvent ( QDragEnterEvent *  e)
overrideprotected

Definition at line 260 of file qgsfontbutton.cpp.

void QgsFontButton::dragLeaveEvent ( QDragLeaveEvent *  e)
overrideprotected

Definition at line 288 of file qgsfontbutton.cpp.

void QgsFontButton::dropEvent ( QDropEvent *  e)
overrideprotected

Definition at line 295 of file qgsfontbutton.cpp.

bool QgsFontButton::event ( QEvent *  e)
overrideprotected

Definition at line 172 of file qgsfontbutton.cpp.

QgsMapCanvas * QgsFontButton::mapCanvas ( ) const

Returns the map canvas associated with the widget.

See also
setMapCanvas()

Definition at line 112 of file qgsfontbutton.cpp.

QSize QgsFontButton::minimumSizeHint ( ) const
override

Definition at line 57 of file qgsfontbutton.cpp.

QgsFontButton::Mode QgsFontButton::mode ( ) const

Returns the current button mode.

See also
setMode()
void QgsFontButton::mouseMoveEvent ( QMouseEvent *  e)
overrideprotected

Definition at line 209 of file qgsfontbutton.cpp.

void QgsFontButton::mousePressEvent ( QMouseEvent *  e)
overrideprotected

Definition at line 195 of file qgsfontbutton.cpp.

void QgsFontButton::pasteColor ( )
slot

Pastes a color from the clipboard to the text format.

If clipboard does not contain a valid color or string representation of a color, then no change is applied. This is only used when mode() is ModeTextRenderer.

See also
copyColor()

Definition at line 872 of file qgsfontbutton.cpp.

void QgsFontButton::pasteFormat ( )
slot

Pastes a format from the clipboard.

If clipboard does not contain a valid format then no change is applied.

See also
copyFormat()

Definition at line 156 of file qgsfontbutton.cpp.

void QgsFontButton::resizeEvent ( QResizeEvent *  event)
overrideprotected

Definition at line 740 of file qgsfontbutton.cpp.

void QgsFontButton::setColor ( const QColor &  color)
slot

Sets the current color for the text.

Will emit a changed signal if the color is different to the previous text color. This is only used when mode() is ModeTextRenderer.

Definition at line 129 of file qgsfontbutton.cpp.

void QgsFontButton::setCurrentFont ( const QFont &  font)
slot

Sets the current text font to show in the widget.

This is only used when mode() is ModeQFont.

See also
currentFont()

Definition at line 693 of file qgsfontbutton.cpp.

void QgsFontButton::setDialogTitle ( const QString &  title)

Sets the title for the text settings dialog window.

See also
dialogTitle()

Definition at line 884 of file qgsfontbutton.cpp.

void QgsFontButton::setMapCanvas ( QgsMapCanvas canvas)

Sets a map canvas to associate with the widget.

This allows the widget to fetch current settings from the map canvas, such as current scale.

See also
mapCanvas()

Definition at line 117 of file qgsfontbutton.cpp.

void QgsFontButton::setMode ( Mode  mode)

Sets the current button mode.

This can be used to toggle between the full capabilities of the button (for configuring QgsTextFormat/QgsTextRenderer objects) and a cut-back version for configuring QFont object properties (i.e. with no color settings or the other advanced options QgsTextFormat allows).

See also
mode()

Definition at line 705 of file qgsfontbutton.cpp.

void QgsFontButton::setTextFormat ( const QgsTextFormat format)
slot

Sets the current text format to show in the widget.

This is only used when mode() is ModeTextRenderer.

See also
textFormat()

Definition at line 122 of file qgsfontbutton.cpp.

void QgsFontButton::showEvent ( QShowEvent *  e)
overrideprotected

Definition at line 734 of file qgsfontbutton.cpp.

QSize QgsFontButton::sizeHint ( ) const
override

Definition at line 62 of file qgsfontbutton.cpp.

QgsTextFormat QgsFontButton::textFormat ( ) const
inline

Returns the current text formatting set by the widget.

This is only used when mode() is ModeTextRenderer.

See also
setTextFormat()

Definition at line 117 of file qgsfontbutton.h.

void QgsFontButton::wheelEvent ( QWheelEvent *  event)
overrideprotected

Definition at line 332 of file qgsfontbutton.cpp.

Property Documentation

QFont QgsFontButton::currentFont
readwrite

Definition at line 48 of file qgsfontbutton.h.

QString QgsFontButton::dialogTitle
readwrite

Definition at line 47 of file qgsfontbutton.h.

QgsFontButton::Mode QgsFontButton::mode
readwrite

Definition at line 46 of file qgsfontbutton.h.

QgsTextFormat QgsFontButton::textFormat
readwrite

Definition at line 49 of file qgsfontbutton.h.


The documentation for this class was generated from the following files: