gui namespace

master
Marc Wäckerlin 16 years ago
parent ceb2bcca7e
commit 121637835c
  1. 254
      proxyface/proxy.hxx

@ -18,131 +18,135 @@
#include <QtCore/QDebug> #include <QtCore/QDebug>
class Proxy: public QDialog, public Ui::Proxy { namespace gui {
Q_OBJECT class Proxy: public QDialog, public Ui::Proxy {
public: Q_OBJECT
Proxy(QString testUrl, QWidget* p=0): QDialog(p), _testUrl(testUrl){ public:
setupUi(this);
QSettings s("SwissSign", "ProxySettings"); Proxy(QString testUrl, QWidget* p=0): QDialog(p), _testUrl(testUrl){
_type->setCurrentIndex(s.value("default-type", 0).toInt()); setupUi(this);
_url->setText(s.value("default-server", QString()).toString()); QSettings s("SwissSign", "ProxySettings");
_port->setValue(s.value("default-port", 0).toInt()); _type->setCurrentIndex(s.value("default-type", 0).toInt());
connect(&_auto, SIGNAL(proxyFound(const QUrl&, const QNetworkProxy&)), _url->setText(s.value("default-server", QString()).toString());
SIGNAL(proxyFound(const QUrl&, const QNetworkProxy&))); _port->setValue(s.value("default-port", 0).toInt());
connect(&_auto, SIGNAL(proxyFound(const QUrl&, const QNetworkProxy&)), connect(&_auto, SIGNAL(proxyFound(const QUrl&, const QNetworkProxy&)),
SLOT(proxyFoundSlot(const QUrl&, const QNetworkProxy&))); SIGNAL(proxyFound(const QUrl&, const QNetworkProxy&)));
connect(&_auto, SIGNAL(proxyError(QNetworkReply::NetworkError)), connect(&_auto, SIGNAL(proxyFound(const QUrl&, const QNetworkProxy&)),
SIGNAL(proxyError(QNetworkReply::NetworkError))); SLOT(proxyFoundSlot(const QUrl&, const QNetworkProxy&)));
accept(); connect(&_auto, SIGNAL(proxyError(QNetworkReply::NetworkError)),
} SIGNAL(proxyError(QNetworkReply::NetworkError)));
accept();
void checkUrl(const QString& url) { }
_testUrl = url;
accept(); void checkUrl(const QString& url) {
} _testUrl = url;
accept();
void acceptValues() {
QNetworkProxy::ProxyType type(QNetworkProxy::NoProxy);
switch (_type->currentIndex()) {
case 0: try {
_url->setEnabled(false);
_port->setEnabled(false);
type=QNetworkProxy::NoProxy;
_auto.proxy(_testUrl);
} catch (...) {} break;
case 1: type=QNetworkProxy::HttpProxy; break;
case 2: type=QNetworkProxy::Socks5Proxy; break;
} }
QNetworkProxy::setApplicationProxy
(QNetworkProxy(type, _url->text(), _port->value())); void acceptValues() {
qDebug()<<"Proxy:" QNetworkProxy::ProxyType type(QNetworkProxy::NoProxy);
<<(QNetworkProxy::applicationProxy().type() switch (_type->currentIndex()) {
==QNetworkProxy::NoProxy case 0: try {
?trUtf8("Kein Proxy") _url->setEnabled(false);
:QNetworkProxy::applicationProxy().type() _port->setEnabled(false);
==QNetworkProxy::HttpProxy type=QNetworkProxy::NoProxy;
?trUtf8("HTTP:") _auto.proxy(_testUrl);
:QNetworkProxy::applicationProxy().type() } catch (...) {} break;
==QNetworkProxy::Socks5Proxy case 1: type=QNetworkProxy::HttpProxy; break;
?trUtf8("Socks5Proxy:") case 2: type=QNetworkProxy::Socks5Proxy; break;
:trUtf8("System")) }
<<(QNetworkProxy::applicationProxy().type() QNetworkProxy::setApplicationProxy
==QNetworkProxy::NoProxy || (QNetworkProxy(type, _url->text(), _port->value()));
QNetworkProxy::applicationProxy().type() qDebug()<<"Proxy:"
==QNetworkProxy::DefaultProxy <<(QNetworkProxy::applicationProxy().type()
?QString() ==QNetworkProxy::NoProxy
:trUtf8("%1:%2", "proxy host/port") ?trUtf8("Kein Proxy")
.arg(QNetworkProxy::applicationProxy().hostName()) :QNetworkProxy::applicationProxy().type()
.arg(QNetworkProxy::applicationProxy().port())); ==QNetworkProxy::HttpProxy
} ?trUtf8("HTTP:")
:QNetworkProxy::applicationProxy().type()
Q_SIGNALS: ==QNetworkProxy::Socks5Proxy
?trUtf8("Socks5Proxy:")
void proxyFound(const QUrl&, const QNetworkProxy&); :trUtf8("System"))
void proxyError(QNetworkReply::NetworkError); <<(QNetworkProxy::applicationProxy().type()
==QNetworkProxy::NoProxy ||
public Q_SLOTS: QNetworkProxy::applicationProxy().type()
==QNetworkProxy::DefaultProxy
void proxyFoundSlot(const QUrl&, const QNetworkProxy& p) { ?QString()
QNetworkProxy::setApplicationProxy(p); :trUtf8("%1:%2", "proxy host/port")
_url->setText(p.hostName()); .arg(QNetworkProxy::applicationProxy().hostName())
_port->setValue(p.port()); .arg(QNetworkProxy::applicationProxy().port()));
qDebug()<<"Auto Proxy Found:" }
<<(QNetworkProxy::applicationProxy().type()
==QNetworkProxy::NoProxy Q_SIGNALS:
?trUtf8("Kein Proxy")
:QNetworkProxy::applicationProxy().type() void proxyFound(const QUrl&, const QNetworkProxy&);
==QNetworkProxy::HttpProxy void proxyError(QNetworkReply::NetworkError);
?trUtf8("HTTP:")
:QNetworkProxy::applicationProxy().type() public Q_SLOTS:
==QNetworkProxy::Socks5Proxy
?trUtf8("Socks5Proxy:") void proxyFoundSlot(const QUrl&, const QNetworkProxy& p) {
:trUtf8("System")) QNetworkProxy::setApplicationProxy(p);
<<(QNetworkProxy::applicationProxy().type() _url->setText(p.hostName());
==QNetworkProxy::NoProxy || _port->setValue(p.port());
QNetworkProxy::applicationProxy().type() qDebug()<<"Auto Proxy Found:"
==QNetworkProxy::DefaultProxy <<(QNetworkProxy::applicationProxy().type()
?QString() ==QNetworkProxy::NoProxy
:trUtf8("%1:%2", "proxy host/port") ?trUtf8("Kein Proxy")
.arg(QNetworkProxy::applicationProxy().hostName()) :QNetworkProxy::applicationProxy().type()
.arg(QNetworkProxy::applicationProxy().port())); ==QNetworkProxy::HttpProxy
} ?trUtf8("HTTP:")
:QNetworkProxy::applicationProxy().type()
void on__type_currentIndexChanged(int index) { ==QNetworkProxy::Socks5Proxy
_url->setEnabled(index!=0); ?trUtf8("Socks5Proxy:")
_port->setEnabled(index!=0); :trUtf8("System"))
} <<(QNetworkProxy::applicationProxy().type()
==QNetworkProxy::NoProxy ||
void on__save_clicked(bool=false) { QNetworkProxy::applicationProxy().type()
QSettings s("SwissSign", "ProxySettings"); ==QNetworkProxy::DefaultProxy
s.setValue("default-type", _type->currentIndex()); ?QString()
s.setValue("default-server", _url->text()); :trUtf8("%1:%2", "proxy host/port")
s.setValue("default-port", _port->value()); .arg(QNetworkProxy::applicationProxy().hostName())
acceptValues(); .arg(QNetworkProxy::applicationProxy().port()));
} }
void on__clear_clicked(bool=false) { void on__type_currentIndexChanged(int index) {
QSettings s("SwissSign", "ProxySettings"); _url->setEnabled(index!=0);
s.clear(); _port->setEnabled(index!=0);
_type->setCurrentIndex(0); }
_url->setText("");
_port->setValue(80); void on__save_clicked(bool=false) {
acceptValues(); QSettings s("SwissSign", "ProxySettings");
} s.setValue("default-type", _type->currentIndex());
s.setValue("default-server", _url->text());
virtual void accept() { s.setValue("default-port", _port->value());
acceptValues(); acceptValues();
QDialog::accept(); }
}
void on__clear_clicked(bool=false) {
private: QSettings s("SwissSign", "ProxySettings");
s.clear();
proxy::Face _auto; _type->setCurrentIndex(0);
QUrl _testUrl; _url->setText("");
_port->setValue(80);
}; acceptValues();
}
virtual void accept() {
acceptValues();
QDialog::accept();
}
private:
proxy::Face _auto;
QUrl _testUrl;
};
}
#endif #endif

Loading…
Cancel
Save