Skip to content

Commit

Permalink
Use proper QToolButton menu handling
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 26, 2020
1 parent bcbf3f2 commit c12590f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/gui/processing/qgsprocessingoutputdestinationwidget.cpp
Expand Up @@ -37,10 +37,14 @@ QgsProcessingLayerOutputDestinationWidget::QgsProcessingLayerOutputDestinationWi
Q_ASSERT( mParameter );

setupUi( this );
connect( mSelectButton, &QToolButton::clicked, this, &QgsProcessingLayerOutputDestinationWidget::showMenu );

connect( leText, &QLineEdit::textEdited, this, &QgsProcessingLayerOutputDestinationWidget::textChanged );

mMenu = new QMenu( this );
connect( mMenu, &QMenu::aboutToShow, this, &QgsProcessingLayerOutputDestinationWidget::menuAboutToShow );
mSelectButton->setMenu( mMenu );
mSelectButton->setPopupMode( QToolButton::InstantPopup );

QgsSettings settings;
mEncoding = settings.value( QStringLiteral( "/Processing/encoding" ), QStringLiteral( "System" ) ).toString();

Expand Down Expand Up @@ -174,7 +178,7 @@ void QgsProcessingLayerOutputDestinationWidget::setWidgetContext( const QgsProce
mBrowserModel = context.browserModel();
}

void QgsProcessingLayerOutputDestinationWidget::showMenu()
void QgsProcessingLayerOutputDestinationWidget::menuAboutToShow()
{
mMenu->clear();

Expand Down Expand Up @@ -239,7 +243,6 @@ void QgsProcessingLayerOutputDestinationWidget::showMenu()
connect( actionSetEncoding, &QAction::triggered, this, &QgsProcessingLayerOutputDestinationWidget::selectEncoding );
mMenu->addAction( actionSetEncoding );
}
mMenu->exec( QCursor::pos() );
}

void QgsProcessingLayerOutputDestinationWidget::skipOutput()
Expand Down
2 changes: 1 addition & 1 deletion src/gui/processing/qgsprocessingoutputdestinationwidget.h
Expand Up @@ -80,7 +80,7 @@ class GUI_EXPORT QgsProcessingLayerOutputDestinationWidget : public QWidget, pri

private slots:

void showMenu();
void menuAboutToShow();
void skipOutput();
void saveToTemporary();
void selectDirectory();
Expand Down

0 comments on commit c12590f

Please sign in to comment.