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