mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-16 00:05:45 -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"),
|
QCoreApplication.translate("PythonConsole", "Run Selected"),
|
||||||
self.runSelectedCode, 'Ctrl+E') # spellok
|
self.runSelectedCode, 'Ctrl+E') # spellok
|
||||||
pyQGISHelpAction = menu.addAction(QgsApplication.getThemeIcon("console/iconHelpConsole.svg"),
|
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)
|
self.searchSelectedTextInPyQGISDocs)
|
||||||
menu.addAction(QgsApplication.getThemeIcon("mActionStart.svg"),
|
menu.addAction(QgsApplication.getThemeIcon("mActionStart.svg"),
|
||||||
QCoreApplication.translate("PythonConsole", "Run Script"),
|
QCoreApplication.translate("PythonConsole", "Run Script"),
|
||||||
|
@ -179,7 +179,7 @@ class ShellOutputScintilla(QgsCodeEditorPython):
|
|||||||
QCoreApplication.translate("PythonConsole", "Clear Console"),
|
QCoreApplication.translate("PythonConsole", "Clear Console"),
|
||||||
self.clearConsole)
|
self.clearConsole)
|
||||||
pyQGISHelpAction = menu.addAction(QgsApplication.getThemeIcon("console/iconHelpConsole.svg"),
|
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)
|
self.searchSelectedTextInPyQGISDocs)
|
||||||
menu.addSeparator()
|
menu.addSeparator()
|
||||||
copyAction = menu.addAction(
|
copyAction = menu.addAction(
|
||||||
|
@ -213,14 +213,6 @@ class ShellScintilla(QgsCodeEditorPython):
|
|||||||
QgsCodeEditorPython.keyPressEvent(self, e)
|
QgsCodeEditorPython.keyPressEvent(self, e)
|
||||||
self.updatePrompt()
|
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):
|
def mousePressEvent(self, e):
|
||||||
"""
|
"""
|
||||||
Re-implemented to handle the mouse press event.
|
Re-implemented to handle the mouse press event.
|
||||||
|
@ -115,6 +115,8 @@ Toggle comment for the selected text.
|
|||||||
virtual void keyPressEvent( QKeyEvent *event );
|
virtual void keyPressEvent( QKeyEvent *event );
|
||||||
virtual QString reformatCodeString( const QString &string );
|
virtual QString reformatCodeString( const QString &string );
|
||||||
|
|
||||||
|
virtual void populateContextMenu( QMenu *menu );
|
||||||
|
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
#include <Qsci/qscilexerpython.h>
|
#include <Qsci/qscilexerpython.h>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
#include <QAction>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
const QMap<QString, QString> QgsCodeEditorPython::sCompletionPairs
|
const QMap<QString, QString> QgsCodeEditorPython::sCompletionPairs
|
||||||
{
|
{
|
||||||
@ -516,6 +518,21 @@ QString QgsCodeEditorPython::reformatCodeString( const QString &string )
|
|||||||
return newText;
|
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()
|
void QgsCodeEditorPython::autoComplete()
|
||||||
{
|
{
|
||||||
switch ( autoCompletionSource() )
|
switch ( autoCompletionSource() )
|
||||||
|
@ -142,6 +142,7 @@ class GUI_EXPORT QgsCodeEditorPython : public QgsCodeEditor
|
|||||||
void initializeLexer() override;
|
void initializeLexer() override;
|
||||||
virtual void keyPressEvent( QKeyEvent *event ) override;
|
virtual void keyPressEvent( QKeyEvent *event ) override;
|
||||||
QString reformatCodeString( const QString &string ) override;
|
QString reformatCodeString( const QString &string ) override;
|
||||||
|
void populateContextMenu( QMenu *menu ) override;
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user