Skip to content

Commit

Permalink
feat(QgsLocatorWidget): define anchors for result container
Browse files Browse the repository at this point in the history
  • Loading branch information
jmkerloch authored and nyalldawson committed Feb 7, 2024
1 parent 4445ef0 commit 8e9267f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ as prioritizing results which are near the current canvas extent.
%Docstring
Set placeholder ``text`` for the line edit.

.. versionadded:: 3.36
%End

void setResultContainerAnchors( QgsFloatingWidget::AnchorPoint anchorPoint, QgsFloatingWidget::AnchorPoint anchorWidgetPoint );
%Docstring
Sets the result container ``anchorPoint`` and ``anchorWidgetPoint`` position.

.. versionadded:: 3.36
%End

Expand Down
7 changes: 7 additions & 0 deletions python/gui/auto_generated/locator/qgslocatorwidget.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ as prioritizing results which are near the current canvas extent.
%Docstring
Set placeholder ``text`` for the line edit.

.. versionadded:: 3.36
%End

void setResultContainerAnchors( QgsFloatingWidget::AnchorPoint anchorPoint, QgsFloatingWidget::AnchorPoint anchorWidgetPoint );
%Docstring
Sets the result container ``anchorPoint`` and ``anchorWidgetPoint`` position.

.. versionadded:: 3.36
%End

Expand Down
6 changes: 6 additions & 0 deletions src/gui/locator/qgslocatorwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ void QgsLocatorWidget::setPlaceholderText( const QString &text )
mLineEdit->setPlaceholderText( text );
}

void QgsLocatorWidget::setResultContainerAnchors( QgsFloatingWidget::AnchorPoint anchorPoint, QgsFloatingWidget::AnchorPoint anchorWidgetPoint )
{
mResultsContainer->setAnchorPoint( anchorPoint );
mResultsContainer->setAnchorWidgetPoint( anchorWidgetPoint );
}

void QgsLocatorWidget::search( const QString &string )
{
window()->activateWindow(); // window must also be active - otherwise floating docks can steal keystrokes
Expand Down
7 changes: 7 additions & 0 deletions src/gui/locator/qgslocatorwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ class GUI_EXPORT QgsLocatorWidget : public QWidget
*/
void setPlaceholderText( const QString &text );

/**
* Sets the result container \a anchorPoint and \a anchorWidgetPoint position.
*
* \since QGIS 3.36
*/
void setResultContainerAnchors( QgsFloatingWidget::AnchorPoint anchorPoint, QgsFloatingWidget::AnchorPoint anchorWidgetPoint );

public slots:

/**
Expand Down

0 comments on commit 8e9267f

Please sign in to comment.