mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-02 11:04:00 +01:00
various small qt gui fixes
This commit is contained in:
parent
5c3d6298b0
commit
3d5fb07ca8
|
@ -85,7 +85,7 @@ protected:
|
||||||
|
|
||||||
ctc->setaddress(addressLineEdit->text().toStdString());
|
ctc->setaddress(addressLineEdit->text().toStdString());
|
||||||
|
|
||||||
auto dportStr=portLineEdit->text();
|
auto dportStr=destinationPortLineEdit->text();
|
||||||
int dportInt=dportStr.toInt(&ok);
|
int dportInt=dportStr.toInt(&ok);
|
||||||
if(!ok)return false;
|
if(!ok)return false;
|
||||||
ctc->setdestinationPort(dportInt);
|
ctc->setdestinationPort(dportInt);
|
||||||
|
|
|
@ -143,10 +143,16 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
initFileChooser( OPTION("","tunconf",[](){return "";}), ui->tunnelsConfigFileLineEdit, ui->tunnelsConfigFileBrowsePushButton);
|
initFileChooser( OPTION("","tunconf",[](){return "";}), ui->tunnelsConfigFileLineEdit, ui->tunnelsConfigFileBrowsePushButton);
|
||||||
|
|
||||||
initFileChooser( OPTION("","pidfile",[]{return "";}), ui->pidFileLineEdit, ui->pidFileBrowsePushButton);
|
initFileChooser( OPTION("","pidfile",[]{return "";}), ui->pidFileLineEdit, ui->pidFileBrowsePushButton);
|
||||||
logOption=initNonGUIOption( OPTION("","log",[]{return "";}));
|
|
||||||
daemonOption=initNonGUIOption( OPTION("","daemon",[]{return "";}));
|
daemonOption=initNonGUIOption( OPTION("","daemon",[]{return "";}));
|
||||||
serviceOption=initNonGUIOption( OPTION("","service",[]{return "";}));
|
serviceOption=initNonGUIOption( OPTION("","service",[]{return "";}));
|
||||||
|
|
||||||
|
ui->logDestinationComboBox->clear();
|
||||||
|
ui->logDestinationComboBox->insertItems(0, QStringList()
|
||||||
|
<< QApplication::translate("MainWindow", "stdout", 0)
|
||||||
|
<< QApplication::translate("MainWindow", "file", 0)
|
||||||
|
);
|
||||||
|
initLogDestinationCombobox( OPTION("","log",[]{return "";}), ui->logDestinationComboBox);
|
||||||
|
|
||||||
logFileNameOption=initFileChooser( OPTION("","logfile",[]{return "";}), ui->logFileLineEdit, ui->logFileBrowsePushButton);
|
logFileNameOption=initFileChooser( OPTION("","logfile",[]{return "";}), ui->logFileLineEdit, ui->logFileBrowsePushButton);
|
||||||
initLogLevelCombobox(OPTION("","loglevel",[]{return "";}), ui->logLevelComboBox);
|
initLogLevelCombobox(OPTION("","loglevel",[]{return "";}), ui->logLevelComboBox);
|
||||||
|
|
||||||
|
@ -246,6 +252,10 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
|
|
||||||
loadAllConfigs();
|
loadAllConfigs();
|
||||||
|
|
||||||
|
QObject::connect(ui->logDestinationComboBox, SIGNAL(currentIndexChanged(const QString &)),
|
||||||
|
this, SLOT(logDestinationComboBoxValueChanged(const QString &)));
|
||||||
|
logDestinationComboBoxValueChanged(ui->logDestinationComboBox->currentText());
|
||||||
|
|
||||||
//tunnelsFormGridLayoutWidget = new QWidget(ui->tunnelsScrollAreaWidgetContents);
|
//tunnelsFormGridLayoutWidget = new QWidget(ui->tunnelsScrollAreaWidgetContents);
|
||||||
//tunnelsFormGridLayoutWidget->setObjectName(QStringLiteral("tunnelsFormGridLayoutWidget"));
|
//tunnelsFormGridLayoutWidget->setObjectName(QStringLiteral("tunnelsFormGridLayoutWidget"));
|
||||||
//tunnelsFormGridLayoutWidget->setGeometry(QRect(0, 0, 621, 451));
|
//tunnelsFormGridLayoutWidget->setGeometry(QRect(0, 0, 621, 451));
|
||||||
|
@ -281,6 +291,13 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
//QMetaObject::connectSlotsByName(this);
|
//QMetaObject::connectSlotsByName(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::logDestinationComboBoxValueChanged(const QString & text) {
|
||||||
|
bool stdout = text==QString("stdout");
|
||||||
|
ui->logFileLineEdit->setEnabled(!stdout);
|
||||||
|
ui->logFileBrowsePushButton->setEnabled(!stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::updateRouterCommandsButtons() {
|
void MainWindow::updateRouterCommandsButtons() {
|
||||||
bool acceptsTunnels = i2p::context.AcceptsTunnels ();
|
bool acceptsTunnels = i2p::context.AcceptsTunnels ();
|
||||||
routerCommandsUI->declineTransitTunnelsPushButton->setEnabled(acceptsTunnels);
|
routerCommandsUI->declineTransitTunnelsPushButton->setEnabled(acceptsTunnels);
|
||||||
|
@ -518,6 +535,9 @@ void MainWindow::initFolderChooser(ConfigOption option, QLineEdit* folderLineEdi
|
||||||
configItems.append(new ComboBoxItem(option, comboBox));
|
configItems.append(new ComboBoxItem(option, comboBox));
|
||||||
QObject::connect(comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(saveAllConfigs()));
|
QObject::connect(comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(saveAllConfigs()));
|
||||||
}*/
|
}*/
|
||||||
|
void MainWindow::initLogDestinationCombobox(ConfigOption option, QComboBox* comboBox){
|
||||||
|
configItems.append(new LogDestinationComboBoxItem(option, comboBox));
|
||||||
|
}
|
||||||
void MainWindow::initLogLevelCombobox(ConfigOption option, QComboBox* comboBox){
|
void MainWindow::initLogLevelCombobox(ConfigOption option, QComboBox* comboBox){
|
||||||
configItems.append(new LogLevelComboBoxItem(option, comboBox));
|
configItems.append(new LogLevelComboBoxItem(option, comboBox));
|
||||||
}
|
}
|
||||||
|
@ -572,10 +592,7 @@ void MainWindow::loadAllConfigs(){
|
||||||
LogPrint(eLogWarning, "Daemon: please rename i2p.conf to i2pd.conf here: ", config);
|
LogPrint(eLogWarning, "Daemon: please rename i2p.conf to i2pd.conf here: ", config);
|
||||||
} else {
|
} else {
|
||||||
config = i2p::fs::DataDirPath("i2pd.conf");
|
config = i2p::fs::DataDirPath("i2pd.conf");
|
||||||
if (!i2p::fs::Exists (config)) {
|
/*if (!i2p::fs::Exists (config)) {}*/
|
||||||
// use i2pd.conf only if exists
|
|
||||||
config = ""; /* reset */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -605,8 +622,8 @@ void MainWindow::loadAllConfigs(){
|
||||||
/** returns false iff not valid items present and save was aborted */
|
/** returns false iff not valid items present and save was aborted */
|
||||||
bool MainWindow::saveAllConfigs(){
|
bool MainWindow::saveAllConfigs(){
|
||||||
programOptionsWriterCurrentSection="";
|
programOptionsWriterCurrentSection="";
|
||||||
if(!logFileNameOption->lineEdit->text().trimmed().isEmpty())logOption->optionValue=boost::any(std::string("file"));
|
/*if(!logFileNameOption->lineEdit->text().trimmed().isEmpty())logOption->optionValue=boost::any(std::string("file"));
|
||||||
else logOption->optionValue=boost::any(std::string("stdout"));
|
else logOption->optionValue=boost::any(std::string("stdout"));*/
|
||||||
daemonOption->optionValue=boost::any(false);
|
daemonOption->optionValue=boost::any(false);
|
||||||
serviceOption->optionValue=boost::any(false);
|
serviceOption->optionValue=boost::any(false);
|
||||||
|
|
||||||
|
@ -623,9 +640,10 @@ bool MainWindow::saveAllConfigs(){
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
QString backup=confpath+"~";
|
QString backup=confpath+"~";
|
||||||
if(QFile::exists(backup)) QFile::remove(backup);//TODO handle errors
|
if(QFile::exists(backup)) QFile::remove(backup);//TODO handle errors
|
||||||
QFile::rename(confpath, backup);//TODO handle errors
|
if(QFile::exists(confpath)) QFile::rename(confpath, backup);//TODO handle errors
|
||||||
ofstream outfile;
|
ofstream outfile;
|
||||||
outfile.open(confpath.toStdString());//TODO handle errors
|
outfile.open(confpath.toStdString());//TODO handle errors
|
||||||
outfile << out.str().c_str();
|
outfile << out.str().c_str();
|
||||||
|
@ -740,7 +758,7 @@ void MainWindow::SaveTunnelsConfig() {
|
||||||
|
|
||||||
QString backup=tunconfpath+"~";
|
QString backup=tunconfpath+"~";
|
||||||
if(QFile::exists(backup)) QFile::remove(backup);//TODO handle errors
|
if(QFile::exists(backup)) QFile::remove(backup);//TODO handle errors
|
||||||
QFile::rename(tunconfpath, backup);//TODO handle errors
|
if(QFile::exists(tunconfpath)) QFile::rename(tunconfpath, backup);//TODO handle errors
|
||||||
ofstream outfile;
|
ofstream outfile;
|
||||||
outfile.open(tunconfpath.toStdString());//TODO handle errors
|
outfile.open(tunconfpath.toStdString());//TODO handle errors
|
||||||
outfile << out.str().c_str();
|
outfile << out.str().c_str();
|
||||||
|
|
|
@ -57,6 +57,8 @@
|
||||||
#include "SignatureTypeComboboxFactory.h"
|
#include "SignatureTypeComboboxFactory.h"
|
||||||
#include "pagewithbackbutton.h"
|
#include "pagewithbackbutton.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
template<typename ValueType>
|
template<typename ValueType>
|
||||||
bool isType(boost::any& a) {
|
bool isType(boost::any& a) {
|
||||||
return
|
return
|
||||||
|
@ -97,7 +99,7 @@ public:
|
||||||
std::string optName="";
|
std::string optName="";
|
||||||
if(!option.section.isEmpty())optName=option.section.toStdString()+std::string(".");
|
if(!option.section.isEmpty())optName=option.section.toStdString()+std::string(".");
|
||||||
optName+=option.option.toStdString();
|
optName+=option.option.toStdString();
|
||||||
qDebug() << "loadFromConfigOption[" << optName.c_str() << "]";
|
//qDebug() << "loadFromConfigOption[" << optName.c_str() << "]";
|
||||||
boost::any programOption;
|
boost::any programOption;
|
||||||
i2p::config::GetOptionAsAny(optName, programOption);
|
i2p::config::GetOptionAsAny(optName, programOption);
|
||||||
optionValue=programOption.empty()?boost::any(std::string(""))
|
optionValue=programOption.empty()?boost::any(std::string(""))
|
||||||
|
@ -203,6 +205,21 @@ public:
|
||||||
virtual void saveToStringStream(std::stringstream& out)=0;
|
virtual void saveToStringStream(std::stringstream& out)=0;
|
||||||
virtual bool isValid() { return true; }
|
virtual bool isValid() { return true; }
|
||||||
};
|
};
|
||||||
|
class LogDestinationComboBoxItem : public ComboBoxItem {
|
||||||
|
public:
|
||||||
|
LogDestinationComboBoxItem(ConfigOption option_, QComboBox* comboBox_) : ComboBoxItem(option_, comboBox_) {};
|
||||||
|
virtual ~LogDestinationComboBoxItem(){}
|
||||||
|
virtual void loadFromConfigOption(){
|
||||||
|
MainWindowItem::loadFromConfigOption();
|
||||||
|
const char * ld = boost::any_cast<std::string>(optionValue).c_str();
|
||||||
|
comboBox->setCurrentText(QString(ld));
|
||||||
|
}
|
||||||
|
virtual void saveToStringStream(std::stringstream& out){
|
||||||
|
optionValue=comboBox->currentText().toStdString();
|
||||||
|
MainWindowItem::saveToStringStream(out);
|
||||||
|
}
|
||||||
|
virtual bool isValid() { return true; }
|
||||||
|
};
|
||||||
class LogLevelComboBoxItem : public ComboBoxItem {
|
class LogLevelComboBoxItem : public ComboBoxItem {
|
||||||
public:
|
public:
|
||||||
LogLevelComboBoxItem(ConfigOption option_, QComboBox* comboBox_) : ComboBoxItem(option_, comboBox_) {};
|
LogLevelComboBoxItem(ConfigOption option_, QComboBox* comboBox_) : ComboBoxItem(option_, comboBox_) {};
|
||||||
|
@ -418,14 +435,15 @@ protected:
|
||||||
QString getStatusPageHtml(bool showHiddenInfo);
|
QString getStatusPageHtml(bool showHiddenInfo);
|
||||||
|
|
||||||
QList<MainWindowItem*> configItems;
|
QList<MainWindowItem*> configItems;
|
||||||
NonGUIOptionItem* logOption;
|
|
||||||
NonGUIOptionItem* daemonOption;
|
NonGUIOptionItem* daemonOption;
|
||||||
NonGUIOptionItem* serviceOption;
|
NonGUIOptionItem* serviceOption;
|
||||||
|
//LogDestinationComboBoxItem* logOption;
|
||||||
FileChooserItem* logFileNameOption;
|
FileChooserItem* logFileNameOption;
|
||||||
|
|
||||||
FileChooserItem* initFileChooser(ConfigOption option, QLineEdit* fileNameLineEdit, QPushButton* fileBrowsePushButton);
|
FileChooserItem* initFileChooser(ConfigOption option, QLineEdit* fileNameLineEdit, QPushButton* fileBrowsePushButton);
|
||||||
void initFolderChooser(ConfigOption option, QLineEdit* folderLineEdit, QPushButton* folderBrowsePushButton);
|
void initFolderChooser(ConfigOption option, QLineEdit* folderLineEdit, QPushButton* folderBrowsePushButton);
|
||||||
//void initCombobox(ConfigOption option, QComboBox* comboBox);
|
//void initCombobox(ConfigOption option, QComboBox* comboBox);
|
||||||
|
void initLogDestinationCombobox(ConfigOption option, QComboBox* comboBox);
|
||||||
void initLogLevelCombobox(ConfigOption option, QComboBox* comboBox);
|
void initLogLevelCombobox(ConfigOption option, QComboBox* comboBox);
|
||||||
void initSignatureTypeCombobox(ConfigOption option, QComboBox* comboBox);
|
void initSignatureTypeCombobox(ConfigOption option, QComboBox* comboBox);
|
||||||
void initIPAddressBox(ConfigOption option, QLineEdit* addressLineEdit, QString fieldNameTranslated);
|
void initIPAddressBox(ConfigOption option, QLineEdit* addressLineEdit, QString fieldNameTranslated);
|
||||||
|
@ -453,6 +471,8 @@ public slots:
|
||||||
void anchorClickedHandler(const QUrl & link);
|
void anchorClickedHandler(const QUrl & link);
|
||||||
void backClickedFromChild();
|
void backClickedFromChild();
|
||||||
|
|
||||||
|
void logDestinationComboBoxValueChanged(const QString & text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString datadir;
|
QString datadir;
|
||||||
QString confpath;
|
QString confpath;
|
||||||
|
@ -635,13 +655,17 @@ private:
|
||||||
{
|
{
|
||||||
// mandatory params
|
// mandatory params
|
||||||
std::string dest;
|
std::string dest;
|
||||||
if (type == I2P_TUNNELS_SECTION_TYPE_CLIENT || type == I2P_TUNNELS_SECTION_TYPE_UDPCLIENT)
|
if (type == I2P_TUNNELS_SECTION_TYPE_CLIENT || type == I2P_TUNNELS_SECTION_TYPE_UDPCLIENT) {
|
||||||
dest = section.second.get<std::string> (I2P_CLIENT_TUNNEL_DESTINATION);
|
dest = section.second.get<std::string> (I2P_CLIENT_TUNNEL_DESTINATION);
|
||||||
|
std::cout << "had read tunnel dest: " << dest << std::endl;
|
||||||
|
}
|
||||||
int port = section.second.get<int> (I2P_CLIENT_TUNNEL_PORT);
|
int port = section.second.get<int> (I2P_CLIENT_TUNNEL_PORT);
|
||||||
|
std::cout << "had read tunnel port: " << port << std::endl;
|
||||||
// optional params
|
// optional params
|
||||||
std::string keys = section.second.get (I2P_CLIENT_TUNNEL_KEYS, "");
|
std::string keys = section.second.get (I2P_CLIENT_TUNNEL_KEYS, "");
|
||||||
std::string address = section.second.get (I2P_CLIENT_TUNNEL_ADDRESS, "127.0.0.1");
|
std::string address = section.second.get (I2P_CLIENT_TUNNEL_ADDRESS, "127.0.0.1");
|
||||||
int destinationPort = section.second.get (I2P_CLIENT_TUNNEL_DESTINATION_PORT, 0);
|
int destinationPort = section.second.get<int>(I2P_CLIENT_TUNNEL_DESTINATION_PORT, 0);
|
||||||
|
std::cout << "had read tunnel destinationPort: " << destinationPort << std::endl;
|
||||||
i2p::data::SigningKeyType sigType = section.second.get (I2P_CLIENT_TUNNEL_SIGNATURE_TYPE, i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA256_P256);
|
i2p::data::SigningKeyType sigType = section.second.get (I2P_CLIENT_TUNNEL_SIGNATURE_TYPE, i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA256_P256);
|
||||||
// I2CP
|
// I2CP
|
||||||
std::map<std::string, std::string> options;
|
std::map<std::string, std::string> options;
|
||||||
|
|
|
@ -188,7 +188,7 @@
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="statusPage">
|
<widget class="QWidget" name="statusPage">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -506,6 +506,16 @@
|
||||||
<property name="sizeConstraint">
|
<property name="sizeConstraint">
|
||||||
<enum>QLayout::SetMaximumSize</enum>
|
<enum>QLayout::SetMaximumSize</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Destination:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="logDestinationComboBox"/>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="logFileLabel">
|
<widget class="QLabel" name="logFileLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -3007,7 +3017,7 @@ Comma separated list of base64 identities:</string>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_42">
|
<widget class="QLabel" name="label_42">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>SIgnature type:</string>
|
<string>Signature type:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
Loading…
Reference in a new issue