Browse Source

Prevent tunnels.conf save after errors with it.

pull/79/head
nonlin-lin-chaos-order-etc-etal 2 years ago
parent
commit
b2e1dc38b1
  1. 2
      src/Saver.h
  2. 8
      src/SaverImpl.cpp
  3. 3
      src/SaverImpl.h
  4. 17
      src/mainwindow.cpp
  5. 6
      src/mainwindow.h

2
src/Saver.h

@ -19,7 +19,7 @@ public: @@ -19,7 +19,7 @@ public:
signals:
void reloadTunnelsConfigAndUISignal(const QString);
void showPreventedSaveTunnelsConfMessage();
};
#endif // SAVER_H

8
src/SaverImpl.cpp

@ -11,7 +11,9 @@ @@ -11,7 +11,9 @@
SaverImpl::SaverImpl(MainWindow *mainWindowPtr_, QList<MainWindowItem*>* configItems_, std::map<std::string,TunnelConfig*>* tunnelConfigs_) :
configItems(configItems_), tunnelConfigs(tunnelConfigs_), confpath(), tunconfpath(), mainWindowPtr(mainWindowPtr_)
{}
{
QObject::connect(this, SIGNAL(showPreventedSaveTunnelsConfMessage()), mainWindowPtr, SLOT(showTunnelsPagePreventedMessage()));
}
SaverImpl::~SaverImpl() {}
@ -37,7 +39,9 @@ bool SaverImpl::save(bool reloadAfterSave, const FocusEnum focusOn, const std::s @@ -37,7 +39,9 @@ bool SaverImpl::save(bool reloadAfterSave, const FocusEnum focusOn, const std::s
}
//save tunnels config
{
if (mainWindowPtr->isPreventSaveTunnelsMode()) {
emit showPreventedSaveTunnelsConfMessage();
}else{
std::stringstream out;
for (std::map<std::string,TunnelConfig*>::iterator it=tunnelConfigs->begin(); it!=tunnelConfigs->end(); ++it) {

3
src/SaverImpl.h

@ -14,8 +14,7 @@ @@ -14,8 +14,7 @@
class MainWindowItem;
class TunnelConfig;
class SaverImpl : public Saver
{
class SaverImpl : public Saver {
public:
SaverImpl(MainWindow *mainWindowPtr_, QList<MainWindowItem*>* configItems_, std::map<std::string,TunnelConfig*>* tunnelConfigs_);
virtual ~SaverImpl();

17
src/mainwindow.cpp

@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
#include <QStyleHints>
#include <QScreen>
#include <QWindow>
#include <QMessageBox>
#include <assert.h>
@ -68,6 +69,7 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren @@ -68,6 +69,7 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren
,tunconfpath()
,tunnelConfigs()
,tunnelsPageUpdateListener(this)
,preventSaveTunnelsBool(false)
,saverPtr(
new SaverImpl(this,
&configItems,
@ -778,6 +780,10 @@ void MainWindow::loadAllConfigs(SaverImpl* saverPtr){ @@ -778,6 +780,10 @@ void MainWindow::loadAllConfigs(SaverImpl* saverPtr){
void MainWindow::DisableTunnelsPage() {
ui->tunnelsScrollAreaWidgetContents->setEnabled(false);
ui->tunnelsScrollArea->setEnabled(false);
ui->addClientTunnelPushButton->setEnabled(false);
ui->addServerTunnelPushButton->setEnabled(false);
preventSaveTunnels();
}
void MainWindow::layoutTunnels() {
@ -1135,3 +1141,14 @@ void MainWindow::syncLogLevel (int /*comboBoxIndex*/) { @@ -1135,3 +1141,14 @@ void MainWindow::syncLogLevel (int /*comboBoxIndex*/) {
i2p::log::Logger().Reopen ();
}
void MainWindow::preventSaveTunnels() {
preventSaveTunnelsBool = true;
}
bool MainWindow::isPreventSaveTunnelsMode() {
return preventSaveTunnelsBool;
}
void MainWindow::showTunnelsPagePreventedMessage() {
QMessageBox::critical(this,QObject::tr("Error"),QObject::tr("Not saving tunnels configuration due to previous errors with it."));
}

6
src/mainwindow.h

@ -500,6 +500,8 @@ public: @@ -500,6 +500,8 @@ public:
Ui::GeneralSettingsContentsForm* uiSettings;
void adjustSizesAccordingToWrongLabel();
bool applyTunnelsUiToConfigs();
void preventSaveTunnels();
bool isPreventSaveTunnelsMode();
private:
int settingsTitleLabelNominalHeight;
TextBrowserTweaked1 * textBrowser;
@ -894,9 +896,13 @@ private: @@ -894,9 +896,13 @@ private:
//void onLoggingOptionsChange() {}
bool preventSaveTunnelsBool;
SaverImpl* saverPtr;
void DisableTunnelsPage();
public slots:
void showTunnelsPagePreventedMessage();
};
#endif // MAINWINDOW_H

Loading…
Cancel
Save