1 module ircclient.ui.settings;
2 
3 import dlangui.core.settings;
4 
5 class IRCSettings : SettingsFile {
6     this(string filename) {
7         super(filename);
8     }
9 
10     IRCSettings clone() {
11         IRCSettings res = new IRCSettings(filename);
12         res.applySettings(setting);
13         return res;
14     }
15 
16     override void updateDefaults() {
17         // def server
18         serverSettings.setStringDef("host", "irc.freenode.net");
19         serverSettings.setUintegerDef("port", 6667);
20         // def user
21         userSettings.setStringDef("username", "user");
22         userSettings.setStringDef("realname", "User");
23         userSettings.setStringDef("nick", "dlanguiIRC");
24         userSettings.setStringDef("alternick", "d_IRC_client");
25         // channel settings
26         channelSettings.setStringDef("channelName", "#d");
27         channelSettings.setBooleanDef("joinOnConnect", true);
28     }
29 
30     @property Setting serverSettings() { return _setting.objectByPath("server", true); }
31 
32     @property string host() { return serverSettings.getString("host", "irc.freenode.net"); }
33     @property void host(string s) { serverSettings.setString("host", s); }
34     @property ushort port() { return cast(ushort)serverSettings.getUinteger("port", 6667); }
35     @property void port(ushort v) { serverSettings.setUinteger("port", v); }
36 
37     @property Setting channelSettings() { return _setting.objectByPath("channels/startup", true); }
38 
39     @property string defChannel() { return channelSettings.getString("channelName", ""); }
40     @property void defChannel(string s) { channelSettings.setString("channelName", s); }
41     @property bool joinOnConnect() { return channelSettings.getBoolean("joinOnConnect", true); }
42     @property void joinOnConnect(bool v) { channelSettings.setBoolean("joinOnConnect", v); }
43 
44     @property Setting userSettings() { return _setting.objectByPath("user", true); }
45 
46     @property string nick() { return userSettings.getString("nick", ""); }
47     @property void nick(string s) { userSettings.setString("nick", s); }
48     @property string alternateNick() { return userSettings.getString("alternick", ""); }
49     @property void alternateNick(string s) { userSettings.setString("alternick", s); }
50     @property string userName() { return userSettings.getString("username", "user"); }
51     @property void userName(string s) { userSettings.setString("username", s); }
52     @property string userRealName() { return userSettings.getString("realname", "User"); }
53     @property void userRealName(string s) { userSettings.setString("realname", s); }
54 
55 }
56 
57