From f781cce1561eaf578b09c88a4522c40442c60e71 Mon Sep 17 00:00:00 2001 From: Xinyu Hou Date: Wed, 12 Nov 2014 16:44:25 +0000 Subject: [PATCH] Prompt to enable auto connect #4196 --- src/gui/src/AppConfig.cpp | 14 +++++++++++--- src/gui/src/AppConfig.h | 3 +++ src/gui/src/MainWindow.cpp | 31 +++++++++++++++++++++++-------- src/gui/src/MainWindow.h | 2 +- 4 files changed, 38 insertions(+), 12 deletions(-) diff --git a/src/gui/src/AppConfig.cpp b/src/gui/src/AppConfig.cpp index 4acbcb5a..cd31a6bd 100644 --- a/src/gui/src/AppConfig.cpp +++ b/src/gui/src/AppConfig.cpp @@ -54,8 +54,9 @@ AppConfig::AppConfig(QSettings* settings) : m_WizardLastRun(0), m_CryptoPass(), m_ProcessMode(DEFAULT_PROCESS_MODE), - m_AutoConnect(true), - m_ElevateMode(false) + m_AutoConnect(false), + m_ElevateMode(false), + m_AutoConnectPrompted(false) { Q_ASSERT(m_pSettings); @@ -123,8 +124,9 @@ void AppConfig::loadSettings() m_CryptoEnabled = settings().value("cryptoEnabled", false).toBool(); m_Language = settings().value("language", QLocale::system().name()).toString(); m_StartedBefore = settings().value("startedBefore", false).toBool(); - m_AutoConnect = settings().value("autoConnect", true).toBool(); + m_AutoConnect = settings().value("autoConnect", false).toBool(); m_ElevateMode = settings().value("elevateMode", false).toBool(); + m_AutoConnectPrompted = settings().value("autoConnectPrompted", false).toBool(); } void AppConfig::saveSettings() @@ -142,6 +144,7 @@ void AppConfig::saveSettings() settings().setValue("startedBefore", m_StartedBefore); settings().setValue("autoConnect", m_AutoConnect); settings().setValue("elevateMode", m_ElevateMode); + settings().setValue("autoConnectPrompted", m_AutoConnectPrompted); } void AppConfig::setCryptoPass(const QString &s) @@ -165,6 +168,11 @@ void AppConfig::setAutoConnect(bool autoConnect) m_AutoConnect = autoConnect; } +void AppConfig::setAutoConnectPrompted(bool prompted) +{ + m_AutoConnectPrompted = prompted; +} + bool AppConfig::elevateMode() { return m_ElevateMode; diff --git a/src/gui/src/AppConfig.h b/src/gui/src/AppConfig.h index 3ac9c65a..ae872d64 100644 --- a/src/gui/src/AppConfig.h +++ b/src/gui/src/AppConfig.h @@ -70,6 +70,8 @@ class AppConfig bool startedBefore() const { return m_StartedBefore; } bool autoConnect() const { return m_AutoConnect; } void setAutoConnect(bool autoConnect); + bool autoConnectPrompted() { return m_AutoConnectPrompted; } + void setAutoConnectPrompted(bool prompted); QString synergysName() const { return m_SynergysName; } QString synergycName() const { return m_SynergycName; } @@ -115,6 +117,7 @@ class AppConfig bool m_StartedBefore; bool m_AutoConnect; bool m_ElevateMode; + bool m_AutoConnectPrompted; 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 8d152f4e..8522b98c 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -77,8 +77,7 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) : m_pMenuEdit(NULL), m_pMenuWindow(NULL), m_pMenuHelp(NULL), - m_pZeroconfService(NULL), - m_SuppressBonjourWarning(appConfig.autoConnect()) + m_pZeroconfService(NULL) { setupUi(this); @@ -108,6 +107,10 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) : setMinimumSize(size()); #endif + if (!appConfig.autoConnectPrompted()) { + promptAutoConnect(); + } + m_pAutoConnectCheckBox->setChecked(appConfig.autoConnect()); } @@ -896,12 +899,6 @@ void MainWindow::on_m_pButtonApply_clicked() void MainWindow::on_m_pAutoConnectCheckBox_toggled(bool checked) { if (!isBonjourRunning() && checked) { - if (m_SuppressBonjourWarning) { - m_pAutoConnectCheckBox->setChecked(false); - m_SuppressBonjourWarning = false; - return; - } - int r = QMessageBox::warning( this, tr("Synergy"), tr("Auto connect feature requires Bonjour installed.\n\n" @@ -978,3 +975,21 @@ void MainWindow::downloadBonjour() QDesktopServices::openUrl(QUrl(BonjourUrl)); #endif } + +void MainWindow::promptAutoConnect() +{ + int r = QMessageBox::warning( + this, tr("Synergy"), + tr("Do you want to enable auto connect?\n\n" + "This feature helps you establish the connection."), + QMessageBox::Yes | QMessageBox::No); + + if (r == QMessageBox::Yes) { + m_AppConfig.setAutoConnect(true); + } + else { + m_AppConfig.setAutoConnect(false); + } + + m_AppConfig.setAutoConnectPrompted(true); +} diff --git a/src/gui/src/MainWindow.h b/src/gui/src/MainWindow.h index 7e51267e..ac3aba8a 100644 --- a/src/gui/src/MainWindow.h +++ b/src/gui/src/MainWindow.h @@ -149,6 +149,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase bool isServiceRunning(QString name); bool isBonjourRunning(); void downloadBonjour(); + void promptAutoConnect(); private: QSettings& m_Settings; @@ -168,7 +169,6 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase QMenu* m_pMenuWindow; QMenu* m_pMenuHelp; ZeroconfService* m_pZeroconfService; - bool m_SuppressBonjourWarning; private slots: void on_m_pAutoConnectCheckBox_toggled(bool checked);