Skip to content

Commit 8fb147f

Browse files
committedDec 21, 2017
Use standard buttons for unified add layer dialog
Fixes #17728 by setting the standard buttons in the button box instead of manually adding them by code. This way the buttons should honor the platform-specific position and look&feel.
1 parent 5daf33a commit 8fb147f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
 

‎src/gui/qgsabstractdatasourcewidget.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ const QgsMapCanvas *QgsAbstractDataSourceWidget::mapCanvas() const
3838
void QgsAbstractDataSourceWidget::setupButtons( QDialogButtonBox *buttonBox )
3939
{
4040

41-
mAddButton = new QPushButton( tr( "&Add" ) );
41+
buttonBox->setStandardButtons( QDialogButtonBox::Apply | QDialogButtonBox::Close | QDialogButtonBox::Help );
42+
mAddButton = buttonBox->button( QDialogButtonBox::Apply );
43+
mAddButton->setText( tr( "&Add" ) );
4244
mAddButton->setToolTip( tr( "Add selected layers to map" ) );
4345
mAddButton->setEnabled( false );
44-
buttonBox->addButton( mAddButton, QDialogButtonBox::ApplyRole );
4546
connect( mAddButton, &QPushButton::clicked, this, &QgsAbstractDataSourceWidget::addButtonClicked );
4647
connect( this, &QgsAbstractDataSourceWidget::enableButtons, mAddButton, &QPushButton::setEnabled );
4748

48-
QPushButton *closeButton = new QPushButton( tr( "&Close" ) );
49+
QPushButton *closeButton = buttonBox->button( QDialogButtonBox::Close );
4950
closeButton->setToolTip( tr( "Close this dialog without adding any layer" ) );
50-
buttonBox->addButton( closeButton, QDialogButtonBox::RejectRole );
5151
connect( closeButton, &QPushButton::clicked, this, &QgsAbstractDataSourceWidget::reject );
5252

5353
}

0 commit comments

Comments
 (0)
Please sign in to comment.