refactor: move numColumns to general configuation server/gridWidth

This commit is contained in:
sithlord48 2026-06-08 19:30:05 -04:00 committed by Nick Bolton
parent 16141d7156
commit cd1ceccda5
6 changed files with 18 additions and 6 deletions

View file

@ -144,6 +144,7 @@ This section contains options used when in server mode it will begin with `[serv
|:-------------------|:-----------------:|:-----------|
| 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.|
| gridWidth | int | Width of the server's intenal grid used for the computer layout (default: 5) |
| protocol | `barrier` or `synergy` | The protocol to use when saying hello to clients. Can be set to barrier or synergy. If not set barrier is used as the default |
| xdpRestoreToken | UUID | Restore token provided by XDG portals |

View file

@ -1,6 +1,6 @@
/*
* Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2024 - 2025 Chris Rizzitello <sithlord48@gmail.com>
* SPDX-FileCopyrightText: (C) 2024 - 2026 Chris Rizzitello <sithlord48@gmail.com>
* SPDX-FileCopyrightText: (C) 2025 Synergy App Ltd
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
*/
@ -23,6 +23,8 @@ const auto kCopyright = //
const auto kCoreBinName = "@CORE_BINARY@";
const auto kCoreIpcName = "@CMAKE_PROJECT_NAME@-core";
const auto kServerGridWidth = 5;
#ifdef _WIN32
// clang-format off

View file

@ -111,7 +111,7 @@ void Settings::cleanSettings()
{
const QStringList keys = m_settings->allKeys();
for (const QString &key : keys) {
if (key.startsWith(QStringLiteral("internalConfig/protocol")))
if (m_oldServerConfigKeys.contains(key))
m_settings->remove(key);
if (key.startsWith(QStringLiteral("internalConfig")))
continue;
@ -210,6 +210,9 @@ QVariant Settings::defaultValue(const QString &key)
if (key == Server::Protocol)
return QVariant::fromValue(NetworkProtocol::Barrier);
if (key == Server::GridWidth)
return kServerGridWidth;
return QVariant();
}

View file

@ -105,6 +105,7 @@ public:
{
inline static const auto ExternalConfig = QStringLiteral("server/externalConfig");
inline static const auto ExternalConfigFile = QStringLiteral("server/externalConfigFile");
inline static const auto GridWidth = QStringLiteral("server/gridWidth");
inline static const auto Protocol = QStringLiteral("server/protocol");
inline static const auto XdpRestoreToken = QStringLiteral("server/xdpRestoreToken");
};
@ -241,6 +242,7 @@ private:
, Settings::Security::TlsEnabled
, Settings::Server::ExternalConfig
, Settings::Server::ExternalConfigFile
, Settings::Server::GridWidth
, Settings::Server::Protocol
, Settings::Server::XdpRestoreToken
};
@ -285,5 +287,10 @@ private:
/* OLD KEY NEW KEY */
{QStringLiteral("core/screenName"), Settings::Core::ComputerName}
};
// Contains settings removed from server-configuration file
inline static const QStringList m_oldServerConfigKeys = {
QStringLiteral("internalConfig/protocol")
, QStringLiteral("internalConfig/numColumns")
};
// clang-format on
};

View file

@ -102,7 +102,6 @@ void ServerConfig::commit()
settings().beginGroup("internalConfig");
settings().remove("");
settings().setValue("numColumns", numColumns());
settings().setValue("numRows", numRows());
settings().setValue("hasHeartbeat", hasHeartbeat());
@ -149,7 +148,7 @@ void ServerConfig::recall()
settings().beginGroup("internalConfig");
setNumColumns(settings().value("numColumns", 5).toInt());
setNumColumns(Settings::value(Settings::Server::GridWidth).toInt());
setNumRows(settings().value("numRows", 3).toInt());
// we need to know the number of columns and rows before we can set up

View file

@ -7,6 +7,7 @@
#pragma once
#include "common/Constants.h"
#include "common/NetworkProtocol.h"
#include "gui/Hotkey.h"
#include "gui/config/ScreenConfig.h"
@ -14,7 +15,6 @@
#include <QList>
const auto kDefaultColumns = 5;
const auto kDefaultRows = 3;
class QTextStream;
@ -36,7 +36,7 @@ class ServerConfig : public ScreenConfig
friend QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config);
public:
explicit ServerConfig(int columns = kDefaultColumns, int rows = kDefaultRows);
explicit ServerConfig(int columns = kServerGridWidth, int rows = kDefaultRows);
~ServerConfig() = default;
bool operator==(const ServerConfig &sc) const;