From e8e7f5ae9493b479f0c7c248e6c6b822beecea65 Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Wed, 8 May 2019 13:52:44 +0200 Subject: [PATCH 01/27] [cad] floater initial implementation --- src/gui/CMakeLists.txt | 2 + src/gui/qgsadvanceddigitizingdockwidget.cpp | 55 +++++- src/gui/qgsadvanceddigitizingdockwidget.h | 8 + src/gui/qgsadvanceddigitizingfloater.cpp | 142 +++++++++++++++ src/gui/qgsadvanceddigitizingfloater.h | 79 ++++++++ src/ui/qgsadvanceddigitizingdockwidgetbase.ui | 14 ++ src/ui/qgsadvanceddigitizingfloaterbase.ui | 168 ++++++++++++++++++ 7 files changed, 467 insertions(+), 1 deletion(-) create mode 100644 src/gui/qgsadvanceddigitizingfloater.cpp create mode 100644 src/gui/qgsadvanceddigitizingfloater.h create mode 100644 src/ui/qgsadvanceddigitizingfloaterbase.ui diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index ece906252418..83d5ac077bdd 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -214,6 +214,7 @@ SET(QGIS_GUI_SRCS qgsactionmenu.cpp qgsadvanceddigitizingcanvasitem.cpp qgsadvanceddigitizingdockwidget.cpp + qgsadvanceddigitizingfloater.cpp qgsaggregatetoolbutton.cpp qgsattributedialog.cpp qgsattributeform.cpp @@ -401,6 +402,7 @@ SET(QGIS_GUI_MOC_HDRS qgisinterface.h qgsactionmenu.h qgsadvanceddigitizingdockwidget.h + qgsadvanceddigitizingfloater.h qgsaggregatetoolbutton.h qgsattributedialog.h qgsattributeform.h diff --git a/src/gui/qgsadvanceddigitizingdockwidget.cpp b/src/gui/qgsadvanceddigitizingdockwidget.cpp index c6dcb7ac489c..4e5a5af2b36b 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.cpp +++ b/src/gui/qgsadvanceddigitizingdockwidget.cpp @@ -18,6 +18,7 @@ #include #include "qgsadvanceddigitizingdockwidget.h" +#include "qgsadvanceddigitizingfloater.h" #include "qgsadvanceddigitizingcanvasitem.h" #include "qgsapplication.h" #include "qgscadutils.h" @@ -33,6 +34,7 @@ #include "qgssnappingutils.h" #include "qgsproject.h" #include "qgsmapmouseevent.h" +#include "qgsmessagelog.h" QgsAdvancedDigitizingDockWidget::QgsAdvancedDigitizingDockWidget( QgsMapCanvas *canvas, QWidget *parent ) @@ -59,6 +61,7 @@ QgsAdvancedDigitizingDockWidget::QgsAdvancedDigitizingDockWidget( QgsMapCanvas * // Connect the UI to the event filter to update constraints connect( mEnableAction, &QAction::triggered, this, &QgsAdvancedDigitizingDockWidget::activateCad ); connect( mConstructionModeAction, &QAction::triggered, this, &QgsAdvancedDigitizingDockWidget::setConstructionMode ); + connect( mToggleFloaterAction, &QAction::triggered, this, &QgsAdvancedDigitizingDockWidget::toggleFloater ); connect( mParallelAction, &QAction::triggered, this, &QgsAdvancedDigitizingDockWidget::additionalConstraintClicked ); connect( mPerpendicularAction, &QAction::triggered, this, &QgsAdvancedDigitizingDockWidget::additionalConstraintClicked ); connect( mLockAngleButton, &QAbstractButton::clicked, this, &QgsAdvancedDigitizingDockWidget::lockConstraint ); @@ -141,6 +144,14 @@ QgsAdvancedDigitizingDockWidget::QgsAdvancedDigitizingDockWidget( QgsMapCanvas * mLockYButton->setToolTip( "" + tr( "Lock y coordinate" ) + "
(" + tr( "press Ctrl + y for quick access" ) + ")" ); mRepeatingLockYButton->setToolTip( "" + tr( "Continuously lock y coordinate" ) + "" ); + // Create the floater + mFloater = new QgsAdvancedDigitizingFloater(canvas, this); + mToggleFloaterAction->setChecked(QgsSettings().value(QStringLiteral("/Cad/Floater"), false).toBool()); + toggleFloater(QgsSettings().value(QStringLiteral("/Cad/Floater"), false).toBool()); + connect(mXLineEdit, &QLineEdit::textChanged, mFloater, &QgsAdvancedDigitizingFloater::changeX); + connect(mYLineEdit, &QLineEdit::textChanged, mFloater, &QgsAdvancedDigitizingFloater::changeY); + connect(mDistanceLineEdit, &QLineEdit::textChanged, mFloater, &QgsAdvancedDigitizingFloater::changeDistance); + connect(mAngleLineEdit, &QLineEdit::textChanged, mFloater, &QgsAdvancedDigitizingFloater::changeAngle); updateCapacity( true ); connect( QgsProject::instance(), &QgsProject::snappingConfigChanged, this, [ = ] { updateCapacity( true ); } ); @@ -148,13 +159,16 @@ QgsAdvancedDigitizingDockWidget::QgsAdvancedDigitizingDockWidget( QgsMapCanvas * disable(); } + void QgsAdvancedDigitizingDockWidget::hideEvent( QHideEvent * ) { // disable CAD but do not unset map event filter // so it will be reactivated whenever the map tool is show again - setCadEnabled( false ); + // TODO : remove this (we don't want to disable CAD events, even when the dockerwidget is hidden) + // setCadEnabled( false ); } + void QgsAdvancedDigitizingDockWidget::setCadEnabled( bool enabled ) { mCadEnabled = enabled; @@ -235,6 +249,14 @@ void QgsAdvancedDigitizingDockWidget::setConstraintRepeatingLock( bool activate } } +void QgsAdvancedDigitizingDockWidget::toggleFloater( bool enabled ) +{ + mFloater->setActive(enabled); + mToggleFloaterAction->setChecked( enabled ); + QgsSettings().setValue( QStringLiteral( "/Cad/Floater" ), enabled ); +} + + void QgsAdvancedDigitizingDockWidget::setConstructionMode( bool enabled ) { mConstructionMode = enabled; @@ -261,13 +283,25 @@ void QgsAdvancedDigitizingDockWidget::releaseLocks( bool releaseRepeatingLocks ) lockAdditionalConstraint( AdditionalConstraint::NoConstraint ); if ( releaseRepeatingLocks || !mAngleConstraint->isRepeatingLock() ) + { mAngleConstraint->setLockMode( CadConstraint::NoLock ); + mFloater->changeLockAngle(false); + } if ( releaseRepeatingLocks || !mDistanceConstraint->isRepeatingLock() ) + { mDistanceConstraint->setLockMode( CadConstraint::NoLock ); + mFloater->changeLockDistance(false); + } if ( releaseRepeatingLocks || !mXConstraint->isRepeatingLock() ) + { mXConstraint->setLockMode( CadConstraint::NoLock ); + mFloater->changeLockX(false); + } if ( releaseRepeatingLocks || !mYConstraint->isRepeatingLock() ) + { mYConstraint->setLockMode( CadConstraint::NoLock ); + mFloater->changeLockY(false); + } } #if 0 @@ -375,6 +409,20 @@ void QgsAdvancedDigitizingDockWidget::lockConstraint( bool activate /* default t } constraint->setLockMode( activate ? CadConstraint::HardLock : CadConstraint::NoLock ); + // TODO : this should be implemented with signals on the constraints + if( constraint == mXConstraint.get() ){ + mFloater->changeLockX(activate); + } + else if( constraint == mYConstraint.get() ){ + mFloater->changeLockY(activate); + } + else if( constraint == mDistanceConstraint.get() ){ + mFloater->changeLockDistance(activate); + } + else if( constraint == mAngleConstraint.get() ){ + mFloater->changeLockAngle(activate); + } + if ( activate ) { // deactivate perpendicular/parallel if angle has been activated @@ -825,6 +873,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) if ( type == QEvent::ShortcutOverride && ( e->modifiers() == Qt::AltModifier || e->modifiers() == Qt::ControlModifier ) ) { mXConstraint->toggleLocked(); + mFloater->changeLockX(mXConstraint->isLocked()); emit pointChanged( mCadPointList.value( 0 ) ); e->accept(); } @@ -852,6 +901,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) if ( type == QEvent::ShortcutOverride && ( e->modifiers() == Qt::AltModifier || e->modifiers() == Qt::ControlModifier ) ) { mYConstraint->toggleLocked(); + mFloater->changeLockY(mYConstraint->isLocked()); emit pointChanged( mCadPointList.value( 0 ) ); e->accept(); } @@ -881,6 +931,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) if ( mCapacities.testFlag( AbsoluteAngle ) ) { mAngleConstraint->toggleLocked(); + mFloater->changeLockAngle(mAngleConstraint->isLocked()); emit pointChanged( mCadPointList.value( 0 ) ); e->accept(); } @@ -911,6 +962,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) if ( mCapacities.testFlag( RelativeCoordinates ) ) { mDistanceConstraint->toggleLocked(); + mFloater->changeLockDistance(mDistanceConstraint->isLocked()); emit pointChanged( mCadPointList.value( 0 ) ); e->accept(); } @@ -1076,6 +1128,7 @@ void QgsAdvancedDigitizingDockWidget::CadConstraint::setLockMode( LockMode mode { mLineEdit->clear(); } + } void QgsAdvancedDigitizingDockWidget::CadConstraint::setRepeatingLock( bool repeating ) diff --git a/src/gui/qgsadvanceddigitizingdockwidget.h b/src/gui/qgsadvanceddigitizingdockwidget.h index e0c81fa48240..393ea445710e 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.h +++ b/src/gui/qgsadvanceddigitizingdockwidget.h @@ -21,6 +21,7 @@ #include #include "ui_qgsadvanceddigitizingdockwidgetbase.h" +#include "qgsadvanceddigitizingfloater.h" #include "qgis_gui.h" #include "qgis_sip.h" #include "qgsdockwidget.h" @@ -30,6 +31,7 @@ class QgsAdvancedDigitizingCanvasItem; +class QgsAdvancedDigitizingFloater; class QgsMapCanvas; class QgsMapTool; class QgsMapToolAdvancedDigitizing; @@ -399,6 +401,9 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private */ void activateCad( bool enabled ); + //! enable/disable floater + void toggleFloater( bool enabled ); + //! enable/disable construction mode (events are not forwarded to the map tool) void setConstructionMode( bool enabled ); @@ -469,6 +474,9 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private bool mCurrentMapToolSupportsCad = false; + // Pointer to the floater + QgsAdvancedDigitizingFloater *mFloater = nullptr; + // CAD properties //! is CAD currently enabled for current map tool bool mCadEnabled = false; diff --git a/src/gui/qgsadvanceddigitizingfloater.cpp b/src/gui/qgsadvanceddigitizingfloater.cpp new file mode 100644 index 000000000000..ae17d124defe --- /dev/null +++ b/src/gui/qgsadvanceddigitizingfloater.cpp @@ -0,0 +1,142 @@ +/*************************************************************************** + qgsadvanceddigitizingfloater.cpp - floater for CAD tools + ---------------------- + begin : May 2019 + copyright : (C) Olivier Dalang + email : olivier.dalang@gmail.com + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include +#include +#include + +#include "qgsadvanceddigitizingfloater.h" +#include "qgsmessagelog.h" +#include "qgsmapcanvas.h" + +QgsAdvancedDigitizingFloater::QgsAdvancedDigitizingFloater(QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget) + : QWidget(canvas->viewport()), mMapCanvas(canvas), mCadDockWidget(cadDockWidget) +{ + setupUi(this); + setWindowFlag(Qt::FramelessWindowHint); + setAttribute(Qt::WA_TransparentForMouseEvents); + setVisible(false); + mMapCanvas->viewport()->installEventFilter(this); + mMapCanvas->viewport()->setMouseTracking(true); + + // We use the same event filter so that shortcuts are still active + mAngleLineEdit->installEventFilter( cadDockWidget ); + mDistanceLineEdit->installEventFilter( cadDockWidget ); + mXLineEdit->installEventFilter( cadDockWidget ); + mYLineEdit->installEventFilter( cadDockWidget ); + + //connect(mEnableAction, &QAction::triggered, this, &QgsAdvancedDigitizingDockWidget::activateCad); +} + +bool QgsAdvancedDigitizingFloater::eventFilter(QObject *obj, QEvent *event) +{ + if (mCadDockWidget->cadEnabled() && mActive) { + if (event->type() == QEvent::MouseMove) + { + QMouseEvent *mouseEvent = dynamic_cast(event); + updatePos(mouseEvent->pos()); + } + else if (event->type() == QEvent::Enter) + { + QEnterEvent *enterEvent = dynamic_cast(event); + updatePos(enterEvent->pos()); + setVisible(true); + } + else if (event->type() == QEvent::Leave) + { + setVisible(false); + } + } + return QWidget::eventFilter(obj, event); +} + +bool QgsAdvancedDigitizingFloater::active() +{ + return mActive; +} +void QgsAdvancedDigitizingFloater::setActive(bool active) +{ + mActive = active; + if (!active) { + setVisible(false); + } +} + +void QgsAdvancedDigitizingFloater::updatePos(QPoint pos) +{ + //QPoint newPos = mMapCanvas->mapToGlobal(pos) + QPoint(10, -10); + //move(newPos); + move(pos + QPoint(15,5)); +} + +void QgsAdvancedDigitizingFloater::changeX(QString text) +{ + mXLineEdit->setText(text); +} + +void QgsAdvancedDigitizingFloater::changeY(QString text) +{ + mYLineEdit->setText(text); +} + +void QgsAdvancedDigitizingFloater::changeDistance(QString text) +{ + mDistanceLineEdit->setText(text); +} + +void QgsAdvancedDigitizingFloater::changeAngle(QString text) +{ + mAngleLineEdit->setText(text); +} + +void QgsAdvancedDigitizingFloater::changeLockX(bool enabled) +{ + if (!enabled) { + mXLineEdit->setStyleSheet(""); + } + else { + mXLineEdit->setStyleSheet("font-weight: bold"); + } +} + +void QgsAdvancedDigitizingFloater::changeLockY(bool enabled) +{ + if (!enabled) { + mYLineEdit->setStyleSheet(""); + } + else { + mYLineEdit->setStyleSheet("font-weight: bold"); + } +} + +void QgsAdvancedDigitizingFloater::changeLockDistance(bool enabled) +{ + if (!enabled) { + mDistanceLineEdit->setStyleSheet(""); + } + else { + mDistanceLineEdit->setStyleSheet("font-weight: bold"); + } +} + +void QgsAdvancedDigitizingFloater::changeLockAngle(bool enabled) +{ + if (!enabled) { + mAngleLineEdit->setStyleSheet(""); + } + else { + mAngleLineEdit->setStyleSheet("font-weight: bold"); + } +} diff --git a/src/gui/qgsadvanceddigitizingfloater.h b/src/gui/qgsadvanceddigitizingfloater.h new file mode 100644 index 000000000000..f7d9e0a737ee --- /dev/null +++ b/src/gui/qgsadvanceddigitizingfloater.h @@ -0,0 +1,79 @@ +/*************************************************************************** + qgsadvanceddigitizingfloater.cpp - floater for CAD tools + ---------------------- + begin : May 2019 + copyright : (C) Olivier Dalang + email : olivier.dalang@gmail.com + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef QGSADVANCEDDIGITIZINGFLOATER +#define QGSADVANCEDDIGITIZINGFLOATER + +#include +#include + +#include "ui_qgsadvanceddigitizingfloaterbase.h" +#include "qgsadvanceddigitizingdockwidget.h" +#include "qgis_gui.h" +#include "qgis_sip.h" + +class QgsMapCanvas; +class QgsAdvancedDigitizingDockWidget; + +class GUI_EXPORT QgsAdvancedDigitizingFloater : public QWidget, private Ui::QgsAdvancedDigitizingFloaterBase +{ + Q_OBJECT + + public: + + explicit QgsAdvancedDigitizingFloater(QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget); + + /** + * getter for mActive + */ + bool active(); + + public slots: + void setActive(bool active); + void changeX(QString text); + void changeY(QString text); + void changeDistance(QString text); + void changeAngle(QString text); + void changeLockX(bool enabled); + void changeLockY(bool enabled); + void changeLockDistance(bool enabled); + void changeLockAngle(bool enabled); + + private: + + //! pointer to map canvas + QgsMapCanvas *mMapCanvas = nullptr; + + //! pointer to map cad docker widget + QgsAdvancedDigitizingDockWidget *mCadDockWidget = nullptr; + + //! Whether the floater is enabled + bool mActive = false; + + /** + * event filter to track mouse position + * \note defined as private in Python bindings + */ + bool eventFilter(QObject *obj, QEvent *event) override SIP_SKIP; + + /** + * move the widget + * \param pos position of the cursor + */ + void updatePos(QPoint pos); + +}; + +#endif // QGSADVANCEDDIGITIZINGFLOATER_H diff --git a/src/ui/qgsadvanceddigitizingdockwidgetbase.ui b/src/ui/qgsadvanceddigitizingdockwidgetbase.ui index 58b48db517f9..c795786a7024 100644 --- a/src/ui/qgsadvanceddigitizingdockwidgetbase.ui +++ b/src/ui/qgsadvanceddigitizingdockwidgetbase.ui @@ -54,6 +54,8 @@ + + @@ -466,6 +468,18 @@ + + + true + + + + :/images/themes/default/propertyicons/display.svg:/images/themes/default/propertyicons/display.svg + + + Toggle Floater + + diff --git a/src/ui/qgsadvanceddigitizingfloaterbase.ui b/src/ui/qgsadvanceddigitizingfloaterbase.ui new file mode 100644 index 000000000000..d1b2715e0dca --- /dev/null +++ b/src/ui/qgsadvanceddigitizingfloaterbase.ui @@ -0,0 +1,168 @@ + + + QgsAdvancedDigitizingFloaterBase + + + + 0 + 0 + 128 + 77 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 6 + + + 2 + + + + + a + + + + + + + + 16777215 + 14 + + + + + 8 + + + + + + + - + + + false + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + 40 + 0 + + + + + 16777215 + 14 + + + + + + + - + + + false + + + + + + + + 40 + 0 + + + + + 16777215 + 14 + + + + + + + - + + + false + + + + + + + x + + + + + + + y + + + + + + + + 40 + 0 + + + + + 16777215 + 14 + + + + + + + - + + + false + + + + + + + d + + + + + + + + + + From 6dd0b787aeee5874c5d8576ce18fb19a1f037522 Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Wed, 8 May 2019 16:05:13 +0200 Subject: [PATCH 02/27] hide unused labels --- src/gui/qgsadvanceddigitizingfloater.cpp | 8 ++++++++ src/ui/qgsadvanceddigitizingfloaterbase.ui | 21 +++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/gui/qgsadvanceddigitizingfloater.cpp b/src/gui/qgsadvanceddigitizingfloater.cpp index ae17d124defe..9d1e83de4c1f 100644 --- a/src/gui/qgsadvanceddigitizingfloater.cpp +++ b/src/gui/qgsadvanceddigitizingfloater.cpp @@ -84,21 +84,29 @@ void QgsAdvancedDigitizingFloater::updatePos(QPoint pos) void QgsAdvancedDigitizingFloater::changeX(QString text) { mXLineEdit->setText(text); + mXLineEdit->setVisible(text != QString("")); + mXLabel->setVisible(text != QString("")); } void QgsAdvancedDigitizingFloater::changeY(QString text) { mYLineEdit->setText(text); + mYLineEdit->setVisible(text != QString("")); + mYLabel->setVisible(text != QString("")); } void QgsAdvancedDigitizingFloater::changeDistance(QString text) { mDistanceLineEdit->setText(text); + mDistanceLineEdit->setVisible(text != QString("")); + mDistanceLabel->setVisible(text != QString("")); } void QgsAdvancedDigitizingFloater::changeAngle(QString text) { mAngleLineEdit->setText(text); + mAngleLineEdit->setVisible(text != QString("")); + mAngleLabel->setVisible(text != QString("")); } void QgsAdvancedDigitizingFloater::changeLockX(bool enabled) diff --git a/src/ui/qgsadvanceddigitizingfloaterbase.ui b/src/ui/qgsadvanceddigitizingfloaterbase.ui index d1b2715e0dca..fd372ac2f6b3 100644 --- a/src/ui/qgsadvanceddigitizingfloaterbase.ui +++ b/src/ui/qgsadvanceddigitizingfloaterbase.ui @@ -30,7 +30,7 @@ 2 - + a @@ -114,14 +114,14 @@ - + x - + y @@ -153,12 +153,25 @@ - + d + + + + Qt::Vertical + + + + 20 + 40 + + + + From dc5d51af3b57ecfab8e4bdafde9b814abc2c8abe Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Thu, 9 May 2019 12:08:13 +0200 Subject: [PATCH 03/27] implementation with signals/slots --- src/gui/qgsadvanceddigitizingdockwidget.cpp | 60 +++++++---- src/gui/qgsadvanceddigitizingdockwidget.h | 32 ++++++ src/gui/qgsadvanceddigitizingfloater.cpp | 107 +++++++++++++++++--- src/gui/qgsadvanceddigitizingfloater.h | 27 +++-- 4 files changed, 185 insertions(+), 41 deletions(-) diff --git a/src/gui/qgsadvanceddigitizingdockwidget.cpp b/src/gui/qgsadvanceddigitizingdockwidget.cpp index 4e5a5af2b36b..891e01bdd491 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.cpp +++ b/src/gui/qgsadvanceddigitizingdockwidget.cpp @@ -144,14 +144,17 @@ QgsAdvancedDigitizingDockWidget::QgsAdvancedDigitizingDockWidget( QgsMapCanvas * mLockYButton->setToolTip( "" + tr( "Lock y coordinate" ) + "
(" + tr( "press Ctrl + y for quick access" ) + ")" ); mRepeatingLockYButton->setToolTip( "" + tr( "Continuously lock y coordinate" ) + "" ); + // Create the slots/signals + connect(mXLineEdit, &QLineEdit::textChanged, this, &QgsAdvancedDigitizingDockWidget::valueXChanged); + connect(mYLineEdit, &QLineEdit::textChanged, this, &QgsAdvancedDigitizingDockWidget::valueYChanged); + connect(mDistanceLineEdit, &QLineEdit::textChanged, this, &QgsAdvancedDigitizingDockWidget::valueDistanceChanged); + connect(mAngleLineEdit, &QLineEdit::textChanged, this, &QgsAdvancedDigitizingDockWidget::valueAngleChanged); + + // Create the floater mFloater = new QgsAdvancedDigitizingFloater(canvas, this); mToggleFloaterAction->setChecked(QgsSettings().value(QStringLiteral("/Cad/Floater"), false).toBool()); toggleFloater(QgsSettings().value(QStringLiteral("/Cad/Floater"), false).toBool()); - connect(mXLineEdit, &QLineEdit::textChanged, mFloater, &QgsAdvancedDigitizingFloater::changeX); - connect(mYLineEdit, &QLineEdit::textChanged, mFloater, &QgsAdvancedDigitizingFloater::changeY); - connect(mDistanceLineEdit, &QLineEdit::textChanged, mFloater, &QgsAdvancedDigitizingFloater::changeDistance); - connect(mAngleLineEdit, &QLineEdit::textChanged, mFloater, &QgsAdvancedDigitizingFloater::changeAngle); updateCapacity( true ); connect( QgsProject::instance(), &QgsProject::snappingConfigChanged, this, [ = ] { updateCapacity( true ); } ); @@ -169,6 +172,24 @@ void QgsAdvancedDigitizingDockWidget::hideEvent( QHideEvent * ) } +void QgsAdvancedDigitizingDockWidget::setX(QString value){ + mXLineEdit->setText(value); + mXLineEdit->returnPressed(); +} +void QgsAdvancedDigitizingDockWidget::setY(QString value){ + mYLineEdit->setText(value); + mYLineEdit->returnPressed(); +} +void QgsAdvancedDigitizingDockWidget::setAngle(QString value){ + mAngleLineEdit->setText(value); + mAngleLineEdit->returnPressed(); +} +void QgsAdvancedDigitizingDockWidget::setDistance(QString value){ + mDistanceLineEdit->setText(value); + mDistanceLineEdit->returnPressed(); +} + + void QgsAdvancedDigitizingDockWidget::setCadEnabled( bool enabled ) { mCadEnabled = enabled; @@ -285,22 +306,22 @@ void QgsAdvancedDigitizingDockWidget::releaseLocks( bool releaseRepeatingLocks ) if ( releaseRepeatingLocks || !mAngleConstraint->isRepeatingLock() ) { mAngleConstraint->setLockMode( CadConstraint::NoLock ); - mFloater->changeLockAngle(false); + emit lockAngleChanged(false); } if ( releaseRepeatingLocks || !mDistanceConstraint->isRepeatingLock() ) { mDistanceConstraint->setLockMode( CadConstraint::NoLock ); - mFloater->changeLockDistance(false); + emit lockDistanceChanged(false); } if ( releaseRepeatingLocks || !mXConstraint->isRepeatingLock() ) { mXConstraint->setLockMode( CadConstraint::NoLock ); - mFloater->changeLockX(false); + emit lockXChanged(false); } if ( releaseRepeatingLocks || !mYConstraint->isRepeatingLock() ) { mYConstraint->setLockMode( CadConstraint::NoLock ); - mFloater->changeLockY(false); + emit lockYChanged(false); } } @@ -409,18 +430,17 @@ void QgsAdvancedDigitizingDockWidget::lockConstraint( bool activate /* default t } constraint->setLockMode( activate ? CadConstraint::HardLock : CadConstraint::NoLock ); - // TODO : this should be implemented with signals on the constraints if( constraint == mXConstraint.get() ){ - mFloater->changeLockX(activate); + emit lockXChanged(activate); } else if( constraint == mYConstraint.get() ){ - mFloater->changeLockY(activate); + emit lockYChanged(activate); } else if( constraint == mDistanceConstraint.get() ){ - mFloater->changeLockDistance(activate); + emit lockDistanceChanged(activate); } else if( constraint == mAngleConstraint.get() ){ - mFloater->changeLockAngle(activate); + emit lockAngleChanged(activate); } if ( activate ) @@ -520,6 +540,7 @@ void QgsAdvancedDigitizingDockWidget::updateCapacity( bool updateUIwithoutChange mLockAngleButton->setEnabled( absoluteAngle ); mRelativeAngleButton->setEnabled( relativeAngle ); mAngleLineEdit->setEnabled( absoluteAngle ); + emit enabledChangedAngle(absoluteAngle); if ( !absoluteAngle ) { mAngleConstraint->setLockMode( CadConstraint::NoLock ); @@ -537,6 +558,7 @@ void QgsAdvancedDigitizingDockWidget::updateCapacity( bool updateUIwithoutChange // distance is always relative mLockDistanceButton->setEnabled( relativeCoordinates ); mDistanceLineEdit->setEnabled( relativeCoordinates ); + emit enabledChangedDistance(relativeCoordinates); if ( !relativeCoordinates ) { mDistanceConstraint->setLockMode( CadConstraint::NoLock ); @@ -873,7 +895,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) if ( type == QEvent::ShortcutOverride && ( e->modifiers() == Qt::AltModifier || e->modifiers() == Qt::ControlModifier ) ) { mXConstraint->toggleLocked(); - mFloater->changeLockX(mXConstraint->isLocked()); + emit lockXChanged(mXConstraint->isLocked()); emit pointChanged( mCadPointList.value( 0 ) ); e->accept(); } @@ -891,6 +913,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) { mXLineEdit->setFocus(); mXLineEdit->selectAll(); + emit focusOnX(); e->accept(); } break; @@ -901,7 +924,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) if ( type == QEvent::ShortcutOverride && ( e->modifiers() == Qt::AltModifier || e->modifiers() == Qt::ControlModifier ) ) { mYConstraint->toggleLocked(); - mFloater->changeLockY(mYConstraint->isLocked()); + emit lockYChanged(mYConstraint->isLocked()); emit pointChanged( mCadPointList.value( 0 ) ); e->accept(); } @@ -919,6 +942,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) { mYLineEdit->setFocus(); mYLineEdit->selectAll(); + emit focusOnY(); e->accept(); } break; @@ -931,7 +955,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) if ( mCapacities.testFlag( AbsoluteAngle ) ) { mAngleConstraint->toggleLocked(); - mFloater->changeLockAngle(mAngleConstraint->isLocked()); + emit lockAngleChanged(mAngleConstraint->isLocked()); emit pointChanged( mCadPointList.value( 0 ) ); e->accept(); } @@ -950,6 +974,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) { mAngleLineEdit->setFocus(); mAngleLineEdit->selectAll(); + emit focusOnAngle(); e->accept(); } break; @@ -962,7 +987,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) if ( mCapacities.testFlag( RelativeCoordinates ) ) { mDistanceConstraint->toggleLocked(); - mFloater->changeLockDistance(mDistanceConstraint->isLocked()); + emit lockDistanceChanged(mDistanceConstraint->isLocked()); emit pointChanged( mCadPointList.value( 0 ) ); e->accept(); } @@ -972,6 +997,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) { mDistanceLineEdit->setFocus(); mDistanceLineEdit->selectAll(); + emit focusOnDistance(); e->accept(); } break; diff --git a/src/gui/qgsadvanceddigitizingdockwidget.h b/src/gui/qgsadvanceddigitizingdockwidget.h index 393ea445710e..58dc5bc44637 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.h +++ b/src/gui/qgsadvanceddigitizingdockwidget.h @@ -370,6 +370,38 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private */ void pointChanged( const QgsPointXY &point ); + // These are emitted when the value of the field has changed (either the mouse moved, or the user changed the input) + void valueXChanged(QString value); + void valueYChanged(QString value); + void valueAngleChanged(QString value); + void valueDistanceChanged(QString value); + + // These are emitted when locked state was changed (either after an input, or the user triggered the lock) + void lockXChanged(bool locked); + void lockYChanged(bool locked); + void lockAngleChanged(bool locked); + void lockDistanceChanged(bool locked); + + // These are emitted when a is enabled/disabled + void enabledChangedX(bool enabled); + void enabledChangedY(bool enabled); + void enabledChangedAngle(bool enabled); + void enabledChangedDistance(bool enabled); + + // These are emitted when a field gets the focus (allowing other widget to capture the focus) + void focusOnX(); + void focusOnY(); + void focusOnAngle(); + void focusOnDistance(); + + + public slots: + void setX(QString value); + void setY(QString value); + void setAngle(QString value); + void setDistance(QString value); + + private slots: //! Sets the additional constraint by clicking on the perpendicular/parallel buttons void additionalConstraintClicked( bool activated ); diff --git a/src/gui/qgsadvanceddigitizingfloater.cpp b/src/gui/qgsadvanceddigitizingfloater.cpp index 9d1e83de4c1f..511aee0b36a6 100644 --- a/src/gui/qgsadvanceddigitizingfloater.cpp +++ b/src/gui/qgsadvanceddigitizingfloater.cpp @@ -38,6 +38,32 @@ QgsAdvancedDigitizingFloater::QgsAdvancedDigitizingFloater(QgsMapCanvas *canvas, mYLineEdit->installEventFilter( cadDockWidget ); //connect(mEnableAction, &QAction::triggered, this, &QgsAdvancedDigitizingDockWidget::activateCad); + connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueXChanged, this, &QgsAdvancedDigitizingFloater::changeX); + connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueYChanged, this, &QgsAdvancedDigitizingFloater::changeY); + connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueAngleChanged, this, &QgsAdvancedDigitizingFloater::changeAngle); + connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueDistanceChanged, this, &QgsAdvancedDigitizingFloater::changeDistance); + + connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockXChanged, this, &QgsAdvancedDigitizingFloater::changeLockX); + connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockYChanged, this, &QgsAdvancedDigitizingFloater::changeLockY); + connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockAngleChanged, this, &QgsAdvancedDigitizingFloater::changeLockAngle); + connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockDistanceChanged, this, &QgsAdvancedDigitizingFloater::changeLockDistance); + + connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnX, this, &QgsAdvancedDigitizingFloater::focusOnX); + connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnY, this, &QgsAdvancedDigitizingFloater::focusOnY); + connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnAngle, this, &QgsAdvancedDigitizingFloater::focusOnAngle); + connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnDistance, this, &QgsAdvancedDigitizingFloater::focusOnDistance); + + connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedX, this, &QgsAdvancedDigitizingFloater::enabledChangedX); + connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedY, this, &QgsAdvancedDigitizingFloater::enabledChangedY); + connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedAngle, this, &QgsAdvancedDigitizingFloater::enabledChangedAngle); + connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedDistance, this, &QgsAdvancedDigitizingFloater::enabledChangedDistance); + + connect(mXLineEdit, &QLineEdit::returnPressed, cadDockWidget, [=]() { cadDockWidget->setX(mXLineEdit->text()); }); + connect(mYLineEdit, &QLineEdit::returnPressed, cadDockWidget, [=]() { cadDockWidget->setY(mYLineEdit->text()); }); + connect(mAngleLineEdit, &QLineEdit::returnPressed, cadDockWidget, [=]() { cadDockWidget->setAngle(mAngleLineEdit->text()); }); + connect(mDistanceLineEdit, &QLineEdit::returnPressed, cadDockWidget, [=]() { cadDockWidget->setDistance(mDistanceLineEdit->text()); }); + + } bool QgsAdvancedDigitizingFloater::eventFilter(QObject *obj, QEvent *event) @@ -84,34 +110,26 @@ void QgsAdvancedDigitizingFloater::updatePos(QPoint pos) void QgsAdvancedDigitizingFloater::changeX(QString text) { mXLineEdit->setText(text); - mXLineEdit->setVisible(text != QString("")); - mXLabel->setVisible(text != QString("")); } void QgsAdvancedDigitizingFloater::changeY(QString text) { mYLineEdit->setText(text); - mYLineEdit->setVisible(text != QString("")); - mYLabel->setVisible(text != QString("")); } void QgsAdvancedDigitizingFloater::changeDistance(QString text) { mDistanceLineEdit->setText(text); - mDistanceLineEdit->setVisible(text != QString("")); - mDistanceLabel->setVisible(text != QString("")); } void QgsAdvancedDigitizingFloater::changeAngle(QString text) { mAngleLineEdit->setText(text); - mAngleLineEdit->setVisible(text != QString("")); - mAngleLabel->setVisible(text != QString("")); } -void QgsAdvancedDigitizingFloater::changeLockX(bool enabled) +void QgsAdvancedDigitizingFloater::changeLockX(bool locked) { - if (!enabled) { + if (!locked) { mXLineEdit->setStyleSheet(""); } else { @@ -119,9 +137,9 @@ void QgsAdvancedDigitizingFloater::changeLockX(bool enabled) } } -void QgsAdvancedDigitizingFloater::changeLockY(bool enabled) +void QgsAdvancedDigitizingFloater::changeLockY(bool locked) { - if (!enabled) { + if (!locked) { mYLineEdit->setStyleSheet(""); } else { @@ -129,9 +147,9 @@ void QgsAdvancedDigitizingFloater::changeLockY(bool enabled) } } -void QgsAdvancedDigitizingFloater::changeLockDistance(bool enabled) +void QgsAdvancedDigitizingFloater::changeLockDistance(bool locked) { - if (!enabled) { + if (!locked) { mDistanceLineEdit->setStyleSheet(""); } else { @@ -139,12 +157,69 @@ void QgsAdvancedDigitizingFloater::changeLockDistance(bool enabled) } } -void QgsAdvancedDigitizingFloater::changeLockAngle(bool enabled) +void QgsAdvancedDigitizingFloater::changeLockAngle(bool locked) { - if (!enabled) { + if (!locked) { mAngleLineEdit->setStyleSheet(""); } else { mAngleLineEdit->setStyleSheet("font-weight: bold"); } } + +void QgsAdvancedDigitizingFloater::focusOnX() +{ + if(mActive){ + mXLineEdit->setFocus(); + mXLineEdit->selectAll(); + } +} + +void QgsAdvancedDigitizingFloater::focusOnY() +{ + if (mActive) { + mYLineEdit->setFocus(); + mYLineEdit->selectAll(); +} +} + +void QgsAdvancedDigitizingFloater::focusOnDistance() +{ + if (mActive) { + mDistanceLineEdit->setFocus(); + mDistanceLineEdit->selectAll(); +} +} + +void QgsAdvancedDigitizingFloater::focusOnAngle() +{ + if (mActive) { + mAngleLineEdit->setFocus(); + mAngleLineEdit->selectAll(); +} +} + + +void QgsAdvancedDigitizingFloater::enabledChangedX(bool enabled) +{ + mXLineEdit->setVisible(enabled); + mXLabel->setVisible(enabled); +} + +void QgsAdvancedDigitizingFloater::enabledChangedY(bool enabled) +{ + mYLineEdit->setVisible(enabled); + mYLabel->setVisible(enabled); +} + +void QgsAdvancedDigitizingFloater::enabledChangedDistance(bool enabled) +{ + mDistanceLineEdit->setVisible(enabled); + mDistanceLabel->setVisible(enabled); +} + +void QgsAdvancedDigitizingFloater::enabledChangedAngle(bool enabled) +{ + mAngleLineEdit->setVisible(enabled); + mAngleLabel->setVisible(enabled); +} diff --git a/src/gui/qgsadvanceddigitizingfloater.h b/src/gui/qgsadvanceddigitizingfloater.h index f7d9e0a737ee..520806fe2684 100644 --- a/src/gui/qgsadvanceddigitizingfloater.h +++ b/src/gui/qgsadvanceddigitizingfloater.h @@ -42,14 +42,25 @@ class GUI_EXPORT QgsAdvancedDigitizingFloater : public QWidget, private Ui::QgsA public slots: void setActive(bool active); - void changeX(QString text); - void changeY(QString text); - void changeDistance(QString text); - void changeAngle(QString text); - void changeLockX(bool enabled); - void changeLockY(bool enabled); - void changeLockDistance(bool enabled); - void changeLockAngle(bool enabled); + +private slots: + + void changeX(QString text); + void changeY(QString text); + void changeDistance(QString text); + void changeAngle(QString text); + void changeLockX(bool locked); + void changeLockY(bool locked); + void changeLockDistance(bool locked); + void changeLockAngle(bool locked); + void focusOnX(); + void focusOnY(); + void focusOnAngle(); + void focusOnDistance(); + void enabledChangedX(bool enabled); + void enabledChangedY(bool enabled); + void enabledChangedAngle(bool enabled); + void enabledChangedDistance(bool enabled); private: From 90a89d85da4f56e1fdb67ccb39b502b6b409212a Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Thu, 9 May 2019 12:09:36 +0200 Subject: [PATCH 04/27] docstrings & cleanup --- src/gui/qgsadvanceddigitizingdockwidget.h | 35 ++++++++++++++++++++--- src/gui/qgsadvanceddigitizingfloater.cpp | 18 +++++++----- src/gui/qgsadvanceddigitizingfloater.h | 21 +++++++++++--- 3 files changed, 59 insertions(+), 15 deletions(-) diff --git a/src/gui/qgsadvanceddigitizingdockwidget.h b/src/gui/qgsadvanceddigitizingdockwidget.h index 58dc5bc44637..718a1b53abe9 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.h +++ b/src/gui/qgsadvanceddigitizingdockwidget.h @@ -370,25 +370,46 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private */ void pointChanged( const QgsPointXY &point ); - // These are emitted when the value of the field has changed (either the mouse moved, or the user changed the input) + //! Signals for external widgets that need to update according to current values + + /** + * Emitted whenever the value changes (either the mouse moved, or the user changed the input). + * Could be used by widgets that must reflect the current advanced digitizing state. + * + * \param value The current value (as a QString, as it could be an expression). + */ void valueXChanged(QString value); void valueYChanged(QString value); void valueAngleChanged(QString value); void valueDistanceChanged(QString value); - // These are emitted when locked state was changed (either after an input, or the user triggered the lock) + /** + * Emitted whenever the parameter is locked. + * Could be used by widgets that must reflect the current advanced digitizing state. + * + * \param locked Whether the parameter is locked or not. + */ void lockXChanged(bool locked); void lockYChanged(bool locked); void lockAngleChanged(bool locked); void lockDistanceChanged(bool locked); - // These are emitted when a is enabled/disabled + /** + * Emitted whenever the field is enabled or disabled. Depending on the context, some parameters + * dont make sense (e.g. you need a previous point to define a distance). + * Could be used by widgets that must reflect the current advanced digitizing state. + * + * \param enabled Whether the parameter is enabled or not. + */ void enabledChangedX(bool enabled); void enabledChangedY(bool enabled); void enabledChangedAngle(bool enabled); void enabledChangedDistance(bool enabled); - // These are emitted when a field gets the focus (allowing other widget to capture the focus) + /** + * Emitted whenever the field should get the focus using the shortcuts (X, Y, A, D). + * Could be used by widgets to capture the focus when a field is being edited. + */ void focusOnX(); void focusOnY(); void focusOnAngle(); @@ -396,6 +417,12 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private public slots: + /** + * Set and lock the parameter. + * Can be used to set constraints. + * + * \param value The current value (as a QString, as it could be an expression). + */ void setX(QString value); void setY(QString value); void setAngle(QString value); diff --git a/src/gui/qgsadvanceddigitizingfloater.cpp b/src/gui/qgsadvanceddigitizingfloater.cpp index 511aee0b36a6..b38d3a8da209 100644 --- a/src/gui/qgsadvanceddigitizingfloater.cpp +++ b/src/gui/qgsadvanceddigitizingfloater.cpp @@ -28,16 +28,18 @@ QgsAdvancedDigitizingFloater::QgsAdvancedDigitizingFloater(QgsMapCanvas *canvas, setWindowFlag(Qt::FramelessWindowHint); setAttribute(Qt::WA_TransparentForMouseEvents); setVisible(false); + + // This is required to be able to track mouse move events mMapCanvas->viewport()->installEventFilter(this); mMapCanvas->viewport()->setMouseTracking(true); - // We use the same event filter so that shortcuts are still active + // We reuse cadDockWidget's eventFilter for the CAD specific shortcuts mAngleLineEdit->installEventFilter( cadDockWidget ); mDistanceLineEdit->installEventFilter( cadDockWidget ); mXLineEdit->installEventFilter( cadDockWidget ); mYLineEdit->installEventFilter( cadDockWidget ); - //connect(mEnableAction, &QAction::triggered, this, &QgsAdvancedDigitizingDockWidget::activateCad); + // Connect all cadDockWidget's signals to update the widget's display connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueXChanged, this, &QgsAdvancedDigitizingFloater::changeX); connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueYChanged, this, &QgsAdvancedDigitizingFloater::changeY); connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueAngleChanged, this, &QgsAdvancedDigitizingFloater::changeAngle); @@ -58,12 +60,11 @@ QgsAdvancedDigitizingFloater::QgsAdvancedDigitizingFloater(QgsMapCanvas *canvas, connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedAngle, this, &QgsAdvancedDigitizingFloater::enabledChangedAngle); connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedDistance, this, &QgsAdvancedDigitizingFloater::enabledChangedDistance); + // Connect our line edits signals to update cadDockWidget's tate connect(mXLineEdit, &QLineEdit::returnPressed, cadDockWidget, [=]() { cadDockWidget->setX(mXLineEdit->text()); }); connect(mYLineEdit, &QLineEdit::returnPressed, cadDockWidget, [=]() { cadDockWidget->setY(mYLineEdit->text()); }); connect(mAngleLineEdit, &QLineEdit::returnPressed, cadDockWidget, [=]() { cadDockWidget->setAngle(mAngleLineEdit->text()); }); connect(mDistanceLineEdit, &QLineEdit::returnPressed, cadDockWidget, [=]() { cadDockWidget->setDistance(mDistanceLineEdit->text()); }); - - } bool QgsAdvancedDigitizingFloater::eventFilter(QObject *obj, QEvent *event) @@ -71,17 +72,20 @@ bool QgsAdvancedDigitizingFloater::eventFilter(QObject *obj, QEvent *event) if (mCadDockWidget->cadEnabled() && mActive) { if (event->type() == QEvent::MouseMove) { + // We update the position when mouse moves QMouseEvent *mouseEvent = dynamic_cast(event); updatePos(mouseEvent->pos()); } else if (event->type() == QEvent::Enter) { + // We show the widget when mouse enters QEnterEvent *enterEvent = dynamic_cast(event); updatePos(enterEvent->pos()); setVisible(true); } else if (event->type() == QEvent::Leave) { + // We hide the widget when mouse leaves setVisible(false); } } @@ -92,6 +96,7 @@ bool QgsAdvancedDigitizingFloater::active() { return mActive; } + void QgsAdvancedDigitizingFloater::setActive(bool active) { mActive = active; @@ -102,8 +107,7 @@ void QgsAdvancedDigitizingFloater::setActive(bool active) void QgsAdvancedDigitizingFloater::updatePos(QPoint pos) { - //QPoint newPos = mMapCanvas->mapToGlobal(pos) + QPoint(10, -10); - //move(newPos); + // We hardcode a small delta between the mouse position and the widget's position move(pos + QPoint(15,5)); } @@ -196,7 +200,7 @@ void QgsAdvancedDigitizingFloater::focusOnAngle() if (mActive) { mAngleLineEdit->setFocus(); mAngleLineEdit->selectAll(); -} + } } diff --git a/src/gui/qgsadvanceddigitizingfloater.h b/src/gui/qgsadvanceddigitizingfloater.h index 520806fe2684..8b1cc74b2523 100644 --- a/src/gui/qgsadvanceddigitizingfloater.h +++ b/src/gui/qgsadvanceddigitizingfloater.h @@ -27,6 +27,12 @@ class QgsMapCanvas; class QgsAdvancedDigitizingDockWidget; +/** +* \ingroup gui +* \brief The QgsAdvancedDigitizingFloater class is widget that floats +* next to the mouse pointer, and allow interaction with the AdvancedDigitizing +* feature. It proxies display and actions to QgsMapToolAdvancedDigitizingDockWidget. +*/ class GUI_EXPORT QgsAdvancedDigitizingFloater : public QWidget, private Ui::QgsAdvancedDigitizingFloaterBase { Q_OBJECT @@ -36,11 +42,18 @@ class GUI_EXPORT QgsAdvancedDigitizingFloater : public QWidget, private Ui::QgsA explicit QgsAdvancedDigitizingFloater(QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget); /** - * getter for mActive + * Whether the floater is active or not. + * Note that the floater may be active but not visible (e.g. if the mouse is not over the canvas). */ bool active(); public slots: + /** + * Set whether the floater should be active or not. + * Note that the floater may be active but not visible (e.g. if the mouse is not over the canvas). + * + * \param active + */ void setActive(bool active); private slots: @@ -70,9 +83,6 @@ private slots: //! pointer to map cad docker widget QgsAdvancedDigitizingDockWidget *mCadDockWidget = nullptr; - //! Whether the floater is enabled - bool mActive = false; - /** * event filter to track mouse position * \note defined as private in Python bindings @@ -85,6 +95,9 @@ private slots: */ void updatePos(QPoint pos); + //! Whether the floater is enabled. + bool mActive = false; + }; #endif // QGSADVANCEDDIGITIZINGFLOATER_H From ae3972e83643d3dea6d40b678d2c0321a753758a Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Thu, 9 May 2019 12:28:01 +0200 Subject: [PATCH 05/27] astyle --- src/gui/qgsadvanceddigitizingdockwidget.cpp | 76 +++--- src/gui/qgsadvanceddigitizingdockwidget.h | 109 ++++----- src/gui/qgsadvanceddigitizingfloater.cpp | 256 +++++++++++--------- src/gui/qgsadvanceddigitizingfloater.h | 85 +++---- 4 files changed, 275 insertions(+), 251 deletions(-) diff --git a/src/gui/qgsadvanceddigitizingdockwidget.cpp b/src/gui/qgsadvanceddigitizingdockwidget.cpp index 891e01bdd491..b6a52fc48abb 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.cpp +++ b/src/gui/qgsadvanceddigitizingdockwidget.cpp @@ -145,16 +145,16 @@ QgsAdvancedDigitizingDockWidget::QgsAdvancedDigitizingDockWidget( QgsMapCanvas * mRepeatingLockYButton->setToolTip( "" + tr( "Continuously lock y coordinate" ) + "" ); // Create the slots/signals - connect(mXLineEdit, &QLineEdit::textChanged, this, &QgsAdvancedDigitizingDockWidget::valueXChanged); - connect(mYLineEdit, &QLineEdit::textChanged, this, &QgsAdvancedDigitizingDockWidget::valueYChanged); - connect(mDistanceLineEdit, &QLineEdit::textChanged, this, &QgsAdvancedDigitizingDockWidget::valueDistanceChanged); - connect(mAngleLineEdit, &QLineEdit::textChanged, this, &QgsAdvancedDigitizingDockWidget::valueAngleChanged); + connect( mXLineEdit, &QLineEdit::textChanged, this, &QgsAdvancedDigitizingDockWidget::valueXChanged ); + connect( mYLineEdit, &QLineEdit::textChanged, this, &QgsAdvancedDigitizingDockWidget::valueYChanged ); + connect( mDistanceLineEdit, &QLineEdit::textChanged, this, &QgsAdvancedDigitizingDockWidget::valueDistanceChanged ); + connect( mAngleLineEdit, &QLineEdit::textChanged, this, &QgsAdvancedDigitizingDockWidget::valueAngleChanged ); // Create the floater - mFloater = new QgsAdvancedDigitizingFloater(canvas, this); - mToggleFloaterAction->setChecked(QgsSettings().value(QStringLiteral("/Cad/Floater"), false).toBool()); - toggleFloater(QgsSettings().value(QStringLiteral("/Cad/Floater"), false).toBool()); + mFloater = new QgsAdvancedDigitizingFloater( canvas, this ); + mToggleFloaterAction->setChecked( QgsSettings().value( QStringLiteral( "/Cad/Floater" ), false ).toBool() ); + toggleFloater( QgsSettings().value( QStringLiteral( "/Cad/Floater" ), false ).toBool() ); updateCapacity( true ); connect( QgsProject::instance(), &QgsProject::snappingConfigChanged, this, [ = ] { updateCapacity( true ); } ); @@ -172,20 +172,24 @@ void QgsAdvancedDigitizingDockWidget::hideEvent( QHideEvent * ) } -void QgsAdvancedDigitizingDockWidget::setX(QString value){ - mXLineEdit->setText(value); +void QgsAdvancedDigitizingDockWidget::setX( QString value ) +{ + mXLineEdit->setText( value ); mXLineEdit->returnPressed(); } -void QgsAdvancedDigitizingDockWidget::setY(QString value){ - mYLineEdit->setText(value); +void QgsAdvancedDigitizingDockWidget::setY( QString value ) +{ + mYLineEdit->setText( value ); mYLineEdit->returnPressed(); } -void QgsAdvancedDigitizingDockWidget::setAngle(QString value){ - mAngleLineEdit->setText(value); +void QgsAdvancedDigitizingDockWidget::setAngle( QString value ) +{ + mAngleLineEdit->setText( value ); mAngleLineEdit->returnPressed(); } -void QgsAdvancedDigitizingDockWidget::setDistance(QString value){ - mDistanceLineEdit->setText(value); +void QgsAdvancedDigitizingDockWidget::setDistance( QString value ) +{ + mDistanceLineEdit->setText( value ); mDistanceLineEdit->returnPressed(); } @@ -272,7 +276,7 @@ void QgsAdvancedDigitizingDockWidget::setConstraintRepeatingLock( bool activate void QgsAdvancedDigitizingDockWidget::toggleFloater( bool enabled ) { - mFloater->setActive(enabled); + mFloater->setActive( enabled ); mToggleFloaterAction->setChecked( enabled ); QgsSettings().setValue( QStringLiteral( "/Cad/Floater" ), enabled ); } @@ -306,22 +310,22 @@ void QgsAdvancedDigitizingDockWidget::releaseLocks( bool releaseRepeatingLocks ) if ( releaseRepeatingLocks || !mAngleConstraint->isRepeatingLock() ) { mAngleConstraint->setLockMode( CadConstraint::NoLock ); - emit lockAngleChanged(false); + emit lockAngleChanged( false ); } if ( releaseRepeatingLocks || !mDistanceConstraint->isRepeatingLock() ) { mDistanceConstraint->setLockMode( CadConstraint::NoLock ); - emit lockDistanceChanged(false); + emit lockDistanceChanged( false ); } if ( releaseRepeatingLocks || !mXConstraint->isRepeatingLock() ) { mXConstraint->setLockMode( CadConstraint::NoLock ); - emit lockXChanged(false); + emit lockXChanged( false ); } if ( releaseRepeatingLocks || !mYConstraint->isRepeatingLock() ) { mYConstraint->setLockMode( CadConstraint::NoLock ); - emit lockYChanged(false); + emit lockYChanged( false ); } } @@ -430,17 +434,21 @@ void QgsAdvancedDigitizingDockWidget::lockConstraint( bool activate /* default t } constraint->setLockMode( activate ? CadConstraint::HardLock : CadConstraint::NoLock ); - if( constraint == mXConstraint.get() ){ - emit lockXChanged(activate); + if ( constraint == mXConstraint.get() ) + { + emit lockXChanged( activate ); } - else if( constraint == mYConstraint.get() ){ - emit lockYChanged(activate); + else if ( constraint == mYConstraint.get() ) + { + emit lockYChanged( activate ); } - else if( constraint == mDistanceConstraint.get() ){ - emit lockDistanceChanged(activate); + else if ( constraint == mDistanceConstraint.get() ) + { + emit lockDistanceChanged( activate ); } - else if( constraint == mAngleConstraint.get() ){ - emit lockAngleChanged(activate); + else if ( constraint == mAngleConstraint.get() ) + { + emit lockAngleChanged( activate ); } if ( activate ) @@ -540,7 +548,7 @@ void QgsAdvancedDigitizingDockWidget::updateCapacity( bool updateUIwithoutChange mLockAngleButton->setEnabled( absoluteAngle ); mRelativeAngleButton->setEnabled( relativeAngle ); mAngleLineEdit->setEnabled( absoluteAngle ); - emit enabledChangedAngle(absoluteAngle); + emit enabledChangedAngle( absoluteAngle ); if ( !absoluteAngle ) { mAngleConstraint->setLockMode( CadConstraint::NoLock ); @@ -558,7 +566,7 @@ void QgsAdvancedDigitizingDockWidget::updateCapacity( bool updateUIwithoutChange // distance is always relative mLockDistanceButton->setEnabled( relativeCoordinates ); mDistanceLineEdit->setEnabled( relativeCoordinates ); - emit enabledChangedDistance(relativeCoordinates); + emit enabledChangedDistance( relativeCoordinates ); if ( !relativeCoordinates ) { mDistanceConstraint->setLockMode( CadConstraint::NoLock ); @@ -895,7 +903,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) if ( type == QEvent::ShortcutOverride && ( e->modifiers() == Qt::AltModifier || e->modifiers() == Qt::ControlModifier ) ) { mXConstraint->toggleLocked(); - emit lockXChanged(mXConstraint->isLocked()); + emit lockXChanged( mXConstraint->isLocked() ); emit pointChanged( mCadPointList.value( 0 ) ); e->accept(); } @@ -924,7 +932,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) if ( type == QEvent::ShortcutOverride && ( e->modifiers() == Qt::AltModifier || e->modifiers() == Qt::ControlModifier ) ) { mYConstraint->toggleLocked(); - emit lockYChanged(mYConstraint->isLocked()); + emit lockYChanged( mYConstraint->isLocked() ); emit pointChanged( mCadPointList.value( 0 ) ); e->accept(); } @@ -955,7 +963,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) if ( mCapacities.testFlag( AbsoluteAngle ) ) { mAngleConstraint->toggleLocked(); - emit lockAngleChanged(mAngleConstraint->isLocked()); + emit lockAngleChanged( mAngleConstraint->isLocked() ); emit pointChanged( mCadPointList.value( 0 ) ); e->accept(); } @@ -987,7 +995,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) if ( mCapacities.testFlag( RelativeCoordinates ) ) { mDistanceConstraint->toggleLocked(); - emit lockDistanceChanged(mDistanceConstraint->isLocked()); + emit lockDistanceChanged( mDistanceConstraint->isLocked() ); emit pointChanged( mCadPointList.value( 0 ) ); e->accept(); } diff --git a/src/gui/qgsadvanceddigitizingdockwidget.h b/src/gui/qgsadvanceddigitizingdockwidget.h index 718a1b53abe9..100007ecd027 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.h +++ b/src/gui/qgsadvanceddigitizingdockwidget.h @@ -370,63 +370,64 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private */ void pointChanged( const QgsPointXY &point ); - //! Signals for external widgets that need to update according to current values - - /** - * Emitted whenever the value changes (either the mouse moved, or the user changed the input). - * Could be used by widgets that must reflect the current advanced digitizing state. - * - * \param value The current value (as a QString, as it could be an expression). - */ - void valueXChanged(QString value); - void valueYChanged(QString value); - void valueAngleChanged(QString value); - void valueDistanceChanged(QString value); - - /** - * Emitted whenever the parameter is locked. - * Could be used by widgets that must reflect the current advanced digitizing state. - * - * \param locked Whether the parameter is locked or not. - */ - void lockXChanged(bool locked); - void lockYChanged(bool locked); - void lockAngleChanged(bool locked); - void lockDistanceChanged(bool locked); - - /** - * Emitted whenever the field is enabled or disabled. Depending on the context, some parameters - * dont make sense (e.g. you need a previous point to define a distance). - * Could be used by widgets that must reflect the current advanced digitizing state. - * - * \param enabled Whether the parameter is enabled or not. - */ - void enabledChangedX(bool enabled); - void enabledChangedY(bool enabled); - void enabledChangedAngle(bool enabled); - void enabledChangedDistance(bool enabled); - - /** - * Emitted whenever the field should get the focus using the shortcuts (X, Y, A, D). - * Could be used by widgets to capture the focus when a field is being edited. - */ - void focusOnX(); - void focusOnY(); - void focusOnAngle(); - void focusOnDistance(); + //! Signals for external widgets that need to update according to current values + + /** + * Emitted whenever the value changes (either the mouse moved, or the user changed the input). + * Could be used by widgets that must reflect the current advanced digitizing state. + * + * \param value The current value (as a QString, as it could be an expression). + */ + void valueXChanged( QString value ); + void valueYChanged( QString value ); + void valueAngleChanged( QString value ); + void valueDistanceChanged( QString value ); + + /** + * Emitted whenever the parameter is locked. + * Could be used by widgets that must reflect the current advanced digitizing state. + * + * \param locked Whether the parameter is locked or not. + */ + void lockXChanged( bool locked ); + void lockYChanged( bool locked ); + void lockAngleChanged( bool locked ); + void lockDistanceChanged( bool locked ); + + /** + * Emitted whenever the field is enabled or disabled. Depending on the context, some parameters + * dont make sense (e.g. you need a previous point to define a distance). + * Could be used by widgets that must reflect the current advanced digitizing state. + * + * \param enabled Whether the parameter is enabled or not. + */ + void enabledChangedX( bool enabled ); + void enabledChangedY( bool enabled ); + void enabledChangedAngle( bool enabled ); + void enabledChangedDistance( bool enabled ); + + /** + * Emitted whenever the field should get the focus using the shortcuts (X, Y, A, D). + * Could be used by widgets to capture the focus when a field is being edited. + */ + void focusOnX(); + void focusOnY(); + void focusOnAngle(); + void focusOnDistance(); public slots: - /** - * Set and lock the parameter. - * Can be used to set constraints. - * - * \param value The current value (as a QString, as it could be an expression). - */ - void setX(QString value); - void setY(QString value); - void setAngle(QString value); - void setDistance(QString value); + + /** + * Set and lock the parameter. + * Can be used to set constraints. + * + * \param value The current value (as a QString, as it could be an expression). + */ + void setX( QString value ); + void setY( QString value ); + void setAngle( QString value ); + void setDistance( QString value ); private slots: diff --git a/src/gui/qgsadvanceddigitizingfloater.cpp b/src/gui/qgsadvanceddigitizingfloater.cpp index b38d3a8da209..6a1c499a5b09 100644 --- a/src/gui/qgsadvanceddigitizingfloater.cpp +++ b/src/gui/qgsadvanceddigitizingfloater.cpp @@ -1,9 +1,9 @@ /*************************************************************************** - qgsadvanceddigitizingfloater.cpp - floater for CAD tools - ---------------------- - begin : May 2019 - copyright : (C) Olivier Dalang - email : olivier.dalang@gmail.com + qgsadvanceddigitizingfloater.cpp - floater for CAD tools + ---------------------- + begin : May 2019 + copyright : (C) Olivier Dalang + email : olivier.dalang@gmail.com *************************************************************************** * * * This program is free software; you can redistribute it and/or modify * @@ -21,17 +21,17 @@ #include "qgsmessagelog.h" #include "qgsmapcanvas.h" -QgsAdvancedDigitizingFloater::QgsAdvancedDigitizingFloater(QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget) - : QWidget(canvas->viewport()), mMapCanvas(canvas), mCadDockWidget(cadDockWidget) +QgsAdvancedDigitizingFloater::QgsAdvancedDigitizingFloater( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget ) + : QWidget( canvas->viewport() ), mMapCanvas( canvas ), mCadDockWidget( cadDockWidget ) { - setupUi(this); - setWindowFlag(Qt::FramelessWindowHint); - setAttribute(Qt::WA_TransparentForMouseEvents); - setVisible(false); + setupUi( this ); + setWindowFlag( Qt::FramelessWindowHint ); + setAttribute( Qt::WA_TransparentForMouseEvents ); + setVisible( false ); // This is required to be able to track mouse move events - mMapCanvas->viewport()->installEventFilter(this); - mMapCanvas->viewport()->setMouseTracking(true); + mMapCanvas->viewport()->installEventFilter( this ); + mMapCanvas->viewport()->setMouseTracking( true ); // We reuse cadDockWidget's eventFilter for the CAD specific shortcuts mAngleLineEdit->installEventFilter( cadDockWidget ); @@ -39,191 +39,205 @@ QgsAdvancedDigitizingFloater::QgsAdvancedDigitizingFloater(QgsMapCanvas *canvas, mXLineEdit->installEventFilter( cadDockWidget ); mYLineEdit->installEventFilter( cadDockWidget ); - // Connect all cadDockWidget's signals to update the widget's display - connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueXChanged, this, &QgsAdvancedDigitizingFloater::changeX); - connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueYChanged, this, &QgsAdvancedDigitizingFloater::changeY); - connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueAngleChanged, this, &QgsAdvancedDigitizingFloater::changeAngle); - connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueDistanceChanged, this, &QgsAdvancedDigitizingFloater::changeDistance); + // Connect all cadDockWidget's signals to update the widget's display + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueXChanged, this, &QgsAdvancedDigitizingFloater::changeX ); + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueYChanged, this, &QgsAdvancedDigitizingFloater::changeY ); + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueAngleChanged, this, &QgsAdvancedDigitizingFloater::changeAngle ); + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueDistanceChanged, this, &QgsAdvancedDigitizingFloater::changeDistance ); - connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockXChanged, this, &QgsAdvancedDigitizingFloater::changeLockX); - connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockYChanged, this, &QgsAdvancedDigitizingFloater::changeLockY); - connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockAngleChanged, this, &QgsAdvancedDigitizingFloater::changeLockAngle); - connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockDistanceChanged, this, &QgsAdvancedDigitizingFloater::changeLockDistance); + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockXChanged, this, &QgsAdvancedDigitizingFloater::changeLockX ); + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockYChanged, this, &QgsAdvancedDigitizingFloater::changeLockY ); + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockAngleChanged, this, &QgsAdvancedDigitizingFloater::changeLockAngle ); + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockDistanceChanged, this, &QgsAdvancedDigitizingFloater::changeLockDistance ); - connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnX, this, &QgsAdvancedDigitizingFloater::focusOnX); - connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnY, this, &QgsAdvancedDigitizingFloater::focusOnY); - connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnAngle, this, &QgsAdvancedDigitizingFloater::focusOnAngle); - connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnDistance, this, &QgsAdvancedDigitizingFloater::focusOnDistance); + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnX, this, &QgsAdvancedDigitizingFloater::focusOnX ); + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnY, this, &QgsAdvancedDigitizingFloater::focusOnY ); + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnAngle, this, &QgsAdvancedDigitizingFloater::focusOnAngle ); + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnDistance, this, &QgsAdvancedDigitizingFloater::focusOnDistance ); - connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedX, this, &QgsAdvancedDigitizingFloater::enabledChangedX); - connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedY, this, &QgsAdvancedDigitizingFloater::enabledChangedY); - connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedAngle, this, &QgsAdvancedDigitizingFloater::enabledChangedAngle); - connect(cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedDistance, this, &QgsAdvancedDigitizingFloater::enabledChangedDistance); + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedX, this, &QgsAdvancedDigitizingFloater::enabledChangedX ); + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedY, this, &QgsAdvancedDigitizingFloater::enabledChangedY ); + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedAngle, this, &QgsAdvancedDigitizingFloater::enabledChangedAngle ); + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedDistance, this, &QgsAdvancedDigitizingFloater::enabledChangedDistance ); - // Connect our line edits signals to update cadDockWidget's tate - connect(mXLineEdit, &QLineEdit::returnPressed, cadDockWidget, [=]() { cadDockWidget->setX(mXLineEdit->text()); }); - connect(mYLineEdit, &QLineEdit::returnPressed, cadDockWidget, [=]() { cadDockWidget->setY(mYLineEdit->text()); }); - connect(mAngleLineEdit, &QLineEdit::returnPressed, cadDockWidget, [=]() { cadDockWidget->setAngle(mAngleLineEdit->text()); }); - connect(mDistanceLineEdit, &QLineEdit::returnPressed, cadDockWidget, [=]() { cadDockWidget->setDistance(mDistanceLineEdit->text()); }); + // Connect our line edits signals to update cadDockWidget's tate + connect( mXLineEdit, &QLineEdit::returnPressed, cadDockWidget, [ = ]() { cadDockWidget->setX( mXLineEdit->text() ); } ); + connect( mYLineEdit, &QLineEdit::returnPressed, cadDockWidget, [ = ]() { cadDockWidget->setY( mYLineEdit->text() ); } ); + connect( mAngleLineEdit, &QLineEdit::returnPressed, cadDockWidget, [ = ]() { cadDockWidget->setAngle( mAngleLineEdit->text() ); } ); + connect( mDistanceLineEdit, &QLineEdit::returnPressed, cadDockWidget, [ = ]() { cadDockWidget->setDistance( mDistanceLineEdit->text() ); } ); } -bool QgsAdvancedDigitizingFloater::eventFilter(QObject *obj, QEvent *event) +bool QgsAdvancedDigitizingFloater::eventFilter( QObject *obj, QEvent *event ) { - if (mCadDockWidget->cadEnabled() && mActive) { - if (event->type() == QEvent::MouseMove) - { + if ( mCadDockWidget->cadEnabled() && mActive ) + { + if ( event->type() == QEvent::MouseMove ) + { // We update the position when mouse moves - QMouseEvent *mouseEvent = dynamic_cast(event); - updatePos(mouseEvent->pos()); - } - else if (event->type() == QEvent::Enter) - { + QMouseEvent *mouseEvent = dynamic_cast( event ); + updatePos( mouseEvent->pos() ); + } + else if ( event->type() == QEvent::Enter ) + { // We show the widget when mouse enters - QEnterEvent *enterEvent = dynamic_cast(event); - updatePos(enterEvent->pos()); - setVisible(true); - } - else if (event->type() == QEvent::Leave) - { + QEnterEvent *enterEvent = dynamic_cast( event ); + updatePos( enterEvent->pos() ); + setVisible( true ); + } + else if ( event->type() == QEvent::Leave ) + { // We hide the widget when mouse leaves - setVisible(false); - } - } - return QWidget::eventFilter(obj, event); + setVisible( false ); + } + } + return QWidget::eventFilter( obj, event ); } bool QgsAdvancedDigitizingFloater::active() { - return mActive; + return mActive; } -void QgsAdvancedDigitizingFloater::setActive(bool active) +void QgsAdvancedDigitizingFloater::setActive( bool active ) { - mActive = active; - if (!active) { - setVisible(false); - } + mActive = active; + if ( !active ) + { + setVisible( false ); + } } -void QgsAdvancedDigitizingFloater::updatePos(QPoint pos) +void QgsAdvancedDigitizingFloater::updatePos( QPoint pos ) { // We hardcode a small delta between the mouse position and the widget's position - move(pos + QPoint(15,5)); + move( pos + QPoint( 15, 5 ) ); } -void QgsAdvancedDigitizingFloater::changeX(QString text) +void QgsAdvancedDigitizingFloater::changeX( QString text ) { - mXLineEdit->setText(text); + mXLineEdit->setText( text ); } -void QgsAdvancedDigitizingFloater::changeY(QString text) +void QgsAdvancedDigitizingFloater::changeY( QString text ) { - mYLineEdit->setText(text); + mYLineEdit->setText( text ); } -void QgsAdvancedDigitizingFloater::changeDistance(QString text) +void QgsAdvancedDigitizingFloater::changeDistance( QString text ) { - mDistanceLineEdit->setText(text); + mDistanceLineEdit->setText( text ); } -void QgsAdvancedDigitizingFloater::changeAngle(QString text) +void QgsAdvancedDigitizingFloater::changeAngle( QString text ) { - mAngleLineEdit->setText(text); + mAngleLineEdit->setText( text ); } -void QgsAdvancedDigitizingFloater::changeLockX(bool locked) +void QgsAdvancedDigitizingFloater::changeLockX( bool locked ) { - if (!locked) { - mXLineEdit->setStyleSheet(""); - } - else { - mXLineEdit->setStyleSheet("font-weight: bold"); - } + if ( !locked ) + { + mXLineEdit->setStyleSheet( "" ); + } + else + { + mXLineEdit->setStyleSheet( "font-weight: bold" ); + } } -void QgsAdvancedDigitizingFloater::changeLockY(bool locked) +void QgsAdvancedDigitizingFloater::changeLockY( bool locked ) { - if (!locked) { - mYLineEdit->setStyleSheet(""); - } - else { - mYLineEdit->setStyleSheet("font-weight: bold"); - } + if ( !locked ) + { + mYLineEdit->setStyleSheet( "" ); + } + else + { + mYLineEdit->setStyleSheet( "font-weight: bold" ); + } } -void QgsAdvancedDigitizingFloater::changeLockDistance(bool locked) +void QgsAdvancedDigitizingFloater::changeLockDistance( bool locked ) { - if (!locked) { - mDistanceLineEdit->setStyleSheet(""); - } - else { - mDistanceLineEdit->setStyleSheet("font-weight: bold"); - } + if ( !locked ) + { + mDistanceLineEdit->setStyleSheet( "" ); + } + else + { + mDistanceLineEdit->setStyleSheet( "font-weight: bold" ); + } } -void QgsAdvancedDigitizingFloater::changeLockAngle(bool locked) +void QgsAdvancedDigitizingFloater::changeLockAngle( bool locked ) { - if (!locked) { - mAngleLineEdit->setStyleSheet(""); - } - else { - mAngleLineEdit->setStyleSheet("font-weight: bold"); - } + if ( !locked ) + { + mAngleLineEdit->setStyleSheet( "" ); + } + else + { + mAngleLineEdit->setStyleSheet( "font-weight: bold" ); + } } void QgsAdvancedDigitizingFloater::focusOnX() { - if(mActive){ - mXLineEdit->setFocus(); + if ( mActive ) + { + mXLineEdit->setFocus(); mXLineEdit->selectAll(); - } + } } void QgsAdvancedDigitizingFloater::focusOnY() { - if (mActive) { - mYLineEdit->setFocus(); + if ( mActive ) + { + mYLineEdit->setFocus(); mYLineEdit->selectAll(); -} + } } void QgsAdvancedDigitizingFloater::focusOnDistance() { - if (mActive) { - mDistanceLineEdit->setFocus(); + if ( mActive ) + { + mDistanceLineEdit->setFocus(); mDistanceLineEdit->selectAll(); -} + } } void QgsAdvancedDigitizingFloater::focusOnAngle() { - if (mActive) { - mAngleLineEdit->setFocus(); + if ( mActive ) + { + mAngleLineEdit->setFocus(); mAngleLineEdit->selectAll(); } } -void QgsAdvancedDigitizingFloater::enabledChangedX(bool enabled) +void QgsAdvancedDigitizingFloater::enabledChangedX( bool enabled ) { - mXLineEdit->setVisible(enabled); - mXLabel->setVisible(enabled); + mXLineEdit->setVisible( enabled ); + mXLabel->setVisible( enabled ); } -void QgsAdvancedDigitizingFloater::enabledChangedY(bool enabled) +void QgsAdvancedDigitizingFloater::enabledChangedY( bool enabled ) { - mYLineEdit->setVisible(enabled); - mYLabel->setVisible(enabled); + mYLineEdit->setVisible( enabled ); + mYLabel->setVisible( enabled ); } -void QgsAdvancedDigitizingFloater::enabledChangedDistance(bool enabled) +void QgsAdvancedDigitizingFloater::enabledChangedDistance( bool enabled ) { - mDistanceLineEdit->setVisible(enabled); - mDistanceLabel->setVisible(enabled); + mDistanceLineEdit->setVisible( enabled ); + mDistanceLabel->setVisible( enabled ); } -void QgsAdvancedDigitizingFloater::enabledChangedAngle(bool enabled) +void QgsAdvancedDigitizingFloater::enabledChangedAngle( bool enabled ) { - mAngleLineEdit->setVisible(enabled); - mAngleLabel->setVisible(enabled); + mAngleLineEdit->setVisible( enabled ); + mAngleLabel->setVisible( enabled ); } diff --git a/src/gui/qgsadvanceddigitizingfloater.h b/src/gui/qgsadvanceddigitizingfloater.h index 8b1cc74b2523..5f3391d27560 100644 --- a/src/gui/qgsadvanceddigitizingfloater.h +++ b/src/gui/qgsadvanceddigitizingfloater.h @@ -39,7 +39,7 @@ class GUI_EXPORT QgsAdvancedDigitizingFloater : public QWidget, private Ui::QgsA public: - explicit QgsAdvancedDigitizingFloater(QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget); + explicit QgsAdvancedDigitizingFloater( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget ); /** * Whether the floater is active or not. @@ -48,55 +48,56 @@ class GUI_EXPORT QgsAdvancedDigitizingFloater : public QWidget, private Ui::QgsA bool active(); public slots: - /** - * Set whether the floater should be active or not. + + /** + * Set whether the floater should be active or not. * Note that the floater may be active but not visible (e.g. if the mouse is not over the canvas). - * - * \param active - */ - void setActive(bool active); - -private slots: - - void changeX(QString text); - void changeY(QString text); - void changeDistance(QString text); - void changeAngle(QString text); - void changeLockX(bool locked); - void changeLockY(bool locked); - void changeLockDistance(bool locked); - void changeLockAngle(bool locked); - void focusOnX(); - void focusOnY(); - void focusOnAngle(); - void focusOnDistance(); - void enabledChangedX(bool enabled); - void enabledChangedY(bool enabled); - void enabledChangedAngle(bool enabled); - void enabledChangedDistance(bool enabled); + * + * \param active + */ + void setActive( bool active ); + + private slots: + + void changeX( QString text ); + void changeY( QString text ); + void changeDistance( QString text ); + void changeAngle( QString text ); + void changeLockX( bool locked ); + void changeLockY( bool locked ); + void changeLockDistance( bool locked ); + void changeLockAngle( bool locked ); + void focusOnX(); + void focusOnY(); + void focusOnAngle(); + void focusOnDistance(); + void enabledChangedX( bool enabled ); + void enabledChangedY( bool enabled ); + void enabledChangedAngle( bool enabled ); + void enabledChangedDistance( bool enabled ); private: - //! pointer to map canvas - QgsMapCanvas *mMapCanvas = nullptr; + //! pointer to map canvas + QgsMapCanvas *mMapCanvas = nullptr; - //! pointer to map cad docker widget - QgsAdvancedDigitizingDockWidget *mCadDockWidget = nullptr; + //! pointer to map cad docker widget + QgsAdvancedDigitizingDockWidget *mCadDockWidget = nullptr; - /** - * event filter to track mouse position - * \note defined as private in Python bindings - */ - bool eventFilter(QObject *obj, QEvent *event) override SIP_SKIP; + /** + * event filter to track mouse position + * \note defined as private in Python bindings + */ + bool eventFilter( QObject *obj, QEvent *event ) override SIP_SKIP; - /** - * move the widget - * \param pos position of the cursor - */ - void updatePos(QPoint pos); + /** + * move the widget + * \param pos position of the cursor + */ + void updatePos( QPoint pos ); - //! Whether the floater is enabled. - bool mActive = false; + //! Whether the floater is enabled. + bool mActive = false; }; From b53bb910a15ad98ef3c52c9a3b67d04a900f41ab Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Thu, 9 May 2019 13:42:47 +0200 Subject: [PATCH 06/27] show delta in floater --- src/gui/qgsadvanceddigitizingdockwidget.cpp | 8 ++++ src/gui/qgsadvanceddigitizingdockwidget.h | 11 +++++ src/gui/qgsadvanceddigitizingfloater.cpp | 52 +++++++++++++++++++++ src/gui/qgsadvanceddigitizingfloater.h | 4 ++ src/ui/qgsadvanceddigitizingfloaterbase.ui | 2 +- 5 files changed, 76 insertions(+), 1 deletion(-) diff --git a/src/gui/qgsadvanceddigitizingdockwidget.cpp b/src/gui/qgsadvanceddigitizingdockwidget.cpp index b6a52fc48abb..70cdf59a10e6 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.cpp +++ b/src/gui/qgsadvanceddigitizingdockwidget.cpp @@ -243,14 +243,17 @@ void QgsAdvancedDigitizingDockWidget::setConstraintRelative( bool activate ) if ( sender() == mRelativeAngleButton ) { mAngleConstraint->setRelative( activate ); + emit relativeAngleChanged(activate); } else if ( sender() == mRelativeXButton ) { mXConstraint->setRelative( activate ); + emit relativeXChanged(activate); } else if ( sender() == mRelativeYButton ) { mYConstraint->setRelative( activate ); + emit relativeYChanged(activate); } } @@ -556,11 +559,13 @@ void QgsAdvancedDigitizingDockWidget::updateCapacity( bool updateUIwithoutChange if ( !relativeAngle ) { mAngleConstraint->setRelative( false ); + emit relativeAngleChanged(false); } else if ( relativeAngle && !mCapacities.testFlag( RelativeAngle ) ) { // set angle mode to relative if can do and wasn't available before mAngleConstraint->setRelative( true ); + emit relativeAngleChanged(true); } // distance is always relative @@ -912,6 +917,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) if ( mCapacities.testFlag( RelativeCoordinates ) ) { mXConstraint->toggleRelative(); + emit relativeXChanged(mXConstraint->relative()); emit pointChanged( mCadPointList.value( 0 ) ); e->accept(); } @@ -941,6 +947,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) if ( mCapacities.testFlag( RelativeCoordinates ) ) { mYConstraint->toggleRelative(); + emit relativeYChanged(mYConstraint->relative()); emit pointChanged( mCadPointList.value( 0 ) ); e->accept(); } @@ -973,6 +980,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) if ( mCapacities.testFlag( RelativeAngle ) ) { mAngleConstraint->toggleRelative(); + emit relativeAngleChanged(mAngleConstraint->relative()); emit pointChanged( mCadPointList.value( 0 ) ); e->accept(); } diff --git a/src/gui/qgsadvanceddigitizingdockwidget.h b/src/gui/qgsadvanceddigitizingdockwidget.h index 100007ecd027..0f96221e9bee 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.h +++ b/src/gui/qgsadvanceddigitizingdockwidget.h @@ -394,6 +394,17 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private void lockAngleChanged( bool locked ); void lockDistanceChanged( bool locked ); + /** + * Emitted whenever the parameter is toggled between absolute and relative. + * Could be used by widgets that must reflect the current advanced digitizing state. + * + * \param relative Whether the parameter is relative or not. + */ + void relativeXChanged( bool relative ); + void relativeYChanged( bool relative ); + void relativeAngleChanged( bool relative ); + // void relativeDistanceChanged( bool relative ); // distance is always relative + /** * Emitted whenever the field is enabled or disabled. Depending on the context, some parameters * dont make sense (e.g. you need a previous point to define a distance). diff --git a/src/gui/qgsadvanceddigitizingfloater.cpp b/src/gui/qgsadvanceddigitizingfloater.cpp index 6a1c499a5b09..0d21bfbe1522 100644 --- a/src/gui/qgsadvanceddigitizingfloater.cpp +++ b/src/gui/qgsadvanceddigitizingfloater.cpp @@ -50,6 +50,11 @@ QgsAdvancedDigitizingFloater::QgsAdvancedDigitizingFloater( QgsMapCanvas *canvas connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockAngleChanged, this, &QgsAdvancedDigitizingFloater::changeLockAngle ); connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::lockDistanceChanged, this, &QgsAdvancedDigitizingFloater::changeLockDistance ); + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::relativeXChanged, this, &QgsAdvancedDigitizingFloater::changeRelativeX ); + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::relativeYChanged, this, &QgsAdvancedDigitizingFloater::changeRelativeY ); + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::relativeAngleChanged, this, &QgsAdvancedDigitizingFloater::changeRelativeAngle ); + // distance is always relative + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnX, this, &QgsAdvancedDigitizingFloater::focusOnX ); connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnY, this, &QgsAdvancedDigitizingFloater::focusOnY ); connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnAngle, this, &QgsAdvancedDigitizingFloater::focusOnAngle ); @@ -138,10 +143,12 @@ void QgsAdvancedDigitizingFloater::changeLockX( bool locked ) if ( !locked ) { mXLineEdit->setStyleSheet( "" ); + mXLabel->setStyleSheet( "" ); } else { mXLineEdit->setStyleSheet( "font-weight: bold" ); + mXLabel->setStyleSheet( "font-weight: bold" ); } } @@ -150,10 +157,12 @@ void QgsAdvancedDigitizingFloater::changeLockY( bool locked ) if ( !locked ) { mYLineEdit->setStyleSheet( "" ); + mYLabel->setStyleSheet( "" ); } else { mYLineEdit->setStyleSheet( "font-weight: bold" ); + mYLabel->setStyleSheet( "font-weight: bold" ); } } @@ -162,10 +171,12 @@ void QgsAdvancedDigitizingFloater::changeLockDistance( bool locked ) if ( !locked ) { mDistanceLineEdit->setStyleSheet( "" ); + mDistanceLabel->setStyleSheet( "" ); } else { mDistanceLineEdit->setStyleSheet( "font-weight: bold" ); + mDistanceLabel->setStyleSheet( "font-weight: bold" ); } } @@ -174,10 +185,51 @@ void QgsAdvancedDigitizingFloater::changeLockAngle( bool locked ) if ( !locked ) { mAngleLineEdit->setStyleSheet( "" ); + mAngleLabel->setStyleSheet( "" ); } else { mAngleLineEdit->setStyleSheet( "font-weight: bold" ); + mAngleLabel->setStyleSheet( "font-weight: bold" ); + } +} + + +void QgsAdvancedDigitizingFloater::changeRelativeX( bool relative ) +{ + if ( !relative ) + { + mXLabel->setText( "x" ); + } + else + { + mXLabel->setText( "Δx" ); + } +} + +void QgsAdvancedDigitizingFloater::changeRelativeY( bool relative ) +{ + if ( !relative ) + { + mYLabel->setText( "y" ); + } + else + { + mYLabel->setText( "Δy" ); + } +} + +// distance is always relative + +void QgsAdvancedDigitizingFloater::changeRelativeAngle( bool relative ) +{ + if ( !relative ) + { + mAngleLabel->setText( "a" ); + } + else + { + mAngleLabel->setText( "Δa" ); } } diff --git a/src/gui/qgsadvanceddigitizingfloater.h b/src/gui/qgsadvanceddigitizingfloater.h index 5f3391d27560..d6e81f522dc4 100644 --- a/src/gui/qgsadvanceddigitizingfloater.h +++ b/src/gui/qgsadvanceddigitizingfloater.h @@ -67,6 +67,10 @@ class GUI_EXPORT QgsAdvancedDigitizingFloater : public QWidget, private Ui::QgsA void changeLockY( bool locked ); void changeLockDistance( bool locked ); void changeLockAngle( bool locked ); + void changeRelativeX( bool relative ); + void changeRelativeY( bool relative ); + // void changeRelativeDistance( bool relative ); // doesn't happen + void changeRelativeAngle( bool relative ); void focusOnX(); void focusOnY(); void focusOnAngle(); diff --git a/src/ui/qgsadvanceddigitizingfloaterbase.ui b/src/ui/qgsadvanceddigitizingfloaterbase.ui index fd372ac2f6b3..8f75114409d6 100644 --- a/src/ui/qgsadvanceddigitizingfloaterbase.ui +++ b/src/ui/qgsadvanceddigitizingfloaterbase.ui @@ -32,7 +32,7 @@ - a + Δa From 889ffc6b00b454429cb2985fc58f4c45c65cf5bf Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Thu, 9 May 2019 13:43:01 +0200 Subject: [PATCH 07/27] fix toggle floater button not disabled --- src/gui/qgsadvanceddigitizingdockwidget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/qgsadvanceddigitizingdockwidget.cpp b/src/gui/qgsadvanceddigitizingdockwidget.cpp index 70cdf59a10e6..09ff06640a4d 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.cpp +++ b/src/gui/qgsadvanceddigitizingdockwidget.cpp @@ -203,6 +203,7 @@ void QgsAdvancedDigitizingDockWidget::setCadEnabled( bool enabled ) mPerpendicularAction->setEnabled( enabled ); mSettingsAction->setEnabled( enabled ); mInputWidgets->setEnabled( enabled ); + mToggleFloaterAction->setEnabled( enabled ); clear(); setConstructionMode( false ); From b027ef757f6d93a7d6e3772c223a7d81d70a928c Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Thu, 9 May 2019 13:43:15 +0200 Subject: [PATCH 08/27] icon --- images/images.qrc | 1 + images/themes/default/cadtools/floater.svg | 21 +++++++++++++++++++ src/ui/qgsadvanceddigitizingdockwidgetbase.ui | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 images/themes/default/cadtools/floater.svg diff --git a/images/images.qrc b/images/images.qrc index 73d86eb2b705..1f9f736563b8 100644 --- a/images/images.qrc +++ b/images/images.qrc @@ -614,6 +614,7 @@ themes/default/mActionPanHighlightFeature.svg themes/default/cadtools/construction.svg themes/default/cadtools/delta.svg + themes/default/cadtools/floater.svg themes/default/cadtools/cad.svg themes/default/cadtools/lock.svg themes/default/cadtools/parallel.svg diff --git a/images/themes/default/cadtools/floater.svg b/images/themes/default/cadtools/floater.svg new file mode 100644 index 000000000000..91377e7d822e --- /dev/null +++ b/images/themes/default/cadtools/floater.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + diff --git a/src/ui/qgsadvanceddigitizingdockwidgetbase.ui b/src/ui/qgsadvanceddigitizingdockwidgetbase.ui index c795786a7024..69c11a97d118 100644 --- a/src/ui/qgsadvanceddigitizingdockwidgetbase.ui +++ b/src/ui/qgsadvanceddigitizingdockwidgetbase.ui @@ -474,7 +474,7 @@ - :/images/themes/default/propertyicons/display.svg:/images/themes/default/propertyicons/display.svg + :/images/themes/default/cadtools/floater.svg:/images/themes/default/cadtools/floater.svg Toggle Floater From 551eb6b44e9fb35df6ae151cb28104f5e080469d Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Thu, 9 May 2019 13:55:26 +0200 Subject: [PATCH 09/27] prepare-commit --- .../qgsadvanceddigitizingdockwidget.sip.in | 69 +++++++++++++++++++ src/gui/qgsadvanceddigitizingdockwidget.cpp | 16 ++--- 2 files changed, 77 insertions(+), 8 deletions(-) diff --git a/python/gui/auto_generated/qgsadvanceddigitizingdockwidget.sip.in b/python/gui/auto_generated/qgsadvanceddigitizingdockwidget.sip.in index 979fc785deb6..d29038c88c88 100644 --- a/python/gui/auto_generated/qgsadvanceddigitizingdockwidget.sip.in +++ b/python/gui/auto_generated/qgsadvanceddigitizingdockwidget.sip.in @@ -360,6 +360,75 @@ when a constraint is toggled. :param point: The last known digitizing point. Can be used to emulate a mouse event. %End + + void valueXChanged( QString value ); +%Docstring +Emitted whenever the value changes (either the mouse moved, or the user changed the input). +Could be used by widgets that must reflect the current advanced digitizing state. + +:param value: The current value (as a QString, as it could be an expression). +%End + void valueYChanged( QString value ); + void valueAngleChanged( QString value ); + void valueDistanceChanged( QString value ); + + void lockXChanged( bool locked ); +%Docstring +Emitted whenever the parameter is locked. +Could be used by widgets that must reflect the current advanced digitizing state. + +:param locked: Whether the parameter is locked or not. +%End + void lockYChanged( bool locked ); + void lockAngleChanged( bool locked ); + void lockDistanceChanged( bool locked ); + + void relativeXChanged( bool relative ); +%Docstring +Emitted whenever the parameter is toggled between absolute and relative. +Could be used by widgets that must reflect the current advanced digitizing state. + +:param relative: Whether the parameter is relative or not. +%End + void relativeYChanged( bool relative ); + void relativeAngleChanged( bool relative ); + + void enabledChangedX( bool enabled ); +%Docstring +Emitted whenever the field is enabled or disabled. Depending on the context, some parameters +dont make sense (e.g. you need a previous point to define a distance). +Could be used by widgets that must reflect the current advanced digitizing state. + +:param enabled: Whether the parameter is enabled or not. +%End + void enabledChangedY( bool enabled ); + void enabledChangedAngle( bool enabled ); + void enabledChangedDistance( bool enabled ); + + void focusOnX(); +%Docstring +Emitted whenever the field should get the focus using the shortcuts (X, Y, A, D). +Could be used by widgets to capture the focus when a field is being edited. +%End + void focusOnY(); + void focusOnAngle(); + void focusOnDistance(); + + + public slots: + + void setX( QString value ); +%Docstring +Set and lock the parameter. +Can be used to set constraints. + +:param value: The current value (as a QString, as it could be an expression). +%End + void setY( QString value ); + void setAngle( QString value ); + void setDistance( QString value ); + + private: //! event filter for line edits in the dock UI (angle/distance/x/y line edits) bool eventFilter( QObject *obj, QEvent *event ); diff --git a/src/gui/qgsadvanceddigitizingdockwidget.cpp b/src/gui/qgsadvanceddigitizingdockwidget.cpp index 09ff06640a4d..27318457e87a 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.cpp +++ b/src/gui/qgsadvanceddigitizingdockwidget.cpp @@ -244,17 +244,17 @@ void QgsAdvancedDigitizingDockWidget::setConstraintRelative( bool activate ) if ( sender() == mRelativeAngleButton ) { mAngleConstraint->setRelative( activate ); - emit relativeAngleChanged(activate); + emit relativeAngleChanged( activate ); } else if ( sender() == mRelativeXButton ) { mXConstraint->setRelative( activate ); - emit relativeXChanged(activate); + emit relativeXChanged( activate ); } else if ( sender() == mRelativeYButton ) { mYConstraint->setRelative( activate ); - emit relativeYChanged(activate); + emit relativeYChanged( activate ); } } @@ -560,13 +560,13 @@ void QgsAdvancedDigitizingDockWidget::updateCapacity( bool updateUIwithoutChange if ( !relativeAngle ) { mAngleConstraint->setRelative( false ); - emit relativeAngleChanged(false); + emit relativeAngleChanged( false ); } else if ( relativeAngle && !mCapacities.testFlag( RelativeAngle ) ) { // set angle mode to relative if can do and wasn't available before mAngleConstraint->setRelative( true ); - emit relativeAngleChanged(true); + emit relativeAngleChanged( true ); } // distance is always relative @@ -918,7 +918,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) if ( mCapacities.testFlag( RelativeCoordinates ) ) { mXConstraint->toggleRelative(); - emit relativeXChanged(mXConstraint->relative()); + emit relativeXChanged( mXConstraint->relative() ); emit pointChanged( mCadPointList.value( 0 ) ); e->accept(); } @@ -948,7 +948,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) if ( mCapacities.testFlag( RelativeCoordinates ) ) { mYConstraint->toggleRelative(); - emit relativeYChanged(mYConstraint->relative()); + emit relativeYChanged( mYConstraint->relative() ); emit pointChanged( mCadPointList.value( 0 ) ); e->accept(); } @@ -981,7 +981,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) if ( mCapacities.testFlag( RelativeAngle ) ) { mAngleConstraint->toggleRelative(); - emit relativeAngleChanged(mAngleConstraint->relative()); + emit relativeAngleChanged( mAngleConstraint->relative() ); emit pointChanged( mCadPointList.value( 0 ) ); e->accept(); } From d65e63fb0f7a7626c9771ee9162ac9a5dac9275c Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Mon, 13 May 2019 10:06:48 +0200 Subject: [PATCH 10/27] fix display on hidpi --- src/ui/qgsadvanceddigitizingfloaterbase.ui | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/ui/qgsadvanceddigitizingfloaterbase.ui b/src/ui/qgsadvanceddigitizingfloaterbase.ui index 8f75114409d6..ec99386f6003 100644 --- a/src/ui/qgsadvanceddigitizingfloaterbase.ui +++ b/src/ui/qgsadvanceddigitizingfloaterbase.ui @@ -71,6 +71,11 @@ 0 + + + 8 + + 16777215 @@ -96,6 +101,11 @@ 0 + + + 8 + + 16777215 @@ -135,6 +145,11 @@ 0 + + + 8 + + 16777215 From ca878695392de7e1f395b1bac55609acf1f30d1d Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Mon, 13 May 2019 10:16:42 +0200 Subject: [PATCH 11/27] fix comment --- src/gui/qgsadvanceddigitizingfloater.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/qgsadvanceddigitizingfloater.h b/src/gui/qgsadvanceddigitizingfloater.h index d6e81f522dc4..8250b3f1039c 100644 --- a/src/gui/qgsadvanceddigitizingfloater.h +++ b/src/gui/qgsadvanceddigitizingfloater.h @@ -95,8 +95,8 @@ class GUI_EXPORT QgsAdvancedDigitizingFloater : public QWidget, private Ui::QgsA bool eventFilter( QObject *obj, QEvent *event ) override SIP_SKIP; /** - * move the widget - * \param pos position of the cursor + * Move the widget to a new cursor position. A hard-coded offet will be added. + * \param pos position of the cursor */ void updatePos( QPoint pos ); From af4de6e9152af144ec649272f94a7076b170e0ec Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Mon, 13 May 2019 10:42:36 +0200 Subject: [PATCH 12/27] pass arguments by reference --- src/gui/qgsadvanceddigitizingfloater.cpp | 10 +++++----- src/gui/qgsadvanceddigitizingfloater.h | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/gui/qgsadvanceddigitizingfloater.cpp b/src/gui/qgsadvanceddigitizingfloater.cpp index 0d21bfbe1522..513d21f52469 100644 --- a/src/gui/qgsadvanceddigitizingfloater.cpp +++ b/src/gui/qgsadvanceddigitizingfloater.cpp @@ -112,28 +112,28 @@ void QgsAdvancedDigitizingFloater::setActive( bool active ) } } -void QgsAdvancedDigitizingFloater::updatePos( QPoint pos ) +void QgsAdvancedDigitizingFloater::updatePos( const QPoint &pos ) { // We hardcode a small delta between the mouse position and the widget's position move( pos + QPoint( 15, 5 ) ); } -void QgsAdvancedDigitizingFloater::changeX( QString text ) +void QgsAdvancedDigitizingFloater::changeX( const QString &text ) { mXLineEdit->setText( text ); } -void QgsAdvancedDigitizingFloater::changeY( QString text ) +void QgsAdvancedDigitizingFloater::changeY( const QString &text ) { mYLineEdit->setText( text ); } -void QgsAdvancedDigitizingFloater::changeDistance( QString text ) +void QgsAdvancedDigitizingFloater::changeDistance( const QString &text ) { mDistanceLineEdit->setText( text ); } -void QgsAdvancedDigitizingFloater::changeAngle( QString text ) +void QgsAdvancedDigitizingFloater::changeAngle( const QString &text ) { mAngleLineEdit->setText( text ); } diff --git a/src/gui/qgsadvanceddigitizingfloater.h b/src/gui/qgsadvanceddigitizingfloater.h index 8250b3f1039c..2d8ec1b0e895 100644 --- a/src/gui/qgsadvanceddigitizingfloater.h +++ b/src/gui/qgsadvanceddigitizingfloater.h @@ -59,10 +59,10 @@ class GUI_EXPORT QgsAdvancedDigitizingFloater : public QWidget, private Ui::QgsA private slots: - void changeX( QString text ); - void changeY( QString text ); - void changeDistance( QString text ); - void changeAngle( QString text ); + void changeX( const QString &text ); + void changeY( const QString &text ); + void changeDistance( const QString &text ); + void changeAngle( const QString &text ); void changeLockX( bool locked ); void changeLockY( bool locked ); void changeLockDistance( bool locked ); @@ -98,7 +98,7 @@ class GUI_EXPORT QgsAdvancedDigitizingFloater : public QWidget, private Ui::QgsA * Move the widget to a new cursor position. A hard-coded offet will be added. * \param pos position of the cursor */ - void updatePos( QPoint pos ); + void updatePos( const QPoint &pos ); //! Whether the floater is enabled. bool mActive = false; From 7a88cdc4528ebf37e519cd06ba203531bab2baee Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Mon, 13 May 2019 11:02:53 +0200 Subject: [PATCH 13/27] connect directly mToggleFloaterAction to floater --- src/gui/qgsadvanceddigitizingdockwidget.cpp | 14 ++------------ src/gui/qgsadvanceddigitizingdockwidget.h | 3 --- src/gui/qgsadvanceddigitizingfloater.cpp | 6 +++++- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/gui/qgsadvanceddigitizingdockwidget.cpp b/src/gui/qgsadvanceddigitizingdockwidget.cpp index 27318457e87a..54e4c3475ac0 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.cpp +++ b/src/gui/qgsadvanceddigitizingdockwidget.cpp @@ -61,7 +61,6 @@ QgsAdvancedDigitizingDockWidget::QgsAdvancedDigitizingDockWidget( QgsMapCanvas * // Connect the UI to the event filter to update constraints connect( mEnableAction, &QAction::triggered, this, &QgsAdvancedDigitizingDockWidget::activateCad ); connect( mConstructionModeAction, &QAction::triggered, this, &QgsAdvancedDigitizingDockWidget::setConstructionMode ); - connect( mToggleFloaterAction, &QAction::triggered, this, &QgsAdvancedDigitizingDockWidget::toggleFloater ); connect( mParallelAction, &QAction::triggered, this, &QgsAdvancedDigitizingDockWidget::additionalConstraintClicked ); connect( mPerpendicularAction, &QAction::triggered, this, &QgsAdvancedDigitizingDockWidget::additionalConstraintClicked ); connect( mLockAngleButton, &QAbstractButton::clicked, this, &QgsAdvancedDigitizingDockWidget::lockConstraint ); @@ -150,11 +149,10 @@ QgsAdvancedDigitizingDockWidget::QgsAdvancedDigitizingDockWidget( QgsMapCanvas * connect( mDistanceLineEdit, &QLineEdit::textChanged, this, &QgsAdvancedDigitizingDockWidget::valueDistanceChanged ); connect( mAngleLineEdit, &QLineEdit::textChanged, this, &QgsAdvancedDigitizingDockWidget::valueAngleChanged ); - // Create the floater mFloater = new QgsAdvancedDigitizingFloater( canvas, this ); - mToggleFloaterAction->setChecked( QgsSettings().value( QStringLiteral( "/Cad/Floater" ), false ).toBool() ); - toggleFloater( QgsSettings().value( QStringLiteral( "/Cad/Floater" ), false ).toBool() ); + connect( mToggleFloaterAction, &QAction::triggered, mFloater, &QgsAdvancedDigitizingFloater::setActive ); + mToggleFloaterAction->setChecked( mFloater->active() ); updateCapacity( true ); connect( QgsProject::instance(), &QgsProject::snappingConfigChanged, this, [ = ] { updateCapacity( true ); } ); @@ -278,14 +276,6 @@ void QgsAdvancedDigitizingDockWidget::setConstraintRepeatingLock( bool activate } } -void QgsAdvancedDigitizingDockWidget::toggleFloater( bool enabled ) -{ - mFloater->setActive( enabled ); - mToggleFloaterAction->setChecked( enabled ); - QgsSettings().setValue( QStringLiteral( "/Cad/Floater" ), enabled ); -} - - void QgsAdvancedDigitizingDockWidget::setConstructionMode( bool enabled ) { mConstructionMode = enabled; diff --git a/src/gui/qgsadvanceddigitizingdockwidget.h b/src/gui/qgsadvanceddigitizingdockwidget.h index 0f96221e9bee..46cf537ba766 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.h +++ b/src/gui/qgsadvanceddigitizingdockwidget.h @@ -472,9 +472,6 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private */ void activateCad( bool enabled ); - //! enable/disable floater - void toggleFloater( bool enabled ); - //! enable/disable construction mode (events are not forwarded to the map tool) void setConstructionMode( bool enabled ); diff --git a/src/gui/qgsadvanceddigitizingfloater.cpp b/src/gui/qgsadvanceddigitizingfloater.cpp index 513d21f52469..7a1645abedee 100644 --- a/src/gui/qgsadvanceddigitizingfloater.cpp +++ b/src/gui/qgsadvanceddigitizingfloater.cpp @@ -20,6 +20,7 @@ #include "qgsadvanceddigitizingfloater.h" #include "qgsmessagelog.h" #include "qgsmapcanvas.h" +#include "qgssettings.h" QgsAdvancedDigitizingFloater::QgsAdvancedDigitizingFloater( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget ) : QWidget( canvas->viewport() ), mMapCanvas( canvas ), mCadDockWidget( cadDockWidget ) @@ -27,7 +28,8 @@ QgsAdvancedDigitizingFloater::QgsAdvancedDigitizingFloater( QgsMapCanvas *canvas setupUi( this ); setWindowFlag( Qt::FramelessWindowHint ); setAttribute( Qt::WA_TransparentForMouseEvents ); - setVisible( false ); + + setActive( QgsSettings().value( QStringLiteral( "/Cad/Floater" ), false ).toBool() ); // This is required to be able to track mouse move events mMapCanvas->viewport()->installEventFilter( this ); @@ -105,6 +107,8 @@ bool QgsAdvancedDigitizingFloater::active() void QgsAdvancedDigitizingFloater::setActive( bool active ) { + QgsSettings().setValue( QStringLiteral( "/Cad/Floater" ), mActive ); + mActive = active; if ( !active ) { From c9ee0612fbe5bae152cb496a310beed0627a435b Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Mon, 13 May 2019 11:15:21 +0200 Subject: [PATCH 14/27] docstring for each function --- src/gui/qgsadvanceddigitizingdockwidget.h | 127 +++++++++++++++++++--- 1 file changed, 112 insertions(+), 15 deletions(-) diff --git a/src/gui/qgsadvanceddigitizingdockwidget.h b/src/gui/qgsadvanceddigitizingdockwidget.h index 46cf537ba766..0a4e6d670fff 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.h +++ b/src/gui/qgsadvanceddigitizingdockwidget.h @@ -373,71 +373,168 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private //! Signals for external widgets that need to update according to current values /** - * Emitted whenever the value changes (either the mouse moved, or the user changed the input). + * Emitted whenever the X \a value changes (either the mouse moved, or the user changed the input). * Could be used by widgets that must reflect the current advanced digitizing state. - * - * \param value The current value (as a QString, as it could be an expression). */ void valueXChanged( QString value ); + + /** + * Emitted whenever the Y \a value changes (either the mouse moved, or the user changed the input). + * Could be used by widgets that must reflect the current advanced digitizing state. + */ void valueYChanged( QString value ); + + /** + * Emitted whenever the angle \a value changes (either the mouse moved, or the user changed the input). + * Could be used by widgets that must reflect the current advanced digitizing state. + */ void valueAngleChanged( QString value ); + + /** + * Emitted whenever the distance \a value changes (either the mouse moved, or the user changed the input). + * Could be used by widgets that must reflect the current advanced digitizing state. + */ void valueDistanceChanged( QString value ); /** - * Emitted whenever the parameter is locked. + * Emitted whenever the X parameter is \a locked. * Could be used by widgets that must reflect the current advanced digitizing state. - * - * \param locked Whether the parameter is locked or not. */ void lockXChanged( bool locked ); + + /** + * Emitted whenever the Y parameter is \a locked. + * Could be used by widgets that must reflect the current advanced digitizing state. + */ void lockYChanged( bool locked ); + + /** + * Emitted whenever the angle parameter is \a locked. + * Could be used by widgets that must reflect the current advanced digitizing state. + */ void lockAngleChanged( bool locked ); + + /** + * Emitted whenever the distance parameter is \a locked. + * Could be used by widgets that must reflect the current advanced digitizing state. + */ void lockDistanceChanged( bool locked ); /** - * Emitted whenever the parameter is toggled between absolute and relative. + * Emitted whenever the X parameter is toggled between absolute and relative. * Could be used by widgets that must reflect the current advanced digitizing state. * - * \param relative Whether the parameter is relative or not. + * \param relative Whether the X parameter is relative or not. */ void relativeXChanged( bool relative ); + + /** + * Emitted whenever the Y parameter is toggled between absolute and relative. + * Could be used by widgets that must reflect the current advanced digitizing state. + * + * \param relative Whether the Y parameter is relative or not. + */ void relativeYChanged( bool relative ); + + /** + * Emitted whenever the angleX parameter is toggled between absolute and relative. + * Could be used by widgets that must reflect the current advanced digitizing state. + * + * \param relative Whether the angle parameter is relative or not. + */ void relativeAngleChanged( bool relative ); - // void relativeDistanceChanged( bool relative ); // distance is always relative + + // relativeDistanceChanged doesn't exist as distance is always relative /** - * Emitted whenever the field is enabled or disabled. Depending on the context, some parameters + * Emitted whenever the X field is enabled or disabled. Depending on the context, some parameters * dont make sense (e.g. you need a previous point to define a distance). * Could be used by widgets that must reflect the current advanced digitizing state. * - * \param enabled Whether the parameter is enabled or not. + * \param enabled Whether the X parameter is enabled or not. */ void enabledChangedX( bool enabled ); + + /** + * Emitted whenever the Y field is enabled or disabled. Depending on the context, some parameters + * dont make sense (e.g. you need a previous point to define a distance). + * Could be used by widgets that must reflect the current advanced digitizing state. + * + * \param enabled Whether the Y parameter is enabled or not. + */ void enabledChangedY( bool enabled ); + + /** + * Emitted whenever the angle field is enabled or disabled. Depending on the context, some parameters + * dont make sense (e.g. you need a previous point to define a distance). + * Could be used by widgets that must reflect the current advanced digitizing state. + * + * \param enabled Whether the angle parameter is enabled or not. + */ void enabledChangedAngle( bool enabled ); + + /** + * Emitted whenever the distance field is enabled or disabled. Depending on the context, some parameters + * dont make sense (e.g. you need a previous point to define a distance). + * Could be used by widgets that must reflect the current advanced digitizing state. + * + * \param enabled Whether the distance parameter is enabled or not. + */ void enabledChangedDistance( bool enabled ); /** - * Emitted whenever the field should get the focus using the shortcuts (X, Y, A, D). + * Emitted whenever the X field should get the focus using the shortcuts (X). * Could be used by widgets to capture the focus when a field is being edited. */ void focusOnX(); + + /** + * Emitted whenever the Y field should get the focus using the shortcuts (Y). + * Could be used by widgets to capture the focus when a field is being edited. + */ void focusOnY(); + + /** + * Emitted whenever the angle field should get the focus using the shortcuts (A). + * Could be used by widgets to capture the focus when a field is being edited. + */ void focusOnAngle(); + + /** + * Emitted whenever the distance field should get the focus using the shortcuts (D). + * Could be used by widgets to capture the focus when a field is being edited. + */ void focusOnDistance(); public slots: /** - * Set and lock the parameter. + * Set and lock the X \a value. * Can be used to set constraints. - * - * \param value The current value (as a QString, as it could be an expression). + * \note The value is a QString, as it could be an expression. */ void setX( QString value ); + + /** + * Set and lock the Y \a value. + * Can be used to set constraints. + * \note The value is a QString, as it could be an expression. + */ void setY( QString value ); + + /** + * Set and lock the angle \a value. + * Can be used to set constraints. + * \note The value is a QString, as it could be an expression. + */ void setAngle( QString value ); + + /** + * Set and lock the distance \a value. + * Can be used to set constraints. + * \note The value is a QString, as it could be an expression. + */ void setDistance( QString value ); From 7fc0787f6141b680bf92f144a12d906d930a4bfe Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Mon, 13 May 2019 11:17:03 +0200 Subject: [PATCH 15/27] add \since QGIS 3.8 --- src/gui/qgsadvanceddigitizingdockwidget.h | 22 ++++++++++++++++++++++ src/gui/qgsadvanceddigitizingfloater.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/src/gui/qgsadvanceddigitizingdockwidget.h b/src/gui/qgsadvanceddigitizingdockwidget.h index 0a4e6d670fff..0d1ecb4eb8a9 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.h +++ b/src/gui/qgsadvanceddigitizingdockwidget.h @@ -375,36 +375,42 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private /** * Emitted whenever the X \a value changes (either the mouse moved, or the user changed the input). * Could be used by widgets that must reflect the current advanced digitizing state. + * \since QGIS 3.8 */ void valueXChanged( QString value ); /** * Emitted whenever the Y \a value changes (either the mouse moved, or the user changed the input). * Could be used by widgets that must reflect the current advanced digitizing state. + * \since QGIS 3.8 */ void valueYChanged( QString value ); /** * Emitted whenever the angle \a value changes (either the mouse moved, or the user changed the input). * Could be used by widgets that must reflect the current advanced digitizing state. + * \since QGIS 3.8 */ void valueAngleChanged( QString value ); /** * Emitted whenever the distance \a value changes (either the mouse moved, or the user changed the input). * Could be used by widgets that must reflect the current advanced digitizing state. + * \since QGIS 3.8 */ void valueDistanceChanged( QString value ); /** * Emitted whenever the X parameter is \a locked. * Could be used by widgets that must reflect the current advanced digitizing state. + * \since QGIS 3.8 */ void lockXChanged( bool locked ); /** * Emitted whenever the Y parameter is \a locked. * Could be used by widgets that must reflect the current advanced digitizing state. + * \since QGIS 3.8 */ void lockYChanged( bool locked ); @@ -417,6 +423,7 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private /** * Emitted whenever the distance parameter is \a locked. * Could be used by widgets that must reflect the current advanced digitizing state. + * \since QGIS 3.8 */ void lockDistanceChanged( bool locked ); @@ -425,6 +432,7 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private * Could be used by widgets that must reflect the current advanced digitizing state. * * \param relative Whether the X parameter is relative or not. + * \since QGIS 3.8 */ void relativeXChanged( bool relative ); @@ -433,6 +441,7 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private * Could be used by widgets that must reflect the current advanced digitizing state. * * \param relative Whether the Y parameter is relative or not. + * \since QGIS 3.8 */ void relativeYChanged( bool relative ); @@ -441,6 +450,7 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private * Could be used by widgets that must reflect the current advanced digitizing state. * * \param relative Whether the angle parameter is relative or not. + * \since QGIS 3.8 */ void relativeAngleChanged( bool relative ); @@ -452,6 +462,7 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private * Could be used by widgets that must reflect the current advanced digitizing state. * * \param enabled Whether the X parameter is enabled or not. + * \since QGIS 3.8 */ void enabledChangedX( bool enabled ); @@ -461,6 +472,7 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private * Could be used by widgets that must reflect the current advanced digitizing state. * * \param enabled Whether the Y parameter is enabled or not. + * \since QGIS 3.8 */ void enabledChangedY( bool enabled ); @@ -470,6 +482,7 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private * Could be used by widgets that must reflect the current advanced digitizing state. * * \param enabled Whether the angle parameter is enabled or not. + * \since QGIS 3.8 */ void enabledChangedAngle( bool enabled ); @@ -479,30 +492,35 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private * Could be used by widgets that must reflect the current advanced digitizing state. * * \param enabled Whether the distance parameter is enabled or not. + * \since QGIS 3.8 */ void enabledChangedDistance( bool enabled ); /** * Emitted whenever the X field should get the focus using the shortcuts (X). * Could be used by widgets to capture the focus when a field is being edited. + * \since QGIS 3.8 */ void focusOnX(); /** * Emitted whenever the Y field should get the focus using the shortcuts (Y). * Could be used by widgets to capture the focus when a field is being edited. + * \since QGIS 3.8 */ void focusOnY(); /** * Emitted whenever the angle field should get the focus using the shortcuts (A). * Could be used by widgets to capture the focus when a field is being edited. + * \since QGIS 3.8 */ void focusOnAngle(); /** * Emitted whenever the distance field should get the focus using the shortcuts (D). * Could be used by widgets to capture the focus when a field is being edited. + * \since QGIS 3.8 */ void focusOnDistance(); @@ -513,6 +531,7 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private * Set and lock the X \a value. * Can be used to set constraints. * \note The value is a QString, as it could be an expression. + * \since QGIS 3.8 */ void setX( QString value ); @@ -520,6 +539,7 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private * Set and lock the Y \a value. * Can be used to set constraints. * \note The value is a QString, as it could be an expression. + * \since QGIS 3.8 */ void setY( QString value ); @@ -527,6 +547,7 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private * Set and lock the angle \a value. * Can be used to set constraints. * \note The value is a QString, as it could be an expression. + * \since QGIS 3.8 */ void setAngle( QString value ); @@ -534,6 +555,7 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private * Set and lock the distance \a value. * Can be used to set constraints. * \note The value is a QString, as it could be an expression. + * \since QGIS 3.8 */ void setDistance( QString value ); diff --git a/src/gui/qgsadvanceddigitizingfloater.h b/src/gui/qgsadvanceddigitizingfloater.h index 2d8ec1b0e895..c1c46030e36b 100644 --- a/src/gui/qgsadvanceddigitizingfloater.h +++ b/src/gui/qgsadvanceddigitizingfloater.h @@ -44,6 +44,7 @@ class GUI_EXPORT QgsAdvancedDigitizingFloater : public QWidget, private Ui::QgsA /** * Whether the floater is active or not. * Note that the floater may be active but not visible (e.g. if the mouse is not over the canvas). + * \since QGIS 3.8 */ bool active(); @@ -52,6 +53,7 @@ class GUI_EXPORT QgsAdvancedDigitizingFloater : public QWidget, private Ui::QgsA /** * Set whether the floater should be active or not. * Note that the floater may be active but not visible (e.g. if the mouse is not over the canvas). + * \since QGIS 3.8 * * \param active */ From 7e328f6423a0611c36f8b1ce8da457ab94d1a67e Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Mon, 13 May 2019 11:26:55 +0200 Subject: [PATCH 16/27] remove now useless hideEvent --- src/gui/qgsadvanceddigitizingdockwidget.cpp | 10 ---------- src/gui/qgsadvanceddigitizingdockwidget.h | 5 ----- 2 files changed, 15 deletions(-) diff --git a/src/gui/qgsadvanceddigitizingdockwidget.cpp b/src/gui/qgsadvanceddigitizingdockwidget.cpp index 54e4c3475ac0..7d3c040723a7 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.cpp +++ b/src/gui/qgsadvanceddigitizingdockwidget.cpp @@ -160,16 +160,6 @@ QgsAdvancedDigitizingDockWidget::QgsAdvancedDigitizingDockWidget( QgsMapCanvas * disable(); } - -void QgsAdvancedDigitizingDockWidget::hideEvent( QHideEvent * ) -{ - // disable CAD but do not unset map event filter - // so it will be reactivated whenever the map tool is show again - // TODO : remove this (we don't want to disable CAD events, even when the dockerwidget is hidden) - // setCadEnabled( false ); -} - - void QgsAdvancedDigitizingDockWidget::setX( QString value ) { mXLineEdit->setText( value ); diff --git a/src/gui/qgsadvanceddigitizingdockwidget.h b/src/gui/qgsadvanceddigitizingdockwidget.h index 0d1ecb4eb8a9..4287c995808c 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.h +++ b/src/gui/qgsadvanceddigitizingdockwidget.h @@ -201,11 +201,6 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private */ explicit QgsAdvancedDigitizingDockWidget( QgsMapCanvas *canvas, QWidget *parent = nullptr ); - /** - * Disables the CAD tools when hiding the dock - */ - void hideEvent( QHideEvent * ) override; - /** * Filter key events to e.g. toggle construction mode or adapt constraints * From 96ac754c4174b9433f1942498969a0804872a81e Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Mon, 13 May 2019 11:28:42 +0200 Subject: [PATCH 17/27] "" -> QString() and "x" -> QStringLiteral("x") --- src/gui/qgsadvanceddigitizingfloater.cpp | 32 ++++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/gui/qgsadvanceddigitizingfloater.cpp b/src/gui/qgsadvanceddigitizingfloater.cpp index 7a1645abedee..f79977bfbbae 100644 --- a/src/gui/qgsadvanceddigitizingfloater.cpp +++ b/src/gui/qgsadvanceddigitizingfloater.cpp @@ -146,13 +146,13 @@ void QgsAdvancedDigitizingFloater::changeLockX( bool locked ) { if ( !locked ) { - mXLineEdit->setStyleSheet( "" ); - mXLabel->setStyleSheet( "" ); + mXLineEdit->setStyleSheet( QString() ); + mXLabel->setStyleSheet( QString() ); } else { - mXLineEdit->setStyleSheet( "font-weight: bold" ); - mXLabel->setStyleSheet( "font-weight: bold" ); + mXLineEdit->setStyleSheet( QStringLiteral("font-weight: bold") ); + mXLabel->setStyleSheet( QStringLiteral("font-weight: bold") ); } } @@ -160,13 +160,13 @@ void QgsAdvancedDigitizingFloater::changeLockY( bool locked ) { if ( !locked ) { - mYLineEdit->setStyleSheet( "" ); - mYLabel->setStyleSheet( "" ); + mYLineEdit->setStyleSheet( QString() ); + mYLabel->setStyleSheet( QString() ); } else { - mYLineEdit->setStyleSheet( "font-weight: bold" ); - mYLabel->setStyleSheet( "font-weight: bold" ); + mYLineEdit->setStyleSheet( QStringLiteral("font-weight: bold") ); + mYLabel->setStyleSheet( QStringLiteral("font-weight: bold") ); } } @@ -174,13 +174,13 @@ void QgsAdvancedDigitizingFloater::changeLockDistance( bool locked ) { if ( !locked ) { - mDistanceLineEdit->setStyleSheet( "" ); - mDistanceLabel->setStyleSheet( "" ); + mDistanceLineEdit->setStyleSheet( QString() ); + mDistanceLabel->setStyleSheet( QString() ); } else { - mDistanceLineEdit->setStyleSheet( "font-weight: bold" ); - mDistanceLabel->setStyleSheet( "font-weight: bold" ); + mDistanceLineEdit->setStyleSheet( QStringLiteral("font-weight: bold") ); + mDistanceLabel->setStyleSheet( QStringLiteral("font-weight: bold") ); } } @@ -188,13 +188,13 @@ void QgsAdvancedDigitizingFloater::changeLockAngle( bool locked ) { if ( !locked ) { - mAngleLineEdit->setStyleSheet( "" ); - mAngleLabel->setStyleSheet( "" ); + mAngleLineEdit->setStyleSheet( QString() ); + mAngleLabel->setStyleSheet( QString() ); } else { - mAngleLineEdit->setStyleSheet( "font-weight: bold" ); - mAngleLabel->setStyleSheet( "font-weight: bold" ); + mAngleLineEdit->setStyleSheet( QStringLiteral("font-weight: bold") ); + mAngleLabel->setStyleSheet( QStringLiteral("font-weight: bold") ); } } From dda866ee323ac7d5bcfefb092cc38fddae57a5df Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Mon, 13 May 2019 11:44:05 +0200 Subject: [PATCH 18/27] added a cad enabled changed signal and cleanup hide logic --- src/gui/qgsadvanceddigitizingdockwidget.cpp | 2 ++ src/gui/qgsadvanceddigitizingdockwidget.h | 8 ++++++++ src/gui/qgsadvanceddigitizingfloater.cpp | 18 ++++++++++++++---- src/gui/qgsadvanceddigitizingfloater.h | 5 +++++ 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/gui/qgsadvanceddigitizingdockwidget.cpp b/src/gui/qgsadvanceddigitizingdockwidget.cpp index 7d3c040723a7..f82cd42a92b0 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.cpp +++ b/src/gui/qgsadvanceddigitizingdockwidget.cpp @@ -195,6 +195,8 @@ void QgsAdvancedDigitizingDockWidget::setCadEnabled( bool enabled ) clear(); setConstructionMode( false ); + + emit cadEnabledChanged(enabled); } void QgsAdvancedDigitizingDockWidget::activateCad( bool enabled ) diff --git a/src/gui/qgsadvanceddigitizingdockwidget.h b/src/gui/qgsadvanceddigitizingdockwidget.h index 4287c995808c..97c35231d24e 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.h +++ b/src/gui/qgsadvanceddigitizingdockwidget.h @@ -367,6 +367,14 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private //! Signals for external widgets that need to update according to current values + /** + * Emitted whenever CAD is enabled or disabled + * + * \param enabled Whether CAD is enabled or not. + * \since QGIS 3.8 + */ + void cadEnabledChanged( bool enabled ); + /** * Emitted whenever the X \a value changes (either the mouse moved, or the user changed the input). * Could be used by widgets that must reflect the current advanced digitizing state. diff --git a/src/gui/qgsadvanceddigitizingfloater.cpp b/src/gui/qgsadvanceddigitizingfloater.cpp index f79977bfbbae..e28dc704851a 100644 --- a/src/gui/qgsadvanceddigitizingfloater.cpp +++ b/src/gui/qgsadvanceddigitizingfloater.cpp @@ -31,6 +31,8 @@ QgsAdvancedDigitizingFloater::QgsAdvancedDigitizingFloater( QgsMapCanvas *canvas setActive( QgsSettings().value( QStringLiteral( "/Cad/Floater" ), false ).toBool() ); + hideIfDisabled(); + // This is required to be able to track mouse move events mMapCanvas->viewport()->installEventFilter( this ); mMapCanvas->viewport()->setMouseTracking( true ); @@ -42,6 +44,8 @@ QgsAdvancedDigitizingFloater::QgsAdvancedDigitizingFloater( QgsMapCanvas *canvas mYLineEdit->installEventFilter( cadDockWidget ); // Connect all cadDockWidget's signals to update the widget's display + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::cadEnabledChanged, this, &QgsAdvancedDigitizingFloater::hideIfDisabled ); + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueXChanged, this, &QgsAdvancedDigitizingFloater::changeX ); connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueYChanged, this, &QgsAdvancedDigitizingFloater::changeY ); connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::valueAngleChanged, this, &QgsAdvancedDigitizingFloater::changeAngle ); @@ -110,10 +114,8 @@ void QgsAdvancedDigitizingFloater::setActive( bool active ) QgsSettings().setValue( QStringLiteral( "/Cad/Floater" ), mActive ); mActive = active; - if ( !active ) - { - setVisible( false ); - } + + hideIfDisabled(); } void QgsAdvancedDigitizingFloater::updatePos( const QPoint &pos ) @@ -122,6 +124,14 @@ void QgsAdvancedDigitizingFloater::updatePos( const QPoint &pos ) move( pos + QPoint( 15, 5 ) ); } +void QgsAdvancedDigitizingFloater::hideIfDisabled() +{ + if ( ! mCadDockWidget->cadEnabled() || ! mActive ) + { + setVisible( false ); + } +} + void QgsAdvancedDigitizingFloater::changeX( const QString &text ) { mXLineEdit->setText( text ); diff --git a/src/gui/qgsadvanceddigitizingfloater.h b/src/gui/qgsadvanceddigitizingfloater.h index c1c46030e36b..f15ab3eb90a0 100644 --- a/src/gui/qgsadvanceddigitizingfloater.h +++ b/src/gui/qgsadvanceddigitizingfloater.h @@ -102,6 +102,11 @@ class GUI_EXPORT QgsAdvancedDigitizingFloater : public QWidget, private Ui::QgsA */ void updatePos( const QPoint &pos ); + /** + * Hides the widget if either the floater or the cadDockWidget is disabled. + */ + void hideIfDisabled(); + //! Whether the floater is enabled. bool mActive = false; From f4996ecadda02f5c91393f4ca3cbdb200bf4bc22 Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Mon, 13 May 2019 11:44:11 +0200 Subject: [PATCH 19/27] typo --- src/gui/qgsadvanceddigitizingfloater.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/qgsadvanceddigitizingfloater.cpp b/src/gui/qgsadvanceddigitizingfloater.cpp index e28dc704851a..0566b49fa363 100644 --- a/src/gui/qgsadvanceddigitizingfloater.cpp +++ b/src/gui/qgsadvanceddigitizingfloater.cpp @@ -71,7 +71,7 @@ QgsAdvancedDigitizingFloater::QgsAdvancedDigitizingFloater( QgsMapCanvas *canvas connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedAngle, this, &QgsAdvancedDigitizingFloater::enabledChangedAngle ); connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedDistance, this, &QgsAdvancedDigitizingFloater::enabledChangedDistance ); - // Connect our line edits signals to update cadDockWidget's tate + // Connect our line edits signals to update cadDockWidget's state connect( mXLineEdit, &QLineEdit::returnPressed, cadDockWidget, [ = ]() { cadDockWidget->setX( mXLineEdit->text() ); } ); connect( mYLineEdit, &QLineEdit::returnPressed, cadDockWidget, [ = ]() { cadDockWidget->setY( mYLineEdit->text() ); } ); connect( mAngleLineEdit, &QLineEdit::returnPressed, cadDockWidget, [ = ]() { cadDockWidget->setAngle( mAngleLineEdit->text() ); } ); From e61f20c2702a9e5255e8f4b191d7b01eb338cbec Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Mon, 13 May 2019 12:04:27 +0200 Subject: [PATCH 20/27] QgsAdvancedDigitizingDockWidget slots as normal functions --- src/gui/qgsadvanceddigitizingdockwidget.h | 67 +++++++++++------------ 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/src/gui/qgsadvanceddigitizingdockwidget.h b/src/gui/qgsadvanceddigitizingdockwidget.h index 97c35231d24e..05d1ae4ce89d 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.h +++ b/src/gui/qgsadvanceddigitizingdockwidget.h @@ -343,6 +343,38 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private */ void updateCadPaintItem(); + /** + * Set and lock the X \a value. + * Can be used to set constraints. + * \note The value is a QString, as it could be an expression. + * \since QGIS 3.8 + */ + void setX( QString value ); + + /** + * Set and lock the Y \a value. + * Can be used to set constraints. + * \note The value is a QString, as it could be an expression. + * \since QGIS 3.8 + */ + void setY( QString value ); + + /** + * Set and lock the angle \a value. + * Can be used to set constraints. + * \note The value is a QString, as it could be an expression. + * \since QGIS 3.8 + */ + void setAngle( QString value ); + + /** + * Set and lock the distance \a value. + * Can be used to set constraints. + * \note The value is a QString, as it could be an expression. + * \since QGIS 3.8 + */ + void setDistance( QString value ); + signals: /** @@ -528,41 +560,6 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private void focusOnDistance(); - public slots: - - /** - * Set and lock the X \a value. - * Can be used to set constraints. - * \note The value is a QString, as it could be an expression. - * \since QGIS 3.8 - */ - void setX( QString value ); - - /** - * Set and lock the Y \a value. - * Can be used to set constraints. - * \note The value is a QString, as it could be an expression. - * \since QGIS 3.8 - */ - void setY( QString value ); - - /** - * Set and lock the angle \a value. - * Can be used to set constraints. - * \note The value is a QString, as it could be an expression. - * \since QGIS 3.8 - */ - void setAngle( QString value ); - - /** - * Set and lock the distance \a value. - * Can be used to set constraints. - * \note The value is a QString, as it could be an expression. - * \since QGIS 3.8 - */ - void setDistance( QString value ); - - private slots: //! Sets the additional constraint by clicking on the perpendicular/parallel buttons void additionalConstraintClicked( bool activated ); From 853d98bc07c6bb3e3da3d92c8acb9870f392046d Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Mon, 13 May 2019 12:08:50 +0200 Subject: [PATCH 21/27] prepare-commit.sh --- .../qgsadvanceddigitizingdockwidget.sip.in | 203 +++++++++++++++--- src/gui/qgsadvanceddigitizingdockwidget.cpp | 2 +- src/gui/qgsadvanceddigitizingfloater.cpp | 16 +- 3 files changed, 187 insertions(+), 34 deletions(-) diff --git a/python/gui/auto_generated/qgsadvanceddigitizingdockwidget.sip.in b/python/gui/auto_generated/qgsadvanceddigitizingdockwidget.sip.in index d29038c88c88..ac015440ed44 100644 --- a/python/gui/auto_generated/qgsadvanceddigitizingdockwidget.sip.in +++ b/python/gui/auto_generated/qgsadvanceddigitizingdockwidget.sip.in @@ -161,12 +161,6 @@ Create an advanced digitizing dock widget :param canvas: The map canvas on which the widget operates :param parent: The parent -%End - - virtual void hideEvent( QHideEvent * ); - -%Docstring -Disables the CAD tools when hiding the dock %End bool canvasKeyPressEventFilter( QKeyEvent *e ); @@ -336,6 +330,54 @@ Disable the widget. Normally done automatically from :py:func:`QgsMapToolAdvance Updates canvas item that displays constraints on the ma .. versionadded:: 3.0 +%End + + void setX( QString value ); +%Docstring +Set and lock the X ``value``. +Can be used to set constraints. + +.. note:: + + The value is a QString, as it could be an expression. + +.. versionadded:: 3.8 +%End + + void setY( QString value ); +%Docstring +Set and lock the Y ``value``. +Can be used to set constraints. + +.. note:: + + The value is a QString, as it could be an expression. + +.. versionadded:: 3.8 +%End + + void setAngle( QString value ); +%Docstring +Set and lock the angle ``value``. +Can be used to set constraints. + +.. note:: + + The value is a QString, as it could be an expression. + +.. versionadded:: 3.8 +%End + + void setDistance( QString value ); +%Docstring +Set and lock the distance ``value``. +Can be used to set constraints. + +.. note:: + + The value is a QString, as it could be an expression. + +.. versionadded:: 3.8 %End signals: @@ -361,72 +403,183 @@ when a constraint is toggled. %End + void cadEnabledChanged( bool enabled ); +%Docstring +Emitted whenever CAD is enabled or disabled + +:param enabled: Whether CAD is enabled or not. + +.. versionadded:: 3.8 +%End + void valueXChanged( QString value ); %Docstring -Emitted whenever the value changes (either the mouse moved, or the user changed the input). +Emitted whenever the X ``value`` changes (either the mouse moved, or the user changed the input). Could be used by widgets that must reflect the current advanced digitizing state. -:param value: The current value (as a QString, as it could be an expression). +.. versionadded:: 3.8 %End + void valueYChanged( QString value ); +%Docstring +Emitted whenever the Y ``value`` changes (either the mouse moved, or the user changed the input). +Could be used by widgets that must reflect the current advanced digitizing state. + +.. versionadded:: 3.8 +%End + void valueAngleChanged( QString value ); +%Docstring +Emitted whenever the angle ``value`` changes (either the mouse moved, or the user changed the input). +Could be used by widgets that must reflect the current advanced digitizing state. + +.. versionadded:: 3.8 +%End + void valueDistanceChanged( QString value ); +%Docstring +Emitted whenever the distance ``value`` changes (either the mouse moved, or the user changed the input). +Could be used by widgets that must reflect the current advanced digitizing state. + +.. versionadded:: 3.8 +%End void lockXChanged( bool locked ); %Docstring -Emitted whenever the parameter is locked. +Emitted whenever the X parameter is ``locked``. Could be used by widgets that must reflect the current advanced digitizing state. -:param locked: Whether the parameter is locked or not. +.. versionadded:: 3.8 %End + void lockYChanged( bool locked ); +%Docstring +Emitted whenever the Y parameter is ``locked``. +Could be used by widgets that must reflect the current advanced digitizing state. + +.. versionadded:: 3.8 +%End + void lockAngleChanged( bool locked ); +%Docstring +Emitted whenever the angle parameter is ``locked``. +Could be used by widgets that must reflect the current advanced digitizing state. +%End + void lockDistanceChanged( bool locked ); +%Docstring +Emitted whenever the distance parameter is ``locked``. +Could be used by widgets that must reflect the current advanced digitizing state. + +.. versionadded:: 3.8 +%End void relativeXChanged( bool relative ); %Docstring -Emitted whenever the parameter is toggled between absolute and relative. +Emitted whenever the X parameter is toggled between absolute and relative. Could be used by widgets that must reflect the current advanced digitizing state. -:param relative: Whether the parameter is relative or not. +:param relative: Whether the X parameter is relative or not. + +.. versionadded:: 3.8 %End + void relativeYChanged( bool relative ); +%Docstring +Emitted whenever the Y parameter is toggled between absolute and relative. +Could be used by widgets that must reflect the current advanced digitizing state. + +:param relative: Whether the Y parameter is relative or not. + +.. versionadded:: 3.8 +%End + void relativeAngleChanged( bool relative ); +%Docstring +Emitted whenever the angleX parameter is toggled between absolute and relative. +Could be used by widgets that must reflect the current advanced digitizing state. + +:param relative: Whether the angle parameter is relative or not. + +.. versionadded:: 3.8 +%End + void enabledChangedX( bool enabled ); %Docstring -Emitted whenever the field is enabled or disabled. Depending on the context, some parameters +Emitted whenever the X field is enabled or disabled. Depending on the context, some parameters dont make sense (e.g. you need a previous point to define a distance). Could be used by widgets that must reflect the current advanced digitizing state. -:param enabled: Whether the parameter is enabled or not. +:param enabled: Whether the X parameter is enabled or not. + +.. versionadded:: 3.8 %End + void enabledChangedY( bool enabled ); +%Docstring +Emitted whenever the Y field is enabled or disabled. Depending on the context, some parameters +dont make sense (e.g. you need a previous point to define a distance). +Could be used by widgets that must reflect the current advanced digitizing state. + +:param enabled: Whether the Y parameter is enabled or not. + +.. versionadded:: 3.8 +%End + void enabledChangedAngle( bool enabled ); +%Docstring +Emitted whenever the angle field is enabled or disabled. Depending on the context, some parameters +dont make sense (e.g. you need a previous point to define a distance). +Could be used by widgets that must reflect the current advanced digitizing state. + +:param enabled: Whether the angle parameter is enabled or not. + +.. versionadded:: 3.8 +%End + void enabledChangedDistance( bool enabled ); +%Docstring +Emitted whenever the distance field is enabled or disabled. Depending on the context, some parameters +dont make sense (e.g. you need a previous point to define a distance). +Could be used by widgets that must reflect the current advanced digitizing state. + +:param enabled: Whether the distance parameter is enabled or not. + +.. versionadded:: 3.8 +%End void focusOnX(); %Docstring -Emitted whenever the field should get the focus using the shortcuts (X, Y, A, D). +Emitted whenever the X field should get the focus using the shortcuts (X). Could be used by widgets to capture the focus when a field is being edited. + +.. versionadded:: 3.8 %End + void focusOnY(); - void focusOnAngle(); - void focusOnDistance(); +%Docstring +Emitted whenever the Y field should get the focus using the shortcuts (Y). +Could be used by widgets to capture the focus when a field is being edited. +.. versionadded:: 3.8 +%End - public slots: + void focusOnAngle(); +%Docstring +Emitted whenever the angle field should get the focus using the shortcuts (A). +Could be used by widgets to capture the focus when a field is being edited. - void setX( QString value ); +.. versionadded:: 3.8 +%End + + void focusOnDistance(); %Docstring -Set and lock the parameter. -Can be used to set constraints. +Emitted whenever the distance field should get the focus using the shortcuts (D). +Could be used by widgets to capture the focus when a field is being edited. -:param value: The current value (as a QString, as it could be an expression). +.. versionadded:: 3.8 %End - void setY( QString value ); - void setAngle( QString value ); - void setDistance( QString value ); private: diff --git a/src/gui/qgsadvanceddigitizingdockwidget.cpp b/src/gui/qgsadvanceddigitizingdockwidget.cpp index f82cd42a92b0..1d66ae213a9a 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.cpp +++ b/src/gui/qgsadvanceddigitizingdockwidget.cpp @@ -196,7 +196,7 @@ void QgsAdvancedDigitizingDockWidget::setCadEnabled( bool enabled ) clear(); setConstructionMode( false ); - emit cadEnabledChanged(enabled); + emit cadEnabledChanged( enabled ); } void QgsAdvancedDigitizingDockWidget::activateCad( bool enabled ) diff --git a/src/gui/qgsadvanceddigitizingfloater.cpp b/src/gui/qgsadvanceddigitizingfloater.cpp index 0566b49fa363..d2d2e2640c64 100644 --- a/src/gui/qgsadvanceddigitizingfloater.cpp +++ b/src/gui/qgsadvanceddigitizingfloater.cpp @@ -161,8 +161,8 @@ void QgsAdvancedDigitizingFloater::changeLockX( bool locked ) } else { - mXLineEdit->setStyleSheet( QStringLiteral("font-weight: bold") ); - mXLabel->setStyleSheet( QStringLiteral("font-weight: bold") ); + mXLineEdit->setStyleSheet( QStringLiteral( "font-weight: bold" ) ); + mXLabel->setStyleSheet( QStringLiteral( "font-weight: bold" ) ); } } @@ -175,8 +175,8 @@ void QgsAdvancedDigitizingFloater::changeLockY( bool locked ) } else { - mYLineEdit->setStyleSheet( QStringLiteral("font-weight: bold") ); - mYLabel->setStyleSheet( QStringLiteral("font-weight: bold") ); + mYLineEdit->setStyleSheet( QStringLiteral( "font-weight: bold" ) ); + mYLabel->setStyleSheet( QStringLiteral( "font-weight: bold" ) ); } } @@ -189,8 +189,8 @@ void QgsAdvancedDigitizingFloater::changeLockDistance( bool locked ) } else { - mDistanceLineEdit->setStyleSheet( QStringLiteral("font-weight: bold") ); - mDistanceLabel->setStyleSheet( QStringLiteral("font-weight: bold") ); + mDistanceLineEdit->setStyleSheet( QStringLiteral( "font-weight: bold" ) ); + mDistanceLabel->setStyleSheet( QStringLiteral( "font-weight: bold" ) ); } } @@ -203,8 +203,8 @@ void QgsAdvancedDigitizingFloater::changeLockAngle( bool locked ) } else { - mAngleLineEdit->setStyleSheet( QStringLiteral("font-weight: bold") ); - mAngleLabel->setStyleSheet( QStringLiteral("font-weight: bold") ); + mAngleLineEdit->setStyleSheet( QStringLiteral( "font-weight: bold" ) ); + mAngleLabel->setStyleSheet( QStringLiteral( "font-weight: bold" ) ); } } From 211de64d5e987175f2d84ddf2171e34e06b8e933 Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Mon, 13 May 2019 13:17:08 +0200 Subject: [PATCH 22/27] more pass arguments by reference --- src/gui/qgsadvanceddigitizingdockwidget.cpp | 8 ++++---- src/gui/qgsadvanceddigitizingdockwidget.h | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/gui/qgsadvanceddigitizingdockwidget.cpp b/src/gui/qgsadvanceddigitizingdockwidget.cpp index 1d66ae213a9a..b3353f0b720b 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.cpp +++ b/src/gui/qgsadvanceddigitizingdockwidget.cpp @@ -160,22 +160,22 @@ QgsAdvancedDigitizingDockWidget::QgsAdvancedDigitizingDockWidget( QgsMapCanvas * disable(); } -void QgsAdvancedDigitizingDockWidget::setX( QString value ) +void QgsAdvancedDigitizingDockWidget::setX( const QString &value ) { mXLineEdit->setText( value ); mXLineEdit->returnPressed(); } -void QgsAdvancedDigitizingDockWidget::setY( QString value ) +void QgsAdvancedDigitizingDockWidget::setY( const QString &value ) { mYLineEdit->setText( value ); mYLineEdit->returnPressed(); } -void QgsAdvancedDigitizingDockWidget::setAngle( QString value ) +void QgsAdvancedDigitizingDockWidget::setAngle( const QString &value ) { mAngleLineEdit->setText( value ); mAngleLineEdit->returnPressed(); } -void QgsAdvancedDigitizingDockWidget::setDistance( QString value ) +void QgsAdvancedDigitizingDockWidget::setDistance( const QString &value ) { mDistanceLineEdit->setText( value ); mDistanceLineEdit->returnPressed(); diff --git a/src/gui/qgsadvanceddigitizingdockwidget.h b/src/gui/qgsadvanceddigitizingdockwidget.h index 05d1ae4ce89d..922c348945e2 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.h +++ b/src/gui/qgsadvanceddigitizingdockwidget.h @@ -349,7 +349,7 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private * \note The value is a QString, as it could be an expression. * \since QGIS 3.8 */ - void setX( QString value ); + void setX( const QString &value ); /** * Set and lock the Y \a value. @@ -357,7 +357,7 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private * \note The value is a QString, as it could be an expression. * \since QGIS 3.8 */ - void setY( QString value ); + void setY( const QString &value ); /** * Set and lock the angle \a value. @@ -365,7 +365,7 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private * \note The value is a QString, as it could be an expression. * \since QGIS 3.8 */ - void setAngle( QString value ); + void setAngle( const QString &value ); /** * Set and lock the distance \a value. @@ -373,7 +373,7 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private * \note The value is a QString, as it could be an expression. * \since QGIS 3.8 */ - void setDistance( QString value ); + void setDistance( const QString &value ); signals: @@ -412,28 +412,28 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private * Could be used by widgets that must reflect the current advanced digitizing state. * \since QGIS 3.8 */ - void valueXChanged( QString value ); + void valueXChanged( const QString &value ); /** * Emitted whenever the Y \a value changes (either the mouse moved, or the user changed the input). * Could be used by widgets that must reflect the current advanced digitizing state. * \since QGIS 3.8 */ - void valueYChanged( QString value ); + void valueYChanged( const QString &value ); /** * Emitted whenever the angle \a value changes (either the mouse moved, or the user changed the input). * Could be used by widgets that must reflect the current advanced digitizing state. * \since QGIS 3.8 */ - void valueAngleChanged( QString value ); + void valueAngleChanged( const QString &value ); /** * Emitted whenever the distance \a value changes (either the mouse moved, or the user changed the input). * Could be used by widgets that must reflect the current advanced digitizing state. * \since QGIS 3.8 */ - void valueDistanceChanged( QString value ); + void valueDistanceChanged( const QString &value ); /** * Emitted whenever the X parameter is \a locked. From 5db4f157d594f30097108e2a164d0841ed1af1ef Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Mon, 13 May 2019 13:17:17 +0200 Subject: [PATCH 23/27] fix spelling --- src/gui/qgsadvanceddigitizingdockwidget.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/qgsadvanceddigitizingdockwidget.h b/src/gui/qgsadvanceddigitizingdockwidget.h index 922c348945e2..7896053b9f4f 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.h +++ b/src/gui/qgsadvanceddigitizingdockwidget.h @@ -493,7 +493,7 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private /** * Emitted whenever the X field is enabled or disabled. Depending on the context, some parameters - * dont make sense (e.g. you need a previous point to define a distance). + * do not make sense (e.g. you need a previous point to define a distance). * Could be used by widgets that must reflect the current advanced digitizing state. * * \param enabled Whether the X parameter is enabled or not. @@ -503,7 +503,7 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private /** * Emitted whenever the Y field is enabled or disabled. Depending on the context, some parameters - * dont make sense (e.g. you need a previous point to define a distance). + * do not make sense (e.g. you need a previous point to define a distance). * Could be used by widgets that must reflect the current advanced digitizing state. * * \param enabled Whether the Y parameter is enabled or not. @@ -513,7 +513,7 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private /** * Emitted whenever the angle field is enabled or disabled. Depending on the context, some parameters - * dont make sense (e.g. you need a previous point to define a distance). + * do not make sense (e.g. you need a previous point to define a distance). * Could be used by widgets that must reflect the current advanced digitizing state. * * \param enabled Whether the angle parameter is enabled or not. @@ -523,7 +523,7 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private /** * Emitted whenever the distance field is enabled or disabled. Depending on the context, some parameters - * dont make sense (e.g. you need a previous point to define a distance). + * do not make sense (e.g. you need a previous point to define a distance). * Could be used by widgets that must reflect the current advanced digitizing state. * * \param enabled Whether the distance parameter is enabled or not. From 78015802696f94ac8d9a2a9b83644dca4d139a51 Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Mon, 13 May 2019 13:18:57 +0200 Subject: [PATCH 24/27] fix saving of floater settings --- src/gui/qgsadvanceddigitizingfloater.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/qgsadvanceddigitizingfloater.cpp b/src/gui/qgsadvanceddigitizingfloater.cpp index d2d2e2640c64..c443bf3ea123 100644 --- a/src/gui/qgsadvanceddigitizingfloater.cpp +++ b/src/gui/qgsadvanceddigitizingfloater.cpp @@ -111,7 +111,7 @@ bool QgsAdvancedDigitizingFloater::active() void QgsAdvancedDigitizingFloater::setActive( bool active ) { - QgsSettings().setValue( QStringLiteral( "/Cad/Floater" ), mActive ); + QgsSettings().setValue( QStringLiteral( "/Cad/Floater" ), active ); mActive = active; From f9242955ae3ab4e465df6a9653d7489439bb05e3 Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Mon, 13 May 2019 13:25:19 +0200 Subject: [PATCH 25/27] prepare-commit.sh --- .../qgsadvanceddigitizingdockwidget.sip.in | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/python/gui/auto_generated/qgsadvanceddigitizingdockwidget.sip.in b/python/gui/auto_generated/qgsadvanceddigitizingdockwidget.sip.in index ac015440ed44..0b404380211c 100644 --- a/python/gui/auto_generated/qgsadvanceddigitizingdockwidget.sip.in +++ b/python/gui/auto_generated/qgsadvanceddigitizingdockwidget.sip.in @@ -332,7 +332,7 @@ Updates canvas item that displays constraints on the ma .. versionadded:: 3.0 %End - void setX( QString value ); + void setX( const QString &value ); %Docstring Set and lock the X ``value``. Can be used to set constraints. @@ -344,7 +344,7 @@ Can be used to set constraints. .. versionadded:: 3.8 %End - void setY( QString value ); + void setY( const QString &value ); %Docstring Set and lock the Y ``value``. Can be used to set constraints. @@ -356,7 +356,7 @@ Can be used to set constraints. .. versionadded:: 3.8 %End - void setAngle( QString value ); + void setAngle( const QString &value ); %Docstring Set and lock the angle ``value``. Can be used to set constraints. @@ -368,7 +368,7 @@ Can be used to set constraints. .. versionadded:: 3.8 %End - void setDistance( QString value ); + void setDistance( const QString &value ); %Docstring Set and lock the distance ``value``. Can be used to set constraints. @@ -412,7 +412,7 @@ Emitted whenever CAD is enabled or disabled .. versionadded:: 3.8 %End - void valueXChanged( QString value ); + void valueXChanged( const QString &value ); %Docstring Emitted whenever the X ``value`` changes (either the mouse moved, or the user changed the input). Could be used by widgets that must reflect the current advanced digitizing state. @@ -420,7 +420,7 @@ Could be used by widgets that must reflect the current advanced digitizing state .. versionadded:: 3.8 %End - void valueYChanged( QString value ); + void valueYChanged( const QString &value ); %Docstring Emitted whenever the Y ``value`` changes (either the mouse moved, or the user changed the input). Could be used by widgets that must reflect the current advanced digitizing state. @@ -428,7 +428,7 @@ Could be used by widgets that must reflect the current advanced digitizing state .. versionadded:: 3.8 %End - void valueAngleChanged( QString value ); + void valueAngleChanged( const QString &value ); %Docstring Emitted whenever the angle ``value`` changes (either the mouse moved, or the user changed the input). Could be used by widgets that must reflect the current advanced digitizing state. @@ -436,7 +436,7 @@ Could be used by widgets that must reflect the current advanced digitizing state .. versionadded:: 3.8 %End - void valueDistanceChanged( QString value ); + void valueDistanceChanged( const QString &value ); %Docstring Emitted whenever the distance ``value`` changes (either the mouse moved, or the user changed the input). Could be used by widgets that must reflect the current advanced digitizing state. @@ -508,7 +508,7 @@ Could be used by widgets that must reflect the current advanced digitizing state void enabledChangedX( bool enabled ); %Docstring Emitted whenever the X field is enabled or disabled. Depending on the context, some parameters -dont make sense (e.g. you need a previous point to define a distance). +do not make sense (e.g. you need a previous point to define a distance). Could be used by widgets that must reflect the current advanced digitizing state. :param enabled: Whether the X parameter is enabled or not. @@ -519,7 +519,7 @@ Could be used by widgets that must reflect the current advanced digitizing state void enabledChangedY( bool enabled ); %Docstring Emitted whenever the Y field is enabled or disabled. Depending on the context, some parameters -dont make sense (e.g. you need a previous point to define a distance). +do not make sense (e.g. you need a previous point to define a distance). Could be used by widgets that must reflect the current advanced digitizing state. :param enabled: Whether the Y parameter is enabled or not. @@ -530,7 +530,7 @@ Could be used by widgets that must reflect the current advanced digitizing state void enabledChangedAngle( bool enabled ); %Docstring Emitted whenever the angle field is enabled or disabled. Depending on the context, some parameters -dont make sense (e.g. you need a previous point to define a distance). +do not make sense (e.g. you need a previous point to define a distance). Could be used by widgets that must reflect the current advanced digitizing state. :param enabled: Whether the angle parameter is enabled or not. @@ -541,7 +541,7 @@ Could be used by widgets that must reflect the current advanced digitizing state void enabledChangedDistance( bool enabled ); %Docstring Emitted whenever the distance field is enabled or disabled. Depending on the context, some parameters -dont make sense (e.g. you need a previous point to define a distance). +do not make sense (e.g. you need a previous point to define a distance). Could be used by widgets that must reflect the current advanced digitizing state. :param enabled: Whether the distance parameter is enabled or not. From dbcc9fbeea305601a4d06007c68060be36d0f8ef Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Mon, 13 May 2019 13:47:23 +0200 Subject: [PATCH 26/27] use default font size --- src/ui/qgsadvanceddigitizingfloaterbase.ui | 50 ++-------------------- 1 file changed, 3 insertions(+), 47 deletions(-) diff --git a/src/ui/qgsadvanceddigitizingfloaterbase.ui b/src/ui/qgsadvanceddigitizingfloaterbase.ui index ec99386f6003..7e34014319c6 100644 --- a/src/ui/qgsadvanceddigitizingfloaterbase.ui +++ b/src/ui/qgsadvanceddigitizingfloaterbase.ui @@ -6,8 +6,8 @@ 0 0 - 128 - 77 + 150 + 120 @@ -27,7 +27,7 @@ 6 - 2 + 0 @@ -38,17 +38,6 @@ - - - 16777215 - 14 - - - - - 8 - - @@ -71,17 +60,6 @@ 0 - - - 8 - - - - - 16777215 - 14 - - @@ -101,17 +79,6 @@ 0 - - - 8 - - - - - 16777215 - 14 - - @@ -145,17 +112,6 @@ 0 - - - 8 - - - - - 16777215 - 14 - - From 199bd4de497cdc1b8e4547a0de617edd3eece3dc Mon Sep 17 00:00:00 2001 From: olivierdalang Date: Mon, 13 May 2019 14:01:13 +0200 Subject: [PATCH 27/27] focusOnX(); -> focusOnXRequested(); --- .../auto_generated/qgsadvanceddigitizingdockwidget.sip.in | 8 ++++---- src/gui/qgsadvanceddigitizingdockwidget.cpp | 8 ++++---- src/gui/qgsadvanceddigitizingdockwidget.h | 8 ++++---- src/gui/qgsadvanceddigitizingfloater.cpp | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/python/gui/auto_generated/qgsadvanceddigitizingdockwidget.sip.in b/python/gui/auto_generated/qgsadvanceddigitizingdockwidget.sip.in index 0b404380211c..bcb0d2aba30a 100644 --- a/python/gui/auto_generated/qgsadvanceddigitizingdockwidget.sip.in +++ b/python/gui/auto_generated/qgsadvanceddigitizingdockwidget.sip.in @@ -549,7 +549,7 @@ Could be used by widgets that must reflect the current advanced digitizing state .. versionadded:: 3.8 %End - void focusOnX(); + void focusOnXRequested(); %Docstring Emitted whenever the X field should get the focus using the shortcuts (X). Could be used by widgets to capture the focus when a field is being edited. @@ -557,7 +557,7 @@ Could be used by widgets to capture the focus when a field is being edited. .. versionadded:: 3.8 %End - void focusOnY(); + void focusOnYRequested(); %Docstring Emitted whenever the Y field should get the focus using the shortcuts (Y). Could be used by widgets to capture the focus when a field is being edited. @@ -565,7 +565,7 @@ Could be used by widgets to capture the focus when a field is being edited. .. versionadded:: 3.8 %End - void focusOnAngle(); + void focusOnAngleRequested(); %Docstring Emitted whenever the angle field should get the focus using the shortcuts (A). Could be used by widgets to capture the focus when a field is being edited. @@ -573,7 +573,7 @@ Could be used by widgets to capture the focus when a field is being edited. .. versionadded:: 3.8 %End - void focusOnDistance(); + void focusOnDistanceRequested(); %Docstring Emitted whenever the distance field should get the focus using the shortcuts (D). Could be used by widgets to capture the focus when a field is being edited. diff --git a/src/gui/qgsadvanceddigitizingdockwidget.cpp b/src/gui/qgsadvanceddigitizingdockwidget.cpp index b3353f0b720b..5afb41f6e9a0 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.cpp +++ b/src/gui/qgsadvanceddigitizingdockwidget.cpp @@ -910,7 +910,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) { mXLineEdit->setFocus(); mXLineEdit->selectAll(); - emit focusOnX(); + emit focusOnXRequested(); e->accept(); } break; @@ -940,7 +940,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) { mYLineEdit->setFocus(); mYLineEdit->selectAll(); - emit focusOnY(); + emit focusOnYRequested(); e->accept(); } break; @@ -973,7 +973,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) { mAngleLineEdit->setFocus(); mAngleLineEdit->selectAll(); - emit focusOnAngle(); + emit focusOnAngleRequested(); e->accept(); } break; @@ -996,7 +996,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e ) { mDistanceLineEdit->setFocus(); mDistanceLineEdit->selectAll(); - emit focusOnDistance(); + emit focusOnDistanceRequested(); e->accept(); } break; diff --git a/src/gui/qgsadvanceddigitizingdockwidget.h b/src/gui/qgsadvanceddigitizingdockwidget.h index 7896053b9f4f..9cd1e534dd28 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.h +++ b/src/gui/qgsadvanceddigitizingdockwidget.h @@ -536,28 +536,28 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private * Could be used by widgets to capture the focus when a field is being edited. * \since QGIS 3.8 */ - void focusOnX(); + void focusOnXRequested(); /** * Emitted whenever the Y field should get the focus using the shortcuts (Y). * Could be used by widgets to capture the focus when a field is being edited. * \since QGIS 3.8 */ - void focusOnY(); + void focusOnYRequested(); /** * Emitted whenever the angle field should get the focus using the shortcuts (A). * Could be used by widgets to capture the focus when a field is being edited. * \since QGIS 3.8 */ - void focusOnAngle(); + void focusOnAngleRequested(); /** * Emitted whenever the distance field should get the focus using the shortcuts (D). * Could be used by widgets to capture the focus when a field is being edited. * \since QGIS 3.8 */ - void focusOnDistance(); + void focusOnDistanceRequested(); private slots: diff --git a/src/gui/qgsadvanceddigitizingfloater.cpp b/src/gui/qgsadvanceddigitizingfloater.cpp index c443bf3ea123..bfb9d09ab508 100644 --- a/src/gui/qgsadvanceddigitizingfloater.cpp +++ b/src/gui/qgsadvanceddigitizingfloater.cpp @@ -61,10 +61,10 @@ QgsAdvancedDigitizingFloater::QgsAdvancedDigitizingFloater( QgsMapCanvas *canvas connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::relativeAngleChanged, this, &QgsAdvancedDigitizingFloater::changeRelativeAngle ); // distance is always relative - connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnX, this, &QgsAdvancedDigitizingFloater::focusOnX ); - connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnY, this, &QgsAdvancedDigitizingFloater::focusOnY ); - connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnAngle, this, &QgsAdvancedDigitizingFloater::focusOnAngle ); - connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnDistance, this, &QgsAdvancedDigitizingFloater::focusOnDistance ); + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnXRequested, this, &QgsAdvancedDigitizingFloater::focusOnX ); + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnYRequested, this, &QgsAdvancedDigitizingFloater::focusOnY ); + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnAngleRequested, this, &QgsAdvancedDigitizingFloater::focusOnAngle ); + connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::focusOnDistanceRequested, this, &QgsAdvancedDigitizingFloater::focusOnDistance ); connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedX, this, &QgsAdvancedDigitizingFloater::enabledChangedX ); connect( cadDockWidget, &QgsAdvancedDigitizingDockWidget::enabledChangedY, this, &QgsAdvancedDigitizingFloater::enabledChangedY );