QGIS API Documentation
3.18.1-Zürich (202f1bf7e5)
|
A button for customizing QgsTextFormat settings. More...
#include <qgsfontbutton.h>
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... | |
void | setToNullFormat () |
Sets the text format to a null (invalid) QgsTextFormat. 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... | |
QgsVectorLayer * | layer () const |
Returns the layer associated with the widget. More... | |
QgsMapCanvas * | mapCanvas () const |
Returns the map canvas associated with the widget. More... | |
QgsMessageBar * | messageBar () const |
Returns the message bar associated with the widget. More... | |
QSize | minimumSizeHint () const override |
QgsFontButton::Mode | mode () const |
Returns the current button mode. More... | |
void | registerExpressionContextGenerator (QgsExpressionContextGenerator *generator) |
Register an expression context generator class that will be used to retrieve an expression context for the button when required. More... | |
void | setDialogTitle (const QString &title) |
Sets the title for the text settings dialog window. More... | |
void | setLayer (QgsVectorLayer *layer) |
Sets a layer to associate with the widget. More... | |
void | setMapCanvas (QgsMapCanvas *canvas) |
Sets a map canvas to associate with the widget. More... | |
void | setMessageBar (QgsMessageBar *bar) |
Sets the message bar associated with the widget. More... | |
void | setMode (Mode mode) |
Sets the current button mode. More... | |
void | setNoFormatString (const QString &string) |
Sets the string to use for the "null format" option in the button's drop-down menu. More... | |
void | setShowNullFormat (const bool show) |
Sets whether the "null format" option should be shown in the button's drop-down menu. More... | |
bool | showNullFormat () const |
Returns whether the "null format" option will be shown in the button's drop-down menu. 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 |
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.
Definition at line 47 of file qgsfontbutton.h.
enum QgsFontButton::Mode |
Available button modes.
Enumerator | |
---|---|
ModeTextRenderer | Configure font settings for use with QgsTextRenderer. |
ModeQFont | Configure font settings for use with QFont objects. |
Definition at line 59 of file qgsfontbutton.h.
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 38 of file qgsfontbutton.cpp.
|
signal |
Emitted when the widget's text format settings are changed.
|
overrideprotected |
Definition at line 803 of file qgsfontbutton.cpp.
|
slot |
Copies the current text color to the clipboard.
This is only used when mode() is ModeTextRenderer.
Definition at line 951 of file qgsfontbutton.cpp.
|
slot |
Copies the current text format to the clipboard.
Definition at line 191 of file qgsfontbutton.cpp.
QFont QgsFontButton::currentFont | ( | ) | const |
Returns the current QFont set by the widget.
This is only used when mode() is ModeQFont.
Definition at line 751 of file qgsfontbutton.cpp.
QString QgsFontButton::dialogTitle | ( | ) | const |
Returns the title for the text settings dialog window.
Definition at line 974 of file qgsfontbutton.cpp.
|
overrideprotected |
Definition at line 309 of file qgsfontbutton.cpp.
|
overrideprotected |
Definition at line 337 of file qgsfontbutton.cpp.
|
overrideprotected |
Definition at line 344 of file qgsfontbutton.cpp.
|
overrideprotected |
Definition at line 221 of file qgsfontbutton.cpp.
QgsVectorLayer * QgsFontButton::layer | ( | ) | const |
Returns the layer associated with the widget.
Definition at line 756 of file qgsfontbutton.cpp.
QgsMapCanvas * QgsFontButton::mapCanvas | ( | ) | const |
Returns the map canvas associated with the widget.
Definition at line 135 of file qgsfontbutton.cpp.
QgsMessageBar * QgsFontButton::messageBar | ( | ) | const |
Returns the message bar associated with the widget.
Definition at line 150 of file qgsfontbutton.cpp.
|
override |
Definition at line 65 of file qgsfontbutton.cpp.
QgsFontButton::Mode QgsFontButton::mode | ( | ) | const |
Returns the current button mode.
Definition at line 778 of file qgsfontbutton.cpp.
|
overrideprotected |
Definition at line 258 of file qgsfontbutton.cpp.
|
overrideprotected |
Definition at line 244 of file qgsfontbutton.cpp.
|
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.
Definition at line 957 of file qgsfontbutton.cpp.
|
slot |
Pastes a format from the clipboard.
If clipboard does not contain a valid format then no change is applied.
Definition at line 205 of file qgsfontbutton.cpp.
void QgsFontButton::registerExpressionContextGenerator | ( | QgsExpressionContextGenerator * | generator | ) |
Register an expression context generator class that will be used to retrieve an expression context for the button when required.
Definition at line 766 of file qgsfontbutton.cpp.
|
overrideprotected |
Definition at line 818 of file qgsfontbutton.cpp.
|
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 175 of file qgsfontbutton.cpp.
|
slot |
Sets the current text font to show in the widget.
This is only used when mode() is ModeQFont.
Definition at line 771 of file qgsfontbutton.cpp.
void QgsFontButton::setDialogTitle | ( | const QString & | title | ) |
Sets the title for the text settings dialog window.
Definition at line 969 of file qgsfontbutton.cpp.
void QgsFontButton::setLayer | ( | QgsVectorLayer * | layer | ) |
Sets a layer to associate with the widget.
This allows the widget to setup layer related settings within the text settings dialog, such as correctly populating data defined override buttons.
Definition at line 761 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.
Definition at line 140 of file qgsfontbutton.cpp.
void QgsFontButton::setMessageBar | ( | QgsMessageBar * | bar | ) |
Sets the message bar associated with the widget.
This allows the widget to push feedback messages to the appropriate message bar.
Definition at line 145 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).
Definition at line 783 of file qgsfontbutton.cpp.
|
inline |
Sets the string to use for the "null format" option in the button's drop-down menu.
true
.Definition at line 192 of file qgsfontbutton.h.
|
inline |
Sets whether the "null format" option should be shown in the button's drop-down menu.
This option is only used for buttons set to the ModeTextRenderer mode().
If selected, the "null format" option sets the button's format to an invalid QgsTextFormat. This can be used to represent a "use default format" state for the button.
By default this option is not shown.
Definition at line 182 of file qgsfontbutton.h.
|
slot |
Sets the current text format to show in the widget.
This is only used when mode() is ModeTextRenderer.
Definition at line 155 of file qgsfontbutton.cpp.
|
slot |
Sets the text format to a null (invalid) QgsTextFormat.
This is only used when mode() is ModeTextRenderer.
Definition at line 168 of file qgsfontbutton.cpp.
|
overrideprotected |
Definition at line 812 of file qgsfontbutton.cpp.
|
inline |
Returns whether the "null format" option will be shown in the button's drop-down menu.
This option is only used for buttons set to the ModeTextRenderer mode().
If selected, the "null format" option sets the button's format to an invalid QgsTextFormat. This can be used to represent a "use default format" state for the button.
By default this option is not shown.
Definition at line 206 of file qgsfontbutton.h.
|
override |
Definition at line 70 of file qgsfontbutton.cpp.
|
inline |
Returns the current text formatting set by the widget.
This is only used when mode() is ModeTextRenderer.
Definition at line 137 of file qgsfontbutton.h.
|
overrideprotected |
Definition at line 381 of file qgsfontbutton.cpp.
|
readwrite |
Definition at line 1 of file qgsfontbutton.h.
|
readwrite |
Definition at line 1 of file qgsfontbutton.h.
|
readwrite |
Definition at line 1 of file qgsfontbutton.h.
|
readwrite |
Definition at line 1 of file qgsfontbutton.h.