From 66a1ffa5f5a0bee13236451a4d5b9887664ca557 Mon Sep 17 00:00:00 2001 From: Xinyu Hou Date: Tue, 18 Nov 2014 14:16:29 +0000 Subject: [PATCH] Added ignore auto connect clients check box --- src/gui/res/ServerConfigDialogBase.ui | 2 +- src/gui/src/MainWindow.cpp | 30 ++++++++++++++------------- src/gui/src/ServerConfig.cpp | 3 +++ src/gui/src/ServerConfig.h | 3 +++ src/gui/src/ServerConfigDialog.cpp | 3 +++ 5 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/gui/res/ServerConfigDialogBase.ui b/src/gui/res/ServerConfigDialogBase.ui index 1d978b1f..9edcde63 100644 --- a/src/gui/res/ServerConfigDialogBase.ui +++ b/src/gui/res/ServerConfigDialogBase.ui @@ -507,7 +507,7 @@ Double click on a screen to edit its settings. - Ingore all clients from auto connect + Ignore auto connect clients diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index f9243e8f..5ad778c2 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -884,21 +884,23 @@ void MainWindow::on_m_pActionSettings_triggered() void MainWindow::autoAddScreen(const QString name) { - int r = m_ServerConfig.autoAddScreen(name); - if (r != kAutoAddScreenOk) { - switch (r) { - case kAutoAddScreenManualServer: - showConfigureServer( - tr("Please add the server (%1) to the grid.") - .arg(appConfig().screenName())); - break; + if (!m_ServerConfig.ignoreAutoConnectClient()) { + int r = m_ServerConfig.autoAddScreen(name); + if (r != kAutoAddScreenOk) { + switch (r) { + case kAutoAddScreenManualServer: + showConfigureServer( + tr("Please add the server (%1) to the grid.") + .arg(appConfig().screenName())); + break; - case kAutoAddScreenManualClient: - showConfigureServer( - tr("Please drag the new client screen (%1) " - "to the desired position on the grid.") - .arg(name)); - break; + case kAutoAddScreenManualClient: + showConfigureServer( + tr("Please drag the new client screen (%1) " + "to the desired position on the grid.") + .arg(name)); + break; + } } } } diff --git a/src/gui/src/ServerConfig.cpp b/src/gui/src/ServerConfig.cpp index 3153aa6d..a53a1a21 100644 --- a/src/gui/src/ServerConfig.cpp +++ b/src/gui/src/ServerConfig.cpp @@ -49,6 +49,7 @@ ServerConfig::ServerConfig(QSettings* settings, int numColumns, int numRows , m_NumColumns(numColumns), m_NumRows(numRows), m_ServerName(serverName), + m_IgnoreAutoConnectClient(false), m_pMainWindow(mainWindow) { Q_ASSERT(m_pSettings); @@ -112,6 +113,7 @@ void ServerConfig::saveSettings() settings().setValue("hasSwitchDoubleTap", hasSwitchDoubleTap()); settings().setValue("switchDoubleTap", switchDoubleTap()); settings().setValue("switchCornerSize", switchCornerSize()); + settings().setValue("ignoreAutoConnectClient", ignoreAutoConnectClient()); writeSettings(settings(), switchCorners(), "switchCorner"); @@ -154,6 +156,7 @@ void ServerConfig::loadSettings() haveSwitchDoubleTap(settings().value("hasSwitchDoubleTap", false).toBool()); setSwitchDoubleTap(settings().value("switchDoubleTap", 250).toInt()); setSwitchCornerSize(settings().value("switchCornerSize").toInt()); + setIgnoreAutoConnectClient(settings().value("ignoreAutoConnectClient").toBool()); readSettings(settings(), switchCorners(), "switchCorner", false, NumSwitchCorners); diff --git a/src/gui/src/ServerConfig.h b/src/gui/src/ServerConfig.h index f770b0e7..fecfb67f 100644 --- a/src/gui/src/ServerConfig.h +++ b/src/gui/src/ServerConfig.h @@ -60,6 +60,7 @@ class ServerConfig : public BaseConfig int switchCornerSize() const { return m_SwitchCornerSize; } const QList& switchCorners() const { return m_SwitchCorners; } const HotkeyList& hotkeys() const { return m_Hotkeys; } + bool ignoreAutoConnectClient() const { return m_IgnoreAutoConnectClient; } void saveSettings(); void loadSettings(); @@ -86,6 +87,7 @@ class ServerConfig : public BaseConfig void setSwitchDoubleTap(int val) { m_SwitchDoubleTap = val; } void setSwitchCorner(int c, bool on) { m_SwitchCorners[c] = on; } void setSwitchCornerSize(int val) { m_SwitchCornerSize = val; } + void setIgnoreAutoConnectClient(bool on) { m_IgnoreAutoConnectClient = on; } QList& switchCorners() { return m_SwitchCorners; } HotkeyList& hotkeys() { return m_Hotkeys; } @@ -116,6 +118,7 @@ class ServerConfig : public BaseConfig QList m_SwitchCorners; HotkeyList m_Hotkeys; QString m_ServerName; + bool m_IgnoreAutoConnectClient; MainWindow* m_pMainWindow; }; diff --git a/src/gui/src/ServerConfigDialog.cpp b/src/gui/src/ServerConfigDialog.cpp index 46e47f71..182e9cab 100644 --- a/src/gui/src/ServerConfigDialog.cpp +++ b/src/gui/src/ServerConfigDialog.cpp @@ -54,6 +54,8 @@ ServerConfigDialog::ServerConfigDialog(QWidget* parent, ServerConfig& config, co m_pCheckBoxCornerBottomRight->setChecked(serverConfig().switchCorner(BaseConfig::BottomRight)); m_pSpinBoxSwitchCornerSize->setValue(serverConfig().switchCornerSize()); + m_pCheckBoxIgnoreAutoConnectClient->setChecked(serverConfig().ignoreAutoConnectClient()); + foreach(const Hotkey& hotkey, serverConfig().hotkeys()) m_pListHotkeys->addItem(hotkey.text()); @@ -94,6 +96,7 @@ void ServerConfigDialog::accept() serverConfig().setSwitchCorner(BaseConfig::BottomLeft, m_pCheckBoxCornerBottomLeft->isChecked()); serverConfig().setSwitchCorner(BaseConfig::BottomRight, m_pCheckBoxCornerBottomRight->isChecked()); serverConfig().setSwitchCornerSize(m_pSpinBoxSwitchCornerSize->value()); + serverConfig().setIgnoreAutoConnectClient(m_pCheckBoxIgnoreAutoConnectClient->isChecked()); // now that the dialog has been accepted, copy the new server config to the original one, // which is a reference to the one in MainWindow.