Minor fixes to collection pixmap cache
- Add variables for cache size defaults - Increase default disk cache size - Change the pixmap cache settings UI to look better - Add current pixmap disk cache used to settings
This commit is contained in:
@@ -41,6 +41,8 @@
|
||||
|
||||
#include "core/application.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/utilities.h"
|
||||
#include "collection/collectionmodel.h"
|
||||
#include "collection/collectiondirectorymodel.h"
|
||||
#include "collectionsettingspage.h"
|
||||
#include "playlist/playlistdelegates.h"
|
||||
@@ -54,6 +56,8 @@ const char *CollectionSettingsPage::kSettingsCacheSizeUnit = "cache_size_unit";
|
||||
const char *CollectionSettingsPage::kSettingsDiskCacheEnable = "disk_cache_enable";
|
||||
const char *CollectionSettingsPage::kSettingsDiskCacheSize = "disk_cache_size";
|
||||
const char *CollectionSettingsPage::kSettingsDiskCacheSizeUnit = "disk_cache_size_unit";
|
||||
const int CollectionSettingsPage::kSettingsCacheSizeDefault = 160;
|
||||
const int CollectionSettingsPage::kSettingsDiskCacheSizeDefault = 360;
|
||||
|
||||
const QStringList CollectionSettingsPage::cacheUnitNames = { "KB", "MB", "GB", "TB" };
|
||||
|
||||
@@ -70,6 +74,9 @@ CollectionSettingsPage::CollectionSettingsPage(SettingsDialog *dialog)
|
||||
setWindowIcon(IconLoader::Load("library-music"));
|
||||
ui_->add->setIcon(IconLoader::Load("document-open-folder"));
|
||||
|
||||
ui_->combobox_cache_size->addItems(cacheUnitNames);
|
||||
ui_->combobox_disk_cache_size->addItems(cacheUnitNames);
|
||||
|
||||
connect(ui_->add, SIGNAL(clicked()), SLOT(Add()));
|
||||
connect(ui_->remove, SIGNAL(clicked()), SLOT(Remove()));
|
||||
|
||||
@@ -77,6 +84,10 @@ CollectionSettingsPage::CollectionSettingsPage(SettingsDialog *dialog)
|
||||
connect(ui_->radiobutton_cover_hash, SIGNAL(toggled(bool)), SLOT(CoverSaveInAlbumDirChanged()));
|
||||
connect(ui_->radiobutton_cover_pattern, SIGNAL(toggled(bool)), SLOT(CoverSaveInAlbumDirChanged()));
|
||||
|
||||
connect(ui_->checkbox_disk_cache, SIGNAL(stateChanged(int)), SLOT(DiskCacheEnable(int)));
|
||||
connect(ui_->button_clear_disk_cache, SIGNAL(clicked()), dialog->app(), SIGNAL(ClearPixmapDiskCache()));
|
||||
connect(ui_->button_clear_disk_cache, SIGNAL(clicked()), SLOT(ClearPixmapDiskCache()));
|
||||
|
||||
}
|
||||
|
||||
CollectionSettingsPage::~CollectionSettingsPage() { delete ui_; }
|
||||
@@ -104,12 +115,16 @@ void CollectionSettingsPage::CurrentRowChanged(const QModelIndex& index) {
|
||||
ui_->remove->setEnabled(index.isValid());
|
||||
}
|
||||
|
||||
void CollectionSettingsPage::DiskCacheEnable(int state) {
|
||||
void CollectionSettingsPage::DiskCacheEnable(const int state) {
|
||||
|
||||
bool checked = state == Qt::Checked;
|
||||
ui_->button_disk_cache->setEnabled(checked);
|
||||
ui_->label_disk_cache_size->setEnabled(checked);
|
||||
ui_->spinbox_disk_cache_size->setEnabled(checked);
|
||||
ui_->combobox_disk_cache_size->setEnabled(checked);
|
||||
ui_->label_disk_cache_in_use->setEnabled(checked);
|
||||
ui_->disk_cache_in_use->setEnabled(checked);
|
||||
ui_->button_clear_disk_cache->setEnabled(checked);
|
||||
|
||||
}
|
||||
|
||||
void CollectionSettingsPage::Load() {
|
||||
@@ -151,22 +166,18 @@ void CollectionSettingsPage::Load() {
|
||||
ui_->checkbox_cover_lowercase->setChecked(s.value("cover_lowercase", true).toBool());
|
||||
ui_->checkbox_cover_replace_spaces->setChecked(s.value("cover_replace_spaces", true).toBool());
|
||||
|
||||
ui_->spinbox_cache_size->setValue(s.value(kSettingsCacheSize, 80).toInt());
|
||||
ui_->combobox_cache_size->addItems(cacheUnitNames);
|
||||
ui_->spinbox_cache_size->setValue(s.value(kSettingsCacheSize, kSettingsCacheSizeDefault).toInt());
|
||||
ui_->combobox_cache_size->setCurrentIndex(s.value(kSettingsCacheSizeUnit, (int) CacheSizeUnit_MB).toInt());
|
||||
ui_->checkbox_disk_cache->setChecked(s.value(kSettingsDiskCacheEnable, false).toBool());
|
||||
ui_->label_disk_cache_size->setEnabled(ui_->checkbox_disk_cache->isChecked());
|
||||
ui_->spinbox_disk_cache_size->setEnabled(ui_->checkbox_disk_cache->isChecked());
|
||||
ui_->spinbox_disk_cache_size->setValue(s.value(kSettingsDiskCacheSize, 80).toInt());
|
||||
ui_->combobox_disk_cache_size->setEnabled(ui_->checkbox_disk_cache->isChecked());
|
||||
ui_->combobox_disk_cache_size->addItems(cacheUnitNames);
|
||||
ui_->spinbox_disk_cache_size->setValue(s.value(kSettingsDiskCacheSize, kSettingsDiskCacheSizeDefault).toInt());
|
||||
ui_->combobox_disk_cache_size->setCurrentIndex(s.value(kSettingsDiskCacheSizeUnit, (int) CacheSizeUnit_MB).toInt());
|
||||
|
||||
connect(ui_->checkbox_disk_cache, SIGNAL(stateChanged(int)), SLOT(DiskCacheEnable(int)));
|
||||
connect(ui_->button_disk_cache, SIGNAL(clicked()), dialog()->app(), SIGNAL(ClearPixmapDiskCache()));
|
||||
|
||||
s.endGroup();
|
||||
|
||||
DiskCacheEnable(ui_->checkbox_disk_cache->checkState());
|
||||
|
||||
ui_->disk_cache_in_use->setText((dialog()->app()->collection_model()->icon_cache_disk_size() == 0 ? "empty" : Utilities::PrettySize(dialog()->app()->collection_model()->icon_cache_disk_size())));
|
||||
|
||||
}
|
||||
|
||||
void CollectionSettingsPage::Save() {
|
||||
@@ -232,3 +243,9 @@ void CollectionSettingsPage::CoverSaveInAlbumDirChanged() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CollectionSettingsPage::ClearPixmapDiskCache() {
|
||||
|
||||
ui_->disk_cache_in_use->setText("empty");
|
||||
|
||||
}
|
||||
|
||||
@@ -47,6 +47,8 @@ class CollectionSettingsPage : public SettingsPage {
|
||||
static const char *kSettingsDiskCacheEnable;
|
||||
static const char *kSettingsDiskCacheSize;
|
||||
static const char *kSettingsDiskCacheSizeUnit;
|
||||
static const int kSettingsCacheSizeDefault;
|
||||
static const int kSettingsDiskCacheSizeDefault;
|
||||
|
||||
enum CacheSizeUnit {
|
||||
CacheSizeUnit_KB,
|
||||
@@ -68,8 +70,9 @@ class CollectionSettingsPage : public SettingsPage {
|
||||
void Remove();
|
||||
|
||||
void CurrentRowChanged(const QModelIndex &index);
|
||||
void DiskCacheEnable(int state);
|
||||
void DiskCacheEnable(const int state);
|
||||
void CoverSaveInAlbumDirChanged();
|
||||
void ClearPixmapDiskCache();
|
||||
|
||||
private:
|
||||
Ui_CollectionSettingsPage *ui_;
|
||||
|
||||
@@ -160,6 +160,9 @@ If there are no matches then it will use the largest image in the directory.</st
|
||||
<string>Saving album covers</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="layout_albumcovers">
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkbox_cover_album_dir">
|
||||
<property name="text">
|
||||
@@ -249,98 +252,176 @@ If there are no matches then it will use the largest image in the directory.</st
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupbox_albumcovercache">
|
||||
<property name="title">
|
||||
<string>Album cover pixmap cache</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="albumArtGroupBox">
|
||||
<property name="title">
|
||||
<string>Album art cache</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_cache_size">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinbox_cache_size">
|
||||
<property name="maximum">
|
||||
<number>1048576</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="combobox_cache_size">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkbox_disk_cache">
|
||||
<property name="text">
|
||||
<string>Enable Disk Cache</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="button_disk_cache">
|
||||
<property name="text">
|
||||
<string>Clear Disk Cache</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_disk_cache_size">
|
||||
<property name="text">
|
||||
<string>Disk Cache Size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinbox_disk_cache_size">
|
||||
<property name="maximum">
|
||||
<number>1048576</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="combobox_disk_cache_size">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layout class="QGridLayout" name="layout_cache_size">
|
||||
<item row="0" column="2">
|
||||
<widget class="QSpinBox" name="spinbox_cache_size">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1048576</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_cache_size">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QComboBox" name="combobox_cache_size">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<spacer name="spacer_cache_size">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_disk_cache">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkbox_disk_cache">
|
||||
<property name="text">
|
||||
<string>Enable Disk Cache</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_disk_cache">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="layout_disk_cache_size">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_disk_cache_size">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Disk Cache Size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QComboBox" name="combobox_disk_cache_size">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="spinbox_disk_cache_size">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1048576</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<spacer name="spacer_disk_cache_size">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_disk_cache_in_use">
|
||||
<property name="text">
|
||||
<string>Current disk cache in use:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="disk_cache_in_use">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="button_clear_disk_cache">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clear Disk Cache</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_disk_cache_in_use">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@@ -369,9 +450,9 @@ If there are no matches then it will use the largest image in the directory.</st
|
||||
<tabstop>spinbox_cache_size</tabstop>
|
||||
<tabstop>combobox_cache_size</tabstop>
|
||||
<tabstop>checkbox_disk_cache</tabstop>
|
||||
<tabstop>button_disk_cache</tabstop>
|
||||
<tabstop>spinbox_disk_cache_size</tabstop>
|
||||
<tabstop>combobox_disk_cache_size</tabstop>
|
||||
<tabstop>button_clear_disk_cache</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
Reference in New Issue
Block a user