1 /***************************************************************************
2 * Copyright (C) 2005-09 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) any later version. *
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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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())
40 void ConnectionSettingsPage::clientConnected() {
41 if(Client::networkConfig()->isInitialized())
44 connect(Client::networkConfig(), SIGNAL(initDone()), SLOT(initDone()));
47 void ConnectionSettingsPage::clientDisconnected() {
49 setChangedState(false);
52 void ConnectionSettingsPage::initDone() {
56 bool ConnectionSettingsPage::hasDefaults() const {
60 QVariant ConnectionSettingsPage::loadAutoWidgetValue(const QString &widgetName) {
63 NetworkConfig *config = Client::networkConfig();
64 if(widgetName == "pingTimeoutEnabled")
65 return config->pingTimeoutEnabled();
66 if(widgetName == "pingInterval")
67 return config->pingInterval();
68 if(widgetName == "maxPingCount")
69 return config->maxPingCount();
70 if(widgetName == "autoWhoEnabled")
71 return config->autoWhoEnabled();
72 if(widgetName == "autoWhoInterval")
73 return config->autoWhoInterval();
74 if(widgetName == "autoWhoNickLimit")
75 return config->autoWhoNickLimit();
76 if(widgetName == "autoWhoDelay")
77 return config->autoWhoDelay();
79 return SettingsPage::loadAutoWidgetValue(widgetName);
82 void ConnectionSettingsPage::saveAutoWidgetValue(const QString &widgetName, const QVariant &value) {
85 NetworkConfig *config = Client::networkConfig();
86 if(widgetName == "pingTimeoutEnabled")
87 config->requestSetPingTimeoutEnabled(value.toBool());
88 else if(widgetName == "pingInterval")
89 config->requestSetPingInterval(value.toInt());
90 else if(widgetName == "maxPingCount")
91 config->requestSetMaxPingCount(value.toInt());
92 else if(widgetName == "autoWhoEnabled")
93 config->requestSetAutoWhoEnabled(value.toBool());
94 else if(widgetName == "autoWhoInterval")
95 config->requestSetAutoWhoInterval(value.toInt());
96 else if(widgetName == "autoWhoNickLimit")
97 config->requestSetAutoWhoNickLimit(value.toInt());
98 else if(widgetName == "autoWhoDelay")
99 config->requestSetAutoWhoDelay(value.toInt());
102 SettingsPage::saveAutoWidgetValue(widgetName, value);