Skip to content

Commit

Permalink
Add method to use QgsFontButton in cut down mode for QFont settings only
Browse files Browse the repository at this point in the history
The button can now 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/buffer/drop shadow/etc) is also available when the resultant
font is to be used only in a QFont object.
  • Loading branch information
nyalldawson committed Jul 6, 2017
1 parent 5ac9745 commit 99855ea
Show file tree
Hide file tree
Showing 4 changed files with 456 additions and 162 deletions.
50 changes: 50 additions & 0 deletions python/gui/qgsfontbutton.sip
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ class QgsFontButton : QToolButton
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.

.. versionadded:: 3.0
%End

Expand All @@ -25,6 +31,13 @@ class QgsFontButton : QToolButton
%End
public:


enum Mode
{
ModeTextRenderer,
ModeQFont,
};

QgsFontButton( QWidget *parent /TransferThis/ = 0, const QString &dialogTitle = QString() );
%Docstring
Construct a new font button.
Expand All @@ -34,6 +47,22 @@ class QgsFontButton : QToolButton

virtual QSize sizeHint() const;

QgsFontButton::Mode mode() const;
%Docstring
Returns the current button mode.
.. seealso:: setMode()
:rtype: QgsFontButton.Mode
%End

void setMode( const QgsFontButton::Mode &mode );
%Docstring
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).
.. seealso:: mode()
%End

void setDialogTitle( const QString &title );
%Docstring
Sets the ``title`` for the text settings dialog window.
Expand Down Expand Up @@ -64,22 +93,41 @@ class QgsFontButton : QToolButton
QgsTextFormat textFormat() const;
%Docstring
Returns the current text formatting set by the widget.
This is only used when mode() is ModeTextRenderer.
.. seealso:: setTextFormat()
:rtype: QgsTextFormat
%End

QFont currentFont() const;
%Docstring
Returns the current QFont set by the widget.
This is only used when mode() is ModeQFont.
.. seealso:: setCurrentFont()
:rtype: QFont
%End


public slots:

void setTextFormat( const QgsTextFormat &format );
%Docstring
Sets the current text ``format`` to show in the widget.
This is only used when mode() is ModeTextRenderer.
.. seealso:: textFormat()
%End

void setCurrentFont( const QFont &font );
%Docstring
Sets the current text ``font`` to show in the widget.
This is only used when mode() is ModeQFont.
.. seealso:: 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 mode() is ModeTextRenderer.
%End

void copyFormat();
Expand All @@ -98,13 +146,15 @@ class QgsFontButton : QToolButton
void copyColor();
%Docstring
Copies the current text color to the clipboard.
This is only used when mode() is ModeTextRenderer.
.. seealso:: 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 mode() is ModeTextRenderer.
.. seealso:: copyColor()
%End

Expand Down
Loading

0 comments on commit 99855ea

Please sign in to comment.