1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 
8 #include <QFileDialog>
9 #include <QString>
10 
11 #include "prefs_imagecache.h"
12 #include "prefsstructs.h"
13 #include "scribusdoc.h"
14 
Prefs_ImageCache(QWidget * parent,ScribusDoc * doc)15 Prefs_ImageCache::Prefs_ImageCache(QWidget* parent, ScribusDoc* doc)
16 	: Prefs_Pane(parent)
17 {
18 	setupUi(this);
19 	languageChange();
20 
21 	m_caption = tr("Image Cache");
22 	m_icon = "16/image-x-generic.png";
23 }
24 
25 Prefs_ImageCache::~Prefs_ImageCache() = default;
26 
languageChange()27 void Prefs_ImageCache::languageChange()
28 {
29 	enableImageCacheCheckBox->setToolTip( "<qt>" + tr( "Enabling the image cache will significantly speed up the loading of images. Enable the cache if you are often working on large documents with lots of images and if you have plenty of disk space in your application data directory." ) + "</qt>" );
30 	cacheSizeLimitSpinBox->setToolTip( "<qt>"+ tr("Limit the total size of all files in the image cache directory to this amount")+"</qt>" );
31 	cacheEntryLimitSpinBox->setToolTip( "<qt>" + tr( "Limit the number of cache entries to this number" ) + "</qt>" );
32 	compressionLevelSpinBox->setToolTip( "<qt>" + tr( "Set the level of compression for images in the cache. Higher values result in smaller cache files but also make writes to the cache slower." ) + "</qt>" );
33 }
34 
restoreDefaults(struct ApplicationPrefs * prefsData)35 void Prefs_ImageCache::restoreDefaults(struct ApplicationPrefs *prefsData)
36 {
37 	enableImageCacheCheckBox->setChecked(prefsData->imageCachePrefs.cacheEnabled);
38 	cacheSizeLimitSpinBox->setValue(prefsData->imageCachePrefs.maxCacheSizeMiB);
39 	cacheEntryLimitSpinBox->setValue(prefsData->imageCachePrefs.maxCacheEntries);
40 	compressionLevelSpinBox->setValue(prefsData->imageCachePrefs.compressionLevel);
41 }
42 
saveGuiToPrefs(struct ApplicationPrefs * prefsData) const43 void Prefs_ImageCache::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const
44 {
45 	prefsData->imageCachePrefs.cacheEnabled = enableImageCacheCheckBox->isChecked();
46 	prefsData->imageCachePrefs.maxCacheSizeMiB = cacheSizeLimitSpinBox->value();
47 	prefsData->imageCachePrefs.maxCacheEntries = cacheEntryLimitSpinBox->value();
48 	prefsData->imageCachePrefs.compressionLevel = compressionLevelSpinBox->value();
49 }
50 
51