|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2012 - 2025 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the IRC configuration page. |
|
8 """ |
|
9 |
|
10 from eric7.Preferences.ConfigurationPages.ConfigurationPageBase import ( |
|
11 ConfigurationPageBase, |
|
12 ) |
|
13 |
|
14 from .Ui_IrcPage import Ui_IrcPage |
|
15 |
|
16 |
|
17 class IrcPage(ConfigurationPageBase, Ui_IrcPage): |
|
18 """ |
|
19 Class implementing the IRC configuration page. |
|
20 """ |
|
21 |
|
22 TimeFormats = ["hh:mm", "hh:mm:ss", "h:mm ap", "h:mm:ss ap"] |
|
23 DateFormats = [ |
|
24 "yyyy-MM-dd", |
|
25 "dd.MM.yyyy", |
|
26 "MM/dd/yyyy", |
|
27 "yyyy MMM. dd", |
|
28 "dd MMM. yyyy", |
|
29 "MMM. dd, yyyy", |
|
30 ] |
|
31 |
|
32 def __init__(self, plugin): |
|
33 """ |
|
34 Constructor |
|
35 |
|
36 @param plugin reference to the plugin object |
|
37 @type PluginPipxInterface |
|
38 """ |
|
39 super().__init__() |
|
40 self.setupUi(self) |
|
41 self.setObjectName("IrcPage") |
|
42 |
|
43 self.__plugin = plugin |
|
44 |
|
45 self.timeFormatCombo.addItems(IrcPage.TimeFormats) |
|
46 self.dateFormatCombo.addItems(IrcPage.DateFormats) |
|
47 |
|
48 # set initial values |
|
49 # timestamps |
|
50 self.timestampGroup.setChecked(self.__plugin.getPreferences("ShowTimestamps")) |
|
51 self.showDateCheckBox.setChecked( |
|
52 self.__plugin.getPreferences("TimestampIncludeDate") |
|
53 ) |
|
54 self.timeFormatCombo.setCurrentIndex( |
|
55 self.timeFormatCombo.findText(self.__plugin.getPreferences("TimeFormat")) |
|
56 ) |
|
57 self.dateFormatCombo.setCurrentIndex( |
|
58 self.dateFormatCombo.findText(self.__plugin.getPreferences("DateFormat")) |
|
59 ) |
|
60 |
|
61 # colours |
|
62 self.initColour( |
|
63 "NetworkMessageColour", |
|
64 self.networkButton, |
|
65 self.__plugin.getPreferences, |
|
66 byName=True, |
|
67 ) |
|
68 self.initColour( |
|
69 "ServerMessageColour", |
|
70 self.serverButton, |
|
71 self.__plugin.getPreferences, |
|
72 byName=True, |
|
73 ) |
|
74 self.initColour( |
|
75 "ErrorMessageColour", |
|
76 self.errorButton, |
|
77 self.__plugin.getPreferences, |
|
78 byName=True, |
|
79 ) |
|
80 self.initColour( |
|
81 "TimestampColour", |
|
82 self.timestampButton, |
|
83 self.__plugin.getPreferences, |
|
84 byName=True, |
|
85 ) |
|
86 self.initColour( |
|
87 "HyperlinkColour", |
|
88 self.hyperlinkButton, |
|
89 self.__plugin.getPreferences, |
|
90 byName=True, |
|
91 ) |
|
92 self.initColour( |
|
93 "ChannelMessageColour", |
|
94 self.channelButton, |
|
95 self.__plugin.getPreferences, |
|
96 byName=True, |
|
97 ) |
|
98 self.initColour( |
|
99 "OwnNickColour", |
|
100 self.ownNickButton, |
|
101 self.__plugin.getPreferences, |
|
102 byName=True, |
|
103 ) |
|
104 self.initColour( |
|
105 "NickColour", self.nickButton, self.__plugin.getPreferences, byName=True |
|
106 ) |
|
107 self.initColour( |
|
108 "JoinChannelColour", |
|
109 self.joinButton, |
|
110 self.__plugin.getPreferences, |
|
111 byName=True, |
|
112 ) |
|
113 self.initColour( |
|
114 "LeaveChannelColour", |
|
115 self.leaveButton, |
|
116 self.__plugin.getPreferences, |
|
117 byName=True, |
|
118 ) |
|
119 self.initColour( |
|
120 "ChannelInfoColour", |
|
121 self.infoButton, |
|
122 self.__plugin.getPreferences, |
|
123 byName=True, |
|
124 ) |
|
125 |
|
126 # notifications |
|
127 self.notificationsGroup.setChecked( |
|
128 self.__plugin.getPreferences("ShowNotifications") |
|
129 ) |
|
130 self.joinLeaveCheckBox.setChecked( |
|
131 self.__plugin.getPreferences("NotifyJoinPart") |
|
132 ) |
|
133 self.messageCheckBox.setChecked(self.__plugin.getPreferences("NotifyMessage")) |
|
134 self.ownNickCheckBox.setChecked(self.__plugin.getPreferences("NotifyNick")) |
|
135 |
|
136 # IRC text colors |
|
137 self.initColour( |
|
138 "IrcColor0", self.ircColor0Button, self.__plugin.getPreferences, byName=True |
|
139 ) |
|
140 self.initColour( |
|
141 "IrcColor1", self.ircColor1Button, self.__plugin.getPreferences, byName=True |
|
142 ) |
|
143 self.initColour( |
|
144 "IrcColor2", self.ircColor2Button, self.__plugin.getPreferences, byName=True |
|
145 ) |
|
146 self.initColour( |
|
147 "IrcColor3", self.ircColor3Button, self.__plugin.getPreferences, byName=True |
|
148 ) |
|
149 self.initColour( |
|
150 "IrcColor4", self.ircColor4Button, self.__plugin.getPreferences, byName=True |
|
151 ) |
|
152 self.initColour( |
|
153 "IrcColor5", self.ircColor5Button, self.__plugin.getPreferences, byName=True |
|
154 ) |
|
155 self.initColour( |
|
156 "IrcColor6", self.ircColor6Button, self.__plugin.getPreferences, byName=True |
|
157 ) |
|
158 self.initColour( |
|
159 "IrcColor7", self.ircColor7Button, self.__plugin.getPreferences, byName=True |
|
160 ) |
|
161 self.initColour( |
|
162 "IrcColor8", self.ircColor8Button, self.__plugin.getPreferences, byName=True |
|
163 ) |
|
164 self.initColour( |
|
165 "IrcColor9", self.ircColor9Button, self.__plugin.getPreferences, byName=True |
|
166 ) |
|
167 self.initColour( |
|
168 "IrcColor10", |
|
169 self.ircColor10Button, |
|
170 self.__plugin.getPreferences, |
|
171 byName=True, |
|
172 ) |
|
173 self.initColour( |
|
174 "IrcColor11", |
|
175 self.ircColor11Button, |
|
176 self.__plugin.getPreferences, |
|
177 byName=True, |
|
178 ) |
|
179 self.initColour( |
|
180 "IrcColor12", |
|
181 self.ircColor12Button, |
|
182 self.__plugin.getPreferences, |
|
183 byName=True, |
|
184 ) |
|
185 self.initColour( |
|
186 "IrcColor13", |
|
187 self.ircColor13Button, |
|
188 self.__plugin.getPreferences, |
|
189 byName=True, |
|
190 ) |
|
191 self.initColour( |
|
192 "IrcColor14", |
|
193 self.ircColor14Button, |
|
194 self.__plugin.getPreferences, |
|
195 byName=True, |
|
196 ) |
|
197 self.initColour( |
|
198 "IrcColor15", |
|
199 self.ircColor15Button, |
|
200 self.__plugin.getPreferences, |
|
201 byName=True, |
|
202 ) |
|
203 |
|
204 # Automatic User Information Lookup |
|
205 self.whoGroup.setChecked(self.__plugin.getPreferences("AutoUserInfoLookup")) |
|
206 self.whoUsersSpinBox.setValue(self.__plugin.getPreferences("AutoUserInfoMax")) |
|
207 self.whoIntervalSpinBox.setValue( |
|
208 self.__plugin.getPreferences("AutoUserInfoInterval") |
|
209 ) |
|
210 |
|
211 # Markers |
|
212 self.markWhenHiddenCheckBox.setChecked( |
|
213 self.__plugin.getPreferences("MarkPositionWhenHidden") |
|
214 ) |
|
215 self.initColour( |
|
216 "MarkerLineForegroundColour", |
|
217 self.markerForegroundButton, |
|
218 self.__plugin.getPreferences, |
|
219 byName=True, |
|
220 ) |
|
221 self.initColour( |
|
222 "MarkerLineBackgroundColour", |
|
223 self.markerBackgroundButton, |
|
224 self.__plugin.getPreferences, |
|
225 byName=True, |
|
226 ) |
|
227 |
|
228 def save(self): |
|
229 """ |
|
230 Public slot to save the IRC configuration. |
|
231 """ |
|
232 # timestamps |
|
233 self.__plugin.setPreferences("ShowTimestamps", self.timestampGroup.isChecked()) |
|
234 self.__plugin.setPreferences( |
|
235 "TimestampIncludeDate", self.showDateCheckBox.isChecked() |
|
236 ) |
|
237 self.__plugin.setPreferences("TimeFormat", self.timeFormatCombo.currentText()) |
|
238 self.__plugin.setPreferences("DateFormat", self.dateFormatCombo.currentText()) |
|
239 |
|
240 # notifications |
|
241 self.__plugin.setPreferences( |
|
242 "ShowNotifications", self.notificationsGroup.isChecked() |
|
243 ) |
|
244 self.__plugin.setPreferences( |
|
245 "NotifyJoinPart", self.joinLeaveCheckBox.isChecked() |
|
246 ) |
|
247 self.__plugin.setPreferences("NotifyMessage", self.messageCheckBox.isChecked()) |
|
248 self.__plugin.setPreferences("NotifyNick", self.ownNickCheckBox.isChecked()) |
|
249 |
|
250 # Automatic User Information Lookup |
|
251 self.__plugin.setPreferences("AutoUserInfoLookup", self.whoGroup.isChecked()) |
|
252 self.__plugin.setPreferences("AutoUserInfoMax", self.whoUsersSpinBox.value()) |
|
253 self.__plugin.setPreferences( |
|
254 "AutoUserInfoInterval", self.whoIntervalSpinBox.value() |
|
255 ) |
|
256 |
|
257 # Markers |
|
258 self.__plugin.setPreferences( |
|
259 "MarkPositionWhenHidden", self.markWhenHiddenCheckBox.isChecked() |
|
260 ) |
|
261 |
|
262 # colours |
|
263 self.saveColours(self.__plugin.setPreferences) |