Deskflow 1.24.0.365
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_DisableLockToScreen;
119 }
120 bool clipboardSharing() const
121 {
122 return m_ClipboardSharing;
123 }
124 size_t clipboardSharingSize() const
125 {
126 return m_ClipboardSharingSize;
127 }
128 static size_t defaultClipboardSharingSize();
129
130 //
131 // Overrides
132 //
133 bool save(const QString &fileName) const override;
134 bool screenExists(const QString &screenName) const override;
135 void save(QFile &file) const override;
136 bool isFull() const override;
137
138 //
139 // New methods
140 //
141 void commit();
142 int numScreens() const;
143 QString getServerName() const;
144 void updateServerName();
145 QString configFile() const;
146 bool useExternalConfig() const;
147 void addClient(const QString &clientName);
148
149private:
150 void recall();
151 void setupScreens();
152 QSettingsProxy &settings();
154 {
155 return m_Screens;
156 }
157 void setScreens(const ScreenList &screens)
158 {
159 m_Screens = screens;
160 }
161 void addScreen(const Screen &screen)
162 {
163 m_Screens.append(screen);
164 }
165 void setNumColumns(int n)
166 {
167 m_Columns = n;
168 }
169 void setNumRows(int n)
170 {
171 m_Rows = n;
172 }
173 void haveHeartbeat(bool on)
174 {
175 m_HasHeartbeat = on;
176 }
177 void setHeartbeat(int val)
178 {
179 m_Heartbeat = val;
180 }
181 void setProtocol(NetworkProtocol val)
182 {
183 m_Protocol = val;
184 }
185 void setRelativeMouseMoves(bool on)
186 {
187 m_RelativeMouseMoves = on;
188 }
189 void setWin32KeepForeground(bool on)
190 {
191 m_Win32KeepForeground = on;
192 }
193 void haveSwitchDelay(bool on)
194 {
195 m_HasSwitchDelay = on;
196 }
197 void setSwitchDelay(int val)
198 {
199 m_SwitchDelay = val;
200 }
201 void haveSwitchDoubleTap(bool on)
202 {
203 m_HasSwitchDoubleTap = on;
204 }
205 void setSwitchDoubleTap(int val)
206 {
207 m_SwitchDoubleTap = val;
208 }
209 void setSwitchCorner(int c, bool on)
210 {
211 m_SwitchCorners[c] = on;
212 }
213 void setSwitchCornerSize(int val)
214 {
215 m_SwitchCornerSize = val;
216 }
217 void setDisableLockToScreen(bool on)
218 {
219 m_DisableLockToScreen = on;
220 }
221 void setClipboardSharing(bool on)
222 {
223 m_ClipboardSharing = on;
224 }
225 void setConfigFile(const QString &configFile) const;
226 void setUseExternalConfig(bool useExternalConfig) const;
227 size_t setClipboardSharingSize(size_t size);
228 QList<bool> &switchCorners()
229 {
230 return m_SwitchCorners;
231 }
233 {
234 return m_Hotkeys;
235 }
236 int adjacentScreenIndex(int idx, int deltaColumn, int deltaRow) const;
237 bool findScreenName(const QString &name, int &index);
238 bool fixNoServer(const QString &name, int &index);
239
240private:
241 bool m_HasHeartbeat = false;
242 int m_Heartbeat = 0;
244 bool m_RelativeMouseMoves = false;
245 bool m_Win32KeepForeground = false;
246 bool m_HasSwitchDelay = false;
247 int m_SwitchDelay = 0;
248 bool m_HasSwitchDoubleTap = false;
249 int m_SwitchDoubleTap = 0;
250 int m_SwitchCornerSize = 0;
251 bool m_DisableLockToScreen = false;
252 bool m_ClipboardSharing = true;
253 QString m_ClientAddress = "";
254 QList<bool> m_SwitchCorners;
255 HotkeyList m_Hotkeys;
256
257 ScreenList m_Screens;
258 int m_Columns;
259 int m_Rows;
260 size_t m_ClipboardSharingSize = defaultClipboardSharingSize();
261};
262
263QTextStream &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:10
@ Barrier
Definition NetworkProtocol.h:12
QTextStream & operator<<(QTextStream &outStream, const ServerConfig &config)
Definition ServerConfig.cpp:218
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:124
bool useExternalConfig() const
Definition ServerConfig.cpp:338
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
int switchDelay() const
Definition ServerConfig.h:88
friend class ServerConfigDialog
Definition ServerConfig.h:36
static size_t defaultClipboardSharingSize()
Definition ServerConfig.cpp:421
bool operator==(const ServerConfig &sc) const
Definition ServerConfig.cpp:54
friend QTextStream & operator<<(QTextStream &outStream, const ServerConfig &config)
Definition ServerConfig.cpp:218
bool save(const QString &fileName) const override
Definition ServerConfig.cpp:42
int numScreens() const
Definition ServerConfig.cpp:306
NetworkProtocol protocol() const
Definition ServerConfig.h:72
bool relativeMouseMoves() const
Definition ServerConfig.h:76
void updateServerName()
Definition ServerConfig.cpp:323
bool disableLockToScreen() const
Definition ServerConfig.h:116
bool hasSwitchDelay() const
Definition ServerConfig.h:84
bool hasSwitchDoubleTap() const
Definition ServerConfig.h:92
bool isFull() const override
Definition ServerConfig.cpp:343
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:357
void addClient(const QString &clientName)
Definition ServerConfig.cpp:371
int heartbeat() const
Definition ServerConfig.h:68
bool clipboardSharing() const
Definition ServerConfig.h:120
QString getServerName() const
Definition ServerConfig.cpp:318
QString configFile() const
Definition ServerConfig.cpp:333
void commit()
Definition ServerConfig.cpp:98
int numRows() const
Definition ServerConfig.h:60
Definition IServerConfig.h:18
Definition IServerConfig.h:14
const auto kDefaultProtocol
Definition ServerConfig.h:30