Deskflow 1.26.0.0
Keyboard and mouse sharing utility
Loading...
Searching...
No Matches
ServerConfig.h
Go to the documentation of this file.
1/*
2 * Deskflow -- mouse and keyboard sharing utility
3 * SPDX-FileCopyrightText: (C) 2012 Symless Ltd.
4 * SPDX-FileCopyrightText: (C) 2008 Volker Lanz <vl@fidra.de>
5 * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
6 */
7
8#pragma once
9
11#include "gui/Hotkey.h"
15
16#include <QList>
17
18const auto kDefaultColumns = 5;
19const auto kDefaultRows = 3;
20
21class QTextStream;
22class QSettings;
23class QString;
24class QFile;
26
27namespace deskflow::gui {
28
29// The default protocol was decided by a community vote.
31
32} // namespace deskflow::gui
33
35{
36 friend class ServerConfigDialog;
37 friend QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config);
38
39public:
40 explicit ServerConfig(int columns = kDefaultColumns, int rows = kDefaultRows);
41 ~ServerConfig() override = default;
42
43 bool operator==(const ServerConfig &sc) const;
44
45 //
46 // Overrides
47 //
48 const ScreenList &screens() const override
49 {
50 return m_Screens;
51 }
52
53 //
54 // New methods
55 //
56 int numColumns() const
57 {
58 return m_Columns;
59 }
60 int numRows() const
61 {
62 return m_Rows;
63 }
64 bool hasHeartbeat() const
65 {
66 return m_HasHeartbeat;
67 }
68 int heartbeat() const
69 {
70 return m_Heartbeat;
71 }
73 {
74 return m_Protocol;
75 }
76 bool relativeMouseMoves() const
77 {
78 return m_RelativeMouseMoves;
79 }
81 {
82 return m_Win32KeepForeground;
83 }
84 bool hasSwitchDelay() const
85 {
86 return m_HasSwitchDelay;
87 }
88 int switchDelay() const
89 {
90 return m_SwitchDelay;
91 }
92 bool hasSwitchDoubleTap() const
93 {
94 return m_HasSwitchDoubleTap;
95 }
96 int switchDoubleTap() const
97 {
98 return m_SwitchDoubleTap;
99 }
100 bool switchCorner(int c) const
101 {
102 return m_SwitchCorners[c];
103 }
105 {
106 return m_SwitchCornerSize;
107 }
108 const QList<bool> &switchCorners() const
109 {
110 return m_SwitchCorners;
111 }
112 const HotkeyList &hotkeys() const
113 {
114 return m_Hotkeys;
115 }
117 {
118 return m_DefaultLockToScreenState;
119 }
121 {
122 return m_DisableLockToScreen;
123 }
124 bool clipboardSharing() const
125 {
126 return m_ClipboardSharing;
127 }
128 size_t clipboardSharingSize() const
129 {
130 return m_ClipboardSharingSize;
131 }
132 static size_t defaultClipboardSharingSize();
133
134 //
135 // Overrides
136 //
137 bool save(const QString &fileName) const override;
138 bool screenExists(const QString &screenName) const override;
139 void save(QFile &file) const override;
140 bool isFull() const override;
141
142 //
143 // New methods
144 //
145 void commit();
146 int numScreens() const;
147 QString getServerName() const;
148 void updateServerName();
149 QString configFile() const;
150 bool useExternalConfig() const;
151 void addClient(const QString &clientName);
152
153private:
154 void recall();
155 void setupScreens();
156 QSettingsProxy &settings();
158 {
159 return m_Screens;
160 }
161 void setScreens(const ScreenList &screens)
162 {
163 m_Screens = screens;
164 }
165 void addScreen(const Screen &screen)
166 {
167 m_Screens.append(screen);
168 }
169 void setNumColumns(int n)
170 {
171 m_Columns = n;
172 }
173 void setNumRows(int n)
174 {
175 m_Rows = n;
176 }
177 void haveHeartbeat(bool on)
178 {
179 m_HasHeartbeat = on;
180 }
181 void setHeartbeat(int val)
182 {
183 m_Heartbeat = val;
184 }
185 void setProtocol(NetworkProtocol val)
186 {
187 m_Protocol = val;
188 }
189 void setRelativeMouseMoves(bool on)
190 {
191 m_RelativeMouseMoves = on;
192 }
193 void setWin32KeepForeground(bool on)
194 {
195 m_Win32KeepForeground = on;
196 }
197 void haveSwitchDelay(bool on)
198 {
199 m_HasSwitchDelay = on;
200 }
201 void setSwitchDelay(int val)
202 {
203 m_SwitchDelay = val;
204 }
205 void haveSwitchDoubleTap(bool on)
206 {
207 m_HasSwitchDoubleTap = on;
208 }
209 void setSwitchDoubleTap(int val)
210 {
211 m_SwitchDoubleTap = val;
212 }
213 void setSwitchCorner(int c, bool on)
214 {
215 m_SwitchCorners[c] = on;
216 }
217 void setSwitchCornerSize(int val)
218 {
219 m_SwitchCornerSize = val;
220 }
221 void setDefaultLockToScreenState(bool on)
222 {
223 m_DefaultLockToScreenState = on;
224 }
225 void setDisableLockToScreen(bool on)
226 {
227 m_DisableLockToScreen = on;
228 }
229 void setClipboardSharing(bool on)
230 {
231 m_ClipboardSharing = on;
232 }
233 void setConfigFile(const QString &configFile) const;
234 void setUseExternalConfig(bool useExternalConfig) const;
235 size_t setClipboardSharingSize(size_t size);
236 QList<bool> &switchCorners()
237 {
238 return m_SwitchCorners;
239 }
241 {
242 return m_Hotkeys;
243 }
244 int adjacentScreenIndex(int idx, int deltaColumn, int deltaRow) const;
245 bool findScreenName(const QString &name, int &index);
246 bool fixNoServer(const QString &name, int &index);
247
248private:
249 bool m_HasHeartbeat = false;
250 int m_Heartbeat = 0;
252 bool m_RelativeMouseMoves = false;
253 bool m_Win32KeepForeground = false;
254 bool m_HasSwitchDelay = false;
255 int m_SwitchDelay = 0;
256 bool m_HasSwitchDoubleTap = false;
257 int m_SwitchDoubleTap = 0;
258 int m_SwitchCornerSize = 0;
259 bool m_DefaultLockToScreenState = false;
260 bool m_DisableLockToScreen = false;
261 bool m_ClipboardSharing = true;
262 QString m_ClientAddress = "";
263 QList<bool> m_SwitchCorners;
264 HotkeyList m_Hotkeys;
265
266 ScreenList m_Screens;
267 int m_Columns;
268 int m_Rows;
269 size_t m_ClipboardSharingSize = defaultClipboardSharingSize();
270};
271
272QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config);
static const struct sockaddr FAR * name
Definition ArchNetworkWinsock.cpp:28
QList< Hotkey > HotkeyList
Definition Hotkey.h:68
NetworkProtocol
Definition NetworkProtocol.h:14
@ Barrier
Definition NetworkProtocol.h:17
QTextStream & operator<<(QTextStream &outStream, const ServerConfig &config)
Definition ServerConfig.cpp:221
const auto kDefaultRows
Definition ServerConfig.h:19
const auto kDefaultColumns
Definition ServerConfig.h:18
Definition QSettingsProxy.h:14
ScreenConfig()=default
Definition ScreenList.h:12
Definition ServerConfigDialog.h:23
Definition ServerConfig.h:35
bool hasHeartbeat() const
Definition ServerConfig.h:64
size_t clipboardSharingSize() const
Definition ServerConfig.h:128
bool useExternalConfig() const
Definition ServerConfig.cpp:337
const QList< bool > & switchCorners() const
Definition ServerConfig.h:108
bool win32KeepForeground() const
Definition ServerConfig.h:80
int switchCornerSize() const
Definition ServerConfig.h:104
const HotkeyList & hotkeys() const
Definition ServerConfig.h:112
const ScreenList & screens() const override
Definition ServerConfig.h:48
bool defaultLockToScreenState() const
Definition ServerConfig.h:116
int switchDelay() const
Definition ServerConfig.h:88
friend class ServerConfigDialog
Definition ServerConfig.h:36
static size_t defaultClipboardSharingSize()
Definition ServerConfig.cpp:420
bool operator==(const ServerConfig &sc) const
Definition ServerConfig.cpp:54
friend QTextStream & operator<<(QTextStream &outStream, const ServerConfig &config)
Definition ServerConfig.cpp:221
bool save(const QString &fileName) const override
Definition ServerConfig.cpp:42
int numScreens() const
Definition ServerConfig.cpp:305
NetworkProtocol protocol() const
Definition ServerConfig.h:72
bool relativeMouseMoves() const
Definition ServerConfig.h:76
void updateServerName()
Definition ServerConfig.cpp:322
bool disableLockToScreen() const
Definition ServerConfig.h:120
bool hasSwitchDelay() const
Definition ServerConfig.h:84
bool hasSwitchDoubleTap() const
Definition ServerConfig.h:92
bool isFull() const override
Definition ServerConfig.cpp:342
int numColumns() const
Definition ServerConfig.h:56
ServerConfig(int columns=kDefaultColumns, int rows=kDefaultRows)
Definition ServerConfig.cpp:37
~ServerConfig() override=default
bool switchCorner(int c) const
Definition ServerConfig.h:100
int switchDoubleTap() const
Definition ServerConfig.h:96
bool screenExists(const QString &screenName) const override
Definition ServerConfig.cpp:356
void addClient(const QString &clientName)
Definition ServerConfig.cpp:370
int heartbeat() const
Definition ServerConfig.h:68
bool clipboardSharing() const
Definition ServerConfig.h:124
QString getServerName() const
Definition ServerConfig.cpp:317
QString configFile() const
Definition ServerConfig.cpp:332
void commit()
Definition ServerConfig.cpp:99
int numRows() const
Definition ServerConfig.h:60
Definition IServerConfig.h:18
Definition IServerConfig.h:14
const auto kDefaultProtocol
Definition ServerConfig.h:30