Skip to content

Commit

Permalink
Disable active layer search filter when no vector layer is active/sel…
Browse files Browse the repository at this point in the history
…ected

and inform user via toast message
  • Loading branch information
nirvn committed Nov 14, 2023
1 parent 492fe28 commit b5a1b60
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/core/projectinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ void ProjectInfo::setActiveLayer( QgsMapLayer *layer )
mSettings.beginGroup( QStringLiteral( "/qgis/projectInfo/%1" ).arg( mFilePath ) );
mSettings.setValue( QStringLiteral( "activeLayer" ), layer->id() );
mSettings.endGroup();

emit activeLayerChanged();
}

QgsMapLayer *ProjectInfo::activeLayer() const
Expand Down
14 changes: 9 additions & 5 deletions src/qml/LocatorItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ Item {
anchors.topMargin: 24
model: searchField.displayText !== '' ? locator.proxyModel() : locatorFilters
width: parent.width
height: resultsList.count > 0 ? Math.min( childrenRect.height, mainWindow.height / 2 - searchFieldRect.height - 10 ) : 0
height: resultsList.count > 0 ? Math.min( contentHeight, mainWindow.height / 2 - searchFieldRect.height - 10 ) : 0
clip: true

delegate: searchField.displayText !== '' ? resultsComponent : filtersComponent
Expand All @@ -288,10 +288,10 @@ Item {
id: delegateRect

anchors.margins: 10
height: textArea.childrenRect.height + textArea.topPadding + textArea.bottomPadding
width: resultsList.width
height: textArea.childrenRect.height + textArea.topPadding + textArea.bottomPadding
color: "transparent"
opacity: 0.95
opacity: (Prefix === 'f' && dashBoard.activeLayer == undefined) ? 0.35 : 0.95

Ripple {
clip: true
Expand All @@ -316,7 +316,7 @@ Item {
id: nameCell
anchors.left: parent.left
anchors.right: parent.right
text: Name + ' (' + Prefix + ')'
text: Name + ' (' + Prefix + ')' + (Prefix === 'f' && dashBoard.activeLayer ? '' + dashBoard.activeLayer.name : '')
leftPadding: 5
font.bold: false
font.pointSize: Theme.resultFont.pointSize
Expand Down Expand Up @@ -352,7 +352,11 @@ Item {
anchors.fill: parent

onClicked: {
searchField.text = Prefix + ' ';
if (Prefix === 'f' && dashBoard.activeLayer == undefined) {
displayToast(qsTr('Activate a vector layer in the legend first to use this functionality'), 'warning')
} else {
searchField.text = Prefix + ' '
}
}
}
}
Expand Down

1 comment on commit b5a1b60

@qfield-fairy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.