refactor(ServerConfigDialog): rename onChange -> setButtonBoxEnabledButtons
This commit is contained in:
parent
4107e7bdda
commit
f7ae12d772
2 changed files with 28 additions and 26 deletions
|
|
@ -52,7 +52,7 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config)
|
||||||
if (!deskflow::platform::isWindows())
|
if (!deskflow::platform::isWindows())
|
||||||
ui->cbWin32KeepForeground->setVisible(false);
|
ui->cbWin32KeepForeground->setVisible(false);
|
||||||
initConnections();
|
initConnections();
|
||||||
onChange();
|
setButtonBoxEnabledButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerConfigDialog::~ServerConfigDialog() = default;
|
ServerConfigDialog::~ServerConfigDialog() = default;
|
||||||
|
|
@ -120,7 +120,7 @@ void ServerConfigDialog::addHotkey()
|
||||||
if (dlg.exec() == QDialog::Accepted) {
|
if (dlg.exec() == QDialog::Accepted) {
|
||||||
serverConfig().hotkeys().append(hotkey);
|
serverConfig().hotkeys().append(hotkey);
|
||||||
ui->listHotkeys->addItem(hotkey.text());
|
ui->listHotkeys->addItem(hotkey.text());
|
||||||
onChange();
|
setButtonBoxEnabledButtons();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -136,7 +136,7 @@ void ServerConfigDialog::editHotkey()
|
||||||
HotkeyDialog dlg(this, hotkey);
|
HotkeyDialog dlg(this, hotkey);
|
||||||
if (dlg.exec() == QDialog::Accepted) {
|
if (dlg.exec() == QDialog::Accepted) {
|
||||||
ui->listHotkeys->currentItem()->setText(hotkey.text());
|
ui->listHotkeys->currentItem()->setText(hotkey.text());
|
||||||
onChange();
|
setButtonBoxEnabledButtons();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -151,7 +151,7 @@ void ServerConfigDialog::removeHotkey()
|
||||||
serverConfig().hotkeys().removeAt(row);
|
serverConfig().hotkeys().removeAt(row);
|
||||||
ui->listActions->clear();
|
ui->listActions->clear();
|
||||||
delete ui->listHotkeys->item(row);
|
delete ui->listHotkeys->item(row);
|
||||||
onChange();
|
setButtonBoxEnabledButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::listHotkeysSelectionChanged(const QItemSelection &selected, const QItemSelection &)
|
void ServerConfigDialog::listHotkeysSelectionChanged(const QItemSelection &selected, const QItemSelection &)
|
||||||
|
|
@ -183,7 +183,7 @@ void ServerConfigDialog::addAction()
|
||||||
if (dlg.exec() == QDialog::Accepted) {
|
if (dlg.exec() == QDialog::Accepted) {
|
||||||
hotkey.actions().append(action);
|
hotkey.actions().append(action);
|
||||||
ui->listActions->addItem(action.text());
|
ui->listActions->addItem(action.text());
|
||||||
onChange();
|
setButtonBoxEnabledButtons();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -206,7 +206,7 @@ void ServerConfigDialog::editAction()
|
||||||
ActionDialog dlg(this, serverConfig(), hotkey, action);
|
ActionDialog dlg(this, serverConfig(), hotkey, action);
|
||||||
if (dlg.exec() == QDialog::Accepted) {
|
if (dlg.exec() == QDialog::Accepted) {
|
||||||
ui->listActions->currentItem()->setText(action.text());
|
ui->listActions->currentItem()->setText(action.text());
|
||||||
onChange();
|
setButtonBoxEnabledButtons();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -227,7 +227,7 @@ void ServerConfigDialog::removeAction()
|
||||||
|
|
||||||
hotkey.actions().removeAt(actionRow);
|
hotkey.actions().removeAt(actionRow);
|
||||||
delete ui->listActions->currentItem();
|
delete ui->listActions->currentItem();
|
||||||
onChange();
|
setButtonBoxEnabledButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::toggleClipboard(bool enabled)
|
void ServerConfigDialog::toggleClipboard(bool enabled)
|
||||||
|
|
@ -242,7 +242,7 @@ void ServerConfigDialog::toggleClipboard(bool enabled)
|
||||||
m_clipboardSize = Settings::defaultValue(Settings::Server::ClipboardSize).toUInt();
|
m_clipboardSize = Settings::defaultValue(Settings::Server::ClipboardSize).toUInt();
|
||||||
ui->sbClipboardSizeLimit->setValue(m_clipboardSize ? m_clipboardSize : 1);
|
ui->sbClipboardSizeLimit->setValue(m_clipboardSize ? m_clipboardSize : 1);
|
||||||
}
|
}
|
||||||
onChange();
|
setButtonBoxEnabledButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::setClipboardLimit(int limit)
|
void ServerConfigDialog::setClipboardLimit(int limit)
|
||||||
|
|
@ -251,14 +251,14 @@ void ServerConfigDialog::setClipboardLimit(int limit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_clipboardSize = limit;
|
m_clipboardSize = limit;
|
||||||
onChange();
|
setButtonBoxEnabledButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::toggleHeartbeat(bool enabled)
|
void ServerConfigDialog::toggleHeartbeat(bool enabled)
|
||||||
{
|
{
|
||||||
m_enableHeartbeat = enabled;
|
m_enableHeartbeat = enabled;
|
||||||
ui->sbHeartbeat->setEnabled(enabled);
|
ui->sbHeartbeat->setEnabled(enabled);
|
||||||
onChange();
|
setButtonBoxEnabledButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::setHeartbeat(int rate)
|
void ServerConfigDialog::setHeartbeat(int rate)
|
||||||
|
|
@ -266,7 +266,7 @@ void ServerConfigDialog::setHeartbeat(int rate)
|
||||||
if (rate == m_heartbeatRate)
|
if (rate == m_heartbeatRate)
|
||||||
return;
|
return;
|
||||||
m_heartbeatRate = rate;
|
m_heartbeatRate = rate;
|
||||||
onChange();
|
setButtonBoxEnabledButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::toggleRelativeMouseMoves(bool enabled)
|
void ServerConfigDialog::toggleRelativeMouseMoves(bool enabled)
|
||||||
|
|
@ -274,13 +274,13 @@ void ServerConfigDialog::toggleRelativeMouseMoves(bool enabled)
|
||||||
if (m_relativeMouseMoves == enabled)
|
if (m_relativeMouseMoves == enabled)
|
||||||
return;
|
return;
|
||||||
m_relativeMouseMoves = enabled;
|
m_relativeMouseMoves = enabled;
|
||||||
onChange();
|
setButtonBoxEnabledButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::toggleProtocol()
|
void ServerConfigDialog::toggleProtocol()
|
||||||
{
|
{
|
||||||
m_protocol = ui->rbProtocolBarrier->isChecked() ? NetworkProtocol::Barrier : NetworkProtocol::Synergy;
|
m_protocol = ui->rbProtocolBarrier->isChecked() ? NetworkProtocol::Barrier : NetworkProtocol::Synergy;
|
||||||
onChange();
|
setButtonBoxEnabledButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::listActionsSelectionChanged(const QItemSelection &selected, const QItemSelection &)
|
void ServerConfigDialog::listActionsSelectionChanged(const QItemSelection &selected, const QItemSelection &)
|
||||||
|
|
@ -294,7 +294,7 @@ void ServerConfigDialog::toggleSwitchDoubleTap(bool enable)
|
||||||
{
|
{
|
||||||
m_enableSwitchDoubleTap = enable;
|
m_enableSwitchDoubleTap = enable;
|
||||||
ui->sbSwitchDoubleTap->setEnabled(enable);
|
ui->sbSwitchDoubleTap->setEnabled(enable);
|
||||||
onChange();
|
setButtonBoxEnabledButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::setSwitchDoubleTap(int within)
|
void ServerConfigDialog::setSwitchDoubleTap(int within)
|
||||||
|
|
@ -302,14 +302,14 @@ void ServerConfigDialog::setSwitchDoubleTap(int within)
|
||||||
if (m_switchDoubleTap == within)
|
if (m_switchDoubleTap == within)
|
||||||
return;
|
return;
|
||||||
m_switchDoubleTap = within;
|
m_switchDoubleTap = within;
|
||||||
onChange();
|
setButtonBoxEnabledButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::toggleSwitchDelay(bool enable)
|
void ServerConfigDialog::toggleSwitchDelay(bool enable)
|
||||||
{
|
{
|
||||||
m_enableSwitchDelay = enable;
|
m_enableSwitchDelay = enable;
|
||||||
ui->sbSwitchDelay->setEnabled(enable);
|
ui->sbSwitchDelay->setEnabled(enable);
|
||||||
onChange();
|
setButtonBoxEnabledButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::setSwitchDelay(int delay)
|
void ServerConfigDialog::setSwitchDelay(int delay)
|
||||||
|
|
@ -317,7 +317,7 @@ void ServerConfigDialog::setSwitchDelay(int delay)
|
||||||
if (m_switchDelay == delay)
|
if (m_switchDelay == delay)
|
||||||
return;
|
return;
|
||||||
m_switchDelay = delay;
|
m_switchDelay = delay;
|
||||||
onChange();
|
setButtonBoxEnabledButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::toggleDefaultLockToComputerState(bool state)
|
void ServerConfigDialog::toggleDefaultLockToComputerState(bool state)
|
||||||
|
|
@ -325,7 +325,7 @@ void ServerConfigDialog::toggleDefaultLockToComputerState(bool state)
|
||||||
if (m_defaultLockToComputerState == state)
|
if (m_defaultLockToComputerState == state)
|
||||||
return;
|
return;
|
||||||
m_defaultLockToComputerState = state;
|
m_defaultLockToComputerState = state;
|
||||||
onChange();
|
setButtonBoxEnabledButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::toggleLockToComputer(bool disabled)
|
void ServerConfigDialog::toggleLockToComputer(bool disabled)
|
||||||
|
|
@ -333,7 +333,7 @@ void ServerConfigDialog::toggleLockToComputer(bool disabled)
|
||||||
if (m_disableLockToComputer == disabled)
|
if (m_disableLockToComputer == disabled)
|
||||||
return;
|
return;
|
||||||
m_disableLockToComputer = disabled;
|
m_disableLockToComputer = disabled;
|
||||||
onChange();
|
setButtonBoxEnabledButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::toggleWin32Foreground(bool enabled)
|
void ServerConfigDialog::toggleWin32Foreground(bool enabled)
|
||||||
|
|
@ -341,7 +341,7 @@ void ServerConfigDialog::toggleWin32Foreground(bool enabled)
|
||||||
if (m_win32keepForeground == enabled)
|
if (m_win32keepForeground == enabled)
|
||||||
return;
|
return;
|
||||||
m_win32keepForeground = enabled;
|
m_win32keepForeground = enabled;
|
||||||
onChange();
|
setButtonBoxEnabledButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::addClient()
|
void ServerConfigDialog::addClient()
|
||||||
|
|
@ -352,7 +352,7 @@ void ServerConfigDialog::addClient()
|
||||||
void ServerConfigDialog::onScreenRemoved()
|
void ServerConfigDialog::onScreenRemoved()
|
||||||
{
|
{
|
||||||
ui->lblNewScreen->setEnabled(true);
|
ui->lblNewScreen->setEnabled(true);
|
||||||
onChange();
|
setButtonBoxEnabledButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::toggleExternalConfig(bool checked)
|
void ServerConfigDialog::toggleExternalConfig(bool checked)
|
||||||
|
|
@ -361,7 +361,7 @@ void ServerConfigDialog::toggleExternalConfig(bool checked)
|
||||||
ui->tabWidget->setTabEnabled(0, !checked);
|
ui->tabWidget->setTabEnabled(0, !checked);
|
||||||
ui->tabWidget->setTabEnabled(1, !checked);
|
ui->tabWidget->setTabEnabled(1, !checked);
|
||||||
serverConfig().setUseExternalConfig(checked);
|
serverConfig().setUseExternalConfig(checked);
|
||||||
onChange();
|
setButtonBoxEnabledButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServerConfigDialog::browseConfigFile()
|
bool ServerConfigDialog::browseConfigFile()
|
||||||
|
|
@ -376,7 +376,7 @@ bool ServerConfigDialog::browseConfigFile()
|
||||||
if (!fileName.isEmpty()) {
|
if (!fileName.isEmpty()) {
|
||||||
ui->lineConfigFile->setText(fileName);
|
ui->lineConfigFile->setText(fileName);
|
||||||
serverConfig().setConfigFile(ui->lineConfigFile->text());
|
serverConfig().setConfigFile(ui->lineConfigFile->text());
|
||||||
onChange();
|
setButtonBoxEnabledButtons();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -504,7 +504,9 @@ void ServerConfigDialog::initConnections() const
|
||||||
ui->cbDefaultLockToComputerState, &QCheckBox::toggled, this, &ServerConfigDialog::toggleDefaultLockToComputerState
|
ui->cbDefaultLockToComputerState, &QCheckBox::toggled, this, &ServerConfigDialog::toggleDefaultLockToComputerState
|
||||||
);
|
);
|
||||||
connect(ui->cbDisableLockToComputer, &QCheckBox::toggled, this, &ServerConfigDialog::toggleLockToComputer);
|
connect(ui->cbDisableLockToComputer, &QCheckBox::toggled, this, &ServerConfigDialog::toggleLockToComputer);
|
||||||
connect(&m_screenSetupModel, &ScreenSetupModel::screensChanged, this, &ServerConfigDialog::onChange);
|
connect(
|
||||||
|
&m_screenSetupModel, &ScreenSetupModel::screensChanged, this, &ServerConfigDialog::setButtonBoxEnabledButtons
|
||||||
|
);
|
||||||
connect(Settings::instance(), &Settings::settingsWritableChanged, this, &ServerConfigDialog::updateControls);
|
connect(Settings::instance(), &Settings::settingsWritableChanged, this, &ServerConfigDialog::updateControls);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -560,7 +562,7 @@ bool ServerConfigDialog::isGeneralConfigModified() const
|
||||||
m_defaultLockToComputerState != Settings::value(Settings::Server::DefaultLockToComputerState).toBool();
|
m_defaultLockToComputerState != Settings::value(Settings::Server::DefaultLockToComputerState).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::onChange()
|
void ServerConfigDialog::setButtonBoxEnabledButtons() const
|
||||||
{
|
{
|
||||||
const bool writable = Settings::isWritable();
|
const bool writable = Settings::isWritable();
|
||||||
m_buttonBox->enableSave(writable && (isGeneralConfigModified() || !(m_originalServerConfig == m_serverConfig)));
|
m_buttonBox->enableSave(writable && (isGeneralConfigModified() || !(m_originalServerConfig == m_serverConfig)));
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ private:
|
||||||
void initConnections() const;
|
void initConnections() const;
|
||||||
void updateControls() const;
|
void updateControls() const;
|
||||||
bool isGeneralConfigModified() const;
|
bool isGeneralConfigModified() const;
|
||||||
void onChange();
|
void setButtonBoxEnabledButtons() const;
|
||||||
std::unique_ptr<Ui::ServerConfigDialog> ui;
|
std::unique_ptr<Ui::ServerConfigDialog> ui;
|
||||||
QString m_message = "";
|
QString m_message = "";
|
||||||
int m_columns;
|
int m_columns;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue