diff --git a/docs/user/configuration.md b/docs/user/configuration.md index 8de0bcf34..80962a5f6 100644 --- a/docs/user/configuration.md +++ b/docs/user/configuration.md @@ -143,6 +143,7 @@ This section contains options used when in server mode it will begin with `[serv |Option | Valid Values |Description| |:-------------------|:-----------------:|:-----------| | enableHeartbeat | `true` or `false` | Send a heartbeat to connected clients; this has been replaced by internal keep alive (default: false)| +| enableSwitchDelay | `true` or `false` | Switching will be delayed by the set value (default: false)| | externalConfig | `true` or `false` | When true use the external config path | | externalConfigFile | Filepath | Path the server config file if it does not exist the GUI will it generated based on the `internalConfig` section.| | gridHeight | int | Height of the server's intenal grid used for the computer layout (default: 3)| @@ -161,7 +162,6 @@ clipboardSharing=true clipboardSharingSize=@Variant(\0\0\0\x84\0\0\0\0\0\0<\0) defaultLockToScreenState=false disableLockToScreen=false -hasSwitchDelay=false hasSwitchDoubleTap=false heartbeat=5000 hotkeys\1\actions\1\activeOnRelease=false diff --git a/src/lib/common/Settings.h b/src/lib/common/Settings.h index 8cdc6276b..3d00e7338 100644 --- a/src/lib/common/Settings.h +++ b/src/lib/common/Settings.h @@ -105,6 +105,7 @@ public: struct Server { inline static const auto EnableHeatbeat = QStringLiteral("server/enableHeatbeat"); + inline static const auto EnableSwitchDelay = QStringLiteral("server/enableSwitchDelay"); inline static const auto ExternalConfig = QStringLiteral("server/externalConfig"); inline static const auto ExternalConfigFile = QStringLiteral("server/externalConfigFile"); inline static const auto GridHeight = QStringLiteral("server/gridHeight"); @@ -245,6 +246,7 @@ private: , Settings::Security::KeySize , Settings::Security::TlsEnabled , Settings::Server::EnableHeatbeat + , Settings::Server::EnableSwitchDelay , Settings::Server::ExternalConfig , Settings::Server::ExternalConfigFile , Settings::Server::GridHeight @@ -263,15 +265,16 @@ private: , Settings::Gui::IgnoreMissingKeyboardLayouts , Settings::Core::PreventSleep , Settings::Core::UseWlClipboard - , Settings::Server::EnableHeatbeat , Settings::Core::EnableEnterCommand , Settings::Core::EnableExitCommand , Settings::Client::DynamicConnectionRetry - , Settings::Server::ExternalConfig , Settings::Client::InvertYScroll , Settings::Client::InvertXScroll , Settings::Log::ToFile , Settings::Log::GuiDebug + , Settings::Server::EnableHeatbeat + , Settings::Server::EnableSwitchDelay + , Settings::Server::ExternalConfig }; // When checking the default values this list contains the ones that default to true. @@ -297,6 +300,7 @@ private: // Contains settings removed from server-configuration file inline static const QStringList m_oldServerConfigKeys = { QStringLiteral("internalConfig/hasHeartbeat") + , QStringLiteral("internalConfig/hasSwitchDelay") , QStringLiteral("internalConfig/protocol") , QStringLiteral("internalConfig/numColumns") , QStringLiteral("internalConfig/numRows") diff --git a/src/lib/gui/config/ServerConfig.cpp b/src/lib/gui/config/ServerConfig.cpp index 04f777eb1..8a4203876 100644 --- a/src/lib/gui/config/ServerConfig.cpp +++ b/src/lib/gui/config/ServerConfig.cpp @@ -56,7 +56,6 @@ bool ServerConfig::operator==(const ServerConfig &sc) const m_Heartbeat == sc.m_Heartbeat && // m_RelativeMouseMoves == sc.m_RelativeMouseMoves && // m_Win32KeepForeground == sc.m_Win32KeepForeground && // - m_HasSwitchDelay == sc.m_HasSwitchDelay && // m_SwitchDelay == sc.m_SwitchDelay && // m_HasSwitchDoubleTap == sc.m_HasSwitchDoubleTap && // m_SwitchDoubleTap == sc.m_SwitchDoubleTap && // @@ -101,7 +100,6 @@ void ServerConfig::commit() settings().setValue("heartbeat", heartbeat()); settings().setValue("relativeMouseMoves", relativeMouseMoves()); settings().setValue("win32KeepForeground", win32KeepForeground()); - settings().setValue("hasSwitchDelay", hasSwitchDelay()); settings().setValue("switchDelay", switchDelay()); settings().setValue("hasSwitchDoubleTap", hasSwitchDoubleTap()); settings().setValue("switchDoubleTap", switchDoubleTap()); @@ -151,7 +149,6 @@ void ServerConfig::recall() setHeartbeat(settings().value("heartbeat", 5000).toInt()); setRelativeMouseMoves(settings().value("relativeMouseMoves", false).toBool()); setWin32KeepForeground(settings().value("win32KeepForeground", false).toBool()); - haveSwitchDelay(settings().value("hasSwitchDelay", false).toBool()); setSwitchDelay(settings().value("switchDelay", 250).toInt()); haveSwitchDoubleTap(settings().value("hasSwitchDoubleTap", false).toBool()); setSwitchDoubleTap(settings().value("switchDoubleTap", 250).toInt()); @@ -260,7 +257,7 @@ QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config) outStream << "\t" << "clipboardSharingSize = " << config.clipboardSharingSize() << Qt::endl; - if (config.hasSwitchDelay()) + if (Settings::value(Settings::Server::EnableSwitchDelay).toBool()) outStream << "\t" << "switchDelay = " << config.switchDelay() << Qt::endl; diff --git a/src/lib/gui/config/ServerConfig.h b/src/lib/gui/config/ServerConfig.h index 3ea447a7e..0eee78adc 100644 --- a/src/lib/gui/config/ServerConfig.h +++ b/src/lib/gui/config/ServerConfig.h @@ -52,10 +52,6 @@ public: { return m_Win32KeepForeground; } - bool hasSwitchDelay() const - { - return m_HasSwitchDelay; - } int switchDelay() const { return m_SwitchDelay; @@ -142,10 +138,6 @@ private: { m_Win32KeepForeground = on; } - void haveSwitchDelay(bool on) - { - m_HasSwitchDelay = on; - } void setSwitchDelay(int val) { m_SwitchDelay = val; @@ -197,7 +189,6 @@ private: int m_Heartbeat = 0; bool m_RelativeMouseMoves = false; bool m_Win32KeepForeground = false; - bool m_HasSwitchDelay = false; int m_SwitchDelay = 0; bool m_HasSwitchDoubleTap = false; int m_SwitchDoubleTap = 0; diff --git a/src/lib/gui/dialogs/ServerConfigDialog.cpp b/src/lib/gui/dialogs/ServerConfigDialog.cpp index b370d2964..5ea7358b5 100644 --- a/src/lib/gui/dialogs/ServerConfigDialog.cpp +++ b/src/lib/gui/dialogs/ServerConfigDialog.cpp @@ -77,6 +77,7 @@ void ServerConfigDialog::accept() setOriginalServerConfig(serverConfig()); Settings::setValue(Settings::Server::Protocol, networkProtocolToOption(m_protocol)); Settings::setValue(Settings::Server::EnableHeatbeat, m_enableHeartbeat); + Settings::setValue(Settings::Server::EnableSwitchDelay, m_enableSwitchDelay); QDialog::accept(); } @@ -300,8 +301,8 @@ void ServerConfigDialog::setSwitchDoubleTap(int within) void ServerConfigDialog::toggleSwitchDelay(bool enable) { + m_enableSwitchDelay = enable; ui->sbSwitchDelay->setEnabled(enable); - serverConfig().haveSwitchDelay(enable); onChange(); } @@ -386,7 +387,9 @@ void ServerConfigDialog::loadFromConfig() ui->sbHeartbeat->setValue(serverConfig().heartbeat()); ui->cbRelativeMouseMoves->setChecked(serverConfig().relativeMouseMoves()); ui->cbWin32KeepForeground->setChecked(serverConfig().win32KeepForeground()); - ui->cbSwitchDelay->setChecked(serverConfig().hasSwitchDelay()); + + m_enableSwitchDelay = Settings::value(Settings::Server::EnableSwitchDelay).toBool(); + ui->cbSwitchDelay->setChecked(m_enableSwitchDelay); ui->sbSwitchDelay->setValue(serverConfig().switchDelay()); ui->cbSwitchDoubleTap->setChecked(serverConfig().hasSwitchDoubleTap()); ui->sbSwitchDelay->setEnabled(ui->cbSwitchDelay->isChecked()); @@ -507,7 +510,8 @@ void ServerConfigDialog::onChange() bool isAppConfigDataEqual = m_originalServerConfigIsExternal == serverConfig().useExternalConfig() && m_originalServerConfigUsesExternalFile == serverConfig().configFile() && m_protocol == Settings::networkProtocol() && - m_enableHeartbeat == Settings::value(Settings::Server::EnableHeatbeat).toBool(); + m_enableHeartbeat == Settings::value(Settings::Server::EnableHeatbeat).toBool() && + m_enableSwitchDelay == Settings::value(Settings::Server::EnableSwitchDelay).toBool(); ui->buttonBox->button(QDialogButtonBox::Ok) ->setEnabled(!isAppConfigDataEqual || !(m_originalServerConfig == m_serverConfig)); } diff --git a/src/lib/gui/dialogs/ServerConfigDialog.h b/src/lib/gui/dialogs/ServerConfigDialog.h index 6799ec785..c8cb89bcb 100644 --- a/src/lib/gui/dialogs/ServerConfigDialog.h +++ b/src/lib/gui/dialogs/ServerConfigDialog.h @@ -105,6 +105,7 @@ private: ServerConfig &m_originalServerConfig; NetworkProtocol m_protocol; bool m_enableHeartbeat; + bool m_enableSwitchDelay; bool m_originalServerConfigIsExternal; QString m_originalServerConfigUsesExternalFile; ServerConfig m_serverConfig;