Use standardKey instead of hardcoded F1

This commit is contained in:
Yoann Quenach de Quivillic 2025-07-04 11:39:50 +02:00 committed by Nyall Dawson
parent 88417360f3
commit b137461998
5 changed files with 6 additions and 6 deletions

View File

@ -185,7 +185,7 @@ class Editor(QgsCodeEditorPython):
force_search=True,
)
)
context_help_action.setShortcut("F1")
context_help_action.setShortcut(QKeySequence.StandardKey.HelpContents)
menu.addAction(context_help_action)
start_action = QAction(

View File

@ -295,7 +295,7 @@ class ShellOutputScintilla(QgsCodeEditorPython):
context_help_action.triggered.connect(
partial(self.shell_editor.showApiDocumentation, word, force_search=True)
)
context_help_action.setShortcut("F1")
context_help_action.setShortcut(QKeySequence.StandardKey.HelpContents)
menu.addAction(context_help_action)
menu.addSeparator()

View File

@ -547,5 +547,5 @@ class ShellScintilla(QgsCodeEditorPython):
context_help_action.triggered.connect(
partial(self.showApiDocumentation, word, force_search=True)
)
context_help_action.setShortcut("F1")
context_help_action.setShortcut(QKeySequence.StandardKey.HelpContents)
menu.addAction(context_help_action)

View File

@ -204,7 +204,7 @@ void QgsCodeEditor::keyPressEvent( QKeyEvent *event )
return;
}
if ( event->key() == Qt::Key_F1 )
if ( event->matches( QKeySequence::StandardKey::HelpContents ) )
{
// Check if some text is selected
QString text = selectedText();
@ -365,7 +365,7 @@ bool QgsCodeEditor::event( QEvent *event )
{
if ( QKeyEvent *keyEvent = dynamic_cast<QKeyEvent *>( event ) )
{
if ( keyEvent->key() == Qt::Key_F1 )
if ( keyEvent->matches( QKeySequence::StandardKey::HelpContents ) )
{
// If the user pressed F1, we want to prevent the main help dialog to show
// and handle the event in QgsCodeEditor::keyPressEvent

View File

@ -534,7 +534,7 @@ void QgsCodeEditorPython::populateContextMenu( QMenu *menu )
);
pyQgisHelpAction->setEnabled( hasSelectedText() );
pyQgisHelpAction->setShortcut( QStringLiteral( "F1" ) );
pyQgisHelpAction->setShortcut( QKeySequence::StandardKey::HelpContents );
connect( pyQgisHelpAction, &QAction::triggered, this, [text, this] { showApiDocumentation( text ); } );
menu->addSeparator();