fixed: service mode sends command every time you start (causing server/client to restart)

fixed: apply button stops working when you switch from desktop to service mode.
This commit is contained in:
Nick Bolton 2012-07-13 18:44:43 +00:00
parent 131aa190c3
commit a62fee84cc
2 changed files with 17 additions and 9 deletions

View File

@ -77,7 +77,7 @@ MainWindow::MainWindow(QSettings& settings, AppConfig& appConfig) :
m_versionChecker.setApp(appPath(appConfig.synergycName())); m_versionChecker.setApp(appPath(appConfig.synergycName()));
m_SetupWizard = new SetupWizard(*this, false); m_SetupWizard = new SetupWizard(*this, false);
connect(m_SetupWizard, SIGNAL(finished(int)), this, SLOT(onModeChanged())); connect(m_SetupWizard, SIGNAL(finished(int)), this, SLOT(wizardFinished()));
// ipc must always be enabled, so that we can disable command when switching to desktop mode. // ipc must always be enabled, so that we can disable command when switching to desktop mode.
connect(&m_IpcClient, SIGNAL(readLogLine(const QString&)), this, SLOT(appendLogRaw(const QString&))); connect(&m_IpcClient, SIGNAL(readLogLine(const QString&)), this, SLOT(appendLogRaw(const QString&)));
@ -95,7 +95,7 @@ MainWindow::~MainWindow()
void MainWindow::start(bool firstRun) void MainWindow::start(bool firstRun)
{ {
onModeChanged(firstRun); onModeChanged(firstRun, false);
createTrayIcon(); createTrayIcon();
@ -105,12 +105,12 @@ void MainWindow::start(bool firstRun)
m_versionChecker.checkLatest(); m_versionChecker.checkLatest();
} }
void MainWindow::onModeChanged() void MainWindow::wizardFinished()
{ {
onModeChanged(false); onModeChanged(false, true);
} }
void MainWindow::onModeChanged(bool firstRun) void MainWindow::onModeChanged(bool firstRun, bool forceServiceApply)
{ {
refreshStartButton(); refreshStartButton();
@ -118,7 +118,15 @@ void MainWindow::onModeChanged(bool firstRun)
if (appConfig().processMode() == Service) if (appConfig().processMode() == Service)
{ {
startSynergy(); // ensure that the apply button actually does something, since desktop
// mode screws around with connecting/disconnecting the action.
disconnect(m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStartSynergy, SLOT(trigger()));
connect(m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStartSynergy, SLOT(trigger()));
if (firstRun || forceServiceApply)
{
startSynergy();
}
} }
else else
{ {
@ -126,7 +134,7 @@ void MainWindow::onModeChanged(bool firstRun)
sendDaemonCommand("", false); sendDaemonCommand("", false);
} }
if (appConfig().processMode() == Desktop && !firstRun && appConfig().autoConnect()) if ((appConfig().processMode() == Desktop) && !firstRun && appConfig().autoConnect())
{ {
startSynergy(); startSynergy();
} }

View File

@ -112,8 +112,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
void logError(); void logError();
void updateFound(const QString& version); void updateFound(const QString& version);
void refreshStartButton(); void refreshStartButton();
void onModeChanged(); void wizardFinished();
void onModeChanged(bool firstRun);
protected: protected:
QSettings& settings() { return m_Settings; } QSettings& settings() { return m_Settings; }
@ -135,6 +134,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
void setStatus(const QString& status); void setStatus(const QString& status);
void sendDaemonCommand(const QString& command, bool showErrors); void sendDaemonCommand(const QString& command, bool showErrors);
void sendIpcMessage(qIpcMessageType type, const char* buffer, bool showErrors); void sendIpcMessage(qIpcMessageType type, const char* buffer, bool showErrors);
void onModeChanged(bool firstRun, bool forceServiceApply);
private: private:
QSettings& m_Settings; QSettings& m_Settings;