Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move toggle comment call to QgsCodeEditor
  • Loading branch information
YoannQDQ authored and nyalldawson committed Mar 30, 2023
1 parent 77641b6 commit 738b16e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
11 changes: 10 additions & 1 deletion src/gui/codeeditors/qgscodeeditor.cpp
Expand Up @@ -216,13 +216,22 @@ void QgsCodeEditor::keyPressEvent( QKeyEvent *event )

// Ctrl+Alt+F: reformat code
const bool canReformat = languageCapabilities() & Qgis::ScriptLanguageCapability::Reformat;
if ( canReformat && ctrlModifier && altModifier && event->key() == Qt::Key_F )
if ( !isReadOnly() && canReformat && ctrlModifier && altModifier && event->key() == Qt::Key_F )
{
event->accept();
reformatCode();
return;
}

// Toggle comment when user presses Ctrl+:
const bool canToggle = languageCapabilities() & Qgis::ScriptLanguageCapability::ToggleComment;
if ( !isReadOnly() && canToggle && ctrlModifier && event->key() == Qt::Key_Colon )
{
event->accept();
toggleComment();
return;
}

QsciScintilla::keyPressEvent( event );

}
Expand Down
9 changes: 0 additions & 9 deletions src/gui/codeeditors/qgscodeeditorpython.cpp
Expand Up @@ -221,15 +221,6 @@ void QgsCodeEditorPython::keyPressEvent( QKeyEvent *event )
{
return QgsCodeEditor::keyPressEvent( event );
}
const bool ctrlModifier = event->modifiers() & Qt::ControlModifier;

// Toggle comment when user presses Ctrl+:
if ( ctrlModifier && event->key() == Qt::Key_Colon )
{
event->accept();
toggleComment();
return;
}

const QgsSettings settings;

Expand Down

0 comments on commit 738b16e

Please sign in to comment.