From 7f5402b70734953249ef8ec80414bc9d4d4cb5e3 Mon Sep 17 00:00:00 2001 From: jNullj Date: Sat, 11 Feb 2023 14:28:34 +0200 Subject: [PATCH 1/3] Fix DefaultHistoryMaxSize set in UI The default value in the Metadata is saved in Bytes while the UI shows the size in MB. Old code used the default in metadata as is, if database max size is unset the gui presents the default in bytes insted of MB which results in a huge number. This commit fixes this by adding the calculation to transform the value to MB. --- src/gui/dbsettings/DatabaseSettingsWidgetGeneral.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/dbsettings/DatabaseSettingsWidgetGeneral.cpp b/src/gui/dbsettings/DatabaseSettingsWidgetGeneral.cpp index ac883ac7a9..607ce4197c 100644 --- a/src/gui/dbsettings/DatabaseSettingsWidgetGeneral.cpp +++ b/src/gui/dbsettings/DatabaseSettingsWidgetGeneral.cpp @@ -57,7 +57,7 @@ void DatabaseSettingsWidgetGeneral::initialize() m_ui->historyMaxSizeSpinBox->setValue(historyMaxSizeMiB); m_ui->historyMaxSizeCheckBox->setChecked(true); } else { - m_ui->historyMaxSizeSpinBox->setValue(Metadata::DefaultHistoryMaxSize); + m_ui->historyMaxSizeSpinBox->setValue(qRound(Metadata::DefaultHistoryMaxSize / qreal(1048576))); m_ui->historyMaxSizeCheckBox->setChecked(false); } } From dbd68b2fb7e2785c75ab1c57cb59d15480ee7c4c Mon Sep 17 00:00:00 2001 From: jNullj Date: Sat, 11 Feb 2023 14:31:35 +0200 Subject: [PATCH 2/3] Fix DatabaseSettings UI SpinBoxs enable state SpinBoxes for items with disabled checkbox should not be enabled. If the user saves those settings as dissabled then reload the database the UI defaults to enable the SpinBox. This commit fixes this by setting enable to false if the setting checkbox is not checked. --- src/gui/dbsettings/DatabaseSettingsWidgetGeneral.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/dbsettings/DatabaseSettingsWidgetGeneral.cpp b/src/gui/dbsettings/DatabaseSettingsWidgetGeneral.cpp index 607ce4197c..dc270f92ed 100644 --- a/src/gui/dbsettings/DatabaseSettingsWidgetGeneral.cpp +++ b/src/gui/dbsettings/DatabaseSettingsWidgetGeneral.cpp @@ -50,6 +50,7 @@ void DatabaseSettingsWidgetGeneral::initialize() m_ui->historyMaxItemsCheckBox->setChecked(true); } else { m_ui->historyMaxItemsSpinBox->setValue(Metadata::DefaultHistoryMaxItems); + m_ui->historyMaxItemsSpinBox->setEnabled(false); m_ui->historyMaxItemsCheckBox->setChecked(false); } int historyMaxSizeMiB = qRound(meta->historyMaxSize() / qreal(1048576)); @@ -58,6 +59,7 @@ void DatabaseSettingsWidgetGeneral::initialize() m_ui->historyMaxSizeCheckBox->setChecked(true); } else { m_ui->historyMaxSizeSpinBox->setValue(qRound(Metadata::DefaultHistoryMaxSize / qreal(1048576))); + m_ui->historyMaxSizeSpinBox->setEnabled(false); m_ui->historyMaxSizeCheckBox->setChecked(false); } } From ec1dbf0444f12292bdb4e2ac13d4cba563001454 Mon Sep 17 00:00:00 2001 From: jNullj Date: Sun, 12 Feb 2023 22:11:22 +0200 Subject: [PATCH 3/3] Improve readability Values in DatabaseSettingsWidgetGeneral to convert from bytes to MB are written a more reabable way. --- src/gui/dbsettings/DatabaseSettingsWidgetGeneral.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/dbsettings/DatabaseSettingsWidgetGeneral.cpp b/src/gui/dbsettings/DatabaseSettingsWidgetGeneral.cpp index dc270f92ed..a146ebd7e1 100644 --- a/src/gui/dbsettings/DatabaseSettingsWidgetGeneral.cpp +++ b/src/gui/dbsettings/DatabaseSettingsWidgetGeneral.cpp @@ -53,12 +53,12 @@ void DatabaseSettingsWidgetGeneral::initialize() m_ui->historyMaxItemsSpinBox->setEnabled(false); m_ui->historyMaxItemsCheckBox->setChecked(false); } - int historyMaxSizeMiB = qRound(meta->historyMaxSize() / qreal(1048576)); + int historyMaxSizeMiB = qRound(meta->historyMaxSize() / qreal(1024 * 1024)); if (historyMaxSizeMiB > 0) { m_ui->historyMaxSizeSpinBox->setValue(historyMaxSizeMiB); m_ui->historyMaxSizeCheckBox->setChecked(true); } else { - m_ui->historyMaxSizeSpinBox->setValue(qRound(Metadata::DefaultHistoryMaxSize / qreal(1048576))); + m_ui->historyMaxSizeSpinBox->setValue(qRound(Metadata::DefaultHistoryMaxSize / qreal(1024 * 1024))); m_ui->historyMaxSizeSpinBox->setEnabled(false); m_ui->historyMaxSizeCheckBox->setChecked(false); }