We now allow providing a networks.ini that contains a predefined list of networks/servers.
When adding a network, one can choose a preset from that list to have server properties
filled in automatically. This should make it much easier for users to add networks.
For adding a custom network, we allow entering the most important data right in the dialog,
to avoid useless clicks.
endif(WANT_MONO)
if(WANT_MONO OR WANT_QTCLIENT)
- install(FILES quassel.notifyrc DESTINATION ${DATA_INSTALL_DIR}/quassel)
+ install(FILES quassel.notifyrc networks.ini
+ DESTINATION ${DATA_INSTALL_DIR}/quassel)
endif(WANT_MONO OR WANT_QTCLIENT)
--- /dev/null
+[Freenode]
+Default=Yes
+DefaultChannels=#kubuntu,#quassel
+Servers=irc.freenode.net:6667,chat.freenode.net:6667,kornbluth.freenode.net:6668
+
+[Quakenet]
+Servers=irc.quakenet.net:6667
--- /dev/null
+<ui version="4.0" >
+ <class>NetworkAddDlg</class>
+ <widget class="QDialog" name="NetworkAddDlg" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>421</width>
+ <height>275</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Add Network</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2" >
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2" >
+ <item>
+ <widget class="QRadioButton" name="usePreset" >
+ <property name="text" >
+ <string>Use preset:</string>
+ </property>
+ <property name="checked" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="presetList" />
+ </item>
+ <item>
+ <spacer name="horizontalSpacer" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="useManual" >
+ <property name="text" >
+ <string>Manually specify network settings</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox" >
+ <property name="enabled" >
+ <bool>false</bool>
+ </property>
+ <property name="title" >
+ <string>Manual Settings</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout" >
+ <item>
+ <layout class="QGridLayout" name="gridLayout" >
+ <item row="0" column="0" >
+ <widget class="QLabel" name="label_3" >
+ <property name="text" >
+ <string>Network name:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" colspan="3" >
+ <widget class="QLineEdit" name="networkName" />
+ </item>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="label" >
+ <property name="text" >
+ <string>Server address:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QLineEdit" name="serverAddress" />
+ </item>
+ <item row="1" column="2" >
+ <widget class="QLabel" name="label_2" >
+ <property name="text" >
+ <string>Port:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="3" >
+ <widget class="QSpinBox" name="port" >
+ <property name="minimum" >
+ <number>0</number>
+ </property>
+ <property name="maximum" >
+ <number>65535</number>
+ </property>
+ <property name="value" >
+ <number>6667</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="label_4" >
+ <property name="text" >
+ <string>Server password:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" colspan="3" >
+ <widget class="QLineEdit" name="serverPassword" >
+ <property name="echoMode" >
+ <enum>QLineEdit::Password</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="useSSL" >
+ <property name="text" >
+ <string>Use secure connection</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer" >
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>20</width>
+ <height>31</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons" >
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>NetworkAddDlg</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>NetworkAddDlg</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>usePreset</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>presetList</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>53</x>
+ <y>18</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>132</x>
+ <y>17</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>useManual</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>groupBox</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>46</x>
+ <y>47</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>59</x>
+ <y>84</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>useManual</sender>
+ <signal>clicked()</signal>
+ <receiver>networkName</receiver>
+ <slot>setFocus()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>26</x>
+ <y>45</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>153</x>
+ <y>113</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
#include "iconloader.h"
#include "identity.h"
#include "network.h"
-
+#include "util.h"
NetworksSettingsPage::NetworksSettingsPage(QWidget *parent) : SettingsPage(tr("General"), tr("Networks"), parent) {
ui.setupUi(this);
void NetworksSettingsPage::on_addNetwork_clicked() {
QStringList existing;
for(int i = 0; i < ui.networkList->count(); i++) existing << ui.networkList->item(i)->text();
- NetworkEditDlg dlg(QString(), existing, this);
+ NetworkAddDlg dlg(existing, this);
if(dlg.exec() == QDialog::Accepted) {
NetworkId id;
for(id = 1; id <= networkInfos.count(); id++) {
if(!networkInfos.keys().contains(-id.toInt())) break;
}
id = -id.toInt();
- NetworkInfo info;
+
+ NetworkInfo info = dlg.networkInfo();
+ if(info.networkName.isEmpty())
+ return; // sanity check
info.networkId = id;
- info.networkName = dlg.networkName();
info.identity = 1;
// defaults
widgetHasChanged();
}
+/**************************************************************************
+* NetworkAddDlg
+*************************************************************************/
+
+NetworkAddDlg::NetworkAddDlg(const QStringList &exist, QWidget *parent) : QDialog(parent), existing(exist) {
+ ui.setupUi(this);
+ ui.useSSL->setIcon(SmallIcon("document-encrypt"));
+
+ // read preset networks
+ networksFilePath = findDataFilePath("networks.ini");
+ if(!networksFilePath.isEmpty()) {
+ QSettings s(networksFilePath, QSettings::IniFormat);
+ QStringList networks = s.childGroups();
+ foreach(QString s, existing)
+ networks.removeAll(s);
+ if(!networks.isEmpty())
+ networks.sort();
+ ui.presetList->addItems(networks);
+ }
+ if(!ui.presetList->count()) {
+ ui.useManual->setChecked(true);
+ ui.usePreset->setEnabled(false);
+ }
+ connect(ui.networkName, SIGNAL(textChanged(const QString &)), SLOT(setButtonStates()));
+ connect(ui.serverAddress, SIGNAL(textChanged(const QString &)), SLOT(setButtonStates()));
+ setButtonStates();
+}
+
+NetworkInfo NetworkAddDlg::networkInfo() const {
+ NetworkInfo info;
+
+ if(ui.useManual->isChecked()) {
+ info.networkName = ui.networkName->text().trimmed();
+ info.serverList << Network::Server(ui.serverAddress->text().trimmed(), ui.port->value(), ui.serverPassword->text(), ui.useSSL->isChecked());
+ } else {
+ info.networkName = ui.presetList->currentText();
+ QSettings s(networksFilePath, QSettings::IniFormat);
+ s.beginGroup(info.networkName);
+ foreach(QString server, s.value("Servers").toStringList()) {
+ bool ssl = false;
+ QStringList splitserver = server.split(':', QString::SkipEmptyParts);
+ if(splitserver.count() != 2) {
+ qWarning() << "Invalid server entry in networks.conf:" << server;
+ continue;
+ }
+ if(splitserver[1].at(0) == '+')
+ ssl = true;
+ uint port = splitserver[1].toUInt();
+ if(!port) {
+ qWarning() << "Invalid port entry in networks.conf:" << server;
+ continue;
+ }
+ info.serverList << Network::Server(splitserver[0].trimmed(), port, QString(), ssl);
+ }
+ }
+
+ return info;
+}
+
+void NetworkAddDlg::setButtonStates() {
+ bool ok = false;
+ if(ui.usePreset->isChecked() && ui.presetList->count())
+ ok = true;
+ else if(ui.useManual->isChecked()) {
+ ok = !ui.networkName->text().trimmed().isEmpty() && !existing.contains(ui.networkName->text().trimmed())
+ && !ui.serverAddress->text().isEmpty();
+ }
+ ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ok);
+}
+
/**************************************************************************
* NetworkEditDlg
*************************************************************************/
ui.buttonBox->button(QDialogButtonBox::Ok)->setDisabled(text.isEmpty() || existing.contains(text.trimmed()));
}
-
/**************************************************************************
* ServerEditDlg
*************************************************************************/
#include "settingspage.h"
#include "ui_networkssettingspage.h"
+#include "ui_networkadddlg.h"
#include "ui_networkeditdlg.h"
#include "ui_servereditdlg.h"
#include "ui_saveidentitiesdlg.h"
void saveToNetworkInfo(NetworkInfo &);
};
+
+class NetworkAddDlg : public QDialog {
+ Q_OBJECT
+
+ public:
+ NetworkAddDlg(const QStringList &existing = QStringList(), QWidget *parent = 0);
+
+ NetworkInfo networkInfo() const;
+
+ private slots:
+ void setButtonStates();
+
+ private:
+ Ui::NetworkAddDlg ui;
+
+ QString networksFilePath;
+ QStringList existing;
+};
+
+
class NetworkEditDlg : public QDialog {
Q_OBJECT
};
-
class ServerEditDlg : public QDialog {
Q_OBJECT
# Specify additional files (e.g. for subdialogs) here!
set(SP_SOURCES aliasesmodel.cpp notificationssettingspage.cpp)
set(SP_HEADERS aliasesmodel.h notificationssettingspage.h previewbufferview.h)
-set(SP_FORMS buffervieweditdlg.ui createidentitydlg.ui saveidentitiesdlg.ui networkeditdlg.ui nickeditdlg.ui servereditdlg.ui)
+set(SP_FORMS buffervieweditdlg.ui createidentitydlg.ui saveidentitiesdlg.ui networkadddlg.ui networkeditdlg.ui nickeditdlg.ui servereditdlg.ui)