Sun, 16 May 2021 20:07:24 +0200
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
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 | |
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
|
12 | from PyQt6.QtCore import pyqtSlot, Qt, QMetaObject, QSize |
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 | |
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
|
19 | from E5Gui.E5ComboBox import E5ClearableComboBox |
4039
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 | 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
|
22 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | |
8268
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
24 | class E5TextEditType(enum.Enum): |
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 | Class defining the supported text edit types. |
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
27 | """ |
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
28 | UNKNOWN = 0 |
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
29 | QTEXTEDIT = 1 |
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
30 | QTEXTBROWSER = 2 |
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
31 | QWEBENGINEVIEW = 3 |
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
32 | |
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
33 | |
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
|
34 | class E5TextEditSearchWidget(QWidget): |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | Class 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
|
37 | """ |
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
|
38 | def __init__(self, parent=None, widthForHeight=True): |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | Constructor |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | |
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
|
42 | @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
|
43 | @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
|
44 | @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
|
45 | 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
|
46 | 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
|
47 | @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
|
48 | """ |
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
|
49 | super().__init__(parent) |
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
|
50 | self.__setupUi(widthForHeight) |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | self.__textedit = None |
8268
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
53 | self.__texteditType = E5TextEditType.UNKNOWN |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | self.__findBackwards = True |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | |
7252
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
56 | 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
|
57 | 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
|
58 | QPalette.ColorRole.Base) |
7252
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
59 | ) |
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
60 | 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
|
61 | 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
|
62 | QPalette.ColorRole.Text) |
7252
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
63 | ) |
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
|
64 | |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | self.findHistory = [] |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | 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
|
68 | 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
|
69 | self.__findByReturnPressed) |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | 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
|
72 | self.infoLabel.hide() |
4586
9221c0c5c66f
Fixed a forgotten focus proxy for the E5TextEditSearchWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4039
diff
changeset
|
73 | |
9221c0c5c66f
Fixed a forgotten focus proxy for the E5TextEditSearchWidget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4039
diff
changeset
|
74 | 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
|
75 | |
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
|
76 | def __setupUi(self, widthForHeight): |
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
|
77 | """ |
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
|
78 | 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
|
79 | |
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
|
80 | @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
|
81 | @type bool |
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 | self.setObjectName("E5TextEditSearchWidget") |
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 | 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
|
86 | 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
|
87 | 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
|
88 | |
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 | # 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
|
90 | 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
|
91 | 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
|
92 | |
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.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
|
94 | 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
|
95 | 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
|
96 | 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
|
97 | |
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.findtextCombo = E5ClearableComboBox(self) |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
99 | 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
|
100 | 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
|
101 | 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
|
102 | 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
|
103 | 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
|
104 | 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
|
105 | 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
|
106 | 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
|
107 | 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
|
108 | 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
|
109 | 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
|
110 | 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
|
111 | 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
|
112 | |
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
|
113 | # 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
|
114 | 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
|
115 | 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
|
116 | |
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
|
117 | 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
|
118 | 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
|
119 | 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
|
120 | 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
|
121 | |
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.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
|
123 | 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
|
124 | 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
|
125 | 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
|
126 | |
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 | # 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
|
128 | 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
|
129 | 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
|
130 | 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
|
131 | |
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.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
|
133 | 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
|
134 | 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
|
135 | "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
|
136 | 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
|
137 | 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
|
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.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
|
140 | 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
|
141 | 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
|
142 | "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
|
143 | 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
|
144 | 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
|
145 | |
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.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
|
147 | |
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 | # 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
|
149 | 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
|
150 | 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
|
151 | 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
|
152 | |
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
|
153 | # 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
|
154 | 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
|
155 | 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
|
156 | 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
|
157 | |
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 | 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
|
159 | |
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
|
160 | 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
|
161 | 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
|
162 | 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
|
163 | 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
|
164 | |
6499
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
165 | def setWidthForHeight(self, widthForHeight): |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
166 | """ |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
167 | 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
|
168 | |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
169 | @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
|
170 | @type bool |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
171 | """ |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
172 | if self.__widthForHeight: |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
173 | self.horizontalLayout1.takeAt(self.__widthForHeightLayoutIndex) |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
174 | else: |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
175 | self.verticalLayout.takeAt(self.__widthForHeightLayoutIndex) |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
176 | self.__addWidthForHeightLayout(widthForHeight) |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
177 | |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
178 | def __addWidthForHeightLayout(self, widthForHeight): |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
179 | """ |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
180 | 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
|
181 | |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
182 | @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
|
183 | @type bool |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
184 | """ |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
185 | if widthForHeight: |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
186 | self.horizontalLayout1.addLayout(self.horizontalLayout2) |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
187 | self.__widthForHeightLayoutIndex = 2 |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
188 | else: |
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
189 | 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
|
190 | self.__widthForHeightLayoutIndex = 1 |
6501
d564cd2c9a2d
E5TextEditSearchWidget: fixed an issue introduced in the last change.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6499
diff
changeset
|
191 | |
d564cd2c9a2d
E5TextEditSearchWidget: fixed an issue introduced in the last change.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6499
diff
changeset
|
192 | self.__widthForHeight = widthForHeight |
6499
dcff57f91861
E5TextEditSearchWidget: added method to modify the layout strategy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6048
diff
changeset
|
193 | |
8268
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
194 | def attachTextEdit(self, textedit, editType=E5TextEditType.QTEXTEDIT): |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
195 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
196 | Public method to attach a QTextEdit widget. |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
197 | |
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
|
198 | @param textedit reference to the edit widget to be attached |
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
|
199 | @type QTextEdit, QWebEngineView or QWebView |
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
|
200 | @param editType type of the attached edit widget |
8268
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
201 | @type E5TextEditType |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
202 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
203 | 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
|
204 | 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
|
205 | |
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
|
206 | self.wordCheckBox.setVisible(editType == "QTextEdit") |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
207 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
208 | 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
|
209 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
210 | 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
|
211 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
212 | @param event reference to the key press event (QKeyEvent) |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
213 | """ |
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
|
214 | if self.__textedit and event.key() == Qt.Key.Key_Escape: |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
215 | self.__textedit.setFocus(Qt.FocusReason.ActiveWindowFocusReason) |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
216 | event.accept() |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
217 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
218 | @pyqtSlot(str) |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
219 | 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
|
220 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
221 | 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
|
222 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
223 | @param txt text of the combobox (string) |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
224 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
225 | 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
|
226 | |
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
|
227 | 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
|
228 | 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
|
229 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
230 | 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
|
231 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
232 | 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
|
233 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
234 | @param enabled flag indicating the state (boolean) |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
235 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
236 | 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
|
237 | 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
|
238 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
239 | 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
|
240 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
241 | 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
|
242 | combobox. |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
243 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
244 | 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
|
245 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
246 | @pyqtSlot() |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
247 | 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
|
248 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
249 | 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
|
250 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
251 | 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
|
252 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
253 | @pyqtSlot() |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
254 | 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
|
255 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
256 | 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
|
257 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
258 | 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
|
259 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
260 | 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
|
261 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
262 | 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
|
263 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
264 | @param backwards flag indicating a backwards search (boolean) |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
265 | """ |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
266 | 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
|
267 | return |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
268 | |
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
|
269 | 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
|
270 | 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
|
271 | 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
|
272 | |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
273 | 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
|
274 | 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
|
275 | return |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
276 | 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
|
277 | |
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
278 | # 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
|
279 | # 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
|
280 | 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
|
281 | 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
|
282 | 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
|
283 | 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
|
284 | 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
|
285 | |
8268
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
286 | if self.__texteditType in ( |
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
287 | E5TextEditType.QTEXTBROWSER, E5TextEditType.QTEXTEDIT |
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
288 | ): |
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
|
289 | 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
|
290 | self.__findNextPrevCallback(ok) |
8268
6b8128e0c9d1
Modernized some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8257
diff
changeset
|
291 | elif self.__texteditType == E5TextEditType.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
|
292 | 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
|
293 | |
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
|
294 | 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
|
295 | """ |
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
|
296 | 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
|
297 | 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
|
298 | |
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
|
299 | @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
|
300 | @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
|
301 | @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
|
302 | @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
|
303 | """ |
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
|
304 | flags = ( |
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
|
305 | QTextDocument.FindFlags(QTextDocument.FindFlag.FindBackward) |
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
|
306 | if backwards else |
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
|
307 | QTextDocument.FindFlags() |
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
|
308 | ) |
4039
661167a99aef
Added the capability to search in the output to the Diff dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
309 | 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
|
310 | 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
|
311 | 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
|
312 | 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
|
313 | |
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
|
314 | 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
|
315 | 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
|
316 | # 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
|
317 | 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
|
318 | 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
|
319 | 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
|
320 | # 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
|
321 | 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
|
322 | 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
|
323 | # 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
|
324 | 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
|
325 | 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
|
326 | 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
|
327 | |
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
|
328 | 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
|
329 | |
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
|
330 | 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
|
331 | """ |
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
|
332 | 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
|
333 | 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
|
334 | |
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
|
335 | @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
|
336 | @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
|
337 | """ |
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
|
338 | from PyQt6.QtWebEngineWidgets 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
|
339 | |
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
|
340 | findFlags = QWebEnginePage.FindFlags() |
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
|
341 | 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
|
342 | 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
|
343 | 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
|
344 | 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
|
345 | 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
|
346 | 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
|
347 | |
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
|
348 | 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
|
349 | """ |
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
|
350 | 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
|
351 | |
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
|
352 | @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
|
353 | @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
|
354 | """ |
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
|
355 | 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
|
356 | 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
|
357 | 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
|
358 | 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
|
359 | 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
|
360 | 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
|
361 | |
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
|
362 | 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
|
363 | """ |
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
|
364 | 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
|
365 | 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
|
366 | |
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 | @param error flag indicating an error condition (boolean) |
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 | """ |
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 | 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
|
370 | 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
|
371 | 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
|
372 | 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
|
373 | 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
|
374 | 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
|
375 | 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
|
376 | 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
|
377 | 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
|
378 | le.update() |