eric7/UI/CodeDocumentationViewer.py

Sun, 19 Sep 2021 16:26:29 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 19 Sep 2021 16:26:29 +0200
branch
eric7
changeset 8617
3ea0b67205b6
parent 8553
10d31e5ce9e5
child 8631
b2c4c2f3fda7
permissions
-rw-r--r--

Implemented four workarounds to suppress use of QtWebEngine on non-Linux systems because of issues in Qt 6.2.0 rc0.

5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7717
diff changeset
3 # Copyright (c) 2017 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a widget to show some source code information provided by
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 plug-ins.
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9 """
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
11 from PyQt6.QtCore import pyqtSlot, pyqtSignal, Qt, QUrl, QTimer
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
12 from PyQt6.QtGui import QCursor
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
13 from PyQt6.QtWidgets import (
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7236
diff changeset
14 QWidget, QVBoxLayout, QHBoxLayout, QLabel, QComboBox, QSizePolicy,
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7236
diff changeset
15 QLineEdit, QTextBrowser, QToolTip
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7236
diff changeset
16 )
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
8366
2a9f5153c438 Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8358
diff changeset
18 from EricWidgets.EricTextEditSearchWidget import (
2a9f5153c438 Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8358
diff changeset
19 EricTextEditSearchWidget, EricTextEditType
2a9f5153c438 Corrected some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8358
diff changeset
20 )
8358
144a6b854f70 Sorted the eric specific extensions into packages named like the corresponding PyQt packages (i.e. EricCore,EricGui and EricWidgets).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8356
diff changeset
21 from EricWidgets.EricApplication import ericApp
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 import Preferences
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7236
diff changeset
25 from .CodeDocumentationViewerTemplate import (
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7236
diff changeset
26 prepareDocumentationViewerHtmlDocument,
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7236
diff changeset
27 prepareDocumentationViewerHtmlDocWarningDocument,
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5913
diff changeset
28 prepareDocumentationViewerHtmlWarningDocument
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7236
diff changeset
29 )
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5913
diff changeset
30
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
6506
ff6172ce89a9 CodeDocumentationViewer: simplified the front end handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6505
diff changeset
32 class DocumentationViewerWidget(QWidget):
5912
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
33 """
6506
ff6172ce89a9 CodeDocumentationViewer: simplified the front end handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6505
diff changeset
34 Class implementing a rich text documentation viewer.
5912
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
35 """
7526
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
36 EmpytDocument_Light = (
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
37 '''<!DOCTYPE html>\n'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
38 '''<html lang="EN">\n'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
39 '''<head>\n'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
40 '''<style type="text/css">\n'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
41 '''html {background-color: #ffffff;}\n'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
42 '''body {background-color: #ffffff;\n'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
43 ''' color: #000000;\n'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
44 ''' margin: 0px 10px 10px 10px;\n'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
45 '''}\n'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
46 '''</style'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
47 '''</head>\n'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
48 '''<body>\n'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
49 '''</body>\n'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
50 '''</html>'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
51 )
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
52 EmpytDocument_Dark = (
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
53 '''<!DOCTYPE html>\n'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
54 '''<html lang="EN">\n'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
55 '''<head>\n'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
56 '''<style type="text/css">\n'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
57 '''html {background-color: #262626;}\n'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
58 '''body {background-color: #262626;\n'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
59 ''' color: #ffffff;\n'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
60 ''' margin: 0px 10px 10px 10px;\n'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
61 '''}\n'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
62 '''</style'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
63 '''</head>\n'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
64 '''<body>\n'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
65 '''</body>\n'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
66 '''</html>'''
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
67 )
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
68
5912
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
69 def __init__(self, parent=None):
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
70 """
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
71 Constructor
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
72
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
73 @param parent reference to the parent widget
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
74 @type QWidget
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
75 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
76 super().__init__(parent)
6506
ff6172ce89a9 CodeDocumentationViewer: simplified the front end handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6505
diff changeset
77 self.setObjectName("DocumentationViewerWidget")
5913
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
78
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
79 self.__verticalLayout = QVBoxLayout(self)
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
80 self.__verticalLayout.setObjectName("verticalLayout")
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
81 self.__verticalLayout.setContentsMargins(0, 0, 0, 0)
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
82
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
83 try:
8617
3ea0b67205b6 Implemented four workarounds to suppress use of QtWebEngine on non-Linux systems because of issues in Qt 6.2.0 rc0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
84 # TODO: remove this workaround once rc0 issue is fixed
3ea0b67205b6 Implemented four workarounds to suppress use of QtWebEngine on non-Linux systems because of issues in Qt 6.2.0 rc0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
85 # Workaround for a bug in Qt 6.2.0 rc0 on non-Linux
3ea0b67205b6 Implemented four workarounds to suppress use of QtWebEngine on non-Linux systems because of issues in Qt 6.2.0 rc0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
86 import sys
3ea0b67205b6 Implemented four workarounds to suppress use of QtWebEngine on non-Linux systems because of issues in Qt 6.2.0 rc0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
87 if not sys.platform.startswith("linux"):
3ea0b67205b6 Implemented four workarounds to suppress use of QtWebEngine on non-Linux systems because of issues in Qt 6.2.0 rc0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
88 raise ImportError
3ea0b67205b6 Implemented four workarounds to suppress use of QtWebEngine on non-Linux systems because of issues in Qt 6.2.0 rc0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8553
diff changeset
89
8553
10d31e5ce9e5 First batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8469
diff changeset
90 from PyQt6.QtWebEngineCore import QWebEngineSettings
10d31e5ce9e5 First batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8469
diff changeset
91 from PyQt6.QtWebEngineWidgets import QWebEngineView
5913
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
92 self.__contents = QWebEngineView(self)
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
93 self.__contents.page().linkHovered.connect(self.__showLink)
8243
cc717c2ae956 Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8227
diff changeset
94 self.__contents.settings().setAttribute(
cc717c2ae956 Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8227
diff changeset
95 QWebEngineSettings.WebAttribute.FocusOnNavigationEnabled,
cc717c2ae956 Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8227
diff changeset
96 False)
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
97 self.__viewerType = EricTextEditType.QWEBENGINEVIEW
5913
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
98 except ImportError:
7196
ab0a91b82b37 Removed support for QtWebKit and the old web rowser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7192
diff changeset
99 self.__contents = QTextBrowser(self)
ab0a91b82b37 Removed support for QtWebKit and the old web rowser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7192
diff changeset
100 self.__contents.setOpenExternalLinks(True)
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
101 self.__viewerType = EricTextEditType.QTEXTBROWSER
5913
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
102
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
103 sizePolicy = QSizePolicy(QSizePolicy.Policy.Preferred,
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
104 QSizePolicy.Policy.Expanding)
5913
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
105 sizePolicy.setHorizontalStretch(0)
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
106 sizePolicy.setVerticalStretch(0)
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
107 sizePolicy.setHeightForWidth(
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
108 self.__contents.sizePolicy().hasHeightForWidth())
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
109 self.__contents.setSizePolicy(sizePolicy)
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
110 self.__contents.setContextMenuPolicy(
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
111 Qt.ContextMenuPolicy.NoContextMenu)
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
112 if self.__viewerType != EricTextEditType.QTEXTBROWSER:
6506
ff6172ce89a9 CodeDocumentationViewer: simplified the front end handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6505
diff changeset
113 self.__contents.setUrl(QUrl("about:blank"))
5913
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
114 self.__verticalLayout.addWidget(self.__contents)
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
115
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
116 self.__searchWidget = EricTextEditSearchWidget(self, False)
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
117 self.__searchWidget.setFocusPolicy(Qt.FocusPolicy.WheelFocus)
5913
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
118 self.__searchWidget.setObjectName("searchWidget")
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
119 self.__verticalLayout.addWidget(self.__searchWidget)
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
120
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
121 self.__searchWidget.attachTextEdit(
8268
6b8128e0c9d1 Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8243
diff changeset
122 self.__contents, editType=self.__viewerType)
5913
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
123
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
124 @pyqtSlot(str)
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
125 def __showLink(self, urlStr):
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
126 """
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
127 Private slot to show the hovered link in a tooltip.
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
128
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
129 @param urlStr hovered URL
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
130 @type str
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
131 """
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
132 QToolTip.showText(QCursor.pos(), urlStr, self.__contents)
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
133
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
134 def setHtml(self, html):
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
135 """
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
136 Public method to set the HTML text of the widget.
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
137
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
138 @param html HTML text to be shown
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
139 @type str
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
140 """
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5913
diff changeset
141 self.__contents.setEnabled(False)
5913
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
142 self.__contents.setHtml(html)
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5913
diff changeset
143 self.__contents.setEnabled(True)
5913
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
144
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
145 def clear(self):
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
146 """
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
147 Public method to clear the shown contents.
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
148 """
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
149 if self.__viewerType == EricTextEditType.QTEXTBROWSER:
6506
ff6172ce89a9 CodeDocumentationViewer: simplified the front end handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6505
diff changeset
150 self.__contents.clear()
ff6172ce89a9 CodeDocumentationViewer: simplified the front end handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6505
diff changeset
151 else:
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
152 if ericApp().usesDarkPalette():
7526
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
153 self.__contents.setHtml(self.EmpytDocument_Dark)
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
154 else:
92ef4bd9d2c5 CodeDocumentationViewer: improved the clean() method to respect current color scheme type.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
155 self.__contents.setHtml(self.EmpytDocument_Light)
5913
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
156
5912
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
157
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
158 class CodeDocumentationViewer(QWidget):
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 """
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 Class implementing a widget to show some source code information provided
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 by plug-ins.
5913
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
162
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
163 @signal providerAdded() emitted to indicate the availability of a new
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
164 provider
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
165 @signal providerRemoved() emitted to indicate the removal of a provider
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 """
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 providerAdded = pyqtSignal()
5913
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
168 providerRemoved = pyqtSignal()
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 def __init__(self, parent=None):
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 """
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 Constructor
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 @param parent reference to the parent widget
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 @type QWidget
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
177 super().__init__(parent)
5912
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
178 self.__setupUi()
5905
f31960634997 Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5900
diff changeset
179
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 self.__ui = parent
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 self.__providers = {}
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 self.__selectedProvider = ""
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 self.__disabledProvider = "disabled"
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 self.__shuttingDown = False
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 self.__startingUp = True
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188
5905
f31960634997 Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5900
diff changeset
189 self.__lastDocumentation = None
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5913
diff changeset
190 self.__requestingEditor = None
6266
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
191
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
192 self.__unregisterTimer = QTimer(self)
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
193 self.__unregisterTimer.setInterval(30000) # 30 seconds
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
194 self.__unregisterTimer.setSingleShot(True)
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
195 self.__unregisterTimer.timeout.connect(self.__unregisterTimerTimeout)
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
196 self.__mostRecentlyUnregisteredProvider = None
5912
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
197
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
198 def __setupUi(self):
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
199 """
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
200 Private method to generate the UI layout.
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
201 """
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
202 self.setObjectName("CodeDocumentationViewer")
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
203
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
204 self.verticalLayout = QVBoxLayout(self)
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
205 self.verticalLayout.setObjectName("verticalLayout")
5915
4bdac859df60 Fixed a few issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5914
diff changeset
206 self.verticalLayout.setContentsMargins(3, 3, 3, 3)
5912
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
207
5959
4c716b02e10d Changed the search widget used in the documentation viewer (and other places) to allow to save width but make it higher.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5925
diff changeset
208 # top row 1 of widgets
4c716b02e10d Changed the search widget used in the documentation viewer (and other places) to allow to save width but make it higher.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5925
diff changeset
209 self.horizontalLayout1 = QHBoxLayout()
4c716b02e10d Changed the search widget used in the documentation viewer (and other places) to allow to save width but make it higher.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5925
diff changeset
210 self.horizontalLayout1.setObjectName("horizontalLayout1")
5912
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
211
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
212 self.label = QLabel(self)
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
213 self.label.setObjectName("label")
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
214 self.label.setText(self.tr("Code Info Provider:"))
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
215 self.label.setAlignment(Qt.AlignmentFlag.AlignRight |
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
216 Qt.AlignmentFlag.AlignVCenter)
5959
4c716b02e10d Changed the search widget used in the documentation viewer (and other places) to allow to save width but make it higher.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5925
diff changeset
217 self.horizontalLayout1.addWidget(self.label)
5905
f31960634997 Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5900
diff changeset
218
5912
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
219 self.providerComboBox = QComboBox(self)
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
220 sizePolicy = QSizePolicy(
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
221 QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Fixed)
5912
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
222 sizePolicy.setHorizontalStretch(0)
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
223 sizePolicy.setVerticalStretch(0)
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
224 sizePolicy.setHeightForWidth(
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
225 self.providerComboBox.sizePolicy().hasHeightForWidth())
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
226 self.providerComboBox.setSizePolicy(sizePolicy)
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
227 self.providerComboBox.setSizeAdjustPolicy(
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
228 QComboBox.SizeAdjustPolicy.AdjustToContents)
5912
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
229 self.providerComboBox.setObjectName("providerComboBox")
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
230 self.providerComboBox.setToolTip(
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
231 self.tr("Select the code info provider"))
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
232 self.providerComboBox.addItem(self.tr("<disabled>"), "disabled")
5959
4c716b02e10d Changed the search widget used in the documentation viewer (and other places) to allow to save width but make it higher.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5925
diff changeset
233 self.horizontalLayout1.addWidget(self.providerComboBox)
4c716b02e10d Changed the search widget used in the documentation viewer (and other places) to allow to save width but make it higher.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5925
diff changeset
234
4c716b02e10d Changed the search widget used in the documentation viewer (and other places) to allow to save width but make it higher.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5925
diff changeset
235 # top row 2 of widgets
5912
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
236 self.objectLineEdit = QLineEdit(self)
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
237 self.objectLineEdit.setReadOnly(True)
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
238 self.objectLineEdit.setObjectName("objectLineEdit")
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
239
5962
a339eed93b19 Made the HTML based documentation viewer optional.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5961
diff changeset
240 self.verticalLayout.addLayout(self.horizontalLayout1)
6505
470d878cbe9f CodeDocumentationViewer: chanegd code to always show the HTML based documentation viewer, if QtWebEngine or QtWebKit is available.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6475
diff changeset
241 self.verticalLayout.addWidget(self.objectLineEdit)
5962
a339eed93b19 Made the HTML based documentation viewer optional.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5961
diff changeset
242
8469
77e00a1c55bf Removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8366
diff changeset
243 # Rich Text (Web) Documentation Viewer
6506
ff6172ce89a9 CodeDocumentationViewer: simplified the front end handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6505
diff changeset
244 self.__viewerWidget = DocumentationViewerWidget(self)
ff6172ce89a9 CodeDocumentationViewer: simplified the front end handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6505
diff changeset
245 self.__viewerWidget.setObjectName("__viewerWidget")
ff6172ce89a9 CodeDocumentationViewer: simplified the front end handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6505
diff changeset
246 self.verticalLayout.addWidget(self.__viewerWidget)
ff6172ce89a9 CodeDocumentationViewer: simplified the front end handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6505
diff changeset
247
5912
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
248 self.providerComboBox.currentIndexChanged[int].connect(
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
249 self.on_providerComboBox_currentIndexChanged)
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 def finalizeSetup(self):
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 """
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 Public method to finalize the setup of the documentation viewer.
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 """
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 self.__startingUp = False
5905
f31960634997 Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5900
diff changeset
256 provider = Preferences.getDocuViewer("Provider")
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 if provider in self.__providers:
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 index = self.providerComboBox.findData(provider)
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 else:
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 index = 0
5908
4d08fb83a844 Some fixes in the new code info viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5905
diff changeset
261 provider = self.__disabledProvider
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 self.providerComboBox.setCurrentIndex(index)
5908
4d08fb83a844 Some fixes in the new code info viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5905
diff changeset
263 self.__selectedProvider = provider
5922
4ee909600092 Streamlined the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5919
diff changeset
264 if index == 0:
5925
0174aece0923 Some little enhancement to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5924
diff changeset
265 self.__showDisabledMessage()
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266
5911
0c7bcba51391 Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5908
diff changeset
267 def registerProvider(self, providerName, providerDisplay, provider,
0c7bcba51391 Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5908
diff changeset
268 supported):
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 """
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 Public method register a source docu provider.
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 @param providerName name of the provider (must be unique)
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 @type str
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 @param providerDisplay visible name of the provider
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 @type str
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 @param provider function to be called to determine source docu
5911
0c7bcba51391 Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5908
diff changeset
277 @type function(editor)
0c7bcba51391 Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5908
diff changeset
278 @param supported function to be called to determine, if a language is
0c7bcba51391 Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5908
diff changeset
279 supported
0c7bcba51391 Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5908
diff changeset
280 @type function(language)
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 @exception KeyError raised if a provider with the given name was
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 already registered
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 """
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 if providerName in self.__providers:
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 raise KeyError(
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 "Provider '{0}' already registered.".format(providerName))
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287
5911
0c7bcba51391 Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5908
diff changeset
288 self.__providers[providerName] = (provider, supported)
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 self.providerComboBox.addItem(providerDisplay, providerName)
5913
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
290
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
291 self.providerAdded.emit()
6266
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
292
8227
349308e84eeb Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
293 if (
349308e84eeb Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
294 self.__unregisterTimer.isActive() and
349308e84eeb Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
295 providerName == self.__mostRecentlyUnregisteredProvider
349308e84eeb Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
296 ):
349308e84eeb Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
297 # this is assumed to be a plug-in reload
349308e84eeb Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
298 self.__unregisterTimer.stop()
349308e84eeb Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
299 self.__mostRecentlyUnregisteredProvider = None
349308e84eeb Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
300 self.__selectProvider(providerName)
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 def unregisterProvider(self, providerName):
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 """
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 Public method register a source docu provider.
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 @param providerName name of the provider (must be unique)
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 @type str
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 """
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 if providerName in self.__providers:
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 if providerName == self.__selectedProvider:
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 self.providerComboBox.setCurrentIndex(0)
6266
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
312
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
313 # in case this is just a temporary unregistration (< 30s)
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
314 # e.g. when the plug-in is re-installed or updated
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
315 self.__mostRecentlyUnregisteredProvider = providerName
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
316 self.__unregisterTimer.start()
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 del self.__providers[providerName]
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 index = self.providerComboBox.findData(providerName)
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 self.providerComboBox.removeItem(index)
5913
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
321
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
322 self.providerRemoved.emit()
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323
6266
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
324 @pyqtSlot()
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
325 def __unregisterTimerTimeout(self):
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
326 """
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
327 Private slot handling the timeout signal of the unregister timer.
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
328 """
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
329 self.__mostRecentlyUnregisteredProvider = None
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
330
5911
0c7bcba51391 Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5908
diff changeset
331 def isSupportedLanguage(self, language):
0c7bcba51391 Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5908
diff changeset
332 """
0c7bcba51391 Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5908
diff changeset
333 Public method to check, if the given language is supported by the
0c7bcba51391 Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5908
diff changeset
334 selected provider.
0c7bcba51391 Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5908
diff changeset
335
0c7bcba51391 Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5908
diff changeset
336 @param language editor programming language to check
0c7bcba51391 Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5908
diff changeset
337 @type str
0c7bcba51391 Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5908
diff changeset
338 @return flag indicating the support status
0c7bcba51391 Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5908
diff changeset
339 @rtype bool
0c7bcba51391 Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5908
diff changeset
340 """
0c7bcba51391 Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5908
diff changeset
341 supported = False
0c7bcba51391 Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5908
diff changeset
342
0c7bcba51391 Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5908
diff changeset
343 if self.__selectedProvider != self.__disabledProvider:
0c7bcba51391 Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5908
diff changeset
344 supported = self.__providers[self.__selectedProvider][1](language)
0c7bcba51391 Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5908
diff changeset
345
0c7bcba51391 Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5908
diff changeset
346 return supported
0c7bcba51391 Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5908
diff changeset
347
5912
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
348 def getProviders(self):
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
349 """
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
350 Public method to get a list of providers and their visible strings.
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
351
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
352 @return list containing the providers and their visible strings
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
353 @rtype list of tuple of (str,str)
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
354 """
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
355 providers = []
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
356 for index in range(1, self.providerComboBox.count()):
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
357 provider = self.providerComboBox.itemData(index)
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
358 text = self.providerComboBox.itemText(index)
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
359 providers.append((provider, text))
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
360
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
361 return providers
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
362
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 def showInfo(self, editor):
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 """
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 Public method to request code documentation data from a provider.
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 @param editor reference to the editor to request code docu for
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 @type Editor
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 """
5905
f31960634997 Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5900
diff changeset
370 line, index = editor.getCursorPosition()
f31960634997 Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5900
diff changeset
371 word = editor.getWord(line, index)
f31960634997 Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5900
diff changeset
372 if not word:
f31960634997 Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5900
diff changeset
373 # try again one index before
5913
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
374 word = editor.getWord(line, index - 1)
5905
f31960634997 Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5900
diff changeset
375 self.objectLineEdit.setText(word)
f31960634997 Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5900
diff changeset
376
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377 if self.__selectedProvider != self.__disabledProvider:
6506
ff6172ce89a9 CodeDocumentationViewer: simplified the front end handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6505
diff changeset
378 self.__viewerWidget.clear()
5911
0c7bcba51391 Added functionality to enable the code info actions only, if the currently selected provider supports the editor language.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5908
diff changeset
379 self.__providers[self.__selectedProvider][0](editor)
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380
5919
d0de2b378b24 Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5915
diff changeset
381 def documentationReady(self, documentationInfo, isWarning=False,
d0de2b378b24 Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5915
diff changeset
382 isDocWarning=False):
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 """
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 Public method to provide the documentation info to the viewer.
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385
5961
2a5232311a65 Added possibility to show the type of the object info is shown for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5959
diff changeset
386 If documentationInfo is a dictionary, it should contain these
2a5232311a65 Added possibility to show the type of the object info is shown for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5959
diff changeset
387 (optional) keys and data:
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 name: the name of the inspected object
5961
2a5232311a65 Added possibility to show the type of the object info is shown for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5959
diff changeset
390 argspec: its arguments specification
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 note: A phrase describing the type of object (function or method) and
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 the module it belongs to.
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 docstring: its documentation string
5961
2a5232311a65 Added possibility to show the type of the object info is shown for.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5959
diff changeset
394 typ: its type information
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 @param documentationInfo dictionary containing the source docu data
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 @type dict or str
5914
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5913
diff changeset
398 @param isWarning flag indicating a warning page
e44c04a89dbc Improved and beautified the rich text display of the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5913
diff changeset
399 @type bool
5919
d0de2b378b24 Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5915
diff changeset
400 @param isDocWarning flag indicating a documentation warning page
d0de2b378b24 Improved and beautified the rich text display of the documentation viewer some more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5915
diff changeset
401 @type bool
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402 """
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 self.__ui.activateCodeDocumentationViewer(switchFocus=False)
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404
5922
4ee909600092 Streamlined the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5919
diff changeset
405 if not isWarning and not isDocWarning:
4ee909600092 Streamlined the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5919
diff changeset
406 self.__lastDocumentation = documentationInfo
5905
f31960634997 Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5900
diff changeset
407
5922
4ee909600092 Streamlined the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5919
diff changeset
408 if not documentationInfo:
4ee909600092 Streamlined the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5919
diff changeset
409 if self.__selectedProvider == self.__disabledProvider:
5925
0174aece0923 Some little enhancement to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5924
diff changeset
410 self.__showDisabledMessage()
5922
4ee909600092 Streamlined the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5919
diff changeset
411 else:
5925
0174aece0923 Some little enhancement to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5924
diff changeset
412 self.documentationReady(self.tr("No documentation available"),
5922
4ee909600092 Streamlined the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5919
diff changeset
413 isDocWarning=True)
4ee909600092 Streamlined the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5919
diff changeset
414 else:
6506
ff6172ce89a9 CodeDocumentationViewer: simplified the front end handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6505
diff changeset
415 if isWarning:
ff6172ce89a9 CodeDocumentationViewer: simplified the front end handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6505
diff changeset
416 html = prepareDocumentationViewerHtmlWarningDocument(
ff6172ce89a9 CodeDocumentationViewer: simplified the front end handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6505
diff changeset
417 documentationInfo)
ff6172ce89a9 CodeDocumentationViewer: simplified the front end handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6505
diff changeset
418 elif isDocWarning:
ff6172ce89a9 CodeDocumentationViewer: simplified the front end handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6505
diff changeset
419 html = prepareDocumentationViewerHtmlDocWarningDocument(
ff6172ce89a9 CodeDocumentationViewer: simplified the front end handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6505
diff changeset
420 documentationInfo)
ff6172ce89a9 CodeDocumentationViewer: simplified the front end handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6505
diff changeset
421 elif isinstance(documentationInfo, dict):
ff6172ce89a9 CodeDocumentationViewer: simplified the front end handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6505
diff changeset
422 html = prepareDocumentationViewerHtmlDocument(
ff6172ce89a9 CodeDocumentationViewer: simplified the front end handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6505
diff changeset
423 documentationInfo)
5922
4ee909600092 Streamlined the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5919
diff changeset
424 else:
6506
ff6172ce89a9 CodeDocumentationViewer: simplified the front end handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6505
diff changeset
425 html = documentationInfo
ff6172ce89a9 CodeDocumentationViewer: simplified the front end handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6505
diff changeset
426 self.__viewerWidget.setHtml(html)
5912
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
427
5925
0174aece0923 Some little enhancement to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5924
diff changeset
428 def __showDisabledMessage(self):
0174aece0923 Some little enhancement to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5924
diff changeset
429 """
0174aece0923 Some little enhancement to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5924
diff changeset
430 Private method to show a message giving the reason for being disabled.
0174aece0923 Some little enhancement to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5924
diff changeset
431 """
0174aece0923 Some little enhancement to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5924
diff changeset
432 if len(self.__providers) == 0:
0174aece0923 Some little enhancement to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5924
diff changeset
433 self.documentationReady(
0174aece0923 Some little enhancement to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5924
diff changeset
434 self.tr("No source code documentation provider has been"
0174aece0923 Some little enhancement to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5924
diff changeset
435 " registered. This function has been disabled."),
0174aece0923 Some little enhancement to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5924
diff changeset
436 isWarning=True)
0174aece0923 Some little enhancement to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5924
diff changeset
437 else:
0174aece0923 Some little enhancement to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5924
diff changeset
438 self.documentationReady(
0174aece0923 Some little enhancement to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5924
diff changeset
439 self.tr("This function has been disabled."),
0174aece0923 Some little enhancement to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5924
diff changeset
440 isWarning=True)
0174aece0923 Some little enhancement to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5924
diff changeset
441
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
442 @pyqtSlot(int)
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443 def on_providerComboBox_currentIndexChanged(self, index):
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444 """
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 Private slot to handle the selection of a provider.
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447 @param index index of the selected provider
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
448 @type int
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449 """
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
450 if not self.__shuttingDown and not self.__startingUp:
6506
ff6172ce89a9 CodeDocumentationViewer: simplified the front end handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6505
diff changeset
451 self.__viewerWidget.clear()
5912
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
452 self.objectLineEdit.clear()
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
453
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 provider = self.providerComboBox.itemData(index)
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 if provider == self.__disabledProvider:
5925
0174aece0923 Some little enhancement to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5924
diff changeset
456 self.__showDisabledMessage()
5913
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
457 else:
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
458 self.__lastDocumentation = None
7ab2293917f8 Changed the rich text display of the document viewer to use a QWebEngineView or QWebView based widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5912
diff changeset
459
5912
b6643d36dddd Added the rich text view to the documentation viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5911
diff changeset
460 Preferences.setDocuViewer("Provider", provider)
5900
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 self.__selectedProvider = provider
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
463 def shutdown(self):
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
464 """
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
465 Public method to perform shutdown actions.
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
466 """
cd90bfdc1247 Started to implement a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
467 self.__shuttingDown = True
5905
f31960634997 Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5900
diff changeset
468 Preferences.setDocuViewer("Provider", self.__selectedProvider)
f31960634997 Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5900
diff changeset
469
f31960634997 Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5900
diff changeset
470 def preferencesChanged(self):
f31960634997 Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5900
diff changeset
471 """
f31960634997 Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5900
diff changeset
472 Public slot to handle a change of preferences.
f31960634997 Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5900
diff changeset
473 """
f31960634997 Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5900
diff changeset
474 provider = Preferences.getDocuViewer("Provider")
6266
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
475 self.__selectProvider(provider)
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
476
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
477 def __selectProvider(self, provider):
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
478 """
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
479 Private method to select a provider programmatically.
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
480
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
481 @param provider name of the provider to be selected
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
482 @type str
c7bc0e516cd6 CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
483 """
5905
f31960634997 Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5900
diff changeset
484 if provider != self.__selectedProvider:
f31960634997 Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5900
diff changeset
485 index = self.providerComboBox.findData(provider)
f31960634997 Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5900
diff changeset
486 if index < 0:
f31960634997 Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5900
diff changeset
487 index = 0
f31960634997 Continued implementing a viewer for source code documentation extracted by providers to be implemented by plug-ins (like rope and jedi).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5900
diff changeset
488 self.providerComboBox.setCurrentIndex(index)

eric ide

mercurial