mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Show item size in status bar when creating a new item
This commit is contained in:
parent
b95363c5b6
commit
1402f76e85
@ -46,7 +46,6 @@
|
||||
%Include layertree/qgslayertreeembeddedconfigwidget.sip
|
||||
%Include layertree/qgslayertreeembeddedwidgetregistry.sip
|
||||
%Include layout/qgslayoutviewmouseevent.sip
|
||||
%Include layout/qgslayoutviewrubberband.sip
|
||||
%Include raster/qgsrasterrendererwidget.sip
|
||||
%Include symbology/qgssymbolwidgetcontext.sip
|
||||
%Include qgisinterface.sip
|
||||
@ -295,6 +294,7 @@
|
||||
%Include layout/qgslayoutruler.sip
|
||||
%Include layout/qgslayoutunitscombobox.sip
|
||||
%Include layout/qgslayoutview.sip
|
||||
%Include layout/qgslayoutviewrubberband.sip
|
||||
%Include layout/qgslayoutviewtool.sip
|
||||
%Include layout/qgslayoutviewtooladditem.sip
|
||||
%Include layout/qgslayoutviewtooladdnodeitem.sip
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
|
||||
class QgsLayoutViewRubberBand
|
||||
class QgsLayoutViewRubberBand : QObject
|
||||
{
|
||||
%Docstring
|
||||
QgsLayoutViewRubberBand is an abstract base class for temporary rubber band items
|
||||
@ -109,6 +109,16 @@ Sets the ``pen`` used for drawing the rubber band.
|
||||
.. seealso:: :py:func:`pen`
|
||||
|
||||
.. seealso:: :py:func:`setBrush`
|
||||
%End
|
||||
|
||||
signals:
|
||||
|
||||
void sizeChanged( const QString &size );
|
||||
%Docstring
|
||||
Emitted when the size of the rubber band is changed. The ``size``
|
||||
argument gives a translated string describing the new rubber band size,
|
||||
with a format which differs per subclass (e.g. rectangles may describe
|
||||
a size using width and height, while circles may describe a size by radius).
|
||||
%End
|
||||
|
||||
protected:
|
||||
|
@ -690,6 +690,7 @@ SET(QGIS_GUI_MOC_HDRS
|
||||
layout/qgslayoutruler.h
|
||||
layout/qgslayoutunitscombobox.h
|
||||
layout/qgslayoutview.h
|
||||
layout/qgslayoutviewrubberband.h
|
||||
layout/qgslayoutviewtool.h
|
||||
layout/qgslayoutviewtooladditem.h
|
||||
layout/qgslayoutviewtooladdnodeitem.h
|
||||
@ -804,7 +805,6 @@ SET(QGIS_GUI_HDRS
|
||||
|
||||
layout/qgslayoutreportsectionlabel.h
|
||||
layout/qgslayoutviewmouseevent.h
|
||||
layout/qgslayoutviewrubberband.h
|
||||
|
||||
raster/qgsrasterrendererwidget.h
|
||||
|
||||
|
@ -169,6 +169,8 @@ void QgsLayoutViewRectangularRubberBand::update( QPointF position, Qt::KeyboardM
|
||||
QTransform t;
|
||||
t.translate( newRect.x(), newRect.y() );
|
||||
mRubberBandItem->setTransform( t );
|
||||
|
||||
emit sizeChanged( tr( "width: %1 %3 height: %2 %3" ).arg( newRect.width() ).arg( newRect.height() ).arg( QgsUnitTypes::toAbbreviatedString( layout()->units() ) ) );
|
||||
}
|
||||
|
||||
QRectF QgsLayoutViewRectangularRubberBand::finish( QPointF position, Qt::KeyboardModifiers modifiers )
|
||||
@ -234,6 +236,8 @@ void QgsLayoutViewEllipticalRubberBand::update( QPointF position, Qt::KeyboardMo
|
||||
QTransform t;
|
||||
t.translate( newRect.x(), newRect.y() );
|
||||
mRubberBandItem->setTransform( t );
|
||||
|
||||
emit sizeChanged( tr( "width: %1 %3 height: %2 %3" ).arg( newRect.width() ).arg( newRect.height() ).arg( QgsUnitTypes::toAbbreviatedString( layout()->units() ) ) );
|
||||
}
|
||||
|
||||
QRectF QgsLayoutViewEllipticalRubberBand::finish( QPointF position, Qt::KeyboardModifiers modifiers )
|
||||
@ -309,6 +313,8 @@ void QgsLayoutViewTriangleRubberBand::update( QPointF position, Qt::KeyboardModi
|
||||
QTransform t;
|
||||
t.translate( newRect.x(), newRect.y() );
|
||||
mRubberBandItem->setTransform( t );
|
||||
|
||||
emit sizeChanged( tr( "width: %1 %3 height: %2 %3" ).arg( newRect.width() ).arg( newRect.height() ).arg( QgsUnitTypes::toAbbreviatedString( layout()->units() ) ) );
|
||||
}
|
||||
|
||||
QRectF QgsLayoutViewTriangleRubberBand::finish( QPointF position, Qt::KeyboardModifiers modifiers )
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "qgis_sip.h"
|
||||
#include <QBrush>
|
||||
#include <QPen>
|
||||
#include <QObject>
|
||||
|
||||
class QgsLayoutView;
|
||||
class QGraphicsRectItem;
|
||||
@ -35,9 +36,11 @@ class QgsLayout;
|
||||
* in various shapes, for use within QgsLayoutView widgets.
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
class GUI_EXPORT QgsLayoutViewRubberBand
|
||||
class GUI_EXPORT QgsLayoutViewRubberBand : public QObject
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
#ifdef SIP_RUN
|
||||
SIP_CONVERT_TO_SUBCLASS_CODE
|
||||
if ( dynamic_cast<QgsLayoutViewMouseEvent *>( sipCpp ) )
|
||||
@ -120,6 +123,16 @@ class GUI_EXPORT QgsLayoutViewRubberBand
|
||||
*/
|
||||
void setPen( const QPen &pen );
|
||||
|
||||
signals:
|
||||
|
||||
/**
|
||||
* Emitted when the size of the rubber band is changed. The \a size
|
||||
* argument gives a translated string describing the new rubber band size,
|
||||
* with a format which differs per subclass (e.g. rectangles may describe
|
||||
* a size using width and height, while circles may describe a size by radius).
|
||||
*/
|
||||
void sizeChanged( const QString &size );
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
@ -56,6 +56,10 @@ void QgsLayoutViewToolAddItem::layoutPressEvent( QgsLayoutViewMouseEvent *event
|
||||
mRubberBand.reset( QgsGui::layoutItemGuiRegistry()->createItemRubberBand( mItemMetadataId, view() ) );
|
||||
if ( mRubberBand )
|
||||
{
|
||||
connect( mRubberBand.get(), &QgsLayoutViewRubberBand::sizeChanged, this, [ = ]( const QString & size )
|
||||
{
|
||||
view()->pushStatusMessage( size );
|
||||
} );
|
||||
mRubberBand->start( event->snappedPoint(), event->modifiers() );
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user