From e477cf441b6a8651672cc1941460817042d9d78f Mon Sep 17 00:00:00 2001 From: Gitea Date: Sun, 14 Aug 2022 12:56:49 +0800 Subject: [PATCH 1/2] fixed #40 --- src/ServerTunnelPane.cpp | 7 ++++--- src/ServerTunnelPane.h | 11 ++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/ServerTunnelPane.cpp b/src/ServerTunnelPane.cpp index cd751f5..ea8f376 100644 --- a/src/ServerTunnelPane.cpp +++ b/src/ServerTunnelPane.cpp @@ -31,8 +31,8 @@ int ServerTunnelPane::appendServerTunnelForm( gridLayoutWidget_2->setGeometry(QRect(0, 0, 561, h)); serverTunnelNameGroupBox->setGeometry(QRect(0, 0, 561, h)); + const QString& type = tunnelConfig->getType(); { - const QString& type = tunnelConfig->getType(); int index=0; if(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_SERVER)tunnelTypeComboBox->setCurrentIndex(index); ++index; @@ -137,7 +137,8 @@ int ServerTunnelPane::appendServerTunnelForm( horizontalLayout_2->addItem(horizontalSpacer); tunnelGridLayout->addLayout(horizontalLayout_2); } - { + + if(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_HTTP) { std::string hostOverride = tunnelConfig->gethostOverride(); QHBoxLayout *horizontalLayout_2 = new QHBoxLayout(); horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2")); @@ -148,7 +149,7 @@ int ServerTunnelPane::appendServerTunnelForm( hostOverrideLineEdit->setObjectName(QStringLiteral("hostOverrideLineEdit")); hostOverrideLineEdit->setText(hostOverride.c_str()); QObject::connect(hostOverrideLineEdit, SIGNAL(textChanged(const QString &)), - this, SLOT(updated())); + this, SLOT(updated())); horizontalLayout_2->addWidget(hostOverrideLineEdit); QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); horizontalLayout_2->addItem(horizontalSpacer); diff --git a/src/ServerTunnelPane.h b/src/ServerTunnelPane.h index de84424..f9f53b9 100644 --- a/src/ServerTunnelPane.h +++ b/src/ServerTunnelPane.h @@ -107,7 +107,8 @@ private: inPortLabel->setText(QApplication::translate("srvTunForm", "InPort:", 0)); cryptoTypeLabel->setText(QApplication::translate("srvTunForm", "Crypto type:", 0)); accessListLabel->setText(QApplication::translate("srvTunForm", "Access list:", 0)); - hostOverrideLabel->setText(QApplication::translate("srvTunForm", "Host override:", 0)); + if(tunnelConfig->getType()==i2p::client::I2P_TUNNELS_SECTION_TYPE_HTTP) + hostOverrideLabel->setText(QApplication::translate("srvTunForm", "Host override:", 0)); webIRCPassLabel->setText(QApplication::translate("srvTunForm", "WebIRC password:", 0)); addressLabel->setText(QApplication::translate("srvTunForm", "Address:", 0)); @@ -131,7 +132,9 @@ protected: if(!isValidSingleLine(keysLineEdit))return false; if(!isValidSingleLine(inPortLineEdit))return false; if(!isValidSingleLine(accessListLineEdit))return false; - if(!isValidSingleLine(hostOverrideLineEdit))return false; + if(stc->getType()==i2p::client::I2P_TUNNELS_SECTION_TYPE_HTTP) { + if(!isValidSingleLine(hostOverrideLineEdit))return false; + } if(!isValidSingleLine(webIRCPassLineEdit))return false; if(!isValidSingleLine(addressLineEdit))return false; @@ -165,7 +168,9 @@ protected: stc->setaccessList(accessListLineEdit->text().toStdString()); - stc->sethostOverride(hostOverrideLineEdit->text().toStdString()); + if(stc->getType()==i2p::client::I2P_TUNNELS_SECTION_TYPE_HTTP) { + stc->sethostOverride(hostOverrideLineEdit->text().toStdString()); + } stc->setwebircpass(webIRCPassLineEdit->text().toStdString()); From 6ee6d92a96d9c2b96e03d29f080cbbd1d34a2fb4 Mon Sep 17 00:00:00 2001 From: Gitea Date: Sun, 14 Aug 2022 13:21:57 +0800 Subject: [PATCH 2/2] fixed --- src/ServerTunnelPane.cpp | 4 +++- src/ServerTunnelPane.h | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ServerTunnelPane.cpp b/src/ServerTunnelPane.cpp index ea8f376..7423221 100644 --- a/src/ServerTunnelPane.cpp +++ b/src/ServerTunnelPane.cpp @@ -138,19 +138,21 @@ int ServerTunnelPane::appendServerTunnelForm( tunnelGridLayout->addLayout(horizontalLayout_2); } - if(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_HTTP) { + { std::string hostOverride = tunnelConfig->gethostOverride(); QHBoxLayout *horizontalLayout_2 = new QHBoxLayout(); horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2")); ui.hostOverrideLabel = new QLabel(gridLayoutWidget_2); hostOverrideLabel->setObjectName(QStringLiteral("hostOverrideLabel")); horizontalLayout_2->addWidget(hostOverrideLabel); + hostOverrideLabel->setEnabled(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_HTTP); ui.hostOverrideLineEdit = new QLineEdit(gridLayoutWidget_2); hostOverrideLineEdit->setObjectName(QStringLiteral("hostOverrideLineEdit")); hostOverrideLineEdit->setText(hostOverride.c_str()); QObject::connect(hostOverrideLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(updated())); horizontalLayout_2->addWidget(hostOverrideLineEdit); + hostOverrideLineEdit->setEnabled(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_HTTP); QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); horizontalLayout_2->addItem(horizontalSpacer); tunnelGridLayout->addLayout(horizontalLayout_2); diff --git a/src/ServerTunnelPane.h b/src/ServerTunnelPane.h index f9f53b9..64fee10 100644 --- a/src/ServerTunnelPane.h +++ b/src/ServerTunnelPane.h @@ -107,8 +107,7 @@ private: inPortLabel->setText(QApplication::translate("srvTunForm", "InPort:", 0)); cryptoTypeLabel->setText(QApplication::translate("srvTunForm", "Crypto type:", 0)); accessListLabel->setText(QApplication::translate("srvTunForm", "Access list:", 0)); - if(tunnelConfig->getType()==i2p::client::I2P_TUNNELS_SECTION_TYPE_HTTP) - hostOverrideLabel->setText(QApplication::translate("srvTunForm", "Host override:", 0)); + hostOverrideLabel->setText(QApplication::translate("srvTunForm", "Host override:", 0)); webIRCPassLabel->setText(QApplication::translate("srvTunForm", "WebIRC password:", 0)); addressLabel->setText(QApplication::translate("srvTunForm", "Address:", 0)); @@ -181,6 +180,10 @@ protected: stc->setisUniqueLocal(isUniqueLocalCheckBox->isChecked()); stc->setsigType(readSigTypeComboboxUI(sigTypeComboBox)); + + hostOverrideLabel->setEnabled(stc->getType()==i2p::client::I2P_TUNNELS_SECTION_TYPE_HTTP); + hostOverrideLineEdit->setEnabled(stc->getType()==i2p::client::I2P_TUNNELS_SECTION_TYPE_HTTP); + return true; } };