1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
|
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsfontbutton.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
class QgsFontButton : QToolButton
{
%Docstring(signature="appended")
A button for customizing :py:class:`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 :py:func:`~modes`. The default
behavior is to include all settings used for configuring
:py:class:`QgsTextFormat`/:py:class:`QgsTextRenderer` classes. A cut
down mode (without settings for color) is also available when the
resultant font is used only in a QFont object.
%End
%TypeHeaderCode
#include "qgsfontbutton.h"
%End
public:
enum Mode /BaseType=IntEnum/
{
ModeTextRenderer,
ModeQFont,
};
QgsFontButton( QWidget *parent /TransferThis/ = 0, const QString &dialogTitle = QString() );
%Docstring
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.
%End
virtual QSize minimumSizeHint() const;
virtual QSize sizeHint() const;
QgsFontButton::Mode mode() const;
%Docstring
Returns the current button mode.
.. seealso:: :py:func:`setMode`
%End
void setMode( Mode mode );
%Docstring
Sets the current button ``mode``. This can be used to toggle between the
full capabilities of the button (for configuring
:py:class:`QgsTextFormat`/:py:class:`QgsTextRenderer` objects) and a
cut-back version for configuring QFont object properties (i.e. with no
color settings or the other advanced options :py:class:`QgsTextFormat`
allows).
.. seealso:: :py:func:`mode`
%End
void setDialogTitle( const QString &title );
%Docstring
Sets the ``title`` for the text settings dialog window.
.. seealso:: :py:func:`dialogTitle`
%End
QString dialogTitle() const;
%Docstring
Returns the title for the text settings dialog window.
.. seealso:: :py:func:`setDialogTitle`
%End
QgsMapCanvas *mapCanvas() const;
%Docstring
Returns the map canvas associated with the widget.
.. seealso:: :py:func:`setMapCanvas`
%End
void setMapCanvas( QgsMapCanvas *canvas );
%Docstring
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.
.. seealso:: :py:func:`mapCanvas`
%End
void setMessageBar( QgsMessageBar *bar );
%Docstring
Sets the message ``bar`` associated with the widget. This allows the
widget to push feedback messages to the appropriate message bar.
.. seealso:: :py:func:`messageBar`
.. versionadded:: 3.10
%End
QgsMessageBar *messageBar() const;
%Docstring
Returns the message bar associated with the widget.
.. seealso:: :py:func:`setMessageBar`
.. versionadded:: 3.10
%End
QgsTextFormat textFormat() const;
%Docstring
Returns the current text formatting set by the widget. This is only used
when :py:func:`~QgsFontButton.mode` is ModeTextRenderer.
.. seealso:: :py:func:`setTextFormat`
%End
QFont currentFont() const;
%Docstring
Returns the current QFont set by the widget. This is only used when
:py:func:`~QgsFontButton.mode` is ModeQFont.
.. seealso:: :py:func:`setCurrentFont`
%End
QgsVectorLayer *layer() const;
%Docstring
Returns the layer associated with the widget.
.. seealso:: :py:func:`setLayer`
.. versionadded:: 3.10
%End
void setLayer( QgsVectorLayer *layer );
%Docstring
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.
.. seealso:: :py:func:`layer`
.. versionadded:: 3.10
%End
void registerExpressionContextGenerator( QgsExpressionContextGenerator *generator );
%Docstring
Register an expression context generator class that will be used to
retrieve an expression context for the button when required.
.. versionadded:: 3.10
%End
void setShowNullFormat( const bool show );
%Docstring
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 :py:func:`~QgsFontButton.mode`.
If selected, the "null format" option sets the button's format to an
invalid :py:class:`QgsTextFormat`. This can be used to represent a "use
default format" state for the button.
By default this option is not shown.
.. seealso:: :py:func:`setNoFormatString`
.. seealso:: :py:func:`showNullFormat`
.. versionadded:: 3.16
%End
void setNoFormatString( const QString &string );
%Docstring
Sets the ``string`` to use for the "null format" option in the button's
drop-down menu.
.. note::
The "null format" option is only shown if :py:func:`~QgsFontButton.showNullFormat` is ``True``.
.. seealso:: :py:func:`setShowNullFormat`
.. versionadded:: 3.16
%End
bool showNullFormat() const;
%Docstring
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 :py:func:`~QgsFontButton.mode`.
If selected, the "null format" option sets the button's format to an
invalid :py:class:`QgsTextFormat`. This can be used to represent a "use
default format" state for the button.
By default this option is not shown.
.. seealso:: :py:func:`setShowNullFormat`
.. versionadded:: 3.16
%End
public slots:
void setTextFormat( const QgsTextFormat &format );
%Docstring
Sets the current text ``format`` to show in the widget. This is only
used when :py:func:`~QgsFontButton.mode` is ModeTextRenderer.
.. seealso:: :py:func:`textFormat`
%End
void setToNullFormat();
%Docstring
Sets the text format to a null (invalid) :py:class:`QgsTextFormat`.
This is only used when :py:func:`~QgsFontButton.mode` is
ModeTextRenderer.
.. versionadded:: 3.16
%End
void setCurrentFont( const QFont &font );
%Docstring
Sets the current text ``font`` to show in the widget. This is only used
when :py:func:`~QgsFontButton.mode` is ModeQFont.
.. seealso:: :py:func:`currentFont`
%End
void setColor( const QColor &color );
%Docstring
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 :py:func:`~QgsFontButton.mode` is ModeTextRenderer.
%End
void copyFormat();
%Docstring
Copies the current text format to the clipboard.
.. seealso:: :py:func:`pasteFormat`
%End
void pasteFormat();
%Docstring
Pastes a format from the clipboard. If clipboard does not contain a
valid format then no change is applied.
.. seealso:: :py:func:`copyFormat`
%End
void copyColor();
%Docstring
Copies the current text color to the clipboard. This is only used when
:py:func:`~QgsFontButton.mode` is ModeTextRenderer.
.. seealso:: :py:func:`pasteColor`
%End
void pasteColor();
%Docstring
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 :py:func:`~QgsFontButton.mode`
is ModeTextRenderer.
.. seealso:: :py:func:`copyColor`
%End
signals:
void changed();
%Docstring
Emitted when the widget's text format settings are changed.
%End
protected:
virtual bool event( QEvent *e );
virtual void changeEvent( QEvent *e );
virtual void showEvent( QShowEvent *e );
virtual void resizeEvent( QResizeEvent *event );
virtual void mousePressEvent( QMouseEvent *e );
virtual void mouseMoveEvent( QMouseEvent *e );
virtual void dragEnterEvent( QDragEnterEvent *e );
virtual void dragLeaveEvent( QDragLeaveEvent *e );
virtual void dropEvent( QDropEvent *e );
virtual void wheelEvent( QWheelEvent *event );
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsfontbutton.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
|