Tue, 19 Oct 2021 19:57:26 +0200
***
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
7923
91e843545d9a
Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7780
diff
changeset
|
3 | # Copyright (c) 2012 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a horizontal search widget for QTextEdit. |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
8268
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
10 | import enum |
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
11 | |
8702 | 12 | from PyQt6.QtCore import pyqtSlot, pyqtSignal, Qt, QMetaObject, QSize |
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
|
13 | from PyQt6.QtGui import QPalette, QBrush, QColor, QTextDocument, QTextCursor |
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
|
14 | from PyQt6.QtWidgets import ( |
7252
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
15 | QWidget, QVBoxLayout, QHBoxLayout, QLabel, QComboBox, QCheckBox, |
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
16 | QToolButton, QSizePolicy |
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
17 | ) |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | import UI.PixmapCache |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | |
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:
8350
diff
changeset
|
22 | class EricTextEditType(enum.Enum): |
8268
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
23 | """ |
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
24 | Class defining the supported text edit types. |
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
25 | """ |
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
26 | UNKNOWN = 0 |
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
27 | QTEXTEDIT = 1 |
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
28 | QTEXTBROWSER = 2 |
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
29 | QWEBENGINEVIEW = 3 |
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
30 | |
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
31 | |
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:
8350
diff
changeset
|
32 | class EricTextEditSearchWidget(QWidget): |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | Class implementing a horizontal search widget for QTextEdit. |
8702 | 35 | |
36 | @signal closePressed() emitted to indicate the closing of the widget via | |
37 | the close button | |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | """ |
8702 | 39 | closePressed = pyqtSignal() |
40 | ||
8690
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
41 | def __init__(self, parent=None, widthForHeight=True, enableClose=False): |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | Constructor |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | |
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:
5924
diff
changeset
|
45 | @param parent reference to the parent widget |
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:
5924
diff
changeset
|
46 | @type QWidget |
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:
5924
diff
changeset
|
47 | @param widthForHeight flag indicating to prefer width for height. |
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:
5924
diff
changeset
|
48 | If this parameter is False, some widgets are shown in a third |
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:
5924
diff
changeset
|
49 | line. |
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:
5924
diff
changeset
|
50 | @type bool |
8690
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
51 | @param enableClose flag indicating to show a close button |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
52 | @type bool |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | """ |
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
|
54 | super().__init__(parent) |
8690
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
55 | self.__setupUi(widthForHeight, enableClose) |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | self.__textedit = None |
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:
8350
diff
changeset
|
58 | self.__texteditType = EricTextEditType.UNKNOWN |
8702 | 59 | self.__findBackwards = False |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | |
7252
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
61 | self.__defaultBaseColor = ( |
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
|
62 | self.findtextCombo.lineEdit().palette().color( |
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
|
63 | QPalette.ColorRole.Base) |
7252
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
64 | ) |
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
65 | self.__defaultTextColor = ( |
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
|
66 | self.findtextCombo.lineEdit().palette().color( |
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
|
67 | QPalette.ColorRole.Text) |
7252
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
68 | ) |
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:
5389
diff
changeset
|
69 | |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | self.findHistory = [] |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | self.findtextCombo.setCompleter(None) |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | self.findtextCombo.lineEdit().returnPressed.connect( |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | self.__findByReturnPressed) |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | self.__setSearchButtons(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:
5389
diff
changeset
|
77 | self.infoLabel.hide() |
4586
9221c0c5c66f
Fixed a forgotten focus proxy for the E5TextEditSearchWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4039
diff
changeset
|
78 | |
9221c0c5c66f
Fixed a forgotten focus proxy for the E5TextEditSearchWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4039
diff
changeset
|
79 | self.setFocusProxy(self.findtextCombo) |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | |
8690
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
81 | def __setupUi(self, widthForHeight, enableClose): |
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:
5924
diff
changeset
|
82 | """ |
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:
5924
diff
changeset
|
83 | Private method to generate the UI. |
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:
5924
diff
changeset
|
84 | |
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:
5924
diff
changeset
|
85 | @param widthForHeight flag indicating to prefer width for height |
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:
5924
diff
changeset
|
86 | @type bool |
8690
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
87 | @param enableClose flag indicating to show a close button |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
88 | @type bool |
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:
5924
diff
changeset
|
89 | """ |
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:
8350
diff
changeset
|
90 | self.setObjectName("EricTextEditSearchWidget") |
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:
5924
diff
changeset
|
91 | |
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:
5924
diff
changeset
|
92 | self.verticalLayout = QVBoxLayout(self) |
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:
5924
diff
changeset
|
93 | self.verticalLayout.setObjectName("verticalLayout") |
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:
5924
diff
changeset
|
94 | self.verticalLayout.setContentsMargins(0, 0, 0, 0) |
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:
5924
diff
changeset
|
95 | |
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:
5924
diff
changeset
|
96 | # 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:
5924
diff
changeset
|
97 | 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:
5924
diff
changeset
|
98 | self.horizontalLayout1.setObjectName("horizontalLayout1") |
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:
5924
diff
changeset
|
99 | |
8690
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
100 | if enableClose: |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
101 | self.closeButton = QToolButton(self) |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
102 | self.closeButton.setIcon(UI.PixmapCache.getIcon("close")) |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
103 | self.closeButton.clicked.connect(self.__closeButtonClicked) |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
104 | self.horizontalLayout1.addWidget(self.closeButton) |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
105 | else: |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
106 | self.closeButton = None |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
107 | |
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:
5924
diff
changeset
|
108 | self.label = QLabel(self) |
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:
5924
diff
changeset
|
109 | self.label.setObjectName("label") |
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:
5924
diff
changeset
|
110 | self.label.setText(self.tr("Find:")) |
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:
5924
diff
changeset
|
111 | self.horizontalLayout1.addWidget(self.label) |
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:
5924
diff
changeset
|
112 | |
8350
74a3b2a6a944
Removed all references to E5ComboBox and most references to E5LineEdit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8324
diff
changeset
|
113 | self.findtextCombo = QComboBox(self) |
74a3b2a6a944
Removed all references to E5ComboBox and most references to E5LineEdit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8324
diff
changeset
|
114 | self.findtextCombo.setEditable(True) |
74a3b2a6a944
Removed all references to E5ComboBox and most references to E5LineEdit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8324
diff
changeset
|
115 | self.findtextCombo.lineEdit().setClearButtonEnabled(True) |
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
|
116 | sizePolicy = QSizePolicy(QSizePolicy.Policy.Expanding, |
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 | QSizePolicy.Policy.Fixed) |
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:
5924
diff
changeset
|
118 | sizePolicy.setHorizontalStretch(0) |
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:
5924
diff
changeset
|
119 | sizePolicy.setVerticalStretch(0) |
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:
5924
diff
changeset
|
120 | sizePolicy.setHeightForWidth( |
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:
5924
diff
changeset
|
121 | self.findtextCombo.sizePolicy().hasHeightForWidth()) |
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:
5924
diff
changeset
|
122 | self.findtextCombo.setSizePolicy(sizePolicy) |
6635
00d9efb7afc6
E5TextEditSearchWidget: made the minimum size smaller in order to allow better resizability for small screens.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6501
diff
changeset
|
123 | self.findtextCombo.setMinimumSize(QSize(100, 0)) |
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:
5924
diff
changeset
|
124 | self.findtextCombo.setEditable(True) |
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
|
125 | self.findtextCombo.setInsertPolicy(QComboBox.InsertPolicy.InsertAtTop) |
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:
5924
diff
changeset
|
126 | self.findtextCombo.setDuplicatesEnabled(False) |
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:
5924
diff
changeset
|
127 | self.findtextCombo.setObjectName("findtextCombo") |
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:
5924
diff
changeset
|
128 | self.horizontalLayout1.addWidget(self.findtextCombo) |
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:
5924
diff
changeset
|
129 | |
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:
5924
diff
changeset
|
130 | # row 2 (maybe) 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:
5924
diff
changeset
|
131 | self.horizontalLayout2 = 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:
5924
diff
changeset
|
132 | self.horizontalLayout2.setObjectName("horizontalLayout2") |
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:
5924
diff
changeset
|
133 | |
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:
5924
diff
changeset
|
134 | self.caseCheckBox = QCheckBox(self) |
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:
5924
diff
changeset
|
135 | self.caseCheckBox.setObjectName("caseCheckBox") |
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:
5924
diff
changeset
|
136 | self.caseCheckBox.setText(self.tr("Match case")) |
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:
5924
diff
changeset
|
137 | self.horizontalLayout2.addWidget(self.caseCheckBox) |
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:
5924
diff
changeset
|
138 | |
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:
5924
diff
changeset
|
139 | self.wordCheckBox = QCheckBox(self) |
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:
5924
diff
changeset
|
140 | self.wordCheckBox.setObjectName("wordCheckBox") |
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:
5924
diff
changeset
|
141 | self.wordCheckBox.setText(self.tr("Whole word")) |
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:
5924
diff
changeset
|
142 | self.horizontalLayout2.addWidget(self.wordCheckBox) |
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:
5924
diff
changeset
|
143 | |
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:
5924
diff
changeset
|
144 | # layout for the navigation buttons |
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:
5924
diff
changeset
|
145 | self.horizontalLayout3 = 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:
5924
diff
changeset
|
146 | self.horizontalLayout3.setSpacing(0) |
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:
5924
diff
changeset
|
147 | self.horizontalLayout3.setObjectName("horizontalLayout3") |
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:
5924
diff
changeset
|
148 | |
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:
5924
diff
changeset
|
149 | self.findPrevButton = QToolButton(self) |
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:
5924
diff
changeset
|
150 | self.findPrevButton.setObjectName("findPrevButton") |
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:
5924
diff
changeset
|
151 | self.findPrevButton.setToolTip(self.tr( |
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:
5924
diff
changeset
|
152 | "Press to find the previous occurrence")) |
7533
88261c96484b
Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
153 | self.findPrevButton.setIcon(UI.PixmapCache.getIcon("1leftarrow")) |
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:
5924
diff
changeset
|
154 | self.horizontalLayout3.addWidget(self.findPrevButton) |
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:
5924
diff
changeset
|
155 | |
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:
5924
diff
changeset
|
156 | self.findNextButton = QToolButton(self) |
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:
5924
diff
changeset
|
157 | self.findNextButton.setObjectName("findNextButton") |
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:
5924
diff
changeset
|
158 | self.findNextButton.setToolTip(self.tr( |
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:
5924
diff
changeset
|
159 | "Press to find the next occurrence")) |
7533
88261c96484b
Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
160 | self.findNextButton.setIcon(UI.PixmapCache.getIcon("1rightarrow")) |
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:
5924
diff
changeset
|
161 | self.horizontalLayout3.addWidget(self.findNextButton) |
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:
5924
diff
changeset
|
162 | |
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:
5924
diff
changeset
|
163 | self.horizontalLayout2.addLayout(self.horizontalLayout3) |
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:
5924
diff
changeset
|
164 | |
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:
5924
diff
changeset
|
165 | # info label (in row 2 or 3) |
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:
5924
diff
changeset
|
166 | self.infoLabel = QLabel(self) |
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:
5924
diff
changeset
|
167 | self.infoLabel.setText("") |
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:
5924
diff
changeset
|
168 | self.infoLabel.setObjectName("infoLabel") |
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:
5924
diff
changeset
|
169 | |
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:
5924
diff
changeset
|
170 | # place everything together |
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:
5924
diff
changeset
|
171 | self.verticalLayout.addLayout(self.horizontalLayout1) |
6499
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
172 | self.__addWidthForHeightLayout(widthForHeight) |
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:
5924
diff
changeset
|
173 | self.verticalLayout.addWidget(self.infoLabel) |
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:
5924
diff
changeset
|
174 | |
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:
5924
diff
changeset
|
175 | QMetaObject.connectSlotsByName(self) |
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:
5924
diff
changeset
|
176 | |
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:
5924
diff
changeset
|
177 | self.setTabOrder(self.findtextCombo, self.caseCheckBox) |
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:
5924
diff
changeset
|
178 | self.setTabOrder(self.caseCheckBox, self.wordCheckBox) |
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:
5924
diff
changeset
|
179 | self.setTabOrder(self.wordCheckBox, self.findPrevButton) |
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:
5924
diff
changeset
|
180 | self.setTabOrder(self.findPrevButton, self.findNextButton) |
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:
5924
diff
changeset
|
181 | |
6499
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
182 | def setWidthForHeight(self, widthForHeight): |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
183 | """ |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
184 | Public method to set the 'width for height'. |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
185 | |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
186 | @param widthForHeight flag indicating to prefer width |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
187 | @type bool |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
188 | """ |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
189 | if self.__widthForHeight: |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
190 | self.horizontalLayout1.takeAt(self.__widthForHeightLayoutIndex) |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
191 | else: |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
192 | self.verticalLayout.takeAt(self.__widthForHeightLayoutIndex) |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
193 | self.__addWidthForHeightLayout(widthForHeight) |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
194 | |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
195 | def __addWidthForHeightLayout(self, widthForHeight): |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
196 | """ |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
197 | Private method to set the middle part of the layout. |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
198 | |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
199 | @param widthForHeight flag indicating to prefer width |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
200 | @type bool |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
201 | """ |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
202 | if widthForHeight: |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
203 | self.horizontalLayout1.addLayout(self.horizontalLayout2) |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
204 | self.__widthForHeightLayoutIndex = 2 |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
205 | else: |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
206 | self.verticalLayout.insertLayout(1, self.horizontalLayout2) |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
207 | self.__widthForHeightLayoutIndex = 1 |
6501
d564cd2c9a2d
E5TextEditSearchWidget: fixed an issue introduced in the last change.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6499
diff
changeset
|
208 | |
d564cd2c9a2d
E5TextEditSearchWidget: fixed an issue introduced in the last change.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6499
diff
changeset
|
209 | self.__widthForHeight = widthForHeight |
6499
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
210 | |
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:
8350
diff
changeset
|
211 | def attachTextEdit(self, textedit, editType=EricTextEditType.QTEXTEDIT): |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
212 | """ |
8690
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
213 | Public method to attach a QTextEdit or QWebEngineView widget. |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
214 | |
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:
5389
diff
changeset
|
215 | @param textedit reference to the edit widget to be attached |
8690
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
216 | @type QTextEdit, QTextBrowser or 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:
5389
diff
changeset
|
217 | @param editType type of the attached edit widget |
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:
8350
diff
changeset
|
218 | @type EricTextEditType |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
219 | """ |
8690
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
220 | if self.__textedit is not None: |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
221 | self.detachTextEdit() |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
222 | |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
223 | self.__textedit = textedit |
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:
5389
diff
changeset
|
224 | self.__texteditType = editType |
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:
5389
diff
changeset
|
225 | |
8690
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
226 | self.wordCheckBox.setVisible(editType in ( |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
227 | EricTextEditType.QTEXTEDIT, EricTextEditType.QTEXTBROWSER |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
228 | )) |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
229 | if editType == EricTextEditType.QWEBENGINEVIEW: |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
230 | self.__textedit.page().findTextFinished.connect( |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
231 | self.__findTextFinished) |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
232 | |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
233 | def detachTextEdit(self): |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
234 | """ |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
235 | Public method to detach the current text edit. |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
236 | """ |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
237 | if self.__texteditType == EricTextEditType.QWEBENGINEVIEW: |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
238 | self.__textedit.page().findTextFinished.disconnect( |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
239 | self.__findTextFinished) |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
240 | |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
241 | self.__textedit = None |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
242 | self.__texteditType = EricTextEditType.UNKNOWN |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
243 | |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
244 | @pyqtSlot() |
8702 | 245 | def activate(self): |
246 | """ | |
247 | Public slot to activate the widget. | |
248 | """ | |
249 | self.show() | |
250 | self.findtextCombo.setFocus( | |
251 | Qt.FocusReason.ActiveWindowFocusReason) | |
252 | self.findtextCombo.lineEdit().selectAll() | |
253 | ||
254 | @pyqtSlot() | |
255 | def deactivate(self): | |
256 | """ | |
257 | Public slot to deactivate the widget. | |
258 | """ | |
259 | if self.__textedit: | |
260 | self.__textedit.setFocus(Qt.FocusReason.ActiveWindowFocusReason) | |
261 | if self.closeButton is not None: | |
262 | self.hide() | |
263 | self.closePressed.emit() | |
264 | ||
265 | @pyqtSlot() | |
8690
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
266 | def __closeButtonClicked(self): |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
267 | """ |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
268 | Private slot to close the widget. |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
269 | |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
270 | Note: The widget is just hidden. |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
271 | """ |
8702 | 272 | self.deactivate() |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
273 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
274 | def keyPressEvent(self, event): |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
275 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
276 | Protected slot to handle key press events. |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
277 | |
8690
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
278 | @param event reference to the key press event |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
279 | @type QKeyEvent |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
280 | """ |
8690
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
281 | if self.__textedit: |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
282 | key = event.key() |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
283 | modifiers = event.modifiers() |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
284 | |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
285 | if key == Qt.Key.Key_Escape: |
8702 | 286 | self.deactivate() |
8690
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
287 | event.accept() |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
288 | |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
289 | elif key == Qt.Key.Key_F3: |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
290 | if modifiers == Qt.KeyboardModifier.NoModifier: |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
291 | # search forward |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
292 | self.on_findNextButton_clicked() |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
293 | event.accept() |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
294 | elif modifiers == Qt.KeyboardModifier.ShiftModifier: |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
295 | # search backward |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
296 | self.on_findPrevButton_clicked() |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
297 | event.accept() |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
298 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
299 | @pyqtSlot(str) |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
300 | def on_findtextCombo_editTextChanged(self, txt): |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
301 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
302 | Private slot to enable/disable the find buttons. |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
303 | |
8690
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
304 | @param txt text of the combobox |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
305 | @type str |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
306 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
307 | self.__setSearchButtons(txt != "") |
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:
5389
diff
changeset
|
308 | |
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:
5389
diff
changeset
|
309 | self.infoLabel.hide() |
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:
5389
diff
changeset
|
310 | self.__setFindtextComboBackground(False) |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
311 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
312 | def __setSearchButtons(self, enabled): |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
313 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
314 | Private slot to set the state of the search buttons. |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
315 | |
8690
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
316 | @param enabled flag indicating the state |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
317 | @type bool |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
318 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
319 | self.findPrevButton.setEnabled(enabled) |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
320 | self.findNextButton.setEnabled(enabled) |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
321 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
322 | def __findByReturnPressed(self): |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
323 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
324 | Private slot to handle the returnPressed signal of the findtext |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
325 | combobox. |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
326 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
327 | self.__find(self.__findBackwards) |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
328 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
329 | @pyqtSlot() |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
330 | def on_findPrevButton_clicked(self): |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
331 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
332 | Private slot to find the previous occurrence. |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
333 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
334 | self.__find(True) |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
335 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
336 | @pyqtSlot() |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
337 | def on_findNextButton_clicked(self): |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
338 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
339 | Private slot to find the next occurrence. |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
340 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
341 | self.__find(False) |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
342 | |
8702 | 343 | @pyqtSlot() |
344 | def findPrev(self): | |
345 | """ | |
346 | Public slot to find the previous occurrence of the current search term. | |
347 | """ | |
348 | self.on_findPrevButton_clicked() | |
349 | ||
350 | @pyqtSlot() | |
351 | def findNext(self): | |
352 | """ | |
353 | Public slot to find the next occurrence of the current search term. | |
354 | """ | |
355 | self.on_findNextButton_clicked() | |
356 | ||
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
357 | def __find(self, backwards): |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
358 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
359 | Private method to search the associated text edit. |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
360 | |
8690
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
361 | @param backwards flag indicating a backwards search |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
362 | @type bool |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
363 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
364 | if not self.__textedit: |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
365 | return |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
366 | |
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:
5389
diff
changeset
|
367 | self.infoLabel.clear() |
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:
5389
diff
changeset
|
368 | self.infoLabel.hide() |
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:
5389
diff
changeset
|
369 | self.__setFindtextComboBackground(False) |
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:
5389
diff
changeset
|
370 | |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
371 | txt = self.findtextCombo.currentText() |
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:
5389
diff
changeset
|
372 | if not txt: |
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:
5389
diff
changeset
|
373 | return |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
374 | self.__findBackwards = backwards |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
375 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
376 | # This moves any previous occurrence of this statement to the head |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
377 | # of the list and updates the combobox |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
378 | if txt in self.findHistory: |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
379 | self.findHistory.remove(txt) |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
380 | self.findHistory.insert(0, txt) |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
381 | self.findtextCombo.clear() |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
382 | self.findtextCombo.addItems(self.findHistory) |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
383 | |
8268
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
384 | if self.__texteditType in ( |
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:
8350
diff
changeset
|
385 | EricTextEditType.QTEXTBROWSER, EricTextEditType.QTEXTEDIT |
8268
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
386 | ): |
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:
5389
diff
changeset
|
387 | ok = self.__findPrevNextQTextEdit(backwards) |
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:
5389
diff
changeset
|
388 | self.__findNextPrevCallback(ok) |
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:
8350
diff
changeset
|
389 | elif self.__texteditType == 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:
5389
diff
changeset
|
390 | self.__findPrevNextQWebEngineView(backwards) |
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:
5389
diff
changeset
|
391 | |
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:
5389
diff
changeset
|
392 | def __findPrevNextQTextEdit(self, backwards): |
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:
5389
diff
changeset
|
393 | """ |
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:
5389
diff
changeset
|
394 | Private method to to search the associated edit widget of |
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:
5389
diff
changeset
|
395 | type QTextEdit. |
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:
5389
diff
changeset
|
396 | |
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:
5389
diff
changeset
|
397 | @param backwards flag indicating a backwards search |
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:
5389
diff
changeset
|
398 | @type bool |
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:
5389
diff
changeset
|
399 | @return flag indicating the search result |
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:
5389
diff
changeset
|
400 | @rtype bool |
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:
5389
diff
changeset
|
401 | """ |
8257
28146736bbfc
Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
402 | flags = ( |
8324
83084f088655
Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
403 | QTextDocument.FindFlag.FindBackward |
8257
28146736bbfc
Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
404 | if backwards else |
8324
83084f088655
Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
405 | QTextDocument.FindFlag(0) |
8257
28146736bbfc
Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
406 | ) |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
407 | if self.caseCheckBox.isChecked(): |
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
|
408 | flags |= QTextDocument.FindFlag.FindCaseSensitively |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
409 | if self.wordCheckBox.isChecked(): |
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
|
410 | flags |= QTextDocument.FindFlag.FindWholeWords |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
411 | |
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:
5389
diff
changeset
|
412 | ok = self.__textedit.find(self.findtextCombo.currentText(), flags) |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
413 | if not ok: |
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:
5389
diff
changeset
|
414 | # wrap around once |
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:
5389
diff
changeset
|
415 | cursor = self.__textedit.textCursor() |
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:
5389
diff
changeset
|
416 | if backwards: |
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
|
417 | moveOp = QTextCursor.MoveOperation.End |
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
|
418 | # move to end of document |
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:
5389
diff
changeset
|
419 | else: |
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
|
420 | moveOp = QTextCursor.MoveOperation.Start |
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
|
421 | # move to start of document |
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:
5389
diff
changeset
|
422 | cursor.movePosition(moveOp) |
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:
5389
diff
changeset
|
423 | self.__textedit.setTextCursor(cursor) |
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:
5389
diff
changeset
|
424 | ok = self.__textedit.find(self.findtextCombo.currentText(), flags) |
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:
5389
diff
changeset
|
425 | |
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:
5389
diff
changeset
|
426 | return ok |
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:
5389
diff
changeset
|
427 | |
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:
5389
diff
changeset
|
428 | def __findPrevNextQWebEngineView(self, backwards): |
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:
5389
diff
changeset
|
429 | """ |
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:
5389
diff
changeset
|
430 | Private method to to search the associated edit widget of |
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:
5389
diff
changeset
|
431 | type QWebEngineView. |
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:
5389
diff
changeset
|
432 | |
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:
5389
diff
changeset
|
433 | @param backwards flag indicating a backwards search |
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:
5389
diff
changeset
|
434 | @type bool |
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:
5389
diff
changeset
|
435 | """ |
8553
10d31e5ce9e5
First batch of changes for QtWebEngine as of Qt 6.2.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8358
diff
changeset
|
436 | from PyQt6.QtWebEngineCore import QWebEnginePage |
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:
5389
diff
changeset
|
437 | |
8324
83084f088655
Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
438 | findFlags = QWebEnginePage.FindFlag(0) |
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:
5389
diff
changeset
|
439 | if self.caseCheckBox.isChecked(): |
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
|
440 | findFlags |= QWebEnginePage.FindFlag.FindCaseSensitively |
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:
5389
diff
changeset
|
441 | if backwards: |
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
|
442 | findFlags |= QWebEnginePage.FindFlag.FindBackward |
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:
5389
diff
changeset
|
443 | self.__textedit.findText(self.findtextCombo.currentText(), |
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:
5389
diff
changeset
|
444 | findFlags, self.__findNextPrevCallback) |
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:
5389
diff
changeset
|
445 | |
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:
5389
diff
changeset
|
446 | def __findNextPrevCallback(self, found): |
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:
5389
diff
changeset
|
447 | """ |
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:
5389
diff
changeset
|
448 | Private method to process the result of the last search. |
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:
5389
diff
changeset
|
449 | |
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:
5389
diff
changeset
|
450 | @param found flag indicating if the last search succeeded |
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:
5389
diff
changeset
|
451 | @type bool |
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:
5389
diff
changeset
|
452 | """ |
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:
5389
diff
changeset
|
453 | if not found: |
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:
5389
diff
changeset
|
454 | txt = self.findtextCombo.currentText() |
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:
5389
diff
changeset
|
455 | self.infoLabel.setText( |
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:
5389
diff
changeset
|
456 | self.tr("'{0}' was not found.").format(txt)) |
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:
5389
diff
changeset
|
457 | self.infoLabel.show() |
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:
5389
diff
changeset
|
458 | self.__setFindtextComboBackground(True) |
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:
5389
diff
changeset
|
459 | |
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:
5389
diff
changeset
|
460 | def __setFindtextComboBackground(self, error): |
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:
5389
diff
changeset
|
461 | """ |
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:
5389
diff
changeset
|
462 | Private slot to change the findtext combo background to indicate |
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:
5389
diff
changeset
|
463 | errors. |
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:
5389
diff
changeset
|
464 | |
8690
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
465 | @param error flag indicating an error condition |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
466 | @type bool |
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:
5389
diff
changeset
|
467 | """ |
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:
5389
diff
changeset
|
468 | le = self.findtextCombo.lineEdit() |
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:
5389
diff
changeset
|
469 | p = le.palette() |
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:
5389
diff
changeset
|
470 | if error: |
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
|
471 | p.setBrush(QPalette.ColorRole.Base, QBrush(QColor("#FF6666"))) |
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
|
472 | p.setBrush(QPalette.ColorRole.Text, QBrush(QColor("#000000"))) |
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:
5389
diff
changeset
|
473 | else: |
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
|
474 | p.setBrush(QPalette.ColorRole.Base, self.__defaultBaseColor) |
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
|
475 | p.setBrush(QPalette.ColorRole.Text, self.__defaultTextColor) |
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:
5389
diff
changeset
|
476 | le.setPalette(p) |
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:
5389
diff
changeset
|
477 | le.update() |
8690
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
478 | |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
479 | def __findTextFinished(self, result): |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
480 | """ |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
481 | Private slot handling the findTextFinished signal of the web page. |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
482 | |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
483 | @param result reference to the QWebEngineFindTextResult object of the |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
484 | last search |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
485 | @type QWebEngineFindTextResult |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
486 | """ |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
487 | self.infoLabel.setText(self.tr("Match {0} of {1}").format( |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
488 | result.activeMatch(), result.numberOfMatches()) |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
489 | ) |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
490 | self.infoLabel.show() |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
491 | |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
492 | def showInfo(self, info): |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
493 | """ |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
494 | Public method to show some information in the info label. |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
495 | |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
496 | @param info informational text to be shown |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
497 | @type str |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
498 | """ |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
499 | self.infoLabel.setText(info) |
25f68ec4181a
Improved the eric search widget for QTextEdit, QTextBrowser and QWebEngineView.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8553
diff
changeset
|
500 | self.infoLabel.show() |