#6344 Add clipboard sharing size limit config option

This commit is contained in:
Andrew Nelless 2017-01-24 15:06:50 +00:00 committed by Nick Bolton
parent 682fe1cfa3
commit 7e7760668a
5 changed files with 35 additions and 1 deletions

View File

@ -53,6 +53,7 @@ ServerConfig::ServerConfig(QSettings* settings, int numColumns, int numRows ,
m_EnableDragAndDrop(false), m_EnableDragAndDrop(false),
m_DisableLockToScreen(false), m_DisableLockToScreen(false),
m_ClipboardSharing(true), m_ClipboardSharing(true),
m_ClipboardSharingSize(defaultClipboardSharingSize()),
m_pMainWindow(mainWindow) m_pMainWindow(mainWindow)
{ {
Q_ASSERT(m_pSettings); Q_ASSERT(m_pSettings);
@ -252,6 +253,7 @@ QTextStream& operator<<(QTextStream& outStream, const ServerConfig& config)
outStream << "\t" << "win32KeepForeground = " << (config.win32KeepForeground() ? "true" : "false") << endl; outStream << "\t" << "win32KeepForeground = " << (config.win32KeepForeground() ? "true" : "false") << endl;
outStream << "\t" << "disableLockToScreen = " << (config.disableLockToScreen() ? "true" : "false") << endl; outStream << "\t" << "disableLockToScreen = " << (config.disableLockToScreen() ? "true" : "false") << endl;
outStream << "\t" << "clipboardSharing = " << (config.clipboardSharing() ? "true" : "false") << endl; outStream << "\t" << "clipboardSharing = " << (config.clipboardSharing() ? "true" : "false") << endl;
outStream << "\t" << "clipboardSharingSize = " << config.clipboardSharingSize() << endl;
if (config.hasSwitchDelay()) if (config.hasSwitchDelay())
outStream << "\t" << "switchDelay = " << config.switchDelay() << endl; outStream << "\t" << "switchDelay = " << config.switchDelay() << endl;
@ -405,3 +407,21 @@ void::ServerConfig::addToFirstEmptyGrid(const QString &clientName)
} }
} }
} }
size_t ServerConfig::defaultClipboardSharingSize() {
return 3 * 1024; // 3 MiB
}
size_t ServerConfig::setClipboardSharingSize(size_t size) {
if (size) {
size += 512; // Round up to the nearest megabyte
size /= 1024;
size *= 1024;
setClipboardSharing(true);
} else {
setClipboardSharing(false);
}
using std::swap;
swap (size, m_ClipboardSharingSize);
return size;
}

View File

@ -64,6 +64,8 @@ class ServerConfig : public BaseConfig
bool enableDragAndDrop() const { return m_EnableDragAndDrop; } bool enableDragAndDrop() const { return m_EnableDragAndDrop; }
bool disableLockToScreen() const { return m_DisableLockToScreen; } bool disableLockToScreen() const { return m_DisableLockToScreen; }
bool clipboardSharing() const { return m_ClipboardSharing; } bool clipboardSharing() const { return m_ClipboardSharing; }
size_t clipboardSharingSize() const { return m_ClipboardSharingSize; }
static size_t defaultClipboardSharingSize();
void saveSettings(); void saveSettings();
void loadSettings(); void loadSettings();
@ -94,6 +96,7 @@ class ServerConfig : public BaseConfig
void setEnableDragAndDrop(bool on) { m_EnableDragAndDrop = on; } void setEnableDragAndDrop(bool on) { m_EnableDragAndDrop = on; }
void setDisableLockToScreen(bool on) { m_DisableLockToScreen = on; } void setDisableLockToScreen(bool on) { m_DisableLockToScreen = on; }
void setClipboardSharing(bool on) { m_ClipboardSharing = on; } void setClipboardSharing(bool on) { m_ClipboardSharing = on; }
size_t setClipboardSharingSize(size_t size);
QList<bool>& switchCorners() { return m_SwitchCorners; } QList<bool>& switchCorners() { return m_SwitchCorners; }
HotkeyList& hotkeys() { return m_Hotkeys; } HotkeyList& hotkeys() { return m_Hotkeys; }
@ -128,6 +131,7 @@ class ServerConfig : public BaseConfig
bool m_EnableDragAndDrop; bool m_EnableDragAndDrop;
bool m_DisableLockToScreen; bool m_DisableLockToScreen;
bool m_ClipboardSharing; bool m_ClipboardSharing;
size_t m_ClipboardSharingSize;
MainWindow* m_pMainWindow; MainWindow* m_pMainWindow;
}; };

View File

@ -60,6 +60,7 @@ ServerConfigDialog::ServerConfigDialog(QWidget* parent, ServerConfig& config, co
m_pCheckBoxEnableDragAndDrop->setChecked(serverConfig().enableDragAndDrop()); m_pCheckBoxEnableDragAndDrop->setChecked(serverConfig().enableDragAndDrop());
m_pCheckBoxEnableClipboard->setChecked(serverConfig().clipboardSharing()); m_pCheckBoxEnableClipboard->setChecked(serverConfig().clipboardSharing());
m_pSpinBoxClipboardSizeLimit->setValue(serverConfig().clipboardSharingSize() / 1024);
foreach(const Hotkey& hotkey, serverConfig().hotkeys()) foreach(const Hotkey& hotkey, serverConfig().hotkeys())
m_pListHotkeys->addItem(hotkey.text()); m_pListHotkeys->addItem(hotkey.text());
@ -105,6 +106,7 @@ void ServerConfigDialog::accept()
serverConfig().setEnableDragAndDrop(m_pCheckBoxEnableDragAndDrop->isChecked()); serverConfig().setEnableDragAndDrop(m_pCheckBoxEnableDragAndDrop->isChecked());
serverConfig().setDisableLockToScreen(m_pCheckBoxDisableLockToScreen->isChecked()); serverConfig().setDisableLockToScreen(m_pCheckBoxDisableLockToScreen->isChecked());
serverConfig().setClipboardSharing(m_pCheckBoxEnableClipboard->isChecked()); serverConfig().setClipboardSharing(m_pCheckBoxEnableClipboard->isChecked());
serverConfig().setClipboardSharingSize(m_pSpinBoxClipboardSizeLimit->value() * 1024);
// now that the dialog has been accepted, copy the new server config to the original one, // now that the dialog has been accepted, copy the new server config to the original one,
// which is a reference to the one in MainWindow. // which is a reference to the one in MainWindow.

View File

@ -771,6 +771,9 @@ Config::readSectionOptions(ConfigReadContext& s)
else if (name == "clipboardSharing") { else if (name == "clipboardSharing") {
addOption("", kOptionClipboardSharing, s.parseBoolean(value)); addOption("", kOptionClipboardSharing, s.parseBoolean(value));
} }
else if (name == "clipboardSharingSize") {
addOption("", kOptionClipboardSharingSize, s.parseInt(value));
}
else { else {
handled = false; handled = false;
} }
@ -1388,6 +1391,9 @@ Config::getOptionName(OptionID id)
if (id == kOptionClipboardSharing) { if (id == kOptionClipboardSharing) {
return "clipboardSharing"; return "clipboardSharing";
} }
if (id == kOptionClipboardSharingSize) {
return "clipboardSharingSize";
}
return NULL; return NULL;
} }
@ -1405,7 +1411,8 @@ Config::getOptionValue(OptionID id, OptionValue value)
id == kOptionRelativeMouseMoves || id == kOptionRelativeMouseMoves ||
id == kOptionWin32KeepForeground || id == kOptionWin32KeepForeground ||
id == kOptionScreenPreserveFocus || id == kOptionScreenPreserveFocus ||
id == kOptionClipboardSharing) { id == kOptionClipboardSharing ||
id == kOptionClipboardSharingSize) {
return (value != 0) ? "true" : "false"; return (value != 0) ? "true" : "false";
} }
if (id == kOptionModifierMapForShift || if (id == kOptionModifierMapForShift ||

View File

@ -69,6 +69,7 @@ static const OptionID kOptionRelativeMouseMoves = OPTION_CODE("MDLT");
static const OptionID kOptionWin32KeepForeground = OPTION_CODE("_KFW"); static const OptionID kOptionWin32KeepForeground = OPTION_CODE("_KFW");
static const OptionID kOptionDisableLockToScreen = OPTION_CODE("DLTS"); static const OptionID kOptionDisableLockToScreen = OPTION_CODE("DLTS");
static const OptionID kOptionClipboardSharing = OPTION_CODE("CLPS"); static const OptionID kOptionClipboardSharing = OPTION_CODE("CLPS");
static const OptionID kOptionClipboardSharingSize = OPTION_CODE("CLSZ");
//@} //@}
//! @name Screen switch corner enumeration //! @name Screen switch corner enumeration