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_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.
connect(&m_IpcClient, SIGNAL(readLogLine(const QString&)), this, SLOT(appendLogRaw(const QString&)));
@ -95,7 +95,7 @@ MainWindow::~MainWindow()
void MainWindow::start(bool firstRun)
{
onModeChanged(firstRun);
onModeChanged(firstRun, false);
createTrayIcon();
@ -105,12 +105,12 @@ void MainWindow::start(bool firstRun)
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();
@ -118,7 +118,15 @@ void MainWindow::onModeChanged(bool firstRun)
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
{
@ -126,7 +134,7 @@ void MainWindow::onModeChanged(bool firstRun)
sendDaemonCommand("", false);
}
if (appConfig().processMode() == Desktop && !firstRun && appConfig().autoConnect())
if ((appConfig().processMode() == Desktop) && !firstRun && appConfig().autoConnect())
{
startSynergy();
}

View File

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