mirror of
https://github.com/debauchee/barrier.git
synced 2026-07-05 19:36:16 +08:00
#6344 Add clipboard sharing size limit config option
This commit is contained in:
committed by
Nick Bolton
parent
682fe1cfa3
commit
7e7760668a
@@ -53,6 +53,7 @@ ServerConfig::ServerConfig(QSettings* settings, int numColumns, int numRows ,
|
||||
m_EnableDragAndDrop(false),
|
||||
m_DisableLockToScreen(false),
|
||||
m_ClipboardSharing(true),
|
||||
m_ClipboardSharingSize(defaultClipboardSharingSize()),
|
||||
m_pMainWindow(mainWindow)
|
||||
{
|
||||
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" << "disableLockToScreen = " << (config.disableLockToScreen() ? "true" : "false") << endl;
|
||||
outStream << "\t" << "clipboardSharing = " << (config.clipboardSharing() ? "true" : "false") << endl;
|
||||
outStream << "\t" << "clipboardSharingSize = " << config.clipboardSharingSize() << endl;
|
||||
|
||||
if (config.hasSwitchDelay())
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -64,6 +64,8 @@ class ServerConfig : public BaseConfig
|
||||
bool enableDragAndDrop() const { return m_EnableDragAndDrop; }
|
||||
bool disableLockToScreen() const { return m_DisableLockToScreen; }
|
||||
bool clipboardSharing() const { return m_ClipboardSharing; }
|
||||
size_t clipboardSharingSize() const { return m_ClipboardSharingSize; }
|
||||
static size_t defaultClipboardSharingSize();
|
||||
|
||||
void saveSettings();
|
||||
void loadSettings();
|
||||
@@ -94,6 +96,7 @@ class ServerConfig : public BaseConfig
|
||||
void setEnableDragAndDrop(bool on) { m_EnableDragAndDrop = on; }
|
||||
void setDisableLockToScreen(bool on) { m_DisableLockToScreen = on; }
|
||||
void setClipboardSharing(bool on) { m_ClipboardSharing = on; }
|
||||
size_t setClipboardSharingSize(size_t size);
|
||||
QList<bool>& switchCorners() { return m_SwitchCorners; }
|
||||
HotkeyList& hotkeys() { return m_Hotkeys; }
|
||||
|
||||
@@ -128,6 +131,7 @@ class ServerConfig : public BaseConfig
|
||||
bool m_EnableDragAndDrop;
|
||||
bool m_DisableLockToScreen;
|
||||
bool m_ClipboardSharing;
|
||||
size_t m_ClipboardSharingSize;
|
||||
MainWindow* m_pMainWindow;
|
||||
};
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ ServerConfigDialog::ServerConfigDialog(QWidget* parent, ServerConfig& config, co
|
||||
m_pCheckBoxEnableDragAndDrop->setChecked(serverConfig().enableDragAndDrop());
|
||||
|
||||
m_pCheckBoxEnableClipboard->setChecked(serverConfig().clipboardSharing());
|
||||
m_pSpinBoxClipboardSizeLimit->setValue(serverConfig().clipboardSharingSize() / 1024);
|
||||
|
||||
foreach(const Hotkey& hotkey, serverConfig().hotkeys())
|
||||
m_pListHotkeys->addItem(hotkey.text());
|
||||
@@ -105,6 +106,7 @@ void ServerConfigDialog::accept()
|
||||
serverConfig().setEnableDragAndDrop(m_pCheckBoxEnableDragAndDrop->isChecked());
|
||||
serverConfig().setDisableLockToScreen(m_pCheckBoxDisableLockToScreen->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,
|
||||
// which is a reference to the one in MainWindow.
|
||||
|
||||
Reference in New Issue
Block a user