refactor: ServerConfigDialog/tabAdvanced no autoconnections, use naming std

This commit is contained in:
sithlord48 2025-02-01 10:56:07 -05:00 committed by Nick Bolton
parent 169422a0eb
commit ae30237f90
3 changed files with 68 additions and 84 deletions

View file

@ -69,13 +69,13 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config, Ap
ui->m_pEditConfigFile->setText(serverConfig().configFile());
ui->m_pCheckBoxUseExternalConfig->setChecked(serverConfig().useExternalConfig());
ui->m_pCheckBoxHeartbeat->setChecked(serverConfig().hasHeartbeat());
ui->cbHeartbeat->setChecked(serverConfig().hasHeartbeat());
ui->m_pRadioProtocolSynergy->setChecked(serverConfig().protocol() == ServerProtocol::kSynergy);
ui->m_pRadioProtocolBarrier->setChecked(serverConfig().protocol() == ServerProtocol::kBarrier);
ui->m_pSpinBoxHeartbeat->setValue(serverConfig().heartbeat());
ui->sbHeartbeat->setValue(serverConfig().heartbeat());
ui->m_pCheckBoxRelativeMouseMoves->setChecked(serverConfig().relativeMouseMoves());
ui->m_pCheckBoxWin32KeepForeground->setChecked(serverConfig().win32KeepForeground());
ui->cbRelativeMouseMoves->setChecked(serverConfig().relativeMouseMoves());
ui->cbWin32KeepForeground->setChecked(serverConfig().win32KeepForeground());
ui->m_pCheckBoxSwitchDelay->setChecked(serverConfig().hasSwitchDelay());
ui->m_pSpinBoxSwitchDelay->setValue(serverConfig().switchDelay());
@ -88,12 +88,12 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config, Ap
ui->m_pCheckBoxCornerBottomLeft->setChecked(serverConfig().switchCorner(static_cast<int>(BottomLeft)));
ui->m_pCheckBoxCornerBottomRight->setChecked(serverConfig().switchCorner(static_cast<int>(BottomRight)));
ui->m_pSpinBoxSwitchCornerSize->setValue(serverConfig().switchCornerSize());
ui->m_pCheckBoxDisableLockToScreen->setChecked(serverConfig().disableLockToScreen());
ui->cbDisableLockToScreen->setChecked(serverConfig().disableLockToScreen());
ui->m_pCheckBoxEnableClipboard->setChecked(serverConfig().clipboardSharing());
ui->cbEnableClipboard->setChecked(serverConfig().clipboardSharing());
int clipboardSharingSizeM = static_cast<int>(serverConfig().clipboardSharingSize() / 1024);
ui->m_pSpinBoxClipboardSizeLimit->setValue(clipboardSharingSizeM);
ui->m_pSpinBoxClipboardSizeLimit->setEnabled(serverConfig().clipboardSharing());
ui->sbClipboardSizeLimit->setValue(clipboardSharingSizeM);
ui->sbClipboardSizeLimit->setEnabled(serverConfig().clipboardSharing());
for (const Hotkey &hotkey : std::as_const(serverConfig().hotkeys()))
ui->listHotkeys->addItem(hotkey.text());
@ -118,6 +118,9 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config, Ap
// computers
connect(&m_ScreenSetupModel, &ScreenSetupModel::screensChanged, this, &ServerConfigDialog::onChange);
connect(ui->cbEnableClipboard, &QCheckBox::toggled, this, &ServerConfigDialog::toggleClipboard);
connect(ui->cbHeartbeat, &QCheckBox::toggled, this, &ServerConfigDialog::toggleHeartbeat);
// Above Qt 6.7 the checkbox signal signature has changed from int to Qt::CheckState
#if QT_VERSION <= QT_VERSION_CHECK(6, 7, 0)
// advanced
@ -129,23 +132,16 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config, Ap
serverConfig().haveSwitchDoubleTap(v);
onChange();
});
connect(ui->m_pCheckBoxEnableClipboard, &QCheckBox::stateChanged, this, [this](const int &v) {
serverConfig().setClipboardSharing(v);
onChange();
});
connect(ui->m_pCheckBoxHeartbeat, &QCheckBox::stateChanged, this, [this](const int &v) {
serverConfig().haveHeartbeat(v);
onChange();
});
connect(ui->m_pCheckBoxRelativeMouseMoves, &QCheckBox::stateChanged, this, [this](const int &v) {
connect(ui->cbRelativeMouseMoves, &QCheckBox::stateChanged, this, [this](const int &v) {
serverConfig().setRelativeMouseMoves(v);
onChange();
});
connect(ui->m_pCheckBoxWin32KeepForeground, &QCheckBox::stateChanged, this, [this](const int &v) {
connect(ui->cbWin32KeepForeground, &QCheckBox::stateChanged, this, [this](const int &v) {
serverConfig().setWin32KeepForeground(v);
onChange();
});
connect(ui->m_pCheckBoxDisableLockToScreen, &QCheckBox::stateChanged, this, [this](const int &v) {
connect(ui->cbDisableLockToScreen, &QCheckBox::stateChanged, this, [this](const int &v) {
serverConfig().setDisableLockToScreen(v);
onChange();
});
@ -179,23 +175,16 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config, Ap
serverConfig().haveSwitchDoubleTap(v == Qt::Checked);
onChange();
});
connect(ui->m_pCheckBoxEnableClipboard, &QCheckBox::checkStateChanged, this, [this](const Qt::CheckState &v) {
serverConfig().setClipboardSharing(v == Qt::Checked);
onChange();
});
connect(ui->m_pCheckBoxHeartbeat, &QCheckBox::checkStateChanged, this, [this](const Qt::CheckState &v) {
serverConfig().haveHeartbeat(v == Qt::Checked);
onChange();
});
connect(ui->m_pCheckBoxRelativeMouseMoves, &QCheckBox::checkStateChanged, this, [this](const Qt::CheckState &v) {
connect(ui->cbRelativeMouseMoves, &QCheckBox::checkStateChanged, this, [this](const Qt::CheckState &v) {
serverConfig().setRelativeMouseMoves(v == Qt::Checked);
onChange();
});
connect(ui->m_pCheckBoxWin32KeepForeground, &QCheckBox::checkStateChanged, this, [this](const Qt::CheckState &v) {
connect(ui->cbWin32KeepForeground, &QCheckBox::checkStateChanged, this, [this](const Qt::CheckState &v) {
serverConfig().setWin32KeepForeground(v == Qt::Checked);
onChange();
});
connect(ui->m_pCheckBoxDisableLockToScreen, &QCheckBox::checkStateChanged, this, [this](const Qt::CheckState &v) {
connect(ui->cbDisableLockToScreen, &QCheckBox::checkStateChanged, this, [this](const Qt::CheckState &v) {
serverConfig().setDisableLockToScreen(v == Qt::Checked);
onChange();
});
@ -237,19 +226,16 @@ ServerConfigDialog::ServerConfigDialog(QWidget *parent, ServerConfig &config, Ap
}
);
connect(
ui->m_pSpinBoxClipboardSizeLimit, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
ui->sbClipboardSizeLimit, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
[this](const int &v) {
serverConfig().setClipboardSharingSize(v * 1024);
onChange();
}
);
connect(
ui->m_pSpinBoxHeartbeat, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
[this](const int &v) {
serverConfig().setHeartbeat(v);
onChange();
}
);
connect(ui->sbHeartbeat, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, [this](const int &v) {
serverConfig().setHeartbeat(v);
onChange();
});
connect(
ui->m_pSpinBoxSwitchCornerSize, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
[this](const int &v) {
@ -326,7 +312,7 @@ void ServerConfigDialog::editHotkey()
{
int row = ui->listHotkeys->currentRow();
if (row < 0 || row >= serverConfig().hotkeys().size()) {
qDebug() << "Atempt to editing out of bounds hotkey row: " << row;
qDebug() << "Attempt to editing out of bounds hotkey row: " << row;
return;
}
@ -342,7 +328,7 @@ void ServerConfigDialog::removeHotkey()
{
int row = ui->listHotkeys->currentRow();
if (row < 0 || row >= serverConfig().hotkeys().size()) {
qDebug() << "Atempt to remove out of bounds hotkey row: " << row;
qDebug() << "Attempt to remove out of bounds hotkey row: " << row;
return;
}
@ -371,7 +357,7 @@ void ServerConfigDialog::addAction()
{
int row = ui->listHotkeys->currentRow();
if (row < 0 || row >= serverConfig().hotkeys().size()) {
qDebug() << "Atempt to add action to out of bounds hotkey row: " << row;
qDebug() << "Attempt to add action to out of bounds hotkey row: " << row;
return;
}
@ -389,14 +375,14 @@ void ServerConfigDialog::editAction()
{
int hotkeyRow = ui->listHotkeys->currentRow();
if (hotkeyRow < 0 || hotkeyRow >= serverConfig().hotkeys().size()) {
qDebug() << "Atempt to edit action from out of bounds hotkey row: " << hotkeyRow;
qDebug() << "Attempt to edit action from out of bounds hotkey row: " << hotkeyRow;
return;
}
Hotkey &hotkey = serverConfig().hotkeys()[hotkeyRow];
int actionRow = ui->listActions->currentRow();
if (actionRow < 0 || actionRow >= hotkey.actions().size()) {
qDebug() << "Atempt to remove out of bounds action row: " << actionRow;
qDebug() << "Attempt to remove out of bounds action row: " << actionRow;
return;
}
Action &action = hotkey.actions()[actionRow];
@ -412,14 +398,14 @@ void ServerConfigDialog::removeAction()
{
int hotkeyRow = ui->listHotkeys->currentRow();
if (hotkeyRow < 0 || hotkeyRow >= serverConfig().hotkeys().size()) {
qDebug() << "Atempt to remove action from out of bounds hotkey row: " << hotkeyRow;
qDebug() << "Attempt to remove action from out of bounds hotkey row: " << hotkeyRow;
return;
}
Hotkey &hotkey = serverConfig().hotkeys()[hotkeyRow];
int actionRow = ui->listActions->currentRow();
if (actionRow < 0 || actionRow >= hotkey.actions().size()) {
qDebug() << "Atempt to remove out of bounds action row: " << actionRow;
qDebug() << "Attempt to remove out of bounds action row: " << actionRow;
return;
}
@ -428,13 +414,22 @@ void ServerConfigDialog::removeAction()
onChange();
}
void ServerConfigDialog::on_m_pCheckBoxEnableClipboard_stateChanged(int const state)
void ServerConfigDialog::toggleClipboard(bool enabled)
{
ui->m_pSpinBoxClipboardSizeLimit->setEnabled(state == Qt::Checked);
if ((state == Qt::Checked) && (!ui->m_pSpinBoxClipboardSizeLimit->value())) {
ui->sbClipboardSizeLimit->setEnabled(enabled);
if (enabled && !ui->sbClipboardSizeLimit->value()) {
int size = static_cast<int>((serverConfig().defaultClipboardSharingSize() + 512) / 1024);
ui->m_pSpinBoxClipboardSizeLimit->setValue(size ? size : 1);
ui->sbClipboardSizeLimit->setValue(size ? size : 1);
}
serverConfig().setClipboardSharing(enabled);
onChange();
}
void ServerConfigDialog::toggleHeartbeat(bool enabled)
{
ui->sbHeartbeat->setEnabled(enabled);
serverConfig().haveHeartbeat(enabled);
onChange();
}
void ServerConfigDialog::listActionsSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)

View file

@ -38,7 +38,6 @@ public slots:
}
protected slots:
void on_m_pCheckBoxEnableClipboard_stateChanged(int state);
void onScreenRemoved();
void on_m_pCheckBoxUseExternalConfig_toggled(bool checked = false);
bool on_m_pButtonBrowseConfigFile_clicked();
@ -57,6 +56,9 @@ protected:
void removeAction();
void listActionsSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
void toggleClipboard(bool enabled);
void toggleHeartbeat(bool enabled);
ServerConfig &serverConfig()
{
return m_ServerConfig;

View file

@ -22,6 +22,9 @@
<layout class="QVBoxLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>2</number>
</property>
<widget class="QWidget" name="tabComputers">
<attribute name="title">
<string>Computers</string>
@ -285,7 +288,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="m_pTabAdvanced">
<widget class="QWidget" name="tabAdvanced">
<attribute name="title">
<string>Advanced</string>
</attribute>
@ -403,7 +406,7 @@
</widget>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="m_pGroupOptions">
<widget class="QGroupBox" name="groupMisc">
<property name="font">
<font>
<kerning>false</kerning>
@ -414,14 +417,14 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QCheckBox" name="m_pCheckBoxDisableLockToScreen">
<widget class="QCheckBox" name="cbDisableLockToScreen">
<property name="text">
<string>Disable lock to computer (scroll lock key)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="m_pCheckBoxRelativeMouseMoves">
<widget class="QCheckBox" name="cbRelativeMouseMoves">
<property name="enabled">
<bool>true</bool>
</property>
@ -431,7 +434,7 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="m_pCheckBoxWin32KeepForeground">
<widget class="QCheckBox" name="cbWin32KeepForeground">
<property name="enabled">
<bool>true</bool>
</property>
@ -441,12 +444,12 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="m_pLayoutClipboard">
<layout class="QHBoxLayout" name="layoutClipboard">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QCheckBox" name="m_pCheckBoxEnableClipboard">
<widget class="QCheckBox" name="cbEnableClipboard">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -482,7 +485,7 @@
</widget>
</item>
<item>
<widget class="QSpinBox" name="m_pSpinBoxClipboardSizeLimit">
<widget class="QSpinBox" name="sbClipboardSizeLimit">
<property name="enabled">
<bool>false</bool>
</property>
@ -520,13 +523,13 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="m_pGroupNetwork">
<widget class="QGroupBox" name="groupNetwork">
<property name="title">
<string>&amp;Network</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout">
<layout class="QHBoxLayout" name="_4">
<property name="spacing">
<number>9</number>
</property>
@ -534,7 +537,7 @@
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="m_pCheckBoxHeartbeat">
<widget class="QCheckBox" name="cbHeartbeat">
<property name="enabled">
<bool>true</bool>
</property>
@ -547,7 +550,7 @@
</widget>
</item>
<item>
<spacer>
<spacer name="spacerNetwork">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
@ -560,7 +563,7 @@
</spacer>
</item>
<item>
<widget class="QSpinBox" name="m_pSpinBoxHeartbeat">
<widget class="QSpinBox" name="sbHeartbeat">
<property name="enabled">
<bool>false</bool>
</property>
@ -1138,11 +1141,11 @@ Enabling this setting will disable the server config GUI.</string>
<tabstop>m_pSpinBoxSwitchDelay</tabstop>
<tabstop>m_pCheckBoxSwitchDoubleTap</tabstop>
<tabstop>m_pSpinBoxSwitchDoubleTap</tabstop>
<tabstop>m_pCheckBoxEnableClipboard</tabstop>
<tabstop>m_pSpinBoxClipboardSizeLimit</tabstop>
<tabstop>m_pCheckBoxHeartbeat</tabstop>
<tabstop>m_pSpinBoxHeartbeat</tabstop>
<tabstop>m_pCheckBoxRelativeMouseMoves</tabstop>
<tabstop>cbEnableClipboard</tabstop>
<tabstop>sbClipboardSizeLimit</tabstop>
<tabstop>cbHeartbeat</tabstop>
<tabstop>sbHeartbeat</tabstop>
<tabstop>cbRelativeMouseMoves</tabstop>
<tabstop>m_pSpinBoxSwitchCornerSize</tabstop>
<tabstop>m_pCheckBoxUseExternalConfig</tabstop>
<tabstop>m_pEditConfigFile</tabstop>
@ -1182,21 +1185,5 @@ Enabling this setting will disable the server config GUI.</string>
</hint>
</hints>
</connection>
<connection>
<sender>m_pCheckBoxHeartbeat</sender>
<signal>toggled(bool)</signal>
<receiver>m_pSpinBoxHeartbeat</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>32</x>
<y>91</y>
</hint>
<hint type="destinationlabel">
<x>44</x>
<y>91</y>
</hint>
</hints>
</connection>
</connections>
</ui>