5 |
5 |
6 """ |
6 """ |
7 Module implementing a dialog to show help about rope. |
7 Module implementing a dialog to show help about rope. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt5.QtCore import Qt |
10 from PyQt6.QtCore import Qt |
11 from PyQt5.QtGui import QTextDocument, QTextCursor |
11 from PyQt6.QtGui import QTextDocument, QTextCursor |
12 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
12 from PyQt6.QtWidgets import QDialog, QDialogButtonBox |
13 |
13 |
14 from .Ui_HelpDialog import Ui_HelpDialog |
14 from .Ui_HelpDialog import Ui_HelpDialog |
15 |
15 |
16 import Globals |
16 import Globals |
17 |
17 |
18 |
18 |
|
19 # TODO: modify help dialog to use the eric7 EricTextEditSearchWidget |
19 class HelpDialog(QDialog, Ui_HelpDialog): |
20 class HelpDialog(QDialog, Ui_HelpDialog): |
20 """ |
21 """ |
21 Class implementing a dialog to show help about rope. |
22 Class implementing a dialog to show help about rope. |
22 """ |
23 """ |
23 def __init__(self, title, helpfile, parent=None): |
24 def __init__(self, title, helpfile, parent=None): |
31 @param parent reference to the parent widget |
32 @param parent reference to the parent widget |
32 @type QWidget |
33 @type QWidget |
33 """ |
34 """ |
34 QDialog.__init__(self, parent) |
35 QDialog.__init__(self, parent) |
35 self.setupUi(self) |
36 self.setupUi(self) |
36 self.setWindowFlags(Qt.Window) |
37 self.setWindowFlags(Qt.WindowType.Window) |
37 |
38 |
38 self.searchButton = self.buttonBox.addButton( |
39 self.searchButton = self.buttonBox.addButton( |
39 self.tr("Search..."), QDialogButtonBox.ActionRole) |
40 self.tr("Search..."), QDialogButtonBox.ButtonRole.ActionRole) |
40 self.__searchDlg = None |
41 self.__searchDlg = None |
41 |
42 |
42 if Globals.isWindowsPlatform(): |
43 if Globals.isWindowsPlatform(): |
43 self.helpEdit.setFontFamily("Lucida Console") |
44 self.helpEdit.setFontFamily("Lucida Console") |
44 else: |
45 else: |
82 @rtype bool |
83 @rtype bool |
83 """ |
84 """ |
84 doc = self.helpEdit.document() |
85 doc = self.helpEdit.document() |
85 cur = self.helpEdit.textCursor() |
86 cur = self.helpEdit.textCursor() |
86 |
87 |
87 findFlags = QTextDocument.FindFlags() |
88 findFlags = QTextDocument.FindFlag(0) |
88 if case: |
89 if case: |
89 findFlags |= QTextDocument.FindCaseSensitively |
90 findFlags |= QTextDocument.FindCaseSensitively |
90 if word: |
91 if word: |
91 findFlags |= QTextDocument.FindWholeWords |
92 findFlags |= QTextDocument.FindWholeWords |
92 if backwards: |
93 if backwards: |
93 findFlags |= QTextDocument.FindBackward |
94 findFlags |= QTextDocument.FindBackward |
94 |
95 |
95 if cur.hasSelection(): |
96 if cur.hasSelection(): |
96 cur.setPosition(backwards and cur.anchor() or cur.position(), |
97 cur.setPosition(backwards and cur.anchor() or cur.position(), |
97 QTextCursor.MoveAnchor) |
98 QTextCursor.MoveMode.MoveAnchor) |
98 newCur = doc.find(txt, cur, findFlags) |
99 newCur = doc.find(txt, cur, findFlags) |
99 if newCur.isNull(): |
100 if newCur.isNull(): |
100 return False |
101 return False |
101 else: |
102 else: |
102 self.helpEdit.setTextCursor(newCur) |
103 self.helpEdit.setTextCursor(newCur) |