Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom tab distances for labels #59253

Merged
merged 7 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions python/PyQt6/core/auto_additions/qgstextformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@
QgsTextFormat.__group__ = ['textrenderer']
except NameError:
pass
try:
QgsTextFormat.Tab.__group__ = ['textrenderer']
except NameError:
pass
102 changes: 101 additions & 1 deletion python/PyQt6/core/auto_generated/textrenderer/qgstextformat.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,12 @@ Sets the ``unit`` for the line height for text.
%Docstring
Returns the distance for tab stops.

.. note::

This value will be ignored if :py:func:`~QgsTextFormat.tabPositions` is non-empty.

.. seealso:: :py:func:`tabPositions`

.. seealso:: :py:func:`tabStopDistanceUnit`

.. seealso:: :py:func:`setTabStopDistance`
Expand All @@ -515,13 +521,103 @@ Returns the distance for tab stops.

void setTabStopDistance( double distance );
%Docstring
Sets the ``distance`` for tab stops. The units are specified using :py:func:`~QgsTextFormat.setTabStopDistanceUnit`.
Sets the ``distance`` for tab stops.

The units are specified using :py:func:`~QgsTextFormat.setTabStopDistanceUnit`.

.. note::

This value will be ignored if :py:func:`~QgsTextFormat.tabPositions` is non-empty.

.. seealso:: :py:func:`tabPositions`

.. seealso:: :py:func:`tabStopDistance`

.. seealso:: :py:func:`setTabStopDistanceUnit`

.. versionadded:: 3.38
%End

class Tab
{
%Docstring(signature="appended")
Defines a tab position for a text format.

.. versionadded:: 3.42
%End

%TypeHeaderCode
#include "qgstextformat.h"
%End
public:

explicit Tab( double position );
%Docstring
Constructor for a Tab at the specified ``position``.
%End

void setPosition( double position );
%Docstring
Sets the tab position.

.. seealso:: :py:func:`position`
%End

double position() const;
%Docstring
Returns the tab position.

.. seealso:: :py:func:`setPosition`
%End

bool operator==( const QgsTextFormat::Tab &other ) const;

SIP_PYOBJECT __repr__();
%MethodCode
const QString str = QStringLiteral( "<QgsTextFormat.Tab: %1>" ).arg( sipCpp->position() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End

};

QList< QgsTextFormat::Tab > tabPositions() const;
%Docstring
Returns the list of tab positions for tab stops.

The units are specified using :py:func:`~QgsTextFormat.tabStopDistanceUnit`.

.. note::

If non-empty, this list overrides any distance defined by :py:func:`~QgsTextFormat.tabStopDistance`.

.. seealso:: :py:func:`setTabPositions`

.. seealso:: :py:func:`tabStopDistance`

.. seealso:: :py:func:`tabStopDistanceUnit`

.. seealso:: :py:func:`setTabStopDistance`

.. versionadded:: 3.42
%End

void setTabPositions( const QList< QgsTextFormat::Tab > &positions );
%Docstring
Sets the list of tab ``positions`` for tab stops.

The units are specified using :py:func:`~QgsTextFormat.setTabStopDistanceUnit`.

.. note::

If non-empty, this list overrides any distance defined by :py:func:`~QgsTextFormat.setTabStopDistance`.

.. seealso:: :py:func:`tabPositions`

.. seealso:: :py:func:`setTabStopDistance`

.. seealso:: :py:func:`setTabStopDistanceUnit`

.. versionadded:: 3.42
%End

Qgis::RenderUnit tabStopDistanceUnit() const;
Expand All @@ -530,6 +626,8 @@ Returns the units for the tab stop distance.

.. seealso:: :py:func:`tabStopDistance`

.. seealso:: :py:func:`tabPositions`

.. seealso:: :py:func:`setTabStopDistanceUnit`

.. versionadded:: 3.38
Expand All @@ -541,6 +639,8 @@ Sets the ``unit`` used for the tab stop distance.

.. seealso:: :py:func:`setTabStopDistance`

.. seealso:: :py:func:`setTabPositions`

.. seealso:: :py:func:`tabStopDistanceUnit`

.. versionadded:: 3.38
Expand Down
11 changes: 11 additions & 0 deletions python/PyQt6/gui/auto_additions/qgstabpositionwidget.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# The following has been generated automatically from src/gui/labeling/qgstabpositionwidget.h
try:
QgsTabPositionWidget.__attribute_docs__ = {'positionsChanged': 'Emitted when positions are changed in the widget.\n'}
QgsTabPositionWidget.__signal_arguments__ = {'positionsChanged': ['positions: List[QgsTextFormat.Tab]']}
QgsTabPositionWidget.__group__ = ['labeling']
except NameError:
pass
try:
QgsTabPositionDialog.__group__ = ['labeling']
except NameError:
pass
104 changes: 104 additions & 0 deletions python/PyQt6/gui/auto_generated/labeling/qgstabpositionwidget.sip.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/labeling/qgstabpositionwidget.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/





class QgsTabPositionWidget: QgsPanelWidget
{
%Docstring(signature="appended")
A widget for configuring :py:class:`QgsTextFormat` tab positions.

.. versionadded:: 3.42
%End

%TypeHeaderCode
#include "qgstabpositionwidget.h"
%End
public:

QgsTabPositionWidget( QWidget *parent /TransferThis/ = 0 );
%Docstring
Constructor for QgsTabPositionWidget, with the specified ``parent`` widget
%End

void setPositions( const QList< QgsTextFormat::Tab > &positions );
%Docstring
Sets the tab ``positions`` to show in the widget.

.. seealso:: :py:func:`positions`
%End

QList< QgsTextFormat::Tab > positions() const;
%Docstring
Returns the tab positions defined in the widget.

.. seealso:: :py:func:`setPositions`
%End

void setUnit( Qgis::RenderUnit unit );
%Docstring
Sets the unit type used for the tab positions (used to update interface labels).
%End

signals:

void positionsChanged( const QList< QgsTextFormat::Tab > &positions );
%Docstring
Emitted when positions are changed in the widget.
%End

};

class QgsTabPositionDialog : QDialog
{
%Docstring(signature="appended")
A dialog to enter a custom dash space pattern for lines

.. versionadded:: 3.42
%End

%TypeHeaderCode
#include "qgstabpositionwidget.h"
%End
public:

QgsTabPositionDialog( QWidget *parent /TransferThis/ = 0, Qt::WindowFlags f = Qt::WindowFlags() );
%Docstring
Constructor for QgsTabPositionDialog
%End

void setPositions( const QList< QgsTextFormat::Tab > &positions );
%Docstring
Sets the tab ``positions`` to show in the dialog.

.. seealso:: :py:func:`positions`
%End

QList< QgsTextFormat::Tab > positions() const;
%Docstring
Returns the tab positions defined in the dialog.

.. seealso:: :py:func:`setPositions`
%End

void setUnit( Qgis::RenderUnit unit );
%Docstring
Sets the unit type used for the tab positions (used to update interface labels).
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/labeling/qgstabpositionwidget.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
1 change: 1 addition & 0 deletions python/PyQt6/gui/auto_generated/qgstextformatwidget.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ when registering labels for the labeling settings currently defined by the widge




protected slots:

void updateLinePlacementOptions();
Expand Down
1 change: 1 addition & 0 deletions python/PyQt6/gui/gui_auto.sip
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@
%Include auto_generated/labeling/qgslabellineanchorwidget.sip
%Include auto_generated/labeling/qgslabelobstaclesettingswidget.sip
%Include auto_generated/labeling/qgslabelsettingswidgetbase.sip
%Include auto_generated/labeling/qgstabpositionwidget.sip
%Include auto_generated/layertree/qgscustomlayerorderwidget.sip
%Include auto_generated/layertree/qgslayertreeembeddedconfigwidget.sip
%Include auto_generated/layertree/qgslayertreeembeddedwidgetregistry.sip
Expand Down
4 changes: 4 additions & 0 deletions python/core/auto_additions/qgstextformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@
QgsTextFormat.__group__ = ['textrenderer']
except NameError:
pass
try:
QgsTextFormat.Tab.__group__ = ['textrenderer']
except NameError:
pass
Loading
Loading