diff --git a/src/lib/gui/dialogs/ClientConfigDialog.cpp b/src/lib/gui/dialogs/ClientConfigDialog.cpp index 12503fb5f..9508df3dc 100644 --- a/src/lib/gui/dialogs/ClientConfigDialog.cpp +++ b/src/lib/gui/dialogs/ClientConfigDialog.cpp @@ -8,15 +8,20 @@ #include "ui_ClientConfigDialog.h" #include "common/Settings.h" +#include "gui/widgets/SettingsDialogButtonBox.h" #include -ClientConfigDialog::ClientConfigDialog(QWidget *parent) : QDialog(parent), ui(new Ui::ClientConfigDialog) +ClientConfigDialog::ClientConfigDialog(QWidget *parent) + : QDialog(parent), + ui(new Ui::ClientConfigDialog), + m_buttonBox{new SettingsDialogButtonBox(this)} { ui->setupUi(this); - updateText(); + layout()->addWidget(m_buttonBox); initConnections(); load(); + updateControls(); setButtonBoxEnabledButtons(); } @@ -28,29 +33,27 @@ ClientConfigDialog::~ClientConfigDialog() void ClientConfigDialog::changeEvent(QEvent *e) { QDialog::changeEvent(e); - if (e->type() == QEvent::LanguageChange) { + if (e->type() == QEvent::LanguageChange) ui->retranslateUi(this); - updateText(); - } } -void ClientConfigDialog::updateText() const +void ClientConfigDialog::updateControls() const { - ui->buttonBox->button(QDialogButtonBox::Save)->setToolTip(tr("Close and save changes")); - ui->buttonBox->button(QDialogButtonBox::Cancel)->setToolTip(tr("Close and forget changes")); - ui->buttonBox->button(QDialogButtonBox::Reset)->setToolTip(tr("Reset to stored values")); - ui->buttonBox->button(QDialogButtonBox::RestoreDefaults)->setToolTip(tr("Reset to default values")); + const auto writable = Settings::isWritable(); + ui->cbDynamicConnectTime->setEnabled(writable); + ui->cbLanguageSync->setEnabled(writable); + ui->cbXScrollInvert->setEnabled(writable); + ui->sbXScrollScale->setEnabled(writable); + ui->cbYScrollInvert->setEnabled(writable); + ui->sbYScrollScale->setEnabled(writable); } void ClientConfigDialog::initConnections() const { - connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &ClientConfigDialog::save); - connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); - connect(ui->buttonBox->button(QDialogButtonBox::Reset), &QPushButton::clicked, this, &ClientConfigDialog::load); - connect( - ui->buttonBox->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, this, - &ClientConfigDialog::resetToDefault - ); + connect(m_buttonBox, &SettingsDialogButtonBox::accepted, this, &ClientConfigDialog::save); + connect(m_buttonBox, &SettingsDialogButtonBox::rejected, this, &QDialog::reject); + connect(m_buttonBox, &SettingsDialogButtonBox::reset, this, &ClientConfigDialog::load); + connect(m_buttonBox, &SettingsDialogButtonBox::restoreDefault, this, &ClientConfigDialog::resetToDefault); connect( ui->cbDynamicConnectTime, &QCheckBox::checkStateChanged, this, &ClientConfigDialog::setButtonBoxEnabledButtons @@ -60,6 +63,7 @@ void ClientConfigDialog::initConnections() const connect(ui->sbYScrollScale, &QDoubleSpinBox::valueChanged, this, &ClientConfigDialog::setButtonBoxEnabledButtons); connect(ui->cbXScrollInvert, &QCheckBox::checkStateChanged, this, &ClientConfigDialog::setButtonBoxEnabledButtons); connect(ui->sbXScrollScale, &QDoubleSpinBox::valueChanged, this, &ClientConfigDialog::setButtonBoxEnabledButtons); + connect(Settings::instance(), &Settings::settingsWritableChanged, this, &ClientConfigDialog::updateControls); } bool ClientConfigDialog::isModified() const @@ -87,9 +91,9 @@ bool ClientConfigDialog::isDefault() const void ClientConfigDialog::setButtonBoxEnabledButtons() const { const bool modified = isModified(); - ui->buttonBox->button(QDialogButtonBox::Save)->setEnabled(modified); - ui->buttonBox->button(QDialogButtonBox::Reset)->setEnabled(modified); - ui->buttonBox->button(QDialogButtonBox::RestoreDefaults)->setEnabled(!isDefault()); + m_buttonBox->enableSave(modified); + m_buttonBox->enableReset(modified); + m_buttonBox->enableRestoreDefaults(!isDefault()); } void ClientConfigDialog::load() diff --git a/src/lib/gui/dialogs/ClientConfigDialog.h b/src/lib/gui/dialogs/ClientConfigDialog.h index 2554e3ef9..3aaae84be 100644 --- a/src/lib/gui/dialogs/ClientConfigDialog.h +++ b/src/lib/gui/dialogs/ClientConfigDialog.h @@ -8,6 +8,8 @@ #include +class SettingsDialogButtonBox; + namespace Ui { class ClientConfigDialog; } @@ -29,9 +31,9 @@ protected: private: /** - * @brief updateText update widget text + * @brief updateControls update widget enable state */ - void updateText() const; + void updateControls() const; /** * @brief initConnections @@ -73,4 +75,5 @@ private: void save(); Ui::ClientConfigDialog *ui = nullptr; + SettingsDialogButtonBox *m_buttonBox = nullptr; }; diff --git a/src/lib/gui/dialogs/ClientConfigDialog.ui b/src/lib/gui/dialogs/ClientConfigDialog.ui index f258ada8c..012cb9d51 100644 --- a/src/lib/gui/dialogs/ClientConfigDialog.ui +++ b/src/lib/gui/dialogs/ClientConfigDialog.ui @@ -6,8 +6,8 @@ 0 0 - 391 - 176 + 482 + 197 @@ -164,16 +164,6 @@ - - - - Qt::Orientation::Horizontal - - - QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Reset|QDialogButtonBox::StandardButton::RestoreDefaults|QDialogButtonBox::StandardButton::Save - - - diff --git a/translations/deskflow_es.ts b/translations/deskflow_es.ts index 093c87e22..80062681a 100644 --- a/translations/deskflow_es.ts +++ b/translations/deskflow_es.ts @@ -165,22 +165,6 @@ p, li { white-space: pre-wrap; } Scale Escala - - Close and save changes - Cerrar y guardar los cambios - - - Close and forget changes - Cerrar y olvidar los cambios - - - Reset to stored values - Restablecer los valores almacenados - - - Reset to default values - Restablecer valores predeterminados - <html><head/><body><p>Allow the client to slow the rate it attempts to reconnect to the server when connections attempts are failing. The delay between connection attempts will start at 1 second intervals and can be a maxium of 5 minutes between connection attempts.</p></body></html> <html><head/><body><p>Permite que el cliente reduzca la frecuencia con la que intenta reconectarse al servidor cuando los intentos de conexión fallan. El intervalo entre intentos de conexión comenzará en 1 segundo y podrá alcanzar un máximo de 5 minutos.</p></body></html> diff --git a/translations/deskflow_it.ts b/translations/deskflow_it.ts index 509784fe4..511386939 100644 --- a/translations/deskflow_it.ts +++ b/translations/deskflow_it.ts @@ -165,22 +165,6 @@ p, li { white-space: pre-wrap; } Scale Scala - - Close and save changes - Chiudi e salva le modifiche - - - Close and forget changes - Chiudi e dimentica le modifiche - - - Reset to stored values - Ripristina i valori memorizzati - - - Reset to default values - Ripristina i valori predefiniti - <html><head/><body><p>Allow the client to slow the rate it attempts to reconnect to the server when connections attempts are failing. The delay between connection attempts will start at 1 second intervals and can be a maxium of 5 minutes between connection attempts.</p></body></html> <html><head/><body><p>Consente al client di rallentare la frequenza dei tentativi di riconnessione al server quando i tentativi di connessione falliscono. Il ritardo tra i tentativi di connessione inizierà a intervalli di 1 secondo, fino a raggiungere un massimo di 5 minuti tra un tentativo e l'altro.</p></body></html> diff --git a/translations/deskflow_ja.ts b/translations/deskflow_ja.ts index c11e8b9b7..b6e2a7f1a 100644 --- a/translations/deskflow_ja.ts +++ b/translations/deskflow_ja.ts @@ -165,22 +165,6 @@ p, li { white-space: pre-wrap; } Scale 倍率 - - Close and save changes - 変更を保存して閉じる - - - Close and forget changes - 変更を破棄して閉じる - - - Reset to stored values - 変更前の値にリセットする - - - Reset to default values - デフォルト値にリセットする - <html><head/><body><p>Allow the client to slow the rate it attempts to reconnect to the server when connections attempts are failing. The delay between connection attempts will start at 1 second intervals and can be a maxium of 5 minutes between connection attempts.</p></body></html> <html><head/><body><p>接続試行が失敗し続けている場合に、クライアントがサーバーへ再接続を試みる頻度を徐々に下げます。接続試行の間隔は当初1秒から開始され、最大で5分まで延長されます。</p></body></html> diff --git a/translations/deskflow_ko.ts b/translations/deskflow_ko.ts index c46dad56a..66d272a2a 100644 --- a/translations/deskflow_ko.ts +++ b/translations/deskflow_ko.ts @@ -165,22 +165,6 @@ p, li { white-space: pre-wrap; } Scale 규모 - - Close and save changes - 변경 사항 저장 후 닫기 - - - Close and forget changes - 저장하지 않고 닫기 - - - Reset to stored values - 저장된 값으로 재설정 - - - Reset to default values - 기본값으로 재설정 - <html><head/><body><p>Allow the client to slow the rate it attempts to reconnect to the server when connections attempts are failing. The delay between connection attempts will start at 1 second intervals and can be a maxium of 5 minutes between connection attempts.</p></body></html> <html><head/><body><p>연결 시도가 실패할 경우, 클라이언트가 서버 재연결 시도 주기를 늦추도록 허용합니다. 연결 시도 간 지연 시간은 1초 간격으로 시작되며, 최대 5분까지 늘어날 수 있습니다.</p></body></html> diff --git a/translations/deskflow_ru.ts b/translations/deskflow_ru.ts index e39cf17ad..e38502f73 100644 --- a/translations/deskflow_ru.ts +++ b/translations/deskflow_ru.ts @@ -165,22 +165,6 @@ p, li { white-space: pre-wrap; } Scale Шкала - - Close and save changes - Закрыть и сохранить изменения - - - Close and forget changes - Закройте изменения и забудьте о них - - - Reset to stored values - Сбросить до сохраненных значений - - - Reset to default values - Сбросить до значений по умолчанию - <html><head/><body><p>Allow the client to slow the rate it attempts to reconnect to the server when connections attempts are failing. The delay between connection attempts will start at 1 second intervals and can be a maxium of 5 minutes between connection attempts.</p></body></html> <html><head/><body><p>Позволить клиенту замедлять частоту попыток повторного подключения к серверу в случае неудачных попыток соединения. Интервал между попытками подключения будет начинаться с 1 секунды и может достигать максимума в 5 минут.</p></body></html> diff --git a/translations/deskflow_zh_CN.ts b/translations/deskflow_zh_CN.ts index fb9a4387d..36da7d56a 100644 --- a/translations/deskflow_zh_CN.ts +++ b/translations/deskflow_zh_CN.ts @@ -165,22 +165,6 @@ p, li { white-space: pre-wrap; } Scale 规模 - - Close and save changes - 关闭并保存更改 - - - Close and forget changes - 关闭并放弃修改 - - - Reset to stored values - 重置为存储值 - - - Reset to default values - 重置为默认值 - <html><head/><body><p>Allow the client to slow the rate it attempts to reconnect to the server when connections attempts are failing. The delay between connection attempts will start at 1 second intervals and can be a maxium of 5 minutes between connection attempts.</p></body></html> <html><head/><body><p>允许客户端在连接尝试失败时,降低其重连服务器的频率。连接尝试之间的间隔将从 1 秒开始,最长可达 5 分钟。</p></body></html>