Fix bug: ui did not in initialize correctly when you start the pref page with area disabled, the other settings were not disabled as they are when you disable the area.

This commit is contained in:
Paddle
2023-07-30 16:03:40 +02:00
committed by Chris Hennes
parent f86107758b
commit 5cd6da6602
2 changed files with 21 additions and 11 deletions

View File

@@ -40,20 +40,12 @@ DlgSettingsNotificationArea::DlgSettingsNotificationArea(QWidget* parent)
{
ui->setupUi(this);
adaptUiToAreaEnabledState(ui->NotificationAreaEnabled->isChecked());
connect(ui->NotificationAreaEnabled, &QCheckBox::stateChanged, [this](int state) {
bool enabled = state == Qt::CheckState::Checked;
this->adaptUiToAreaEnabledState(enabled);
ui->NonIntrusiveNotificationsEnabled->setEnabled(enabled);
ui->maxDuration->setEnabled(enabled);
ui->maxDuration->setEnabled(enabled);
ui->minDuration->setEnabled(enabled);
ui->maxNotifications->setEnabled(enabled);
ui->maxWidgetMessages->setEnabled(enabled);
ui->autoRemoveUserNotifications->setEnabled(enabled);
ui->hideNonIntrusiveNotificationsWhenWindowDeactivated->setEnabled(enabled);
ui->preventNonIntrusiveNotificationsWhenWindowNotActive->setEnabled(enabled);
ui->developerErrorSubscriptionEnabled->setEnabled(enabled);
ui->developerWarningSubscriptionEnabled->setEnabled(enabled);
if (enabled) {
QMessageBox::information(this,
tr("Notification Area"),
@@ -100,6 +92,21 @@ void DlgSettingsNotificationArea::loadSettings()
ui->developerWarningSubscriptionEnabled->onRestore();
}
void DlgSettingsNotificationArea::adaptUiToAreaEnabledState(bool enabled)
{
ui->NonIntrusiveNotificationsEnabled->setEnabled(enabled);
ui->maxDuration->setEnabled(enabled);
ui->maxDuration->setEnabled(enabled);
ui->minDuration->setEnabled(enabled);
ui->maxNotifications->setEnabled(enabled);
ui->maxWidgetMessages->setEnabled(enabled);
ui->autoRemoveUserNotifications->setEnabled(enabled);
ui->hideNonIntrusiveNotificationsWhenWindowDeactivated->setEnabled(enabled);
ui->preventNonIntrusiveNotificationsWhenWindowNotActive->setEnabled(enabled);
ui->developerErrorSubscriptionEnabled->setEnabled(enabled);
ui->developerWarningSubscriptionEnabled->setEnabled(enabled);
}
void DlgSettingsNotificationArea::changeEvent(QEvent* e)
{
if (e->type() == QEvent::LanguageChange) {

View File

@@ -49,6 +49,9 @@ public:
protected:
void changeEvent(QEvent *e) override;
private:
void adaptUiToAreaEnabledState(bool enabled);
private:
std::unique_ptr<Ui_DlgSettingsNotificationArea> ui;
};