HTTP-Proxy support is untestet though -> any feedback is welcomed.
I'm unhappy with the design of the dialog though... maybe someone comes up with something prettier
#include "clientsyncer.h"
+#include <QNetworkProxy>
+
#include "client.h"
#include "global.h"
#include "identity.h"
//emit coreConnectionMsg(tr("Connecting..."));
Q_ASSERT(!socket);
QTcpSocket *sock = new QTcpSocket(Client::instance());
+ if(conn.contains("useProxy") && conn["useProxy"].toBool()) {
+ QNetworkProxy proxy((QNetworkProxy::ProxyType)conn["proxyType"].toInt(), conn["proxyHost"].toString(), conn["proxyPort"].toUInt(), conn["proxyUser"].toString(), conn["proxyPassword"].toString());
+ sock->setProxy(proxy);
+ }
socket = sock;
connect(sock, SIGNAL(readyRead()), this, SLOT(coreHasData()));
connect(sock, SIGNAL(connected()), this, SLOT(coreSocketConnected()));
#include <QDebug>
#include <QMessageBox>
+#include <QNetworkProxy>
#include "coreconnectdlg.h"
existing = _existing;
account = acct;
if(id.isValid()) {
+ // add new settings
+ if(!acct.contains("useProxy")) {
+ account["useProxy"] = false;
+ account["proxyHost"] = "localhost";
+ account["proxyPort"] = 8080;
+ account["proxyType"] = QNetworkProxy::Socks5Proxy;
+ account["proxyUser"] = "";
+ account["proxyPassword"] = "";
+ }
existing.removeAll(acct["AccountName"].toString());
ui.host->setText(acct["Host"].toString());
ui.port->setValue(acct["Port"].toUInt());
ui.useInternal->setChecked(acct["UseInternal"].toBool());
ui.accountName->setText(acct["AccountName"].toString());
+ ui.useProxy->setChecked(account["useProxy"].toBool());
+ ui.proxyHost->setText(account["proxyHost"].toString());
+ ui.proxyPort->setValue(account["proxyPort"].toUInt());
+ ui.proxyType->setCurrentIndex(account["proxyType"].toInt() == QNetworkProxy::Socks5Proxy ? 0 : 1);
+ ui.proxyHost->setText(account["proxyUser"].toString());
+ ui.proxyHost->setText(account["proxyPassword"].toString());
} else {
setWindowTitle(tr("Add Core Account"));
}
account["Host"] = ui.host->text().trimmed();
account["Port"] = ui.port->value();
account["UseInternal"] = ui.useInternal->isChecked();
+ account["useProxy"] = ui.useProxy->isChecked();
+ account["proxyHost"] = ui.proxyHost->text().trimmed();
+ account["proxyPort"] = ui.proxyPort->value();
+ account["proxyType"] = ui.proxyType->currentIndex() == 0 ? QNetworkProxy::Socks5Proxy : QNetworkProxy::HttpProxy;
+ account["proxyUser"] = ui.proxyUser->text().trimmed();
+ account["proxyPassword"] = ui.proxyPassword->text().trimmed();
return account;
}
//Category: General
settingsDlg->registerSettingsPage(new IdentitiesSettingsPage(settingsDlg));
settingsDlg->registerSettingsPage(new NetworksSettingsPage(settingsDlg));
- // settingsDlg->registerSettingsPage(new BufferViewSettingsPage(settingsDlg));
+ settingsDlg->registerSettingsPage(new BufferViewSettingsPage(settingsDlg));
}
void MainWin::setupNickWidget() {
connect(Client::instance(), SIGNAL(coreConnectionStateChanged(bool)), this, SLOT(coreConnectionStateChanged(bool)));
}
+BufferViewSettingsPage::~BufferViewSettingsPage() {
+ reset();
+}
+
void BufferViewSettingsPage::reset() {
- // currentId = 0;
ui.bufferViewList->clear();
_viewToListPos.clear();
_listPosToView.clear();
+
+ QHash<BufferViewConfig *, BufferViewConfig *>::iterator changedConfigIter = _changedBufferViews.begin();
+ QHash<BufferViewConfig *, BufferViewConfig *>::iterator changedConfigIterEnd = _changedBufferViews.end();
+ BufferViewConfig *config;
+ while(changedConfigIter != changedConfigIterEnd) {
+ config = (*changedConfigIter);
+ changedConfigIter = _changedBufferViews.erase(changedConfigIter);
+ config->deleteLater();
+ }
+
+ QList<BufferViewConfig *>::iterator newConfigIter = _newBufferViews.begin();
+ QList<BufferViewConfig *>::iterator newConfigIterEnd = _newBufferViews.end();
+ while(newConfigIter != newConfigIterEnd) {
+ config = *newConfigIter;
+ newConfigIter = _newBufferViews.erase(newConfigIter);
+ config->deleteLater();
+ }
+
+ setChangedState(false);
}
void BufferViewSettingsPage::load() {
void BufferViewSettingsPage::newBufferView(const QString &bufferViewName) {
// id's of newly created bufferviews are negative (-1, -2... -n)
int fakeId = -1 * (_newBufferViews.count() + 1);
- addBufferView(new BufferViewConfig(fakeId));
+ BufferViewConfig *config = new BufferViewConfig(fakeId);
+ config->setBufferViewName(bufferViewName);
+ _newBufferViews << config;
+ addBufferView(config);
}
int BufferViewSettingsPage::listPos(BufferViewConfig *config) {
BufferViewEditDlg dlg(QString(), existing, this);
if(dlg.exec() == QDialog::Accepted) {
newBufferView(dlg.bufferViewName());
+ changed();
}
}
}
BufferViewEditDlg dlg(config->bufferViewName(), existing, this);
- if(dlg.exec() != QDialog::Accepted)
- return;
-
- BufferViewConfig *changedConfig;
- if(!_changedBufferViews.contains(config)) {
- _changedBufferViews[config] = new BufferViewConfig(-1);
- _changedBufferViews[config]->fromVariantMap(config->toVariantMap());
+ if(dlg.exec() == QDialog::Accepted) {
+ BufferViewConfig *changedConfig = cloneConfig(config);
+ changedConfig->setBufferViewName(dlg.bufferViewName());
+ changed();
}
-
- changedConfig = _changedBufferViews[config];
- changedConfig->setBufferViewName(dlg.bufferViewName());
- changed();
+}
+
+BufferViewConfig *BufferViewSettingsPage::cloneConfig(BufferViewConfig *config) {
+ if(_changedBufferViews.contains(config))
+ return _changedBufferViews[config];
+
+ BufferViewConfig *changedConfig = new BufferViewConfig(-1, this);
+ changedConfig->fromVariantMap(config->toVariantMap());
+ return changedConfig;
+}
+
+BufferViewConfig *BufferViewSettingsPage::configForDisplay(BufferViewConfig *config) {
+ if(_changedBufferViews.contains(config))
+ return _changedBufferViews[config];
+ else
+ return config;
}
public:
BufferViewSettingsPage(QWidget *parent = 0);
+ ~BufferViewSettingsPage();
public slots:
void save();
int listPos(BufferViewConfig *config);
int bufferViewId(int listPos);
+ BufferViewConfig *cloneConfig(BufferViewConfig *config);
+ BufferViewConfig *configForDisplay(BufferViewConfig *config);
};
<rect>
<x>0</x>
<y>0</y>
- <width>395</width>
- <height>242</height>
+ <width>514</width>
+ <height>534</height>
</rect>
</property>
<property name="windowTitle" >
</layout>
</item>
<item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
+ <widget class="QGroupBox" name="useProxy" >
+ <property name="title" >
+ <string>Use a proxy:</string>
</property>
- <property name="sizeHint" >
- <size>
- <width>20</width>
- <height>40</height>
- </size>
+ <property name="checkable" >
+ <bool>true</bool>
</property>
- </spacer>
+ <property name="checked" >
+ <bool>false</bool>
+ </property>
+ <layout class="QGridLayout" >
+ <item row="0" column="0" colspan="2" >
+ <widget class="QLabel" name="label_5" >
+ <property name="text" >
+ <string>Proxy Type:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2" >
+ <widget class="QComboBox" name="proxyType" >
+ <item>
+ <property name="text" >
+ <string>Socks 5</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>HTTP</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2" >
+ <widget class="QLabel" name="label_6" >
+ <property name="text" >
+ <string>Proxy Host:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2" >
+ <widget class="QLabel" name="label_7" >
+ <property name="text" >
+ <string>Proxy Port:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" colspan="2" >
+ <widget class="QLineEdit" name="proxyHost" >
+ <property name="text" >
+ <string>localhost</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2" >
+ <widget class="QSpinBox" name="proxyPort" >
+ <property name="maximum" >
+ <number>10000</number>
+ </property>
+ <property name="value" >
+ <number>8080</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" >
+ <widget class="QLabel" name="label_8" >
+ <property name="text" >
+ <string>Proxy Username:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" colspan="2" >
+ <widget class="QLineEdit" name="proxyUser" />
+ </item>
+ <item row="4" column="0" >
+ <widget class="QLabel" name="label_9" >
+ <property name="text" >
+ <string>Proxy Password:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1" colspan="2" >
+ <widget class="QLineEdit" name="proxyPassword" />
+ </item>
+ </layout>
+ </widget>
</item>
</layout>
</widget>
</item>
+ <item>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
<item>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
- <x>263</x>
- <y>230</y>
+ <x>275</x>
+ <y>521</y>
</hint>
<hint type="destinationlabel" >
<x>157</x>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
- <x>331</x>
- <y>230</y>
+ <x>343</x>
+ <y>521</y>
</hint>
<hint type="destinationlabel" >
<x>286</x>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
- <x>30</x>
- <y>79</y>
+ <x>63</x>
+ <y>100</y>
</hint>
<hint type="destinationlabel" >
<x>92</x>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
- <x>39</x>
- <y>78</y>
+ <x>63</x>
+ <y>100</y>
</hint>
<hint type="destinationlabel" >
- <x>331</x>
+ <x>400</x>
<y>144</y>
</hint>
</hints>
<slot>setFocus()</slot>
<hints>
<hint type="sourcelabel" >
- <x>26</x>
- <y>113</y>
+ <x>59</x>
+ <y>126</y>
</hint>
<hint type="destinationlabel" >
<x>184</x>
{ using namespace Global;
quasselVersion = "0.2.0-alpha4-pre";
- quasselDate = "2008-03-27";
- quasselBuild = 661;
+ quasselDate = "2008-03-29";
+ quasselBuild = 664;
//! Minimum client build number the core needs
clientBuildNeeded = 642;