Mon, 23 May 2022 17:18:58 +0200
Implemented the functionality to show the output of the last test run (i.e. the output sent by the test runner).
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 | |
8881
54e42bc2437a
Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8358
diff
changeset
|
3 | # Copyright (c) 2020 - 2022 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 | """ |
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
|
21 | 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
|
22 | """ |
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 | Constructor |
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 | |
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
|
25 | @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
|
26 | @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
|
27 | @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
|
28 | @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
|
29 | @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
|
30 | @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
|
31 | @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
|
32 | @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
|
33 | """ |
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
|
34 | 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
|
35 | self.setupUi(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
|
36 | |
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
|
37 | self.copyButton = self.buttonBox.addButton( |
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
|
38 | self.tr("Copy to Clipboard"), |
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
|
39 | QDialogButtonBox.ButtonRole.ActionRole) |
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
|
40 | self.copyButton.clicked.connect(self.on_copyButton_clicked) |
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 | |
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
|
42 | 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
|
43 | 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
|
44 | self.textEdit.setReadOnly(readOnly) |
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
|
45 | |
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
|
46 | @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
|
47 | 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
|
48 | """ |
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 | 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
|
50 | """ |
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 | 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
|
52 | 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
|
53 | cb.setText(txt) |
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
|
54 | |
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
|
55 | 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
|
56 | """ |
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 | Public method to get the plain text. |
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 | |
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
|
59 | @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
|
60 | @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
|
61 | """ |
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 | return self.textEdit.toPlainText() |