mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
Add helpRequested signal
This commit is contained in:
parent
937c33beb6
commit
2067abc02d
@ -57,13 +57,14 @@ QgsCodeEditor.Flags = lambda flags=0: QgsCodeEditor.Flag(flags)
|
||||
QgsCodeEditor.Flags.baseClass = QgsCodeEditor
|
||||
Flags = QgsCodeEditor # dirty hack since SIP seems to introduce the flags in module
|
||||
try:
|
||||
QgsCodeEditor.__attribute_docs__ = {'SEARCH_RESULT_INDICATOR': 'Indicator index for search results', 'sessionHistoryCleared': 'Emitted when the history of commands run in the current session is cleared.\n\n.. versionadded:: 3.30\n', 'persistentHistoryCleared': 'Emitted when the persistent history of commands run in the editor is cleared.\n\n.. versionadded:: 3.30\n'}
|
||||
QgsCodeEditor.__attribute_docs__ = {'SEARCH_RESULT_INDICATOR': 'Indicator index for search results', 'sessionHistoryCleared': 'Emitted when the history of commands run in the current session is cleared.\n\n.. versionadded:: 3.30\n', 'persistentHistoryCleared': 'Emitted when the persistent history of commands run in the editor is cleared.\n\n.. versionadded:: 3.30\n', 'helpRequested': 'Emitted whent the F1 key is pressed while hovering over a word\n\n.. versionadded:: 3.42\n'}
|
||||
QgsCodeEditor.languageToString = staticmethod(QgsCodeEditor.languageToString)
|
||||
QgsCodeEditor.defaultColor = staticmethod(QgsCodeEditor.defaultColor)
|
||||
QgsCodeEditor.color = staticmethod(QgsCodeEditor.color)
|
||||
QgsCodeEditor.setColor = staticmethod(QgsCodeEditor.setColor)
|
||||
QgsCodeEditor.getMonospaceFont = staticmethod(QgsCodeEditor.getMonospaceFont)
|
||||
QgsCodeEditor.isFixedPitch = staticmethod(QgsCodeEditor.isFixedPitch)
|
||||
QgsCodeEditor.__signal_arguments__ = {'helpRequested': ['word: str']}
|
||||
QgsCodeEditor.__group__ = ['codeeditors']
|
||||
except NameError:
|
||||
pass
|
||||
|
||||
@ -519,6 +519,14 @@ Emitted when the persistent history of commands run in the editor is cleared.
|
||||
.. versionadded:: 3.30
|
||||
%End
|
||||
|
||||
|
||||
void helpRequested( QString word );
|
||||
%Docstring
|
||||
Emitted whent the F1 key is pressed while hovering over a word
|
||||
|
||||
.. versionadded:: 3.42
|
||||
%End
|
||||
|
||||
protected:
|
||||
|
||||
static bool isFixedPitch( const QFont &font );
|
||||
|
||||
@ -56,13 +56,14 @@ QgsCodeEditor.Flag.baseClass = QgsCodeEditor
|
||||
QgsCodeEditor.Flags.baseClass = QgsCodeEditor
|
||||
Flags = QgsCodeEditor # dirty hack since SIP seems to introduce the flags in module
|
||||
try:
|
||||
QgsCodeEditor.__attribute_docs__ = {'SEARCH_RESULT_INDICATOR': 'Indicator index for search results', 'sessionHistoryCleared': 'Emitted when the history of commands run in the current session is cleared.\n\n.. versionadded:: 3.30\n', 'persistentHistoryCleared': 'Emitted when the persistent history of commands run in the editor is cleared.\n\n.. versionadded:: 3.30\n'}
|
||||
QgsCodeEditor.__attribute_docs__ = {'SEARCH_RESULT_INDICATOR': 'Indicator index for search results', 'sessionHistoryCleared': 'Emitted when the history of commands run in the current session is cleared.\n\n.. versionadded:: 3.30\n', 'persistentHistoryCleared': 'Emitted when the persistent history of commands run in the editor is cleared.\n\n.. versionadded:: 3.30\n', 'helpRequested': 'Emitted whent the F1 key is pressed while hovering over a word\n\n.. versionadded:: 3.42\n'}
|
||||
QgsCodeEditor.languageToString = staticmethod(QgsCodeEditor.languageToString)
|
||||
QgsCodeEditor.defaultColor = staticmethod(QgsCodeEditor.defaultColor)
|
||||
QgsCodeEditor.color = staticmethod(QgsCodeEditor.color)
|
||||
QgsCodeEditor.setColor = staticmethod(QgsCodeEditor.setColor)
|
||||
QgsCodeEditor.getMonospaceFont = staticmethod(QgsCodeEditor.getMonospaceFont)
|
||||
QgsCodeEditor.isFixedPitch = staticmethod(QgsCodeEditor.isFixedPitch)
|
||||
QgsCodeEditor.__signal_arguments__ = {'helpRequested': ['word: str']}
|
||||
QgsCodeEditor.__group__ = ['codeeditors']
|
||||
except NameError:
|
||||
pass
|
||||
|
||||
@ -519,6 +519,14 @@ Emitted when the persistent history of commands run in the editor is cleared.
|
||||
.. versionadded:: 3.30
|
||||
%End
|
||||
|
||||
|
||||
void helpRequested( QString word );
|
||||
%Docstring
|
||||
Emitted whent the F1 key is pressed while hovering over a word
|
||||
|
||||
.. versionadded:: 3.42
|
||||
%End
|
||||
|
||||
protected:
|
||||
|
||||
static bool isFixedPitch( const QFont &font );
|
||||
|
||||
@ -193,6 +193,26 @@ void QgsCodeEditor::keyPressEvent( QKeyEvent *event )
|
||||
return;
|
||||
}
|
||||
|
||||
if ( event->key() == Qt::Key_F1 )
|
||||
{
|
||||
// Check if mouse is hovering over a word
|
||||
QString word = wordAtPoint( mapFromGlobal( QCursor::pos() ) );
|
||||
|
||||
// Otherwise, check if there is a word at the current text cursor position
|
||||
if ( word.isEmpty() )
|
||||
{
|
||||
int line, index;
|
||||
getCursorPosition( &line, &index );
|
||||
word = wordAtLineIndex( line, index );
|
||||
}
|
||||
if ( !word.isEmpty() )
|
||||
{
|
||||
emit helpRequested( word ) ;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( mMode == QgsCodeEditor::Mode::CommandInput )
|
||||
{
|
||||
switch ( event->key() )
|
||||
|
||||
@ -551,6 +551,14 @@ class GUI_EXPORT QgsCodeEditor : public QsciScintilla
|
||||
*/
|
||||
void persistentHistoryCleared();
|
||||
|
||||
|
||||
/**
|
||||
* Emitted whent the F1 key is pressed while hovering over a word
|
||||
*
|
||||
* \since QGIS 3.42
|
||||
*/
|
||||
void helpRequested( QString word );
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user