Sat, 23 Dec 2023 15:48:12 +0100
Updated copyright for 2024.
7810
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
10439
21c28b0f9e41
Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
3 | # Copyright (c) 2020 - 2024 Detlev Offenbach <detlev@die-offenbachs.de> |
7810
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a dialog to show some plain text. |
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
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
|
10 | from PyQt6.QtCore import pyqtSlot |
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
11 | from PyQt6.QtGui import QGuiApplication |
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.QtWidgets import QDialog, QDialogButtonBox |
7810
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
14 | from .Ui_EricPlainTextDialog import Ui_EricPlainTextDialog |
7810
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | |
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
17 | class EricPlainTextDialog(QDialog, Ui_EricPlainTextDialog): |
7810
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | """ |
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | Class implementing a dialog to show some plain text. |
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
21 | |
9093
437bfe0c5793
Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8881
diff
changeset
|
22 | def __init__(self, title="", text="", readOnly=True, parent=None): |
7810
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | """ |
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
25 | |
9093
437bfe0c5793
Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8881
diff
changeset
|
26 | @param title title of the dialog (defaults to "") |
437bfe0c5793
Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8881
diff
changeset
|
27 | @type str (optional) |
437bfe0c5793
Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8881
diff
changeset
|
28 | @param text text to be shown (defaults to "") |
437bfe0c5793
Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8881
diff
changeset
|
29 | @type str (optional) |
437bfe0c5793
Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8881
diff
changeset
|
30 | @param readOnly flag indicating a read-only dialog (defaults to True) |
437bfe0c5793
Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8881
diff
changeset
|
31 | @type bool (optional) |
437bfe0c5793
Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8881
diff
changeset
|
32 | @param parent reference to the parent widget (defaults to None) |
437bfe0c5793
Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8881
diff
changeset
|
33 | @type QWidget (optional) |
7810
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | """ |
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
|
35 | super().__init__(parent) |
7810
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | self.setupUi(self) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
37 | |
7810
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | self.copyButton = self.buttonBox.addButton( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
39 | self.tr("Copy to Clipboard"), QDialogButtonBox.ButtonRole.ActionRole |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
40 | ) |
7810
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | self.copyButton.clicked.connect(self.on_copyButton_clicked) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
42 | |
7810
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | self.setWindowTitle(title) |
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | self.textEdit.setPlainText(text) |
9093
437bfe0c5793
Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8881
diff
changeset
|
45 | self.textEdit.setReadOnly(readOnly) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
46 | |
7810
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | @pyqtSlot() |
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | def on_copyButton_clicked(self): |
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | """ |
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | Private slot to copy the text to the clipboard. |
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | """ |
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | txt = self.textEdit.toPlainText() |
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | cb = QGuiApplication.clipboard() |
f8afd2238723
Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | cb.setText(txt) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
55 | |
9093
437bfe0c5793
Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8881
diff
changeset
|
56 | def toPlainText(self): |
437bfe0c5793
Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8881
diff
changeset
|
57 | """ |
437bfe0c5793
Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8881
diff
changeset
|
58 | Public method to get the plain text. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
59 | |
9093
437bfe0c5793
Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8881
diff
changeset
|
60 | @return contents of the plain text edit |
437bfe0c5793
Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8881
diff
changeset
|
61 | @rtype str |
437bfe0c5793
Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8881
diff
changeset
|
62 | """ |
437bfe0c5793
Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8881
diff
changeset
|
63 | return self.textEdit.toPlainText() |