From a2d3b5c7e21dc282e576037f578bfde950b6788b Mon Sep 17 00:00:00 2001 From: jerry Date: Tue, 26 Aug 2014 11:22:09 +0000 Subject: [PATCH] issue #65 - Auto config feature using Zeroconf/Bonjour gave user an option to toggle auto connect --- src/gui/res/MainWindowBase.ui | 11 +++++++++-- src/gui/src/AppConfig.cpp | 10 +++++++++- src/gui/src/AppConfig.h | 3 +++ src/gui/src/MainWindow.cpp | 13 ++++++++++++- src/gui/src/MainWindow.h | 1 + 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/gui/res/MainWindowBase.ui b/src/gui/res/MainWindowBase.ui index faa87258..b6489244 100644 --- a/src/gui/res/MainWindowBase.ui +++ b/src/gui/res/MainWindowBase.ui @@ -271,7 +271,7 @@ - + &Server IP: @@ -281,7 +281,7 @@ - + @@ -291,6 +291,13 @@ + + + + Auto connect + + + diff --git a/src/gui/src/AppConfig.cpp b/src/gui/src/AppConfig.cpp index 855304db..15ed3c03 100644 --- a/src/gui/src/AppConfig.cpp +++ b/src/gui/src/AppConfig.cpp @@ -53,7 +53,8 @@ AppConfig::AppConfig(QSettings* settings) : m_LogLevel(0), m_WizardLastRun(0), m_CryptoPass(), - m_ProcessMode(DEFAULT_PROCESS_MODE) + m_ProcessMode(DEFAULT_PROCESS_MODE), + m_AutoConnect(true) { Q_ASSERT(m_pSettings); @@ -123,6 +124,7 @@ void AppConfig::loadSettings() m_PremiumEmail = settings().value("premiumEmail", "").toString(); m_PremiumToken = settings().value("premiumToken", "").toString(); m_StartedBefore = settings().value("startedBefore", false).toBool(); + m_AutoConnect = settings().value("autoConnect", true).toBool(); } void AppConfig::saveSettings() @@ -140,6 +142,7 @@ void AppConfig::saveSettings() settings().setValue("premiumEmail", m_PremiumEmail); settings().setValue("premiumToken", m_PremiumToken); settings().setValue("startedBefore", m_StartedBefore); + settings().setValue("autoConnect", m_AutoConnect); } void AppConfig::setCryptoPass(const QString &s) @@ -164,3 +167,8 @@ bool AppConfig::isPremium() QString hashResult = hash(hashSrc); return hashResult == m_PremiumToken; } + +void AppConfig::setAutoConnect(bool autoConnect) +{ + m_AutoConnect = autoConnect; +} diff --git a/src/gui/src/AppConfig.h b/src/gui/src/AppConfig.h index 4b962186..03f8044d 100644 --- a/src/gui/src/AppConfig.h +++ b/src/gui/src/AppConfig.h @@ -70,6 +70,8 @@ class AppConfig const QString& premiumEmail() const { return m_PremiumEmail; } const QString& premiumToken() const { return m_PremiumToken; } bool startedBefore() const { return m_StartedBefore; } + bool autoConnect() const { return m_AutoConnect; } + void setAutoConnect(bool autoConnect); QString synergysName() const { return m_SynergysName; } QString synergycName() const { return m_SynergycName; } @@ -116,6 +118,7 @@ class AppConfig QString m_PremiumEmail; QString m_PremiumToken; bool m_StartedBefore; + bool m_AutoConnect; static const char m_SynergysName[]; static const char m_SynergycName[]; diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index dbb70d8b..fb884275 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -112,6 +112,7 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) : updateZeroconfService(); + m_pAutoConnectCheckBox->setChecked(appConfig.autoConnect()); } MainWindow::~MainWindow() @@ -808,9 +809,12 @@ void MainWindow::updateZeroconfService() if (!m_AppConfig.wizardShouldRun()) { if (m_pZeroconfService) { delete m_pZeroconfService; + m_pZeroconfService = NULL; } - m_pZeroconfService = new ZeroconfService(this); + if (m_AppConfig.autoConnect() || synergyType() == synergyServer) { + m_pZeroconfService = new ZeroconfService(this); + } } } @@ -935,3 +939,10 @@ void MainWindow::on_m_pButtonApply_clicked() { startSynergy(); } + +void MainWindow::on_m_pAutoConnectCheckBox_toggled(bool checked) +{ + m_pLineEditHostname->setDisabled(checked); + appConfig().setAutoConnect(checked); + updateZeroconfService(); +} diff --git a/src/gui/src/MainWindow.h b/src/gui/src/MainWindow.h index 80836ed7..86381a02 100644 --- a/src/gui/src/MainWindow.h +++ b/src/gui/src/MainWindow.h @@ -171,6 +171,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase ZeroconfService* m_pZeroconfService; private slots: + void on_m_pAutoConnectCheckBox_toggled(bool checked); void on_m_pButtonApply_clicked(); };