|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2006 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the Log Viewer configuration page. |
|
8 """ |
|
9 |
|
10 from PyQt6.QtCore import pyqtSlot |
|
11 from PyQt6.QtGui import QColor |
|
12 |
|
13 from .ConfigurationPageBase import ConfigurationPageBase |
|
14 from .Ui_LogViewerPage import Ui_LogViewerPage |
|
15 |
|
16 import Preferences |
|
17 |
|
18 |
|
19 class LogViewerPage(ConfigurationPageBase, Ui_LogViewerPage): |
|
20 """ |
|
21 Class implementing the Log Viewer configuration page. |
|
22 """ |
|
23 def __init__(self, parent=None): |
|
24 """ |
|
25 Constructor |
|
26 |
|
27 @param parent reference to the parent widget (QWidget) |
|
28 """ |
|
29 super().__init__() |
|
30 self.setupUi(self) |
|
31 self.setObjectName("LogViewerPage") |
|
32 |
|
33 self.stdoutFilterEdit.setListWhatsThis(self.tr( |
|
34 "<b>Message Filters for Standard Output</b>" |
|
35 "<p>This list shows the configured message filters used to" |
|
36 " suppress messages received via stdout.</p>" |
|
37 )) |
|
38 self.stderrFilterEdit.setListWhatsThis(self.tr( |
|
39 "<b>Message Filters for Standard Error </b>" |
|
40 "<p>This list shows the configured message filters used to" |
|
41 " suppress messages received via stderr.</p>" |
|
42 )) |
|
43 self.stdxxxFilterEdit.setListWhatsThis(self.tr( |
|
44 "<b>Message Filters for both</b>" |
|
45 "<p>This list shows the configured message filters used to" |
|
46 " suppress messages received via stdout or stderr.</p>" |
|
47 )) |
|
48 |
|
49 self.colourChanged.connect(self.__colorChanged) |
|
50 |
|
51 # set initial values |
|
52 self.lvAutoRaiseCheckBox.setChecked( |
|
53 Preferences.getUI("LogViewerAutoRaise")) |
|
54 |
|
55 self.initColour( |
|
56 "LogStdErrColour", self.stderrTextColourButton, |
|
57 Preferences.getUI) |
|
58 |
|
59 self.stdoutFilterEdit.setList( |
|
60 Preferences.getUI("LogViewerStdoutFilter")) |
|
61 self.stderrFilterEdit.setList( |
|
62 Preferences.getUI("LogViewerStderrFilter")) |
|
63 self.stdxxxFilterEdit.setList( |
|
64 Preferences.getUI("LogViewerStdxxxFilter")) |
|
65 |
|
66 def save(self): |
|
67 """ |
|
68 Public slot to save the Interface configuration. |
|
69 """ |
|
70 Preferences.setUI( |
|
71 "LogViewerAutoRaise", |
|
72 self.lvAutoRaiseCheckBox.isChecked()) |
|
73 |
|
74 self.saveColours(Preferences.setUI) |
|
75 |
|
76 Preferences.setUI( |
|
77 "LogViewerStdoutFilter", |
|
78 self.stdoutFilterEdit.getList()) |
|
79 Preferences.setUI( |
|
80 "LogViewerStderrFilter", |
|
81 self.stderrFilterEdit.getList()) |
|
82 Preferences.setUI( |
|
83 "LogViewerStdxxxFilter", |
|
84 self.stdxxxFilterEdit.getList()) |
|
85 |
|
86 @pyqtSlot(str, QColor) |
|
87 def __colorChanged(self, colorKey, color): |
|
88 """ |
|
89 Private slot handling the selection of a color. |
|
90 |
|
91 @param colorKey key of the color entry |
|
92 @type str |
|
93 @param color selected color |
|
94 @type QColor |
|
95 """ |
|
96 if colorKey == "LogStdErrColour": |
|
97 self.errorTextExample.setStyleSheet(f"color: {color.name()}") |
|
98 |
|
99 |
|
100 def create(dlg): |
|
101 """ |
|
102 Module function to create the configuration page. |
|
103 |
|
104 @param dlg reference to the configuration dialog |
|
105 @return reference to the instantiated page (ConfigurationPageBase) |
|
106 """ |
|
107 page = LogViewerPage() |
|
108 return page |