@@ -782,8 +782,7 @@ void QgsAdvancedDigitizingDockWidget::setPoints( const QList<QgsPointXY> &points
782
782
bool QgsAdvancedDigitizingDockWidget::eventFilter ( QObject *obj, QEvent *event )
783
783
{
784
784
// event for line edits
785
- Q_UNUSED ( obj );
786
- if ( event->type () != QEvent::KeyPress )
785
+ if ( !cadEnabled () || ( event->type () != QEvent::ShortcutOverride && event->type () != QEvent::KeyPress ) )
787
786
{
788
787
return QgsDockWidget::eventFilter ( obj, event );
789
788
}
@@ -797,115 +796,135 @@ bool QgsAdvancedDigitizingDockWidget::eventFilter( QObject *obj, QEvent *event )
797
796
798
797
bool QgsAdvancedDigitizingDockWidget::filterKeyPress ( QKeyEvent *e )
799
798
{
799
+ QEvent::Type type = e->type ();
800
800
switch ( e->key () )
801
801
{
802
802
case Qt::Key_X:
803
803
{
804
- if ( e->modifiers () == Qt::AltModifier || e->modifiers () == Qt::ControlModifier )
804
+ if ( type == QEvent::ShortcutOverride && ( e->modifiers () == Qt::AltModifier || e->modifiers () == Qt::ControlModifier ) )
805
805
{
806
806
mXConstraint ->toggleLocked ();
807
807
emit pointChanged ( mCadPointList .value ( 0 ) );
808
+ e->accept ();
808
809
}
809
- else if ( e->modifiers () == Qt::ShiftModifier )
810
+ else if ( type == QEvent::ShortcutOverride && e->modifiers () == Qt::ShiftModifier )
810
811
{
811
812
if ( mCapacities .testFlag ( RelativeCoordinates ) )
812
813
{
813
814
mXConstraint ->toggleRelative ();
814
815
emit pointChanged ( mCadPointList .value ( 0 ) );
816
+ e->accept ();
815
817
}
816
818
}
817
- else
819
+ else if ( type == QEvent::KeyPress )
818
820
{
819
821
mXLineEdit ->setFocus ();
820
822
mXLineEdit ->selectAll ();
823
+ e->accept ();
821
824
}
822
825
break ;
823
826
}
824
827
case Qt::Key_Y:
825
828
{
826
- if ( e->modifiers () == Qt::AltModifier || e->modifiers () == Qt::ControlModifier )
829
+ if ( type == QEvent::ShortcutOverride && ( e->modifiers () == Qt::AltModifier || e->modifiers () == Qt::ControlModifier ) )
827
830
{
828
831
mYConstraint ->toggleLocked ();
829
832
emit pointChanged ( mCadPointList .value ( 0 ) );
833
+ e->accept ();
830
834
}
831
- else if ( e->modifiers () == Qt::ShiftModifier )
835
+ else if ( type == QEvent::ShortcutOverride && e->modifiers () == Qt::ShiftModifier )
832
836
{
833
837
if ( mCapacities .testFlag ( RelativeCoordinates ) )
834
838
{
835
839
mYConstraint ->toggleRelative ();
836
840
emit pointChanged ( mCadPointList .value ( 0 ) );
841
+ e->accept ();
837
842
}
838
843
}
839
- else
844
+ else if ( type == QEvent::KeyPress )
840
845
{
841
846
mYLineEdit ->setFocus ();
842
847
mYLineEdit ->selectAll ();
848
+ e->accept ();
843
849
}
844
850
break ;
845
851
}
846
852
case Qt::Key_A:
847
853
{
848
- if ( e->modifiers () == Qt::AltModifier || e->modifiers () == Qt::ControlModifier )
854
+ if ( type == QEvent::ShortcutOverride && ( e->modifiers () == Qt::AltModifier || e->modifiers () == Qt::ControlModifier ) )
849
855
{
850
856
if ( mCapacities .testFlag ( AbsoluteAngle ) )
851
857
{
852
858
mAngleConstraint ->toggleLocked ();
853
859
emit pointChanged ( mCadPointList .value ( 0 ) );
860
+ e->accept ();
854
861
}
855
862
}
856
- else if ( e->modifiers () == Qt::ShiftModifier )
863
+ else if ( type == QEvent::ShortcutOverride && e->modifiers () == Qt::ShiftModifier )
857
864
{
858
865
if ( mCapacities .testFlag ( RelativeAngle ) )
859
866
{
860
867
mAngleConstraint ->toggleRelative ();
861
868
emit pointChanged ( mCadPointList .value ( 0 ) );
869
+ e->accept ();
862
870
}
863
871
}
864
- else
872
+ else if ( type == QEvent::KeyPress )
865
873
{
866
874
mAngleLineEdit ->setFocus ();
867
875
mAngleLineEdit ->selectAll ();
876
+ e->accept ();
868
877
}
869
878
break ;
870
879
}
871
880
case Qt::Key_D:
872
881
{
873
- if ( e->modifiers () == Qt::AltModifier || e->modifiers () == Qt::ControlModifier )
882
+ if ( type == QEvent::ShortcutOverride && ( e->modifiers () == Qt::AltModifier || e->modifiers () == Qt::ControlModifier ) )
874
883
{
875
884
if ( mCapacities .testFlag ( RelativeCoordinates ) )
876
885
{
877
886
mDistanceConstraint ->toggleLocked ();
878
887
emit pointChanged ( mCadPointList .value ( 0 ) );
888
+ e->accept ();
879
889
}
880
890
}
881
- else
891
+ else if ( type == QEvent::KeyPress )
882
892
{
883
893
mDistanceLineEdit ->setFocus ();
884
894
mDistanceLineEdit ->selectAll ();
895
+ e->accept ();
885
896
}
886
897
break ;
887
898
}
888
899
case Qt::Key_C:
889
900
{
890
- setConstructionMode ( !mConstructionMode );
901
+ if ( type == QEvent::KeyPress )
902
+ {
903
+ setConstructionMode ( !mConstructionMode );
904
+ e->accept ();
905
+ }
891
906
break ;
892
907
}
893
908
case Qt::Key_P:
894
909
{
895
- bool parallel = mParallelButton ->isChecked ();
896
- bool perpendicular = mPerpendicularButton ->isChecked ();
897
-
898
- if ( !parallel && !perpendicular )
910
+ if ( type == QEvent::KeyPress )
899
911
{
900
- lockAdditionalConstraint ( Perpendicular );
901
- }
902
- else if ( perpendicular )
903
- {
904
- lockAdditionalConstraint ( Parallel );
905
- }
906
- else
907
- {
908
- lockAdditionalConstraint ( NoConstraint );
912
+ bool parallel = mParallelButton ->isChecked ();
913
+ bool perpendicular = mPerpendicularButton ->isChecked ();
914
+
915
+ if ( !parallel && !perpendicular )
916
+ {
917
+ lockAdditionalConstraint ( Perpendicular );
918
+ }
919
+ else if ( perpendicular )
920
+ {
921
+ lockAdditionalConstraint ( Parallel );
922
+ }
923
+ else
924
+ {
925
+ lockAdditionalConstraint ( NoConstraint );
926
+ }
927
+ e->accept ();
909
928
}
910
929
break ;
911
930
}
@@ -914,7 +933,7 @@ bool QgsAdvancedDigitizingDockWidget::filterKeyPress( QKeyEvent *e )
914
933
return false ; // continues
915
934
}
916
935
}
917
- return true ; // stop the event
936
+ return e-> isAccepted ();
918
937
}
919
938
920
939
void QgsAdvancedDigitizingDockWidget::enable ()
0 commit comments