Skip to content

Commit

Permalink
fixed tunnels invalid ui data handling 2
Browse files Browse the repository at this point in the history
  • Loading branch information
nonlin-lin-chaos-order-etc-etal committed Sep 8, 2017
1 parent 1947be4 commit cd3f274
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions qt/i2pd_qt/TunnelPane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ void TunnelPane::appendControlsForI2CPParameters(I2CPParameters& i2cpParameters,
void TunnelPane::updated() {
std::string oldName=tunnelConfig->getName();
//validate and show red if invalid
hideWrongInputLabel();
if(!mainWindow->applyTunnelsUiToConfigs())return;
tunnelsPageUpdateListener->updated(oldName, tunnelConfig);
}
Expand Down
1 change: 0 additions & 1 deletion qt/i2pd_qt/TunnelPane.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public slots:
public:
//returns false when invalid data at UI
virtual bool applyDataFromUIToTunnelConfig() {
hideWrongInputLabel();
tunnelConfig->setName(nameLineEdit->text().toStdString());
tunnelConfig->setType(readTunnelTypeComboboxData());
I2CPParameters& i2cpParams=tunnelConfig->getI2cpParameters();
Expand Down
17 changes: 10 additions & 7 deletions qt/i2pd_qt/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,10 +632,6 @@ void MainWindow::loadAllConfigs(){
/** returns false iff not valid items present and save was aborted */
bool MainWindow::saveAllConfigs(){
QString cannotSaveSettings = QApplication::tr("Cannot save settings.");
bool redVisible = ui->wrongInputLabel->isVisible();
ui->wrongInputLabel->setVisible(false);
if(redVisible)adjustSizesAccordingToWrongLabel();

programOptionsWriterCurrentSection="";
/*if(!logFileNameOption->lineEdit->text().trimmed().isEmpty())logOption->optionValue=boost::any(std::string("file"));
else logOption->optionValue=boost::any(std::string("stdout"));*/
Expand Down Expand Up @@ -684,15 +680,22 @@ void FolderChooserItem::pushButtonReleased() {
}

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) {
QObject::connect(comboBox, SIGNAL(currentIndexChanged(int)), mainWindow, SLOT(saveAllConfigs()));
QObject::connect(comboBox, SIGNAL(currentIndexChanged(int)), mainWindow, SLOT(updated()));
}
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) {}

Expand Down
1 change: 1 addition & 0 deletions qt/i2pd_qt/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ class MainWindow : public QMainWindow {
enum StatusPage {main_page, commands, local_destinations, leasesets, tunnels, transit_tunnels,
transports, i2p_tunnels, sam_sessions};
private slots:
void updated();

void handleQuitButton();
void handleGracefulQuitButton();
Expand Down

0 comments on commit cd3f274

Please sign in to comment.