1 /***************************************************************************
2 * Copyright (C) 2005-2014 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
21 #include "connectionsettingspage.h"
24 #include "networkconfig.h"
26 ConnectionSettingsPage::ConnectionSettingsPage(QWidget *parent)
27 : SettingsPage(tr("IRC"), QString(), parent)
32 connect(Client::instance(), SIGNAL(connected()), this, SLOT(clientConnected()));
33 connect(Client::instance(), SIGNAL(disconnected()), this, SLOT(clientDisconnected()));
36 if (Client::isConnected())
41 void ConnectionSettingsPage::clientConnected()
43 if (Client::networkConfig()->isInitialized())
46 connect(Client::networkConfig(), SIGNAL(initDone()), SLOT(initDone()));
50 void ConnectionSettingsPage::clientDisconnected()
53 setChangedState(false);
57 void ConnectionSettingsPage::initDone()
63 bool ConnectionSettingsPage::hasDefaults() const
69 QVariant ConnectionSettingsPage::loadAutoWidgetValue(const QString &widgetName)
73 NetworkConfig *config = Client::networkConfig();
74 if (widgetName == "pingTimeoutEnabled")
75 return config->pingTimeoutEnabled();
76 if (widgetName == "pingInterval")
77 return config->pingInterval();
78 if (widgetName == "maxPingCount")
79 return config->maxPingCount();
80 if (widgetName == "autoWhoEnabled")
81 return config->autoWhoEnabled();
82 if (widgetName == "autoWhoInterval")
83 return config->autoWhoInterval();
84 if (widgetName == "autoWhoNickLimit")
85 return config->autoWhoNickLimit();
86 if (widgetName == "autoWhoDelay")
87 return config->autoWhoDelay();
88 if (widgetName == "standardCtcp")
89 return config->standardCtcp();
91 return SettingsPage::loadAutoWidgetValue(widgetName);
95 void ConnectionSettingsPage::saveAutoWidgetValue(const QString &widgetName, const QVariant &value)
99 NetworkConfig *config = Client::networkConfig();
100 if (widgetName == "pingTimeoutEnabled")
101 config->requestSetPingTimeoutEnabled(value.toBool());
102 else if (widgetName == "pingInterval")
103 config->requestSetPingInterval(value.toInt());
104 else if (widgetName == "maxPingCount")
105 config->requestSetMaxPingCount(value.toInt());
106 else if (widgetName == "autoWhoEnabled")
107 config->requestSetAutoWhoEnabled(value.toBool());
108 else if (widgetName == "autoWhoInterval")
109 config->requestSetAutoWhoInterval(value.toInt());
110 else if (widgetName == "autoWhoNickLimit")
111 config->requestSetAutoWhoNickLimit(value.toInt());
112 else if (widgetName == "autoWhoDelay")
113 config->requestSetAutoWhoDelay(value.toInt());
114 else if (widgetName == "standardCtcp")
115 config->requestSetStandardCtcp(value.toBool());
118 SettingsPage::saveAutoWidgetValue(widgetName, value);