mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-02 11:04:00 +01:00
some work on desktop qt gui
This commit is contained in:
parent
275da075e0
commit
b3050af1a7
|
@ -1,13 +1,16 @@
|
|||
#include "ClientTunnelPane.h"
|
||||
#include "../../ClientContext.h"
|
||||
|
||||
ClientTunnelPane::ClientTunnelPane()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ClientTunnelPane::setGroupBoxTitle(const QString & title) {
|
||||
clientTunnelNameGroupBox->setTitle(title);
|
||||
}
|
||||
|
||||
void ClientTunnelPane::deleteClientTunnelForm(QGridLayout *tunnelsFormGridLayout) {
|
||||
throw "TODO";
|
||||
/*TODO
|
||||
tunnelsFormGridLayout->removeWidget(clientTunnelNameGroupBox);
|
||||
|
||||
clientTunnelNameGroupBox->deleteLater();
|
||||
|
@ -15,7 +18,155 @@ void ClientTunnelPane::deleteClientTunnelForm(QGridLayout *tunnelsFormGridLayout
|
|||
|
||||
gridLayoutWidget_2->deleteLater();
|
||||
gridLayoutWidget_2=nullptr;
|
||||
}
|
||||
|
||||
void ClientTunnelPane::appendClientTunnelForm(
|
||||
ClientTunnelConfig* tunnelConfig, QWidget *tunnelsFormGridLayoutWidget, QGridLayout *tunnelsFormGridLayout, int tunnelsRow) {
|
||||
|
||||
ClientTunnelPane& ui = *this;
|
||||
|
||||
clientTunnelNameGroupBox = new QGroupBox(tunnelsFormGridLayoutWidget);
|
||||
clientTunnelNameGroupBox->setObjectName(QStringLiteral("clientTunnelNameGroupBox"));
|
||||
|
||||
//tunnel
|
||||
ui.gridLayoutWidget_2 = new QWidget(clientTunnelNameGroupBox);
|
||||
|
||||
QComboBox *tunnelTypeComboBox = new QComboBox(gridLayoutWidget_2);
|
||||
tunnelTypeComboBox->setObjectName(QStringLiteral("tunnelTypeComboBox"));
|
||||
tunnelTypeComboBox->addItem("Client", i2p::client::I2P_TUNNELS_SECTION_TYPE_CLIENT);
|
||||
tunnelTypeComboBox->addItem("Socks", i2p::client::I2P_TUNNELS_SECTION_TYPE_SOCKS);
|
||||
tunnelTypeComboBox->addItem("Websocks", i2p::client::I2P_TUNNELS_SECTION_TYPE_WEBSOCKS);
|
||||
tunnelTypeComboBox->addItem("HTTP Proxy", i2p::client::I2P_TUNNELS_SECTION_TYPE_HTTPPROXY);
|
||||
tunnelTypeComboBox->addItem("UDP Client", i2p::client::I2P_TUNNELS_SECTION_TYPE_UDPCLIENT);
|
||||
|
||||
gridLayoutWidget_2->setGeometry(QRect(0, 0, 561, (7+5)*40));
|
||||
|
||||
setupTunnelPane(tunnelConfig,
|
||||
clientTunnelNameGroupBox,
|
||||
gridLayoutWidget_2, tunnelTypeComboBox,
|
||||
tunnelsFormGridLayoutWidget, tunnelsFormGridLayout, tunnelsRow);
|
||||
//this->tunnelGroupBox->setGeometry(QRect(0, tunnelsFormGridLayoutWidget->height()+10, 561, (7+5)*40+10));
|
||||
{
|
||||
const QString& type = tunnelConfig->getType();
|
||||
int index=0;
|
||||
if(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_CLIENT)tunnelTypeComboBox->setCurrentIndex(index);
|
||||
++index;
|
||||
if(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_SOCKS)tunnelTypeComboBox->setCurrentIndex(index);
|
||||
++index;
|
||||
if(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_WEBSOCKS)tunnelTypeComboBox->setCurrentIndex(index);
|
||||
++index;
|
||||
if(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_HTTPPROXY)tunnelTypeComboBox->setCurrentIndex(index);
|
||||
++index;
|
||||
if(type==i2p::client::I2P_TUNNELS_SECTION_TYPE_UDPCLIENT)tunnelTypeComboBox->setCurrentIndex(index);
|
||||
++index;
|
||||
}
|
||||
|
||||
/*
|
||||
std::string destination;
|
||||
*/
|
||||
|
||||
//host
|
||||
ui.horizontalLayout_2 = new QHBoxLayout();
|
||||
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
|
||||
ui.destinationLabel = new QLabel(gridLayoutWidget_2);
|
||||
destinationLabel->setObjectName(QStringLiteral("destinationLabel"));
|
||||
horizontalLayout_2->addWidget(destinationLabel);
|
||||
ui.destinationLineEdit = new QLineEdit(gridLayoutWidget_2);
|
||||
destinationLineEdit->setObjectName(QStringLiteral("destinationLineEdit"));
|
||||
destinationLineEdit->setText(tunnelConfig->getdest().c_str());
|
||||
horizontalLayout_2->addWidget(destinationLineEdit);
|
||||
ui.destinationHorizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
horizontalLayout_2->addItem(destinationHorizontalSpacer);
|
||||
tunnelGridLayout->addLayout(horizontalLayout_2, 2, 0, 1, 1);
|
||||
|
||||
/*
|
||||
* int port;
|
||||
*/
|
||||
int gridIndex = 2;
|
||||
{
|
||||
int port = tunnelConfig->getport();
|
||||
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
|
||||
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
|
||||
ui.portLabel = new QLabel(gridLayoutWidget_2);
|
||||
portLabel->setObjectName(QStringLiteral("portLabel"));
|
||||
horizontalLayout_2->addWidget(portLabel);
|
||||
ui.portLineEdit = new QLineEdit(gridLayoutWidget_2);
|
||||
portLineEdit->setObjectName(QStringLiteral("portLineEdit"));
|
||||
portLineEdit->setText(QString::number(port));
|
||||
portLineEdit->setMaximumWidth(80);
|
||||
horizontalLayout_2->addWidget(portLineEdit);
|
||||
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
horizontalLayout_2->addItem(horizontalSpacer);
|
||||
tunnelGridLayout->addLayout(horizontalLayout_2, ++gridIndex, 0, 1, 1);
|
||||
}
|
||||
/*
|
||||
* std::string keys;
|
||||
*/
|
||||
{
|
||||
std::string keys = tunnelConfig->getkeys();
|
||||
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
|
||||
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
|
||||
ui.keysLabel = new QLabel(gridLayoutWidget_2);
|
||||
keysLabel->setObjectName(QStringLiteral("keysLabel"));
|
||||
horizontalLayout_2->addWidget(keysLabel);
|
||||
ui.keysLineEdit = new QLineEdit(gridLayoutWidget_2);
|
||||
keysLineEdit->setObjectName(QStringLiteral("keysLineEdit"));
|
||||
keysLineEdit->setText(keys.c_str());
|
||||
horizontalLayout_2->addWidget(keysLineEdit);
|
||||
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
horizontalLayout_2->addItem(horizontalSpacer);
|
||||
tunnelGridLayout->addLayout(horizontalLayout_2, ++gridIndex, 0, 1, 1);
|
||||
}
|
||||
/*
|
||||
* std::string address;
|
||||
*/
|
||||
{
|
||||
std::string address = tunnelConfig->getaddress();
|
||||
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
|
||||
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
|
||||
ui.addressLabel = new QLabel(gridLayoutWidget_2);
|
||||
addressLabel->setObjectName(QStringLiteral("addressLabel"));
|
||||
horizontalLayout_2->addWidget(addressLabel);
|
||||
ui.addressLineEdit = new QLineEdit(gridLayoutWidget_2);
|
||||
addressLineEdit->setObjectName(QStringLiteral("addressLineEdit"));
|
||||
addressLineEdit->setText(address.c_str());
|
||||
horizontalLayout_2->addWidget(addressLineEdit);
|
||||
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
horizontalLayout_2->addItem(horizontalSpacer);
|
||||
tunnelGridLayout->addLayout(horizontalLayout_2, ++gridIndex, 0, 1, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
int destinationPort;
|
||||
i2p::data::SigningKeyType sigType;
|
||||
*/
|
||||
{
|
||||
int destinationPort = tunnelConfig->getdestinationPort();
|
||||
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
|
||||
horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2"));
|
||||
ui.destinationPortLabel = new QLabel(gridLayoutWidget_2);
|
||||
destinationPortLabel->setObjectName(QStringLiteral("destinationPortLabel"));
|
||||
horizontalLayout_2->addWidget(destinationPortLabel);
|
||||
ui.destinationPortLineEdit = new QLineEdit(gridLayoutWidget_2);
|
||||
destinationPortLineEdit->setObjectName(QStringLiteral("destinationPortLineEdit"));
|
||||
destinationPortLineEdit->setText(QString::number(destinationPort));
|
||||
destinationPortLineEdit->setMaximumWidth(80);
|
||||
horizontalLayout_2->addWidget(destinationPortLineEdit);
|
||||
QSpacerItem * horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
horizontalLayout_2->addItem(horizontalSpacer);
|
||||
tunnelGridLayout->addLayout(horizontalLayout_2, ++gridIndex, 0, 1, 1);
|
||||
}
|
||||
{
|
||||
i2p::data::SigningKeyType sigType = tunnelConfig->getsigType();
|
||||
//combo box
|
||||
//TODO sigtype
|
||||
}
|
||||
{
|
||||
I2CPParameters& i2cpParameters = tunnelConfig->getI2cpParameters();
|
||||
appendControlsForI2CPParameters(i2cpParameters, gridIndex);
|
||||
}
|
||||
|
||||
retranslateClientTunnelForm(ui);
|
||||
}
|
||||
|
||||
ServerTunnelPane* ClientTunnelPane::asServerTunnelPane(){return nullptr;}
|
||||
|
|
|
@ -5,17 +5,61 @@
|
|||
|
||||
#include "TunnelPane.h"
|
||||
|
||||
class ClientTunnelConfig;
|
||||
|
||||
class ServerTunnelPane;
|
||||
class TunnelPane;
|
||||
|
||||
class ClientTunnelPane : public TunnelPane {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ClientTunnelPane();
|
||||
virtual ~ClientTunnelPane(){}
|
||||
virtual ServerTunnelPane* asServerTunnelPane();
|
||||
virtual ClientTunnelPane* asClientTunnelPane();
|
||||
void appendClientTunnelForm(ClientTunnelConfig* tunnelConfig, QWidget *tunnelsFormGridLayoutWidget,
|
||||
QGridLayout *tunnelsFormGridLayout, int tunnelsRow);
|
||||
void deleteClientTunnelForm(QGridLayout *tunnelsFormGridLayout);
|
||||
private:
|
||||
QGroupBox *clientTunnelNameGroupBox;
|
||||
|
||||
//tunnel
|
||||
QWidget *gridLayoutWidget_2;
|
||||
|
||||
//destination
|
||||
QHBoxLayout *horizontalLayout_2;
|
||||
QLabel *destinationLabel;
|
||||
QLineEdit *destinationLineEdit;
|
||||
QSpacerItem *destinationHorizontalSpacer;
|
||||
|
||||
//port
|
||||
QLabel * portLabel;
|
||||
QLineEdit * portLineEdit;
|
||||
|
||||
//keys
|
||||
QLabel * keysLabel;
|
||||
QLineEdit * keysLineEdit;
|
||||
|
||||
//address
|
||||
QLabel * addressLabel;
|
||||
QLineEdit * addressLineEdit;
|
||||
|
||||
//destinationPort
|
||||
QLabel * destinationPortLabel;
|
||||
QLineEdit * destinationPortLineEdit;
|
||||
|
||||
protected slots:
|
||||
virtual void setGroupBoxTitle(const QString & title){}//TODO
|
||||
virtual void setGroupBoxTitle(const QString & title);
|
||||
|
||||
private:
|
||||
void retranslateClientTunnelForm(ClientTunnelPane& /*ui*/) {
|
||||
destinationLabel->setText(QApplication::translate("srvTunForm", "Destination:", 0));
|
||||
portLabel->setText(QApplication::translate("srvTunForm", "Port:", 0));
|
||||
keysLabel->setText(QApplication::translate("srvTunForm", "Keys:", 0));
|
||||
destinationPortLabel->setText(QApplication::translate("srvTunForm", "Destination port:", 0));
|
||||
addressLabel->setText(QApplication::translate("srvTunForm", "Address:", 0));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // CLIENTTUNNELPANE_H
|
||||
|
|
|
@ -8,9 +8,7 @@ void ServerTunnelPane::setGroupBoxTitle(const QString & title) {
|
|||
}
|
||||
|
||||
void ServerTunnelPane::appendServerTunnelForm(
|
||||
ServerTunnelConfig* tunnelConfig, QWidget *tunnelsFormGridLayoutWidget, QGridLayout *tunnelsFormGridLayout) {
|
||||
|
||||
tunnelsFormGridLayoutWidget->resize(527, 452);
|
||||
ServerTunnelConfig* tunnelConfig, QWidget *tunnelsFormGridLayoutWidget, QGridLayout *tunnelsFormGridLayout, int tunnelsRow) {
|
||||
|
||||
ServerTunnelPane& ui = *this;
|
||||
|
||||
|
@ -27,12 +25,14 @@ void ServerTunnelPane::appendServerTunnelForm(
|
|||
tunnelTypeComboBox->addItem("IRC", i2p::client::I2P_TUNNELS_SECTION_TYPE_IRC);
|
||||
tunnelTypeComboBox->addItem("UDP Server", i2p::client::I2P_TUNNELS_SECTION_TYPE_UDPSERVER);
|
||||
|
||||
gridLayoutWidget_2->setGeometry(QRect(0, 10, 561, 18*40+10));
|
||||
gridLayoutWidget_2->setGeometry(QRect(0, 0, 561, 18*60));
|
||||
|
||||
|
||||
setupTunnelPane(tunnelConfig,
|
||||
serverTunnelNameGroupBox,
|
||||
gridLayoutWidget_2, tunnelTypeComboBox,
|
||||
tunnelsFormGridLayoutWidget, tunnelsFormGridLayout);
|
||||
tunnelsFormGridLayoutWidget, tunnelsFormGridLayout, tunnelsRow);
|
||||
//this->tunnelGroupBox->setGeometry(QRect(0, tunnelsFormGridLayoutWidget->height()+10, 561, 18*40+10));
|
||||
|
||||
{
|
||||
const QString& type = tunnelConfig->getType();
|
||||
|
@ -219,8 +219,6 @@ void ServerTunnelPane::appendServerTunnelForm(
|
|||
appendControlsForI2CPParameters(i2cpParameters, gridIndex);
|
||||
}
|
||||
|
||||
tunnelsFormGridLayout->addWidget(serverTunnelNameGroupBox, 0, 0, 1, 1);
|
||||
|
||||
retranslateServerTunnelForm(ui);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,8 @@ public:
|
|||
virtual ServerTunnelPane* asServerTunnelPane();
|
||||
virtual ClientTunnelPane* asClientTunnelPane();
|
||||
|
||||
void appendServerTunnelForm(ServerTunnelConfig* tunnelConfig, QWidget *tunnelsFormGridLayoutWidget, QGridLayout *tunnelsFormGridLayout);
|
||||
void appendServerTunnelForm(ServerTunnelConfig* tunnelConfig, QWidget *tunnelsFormGridLayoutWidget,
|
||||
QGridLayout *tunnelsFormGridLayout, int tunnelsRow);
|
||||
void deleteServerTunnelForm(QGridLayout *tunnelsFormGridLayout);
|
||||
|
||||
private:
|
||||
|
|
|
@ -54,6 +54,7 @@ class TunnelConfig {
|
|||
std::string name;
|
||||
public:
|
||||
TunnelConfig(std::string name_, QString& type_, I2CPParameters& i2cpParameters_): type(type_), name(name_), i2cpParameters(i2cpParameters_) {}
|
||||
virtual ~TunnelConfig(){}
|
||||
const QString& getType(){return type;}
|
||||
const std::string& getName(){return name;}
|
||||
void setType(const QString& type_){type=type_;}
|
||||
|
|
|
@ -7,8 +7,14 @@ void TunnelPane::setupTunnelPane(
|
|||
TunnelConfig* tunnelConfig,
|
||||
QGroupBox *tunnelGroupBox,
|
||||
QWidget* gridLayoutWidget_2, QComboBox * tunnelTypeComboBox,
|
||||
QWidget */*tunnelsFormGridLayoutWidget*/, QGridLayout */*tunnelsFormGridLayout*/) {
|
||||
QWidget *tunnelsFormGridLayoutWidget, QGridLayout *tunnelsFormGridLayout, int tunnelsRow) {
|
||||
tunnelsFormGridLayoutWidget->resize(527, tunnelsFormGridLayoutWidget->height()+gridLayoutWidget_2->height());
|
||||
tunnelGroupBox->resize(gridLayoutWidget_2->width(), gridLayoutWidget_2->height());
|
||||
tunnelsFormGridLayout->addWidget(tunnelGroupBox, tunnelsRow, 0);
|
||||
|
||||
|
||||
this->tunnelGroupBox=tunnelGroupBox;
|
||||
|
||||
gridLayoutWidget_2->setObjectName(QStringLiteral("gridLayoutWidget_2"));
|
||||
this->gridLayoutWidget_2=gridLayoutWidget_2;
|
||||
tunnelGridLayout = new QGridLayout(gridLayoutWidget_2);
|
||||
|
|
|
@ -66,7 +66,7 @@ protected:
|
|||
TunnelConfig* tunnelConfig,
|
||||
QGroupBox *tunnelGroupBox,
|
||||
QWidget* gridLayoutWidget_2, QComboBox * tunnelTypeComboBox,
|
||||
QWidget *tunnelsFormGridLayoutWidget, QGridLayout *tunnelsFormGridLayout);
|
||||
QWidget *tunnelsFormGridLayoutWidget, QGridLayout *tunnelsFormGridLayout, int tunnelsRow);
|
||||
void appendControlsForI2CPParameters(I2CPParameters& i2cpParameters, int& gridIndex);
|
||||
public:
|
||||
int height() {
|
||||
|
|
|
@ -509,22 +509,24 @@ void MainWindowItem::installListeners(MainWindow *mainWindow) {}
|
|||
|
||||
void MainWindow::appendTunnelForms() {
|
||||
int height=0;
|
||||
tunnelsFormGridLayoutWidget->setGeometry(0,0,0,0);
|
||||
for(std::list<TunnelConfig*>::iterator it = tunnelConfigs.begin(); it != tunnelConfigs.end(); ++it) {
|
||||
TunnelConfig* tunconf = *it;
|
||||
ServerTunnelConfig* stc = tunconf->asServerTunnelConfig();
|
||||
if(stc){
|
||||
ServerTunnelPane * tunnelPane=new ServerTunnelPane();
|
||||
tunnelPane->appendServerTunnelForm(stc, tunnelsFormGridLayoutWidget, tunnelsFormGridLayout);
|
||||
tunnelPane->appendServerTunnelForm(stc, tunnelsFormGridLayoutWidget, tunnelsFormGridLayout, tunnelPanes.size());
|
||||
height+=tunnelPane->height();
|
||||
qDebug() << "tun.height:" << height;
|
||||
qDebug() << "tun.height:" << height << "sz:" << tunnelPanes.size();
|
||||
tunnelPanes.push_back(tunnelPane);
|
||||
continue;
|
||||
}
|
||||
ClientTunnelConfig* ctc = tunconf->asClientTunnelConfig();
|
||||
if(ctc){
|
||||
ClientTunnelPane * tunnelPane=new ClientTunnelPane();//TODO
|
||||
ClientTunnelPane * tunnelPane=new ClientTunnelPane();
|
||||
tunnelPane->appendClientTunnelForm(ctc, tunnelsFormGridLayoutWidget, tunnelsFormGridLayout, tunnelPanes.size());
|
||||
height+=tunnelPane->height();
|
||||
qDebug() << "tun.height:" << height;
|
||||
qDebug() << "tun.height:" << height << "sz:" << tunnelPanes.size();
|
||||
tunnelPanes.push_back(tunnelPane);
|
||||
continue;
|
||||
}
|
||||
|
@ -532,6 +534,7 @@ void MainWindow::appendTunnelForms() {
|
|||
}
|
||||
qDebug() << "tun.setting height:" << height;
|
||||
tunnelsFormGridLayoutWidget->setGeometry(QRect(0, 0, 621, height));
|
||||
tunnelsFormGridLayout->invalidate();
|
||||
ui->tunnelsScrollAreaWidgetContents->setGeometry(QRect(0, 0, 621, height));
|
||||
}
|
||||
void MainWindow::deleteTunnelForms() {
|
||||
|
|
Loading…
Reference in a new issue