Deskflow 1.22.0.197
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
10#include "Hotkey.h"
14
15#include <QList>
16
17const auto kDefaultColumns = 5;
18const auto kDefaultRows = 3;
19
20class QTextStream;
21class QSettings;
22class QString;
23class QFile;
25class MainWindow;
26
27namespace deskflow::gui {
28
34
35// The default protocol was decided by a community vote.
36const auto kDefaultProtocol = ServerProtocol::kBarrier;
37
38} // namespace deskflow::gui
39
41{
42 using ServerProtocol = deskflow::gui::ServerProtocol;
43
44 friend class ServerConfigDialog;
45 friend QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config);
46
47public:
48 ServerConfig(MainWindow &mainWindow, int columns = kDefaultColumns, int rows = kDefaultRows);
49 ~ServerConfig() override = default;
50
51 bool operator==(const ServerConfig &sc) const;
52
53 //
54 // Overrides
55 //
56 const ScreenList &screens() const override
57 {
58 return m_Screens;
59 }
60
61 //
62 // New methods
63 //
64 int numColumns() const
65 {
66 return m_Columns;
67 }
68 int numRows() const
69 {
70 return m_Rows;
71 }
72 bool hasHeartbeat() const
73 {
74 return m_HasHeartbeat;
75 }
76 int heartbeat() const
77 {
78 return m_Heartbeat;
79 }
80 ServerProtocol protocol() const
81 {
82 return m_Protocol;
83 }
84 bool relativeMouseMoves() const
85 {
86 return m_RelativeMouseMoves;
87 }
89 {
90 return m_Win32KeepForeground;
91 }
92 bool hasSwitchDelay() const
93 {
94 return m_HasSwitchDelay;
95 }
96 int switchDelay() const
97 {
98 return m_SwitchDelay;
99 }
101 {
102 return m_HasSwitchDoubleTap;
103 }
104 int switchDoubleTap() const
105 {
106 return m_SwitchDoubleTap;
107 }
108 bool switchCorner(int c) const
109 {
110 return m_SwitchCorners[c];
111 }
113 {
114 return m_SwitchCornerSize;
115 }
116 const QList<bool> &switchCorners() const
117 {
118 return m_SwitchCorners;
119 }
120 const HotkeyList &hotkeys() const
121 {
122 return m_Hotkeys;
123 }
125 {
126 return m_DisableLockToScreen;
127 }
128 bool clipboardSharing() const
129 {
130 return m_ClipboardSharing;
131 }
132 size_t clipboardSharingSize() const
133 {
134 return m_ClipboardSharingSize;
135 }
136 static size_t defaultClipboardSharingSize();
137
138 //
139 // Overrides
140 //
141 bool save(const QString &fileName) const override;
142 bool screenExists(const QString &screenName) const override;
143 void save(QFile &file) const override;
144 bool isFull() const override;
145
146 //
147 // New methods
148 //
149 void commit();
150 int numScreens() const;
151 int autoAddScreen(const QString name);
152 const QString getServerName() const;
153 void updateServerName();
154 const QString configFile() const;
155 bool useExternalConfig() const;
156 void addClient(const QString &clientName);
157 QString getClientAddress() const;
158 void setClientAddress(const QString &address);
159
160private:
161 void recall();
162 void setupScreens();
163 QSettingsProxy &settings();
165 {
166 return m_Screens;
167 }
168 void setScreens(const ScreenList &screens)
169 {
170 m_Screens = screens;
171 }
172 void addScreen(const Screen &screen)
173 {
174 m_Screens.append(screen);
175 }
176 void setNumColumns(int n)
177 {
178 m_Columns = n;
179 }
180 void setNumRows(int n)
181 {
182 m_Rows = n;
183 }
184 void haveHeartbeat(bool on)
185 {
186 m_HasHeartbeat = on;
187 }
188 void setHeartbeat(int val)
189 {
190 m_Heartbeat = val;
191 }
192 void setProtocol(ServerProtocol val)
193 {
194 m_Protocol = val;
195 }
196 void setRelativeMouseMoves(bool on)
197 {
198 m_RelativeMouseMoves = on;
199 }
200 void setWin32KeepForeground(bool on)
201 {
202 m_Win32KeepForeground = on;
203 }
204 void haveSwitchDelay(bool on)
205 {
206 m_HasSwitchDelay = on;
207 }
208 void setSwitchDelay(int val)
209 {
210 m_SwitchDelay = val;
211 }
212 void haveSwitchDoubleTap(bool on)
213 {
214 m_HasSwitchDoubleTap = on;
215 }
216 void setSwitchDoubleTap(int val)
217 {
218 m_SwitchDoubleTap = val;
219 }
220 void setSwitchCorner(int c, bool on)
221 {
222 m_SwitchCorners[c] = on;
223 }
224 void setSwitchCornerSize(int val)
225 {
226 m_SwitchCornerSize = val;
227 }
228 void setDisableLockToScreen(bool on)
229 {
230 m_DisableLockToScreen = on;
231 }
232 void setClipboardSharing(bool on)
233 {
234 m_ClipboardSharing = on;
235 }
236 void setConfigFile(const QString &configFile) const;
237 void setUseExternalConfig(bool useExternalConfig) const;
238 size_t setClipboardSharingSize(size_t size);
239 QList<bool> &switchCorners()
240 {
241 return m_SwitchCorners;
242 }
244 {
245 return m_Hotkeys;
246 }
247 int adjacentScreenIndex(int idx, int deltaColumn, int deltaRow) const;
248 bool findScreenName(const QString &name, int &index);
249 bool fixNoServer(const QString &name, int &index);
250 int showAddClientDialog(const QString &clientName);
251 void addToFirstEmptyGrid(const QString &clientName);
252
253private:
254 bool m_HasHeartbeat = false;
255 int m_Heartbeat = 0;
256 ServerProtocol m_Protocol = deskflow::gui::kDefaultProtocol;
257 bool m_RelativeMouseMoves = false;
258 bool m_Win32KeepForeground = false;
259 bool m_HasSwitchDelay = false;
260 int m_SwitchDelay = 0;
261 bool m_HasSwitchDoubleTap = false;
262 int m_SwitchDoubleTap = 0;
263 int m_SwitchCornerSize = 0;
264 bool m_DisableLockToScreen = false;
265 bool m_ClipboardSharing = true;
266 QString m_ClientAddress = "";
267 QList<bool> m_SwitchCorners;
268 HotkeyList m_Hotkeys;
269
270 MainWindow *m_pMainWindow;
271 ScreenList m_Screens;
272 int m_Columns;
273 int m_Rows;
274 size_t m_ClipboardSharingSize = defaultClipboardSharingSize();
275};
276
277QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config);
278
static const struct sockaddr FAR * name
Definition ArchNetworkWinsock.cpp:27
QList< Hotkey > HotkeyList
Definition Hotkey.h:68
QTextStream & operator<<(QTextStream &outStream, const ServerConfig &config)
Definition ServerConfig.cpp:225
const auto kDefaultRows
Definition ServerConfig.h:18
AddResults
Definition ServerConfig.h:280
@ AutoAddScreenOk
Definition ServerConfig.h:281
@ AutoAddScreenManualServer
Definition ServerConfig.h:282
@ AutoAddScreenIgnore
Definition ServerConfig.h:284
@ AutoAddScreenManualClient
Definition ServerConfig.h:283
const auto kDefaultColumns
Definition ServerConfig.h:17
Definition MainWindow.h:58
Definition QSettingsProxy.h:14
ScreenConfig()=default
Definition ScreenList.h:12
Definition ServerConfigDialog.h:23
Definition ServerConfig.h:41
bool hasHeartbeat() const
Definition ServerConfig.h:72
int autoAddScreen(const QString name)
Definition ServerConfig.cpp:324
size_t clipboardSharingSize() const
Definition ServerConfig.h:132
bool useExternalConfig() const
Definition ServerConfig.cpp:407
const QList< bool > & switchCorners() const
Definition ServerConfig.h:116
const QString getServerName() const
Definition ServerConfig.cpp:387
bool win32KeepForeground() const
Definition ServerConfig.h:88
int switchCornerSize() const
Definition ServerConfig.h:112
const HotkeyList & hotkeys() const
Definition ServerConfig.h:120
const ScreenList & screens() const override
Definition ServerConfig.h:56
int switchDelay() const
Definition ServerConfig.h:96
ServerConfig(MainWindow &mainWindow, int columns=kDefaultColumns, int rows=kDefaultRows)
Definition ServerConfig.cpp:39
friend class ServerConfigDialog
Definition ServerConfig.h:44
static size_t defaultClipboardSharingSize()
Definition ServerConfig.cpp:516
bool operator==(const ServerConfig &sc) const
Definition ServerConfig.cpp:60
friend QTextStream & operator<<(QTextStream &outStream, const ServerConfig &config)
Definition ServerConfig.cpp:225
bool save(const QString &fileName) const override
Definition ServerConfig.cpp:48
int numScreens() const
Definition ServerConfig.cpp:312
void setClientAddress(const QString &address)
bool relativeMouseMoves() const
Definition ServerConfig.h:84
void updateServerName()
Definition ServerConfig.cpp:392
QString getClientAddress() const
bool disableLockToScreen() const
Definition ServerConfig.h:124
bool hasSwitchDelay() const
Definition ServerConfig.h:92
ServerProtocol protocol() const
Definition ServerConfig.h:80
bool hasSwitchDoubleTap() const
Definition ServerConfig.h:100
bool isFull() const override
Definition ServerConfig.cpp:412
int numColumns() const
Definition ServerConfig.h:64
~ServerConfig() override=default
bool switchCorner(int c) const
Definition ServerConfig.h:108
int switchDoubleTap() const
Definition ServerConfig.h:104
bool screenExists(const QString &screenName) const override
Definition ServerConfig.cpp:426
const QString configFile() const
Definition ServerConfig.cpp:402
void addClient(const QString &clientName)
Definition ServerConfig.cpp:440
int heartbeat() const
Definition ServerConfig.h:76
bool clipboardSharing() const
Definition ServerConfig.h:128
void commit()
Definition ServerConfig.cpp:105
int numRows() const
Definition ServerConfig.h:68
Definition IServerConfig.h:17
Definition IServerConfig.h:14
const auto kDefaultProtocol
Definition ServerConfig.h:36
ServerProtocol
Definition ServerConfig.h:30
@ kSynergy
Definition ServerConfig.h:31
@ kBarrier
Definition ServerConfig.h:32