mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-06 00:07:29 -04:00
Expose 'Search Selection in PyQGIS docs' action for all python code editors
This commit is contained in:
parent
ca6df18671
commit
895a68faee
@ -112,7 +112,7 @@ class Editor(QgsCodeEditorPython):
|
||||
QCoreApplication.translate("PythonConsole", "Run Selected"),
|
||||
self.runSelectedCode, 'Ctrl+E') # spellok
|
||||
pyQGISHelpAction = menu.addAction(QgsApplication.getThemeIcon("console/iconHelpConsole.svg"),
|
||||
QCoreApplication.translate("PythonConsole", "Search Selected in PyQGIS docs"),
|
||||
QCoreApplication.translate("PythonConsole", "Search Selection in PyQGIS Documentation"),
|
||||
self.searchSelectedTextInPyQGISDocs)
|
||||
menu.addAction(QgsApplication.getThemeIcon("mActionStart.svg"),
|
||||
QCoreApplication.translate("PythonConsole", "Run Script"),
|
||||
|
@ -179,7 +179,7 @@ class ShellOutputScintilla(QgsCodeEditorPython):
|
||||
QCoreApplication.translate("PythonConsole", "Clear Console"),
|
||||
self.clearConsole)
|
||||
pyQGISHelpAction = menu.addAction(QgsApplication.getThemeIcon("console/iconHelpConsole.svg"),
|
||||
QCoreApplication.translate("PythonConsole", "Search Selected in PyQGIS docs"),
|
||||
QCoreApplication.translate("PythonConsole", "Search Selection in PyQGIS Documentation"),
|
||||
self.searchSelectedTextInPyQGISDocs)
|
||||
menu.addSeparator()
|
||||
copyAction = menu.addAction(
|
||||
|
@ -213,14 +213,6 @@ class ShellScintilla(QgsCodeEditorPython):
|
||||
QgsCodeEditorPython.keyPressEvent(self, e)
|
||||
self.updatePrompt()
|
||||
|
||||
def populateContextMenu(self, menu):
|
||||
pyQGISHelpAction = menu.addAction(
|
||||
QgsApplication.getThemeIcon("console/iconHelpConsole.svg"),
|
||||
QCoreApplication.translate("PythonConsole", "Search Selected in PyQGIS docs"),
|
||||
self.searchSelectedTextInPyQGISDocs
|
||||
)
|
||||
pyQGISHelpAction.setEnabled(self.hasSelectedText())
|
||||
|
||||
def mousePressEvent(self, e):
|
||||
"""
|
||||
Re-implemented to handle the mouse press event.
|
||||
|
@ -115,6 +115,8 @@ Toggle comment for the selected text.
|
||||
virtual void keyPressEvent( QKeyEvent *event );
|
||||
virtual QString reformatCodeString( const QString &string );
|
||||
|
||||
virtual void populateContextMenu( QMenu *menu );
|
||||
|
||||
|
||||
protected slots:
|
||||
|
||||
|
@ -32,6 +32,8 @@
|
||||
#include <Qsci/qscilexerpython.h>
|
||||
#include <QDesktopServices>
|
||||
#include <QKeyEvent>
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
|
||||
const QMap<QString, QString> QgsCodeEditorPython::sCompletionPairs
|
||||
{
|
||||
@ -516,6 +518,21 @@ QString QgsCodeEditorPython::reformatCodeString( const QString &string )
|
||||
return newText;
|
||||
}
|
||||
|
||||
void QgsCodeEditorPython::populateContextMenu( QMenu *menu )
|
||||
{
|
||||
QgsCodeEditor::populateContextMenu( menu );
|
||||
|
||||
QAction *pyQgisHelpAction = new QAction(
|
||||
QgsApplication::getThemeIcon( QStringLiteral( "console/iconHelpConsole.svg" ) ),
|
||||
tr( "Search Selection in PyQGIS Documentation" ),
|
||||
menu );
|
||||
pyQgisHelpAction->setEnabled( hasSelectedText() );
|
||||
connect( pyQgisHelpAction, &QAction::triggered, this, &QgsCodeEditorPython::searchSelectedTextInPyQGISDocs );
|
||||
|
||||
menu->addSeparator();
|
||||
menu->addAction( pyQgisHelpAction );
|
||||
}
|
||||
|
||||
void QgsCodeEditorPython::autoComplete()
|
||||
{
|
||||
switch ( autoCompletionSource() )
|
||||
|
@ -142,6 +142,7 @@ class GUI_EXPORT QgsCodeEditorPython : public QgsCodeEditor
|
||||
void initializeLexer() override;
|
||||
virtual void keyPressEvent( QKeyEvent *event ) override;
|
||||
QString reformatCodeString( const QString &string ) override;
|
||||
void populateContextMenu( QMenu *menu ) override;
|
||||
|
||||
protected slots:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user