mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 08:00:38 +03: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());
|
||||
|
||||
auto dportStr=portLineEdit->text();
|
||||
auto dportStr=destinationPortLineEdit->text();
|
||||
int dportInt=dportStr.toInt(&ok);
|
||||
if(!ok)return false;
|
||||
ctc->setdestinationPort(dportInt);
|
||||
|
@ -143,10 +143,16 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
initFileChooser( OPTION("","tunconf",[](){return "";}), ui->tunnelsConfigFileLineEdit, ui->tunnelsConfigFileBrowsePushButton);
|
||||
|
||||
initFileChooser( OPTION("","pidfile",[]{return "";}), ui->pidFileLineEdit, ui->pidFileBrowsePushButton);
|
||||
logOption=initNonGUIOption( OPTION("","log",[]{return "";}));
|
||||
daemonOption=initNonGUIOption( OPTION("","daemon",[]{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);
|
||||
initLogLevelCombobox(OPTION("","loglevel",[]{return "";}), ui->logLevelComboBox);
|
||||
|
||||
@ -246,6 +252,10 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
loadAllConfigs();
|
||||
|
||||
QObject::connect(ui->logDestinationComboBox, SIGNAL(currentIndexChanged(const QString &)),
|
||||
this, SLOT(logDestinationComboBoxValueChanged(const QString &)));
|
||||
logDestinationComboBoxValueChanged(ui->logDestinationComboBox->currentText());
|
||||
|
||||
//tunnelsFormGridLayoutWidget = new QWidget(ui->tunnelsScrollAreaWidgetContents);
|
||||
//tunnelsFormGridLayoutWidget->setObjectName(QStringLiteral("tunnelsFormGridLayoutWidget"));
|
||||
//tunnelsFormGridLayoutWidget->setGeometry(QRect(0, 0, 621, 451));
|
||||
@ -281,6 +291,13 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
//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() {
|
||||
bool acceptsTunnels = i2p::context.AcceptsTunnels ();
|
||||
routerCommandsUI->declineTransitTunnelsPushButton->setEnabled(acceptsTunnels);
|
||||
@ -518,6 +535,9 @@ void MainWindow::initFolderChooser(ConfigOption option, QLineEdit* folderLineEdi
|
||||
configItems.append(new ComboBoxItem(option, comboBox));
|
||||
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){
|
||||
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);
|
||||
} else {
|
||||
config = i2p::fs::DataDirPath("i2pd.conf");
|
||||
if (!i2p::fs::Exists (config)) {
|
||||
// use i2pd.conf only if exists
|
||||
config = ""; /* reset */
|
||||
}
|
||||
/*if (!i2p::fs::Exists (config)) {}*/
|
||||
}
|
||||
}
|
||||
|
||||
@ -605,8 +622,8 @@ void MainWindow::loadAllConfigs(){
|
||||
/** returns false iff not valid items present and save was aborted */
|
||||
bool MainWindow::saveAllConfigs(){
|
||||
programOptionsWriterCurrentSection="";
|
||||
if(!logFileNameOption->lineEdit->text().trimmed().isEmpty())logOption->optionValue=boost::any(std::string("file"));
|
||||
else logOption->optionValue=boost::any(std::string("stdout"));
|
||||
/*if(!logFileNameOption->lineEdit->text().trimmed().isEmpty())logOption->optionValue=boost::any(std::string("file"));
|
||||
else logOption->optionValue=boost::any(std::string("stdout"));*/
|
||||
daemonOption->optionValue=boost::any(false);
|
||||
serviceOption->optionValue=boost::any(false);
|
||||
|
||||
@ -623,9 +640,10 @@ bool MainWindow::saveAllConfigs(){
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
QString backup=confpath+"~";
|
||||
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;
|
||||
outfile.open(confpath.toStdString());//TODO handle errors
|
||||
outfile << out.str().c_str();
|
||||
@ -740,7 +758,7 @@ void MainWindow::SaveTunnelsConfig() {
|
||||
|
||||
QString backup=tunconfpath+"~";
|
||||
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;
|
||||
outfile.open(tunconfpath.toStdString());//TODO handle errors
|
||||
outfile << out.str().c_str();
|
||||
|
@ -57,6 +57,8 @@
|
||||
#include "SignatureTypeComboboxFactory.h"
|
||||
#include "pagewithbackbutton.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
template<typename ValueType>
|
||||
bool isType(boost::any& a) {
|
||||
return
|
||||
@ -97,7 +99,7 @@ public:
|
||||
std::string optName="";
|
||||
if(!option.section.isEmpty())optName=option.section.toStdString()+std::string(".");
|
||||
optName+=option.option.toStdString();
|
||||
qDebug() << "loadFromConfigOption[" << optName.c_str() << "]";
|
||||
//qDebug() << "loadFromConfigOption[" << optName.c_str() << "]";
|
||||
boost::any programOption;
|
||||
i2p::config::GetOptionAsAny(optName, programOption);
|
||||
optionValue=programOption.empty()?boost::any(std::string(""))
|
||||
@ -203,6 +205,21 @@ public:
|
||||
virtual void saveToStringStream(std::stringstream& out)=0;
|
||||
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 {
|
||||
public:
|
||||
LogLevelComboBoxItem(ConfigOption option_, QComboBox* comboBox_) : ComboBoxItem(option_, comboBox_) {};
|
||||
@ -418,14 +435,15 @@ protected:
|
||||
QString getStatusPageHtml(bool showHiddenInfo);
|
||||
|
||||
QList<MainWindowItem*> configItems;
|
||||
NonGUIOptionItem* logOption;
|
||||
NonGUIOptionItem* daemonOption;
|
||||
NonGUIOptionItem* serviceOption;
|
||||
//LogDestinationComboBoxItem* logOption;
|
||||
FileChooserItem* logFileNameOption;
|
||||
|
||||
FileChooserItem* initFileChooser(ConfigOption option, QLineEdit* fileNameLineEdit, QPushButton* fileBrowsePushButton);
|
||||
void initFolderChooser(ConfigOption option, QLineEdit* folderLineEdit, QPushButton* folderBrowsePushButton);
|
||||
//void initCombobox(ConfigOption option, QComboBox* comboBox);
|
||||
void initLogDestinationCombobox(ConfigOption option, QComboBox* comboBox);
|
||||
void initLogLevelCombobox(ConfigOption option, QComboBox* comboBox);
|
||||
void initSignatureTypeCombobox(ConfigOption option, QComboBox* comboBox);
|
||||
void initIPAddressBox(ConfigOption option, QLineEdit* addressLineEdit, QString fieldNameTranslated);
|
||||
@ -453,6 +471,8 @@ public slots:
|
||||
void anchorClickedHandler(const QUrl & link);
|
||||
void backClickedFromChild();
|
||||
|
||||
void logDestinationComboBoxValueChanged(const QString & text);
|
||||
|
||||
private:
|
||||
QString datadir;
|
||||
QString confpath;
|
||||
@ -635,13 +655,17 @@ private:
|
||||
{
|
||||
// mandatory params
|
||||
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);
|
||||
std::cout << "had read tunnel dest: " << dest << std::endl;
|
||||
}
|
||||
int port = section.second.get<int> (I2P_CLIENT_TUNNEL_PORT);
|
||||
std::cout << "had read tunnel port: " << port << std::endl;
|
||||
// optional params
|
||||
std::string keys = section.second.get (I2P_CLIENT_TUNNEL_KEYS, "");
|
||||
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);
|
||||
// I2CP
|
||||
std::map<std::string, std::string> options;
|
||||
|
@ -188,7 +188,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="statusPage">
|
||||
<property name="sizePolicy">
|
||||
@ -506,6 +506,16 @@
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Destination:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="logDestinationComboBox"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="logFileLabel">
|
||||
<property name="text">
|
||||
@ -3007,7 +3017,7 @@ Comma separated list of base64 identities:</string>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_42">
|
||||
<property name="text">
|
||||
<string>SIgnature type:</string>
|
||||
<string>Signature type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
Reference in New Issue
Block a user