Browse Source

http proxy and socks - initialized comboboxes correctly

pull/911/head
hypnosis-i2p 7 years ago
parent
commit
4776f11b6a
  1. 11
      qt/i2pd_qt/SignatureTypeComboboxFactory.h
  2. 2
      qt/i2pd_qt/mainwindow.cpp
  3. 16
      qt/i2pd_qt/mainwindow.h

11
qt/i2pd_qt/SignatureTypeComboboxFactory.h

@ -18,8 +18,11 @@ class SignatureTypeComboBoxFactory
} }
public: public:
static QComboBox* createSignatureTypeComboBox(QWidget* parent, uint16_t selectedSigType) { static const uint16_t getSigType(const QVariant& var) {
QComboBox* signatureTypeCombobox = new QComboBox(parent); return (uint16_t)var.toInt();
}
static void fillComboBox(QComboBox* signatureTypeCombobox, uint16_t selectedSigType) {
/* /*
<orignal> https://geti2p.net/spec/common-structures#certificate <orignal> https://geti2p.net/spec/common-structures#certificate
<orignal> все коды перечислены <orignal> все коды перечислены
@ -78,7 +81,11 @@ public:
addItem(signatureTypeCombobox, QString::number(selectedSigType), selectedSigType); //unknown sigtype addItem(signatureTypeCombobox, QString::number(selectedSigType), selectedSigType); //unknown sigtype
signatureTypeCombobox->setCurrentIndex(index); signatureTypeCombobox->setCurrentIndex(index);
} }
}
static QComboBox* createSignatureTypeComboBox(QWidget* parent, uint16_t selectedSigType) {
QComboBox* signatureTypeCombobox = new QComboBox(parent);
fillComboBox(signatureTypeCombobox, selectedSigType);
return signatureTypeCombobox; return signatureTypeCombobox;
} }
}; };

2
qt/i2pd_qt/mainwindow.cpp

@ -18,6 +18,7 @@
#include <fstream> #include <fstream>
#include "DaemonQT.h" #include "DaemonQT.h"
#include "SignatureTypeComboboxFactory.h"
std::string programOptionsWriterCurrentSection; std::string programOptionsWriterCurrentSection;
@ -123,6 +124,7 @@ MainWindow::MainWindow(QWidget *parent) :
initIPAddressBox( OPTION("httpproxy","address",[]{return "";}), ui->httpProxyAddressLineEdit, tr("HTTP proxy -> IP address")); initIPAddressBox( OPTION("httpproxy","address",[]{return "";}), ui->httpProxyAddressLineEdit, tr("HTTP proxy -> IP address"));
initTCPPortBox( OPTION("httpproxy","port",[]{return "4444";}), ui->httpProxyPortLineEdit, tr("HTTP proxy -> Port")); initTCPPortBox( OPTION("httpproxy","port",[]{return "4444";}), ui->httpProxyPortLineEdit, tr("HTTP proxy -> Port"));
initFileChooser( OPTION("httpproxy","keys",[]{return "";}), ui->httpProxyKeyFileLineEdit, ui->httpProxyKeyFilePushButton); initFileChooser( OPTION("httpproxy","keys",[]{return "";}), ui->httpProxyKeyFileLineEdit, ui->httpProxyKeyFilePushButton);
initSignatureTypeCombobox(OPTION("httpproxy","signaturetype",[]{return "7";}), ui->comboBox_httpPorxySignatureType); initSignatureTypeCombobox(OPTION("httpproxy","signaturetype",[]{return "7";}), ui->comboBox_httpPorxySignatureType);
initStringBox( OPTION("httpproxy","inbound.length",[]{return "3";}), ui->httpProxyInboundTunnelsLenLineEdit); initStringBox( OPTION("httpproxy","inbound.length",[]{return "3";}), ui->httpProxyInboundTunnelsLenLineEdit);
initStringBox( OPTION("httpproxy","inbound.quantity",[]{return "5";}), ui->httpProxyInboundTunnQuantityLineEdit); initStringBox( OPTION("httpproxy","inbound.quantity",[]{return "5";}), ui->httpProxyInboundTunnQuantityLineEdit);

16
qt/i2pd_qt/mainwindow.h

@ -52,6 +52,7 @@
#include "TunnelsPageUpdateListener.h" #include "TunnelsPageUpdateListener.h"
#include "DaemonQT.h" #include "DaemonQT.h"
#include "SignatureTypeComboboxFactory.h"
template<typename ValueType> template<typename ValueType>
bool isType(boost::any& a) { bool isType(boost::any& a) {
@ -218,16 +219,15 @@ class SignatureTypeComboBoxItem : public ComboBoxItem {
public: public:
SignatureTypeComboBoxItem(ConfigOption option_, QComboBox* comboBox_) : ComboBoxItem(option_, comboBox_) {}; SignatureTypeComboBoxItem(ConfigOption option_, QComboBox* comboBox_) : ComboBoxItem(option_, comboBox_) {};
virtual ~SignatureTypeComboBoxItem(){} virtual ~SignatureTypeComboBoxItem(){}
virtual void loadFromConfigOption(){//TODO virtual void loadFromConfigOption(){
MainWindowItem::loadFromConfigOption(); MainWindowItem::loadFromConfigOption();
comboBox->setCurrentText(QString::number(boost::any_cast<unsigned short>(optionValue))); while(comboBox->count()>0)comboBox->removeItem(0);
uint16_t selected = (uint16_t) boost::any_cast<unsigned short>(optionValue);
SignatureTypeComboBoxFactory::fillComboBox(comboBox, selected);
} }
virtual void saveToStringStream(std::stringstream& out){//TODO virtual void saveToStringStream(std::stringstream& out){
QString txt = comboBox->currentText(); uint16_t selected = SignatureTypeComboBoxFactory::getSigType(comboBox->currentData());
if(txt.isEmpty()) optionValue=(unsigned short)selected;
optionValue=std::string();
else
optionValue=(unsigned short)std::stoi(txt.toStdString());
MainWindowItem::saveToStringStream(out); MainWindowItem::saveToStringStream(out);
} }
virtual bool isValid() { return true; } virtual bool isValid() { return true; }

Loading…
Cancel
Save