diff --git a/python/console/console_sci.py b/python/console/console_sci.py
index 5f1087ce604a..1c6068112c8c 100644
--- a/python/console/console_sci.py
+++ b/python/console/console_sci.py
@@ -478,9 +478,8 @@ def showApiDocumentation(self, text, force_search=False):
pythonSettingsTreeNode = QgsSettingsTree.node("gui").childNode("code-editor").childNode("python")
embedded = pythonSettingsTreeNode.childSetting('context-help-embedded').value()
- api = "pyqgis" if pythonSettingsTreeNode.childSetting('context-help-pyqgis').value() else "qgis"
- self._interpreter.execCommandImpl(f'_help({repr(text)}, api="{api}", embedded={embedded}, force_search={force_search})', show_input=False)
+ self._interpreter.execCommandImpl(f'_help({repr(text)}, api="pyqgis", embedded={embedded}, force_search={force_search})', show_input=False)
def showApi(self, api):
pythonSettingsTreeNode = QgsSettingsTree.node("gui").childNode("code-editor").childNode("python")
diff --git a/python/console/console_settings.py b/python/console/console_settings.py
index 93af15b063a6..39ecc7e14b74 100644
--- a/python/console/console_settings.py
+++ b/python/console/console_settings.py
@@ -211,7 +211,8 @@ def saveSettings(self):
settings.setValue("pythonConsole/formatOnSave", self.formatOnSave.isChecked())
- pythonSettingsTreeNode = QgsSettingsTree.node("gui").childNode("code-editor").childNode("python")
+ codeEditorTreeNode = QgsSettingsTree.node("gui").childNode("code-editor")
+ pythonSettingsTreeNode = codeEditorTreeNode.childNode("python")
pythonSettingsTreeNode.childSetting("sort-imports").setValue(self.sortImports.isChecked())
pythonSettingsTreeNode.childSetting("formatter").setValue(self.formatter.currentText())
pythonSettingsTreeNode.childSetting("autopep8-level").setValue(self.autopep8Level.value())
@@ -219,7 +220,7 @@ def saveSettings(self):
pythonSettingsTreeNode.childSetting("max-line-length").setValue(self.maxLineLength.value())
pythonSettingsTreeNode.childSetting('external-editor').setValue(self.externalEditor.text())
pythonSettingsTreeNode.childSetting('context-help-embedded').setValue(self.contextHelpBrowser.currentIndex() == 0)
- pythonSettingsTreeNode.childSetting('context-help-pyqgis').setValue(self.contextHelpApi.currentIndex() == 0)
+ codeEditorTreeNode.childSetting('context-help-hover').setValue(self.contextHelpHover.isChecked())
def restoreSettings(self):
settings = QgsSettings()
@@ -245,7 +246,8 @@ def restoreSettings(self):
self.autoSurround.setChecked(settings.value("pythonConsole/autoSurround", True, type=bool))
self.autoInsertImport.setChecked(settings.value("pythonConsole/autoInsertImport", False, type=bool))
- pythonSettingsTreeNode = QgsSettingsTree.node("gui").childNode("code-editor").childNode("python")
+ codeEditorTreeNode = QgsSettingsTree.node("gui").childNode("code-editor")
+ pythonSettingsTreeNode = codeEditorTreeNode.childNode("python")
self.formatOnSave.setChecked(settings.value("pythonConsole/formatOnSave", False, type=bool))
self.sortImports.setChecked(pythonSettingsTreeNode.childSetting("sort-imports").value())
@@ -254,7 +256,7 @@ def restoreSettings(self):
self.blackNormalizeQuotes.setChecked(pythonSettingsTreeNode.childSetting("black-normalize-quotes").value())
self.maxLineLength.setValue(pythonSettingsTreeNode.childSetting("max-line-length").value())
self.contextHelpBrowser.setCurrentIndex(0 if pythonSettingsTreeNode.childSetting('context-help-embedded').value() else 1)
- self.contextHelpApi.setCurrentIndex(0 if pythonSettingsTreeNode.childSetting('context-help-pyqgis').value() else 1)
+ self.contextHelpHover.setChecked(codeEditorTreeNode.childSetting('context-help-hover').value())
if settings.value("pythonConsole/autoCompleteSource") == 'fromDoc':
self.autoCompFromDoc.setChecked(True)
diff --git a/python/console/console_settings.ui b/python/console/console_settings.ui
index 501f7de33810..c8e1c3c81e23 100644
--- a/python/console/console_settings.ui
+++ b/python/console/console_settings.ui
@@ -55,7 +55,7 @@
0
0
739
- 1242
+ 1240
@@ -619,27 +619,13 @@
- -
-
+
-
+
- API
+ F1 works on hovered words
- -
-
-
-
-
- PyQGIS
-
-
- -
-
- C++ QGIS
-
-
-
-
@@ -677,7 +663,6 @@
autoSurround
autoInsertImport
contextHelpBrowser
- contextHelpApi
formatOnSave
sortImports
maxLineLength
diff --git a/src/app/devtools/documentation/qgsdocumentationpanelwidget.cpp b/src/app/devtools/documentation/qgsdocumentationpanelwidget.cpp
index 81cefc3c92e3..0fe86ddb81a2 100644
--- a/src/app/devtools/documentation/qgsdocumentationpanelwidget.cpp
+++ b/src/app/devtools/documentation/qgsdocumentationpanelwidget.cpp
@@ -27,8 +27,7 @@ QgsDocumentationPanelWidget::QgsDocumentationPanelWidget( QWidget *parent )
{
setupUi( this );
- connect( mPythonHomeButton, &QToolButton::clicked, this, [] {QgisApp::instance()->showApiDocumentation( QStringLiteral( "pyqgis" ), true );} );
- connect( mCppHomeButton, &QToolButton::clicked, this, [] {QgisApp::instance()->showApiDocumentation( QStringLiteral( "qgis" ), true );} );
+ connect( mPyQgisHomeButton, &QToolButton::clicked, this, [] {QgisApp::instance()->showApiDocumentation( QStringLiteral( "pyqgis" ), true );} );
connect( mQtHomeButton, &QToolButton::clicked, this, [] {QgisApp::instance()->showApiDocumentation( QStringLiteral( "qt" ), true );} );
connect( mOpenUrlButton, &QToolButton::clicked, this, [this] {QgisApp::instance()->openURL( mWebView->url().toString(), false );} );
diff --git a/src/gui/codeeditors/qgscodeeditor.cpp b/src/gui/codeeditors/qgscodeeditor.cpp
index b7937a6de70d..b4407949d46a 100644
--- a/src/gui/codeeditors/qgscodeeditor.cpp
+++ b/src/gui/codeeditors/qgscodeeditor.cpp
@@ -23,6 +23,7 @@
#include "qgscodeeditorhistorydialog.h"
#include "qgsstringutils.h"
#include "qgsfontutils.h"
+#include "qgssettingsentryimpl.h"
#include
#include
@@ -37,6 +38,12 @@
#include
#include "Qsci/qscilexer.h"
+///@cond PRIVATE
+const QgsSettingsEntryBool *QgsCodeEditor::settingContextHelpHover = new QgsSettingsEntryBool( QStringLiteral( "context-help-hover" ), sTreeCodeEditor, false, QStringLiteral( "Whether the context help should works on hovered words" ) );
+///@endcond PRIVATE
+
+
+
QMap< QgsCodeEditorColorScheme::ColorRole, QString > QgsCodeEditor::sColorRoleToSettingsKey
{
{QgsCodeEditorColorScheme::ColorRole::Default, QStringLiteral( "defaultFontColor" ) },
@@ -199,7 +206,7 @@ void QgsCodeEditor::keyPressEvent( QKeyEvent *event )
QString text = selectedText();
// Check if mouse is hovering over a word
- if ( text.isEmpty() )
+ if ( text.isEmpty() && settingContextHelpHover->value() )
{
text = wordAtPoint( mapFromGlobal( QCursor::pos() ) );
}
diff --git a/src/gui/codeeditors/qgscodeeditor.h b/src/gui/codeeditors/qgscodeeditor.h
index dc8bf185583f..7337ba5705e3 100644
--- a/src/gui/codeeditors/qgscodeeditor.h
+++ b/src/gui/codeeditors/qgscodeeditor.h
@@ -33,6 +33,7 @@
class QgsFilterLineEdit;
class QToolButton;
class QCheckBox;
+class QgsSettingsEntryBool;
SIP_IF_MODULE( HAVE_QSCI_SIP )
@@ -107,6 +108,7 @@ class GUI_EXPORT QgsCodeEditor : public QsciScintilla
#ifndef SIP_RUN
static inline QgsSettingsTreeNode *sTreeCodeEditor = QgsSettingsTree::sTreeGui->createChildNode( QStringLiteral( "code-editor" ) );
+ static const QgsSettingsEntryBool *settingContextHelpHover;
#endif
/**
diff --git a/src/gui/codeeditors/qgscodeeditorpython.cpp b/src/gui/codeeditors/qgscodeeditorpython.cpp
index 96375f039006..bb7789f4787d 100644
--- a/src/gui/codeeditors/qgscodeeditorpython.cpp
+++ b/src/gui/codeeditors/qgscodeeditorpython.cpp
@@ -52,7 +52,6 @@ const QgsSettingsEntryInteger *QgsCodeEditorPython::settingAutopep8Level = new Q
const QgsSettingsEntryBool *QgsCodeEditorPython::settingBlackNormalizeQuotes = new QgsSettingsEntryBool( QStringLiteral( "black-normalize-quotes" ), sTreePythonCodeEditor, true, QStringLiteral( "Whether quotes should be normalized when auto-formatting code using black" ) );
const QgsSettingsEntryString *QgsCodeEditorPython::settingExternalPythonEditorCommand = new QgsSettingsEntryString( QStringLiteral( "external-editor" ), sTreePythonCodeEditor, QString(), QStringLiteral( "Command to launch an external Python code editor. Use the token to insert the filename, to insert line number, and to insert the column number." ) );
const QgsSettingsEntryBool *QgsCodeEditorPython::settingContextHelpEmbedded = new QgsSettingsEntryBool( QStringLiteral( "context-help-embedded" ), sTreePythonCodeEditor, true, QStringLiteral( "Whether the context help should be displayed in an embedded webview in the devtools panel" ) );
-const QgsSettingsEntryBool *QgsCodeEditorPython::settingContextHelpPyQgis = new QgsSettingsEntryBool( QStringLiteral( "context-help-pyqgis" ), sTreePythonCodeEditor, true, QStringLiteral( "Whether the context help should use the PyQGIS api instead of the C++ API" ) );
///@endcond PRIVATE
@@ -729,34 +728,17 @@ void QgsCodeEditorPython::showApiDocumentation( const QString &text )
{
QString searchText = text;
searchText = searchText.replace( QLatin1String( ">>> " ), QString() ).replace( QLatin1String( "... " ), QString() ).trimmed(); // removing prompts
- QRegularExpression qgisExpression( "^Qgs[A-Z][a-zA-Z]" );
QRegularExpression qtExpression( "^Q[A-Z][a-zA-Z]" );
- bool pyQgis = QgsCodeEditorPython::settingContextHelpPyQgis->value();
-
- const QString qgisVersion = QString( Qgis::version() ).split( '.' ).mid( 0, 2 ).join( '.' );
- const QString qtVersion = QString( qVersion() ).split( '.' ).mid( 0, 2 ).join( '.' );
-
- QgsSettings settings;
-
- if ( qgisExpression.match( searchText ).hasMatch() )
- {
- if ( !pyQgis )
- {
-
- QString baseUrl = settings.value( QStringLiteral( "qgis/QgisApiUrl" ),
- QString( "https://qgis.org/api/%1" ).arg( qgisVersion ) ).toString();
- QDesktopServices::openUrl( QUrl( QString( "%1/class%2.html" ).arg( baseUrl, searchText ) ) );
- return;
- }
- }
- else if ( qtExpression.match( searchText ).hasMatch() )
+ if ( qtExpression.match( searchText ).hasMatch() )
{
+ const QString qtVersion = QString( qVersion() ).split( '.' ).mid( 0, 2 ).join( '.' );
QString baseUrl = QString( "https://doc.qt.io/qt-%1" ).arg( qtVersion );
QDesktopServices::openUrl( QUrl( QStringLiteral( "%1/%2.html" ).arg( baseUrl, searchText.toLower() ) ) );
return;
}
+ const QString qgisVersion = QString( Qgis::version() ).split( '.' ).mid( 0, 2 ).join( '.' );
QDesktopServices::openUrl( QUrl( QStringLiteral( "https://qgis.org/pyqgis/%1/search.html?q=%2" ).arg( qgisVersion, searchText ) ) );
}
diff --git a/src/gui/codeeditors/qgscodeeditorpython.h b/src/gui/codeeditors/qgscodeeditorpython.h
index 50d3a2e4c369..fc125410c6c2 100644
--- a/src/gui/codeeditors/qgscodeeditorpython.h
+++ b/src/gui/codeeditors/qgscodeeditorpython.h
@@ -63,7 +63,6 @@ class GUI_EXPORT QgsCodeEditorPython : public QgsCodeEditor
static const QgsSettingsEntryBool *settingBlackNormalizeQuotes;
static const QgsSettingsEntryString *settingExternalPythonEditorCommand;
static const QgsSettingsEntryBool *settingContextHelpEmbedded;
- static const QgsSettingsEntryBool *settingContextHelpPyQgis;
///@endcond PRIVATE
#endif
diff --git a/src/ui/qgsdocumentationpanelbase.ui b/src/ui/qgsdocumentationpanelbase.ui
index a32d940998a9..288d4dee34d1 100644
--- a/src/ui/qgsdocumentationpanelbase.ui
+++ b/src/ui/qgsdocumentationpanelbase.ui
@@ -21,27 +21,10 @@
-
-
-
+
PyQGIS API Documentation
-
-
- :/images/themes/default/mIconPythonFile.svg:/images/themes/default/mIconPythonFile.svg
-
-
-
- 24
- 24
-
-
-
-
- -
-
-
- C++ API documentation
-
:/images/icons/qgis_icon.svg:/images/icons/qgis_icon.svg