refactor: remove public access to serverConfig row and column info

This commit is contained in:
sithlord48 2026-06-08 19:48:04 -04:00 committed by Nick Bolton
parent 6105e4025a
commit c4f65c04a3
4 changed files with 14 additions and 28 deletions

View file

@ -33,7 +33,7 @@ static const struct
const int serverDefaultIndex = 7; const int serverDefaultIndex = 7;
ServerConfig::ServerConfig(int columns, int rows) : m_Screens(columns), m_Columns(columns), m_Rows(rows) ServerConfig::ServerConfig(int columns, int rows) : m_Screens(columns), m_columns(columns), m_rows(rows)
{ {
recall(); recall();
} }
@ -53,8 +53,6 @@ bool ServerConfig::save(const QString &fileName) const
bool ServerConfig::operator==(const ServerConfig &sc) const bool ServerConfig::operator==(const ServerConfig &sc) const
{ {
return m_Screens == sc.m_Screens && // return m_Screens == sc.m_Screens && //
m_Columns == sc.m_Columns && //
m_Rows == sc.m_Rows && //
m_HasHeartbeat == sc.m_HasHeartbeat && // m_HasHeartbeat == sc.m_HasHeartbeat && //
m_Heartbeat == sc.m_Heartbeat && // m_Heartbeat == sc.m_Heartbeat && //
m_Protocol == sc.m_Protocol && // m_Protocol == sc.m_Protocol && //
@ -91,7 +89,7 @@ void ServerConfig::setupScreens()
// There must always be screen objects for each cell in the screens QList. // There must always be screen objects for each cell in the screens QList.
// Unused screens are identified by having an empty name. // Unused screens are identified by having an empty name.
for (int i = 0; i < numColumns() * numRows(); i++) for (int i = 0; i < m_columns * m_rows; i++)
addScreen(Screen()); addScreen(Screen());
} }
@ -146,8 +144,8 @@ void ServerConfig::recall()
settings().beginGroup("internalConfig"); settings().beginGroup("internalConfig");
setNumColumns(Settings::value(Settings::Server::GridWidth).toInt()); m_columns = Settings::value(Settings::Server::GridWidth).toInt();
setNumRows(Settings::value(Settings::Server::GridHeight).toInt()); m_rows = Settings::value(Settings::Server::GridHeight).toInt();
// we need to know the number of columns and rows before we can set up // we need to know the number of columns and rows before we can set up
// ourselves // ourselves
@ -202,10 +200,10 @@ int ServerConfig::adjacentScreenIndex(int idx, int deltaColumn, int deltaRow) co
// if we're at the left or right end of the table, don't find results going // if we're at the left or right end of the table, don't find results going
// further left or right // further left or right
if ((deltaColumn > 0 && (idx + 1) % numColumns() == 0) || (deltaColumn < 0 && idx % numColumns() == 0)) if ((deltaColumn > 0 && (idx + 1) % m_columns == 0) || (deltaColumn < 0 && idx % m_columns == 0))
return -1; return -1;
int arrayPos = idx + deltaColumn + deltaRow * numColumns(); int arrayPos = idx + deltaColumn + deltaRow * m_columns;
if (arrayPos >= screens().size() || arrayPos < 0) if (arrayPos >= screens().size() || arrayPos < 0)
return -1; return -1;

View file

@ -47,14 +47,6 @@ public:
// //
// New methods // New methods
// //
int numColumns() const
{
return m_Columns;
}
int numRows() const
{
return m_Rows;
}
bool hasHeartbeat() const bool hasHeartbeat() const
{ {
return m_HasHeartbeat; return m_HasHeartbeat;
@ -153,14 +145,6 @@ private:
{ {
m_Screens.append(screen); m_Screens.append(screen);
} }
void setNumColumns(int n)
{
m_Columns = n;
}
void setNumRows(int n)
{
m_Rows = n;
}
void haveHeartbeat(bool on) void haveHeartbeat(bool on)
{ {
m_HasHeartbeat = on; m_HasHeartbeat = on;
@ -251,8 +235,8 @@ private:
HotkeyList m_Hotkeys; HotkeyList m_Hotkeys;
ScreenList m_Screens; ScreenList m_Screens;
int m_Columns; int m_columns;
int m_Rows; int m_rows;
size_t m_ClipboardSharingSize = defaultClipboardSharingSize(); size_t m_ClipboardSharingSize = defaultClipboardSharingSize();
}; };

View file

@ -25,11 +25,13 @@ using enum ScreenConfig::SwitchCorner;
ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config) ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config)
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
ui{std::make_unique<Ui::ServerConfigDialog>()}, ui{std::make_unique<Ui::ServerConfigDialog>()},
m_columns{Settings::value(Settings::Server::GridWidth).toInt()},
m_rows{Settings::value(Settings::Server::GridHeight).toInt()},
m_originalServerConfig(config), m_originalServerConfig(config),
m_originalServerConfigIsExternal(config.useExternalConfig()), m_originalServerConfigIsExternal(config.useExternalConfig()),
m_originalServerConfigUsesExternalFile(config.configFile()), m_originalServerConfigUsesExternalFile(config.configFile()),
m_serverConfig(config), m_serverConfig(config),
m_screenSetupModel(m_serverConfig.screens(), m_serverConfig.numColumns(), m_serverConfig.numRows()) m_screenSetupModel(m_serverConfig.screens(), m_columns, m_rows)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -164,7 +166,7 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config)
if (server == screens.end()) { if (server == screens.end()) {
Screen serverScreen(serverConfig().getServerName()); Screen serverScreen(serverConfig().getServerName());
serverScreen.markAsServer(); serverScreen.markAsServer();
model().screen(serverConfig().numColumns() / 2, serverConfig().numRows() / 2) = serverScreen; model().screen(m_columns / 2, m_rows / 2) = serverScreen;
} else { } else {
server->markAsServer(); server->markAsServer();
} }

View file

@ -97,6 +97,8 @@ protected:
private: private:
std::unique_ptr<Ui::ServerConfigDialog> ui; std::unique_ptr<Ui::ServerConfigDialog> ui;
QString m_message = ""; QString m_message = "";
int m_columns;
int m_rows;
ServerConfig &m_originalServerConfig; ServerConfig &m_originalServerConfig;
NetworkProtocol m_originalProtocol; NetworkProtocol m_originalProtocol;
bool m_originalServerConfigIsExternal; bool m_originalServerConfigIsExternal;