deskflow/src/lib/gui/dialogs/ServerConfigDialog.cpp

585 lines
22 KiB
C++
Raw Normal View History

2012-06-10 16:50:54 +00:00
/*
* Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2025 - 2026 Chris Rizzitello <sithlord48@gmail.com>
* SPDX-FileCopyrightText: (C) 2012 - 2016 Synergy App Ltd
* 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
*/
#include "ServerConfigDialog.h"
#include "ui_ServerConfigDialog.h"
#include "common/Constants.h"
#include "common/NetworkProtocol.h"
#include "common/PlatformInfo.h"
#include "common/Settings.h"
#include "dialogs/ActionDialog.h"
#include "dialogs/HotkeyDialog.h"
#include "dialogs/ScreenSettingsDialog.h"
#include "gui/widgets/SettingsDialogButtonBox.h"
#include <QFileDialog>
#include <QMessageBox>
2012-06-10 16:50:54 +00:00
using enum ScreenConfig::SwitchCorner;
ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config)
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
ui{std::make_unique<Ui::ServerConfigDialog>()},
m_columns{Settings::value(Settings::Server::GridWidth).toInt()},
m_rows{Settings::value(Settings::Server::GridHeight).toInt()},
m_originalServerConfig(config),
m_originalServerConfigIsExternal(config.useExternalConfig()),
m_originalServerConfigUsesExternalFile(config.configFile()),
m_serverConfig(config),
m_screenSetupModel(m_serverConfig.screens(), m_columns, m_rows),
m_buttonBox{new SettingsDialogButtonBox(this)}
{
ui->setupUi(this);
ui->tabWidget->setCurrentIndex(0);
layout()->addWidget(m_buttonBox);
m_buttonBox->enableRestoreDefaults(false);
setOriginalServerConfig(serverConfig());
loadFromConfig();
ui->lblRemoveScreen->setPixmap(QIcon::fromTheme("user-trash").pixmap(QSize(64, 64)));
ui->lblNewScreen->setEnabled(!model().isFull());
2025-01-30 04:45:28 +00:00
ui->lblNewScreen->setPixmap(QIcon::fromTheme("video-display").pixmap(QSize(64, 64)));
ui->btnBrowseConfigFile->setIcon(QIcon::fromTheme(QIcon::ThemeIcon::DocumentOpen));
if (!deskflow::platform::isWindows())
ui->cbWin32KeepForeground->setVisible(false);
initConnections();
setButtonBoxEnabledButtons();
2012-06-10 16:50:54 +00:00
}
ServerConfigDialog::~ServerConfigDialog() = default;
bool ServerConfigDialog::addClient(const QString &clientName)
{
return addComputer(clientName, true);
Synergy 1161 when clicking on save preferences on configure server window, automatically apply all the new settings (#7081) * SYNERGY-1161 When clicking on "Save" preferences on "Configure server" window, automatically apply all the new settings *Added comparison for all classes which used in server config * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Added server config changes checking logic * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings * Update ChangeLog * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix code style * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings * Fix Linux build * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix Sonar code smells * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix Ubuntu, CentOS and Debian build * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix merge conflicts * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Update ChangeLog * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix server config OK button behaviour on autoconfig * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Update changelog * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix sonar codesmell * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix build * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Adding client on autoconfig silently Co-authored-by: Andrii Batyiev <andrii-external@symless.com>
2021-09-06 08:25:55 +00:00
}
void ServerConfigDialog::save()
{
if (ui->groupExternalConfig->isChecked() && !QFile::exists(ui->lineConfigFile->text())) {
auto selectedButton = QMessageBox::warning(
this, "Filename invalid", "Please select a valid configuration file.", QMessageBox::Ok | QMessageBox::Ignore
);
if (selectedButton != QMessageBox::Ok || !browseConfigFile()) {
return;
}
}
// 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.
Implement safer memory use, improve dev env, fixed GUI bugs (#7407) * Improve dev script for daemon * Ignore `.user` files created by Qt * Add `FORCE_DESKTOP_PROCESS` option * Catch errors related to getting profile dir * Disable IPC entirely if forced desktop * Use in-class init for AppConfig members * Refactor config to use safer memory management * Improve launch config to make OS-specific debugger usage clearer * Re-enable MainWindowTests on Windows, further refactor for memory safety, fixed some include orders * Remove dead singleton code * Swap order of tests * Use HTTPs for URLs * Fixed compile errors for `SYNERGY_ENABLE_LICENSING` compile path * Restore exec function call * Remove extra link in cancel dialog * Fixed broken link on activation cancel UI * Close dialog if activated * Fixed macOS enum ref to kCurrentProcess * Improve wording on cancel activation dialog * WIP - Test timeout (compile error) * Finished timeout logic (with smart pointer) * Include string_view * Switch to thread from jthread (maybe not supported by macOS compiler?) * Improve comment * Disable test on Windows * Add TODO related to jthread on macOS * Refactor settings and paths on Windows * Launch in desktop mode on Windows * Remove arg quote wraps which break desktop mode * Fixed qFatal on Linux * Remove test value * Follow original `AppConfig` accessor convention * Disable service checkbox if not Windows * Simplify TLS control enable logic * Update command and Git ignore * Fixed code style * Fixed include consistency * Fixed includes in validator * Fixed lint errors * Update ChangeLog * Use smart pointer for core process * Remove unneccesary default operators * Don't halt on stderr
2024-07-22 16:48:02 +00:00
setOriginalServerConfig(serverConfig());
Settings::setValue(Settings::Server::Protocol, networkProtocolToOption(m_protocol));
Settings::setValue(Settings::Server::EnableClipboard, m_enableClipboard);
Settings::setValue(Settings::Server::ClipboardSize, m_clipboardSize);
Settings::setValue(Settings::Server::EnableHeatbeat, m_enableHeartbeat);
Settings::setValue(Settings::Server::Heartbeat, m_heartbeatRate);
Settings::setValue(Settings::Server::EnableSwitchDelay, m_enableSwitchDelay);
Settings::setValue(Settings::Server::SwitchDelay, m_switchDelay);
Settings::setValue(Settings::Server::DefaultLockToComputerState, m_defaultLockToComputerState);
Settings::setValue(Settings::Server::DisableLockToComputer, m_disableLockToComputer);
Settings::setValue(Settings::Server::EnableSwitchDoubleTap, m_enableSwitchDoubleTap);
Settings::setValue(Settings::Server::SwitchDoubleTap, m_switchDoubleTap);
Settings::setValue(Settings::Server::RelativeMouseMoves, m_relativeMouseMoves);
Settings::setValue(Settings::Server::Win32KeepForeground, m_win32keepForeground);
2012-06-10 16:50:54 +00:00
QStringList screenNames;
const auto screenList = m_screenSetupModel.m_Screens;
for (const auto &screen : screenList) {
const auto &screenName = screen.name();
if (screenName.isEmpty())
continue;
screenNames.append(QStringLiteral("screen_%1").arg(screenName));
Settings::setValue(Settings::Screen::Aliases.arg(screenName), screen.aliases());
}
Settings::removeUnknownScreens(screenNames);
QDialog::accept();
2012-06-10 16:50:54 +00:00
}
void ServerConfigDialog::cancel()
{
serverConfig().setUseExternalConfig(m_originalServerConfigIsExternal);
serverConfig().setConfigFile(m_originalServerConfigUsesExternalFile);
QDialog::reject();
}
void ServerConfigDialog::addHotkey()
{
Improve UI design and reduce over-use of `#ifdef` (#7413) * Rename `LicenseManager` to `License` * Rename `LicenseManager` to `License` * Move License class to gui lib * Rename license related classes * Refactor serial key parsing * Don't fail fast on containers * Move licensed product name from config to code * Fixed formatting * Update code coverage generator and fixed args * WIP: Converting license to chrono * WIP: Fixed compile errors, tests failing * Fixed all serial key and license tests * Disable verbose logging * Add missing </p> * Add missing include * Revert code coverage config * Handle parse errors * Move more classes into the new gui lib and improve license/serial object ownership * WIP: Fixing signal/slots in MainWindow * Fixed slot for about to quit * Rename manual slots to solve auto-connection warnings * Fixed logging issue * By default, don't close to tray * Add .env support and furthe refactor license code, also fixed some copyright dates * Remove test code * Fixed memory error in .env parser and refactor more licensing display code * Fixed color inconsistencies * Fixed link colors and made log view expand * Disable server components rather than hiding * Reset years of blind UI layout fiddling * Fixed clean Qt task * Only show notice when time limited * Fixed main window layout * Show connected clients * Set 15 spacing * Auto connect on start * More intentional screen size * Fixed tests related to license * Tests for expiry notifications * Reorg tests and remove death test * Update gtest * Tests for dotenv parser * Test command process * What the heck is that doing there? * Merge constants headers * Fixed magic includes * Remove helper function * Remove comment * Remove extern decl * Update ChangeLog
2024-07-26 22:53:52 +00:00
Hotkey hotkey;
HotkeyDialog dlg(this, hotkey);
if (dlg.exec() == QDialog::Accepted) {
serverConfig().hotkeys().append(hotkey);
ui->listHotkeys->addItem(hotkey.text());
setButtonBoxEnabledButtons();
}
2012-06-10 16:50:54 +00:00
}
void ServerConfigDialog::editHotkey()
{
int row = ui->listHotkeys->currentRow();
if (row < 0 || row >= serverConfig().hotkeys().size()) {
qDebug() << "Attempt to editing out of bounds hotkey row: " << row;
return;
}
Hotkey &hotkey = serverConfig().hotkeys()[row];
HotkeyDialog dlg(this, hotkey);
if (dlg.exec() == QDialog::Accepted) {
ui->listHotkeys->currentItem()->setText(hotkey.text());
setButtonBoxEnabledButtons();
}
2012-06-10 16:50:54 +00:00
}
void ServerConfigDialog::removeHotkey()
{
int row = ui->listHotkeys->currentRow();
if (row < 0 || row >= serverConfig().hotkeys().size()) {
qDebug() << "Attempt to remove out of bounds hotkey row: " << row;
return;
}
serverConfig().hotkeys().removeAt(row);
ui->listActions->clear();
delete ui->listHotkeys->item(row);
setButtonBoxEnabledButtons();
}
void ServerConfigDialog::listHotkeysSelectionChanged(const QItemSelection &selected, const QItemSelection &)
{
bool itemsSelected = !selected.isEmpty();
ui->btnEditHotkey->setEnabled(itemsSelected);
ui->btnRemoveHotkey->setEnabled(itemsSelected);
ui->btnNewAction->setEnabled(itemsSelected);
if (itemsSelected && !serverConfig().hotkeys().isEmpty()) {
ui->listActions->clear();
const Hotkey &hotkey = serverConfig().hotkeys().at(selected.indexes().first().row());
for (const Action &action : hotkey.actions())
ui->listActions->addItem(action.text());
}
2012-06-10 16:50:54 +00:00
}
void ServerConfigDialog::addAction()
{
int row = ui->listHotkeys->currentRow();
if (row < 0 || row >= serverConfig().hotkeys().size()) {
qDebug() << "Attempt to add action to out of bounds hotkey row: " << row;
return;
}
Hotkey &hotkey = serverConfig().hotkeys()[row];
Action action;
ActionDialog dlg(this, serverConfig(), hotkey, action);
if (dlg.exec() == QDialog::Accepted) {
hotkey.actions().append(action);
ui->listActions->addItem(action.text());
setButtonBoxEnabledButtons();
}
2012-06-10 16:50:54 +00:00
}
void ServerConfigDialog::editAction()
{
int hotkeyRow = ui->listHotkeys->currentRow();
if (hotkeyRow < 0 || hotkeyRow >= serverConfig().hotkeys().size()) {
qDebug() << "Attempt to edit action from out of bounds hotkey row: " << hotkeyRow;
return;
}
Hotkey &hotkey = serverConfig().hotkeys()[hotkeyRow];
2012-06-10 16:50:54 +00:00
int actionRow = ui->listActions->currentRow();
if (actionRow < 0 || actionRow >= hotkey.actions().size()) {
qDebug() << "Attempt to remove out of bounds action row: " << actionRow;
return;
}
Action &action = hotkey.actions()[actionRow];
2012-06-10 16:50:54 +00:00
ActionDialog dlg(this, serverConfig(), hotkey, action);
if (dlg.exec() == QDialog::Accepted) {
ui->listActions->currentItem()->setText(action.text());
setButtonBoxEnabledButtons();
}
2012-06-10 16:50:54 +00:00
}
void ServerConfigDialog::removeAction()
{
int hotkeyRow = ui->listHotkeys->currentRow();
if (hotkeyRow < 0 || hotkeyRow >= serverConfig().hotkeys().size()) {
qDebug() << "Attempt to remove action from out of bounds hotkey row: " << hotkeyRow;
return;
}
Hotkey &hotkey = serverConfig().hotkeys()[hotkeyRow];
2012-06-10 16:50:54 +00:00
int actionRow = ui->listActions->currentRow();
if (actionRow < 0 || actionRow >= hotkey.actions().size()) {
qDebug() << "Attempt to remove out of bounds action row: " << actionRow;
return;
}
2012-06-10 16:50:54 +00:00
hotkey.actions().removeAt(actionRow);
delete ui->listActions->currentItem();
setButtonBoxEnabledButtons();
2012-06-10 16:50:54 +00:00
}
void ServerConfigDialog::toggleClipboard(bool enabled)
{
if (m_enableClipboard == enabled)
return;
m_enableClipboard = enabled;
ui->sbClipboardSizeLimit->setEnabled(enabled);
if (enabled && !ui->sbClipboardSizeLimit->value()) {
m_clipboardSize = Settings::defaultValue(Settings::Server::ClipboardSize).toUInt();
ui->sbClipboardSizeLimit->setValue(m_clipboardSize ? m_clipboardSize : 1);
}
setButtonBoxEnabledButtons();
}
void ServerConfigDialog::setClipboardLimit(int limit)
{
if (m_clipboardSize == limit)
return;
m_clipboardSize = limit;
setButtonBoxEnabledButtons();
}
void ServerConfigDialog::toggleHeartbeat(bool enabled)
{
m_enableHeartbeat = enabled;
ui->sbHeartbeat->setEnabled(enabled);
setButtonBoxEnabledButtons();
}
void ServerConfigDialog::setHeartbeat(int rate)
{
if (rate == m_heartbeatRate)
return;
m_heartbeatRate = rate;
setButtonBoxEnabledButtons();
}
void ServerConfigDialog::toggleRelativeMouseMoves(bool enabled)
{
if (m_relativeMouseMoves == enabled)
return;
m_relativeMouseMoves = enabled;
setButtonBoxEnabledButtons();
}
void ServerConfigDialog::toggleProtocol()
{
m_protocol = ui->rbProtocolBarrier->isChecked() ? NetworkProtocol::Barrier : NetworkProtocol::Synergy;
setButtonBoxEnabledButtons();
}
void ServerConfigDialog::listActionsSelectionChanged(const QItemSelection &selected, const QItemSelection &)
{
bool enabled = !selected.isEmpty();
ui->btnEditAction->setEnabled(enabled);
ui->btnRemoveAction->setEnabled(enabled);
2012-06-10 16:50:54 +00:00
}
void ServerConfigDialog::toggleSwitchDoubleTap(bool enable)
{
m_enableSwitchDoubleTap = enable;
ui->sbSwitchDoubleTap->setEnabled(enable);
setButtonBoxEnabledButtons();
}
void ServerConfigDialog::setSwitchDoubleTap(int within)
{
if (m_switchDoubleTap == within)
return;
m_switchDoubleTap = within;
setButtonBoxEnabledButtons();
}
void ServerConfigDialog::toggleSwitchDelay(bool enable)
{
m_enableSwitchDelay = enable;
ui->sbSwitchDelay->setEnabled(enable);
setButtonBoxEnabledButtons();
}
void ServerConfigDialog::setSwitchDelay(int delay)
{
if (m_switchDelay == delay)
return;
m_switchDelay = delay;
setButtonBoxEnabledButtons();
}
void ServerConfigDialog::toggleDefaultLockToComputerState(bool state)
{
if (m_defaultLockToComputerState == state)
return;
m_defaultLockToComputerState = state;
setButtonBoxEnabledButtons();
}
void ServerConfigDialog::toggleLockToComputer(bool disabled)
{
if (m_disableLockToComputer == disabled)
return;
m_disableLockToComputer = disabled;
setButtonBoxEnabledButtons();
}
void ServerConfigDialog::toggleWin32Foreground(bool enabled)
{
if (m_win32keepForeground == enabled)
return;
m_win32keepForeground = enabled;
setButtonBoxEnabledButtons();
}
void ServerConfigDialog::addClient()
{
addComputer("", false);
}
void ServerConfigDialog::onScreenRemoved()
{
2025-01-30 04:45:28 +00:00
ui->lblNewScreen->setEnabled(true);
setButtonBoxEnabledButtons();
}
void ServerConfigDialog::toggleExternalConfig(bool checked)
{
ui->widgetExternalConfigControls->setEnabled(checked);
ui->tabWidget->setTabEnabled(0, !checked);
ui->tabWidget->setTabEnabled(1, !checked);
serverConfig().setUseExternalConfig(checked);
setButtonBoxEnabledButtons();
}
bool ServerConfigDialog::browseConfigFile()
{
//: %1 is replaced with the application names
//: (*.conf) and (*.*) should not be translated
const auto deskflowConfigFilter = tr("%1 Configurations (*.conf);;All files (*.*)");
QString fileName =
QFileDialog::getOpenFileName(this, tr("Browse for a config file"), "", deskflowConfigFilter.arg(kAppName));
if (!fileName.isEmpty()) {
ui->lineConfigFile->setText(fileName);
serverConfig().setConfigFile(ui->lineConfigFile->text());
setButtonBoxEnabledButtons();
return true;
}
return false;
}
void ServerConfigDialog::loadFromConfig()
{
m_protocol = Settings::networkProtocol();
ui->rbProtocolSynergy->setChecked(m_protocol == NetworkProtocol::Synergy);
ui->rbProtocolBarrier->setChecked(m_protocol == NetworkProtocol::Barrier);
ui->lineConfigFile->setText(serverConfig().configFile());
m_enableHeartbeat = Settings::value(Settings::Server::EnableHeatbeat).toBool();
ui->cbHeartbeat->setChecked(m_enableHeartbeat);
ui->sbHeartbeat->setEnabled(ui->cbHeartbeat->isChecked());
m_heartbeatRate = Settings::value(Settings::Server::Heartbeat).toInt();
ui->sbHeartbeat->setValue(m_heartbeatRate);
m_relativeMouseMoves = Settings::value(Settings::Server::RelativeMouseMoves).toBool();
ui->cbRelativeMouseMoves->setChecked(m_relativeMouseMoves);
m_win32keepForeground = Settings::value(Settings::Server::Win32KeepForeground).toBool();
ui->cbWin32KeepForeground->setChecked(m_win32keepForeground);
m_enableSwitchDelay = Settings::value(Settings::Server::EnableSwitchDelay).toBool();
ui->cbSwitchDelay->setChecked(m_enableSwitchDelay);
ui->sbSwitchDelay->setEnabled(ui->cbSwitchDelay->isChecked());
m_switchDelay = Settings::value(Settings::Server::SwitchDelay).toInt();
ui->sbSwitchDelay->setValue(m_switchDelay);
m_enableSwitchDoubleTap = Settings::value(Settings::Server::EnableSwitchDoubleTap).toBool();
ui->cbSwitchDoubleTap->setChecked(m_enableSwitchDoubleTap);
ui->sbSwitchDoubleTap->setEnabled(ui->cbSwitchDoubleTap->isChecked());
m_switchDoubleTap = Settings::value(Settings::Server::SwitchDoubleTap).toInt();
ui->sbSwitchDoubleTap->setValue(m_switchDoubleTap);
ui->groupExternalConfig->setChecked(serverConfig().useExternalConfig());
ui->widgetExternalConfigControls->setEnabled(ui->groupExternalConfig->isChecked());
toggleExternalConfig(ui->groupExternalConfig->isChecked());
m_defaultLockToComputerState = Settings::value(Settings::Server::DefaultLockToComputerState).toBool();
ui->cbDefaultLockToComputerState->setChecked(m_defaultLockToComputerState);
m_disableLockToComputer = Settings::value(Settings::Server::DisableLockToComputer).toBool();
ui->cbDisableLockToComputer->setChecked(m_disableLockToComputer);
m_enableClipboard = Settings::value(Settings::Server::EnableClipboard).toBool();
ui->cbEnableClipboard->setChecked(m_enableClipboard);
ui->sbClipboardSizeLimit->setEnabled(m_enableClipboard);
m_clipboardSize = Settings::value(Settings::Server::ClipboardSize).toUInt();
ui->sbClipboardSizeLimit->setValue(m_clipboardSize);
ui->listHotkeys->clear();
for (const Hotkey &hotkey : std::as_const(serverConfig().hotkeys()))
ui->listHotkeys->addItem(hotkey.text());
ui->screenSetupView->setModel(&m_screenSetupModel);
auto &screens = serverConfig().screens();
auto server = std::ranges::find_if(screens, [this](const Screen &screen) {
return (screen.name() == serverConfig().getServerName());
});
if (server == screens.end()) {
Screen serverScreen(serverConfig().getServerName());
serverScreen.markAsServer();
model().screen(m_columns / 2, m_rows / 2) = serverScreen;
} else {
server->markAsServer();
}
updateControls();
}
void ServerConfigDialog::resetFromSettings()
{
m_serverConfig = m_originalServerConfig;
m_serverConfig.setConfigFile(m_originalServerConfigUsesExternalFile);
m_serverConfig.setUseExternalConfig(m_originalServerConfigIsExternal);
loadFromConfig();
if (ui->tabWidget->currentWidget() == ui->tabComputers) {
ui->screenSetupView->reset();
ui->screenSetupView->update();
}
}
void ServerConfigDialog::initConnections() const
{
connect(m_buttonBox, &SettingsDialogButtonBox::accepted, this, &ServerConfigDialog::save);
connect(m_buttonBox, &SettingsDialogButtonBox::rejected, this, &ServerConfigDialog::cancel);
connect(m_buttonBox, &SettingsDialogButtonBox::reset, this, &ServerConfigDialog::resetFromSettings);
connect(ui->lblRemoveScreen, &TrashScreenWidget::screenRemoved, this, &ServerConfigDialog::onScreenRemoved);
connect(ui->btnNewHotkey, &QPushButton::clicked, this, &ServerConfigDialog::addHotkey);
connect(ui->btnEditHotkey, &QPushButton::clicked, this, &ServerConfigDialog::editHotkey);
connect(ui->btnRemoveHotkey, &QPushButton::clicked, this, &ServerConfigDialog::removeHotkey);
connect(ui->listHotkeys, &QListView::doubleClicked, this, &ServerConfigDialog::editHotkey);
connect(
ui->listHotkeys->selectionModel(), &QItemSelectionModel::selectionChanged, this,
&ServerConfigDialog::listHotkeysSelectionChanged
);
connect(ui->btnNewAction, &QPushButton::clicked, this, &ServerConfigDialog::addAction);
connect(ui->btnEditAction, &QPushButton::clicked, this, &ServerConfigDialog::editAction);
connect(ui->btnRemoveAction, &QPushButton::clicked, this, &ServerConfigDialog::removeAction);
connect(ui->listActions, &QListView::doubleClicked, this, &ServerConfigDialog::editAction);
connect(
ui->listActions->selectionModel(), &QItemSelectionModel::selectionChanged, this,
&ServerConfigDialog::listActionsSelectionChanged
);
connect(ui->rbProtocolBarrier, &QRadioButton::toggled, this, &ServerConfigDialog::toggleProtocol);
connect(ui->cbHeartbeat, &QCheckBox::toggled, this, &ServerConfigDialog::toggleHeartbeat);
connect(ui->sbHeartbeat, QOverload<int>::of(&QSpinBox::valueChanged), this, &ServerConfigDialog::setHeartbeat);
connect(ui->cbWin32KeepForeground, &QCheckBox::toggled, this, &ServerConfigDialog::toggleWin32Foreground);
connect(ui->cbSwitchDelay, &QCheckBox::toggled, this, &ServerConfigDialog::toggleSwitchDelay);
connect(ui->sbSwitchDelay, QOverload<int>::of(&QSpinBox::valueChanged), this, &ServerConfigDialog::setSwitchDelay);
connect(ui->cbSwitchDoubleTap, &QCheckBox::toggled, this, &ServerConfigDialog::toggleSwitchDoubleTap);
connect(
ui->sbSwitchDoubleTap, QOverload<int>::of(&QSpinBox::valueChanged), this, &ServerConfigDialog::setSwitchDoubleTap
);
connect(ui->cbRelativeMouseMoves, &QCheckBox::toggled, this, &ServerConfigDialog::toggleRelativeMouseMoves);
connect(ui->cbEnableClipboard, &QCheckBox::toggled, this, &ServerConfigDialog::toggleClipboard);
connect(ui->btnBrowseConfigFile, &QPushButton::clicked, this, &ServerConfigDialog::browseConfigFile);
connect(ui->groupExternalConfig, &QGroupBox::toggled, this, &ServerConfigDialog::toggleExternalConfig);
connect(
ui->sbClipboardSizeLimit, QOverload<int>::of(&QSpinBox::valueChanged), this,
&ServerConfigDialog::setClipboardLimit
);
connect(
ui->cbDefaultLockToComputerState, &QCheckBox::toggled, this, &ServerConfigDialog::toggleDefaultLockToComputerState
);
connect(ui->cbDisableLockToComputer, &QCheckBox::toggled, this, &ServerConfigDialog::toggleLockToComputer);
connect(
&m_screenSetupModel, &ScreenSetupModel::screensChanged, this, &ServerConfigDialog::setButtonBoxEnabledButtons
);
connect(Settings::instance(), &Settings::settingsWritableChanged, this, &ServerConfigDialog::updateControls);
}
void ServerConfigDialog::updateControls() const
{
const bool writable = Settings::isWritable();
ui->cbDefaultLockToComputerState->setEnabled(writable);
ui->cbDisableLockToComputer->setEnabled(writable);
ui->cbEnableClipboard->setEnabled(writable);
ui->sbClipboardSizeLimit->setEnabled(writable);
ui->rbProtocolBarrier->setEnabled(writable);
ui->rbProtocolSynergy->setEnabled(writable);
ui->cbHeartbeat->setEnabled(writable);
ui->cbRelativeMouseMoves->setEnabled(writable);
ui->cbSwitchDelay->setEnabled(writable);
ui->cbWin32KeepForeground->setEnabled(writable);
ui->cbSwitchDoubleTap->setEnabled(writable);
ui->sbSwitchDoubleTap->setEnabled(writable && ui->cbSwitchDoubleTap->isChecked());
ui->sbSwitchDelay->setEnabled(writable && ui->cbSwitchDelay->isChecked());
ui->groupExternalConfig->setEnabled(writable);
setButtonBoxEnabledButtons();
}
bool ServerConfigDialog::addComputer(const QString &clientName, bool doSilent)
{
bool isAccepted = false;
Screen newScreen(clientName);
Synergy 1161 when clicking on save preferences on configure server window, automatically apply all the new settings (#7081) * SYNERGY-1161 When clicking on "Save" preferences on "Configure server" window, automatically apply all the new settings *Added comparison for all classes which used in server config * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Added server config changes checking logic * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings * Update ChangeLog * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix code style * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings * Fix Linux build * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix Sonar code smells * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix Ubuntu, CentOS and Debian build * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix merge conflicts * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Update ChangeLog * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix server config OK button behaviour on autoconfig * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Update changelog * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix sonar codesmell * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix build * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Adding client on autoconfig silently Co-authored-by: Andrii Batyiev <andrii-external@symless.com>
2021-09-06 08:25:55 +00:00
if (ScreenSettingsDialog dlg(this, &newScreen, &model().m_Screens); doSilent || dlg.exec() == QDialog::Accepted) {
model().addScreen(newScreen);
isAccepted = true;
}
Synergy 1161 when clicking on save preferences on configure server window, automatically apply all the new settings (#7081) * SYNERGY-1161 When clicking on "Save" preferences on "Configure server" window, automatically apply all the new settings *Added comparison for all classes which used in server config * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Added server config changes checking logic * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings * Update ChangeLog * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix code style * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings * Fix Linux build * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix Sonar code smells * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix Ubuntu, CentOS and Debian build * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix merge conflicts * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Update ChangeLog * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix server config OK button behaviour on autoconfig * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Update changelog * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix sonar codesmell * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix build * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Adding client on autoconfig silently Co-authored-by: Andrii Batyiev <andrii-external@symless.com>
2021-09-06 08:25:55 +00:00
2025-01-30 04:45:28 +00:00
ui->lblNewScreen->setEnabled(!model().isFull());
return isAccepted;
Synergy 1161 when clicking on save preferences on configure server window, automatically apply all the new settings (#7081) * SYNERGY-1161 When clicking on "Save" preferences on "Configure server" window, automatically apply all the new settings *Added comparison for all classes which used in server config * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Added server config changes checking logic * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings * Update ChangeLog * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix code style * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings * Fix Linux build * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix Sonar code smells * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix Ubuntu, CentOS and Debian build * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix merge conflicts * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Update ChangeLog * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix server config OK button behaviour on autoconfig * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Update changelog * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix sonar codesmell * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Fix build * SYNERGY-1161 When clicking on Save preferences on Configure server window, automatically apply all the new settings *Adding client on autoconfig silently Co-authored-by: Andrii Batyiev <andrii-external@symless.com>
2021-09-06 08:25:55 +00:00
}
bool ServerConfigDialog::isGeneralConfigModified() const
{
return m_originalServerConfigIsExternal != Settings::value(Settings::Server::ExternalConfig).toBool() ||
m_originalServerConfigUsesExternalFile != Settings::value(Settings::Server::ExternalConfigFile).toString() ||
m_protocol != Settings::networkProtocol() ||
m_enableClipboard != Settings::value(Settings::Server::EnableClipboard).toBool() ||
m_clipboardSize != Settings::value(Settings::Server::ClipboardSize).toUInt() ||
m_enableHeartbeat != Settings::value(Settings::Server::EnableHeatbeat).toBool() ||
m_heartbeatRate != Settings::value(Settings::Server::Heartbeat).toInt() ||
m_enableSwitchDelay != Settings::value(Settings::Server::EnableSwitchDelay).toBool() ||
m_switchDelay != Settings::value(Settings::Server::SwitchDelay).toInt() ||
m_enableSwitchDoubleTap != Settings::value(Settings::Server::EnableSwitchDoubleTap).toBool() ||
m_switchDoubleTap != Settings::value(Settings::Server::SwitchDoubleTap).toInt() ||
m_relativeMouseMoves != Settings::value(Settings::Server::RelativeMouseMoves).toBool() ||
m_win32keepForeground != Settings::value(Settings::Server::Win32KeepForeground).toBool() ||
m_disableLockToComputer != Settings::value(Settings::Server::DisableLockToComputer).toBool() ||
m_defaultLockToComputerState != Settings::value(Settings::Server::DefaultLockToComputerState).toBool();
}
void ServerConfigDialog::setButtonBoxEnabledButtons() const
{
const bool writable = Settings::isWritable();
m_buttonBox->enableSave(writable && (isGeneralConfigModified() || !(m_originalServerConfig == m_serverConfig)));
m_buttonBox->enableReset(writable && (isGeneralConfigModified() || !(m_originalServerConfig == m_serverConfig)));
}