Skip to content

Commit 69fc9bb

Browse files
committedOct 15, 2014
use default button action instead of adding a new one (relation reference and editor widgets)
1 parent 4ea5c80 commit 69fc9bb

File tree

3 files changed

+24
-33
lines changed

3 files changed

+24
-33
lines changed
 

‎src/gui/editorwidgets/qgsrelationreferencewidget.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,8 @@ QgsRelationReferenceWidget::QgsRelationReferenceWidget( QWidget* parent )
7878

7979
// open form button
8080
mOpenFormButton = new QToolButton( this );
81-
mOpenFormAction = new QAction( QgsApplication::getThemeIcon( "/mActionPropertyItem.png" ), tr( "Open related feature form" ), this );
82-
mOpenFormButton->addAction( mOpenFormAction );
83-
mOpenFormButton->setDefaultAction( mOpenFormAction );
84-
connect( mOpenFormButton, SIGNAL( triggered( QAction* ) ), this, SLOT( openForm() ) );
81+
mOpenFormButton->setIcon( QgsApplication::getThemeIcon( "/mActionPropertyItem.png" ) );
82+
mOpenFormButton->setText( tr( "Open related feature form" ) );
8583
editLayout->addWidget( mOpenFormButton );
8684

8785
// highlight button
@@ -94,24 +92,19 @@ QgsRelationReferenceWidget::QgsRelationReferenceWidget( QWidget* parent )
9492
mHighlightFeatureButton->addAction( mScaleHighlightFeatureAction );
9593
mHighlightFeatureButton->addAction( mPanHighlightFeatureAction );
9694
mHighlightFeatureButton->setDefaultAction( mHighlightFeatureAction );
97-
connect( mHighlightFeatureButton, SIGNAL( triggered( QAction* ) ), this, SLOT( highlightActionTriggered( QAction* ) ) );
9895
editLayout->addWidget( mHighlightFeatureButton );
9996

10097
// map identification button
10198
mMapIdentificationButton = new QToolButton( this );
102-
mMapIdentificationAction = new QAction( QgsApplication::getThemeIcon( "/mActionMapIdentification.svg" ), tr( "Select on map" ), this );
103-
mMapIdentificationAction->setCheckable( true );
104-
mMapIdentificationButton->addAction( mMapIdentificationAction );
105-
mMapIdentificationButton->setDefaultAction( mMapIdentificationAction );
106-
connect( mMapIdentificationButton, SIGNAL( triggered( QAction* ) ), this, SLOT( mapIdentification() ) );
99+
mMapIdentificationButton->setIcon( QgsApplication::getThemeIcon( "/mActionMapIdentification.svg" ) );
100+
mMapIdentificationButton->setText( tr( "Select on map" ) );
101+
mMapIdentificationButton->setCheckable( true );
107102
editLayout->addWidget( mMapIdentificationButton );
108103

109104
// remove foreign key button
110105
mRemoveFKButton = new QToolButton( this );
111-
mRemoveFKAction = new QAction( QgsApplication::getThemeIcon( "/mActionRemove.svg" ), tr( "No selection" ), this );
112-
mRemoveFKButton->addAction( mRemoveFKAction );
113-
mRemoveFKButton->setDefaultAction( mRemoveFKAction );
114-
connect( mRemoveFKButton, SIGNAL( triggered( QAction* ) ), this, SLOT( deleteForeignKey() ) );
106+
mRemoveFKButton->setIcon( QgsApplication::getThemeIcon( "/mActionRemove.svg" ) );
107+
mRemoveFKButton->setText( tr( "No selection" ) );
115108
editLayout->addWidget( mRemoveFKButton );
116109

117110
// spacer
@@ -142,6 +135,12 @@ QgsRelationReferenceWidget::QgsRelationReferenceWidget( QWidget* parent )
142135
mHighlightFeatureButton->hide();
143136
mAttributeEditorFrame->hide();
144137
mInvalidLabel->hide();
138+
139+
// connect buttons
140+
connect( mOpenFormButton, SIGNAL( clicked() ), this, SLOT( openForm() ) );
141+
connect( mHighlightFeatureButton, SIGNAL( triggered( QAction* ) ), this, SLOT( highlightActionTriggered( QAction* ) ) );
142+
connect( mMapIdentificationButton, SIGNAL( clicked() ), this, SLOT( mapIdentification() ) );
143+
connect( mRemoveFKButton, SIGNAL( clicked() ), this, SLOT( deleteForeignKey() ) );
145144
}
146145

147146
QgsRelationReferenceWidget::~QgsRelationReferenceWidget()
@@ -331,7 +330,7 @@ void QgsRelationReferenceWidget::setEditorContext( QgsAttributeEditorContext con
331330
if ( mMapTool )
332331
delete mMapTool;
333332
mMapTool = new QgsMapToolIdentifyFeature( mCanvas );
334-
mMapTool->setAction( mMapIdentificationAction );
333+
mMapTool->setAction( mMapIdentificationButton->defaultAction() );
335334
}
336335

337336
void QgsRelationReferenceWidget::setEmbedForm( bool display )

‎src/gui/editorwidgets/qgsrelationreferencewidget.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,6 @@ class GUI_EXPORT QgsRelationReferenceWidget : public QWidget
145145
QAction* mHighlightFeatureAction;
146146
QAction* mScaleHighlightFeatureAction;
147147
QAction* mPanHighlightFeatureAction;
148-
QAction* mOpenFormAction;
149-
QAction* mMapIdentificationAction;
150-
QAction* mRemoveFKAction;
151148
QComboBox* mComboBox;
152149
QgsCollapsibleGroupBox* mAttributeEditorFrame;
153150
QVBoxLayout* mAttributeEditorLayout;

‎src/gui/qgsrelationeditorwidget.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,35 +45,30 @@ QgsRelationEditorWidget::QgsRelationEditorWidget( QWidget* parent )
4545
buttonLayout->setContentsMargins( 0, 0, 0, 0 );
4646
// toogle editing
4747
mToggleEditingButton = new QToolButton( this );
48-
QAction* toggleEditingAction = new QAction( QgsApplication::getThemeIcon( "/mActionToggleEditing.svg" ), tr( "Toggle editing" ), this );
49-
mToggleEditingButton->addAction( toggleEditingAction );
50-
mToggleEditingButton->setDefaultAction( toggleEditingAction );
48+
mToggleEditingButton->setIcon( QgsApplication::getThemeIcon( "/mActionToggleEditing.svg" ) );
49+
mToggleEditingButton->setText( tr( "Toggle editing" ) );
5150
mToggleEditingButton->setEnabled( false );
5251
mToggleEditingButton->setCheckable( true );
5352
buttonLayout->addWidget( mToggleEditingButton );
5453
// add feature
5554
mAddFeatureButton = new QToolButton( this );
56-
QAction* addFeatureAction = new QAction( QgsApplication::getThemeIcon( "/mActionAdd.svg" ), tr( "Add feature" ), this );
57-
mAddFeatureButton->addAction( addFeatureAction );
58-
mAddFeatureButton->setDefaultAction( addFeatureAction );
55+
mAddFeatureButton->setIcon( QgsApplication::getThemeIcon( "/mActionAdd.svg" ) );
56+
mAddFeatureButton->setText( tr( "Add feature" ) );
5957
buttonLayout->addWidget( mAddFeatureButton );
6058
// delete feature
6159
mDeleteFeatureButton = new QToolButton( this );
62-
QAction* deleteFeatureAction = new QAction( QgsApplication::getThemeIcon( "/mActionRemove.svg" ), tr( "Delete feature" ), this );
63-
mDeleteFeatureButton->addAction( deleteFeatureAction );
64-
mDeleteFeatureButton->setDefaultAction( deleteFeatureAction );
60+
mDeleteFeatureButton->setIcon( QgsApplication::getThemeIcon( "/mActionRemove.svg" ) );
61+
mDeleteFeatureButton->setText( tr( "Delete feature" ) );
6562
buttonLayout->addWidget( mDeleteFeatureButton );
6663
// link feature
6764
mLinkFeatureButton = new QToolButton( this );
68-
QAction* linkFeatureAction = new QAction( QgsApplication::getThemeIcon( "/mActionLink.svg" ), tr( "Link feature" ), this );
69-
mLinkFeatureButton->addAction( linkFeatureAction );
70-
mLinkFeatureButton->setDefaultAction( linkFeatureAction );
65+
mLinkFeatureButton->setIcon( QgsApplication::getThemeIcon( "/mActionLink.svg" ) );
66+
mLinkFeatureButton->setText( tr( "Link feature" ) );
7167
buttonLayout->addWidget( mLinkFeatureButton );
7268
// unlink feature
7369
mUnlinkFeatureButton = new QToolButton( this );
74-
QAction* unlinkFeatureAction = new QAction( QgsApplication::getThemeIcon( "/mActionUnlink.svg" ), tr( "Unlink feature" ), this );
75-
mUnlinkFeatureButton->addAction( unlinkFeatureAction );
76-
mUnlinkFeatureButton->setDefaultAction( unlinkFeatureAction );
70+
mUnlinkFeatureButton->setIcon( QgsApplication::getThemeIcon( "/mActionUnlink.svg" ) );
71+
mUnlinkFeatureButton->setText( tr( "Unlink feature" ) );
7772
buttonLayout->addWidget( mUnlinkFeatureButton );
7873
// spacer
7974
buttonLayout->addItem( new QSpacerItem( 0, 0, QSizePolicy::Expanding ) );

0 commit comments

Comments
 (0)
Please sign in to comment.