Browse Source

fixed tunnels invalid ui data handling 2

pull/952/head
hypnosis-i2p 7 years ago
parent
commit
cd3f274763
  1. 1
      qt/i2pd_qt/TunnelPane.cpp
  2. 1
      qt/i2pd_qt/TunnelPane.h
  3. 17
      qt/i2pd_qt/mainwindow.cpp
  4. 1
      qt/i2pd_qt/mainwindow.h

1
qt/i2pd_qt/TunnelPane.cpp

@ -186,6 +186,7 @@ void TunnelPane::appendControlsForI2CPParameters(I2CPParameters& i2cpParameters,
void TunnelPane::updated() { void TunnelPane::updated() {
std::string oldName=tunnelConfig->getName(); std::string oldName=tunnelConfig->getName();
//validate and show red if invalid //validate and show red if invalid
hideWrongInputLabel();
if(!mainWindow->applyTunnelsUiToConfigs())return; if(!mainWindow->applyTunnelsUiToConfigs())return;
tunnelsPageUpdateListener->updated(oldName, tunnelConfig); tunnelsPageUpdateListener->updated(oldName, tunnelConfig);
} }

1
qt/i2pd_qt/TunnelPane.h

@ -95,7 +95,6 @@ protected:
public: public:
//returns false when invalid data at UI //returns false when invalid data at UI
virtual bool applyDataFromUIToTunnelConfig() { virtual bool applyDataFromUIToTunnelConfig() {
hideWrongInputLabel();
tunnelConfig->setName(nameLineEdit->text().toStdString()); tunnelConfig->setName(nameLineEdit->text().toStdString());
tunnelConfig->setType(readTunnelTypeComboboxData()); tunnelConfig->setType(readTunnelTypeComboboxData());
I2CPParameters& i2cpParams=tunnelConfig->getI2cpParameters(); I2CPParameters& i2cpParams=tunnelConfig->getI2cpParameters();

17
qt/i2pd_qt/mainwindow.cpp

@ -632,10 +632,6 @@ 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(){
QString cannotSaveSettings = QApplication::tr("Cannot save settings."); QString cannotSaveSettings = QApplication::tr("Cannot save settings.");
bool redVisible = ui->wrongInputLabel->isVisible();
ui->wrongInputLabel->setVisible(false);
if(redVisible)adjustSizesAccordingToWrongLabel();
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"));*/
@ -684,15 +680,22 @@ void FolderChooserItem::pushButtonReleased() {
} }
void BaseStringItem::installListeners(MainWindow *mainWindow) { void BaseStringItem::installListeners(MainWindow *mainWindow) {
QObject::connect(lineEdit, SIGNAL(textChanged(const QString &)), mainWindow, SLOT(saveAllConfigs())); QObject::connect(lineEdit, SIGNAL(textChanged(const QString &)), mainWindow, SLOT(updated()));
} }
void ComboBoxItem::installListeners(MainWindow *mainWindow) { void ComboBoxItem::installListeners(MainWindow *mainWindow) {
QObject::connect(comboBox, SIGNAL(currentIndexChanged(int)), mainWindow, SLOT(saveAllConfigs())); QObject::connect(comboBox, SIGNAL(currentIndexChanged(int)), mainWindow, SLOT(updated()));
} }
void CheckBoxItem::installListeners(MainWindow *mainWindow) { void CheckBoxItem::installListeners(MainWindow *mainWindow) {
QObject::connect(checkBox, SIGNAL(stateChanged(int)), mainWindow, SLOT(saveAllConfigs())); QObject::connect(checkBox, SIGNAL(stateChanged(int)), mainWindow, SLOT(updated()));
} }
void MainWindow::updated() {
ui->wrongInputLabel->setVisible(false);
adjustSizesAccordingToWrongLabel();
applyTunnelsUiToConfigs();
saveAllConfigs();
}
void MainWindowItem::installListeners(MainWindow *mainWindow) {} void MainWindowItem::installListeners(MainWindow *mainWindow) {}

1
qt/i2pd_qt/mainwindow.h

@ -390,6 +390,7 @@ private:
enum StatusPage {main_page, commands, local_destinations, leasesets, tunnels, transit_tunnels, enum StatusPage {main_page, commands, local_destinations, leasesets, tunnels, transit_tunnels,
transports, i2p_tunnels, sam_sessions}; transports, i2p_tunnels, sam_sessions};
private slots: private slots:
void updated();
void handleQuitButton(); void handleQuitButton();
void handleGracefulQuitButton(); void handleGracefulQuitButton();

Loading…
Cancel
Save