diff options
| author | Mike Skec <skec@protonmail.ch> | 2021-02-18 17:44:17 +1100 |
|---|---|---|
| committer | Felix Queißner <felix@ib-queissner.de> | 2021-02-18 11:23:23 +0100 |
| commit | 6e127eb49d6a71e4d05cbb2e29fc164e718a903c (patch) | |
| tree | a11e635dd5ae465c1173fe85e992c8e618fe2e7c /src | |
| parent | fb230927ab64ebcb4f2fe75f33658127421738b9 (diff) | |
| download | kristall-6e127eb49d6a71e4d05cbb2e29fc164e718a903c.tar.gz | |
Add unlimited cache life option
Diffstat (limited to 'src')
| -rw-r--r-- | src/cachehandler.cpp | 4 | ||||
| -rw-r--r-- | src/dialogs/settingsdialog.cpp | 10 | ||||
| -rw-r--r-- | src/dialogs/settingsdialog.hpp | 1 | ||||
| -rw-r--r-- | src/dialogs/settingsdialog.ui | 37 | ||||
| -rw-r--r-- | src/kristall.hpp | 3 | ||||
| -rw-r--r-- | src/main.cpp | 2 |
6 files changed, 44 insertions, 13 deletions
diff --git a/src/cachehandler.cpp b/src/cachehandler.cpp index b2708df..d9c8836 100644 --- a/src/cachehandler.cpp +++ b/src/cachehandler.cpp @@ -77,10 +77,14 @@ int CacheHandler::size() // Clears expired pages out of cache void CacheHandler::clean() { + // Don't clean anything if we have unlimited item life. + if (kristall::options.cache_unlimited_life) return; + // Find list of keys to delete std::vector<QString> vec; for (auto&& i : this->page_cache) { + // Check if this cache item is expired. if (QDateTime::currentDateTime() > i.second->time_cached .addSecs(kristall::options.cache_life * 60)) { diff --git a/src/dialogs/settingsdialog.cpp b/src/dialogs/settingsdialog.cpp index 4cc0ed6..b943a56 100644 --- a/src/dialogs/settingsdialog.cpp +++ b/src/dialogs/settingsdialog.cpp @@ -121,7 +121,7 @@ void SettingsDialog::setGeminiStyle(DocumentStyle const &style) this->ui->enable_justify_text->setChecked(this->current_style.justify_text); this->ui->enable_text_width->setChecked(this->current_style.text_width_enabled); - + this->ui->text_width->setEnabled(this->current_style.text_width_enabled); this->ui->text_width->setValue(this->current_style.text_width); this->ui->line_height_p->setValue(this->current_style.line_height_p); @@ -301,6 +301,8 @@ void SettingsDialog::setOptions(const GenericSettings &options) this->ui->cache_limit->setValue(this->current_options.cache_limit); this->ui->cache_threshold->setValue(this->current_options.cache_threshold); this->ui->cache_life->setValue(this->current_options.cache_life); + this->ui->enable_unlimited_cache_life->setChecked(this->current_options.cache_unlimited_life); + this->ui->cache_life->setEnabled(!this->current_options.cache_unlimited_life); } GenericSettings SettingsDialog::options() const @@ -837,3 +839,9 @@ void SettingsDialog::on_cache_life_valueChanged(int life) { this->current_options.cache_life = life; } + +void SettingsDialog::on_enable_unlimited_cache_life_clicked(bool checked) +{ + this->current_options.cache_unlimited_life = checked; + this->ui->cache_life->setEnabled(!checked); +} diff --git a/src/dialogs/settingsdialog.hpp b/src/dialogs/settingsdialog.hpp index 226abed..80afcc6 100644 --- a/src/dialogs/settingsdialog.hpp +++ b/src/dialogs/settingsdialog.hpp @@ -157,6 +157,7 @@ private slots: void on_cache_limit_valueChanged(int limit); void on_cache_threshold_valueChanged(int thres); void on_cache_life_valueChanged(int life); + void on_enable_unlimited_cache_life_clicked(bool checked); private: void reloadStylePreview(); diff --git a/src/dialogs/settingsdialog.ui b/src/dialogs/settingsdialog.ui index b1890e3..c32489c 100644 --- a/src/dialogs/settingsdialog.ui +++ b/src/dialogs/settingsdialog.ui @@ -500,17 +500,31 @@ </widget> </item> <item row="19" column="1"> - <widget class="QSpinBox" name="cache_life"> - <property name="suffix"> - <string> minutes</string> - </property> - <property name="minimum"> - <number>0</number> - </property> - <property name="maximum"> - <number>8760</number> - </property> - </widget> + <layout class="QHBoxLayout" name="horizontalLayout_25"> + <item> + <widget class="QSpinBox" name="cache_life"> + <property name="suffix"> + <string> minutes</string> + </property> + <property name="minimum"> + <number>0</number> + </property> + <property name="maximum"> + <number>8760</number> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="enable_unlimited_cache_life"> + <property name="text"> + <string>Unlimited item life</string> + </property> + <property name="toolTip"> + <string>Sets cached items to be unexpirable. Items will only be removed if the cache is full.</string> + </property> + </widget> + </item> + </layout> </item> </layout> @@ -1425,6 +1439,7 @@ <tabstop>cache_limit</tabstop> <tabstop>cache_threshold</tabstop> <tabstop>cache_life</tabstop> + <tabstop>enable_unlimited_cache_life</tabstop> <tabstop>bg_change_color</tabstop> <tabstop>style_preview</tabstop> <tabstop>std_change_font</tabstop> diff --git a/src/kristall.hpp b/src/kristall.hpp index 26f3235..1717d71 100644 --- a/src/kristall.hpp +++ b/src/kristall.hpp @@ -86,7 +86,8 @@ struct GenericSettings // In-memory caching int cache_limit = 1000; int cache_threshold = 125; - int cache_life = 15; + int cache_life = 60; + bool cache_unlimited_life = true; void load(QSettings & settings); void save(QSettings & settings) const; diff --git a/src/main.cpp b/src/main.cpp index 6a3e110..6fb5280 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -384,6 +384,7 @@ void GenericSettings::load(QSettings &settings) cache_limit = settings.value("cache_limit", 1000).toInt(); cache_threshold = settings.value("cache_threshold", 125).toInt(); cache_life = settings.value("cache_life", 15).toInt(); + cache_unlimited_life = settings.value("cache_unlimited_life", true).toBool(); } void GenericSettings::save(QSettings &settings) const @@ -429,6 +430,7 @@ void GenericSettings::save(QSettings &settings) const settings.setValue("cache_limit", cache_limit); settings.setValue("cache_threshold", cache_threshold); settings.setValue("cache_life", cache_life); + settings.setValue("cache_unlimited_life", cache_unlimited_life); } |
