Skip to content

Commit

Permalink
Fix inconsistent field name line edit focus behaviour when creating n…
Browse files Browse the repository at this point in the history
…ew vector layers (qgis#58538)

* Fix inconsistent behaviour in create new layer dialogues by returning focus to
the field name line edits in the mAddAttributeButton_clicked slot methods of the
new layer dialogues.

Fixes qgis#58482

* Remove Qt::MouseFocusReason argument from setFocus() calls so that the default
Qt::OtherFocusReason is used.
  • Loading branch information
benwirf authored and velle committed Sep 17, 2024
1 parent 2029cfa commit b0581a6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/app/qgsnewspatialitelayerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ void QgsNewSpatialiteLayerDialog::mAddAttributeButton_clicked()
checkOk();

mNameEdit->clear();

if ( !mNameEdit->hasFocus() )
{
mNameEdit->setFocus();
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/gui/qgsnewgeopackagelayerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ void QgsNewGeoPackageLayerDialog::mAddAttributeButton_clicked()
checkOk();

mFieldNameEdit->clear();

if ( !mFieldNameEdit->hasFocus() )
{
mFieldNameEdit->setFocus();
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/gui/qgsnewmemorylayerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,11 @@ void QgsNewMemoryLayerDialog::mAddAttributeButton_clicked()
mAttributeView->addTopLevelItem( new QTreeWidgetItem( QStringList() << fieldName << fieldType << width << precision ) );

mFieldNameEdit->clear();

if ( !mFieldNameEdit->hasFocus() )
{
mFieldNameEdit->setFocus();
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/gui/qgsnewvectorlayerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,15 @@ void QgsNewVectorLayerDialog::mAddAttributeButton_clicked()
//use userrole to avoid translated type string
const QString myType = mTypeBox->currentData( Qt::UserRole ).toString();
mAttributeView->addTopLevelItem( new QTreeWidgetItem( QStringList() << myName << myType << myWidth << myPrecision ) );

checkOk();

mNameEdit->clear();

if ( !mNameEdit->hasFocus() )
{
mNameEdit->setFocus();
}
}

void QgsNewVectorLayerDialog::mRemoveAttributeButton_clicked()
Expand Down

0 comments on commit b0581a6

Please sign in to comment.