mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-06 00:07:29 -04:00
Show units in tab position widget
This commit is contained in:
parent
22fbd8b87a
commit
cf9007658e
@ -40,6 +40,11 @@ Sets the tab ``positions`` to show in the widget.
|
||||
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:
|
||||
@ -81,6 +86,11 @@ Sets the tab ``positions`` to show in the dialog.
|
||||
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
|
||||
|
||||
};
|
||||
|
@ -40,6 +40,11 @@ Sets the tab ``positions`` to show in the widget.
|
||||
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:
|
||||
@ -81,6 +86,11 @@ Sets the tab ``positions`` to show in the dialog.
|
||||
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
|
||||
|
||||
};
|
||||
|
@ -14,8 +14,10 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgstabpositionwidget.h"
|
||||
#include "moc_qgstabpositionwidget.cpp"
|
||||
#include "qgsapplication.h"
|
||||
#include "qgsdoublevalidator.h"
|
||||
#include "qgsunittypes.h"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
@ -27,6 +29,8 @@ QgsTabPositionWidget::QgsTabPositionWidget( QWidget *parent )
|
||||
mAddButton->setIcon( QgsApplication::getThemeIcon( "symbologyAdd.svg" ) );
|
||||
mRemoveButton->setIcon( QgsApplication::getThemeIcon( "symbologyRemove.svg" ) );
|
||||
|
||||
setUnit( Qgis::RenderUnit::Millimeters );
|
||||
|
||||
connect( mAddButton, &QPushButton::clicked, this, &QgsTabPositionWidget::mAddButton_clicked );
|
||||
connect( mRemoveButton, &QPushButton::clicked, this, &QgsTabPositionWidget::mRemoveButton_clicked );
|
||||
connect( mTabPositionTreeWidget, &QTreeWidget::itemChanged, this, &QgsTabPositionWidget::emitPositionsChanged );
|
||||
@ -66,6 +70,12 @@ QList<QgsTextFormat::Tab> QgsTabPositionWidget::positions() const
|
||||
return result;
|
||||
}
|
||||
|
||||
void QgsTabPositionWidget::setUnit( Qgis::RenderUnit unit )
|
||||
{
|
||||
QTreeWidgetItem *headerItem = mTabPositionTreeWidget->headerItem();
|
||||
headerItem->setText( 0, QStringLiteral( "%1 (%2)" ).arg( tr( "Position" ), QgsUnitTypes::toAbbreviatedString( unit ) ) );
|
||||
}
|
||||
|
||||
void QgsTabPositionWidget::mAddButton_clicked()
|
||||
{
|
||||
const QList< QgsTextFormat::Tab > currentPositions = positions();
|
||||
@ -121,3 +131,8 @@ QList<QgsTextFormat::Tab> QgsTabPositionDialog::positions() const
|
||||
{
|
||||
return mWidget->positions();
|
||||
}
|
||||
|
||||
void QgsTabPositionDialog::setUnit( Qgis::RenderUnit unit )
|
||||
{
|
||||
mWidget->setUnit( unit );
|
||||
}
|
||||
|
@ -52,6 +52,11 @@ class GUI_EXPORT QgsTabPositionWidget: public QgsPanelWidget, private Ui::QgsTab
|
||||
*/
|
||||
QList< QgsTextFormat::Tab > positions() const;
|
||||
|
||||
/**
|
||||
* Sets the unit type used for the tab positions (used to update interface labels).
|
||||
*/
|
||||
void setUnit( Qgis::RenderUnit unit );
|
||||
|
||||
signals:
|
||||
|
||||
/**
|
||||
@ -94,6 +99,11 @@ class GUI_EXPORT QgsTabPositionDialog : public QDialog
|
||||
*/
|
||||
QList< QgsTextFormat::Tab > positions() const;
|
||||
|
||||
/**
|
||||
* Sets the unit type used for the tab positions (used to update interface labels).
|
||||
*/
|
||||
void setUnit( Qgis::RenderUnit unit );
|
||||
|
||||
private:
|
||||
|
||||
QgsTabPositionWidget *mWidget = nullptr;
|
||||
|
@ -2176,6 +2176,7 @@ void QgsTextFormatWidget::configureTabStops()
|
||||
QgsTabPositionWidget *widget = new QgsTabPositionWidget( panel );
|
||||
widget->setPanelTitle( tr( "Tab Positions" ) );
|
||||
widget->setPositions( mTabPositions );
|
||||
widget->setUnit( mTabDistanceUnitWidget->unit() );
|
||||
connect( widget, &QgsTabPositionWidget::positionsChanged, this, [ = ]( const QList< QgsTextFormat::Tab > &positions )
|
||||
{
|
||||
mTabPositions = positions;
|
||||
@ -2188,6 +2189,7 @@ void QgsTextFormatWidget::configureTabStops()
|
||||
{
|
||||
QgsTabPositionDialog dlg( this );
|
||||
dlg.setPositions( mTabPositions );
|
||||
dlg.setUnit( mTabDistanceUnitWidget->unit() );
|
||||
if ( dlg.exec() == QDialog::Accepted )
|
||||
{
|
||||
mTabPositions = dlg.positions();
|
||||
|
@ -29,14 +29,14 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QTreeWidget" name="mTabPositionTreeWidget">
|
||||
<property name="headerHidden">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Dash</string>
|
||||
<string>Position</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
|
Loading…
x
Reference in New Issue
Block a user