1 /***************************************************************************
2 * Copyright (C) 2005-2020 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(), &Client::connected, this, &ConnectionSettingsPage::clientConnected);
33 connect(Client::instance(), &Client::disconnected, this, &ConnectionSettingsPage::clientDisconnected);
36 if (Client::isConnected())
40 void ConnectionSettingsPage::clientConnected()
42 if (Client::networkConfig()->isInitialized())
45 connect(Client::networkConfig(), &SyncableObject::initDone, this, &ConnectionSettingsPage::initDone);
48 void ConnectionSettingsPage::clientDisconnected()
51 setChangedState(false);
54 void ConnectionSettingsPage::initDone()
59 bool ConnectionSettingsPage::hasDefaults() const
64 QVariant ConnectionSettingsPage::loadAutoWidgetValue(const QString& widgetName)
68 NetworkConfig* config = Client::networkConfig();
69 if (widgetName == "pingTimeoutEnabled")
70 return config->pingTimeoutEnabled();
71 if (widgetName == "pingInterval")
72 return config->pingInterval();
73 if (widgetName == "maxPingCount")
74 return config->maxPingCount();
75 if (widgetName == "autoWhoEnabled")
76 return config->autoWhoEnabled();
77 if (widgetName == "autoWhoInterval")
78 return config->autoWhoInterval();
79 if (widgetName == "autoWhoNickLimit")
80 return config->autoWhoNickLimit();
81 if (widgetName == "autoWhoDelay")
82 return config->autoWhoDelay();
83 if (widgetName == "standardCtcp")
84 return config->standardCtcp();
86 return SettingsPage::loadAutoWidgetValue(widgetName);
89 void ConnectionSettingsPage::saveAutoWidgetValue(const QString& widgetName, const QVariant& value)
93 NetworkConfig* config = Client::networkConfig();
94 if (widgetName == "pingTimeoutEnabled")
95 config->requestSetPingTimeoutEnabled(value.toBool());
96 else if (widgetName == "pingInterval")
97 config->requestSetPingInterval(value.toInt());
98 else if (widgetName == "maxPingCount")
99 config->requestSetMaxPingCount(value.toInt());
100 else if (widgetName == "autoWhoEnabled")
101 config->requestSetAutoWhoEnabled(value.toBool());
102 else if (widgetName == "autoWhoInterval")
103 config->requestSetAutoWhoInterval(value.toInt());
104 else if (widgetName == "autoWhoNickLimit")
105 config->requestSetAutoWhoNickLimit(value.toInt());
106 else if (widgetName == "autoWhoDelay")
107 config->requestSetAutoWhoDelay(value.toInt());
108 else if (widgetName == "standardCtcp")
109 config->requestSetStandardCtcp(value.toBool());
112 SettingsPage::saveAutoWidgetValue(widgetName, value);