2012-06-10 16:50:54 +00:00
|
|
|
/*
|
2024-09-17 19:00:25 +00:00
|
|
|
* Deskflow -- mouse and keyboard sharing utility
|
2026-06-08 20:37:23 +00:00
|
|
|
* SPDX-FileCopyrightText: (C) 2012 Synergy App Ltd
|
2025-01-24 00:11:17 +00:00
|
|
|
* SPDX-FileCopyrightText: (C) 2008 Volker Lanz <vl@fidra.de>
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
2012-06-10 16:50:54 +00:00
|
|
|
*/
|
|
|
|
|
|
2024-07-22 16:48:02 +00:00
|
|
|
#pragma once
|
2012-06-10 16:50:54 +00:00
|
|
|
|
2026-06-08 23:30:05 +00:00
|
|
|
#include "common/Constants.h"
|
2026-03-02 04:06:06 +00:00
|
|
|
#include "common/NetworkProtocol.h"
|
2025-07-09 07:44:09 +00:00
|
|
|
#include "gui/Hotkey.h"
|
2024-08-08 17:41:59 +00:00
|
|
|
#include "gui/config/ScreenConfig.h"
|
|
|
|
|
#include "gui/config/ScreenList.h"
|
2024-08-01 00:13:01 +00:00
|
|
|
|
|
|
|
|
#include <QList>
|
2012-06-10 16:50:54 +00:00
|
|
|
|
|
|
|
|
class QTextStream;
|
|
|
|
|
class QSettings;
|
|
|
|
|
class QString;
|
|
|
|
|
class QFile;
|
|
|
|
|
class ServerConfigDialog;
|
|
|
|
|
|
2025-05-23 03:35:24 +00:00
|
|
|
namespace deskflow::gui {
|
2024-10-18 15:13:13 +00:00
|
|
|
|
|
|
|
|
// The default protocol was decided by a community vote.
|
2025-07-31 00:20:59 +00:00
|
|
|
const auto kDefaultProtocol = NetworkProtocol::Barrier;
|
2024-10-18 15:13:13 +00:00
|
|
|
|
2025-05-23 03:35:24 +00:00
|
|
|
} // namespace deskflow::gui
|
2024-10-18 15:13:13 +00:00
|
|
|
|
2026-03-26 14:17:56 +00:00
|
|
|
class ServerConfig : public ScreenConfig
|
2024-10-17 18:04:35 +00:00
|
|
|
{
|
2024-07-02 19:07:06 +00:00
|
|
|
friend class ServerConfigDialog;
|
2024-10-17 18:04:35 +00:00
|
|
|
friend QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config);
|
2024-07-02 19:07:06 +00:00
|
|
|
|
|
|
|
|
public:
|
2026-06-08 23:36:16 +00:00
|
|
|
explicit ServerConfig(int columns = kServerGridWidth, int rows = kServerGridHeight);
|
2026-03-26 14:17:56 +00:00
|
|
|
~ServerConfig() = default;
|
2024-07-02 19:07:06 +00:00
|
|
|
|
|
|
|
|
bool operator==(const ServerConfig &sc) const;
|
|
|
|
|
|
2026-03-26 14:17:56 +00:00
|
|
|
const ScreenList &screens() const
|
2024-10-17 18:04:35 +00:00
|
|
|
{
|
|
|
|
|
return m_Screens;
|
|
|
|
|
}
|
2024-08-08 17:41:59 +00:00
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// New methods
|
|
|
|
|
//
|
2024-10-17 18:04:35 +00:00
|
|
|
bool hasHeartbeat() const
|
|
|
|
|
{
|
|
|
|
|
return m_HasHeartbeat;
|
|
|
|
|
}
|
|
|
|
|
int heartbeat() const
|
|
|
|
|
{
|
|
|
|
|
return m_Heartbeat;
|
|
|
|
|
}
|
2025-07-31 00:20:59 +00:00
|
|
|
NetworkProtocol protocol() const
|
2024-10-18 15:13:13 +00:00
|
|
|
{
|
|
|
|
|
return m_Protocol;
|
|
|
|
|
}
|
2024-10-17 18:04:35 +00:00
|
|
|
bool relativeMouseMoves() const
|
|
|
|
|
{
|
|
|
|
|
return m_RelativeMouseMoves;
|
|
|
|
|
}
|
|
|
|
|
bool win32KeepForeground() const
|
|
|
|
|
{
|
|
|
|
|
return m_Win32KeepForeground;
|
|
|
|
|
}
|
|
|
|
|
bool hasSwitchDelay() const
|
|
|
|
|
{
|
|
|
|
|
return m_HasSwitchDelay;
|
|
|
|
|
}
|
|
|
|
|
int switchDelay() const
|
|
|
|
|
{
|
|
|
|
|
return m_SwitchDelay;
|
|
|
|
|
}
|
|
|
|
|
bool hasSwitchDoubleTap() const
|
|
|
|
|
{
|
|
|
|
|
return m_HasSwitchDoubleTap;
|
|
|
|
|
}
|
|
|
|
|
int switchDoubleTap() const
|
|
|
|
|
{
|
|
|
|
|
return m_SwitchDoubleTap;
|
|
|
|
|
}
|
|
|
|
|
bool switchCorner(int c) const
|
|
|
|
|
{
|
|
|
|
|
return m_SwitchCorners[c];
|
|
|
|
|
}
|
|
|
|
|
int switchCornerSize() const
|
|
|
|
|
{
|
|
|
|
|
return m_SwitchCornerSize;
|
|
|
|
|
}
|
|
|
|
|
const QList<bool> &switchCorners() const
|
|
|
|
|
{
|
|
|
|
|
return m_SwitchCorners;
|
|
|
|
|
}
|
|
|
|
|
const HotkeyList &hotkeys() const
|
|
|
|
|
{
|
|
|
|
|
return m_Hotkeys;
|
|
|
|
|
}
|
2025-11-24 23:35:32 +00:00
|
|
|
bool defaultLockToScreenState() const
|
|
|
|
|
{
|
|
|
|
|
return m_DefaultLockToScreenState;
|
|
|
|
|
}
|
2024-10-17 18:04:35 +00:00
|
|
|
bool disableLockToScreen() const
|
|
|
|
|
{
|
|
|
|
|
return m_DisableLockToScreen;
|
|
|
|
|
}
|
|
|
|
|
bool clipboardSharing() const
|
|
|
|
|
{
|
|
|
|
|
return m_ClipboardSharing;
|
|
|
|
|
}
|
|
|
|
|
size_t clipboardSharingSize() const
|
|
|
|
|
{
|
|
|
|
|
return m_ClipboardSharingSize;
|
|
|
|
|
}
|
2024-07-02 19:07:06 +00:00
|
|
|
static size_t defaultClipboardSharingSize();
|
|
|
|
|
|
2026-03-26 14:17:56 +00:00
|
|
|
bool save(const QString &fileName) const;
|
|
|
|
|
bool screenExists(const QString &screenName) const;
|
|
|
|
|
void save(QFile &file) const;
|
|
|
|
|
bool isFull() const;
|
2024-08-08 17:41:59 +00:00
|
|
|
void commit();
|
2024-07-02 19:07:06 +00:00
|
|
|
int numScreens() const;
|
2025-08-07 02:59:32 +00:00
|
|
|
QString getServerName() const;
|
2024-07-02 19:07:06 +00:00
|
|
|
void updateServerName();
|
2025-08-07 02:59:32 +00:00
|
|
|
QString configFile() const;
|
2024-07-22 16:48:02 +00:00
|
|
|
bool useExternalConfig() const;
|
2024-07-02 19:07:06 +00:00
|
|
|
void addClient(const QString &clientName);
|
|
|
|
|
|
2024-08-03 00:17:29 +00:00
|
|
|
private:
|
|
|
|
|
void recall();
|
|
|
|
|
void setupScreens();
|
2024-08-08 17:41:59 +00:00
|
|
|
QSettingsProxy &settings();
|
2024-10-17 18:04:35 +00:00
|
|
|
ScreenList &screens()
|
|
|
|
|
{
|
|
|
|
|
return m_Screens;
|
|
|
|
|
}
|
|
|
|
|
void setScreens(const ScreenList &screens)
|
|
|
|
|
{
|
|
|
|
|
m_Screens = screens;
|
|
|
|
|
}
|
|
|
|
|
void addScreen(const Screen &screen)
|
|
|
|
|
{
|
|
|
|
|
m_Screens.append(screen);
|
|
|
|
|
}
|
|
|
|
|
void haveHeartbeat(bool on)
|
|
|
|
|
{
|
|
|
|
|
m_HasHeartbeat = on;
|
|
|
|
|
}
|
|
|
|
|
void setHeartbeat(int val)
|
|
|
|
|
{
|
|
|
|
|
m_Heartbeat = val;
|
|
|
|
|
}
|
2025-07-31 00:20:59 +00:00
|
|
|
void setProtocol(NetworkProtocol val)
|
2024-10-18 15:13:13 +00:00
|
|
|
{
|
|
|
|
|
m_Protocol = val;
|
|
|
|
|
}
|
2024-10-17 18:04:35 +00:00
|
|
|
void setRelativeMouseMoves(bool on)
|
|
|
|
|
{
|
|
|
|
|
m_RelativeMouseMoves = on;
|
|
|
|
|
}
|
|
|
|
|
void setWin32KeepForeground(bool on)
|
|
|
|
|
{
|
|
|
|
|
m_Win32KeepForeground = on;
|
|
|
|
|
}
|
|
|
|
|
void haveSwitchDelay(bool on)
|
|
|
|
|
{
|
|
|
|
|
m_HasSwitchDelay = on;
|
|
|
|
|
}
|
|
|
|
|
void setSwitchDelay(int val)
|
|
|
|
|
{
|
|
|
|
|
m_SwitchDelay = val;
|
|
|
|
|
}
|
|
|
|
|
void haveSwitchDoubleTap(bool on)
|
|
|
|
|
{
|
|
|
|
|
m_HasSwitchDoubleTap = on;
|
|
|
|
|
}
|
|
|
|
|
void setSwitchDoubleTap(int val)
|
|
|
|
|
{
|
|
|
|
|
m_SwitchDoubleTap = val;
|
|
|
|
|
}
|
|
|
|
|
void setSwitchCorner(int c, bool on)
|
|
|
|
|
{
|
|
|
|
|
m_SwitchCorners[c] = on;
|
|
|
|
|
}
|
|
|
|
|
void setSwitchCornerSize(int val)
|
|
|
|
|
{
|
|
|
|
|
m_SwitchCornerSize = val;
|
|
|
|
|
}
|
2025-11-24 23:35:32 +00:00
|
|
|
void setDefaultLockToScreenState(bool on)
|
|
|
|
|
{
|
|
|
|
|
m_DefaultLockToScreenState = on;
|
|
|
|
|
}
|
2024-10-17 18:04:35 +00:00
|
|
|
void setDisableLockToScreen(bool on)
|
|
|
|
|
{
|
|
|
|
|
m_DisableLockToScreen = on;
|
|
|
|
|
}
|
|
|
|
|
void setClipboardSharing(bool on)
|
|
|
|
|
{
|
|
|
|
|
m_ClipboardSharing = on;
|
|
|
|
|
}
|
2025-05-20 02:19:19 +00:00
|
|
|
void setConfigFile(const QString &configFile) const;
|
|
|
|
|
void setUseExternalConfig(bool useExternalConfig) const;
|
2024-07-02 19:07:06 +00:00
|
|
|
size_t setClipboardSharingSize(size_t size);
|
2024-10-17 18:04:35 +00:00
|
|
|
QList<bool> &switchCorners()
|
|
|
|
|
{
|
|
|
|
|
return m_SwitchCorners;
|
|
|
|
|
}
|
|
|
|
|
HotkeyList &hotkeys()
|
|
|
|
|
{
|
|
|
|
|
return m_Hotkeys;
|
|
|
|
|
}
|
2024-07-02 19:07:06 +00:00
|
|
|
int adjacentScreenIndex(int idx, int deltaColumn, int deltaRow) const;
|
|
|
|
|
bool findScreenName(const QString &name, int &index);
|
|
|
|
|
bool fixNoServer(const QString &name, int &index);
|
|
|
|
|
|
|
|
|
|
private:
|
2024-07-22 16:48:02 +00:00
|
|
|
bool m_HasHeartbeat = false;
|
|
|
|
|
int m_Heartbeat = 0;
|
2025-07-31 00:20:59 +00:00
|
|
|
NetworkProtocol m_Protocol = deskflow::gui::kDefaultProtocol;
|
2024-07-22 16:48:02 +00:00
|
|
|
bool m_RelativeMouseMoves = false;
|
|
|
|
|
bool m_Win32KeepForeground = false;
|
|
|
|
|
bool m_HasSwitchDelay = false;
|
|
|
|
|
int m_SwitchDelay = 0;
|
|
|
|
|
bool m_HasSwitchDoubleTap = false;
|
|
|
|
|
int m_SwitchDoubleTap = 0;
|
|
|
|
|
int m_SwitchCornerSize = 0;
|
2025-11-24 23:35:32 +00:00
|
|
|
bool m_DefaultLockToScreenState = false;
|
2024-07-22 16:48:02 +00:00
|
|
|
bool m_DisableLockToScreen = false;
|
|
|
|
|
bool m_ClipboardSharing = true;
|
|
|
|
|
QString m_ClientAddress = "";
|
2024-07-02 19:07:06 +00:00
|
|
|
QList<bool> m_SwitchCorners;
|
|
|
|
|
HotkeyList m_Hotkeys;
|
2024-07-22 16:48:02 +00:00
|
|
|
|
|
|
|
|
ScreenList m_Screens;
|
2026-06-08 23:48:04 +00:00
|
|
|
int m_columns;
|
|
|
|
|
int m_rows;
|
2025-05-22 22:22:20 +00:00
|
|
|
size_t m_ClipboardSharingSize = defaultClipboardSharingSize();
|
2012-06-10 16:50:54 +00:00
|
|
|
};
|
|
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config);
|