|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2012 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the IRC configuration page. |
|
8 """ |
|
9 |
|
10 from .ConfigurationPageBase import ConfigurationPageBase |
|
11 from .Ui_IrcPage import Ui_IrcPage |
|
12 |
|
13 import Preferences |
|
14 |
|
15 |
|
16 class IrcPage(ConfigurationPageBase, Ui_IrcPage): |
|
17 """ |
|
18 Class implementing the IRC configuration page. |
|
19 """ |
|
20 TimeFormats = ["hh:mm", "hh:mm:ss", "h:mm ap", "h:mm:ss ap"] |
|
21 DateFormats = ["yyyy-MM-dd", "dd.MM.yyyy", "MM/dd/yyyy", |
|
22 "yyyy MMM. dd", "dd MMM. yyyy", "MMM. dd, yyyy"] |
|
23 |
|
24 def __init__(self): |
|
25 """ |
|
26 Constructor |
|
27 """ |
|
28 super().__init__() |
|
29 self.setupUi(self) |
|
30 self.setObjectName("IrcPage") |
|
31 |
|
32 self.timeFormatCombo.addItems(IrcPage.TimeFormats) |
|
33 self.dateFormatCombo.addItems(IrcPage.DateFormats) |
|
34 |
|
35 # set initial values |
|
36 # timestamps |
|
37 self.timestampGroup.setChecked(Preferences.getIrc("ShowTimestamps")) |
|
38 self.showDateCheckBox.setChecked( |
|
39 Preferences.getIrc("TimestampIncludeDate")) |
|
40 self.timeFormatCombo.setCurrentIndex( |
|
41 self.timeFormatCombo.findText(Preferences.getIrc("TimeFormat"))) |
|
42 self.dateFormatCombo.setCurrentIndex( |
|
43 self.dateFormatCombo.findText(Preferences.getIrc("DateFormat"))) |
|
44 |
|
45 # colours |
|
46 self.initColour("NetworkMessageColour", self.networkButton, |
|
47 Preferences.getIrc, byName=True) |
|
48 self.initColour("ServerMessageColour", self.serverButton, |
|
49 Preferences.getIrc, byName=True) |
|
50 self.initColour("ErrorMessageColour", self.errorButton, |
|
51 Preferences.getIrc, byName=True) |
|
52 self.initColour("TimestampColour", self.timestampButton, |
|
53 Preferences.getIrc, byName=True) |
|
54 self.initColour("HyperlinkColour", self.hyperlinkButton, |
|
55 Preferences.getIrc, byName=True) |
|
56 self.initColour("ChannelMessageColour", self.channelButton, |
|
57 Preferences.getIrc, byName=True) |
|
58 self.initColour("OwnNickColour", self.ownNickButton, |
|
59 Preferences.getIrc, byName=True) |
|
60 self.initColour("NickColour", self.nickButton, |
|
61 Preferences.getIrc, byName=True) |
|
62 self.initColour("JoinChannelColour", self.joinButton, |
|
63 Preferences.getIrc, byName=True) |
|
64 self.initColour("LeaveChannelColour", self.leaveButton, |
|
65 Preferences.getIrc, byName=True) |
|
66 self.initColour("ChannelInfoColour", self.infoButton, |
|
67 Preferences.getIrc, byName=True) |
|
68 |
|
69 # notifications |
|
70 self.notificationsGroup.setChecked( |
|
71 Preferences.getIrc("ShowNotifications")) |
|
72 self.joinLeaveCheckBox.setChecked(Preferences.getIrc("NotifyJoinPart")) |
|
73 self.messageCheckBox.setChecked(Preferences.getIrc("NotifyMessage")) |
|
74 self.ownNickCheckBox.setChecked(Preferences.getIrc("NotifyNick")) |
|
75 |
|
76 # IRC text colors |
|
77 self.initColour("IrcColor0", self.ircColor0Button, |
|
78 Preferences.getIrc, byName=True) |
|
79 self.initColour("IrcColor1", self.ircColor1Button, |
|
80 Preferences.getIrc, byName=True) |
|
81 self.initColour("IrcColor2", self.ircColor2Button, |
|
82 Preferences.getIrc, byName=True) |
|
83 self.initColour("IrcColor3", self.ircColor3Button, |
|
84 Preferences.getIrc, byName=True) |
|
85 self.initColour("IrcColor4", self.ircColor4Button, |
|
86 Preferences.getIrc, byName=True) |
|
87 self.initColour("IrcColor5", self.ircColor5Button, |
|
88 Preferences.getIrc, byName=True) |
|
89 self.initColour("IrcColor6", self.ircColor6Button, |
|
90 Preferences.getIrc, byName=True) |
|
91 self.initColour("IrcColor7", self.ircColor7Button, |
|
92 Preferences.getIrc, byName=True) |
|
93 self.initColour("IrcColor8", self.ircColor8Button, |
|
94 Preferences.getIrc, byName=True) |
|
95 self.initColour("IrcColor9", self.ircColor9Button, |
|
96 Preferences.getIrc, byName=True) |
|
97 self.initColour("IrcColor10", self.ircColor10Button, |
|
98 Preferences.getIrc, byName=True) |
|
99 self.initColour("IrcColor11", self.ircColor11Button, |
|
100 Preferences.getIrc, byName=True) |
|
101 self.initColour("IrcColor12", self.ircColor12Button, |
|
102 Preferences.getIrc, byName=True) |
|
103 self.initColour("IrcColor13", self.ircColor13Button, |
|
104 Preferences.getIrc, byName=True) |
|
105 self.initColour("IrcColor14", self.ircColor14Button, |
|
106 Preferences.getIrc, byName=True) |
|
107 self.initColour("IrcColor15", self.ircColor15Button, |
|
108 Preferences.getIrc, byName=True) |
|
109 |
|
110 # Automatic User Information Lookup |
|
111 self.whoGroup.setChecked(Preferences.getIrc("AutoUserInfoLookup")) |
|
112 self.whoUsersSpinBox.setValue(Preferences.getIrc("AutoUserInfoMax")) |
|
113 self.whoIntervalSpinBox.setValue( |
|
114 Preferences.getIrc("AutoUserInfoInterval")) |
|
115 |
|
116 # Markers |
|
117 self.markWhenHiddenCheckBox.setChecked( |
|
118 Preferences.getIrc("MarkPositionWhenHidden")) |
|
119 self.initColour("MarkerLineForegroundColour", |
|
120 self.markerForegroundButton, |
|
121 Preferences.getIrc, byName=True) |
|
122 self.initColour("MarkerLineBackgroundColour", |
|
123 self.markerBackgroundButton, |
|
124 Preferences.getIrc, byName=True) |
|
125 |
|
126 # Shutdown |
|
127 self.confirmShutdownCheckBox.setChecked( |
|
128 Preferences.getIrc("AskOnShutdown")) |
|
129 |
|
130 def save(self): |
|
131 """ |
|
132 Public slot to save the IRC configuration. |
|
133 """ |
|
134 # timestamps |
|
135 Preferences.setIrc("ShowTimestamps", self.timestampGroup.isChecked()) |
|
136 Preferences.setIrc( |
|
137 "TimestampIncludeDate", self.showDateCheckBox.isChecked()) |
|
138 Preferences.setIrc("TimeFormat", self.timeFormatCombo.currentText()) |
|
139 Preferences.setIrc("DateFormat", self.dateFormatCombo.currentText()) |
|
140 |
|
141 # notifications |
|
142 Preferences.setIrc( |
|
143 "ShowNotifications", self.notificationsGroup.isChecked()) |
|
144 Preferences.setIrc( |
|
145 "NotifyJoinPart", self.joinLeaveCheckBox.isChecked()) |
|
146 Preferences.setIrc("NotifyMessage", self.messageCheckBox.isChecked()) |
|
147 Preferences.setIrc("NotifyNick", self.ownNickCheckBox.isChecked()) |
|
148 |
|
149 # Automatic User Information Lookup |
|
150 Preferences.setIrc("AutoUserInfoLookup", self.whoGroup.isChecked()) |
|
151 Preferences.setIrc("AutoUserInfoMax", self.whoUsersSpinBox.value()) |
|
152 Preferences.setIrc( |
|
153 "AutoUserInfoInterval", self.whoIntervalSpinBox.value()) |
|
154 |
|
155 # Markers |
|
156 Preferences.setIrc( |
|
157 "MarkPositionWhenHidden", |
|
158 self.markWhenHiddenCheckBox.isChecked()) |
|
159 |
|
160 # Shutdown |
|
161 Preferences.setIrc( |
|
162 "AskOnShutdown", self.confirmShutdownCheckBox.isChecked()) |
|
163 |
|
164 # colours |
|
165 self.saveColours(Preferences.setIrc) |
|
166 |
|
167 |
|
168 def create(dlg): |
|
169 """ |
|
170 Module function to create the configuration page. |
|
171 |
|
172 @param dlg reference to the configuration dialog |
|
173 @return reference to the instantiated page (ConfigurationPageBase) |
|
174 """ |
|
175 page = IrcPage() |
|
176 return page |