feat(Client Config Dialog): use SettingsDialogButtonBox and make aware of read only settings
This commit is contained in:
parent
584a74af61
commit
e1950ab347
9 changed files with 31 additions and 130 deletions
|
|
@ -8,15 +8,20 @@
|
|||
#include "ui_ClientConfigDialog.h"
|
||||
|
||||
#include "common/Settings.h"
|
||||
#include "gui/widgets/SettingsDialogButtonBox.h"
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
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()
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
#include <QDialog>
|
||||
|
||||
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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>391</width>
|
||||
<height>176</height>
|
||||
<width>482</width>
|
||||
<height>197</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
|
@ -164,16 +164,6 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Reset|QDialogButtonBox::StandardButton::RestoreDefaults|QDialogButtonBox::StandardButton::Save</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
|
|||
|
|
@ -165,22 +165,6 @@ p, li { white-space: pre-wrap; }
|
|||
<source>Scale</source>
|
||||
<translation type="unfinished">Escala</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Close and save changes</source>
|
||||
<translation type="unfinished">Cerrar y guardar los cambios</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Close and forget changes</source>
|
||||
<translation type="unfinished">Cerrar y olvidar los cambios</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reset to stored values</source>
|
||||
<translation type="unfinished">Restablecer los valores almacenados</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reset to default values</source>
|
||||
<translation type="unfinished">Restablecer valores predeterminados</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source><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></source>
|
||||
<translation type="unfinished"><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></translation>
|
||||
|
|
|
|||
|
|
@ -165,22 +165,6 @@ p, li { white-space: pre-wrap; }
|
|||
<source>Scale</source>
|
||||
<translation type="unfinished">Scala</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Close and save changes</source>
|
||||
<translation type="unfinished">Chiudi e salva le modifiche</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Close and forget changes</source>
|
||||
<translation type="unfinished">Chiudi e dimentica le modifiche</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reset to stored values</source>
|
||||
<translation type="unfinished">Ripristina i valori memorizzati</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reset to default values</source>
|
||||
<translation type="unfinished">Ripristina i valori predefiniti</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source><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></source>
|
||||
<translation type="unfinished"><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></translation>
|
||||
|
|
|
|||
|
|
@ -165,22 +165,6 @@ p, li { white-space: pre-wrap; }
|
|||
<source>Scale</source>
|
||||
<translation>倍率</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Close and save changes</source>
|
||||
<translation>変更を保存して閉じる</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Close and forget changes</source>
|
||||
<translation>変更を破棄して閉じる</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reset to stored values</source>
|
||||
<translation>変更前の値にリセットする</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reset to default values</source>
|
||||
<translation>デフォルト値にリセットする</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source><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></source>
|
||||
<translation><html><head/><body><p>接続試行が失敗し続けている場合に、クライアントがサーバーへ再接続を試みる頻度を徐々に下げます。接続試行の間隔は当初1秒から開始され、最大で5分まで延長されます。</p></body></html></translation>
|
||||
|
|
|
|||
|
|
@ -165,22 +165,6 @@ p, li { white-space: pre-wrap; }
|
|||
<source>Scale</source>
|
||||
<translation type="unfinished">규모</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Close and save changes</source>
|
||||
<translation>변경 사항 저장 후 닫기</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Close and forget changes</source>
|
||||
<translation>저장하지 않고 닫기</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reset to stored values</source>
|
||||
<translation type="unfinished">저장된 값으로 재설정</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reset to default values</source>
|
||||
<translation type="unfinished">기본값으로 재설정</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source><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></source>
|
||||
<translation type="unfinished"><html><head/><body><p>연결 시도가 실패할 경우, 클라이언트가 서버 재연결 시도 주기를 늦추도록 허용합니다. 연결 시도 간 지연 시간은 1초 간격으로 시작되며, 최대 5분까지 늘어날 수 있습니다.</p></body></html></translation>
|
||||
|
|
|
|||
|
|
@ -165,22 +165,6 @@ p, li { white-space: pre-wrap; }
|
|||
<source>Scale</source>
|
||||
<translation type="unfinished">Шкала</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Close and save changes</source>
|
||||
<translation type="unfinished">Закрыть и сохранить изменения</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Close and forget changes</source>
|
||||
<translation type="unfinished">Закройте изменения и забудьте о них</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reset to stored values</source>
|
||||
<translation type="unfinished">Сбросить до сохраненных значений</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reset to default values</source>
|
||||
<translation type="unfinished">Сбросить до значений по умолчанию</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source><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></source>
|
||||
<translation type="unfinished"><html><head/><body><p>Позволить клиенту замедлять частоту попыток повторного подключения к серверу в случае неудачных попыток соединения. Интервал между попытками подключения будет начинаться с 1 секунды и может достигать максимума в 5 минут.</p></body></html></translation>
|
||||
|
|
|
|||
|
|
@ -165,22 +165,6 @@ p, li { white-space: pre-wrap; }
|
|||
<source>Scale</source>
|
||||
<translation type="unfinished">规模</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Close and save changes</source>
|
||||
<translation type="unfinished">关闭并保存更改</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Close and forget changes</source>
|
||||
<translation>关闭并放弃修改</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reset to stored values</source>
|
||||
<translation type="unfinished">重置为存储值</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Reset to default values</source>
|
||||
<translation type="unfinished">重置为默认值</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source><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></source>
|
||||
<translation type="unfinished"><html><head/><body><p>允许客户端在连接尝试失败时,降低其重连服务器的频率。连接尝试之间的间隔将从 1 秒开始,最长可达 5 分钟。</p></body></html></translation>
|
||||
|
|
|
|||
Loading…
Reference in a new issue