issue #65 - Auto config feature using Zeroconf/Bonjour

gave user an option to toggle auto connect
This commit is contained in:
jerry 2014-08-26 11:22:09 +00:00
parent 828f7c02b1
commit a2d3b5c7e2
5 changed files with 34 additions and 4 deletions

View File

@ -271,7 +271,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="2" column="0">
<widget class="QLabel" name="m_pLabelServerName"> <widget class="QLabel" name="m_pLabelServerName">
<property name="text"> <property name="text">
<string>&amp;Server IP:</string> <string>&amp;Server IP:</string>
@ -281,7 +281,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="2" column="1">
<widget class="QLineEdit" name="m_pLineEditHostname"/> <widget class="QLineEdit" name="m_pLineEditHostname"/>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
@ -291,6 +291,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QCheckBox" name="m_pAutoConnectCheckBox">
<property name="text">
<string>Auto connect</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@ -53,7 +53,8 @@ AppConfig::AppConfig(QSettings* settings) :
m_LogLevel(0), m_LogLevel(0),
m_WizardLastRun(0), m_WizardLastRun(0),
m_CryptoPass(), m_CryptoPass(),
m_ProcessMode(DEFAULT_PROCESS_MODE) m_ProcessMode(DEFAULT_PROCESS_MODE),
m_AutoConnect(true)
{ {
Q_ASSERT(m_pSettings); Q_ASSERT(m_pSettings);
@ -123,6 +124,7 @@ void AppConfig::loadSettings()
m_PremiumEmail = settings().value("premiumEmail", "").toString(); m_PremiumEmail = settings().value("premiumEmail", "").toString();
m_PremiumToken = settings().value("premiumToken", "").toString(); m_PremiumToken = settings().value("premiumToken", "").toString();
m_StartedBefore = settings().value("startedBefore", false).toBool(); m_StartedBefore = settings().value("startedBefore", false).toBool();
m_AutoConnect = settings().value("autoConnect", true).toBool();
} }
void AppConfig::saveSettings() void AppConfig::saveSettings()
@ -140,6 +142,7 @@ void AppConfig::saveSettings()
settings().setValue("premiumEmail", m_PremiumEmail); settings().setValue("premiumEmail", m_PremiumEmail);
settings().setValue("premiumToken", m_PremiumToken); settings().setValue("premiumToken", m_PremiumToken);
settings().setValue("startedBefore", m_StartedBefore); settings().setValue("startedBefore", m_StartedBefore);
settings().setValue("autoConnect", m_AutoConnect);
} }
void AppConfig::setCryptoPass(const QString &s) void AppConfig::setCryptoPass(const QString &s)
@ -164,3 +167,8 @@ bool AppConfig::isPremium()
QString hashResult = hash(hashSrc); QString hashResult = hash(hashSrc);
return hashResult == m_PremiumToken; return hashResult == m_PremiumToken;
} }
void AppConfig::setAutoConnect(bool autoConnect)
{
m_AutoConnect = autoConnect;
}

View File

@ -70,6 +70,8 @@ class AppConfig
const QString& premiumEmail() const { return m_PremiumEmail; } const QString& premiumEmail() const { return m_PremiumEmail; }
const QString& premiumToken() const { return m_PremiumToken; } const QString& premiumToken() const { return m_PremiumToken; }
bool startedBefore() const { return m_StartedBefore; } bool startedBefore() const { return m_StartedBefore; }
bool autoConnect() const { return m_AutoConnect; }
void setAutoConnect(bool autoConnect);
QString synergysName() const { return m_SynergysName; } QString synergysName() const { return m_SynergysName; }
QString synergycName() const { return m_SynergycName; } QString synergycName() const { return m_SynergycName; }
@ -116,6 +118,7 @@ class AppConfig
QString m_PremiumEmail; QString m_PremiumEmail;
QString m_PremiumToken; QString m_PremiumToken;
bool m_StartedBefore; bool m_StartedBefore;
bool m_AutoConnect;
static const char m_SynergysName[]; static const char m_SynergysName[];
static const char m_SynergycName[]; static const char m_SynergycName[];

View File

@ -112,6 +112,7 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) :
updateZeroconfService(); updateZeroconfService();
m_pAutoConnectCheckBox->setChecked(appConfig.autoConnect());
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@ -808,9 +809,12 @@ void MainWindow::updateZeroconfService()
if (!m_AppConfig.wizardShouldRun()) { if (!m_AppConfig.wizardShouldRun()) {
if (m_pZeroconfService) { if (m_pZeroconfService) {
delete 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(); startSynergy();
} }
void MainWindow::on_m_pAutoConnectCheckBox_toggled(bool checked)
{
m_pLineEditHostname->setDisabled(checked);
appConfig().setAutoConnect(checked);
updateZeroconfService();
}

View File

@ -171,6 +171,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
ZeroconfService* m_pZeroconfService; ZeroconfService* m_pZeroconfService;
private slots: private slots:
void on_m_pAutoConnectCheckBox_toggled(bool checked);
void on_m_pButtonApply_clicked(); void on_m_pButtonApply_clicked();
}; };