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

2
qt/i2pd_qt/mainwindow.cpp

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

16
qt/i2pd_qt/mainwindow.h

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

Loading…
Cancel
Save