1 /***************************************************************************
2 * Copyright (C) 2005-2016 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 #ifndef NETWORKSSETTINGSPAGE_H
22 #define NETWORKSSETTINGSPAGE_H
27 #include "settingspage.h"
28 #include "clientidentity.h"
30 #include "ui_networkssettingspage.h"
31 #include "ui_networkadddlg.h"
32 #include "ui_networkeditdlg.h"
33 #include "ui_servereditdlg.h"
34 #include "ui_saveidentitiesdlg.h"
36 class NetworksSettingsPage : public SettingsPage
41 NetworksSettingsPage(QWidget *parent = 0);
43 virtual inline bool needsCoreConnection() const { return true; }
52 void widgetHasChanged();
53 void setWidgetStates();
54 void coreConnectionStateChanged(bool);
55 void networkConnectionStateChanged(Network::ConnectionState state);
56 void networkConnectionError(const QString &msg);
58 void displayNetwork(NetworkId);
59 void setItemState(NetworkId, QListWidgetItem *item = 0);
62 * Update the capability-dependent settings according to what the server supports
64 * For example, this updates the SASL text for when the server advertises support. This should
65 * only be called on the currently displayed network.
67 * @param[in] id NetworkId referencing network used to update settings user interface.
69 void setNetworkCapStates(NetworkId id);
71 void clientNetworkAdded(NetworkId);
72 void clientNetworkRemoved(NetworkId);
73 void clientNetworkUpdated();
75 void clientIdentityAdded(IdentityId);
76 void clientIdentityRemoved(IdentityId);
77 void clientIdentityUpdated();
80 * Update the settings user interface according to capabilities advertised by the IRC server
82 void clientNetworkCapsUpdated();
88 void on_networkList_itemSelectionChanged();
89 void on_addNetwork_clicked();
90 void on_deleteNetwork_clicked();
91 void on_renameNetwork_clicked();
92 void on_editIdentities_clicked();
94 // void on_connectNow_clicked();
96 void on_serverList_itemSelectionChanged();
97 void on_addServer_clicked();
98 void on_deleteServer_clicked();
99 void on_editServer_clicked();
100 void on_upServer_clicked();
101 void on_downServer_clicked();
104 Ui::NetworksSettingsPage ui;
107 QHash<NetworkId, NetworkInfo> networkInfos;
108 bool _ignoreWidgetChanges;
113 QIcon connectedIcon, connectingIcon, disconnectedIcon;
116 bool testHasChanged();
117 QListWidgetItem *insertNetwork(NetworkId);
118 QListWidgetItem *insertNetwork(const NetworkInfo &info);
119 QListWidgetItem *networkItem(NetworkId) const;
120 void saveToNetworkInfo(NetworkInfo &);
121 IdentityId defaultIdentity() const;
125 class NetworkAddDlg : public QDialog
130 NetworkAddDlg(const QStringList &existing = QStringList(), QWidget *parent = 0);
132 NetworkInfo networkInfo() const;
135 void setButtonStates();
138 * Update the default server port according to isChecked
140 * Connect with useSSL->toggled() in order to keep the port number in sync. This only modifies
141 * the port if it's not been changed from defaults.
143 * @param isChecked If true and port unchanged, set port to 6697, else set port to 6667.
145 void updateSslPort(bool isChecked);
148 Ui::NetworkAddDlg ui;
150 QStringList existing;
154 class NetworkEditDlg : public QDialog
159 NetworkEditDlg(const QString &old, const QStringList &existing = QStringList(), QWidget *parent = 0);
161 QString networkName() const;
164 void on_networkEdit_textChanged(const QString &);
167 Ui::NetworkEditDlg ui;
169 QStringList existing;
173 class ServerEditDlg : public QDialog
178 ServerEditDlg(const Network::Server &server = Network::Server(), QWidget *parent = 0);
180 Network::Server serverData() const;
183 void on_host_textChanged();
186 * Update the default server port according to isChecked
188 * Connect with useSSL->toggled() in order to keep the port number in sync. This only modifies
189 * the port if it's not been changed from defaults.
191 * @param isChecked If true and port unchanged, set port to 6697, else set port to 6667.
193 void updateSslPort(bool isChecked);
196 Ui::ServerEditDlg ui;
200 class SaveNetworksDlg : public QDialog
205 SaveNetworksDlg(const QList<NetworkInfo> &toCreate, const QList<NetworkInfo> &toUpdate, const QList<NetworkId> &toRemove, QWidget *parent = 0);
211 Ui::SaveIdentitiesDlg ui;
213 int numevents, rcvevents;