Krita Source Code Documentation
Loading...
Searching...
No Matches
KisImageConfig Class Reference

#include <kis_image_config.h>

Public Member Functions

QString animationCacheDir (bool defaultValue=false) const
 
int animationCacheFrameSizeLimit (bool defaultValue=false) const
 
qreal animationCacheRegionOfInterestMargin (bool defaultValue=false) const
 
bool autoKeyEnabled (bool requestDefault=false) const
 
bool autoKeyModeDuplicate (bool requestDefault=false) const
 
int defaultFrameColorLabel () const
 
KisProofingConfigurationSP defaultProofingconfiguration (bool requestDefault=false)
 
bool detectFpsLimit (bool defaultValue=false) const
 
bool enablePerfLog (bool requestDefault=false) const
 
bool enableProgressReporting (bool requestDefault=false) const
 
KisPropertiesConfigurationSP exportConfiguration (const QString &exportConfigId, bool defaultValue=false) const
 
QString exportConfigurationXML (const QString &exportConfigId, bool defaultValue=false) const
 
int fpsLimit (bool defaultValue=false) const
 
int frameRenderingClones (bool defaultValue=false) const
 
int frameRenderingTimeout (bool defaultValue=false) const
 
bool hasExportConfiguration (const QString &exportConfigID)
 
 KisImageConfig (bool readOnly)
 
int maxBrushSize (bool defaultValue=false) const
 
qreal maxCollectAlpha () const
 
int maxMaskingBrushSize () const
 
qreal maxMergeAlpha () const
 
qreal maxMergeCollectAlpha () const
 
int maxNumberOfThreads (bool defaultValue=false) const
 
int maxSwapSize (bool requestDefault=false) const
 
qreal memoryHardLimitPercent (bool requestDefault=false) const
 
qreal memoryPoolLimitPercent (bool requestDefault=false) const
 
qreal memorySoftLimitPercent (bool requestDefault=false) const
 
int numberOfOnionSkins () const
 
int onionSkinOpacity (int offset, bool requestDefault=false) const
 
bool onionSkinState (int offset) const
 
QColor onionSkinTintColorBackward () const
 
QColor onionSkinTintColorForward () const
 
int onionSkinTintFactor () const
 
int poolLimit () const
 
template<class T >
readEntry (const QString &name, const T &defaultValue=T())
 
template<class T >
QList< T > readList (const QString &name, const QList< T > &defaultValue=QList< T >())
 
bool renameDuplicatedLayers (bool defaultValue=false) const
 
bool renameMergedLayers (bool defaultValue=false) const
 
qreal schedulerBalancingRatio () const
 
qreal selectionOutlineOpacity (bool defaultValue=false) const
 
QColor selectionOverlayMaskColor (bool defaultValue=false) const
 
void setAnimationCacheDir (const QString &value)
 
void setAnimationCacheFrameSizeLimit (int value)
 
void setAnimationCacheRegionOfInterestMargin (qreal value)
 
void setAutoKeyEnabled (bool value)
 
void setAutoKeyModeDuplicate (bool value)
 
void setDefaultFrameColorLabel (int label)
 
void setDefaultProofingConfig (const KisProofingConfiguration &config)
 
void setDetectFpsLimit (bool value)
 
void setEnablePerfLog (bool value)
 
void setEnableProgressReporting (bool value)
 
void setExportConfiguration (const QString &exportConfigId, KisPropertiesConfigurationSP properties)
 
void setFpsLimit (int value)
 
void setFrameRenderingClones (int value)
 
void setFrameRenderingTimeout (int value)
 
void setMaxBrushSize (int value)
 
void setMaxNumberOfThreads (int value)
 
void setMaxSwapSize (int value)
 
void setMemoryHardLimitPercent (qreal value)
 
void setMemoryPoolLimitPercent (qreal value)
 
void setMemorySoftLimitPercent (qreal value)
 
void setNumberOfOnionSkins (int value)
 
void setOnionSkinOpacity (int offset, int value)
 
void setOnionSkinState (int offset, bool value)
 
void setOnionSkinTintColorBackward (const QColor &value)
 
void setOnionSkinTintColorForward (const QColor &value)
 
void setOnionSkinTintFactor (int value)
 
void setRenameDuplicatedLayers (bool value)
 
void setRenameMergedLayers (bool value)
 
void setSchedulerBalancingRatio (qreal value)
 
void setSelectionOutlineOpacity (qreal value)
 
void setSelectionOverlayMaskColor (const QColor &color)
 
void setShowAdditionalOnionSkinsSettings (bool value)
 
void setSwapDir (const QString &swapDir)
 
void setSwapSlabSize (int value)
 
void setSwapWindowSize (int value)
 
void setUpdatePatchHeight (int value)
 
void setUpdatePatchWidth (int value)
 
void setUseAnimationCacheFrameSizeLimit (bool value)
 
void setUseAnimationCacheRegionOfInterest (bool value)
 
void setUseLodForColorizeMask (bool value)
 
void setUseOnDiskAnimationCacheSwapping (bool value)
 
bool showAdditionalOnionSkinsSettings (bool requestDefault=false) const
 
QString swapDir (bool requestDefault=false)
 
int swapSlabSize () const
 
int swapWindowSize () const
 
int tilesHardLimit () const
 
int tilesSoftLimit () const
 
qreal transformMaskOffBoundsReadArea () const
 
int updatePatchHeight () const
 
int updatePatchWidth () const
 
bool useAnimationCacheFrameSizeLimit (bool defaultValue=false) const
 
bool useAnimationCacheRegionOfInterest (bool defaultValue=false) const
 
bool useLodForColorizeMask (bool requestDefault=false) const
 
bool useOnDiskAnimationCacheSwapping (bool defaultValue=false) const
 
template<class T >
void writeEntry (const QString &name, const T &value)
 
template<class T >
void writeList (const QString &name, const QList< T > &value)
 
 ~KisImageConfig ()
 

Static Public Member Functions

static void resetConfig ()
 
static int totalRAM ()
 

Private Member Functions

QString safelyGetWritableTempLocation (const QString &suffix, const QString &configKey, bool requestDefault) const
 

Private Attributes

KConfigGroup m_config
 
bool m_readOnly
 

Detailed Description

Definition at line 15 of file kis_image_config.h.

Constructor & Destructor Documentation

◆ KisImageConfig()

KisImageConfig::KisImageConfig ( bool readOnly)

Definition at line 34 of file kis_image_config.cpp.

35 : m_config(KSharedConfig::openConfig()->group(QString()))
36 , m_readOnly(readOnly)
37{
38 if (!readOnly) {
39 KIS_SAFE_ASSERT_RECOVER_RETURN(qApp->thread() == QThread::currentThread());
40 }
41#ifdef Q_OS_MACOS
42 // clear /var/folders/ swap path set by old broken Krita swap implementation in order to use new default swap dir.
43 QString swap = m_config.readEntry("swaplocation", "");
44 if (swap.startsWith("/var/folders/")) {
45 m_config.deleteEntry("swaplocation");
46 }
47#endif
48}
KConfigGroup m_config
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
PROPAGATE_CONST_CONSTEXPR void swap(propagate_const< T > &pt, propagate_const< T > &pu) noexcept(noexcept(swap(declval< T & >(), declval< T & >())))

References KIS_SAFE_ASSERT_RECOVER_RETURN, and m_config.

◆ ~KisImageConfig()

KisImageConfig::~KisImageConfig ( )

Definition at line 50 of file kis_image_config.cpp.

51{
52 if (m_readOnly) return;
53
54 if (qApp->thread() != QThread::currentThread()) {
55 dbgKrita << "KisImageConfig: requested config synchronization from nonGUI thread! Called from" << kisBacktrace();
56 return;
57 }
58
59 m_config.sync();
60}
QString kisBacktrace()
Definition kis_debug.cpp:51
#define dbgKrita
Definition kis_debug.h:45

References dbgKrita, kisBacktrace(), m_config, and m_readOnly.

Member Function Documentation

◆ animationCacheDir()

QString KisImageConfig::animationCacheDir ( bool defaultValue = false) const

Definition at line 637 of file kis_image_config.cpp.

638{
639 return safelyGetWritableTempLocation("animation_cache", "animationCacheDir", defaultValue);
640}
QString safelyGetWritableTempLocation(const QString &suffix, const QString &configKey, bool requestDefault) const

References safelyGetWritableTempLocation().

◆ animationCacheFrameSizeLimit()

int KisImageConfig::animationCacheFrameSizeLimit ( bool defaultValue = false) const

Definition at line 657 of file kis_image_config.cpp.

658{
659 return defaultValue ? 2500 : m_config.readEntry("animationCacheFrameSizeLimit", 2500);
660}

References m_config.

◆ animationCacheRegionOfInterestMargin()

qreal KisImageConfig::animationCacheRegionOfInterestMargin ( bool defaultValue = false) const

Definition at line 677 of file kis_image_config.cpp.

678{
679 return defaultValue ? 0.25 : m_config.readEntry("animationCacheRegionOfInterestMargin", 0.25);
680}

References m_config.

◆ autoKeyEnabled()

bool KisImageConfig::autoKeyEnabled ( bool requestDefault = false) const

Definition at line 390 of file kis_image_config.cpp.

391{
392 return !requestDefault ?
393 m_config.readEntry("lazyFrameCreationEnabled", true) : true;
394}

References m_config.

◆ autoKeyModeDuplicate()

bool KisImageConfig::autoKeyModeDuplicate ( bool requestDefault = false) const

Definition at line 401 of file kis_image_config.cpp.

402{
403 return !requestDefault ?
404 m_config.readEntry("lazyFrameModeDuplicate", true) : true;
405}

References m_config.

◆ defaultFrameColorLabel()

int KisImageConfig::defaultFrameColorLabel ( ) const

Definition at line 505 of file kis_image_config.cpp.

506{
507 return m_config.readEntry("defaultFrameColorLabel", 0);
508}

References m_config.

◆ defaultProofingconfiguration()

KisProofingConfigurationSP KisImageConfig::defaultProofingconfiguration ( bool requestDefault = false)

Definition at line 515 of file kis_image_config.cpp.

516{
518 if (!requestDefault) {
519 proofingConfig->proofingProfile = m_config.readEntry("defaultProofingProfileName", "Chemical proof");
520 proofingConfig->proofingModel = m_config.readEntry("defaultProofingProfileModel", "CMYKA");
521 proofingConfig->proofingDepth = m_config.readEntry("defaultProofingProfileDepth", "U8");
522 proofingConfig->displayIntent = KoColorConversionTransformation::Intent(m_config.readEntry("defaultProofingProfileIntent", int(INTENT_ABSOLUTE_COLORIMETRIC)));
523 proofingConfig->conversionIntent = KoColorConversionTransformation::Intent(m_config.readEntry("defaultProofingConversionIntent", int(INTENT_RELATIVE_COLORIMETRIC)));
524 proofingConfig->useBlackPointCompensationFirstTransform = m_config.readEntry("defaultProofingBlackpointCompensation", true);
525
526 proofingConfig->displayFlags.setFlag(KoColorConversionTransformation::BlackpointCompensation, m_config.readEntry("defaultProofingDisplayBlackpointCompensation", true));
527 proofingConfig->displayMode = KisProofingConfiguration::DisplayTransformState(m_config.readEntry("defaultProofingDisplayMode", int(KisProofingConfiguration::Paper)));
528 QColor def(Qt::green);
529 def = m_config.readEntry("defaultProofingGamutwarning", def);
531 col.fromQColor(def);
532 col.setOpacity(1.0);
533 proofingConfig->warningColor = col;
534 proofingConfig->setLegacyAdaptationState(m_config.readEntry("defaultProofingAdaptationState", 1.0));
535 }
536 return toQShared(proofingConfig);
537}
The KisProofingConfiguration struct Little struct that stores the proofing configuration for a given ...
DisplayTransformState displayMode
@ Paper
Whether to use Paper settings (absolute colorimetric, 0% adaptation.)
KoColorConversionTransformation::Intent displayIntent
This is the intent for the second transform.
KoColorConversionTransformation::Intent conversionIntent
This is the intent for the first transform.
bool useBlackPointCompensationFirstTransform
Whether to use BCP on the first transform. All other flags are handled by displayFlags;.
void setLegacyAdaptationState(qreal value)
KoColorConversionTransformation::ConversionFlags displayFlags
flags for the second transform.
#define INTENT_ABSOLUTE_COLORIMETRIC
Definition kis_global.h:106
#define INTENT_RELATIVE_COLORIMETRIC
Definition kis_global.h:104
QSharedPointer< T > toQShared(T *ptr)
static KoColorSpaceRegistry * instance()

References KoColorConversionTransformation::BlackpointCompensation, KisProofingConfiguration::conversionIntent, KisProofingConfiguration::displayFlags, KisProofingConfiguration::displayIntent, KisProofingConfiguration::displayMode, KoColor::fromQColor(), KoColorSpaceRegistry::instance(), INTENT_ABSOLUTE_COLORIMETRIC, INTENT_RELATIVE_COLORIMETRIC, m_config, KisProofingConfiguration::Paper, KisProofingConfiguration::proofingDepth, KisProofingConfiguration::proofingModel, KisProofingConfiguration::proofingProfile, KisProofingConfiguration::setLegacyAdaptationState(), KoColor::setOpacity(), toQShared(), KisProofingConfiguration::useBlackPointCompensationFirstTransform, and KisProofingConfiguration::warningColor.

◆ detectFpsLimit()

bool KisImageConfig::detectFpsLimit ( bool defaultValue = false) const

Definition at line 617 of file kis_image_config.cpp.

618{
619 return defaultValue ? true : m_config.readEntry("detectFpsLimit", true);
620}

References m_config.

◆ enablePerfLog()

bool KisImageConfig::enablePerfLog ( bool requestDefault = false) const

Definition at line 73 of file kis_image_config.cpp.

74{
75 return !requestDefault ?
76 m_config.readEntry("enablePerfLog", false) :false;
77}

References m_config.

◆ enableProgressReporting()

bool KisImageConfig::enableProgressReporting ( bool requestDefault = false) const

Definition at line 62 of file kis_image_config.cpp.

63{
64 return !requestDefault ?
65 m_config.readEntry("enableProgressReporting", true) : true;
66}

References m_config.

◆ exportConfiguration()

KisPropertiesConfigurationSP KisImageConfig::exportConfiguration ( const QString & exportConfigId,
bool defaultValue = false ) const

Definition at line 753 of file kis_image_config.cpp.

754{
756 const QString xmlData = exportConfigurationXML(exportConfigId, defaultValue);
757 cfg->fromXML(xmlData);
758 return cfg;
759}
QString exportConfigurationXML(const QString &exportConfigId, bool defaultValue=false) const

References exportConfigurationXML().

◆ exportConfigurationXML()

QString KisImageConfig::exportConfigurationXML ( const QString & exportConfigId,
bool defaultValue = false ) const

Definition at line 743 of file kis_image_config.cpp.

744{
745 return (defaultValue ? QString() : m_config.readEntry("ExportConfiguration-" + exportConfigId, QString()));
746}
T readEntry(const QString &name, const T &defaultValue=T())

References m_config.

◆ fpsLimit()

int KisImageConfig::fpsLimit ( bool defaultValue = false) const

Definition at line 606 of file kis_image_config.cpp.

607{
608 int limit = defaultValue ? 100 : m_config.readEntry("fpsLimit", 100);
609 return limit > 0 ? limit : 1;
610}

References m_config.

◆ frameRenderingClones()

int KisImageConfig::frameRenderingClones ( bool defaultValue = false) const

Definition at line 584 of file kis_image_config.cpp.

585{
586 const int defaultClonesCount = qMax(1, maxNumberOfThreads(defaultValue) / 2);
587 return defaultValue ? defaultClonesCount : m_config.readEntry("frameRenderingClones", defaultClonesCount);
588}
int maxNumberOfThreads(bool defaultValue=false) const

References m_config, and maxNumberOfThreads().

◆ frameRenderingTimeout()

int KisImageConfig::frameRenderingTimeout ( bool defaultValue = false) const

Definition at line 595 of file kis_image_config.cpp.

596{
597 const int defaultFrameRenderingTimeout = 30000; // 30 ms
598 return defaultValue ? defaultFrameRenderingTimeout : m_config.readEntry("frameRenderingTimeout", defaultFrameRenderingTimeout);
599}

References m_config.

◆ hasExportConfiguration()

bool KisImageConfig::hasExportConfiguration ( const QString & exportConfigID)

Definition at line 748 of file kis_image_config.cpp.

749{
750 return m_config.hasKey("ExportConfiguration-" + exportConfigID);
751}

References m_config.

◆ maxBrushSize()

int KisImageConfig::maxBrushSize ( bool defaultValue = false) const

Definition at line 708 of file kis_image_config.cpp.

709{
710 return !defaultValue ? m_config.readEntry("maximumBrushSize", 1000) : 1000;
711}

References m_config.

◆ maxCollectAlpha()

qreal KisImageConfig::maxCollectAlpha ( ) const

Definition at line 113 of file kis_image_config.cpp.

114{
115 return m_config.readEntry("maxCollectAlpha", 2.5);
116}

References m_config.

◆ maxMaskingBrushSize()

int KisImageConfig::maxMaskingBrushSize ( ) const

Definition at line 718 of file kis_image_config.cpp.

719{
720 return qMin(15000, 3 * maxBrushSize());
721}
int maxBrushSize(bool defaultValue=false) const

References maxBrushSize().

◆ maxMergeAlpha()

qreal KisImageConfig::maxMergeAlpha ( ) const

Definition at line 118 of file kis_image_config.cpp.

119{
120 return m_config.readEntry("maxMergeAlpha", 1.);
121}

References m_config.

◆ maxMergeCollectAlpha()

qreal KisImageConfig::maxMergeCollectAlpha ( ) const

Definition at line 123 of file kis_image_config.cpp.

124{
125 return m_config.readEntry("maxMergeCollectAlpha", 1.5);
126}

References m_config.

◆ maxNumberOfThreads()

int KisImageConfig::maxNumberOfThreads ( bool defaultValue = false) const

Definition at line 570 of file kis_image_config.cpp.

571{
572 return (defaultValue ? QThread::idealThreadCount() : m_config.readEntry("maxNumberOfThreads", QThread::idealThreadCount()));
573}

References m_config.

◆ maxSwapSize()

int KisImageConfig::maxSwapSize ( bool requestDefault = false) const

Definition at line 141 of file kis_image_config.cpp.

142{
143 return !requestDefault ?
144 m_config.readEntry("maxSwapSize", 4096) : 4096; // in MiB
145}

References m_config.

◆ memoryHardLimitPercent()

qreal KisImageConfig::memoryHardLimitPercent ( bool requestDefault = false) const

Definition at line 195 of file kis_image_config.cpp.

196{
197 return !requestDefault ?
198 m_config.readEntry("memoryHardLimitPercent", 50.) : 50.;
199}

References m_config.

◆ memoryPoolLimitPercent()

qreal KisImageConfig::memoryPoolLimitPercent ( bool requestDefault = false) const

Definition at line 217 of file kis_image_config.cpp.

218{
219 return !requestDefault ?
220 m_config.readEntry("memoryPoolLimitPercent", 0.0) : 0.0;
221}

References m_config.

◆ memorySoftLimitPercent()

qreal KisImageConfig::memorySoftLimitPercent ( bool requestDefault = false) const

Definition at line 206 of file kis_image_config.cpp.

207{
208 return !requestDefault ?
209 m_config.readEntry("memorySoftLimitPercent", 2.) : 2.;
210}

References m_config.

◆ numberOfOnionSkins()

int KisImageConfig::numberOfOnionSkins ( ) const

Definition at line 319 of file kis_image_config.cpp.

320{
321 return m_config.readEntry("numberOfOnionSkins", 10);
322}

References m_config.

◆ onionSkinOpacity()

int KisImageConfig::onionSkinOpacity ( int offset,
bool requestDefault = false ) const

Definition at line 339 of file kis_image_config.cpp.

340{
341 int value = m_config.readEntry("onionSkinOpacity_" + QString::number(offset), -1);
342
343 if (value < 0 || requestDefault) {
344 const int num = numberOfOnionSkins();
345 if (num > 0) {
346 const qreal dx = qreal(qAbs(offset)) / num;
347 value = 0.7 * exp(-pow2(dx) / 0.5) * 255;
348 }
349 }
350
351 return value;
352}
float value(const T *src, size_t ch)
int numberOfOnionSkins() const
T pow2(const T &x)
Definition kis_global.h:166

References m_config, numberOfOnionSkins(), pow2(), and value().

◆ onionSkinState()

bool KisImageConfig::onionSkinState ( int offset) const

Definition at line 359 of file kis_image_config.cpp.

360{
361 bool enableByDefault = (qAbs(offset) <= 2);
362 return m_config.readEntry("onionSkinState_" + QString::number(offset), enableByDefault);
363}

References m_config.

◆ onionSkinTintColorBackward()

QColor KisImageConfig::onionSkinTintColorBackward ( ) const

Definition at line 370 of file kis_image_config.cpp.

371{
372 return m_config.readEntry("onionSkinTintColorBackward", QColor(Qt::red));
373}

References m_config.

◆ onionSkinTintColorForward()

QColor KisImageConfig::onionSkinTintColorForward ( ) const

Definition at line 380 of file kis_image_config.cpp.

381{
382 return m_config.readEntry("oninSkinTintColorForward", QColor(Qt::green));
383}

References m_config.

◆ onionSkinTintFactor()

int KisImageConfig::onionSkinTintFactor ( ) const

Definition at line 329 of file kis_image_config.cpp.

330{
331 return m_config.readEntry("onionSkinTintFactor", 192);
332}

References m_config.

◆ poolLimit()

int KisImageConfig::poolLimit ( ) const

Definition at line 187 of file kis_image_config.cpp.

188{
189 qreal hp = qreal(memoryHardLimitPercent()) / 100.0;
190 qreal pp = qreal(memoryPoolLimitPercent()) / 100.0;
191
192 return totalRAM() * hp * pp;
193}
qreal memoryPoolLimitPercent(bool requestDefault=false) const
qreal memoryHardLimitPercent(bool requestDefault=false) const
static int totalRAM()

References memoryHardLimitPercent(), memoryPoolLimitPercent(), and totalRAM().

◆ readEntry()

template<class T >
T KisImageConfig::readEntry ( const QString & name,
const T & defaultValue = T() )
inline

Definition at line 165 of file kis_image_config.h.

165 {
166 return m_config.readEntry(name, defaultValue);
167 }

◆ readList()

template<class T >
QList< T > KisImageConfig::readList ( const QString & name,
const QList< T > & defaultValue = QList<T>() )
inline

Definition at line 170 of file kis_image_config.h.

170 {
171 return m_config.readEntry(name, defaultValue);
172 }

◆ renameDuplicatedLayers()

bool KisImageConfig::renameDuplicatedLayers ( bool defaultValue = false) const

Definition at line 733 of file kis_image_config.cpp.

734{
735 return defaultValue ? true : m_config.readEntry("renameDuplicatedLayers", true);
736}

References m_config.

◆ renameMergedLayers()

bool KisImageConfig::renameMergedLayers ( bool defaultValue = false) const

Definition at line 723 of file kis_image_config.cpp.

724{
725 return defaultValue ? true : m_config.readEntry("renameMergedLayers", true);
726}

References m_config.

◆ resetConfig()

void KisImageConfig::resetConfig ( )
static

Definition at line 768 of file kis_image_config.cpp.

769{
770 KConfigGroup config = KSharedConfig::openConfig()->group(QString());
771 config.deleteGroup();
772}

◆ safelyGetWritableTempLocation()

QString KisImageConfig::safelyGetWritableTempLocation ( const QString & suffix,
const QString & configKey,
bool requestDefault ) const
private

On NTFS, isWritable() doesn't check for attributes due to performance reasons, so we should try it in a brute-force way... (yes, there is a hacky-global-variable workaround, but let's be safe)

Definition at line 228 of file kis_image_config.cpp.

229{
230#ifdef Q_OS_MACOS
231 // On OSX, QDir::tempPath() gives us a folder we cannot reply upon (usually
232 // something like /var/folders/.../...) and that will have vanished when we
233 // try to create the tmp file in KisMemoryWindow::KisMemoryWindow using
234 // swapFileTemplate. thus, we just pick the home folder if swapDir does not
235 // tell us otherwise.
236
237 // the other option here would be to use a "garbled name" temp file (i.e. no name
238 // KRITA_SWAP_FILE_XXXXXX) in an obscure /var/folders place, which is not
239 // nice to the user. having a clearly named swap file in the home folder is
240 // much nicer to Krita's users.
241
242 // NOTE: QStandardPaths::AppLocalDataLocation on macos sandboxed envs
243 // does not return writable locations at all times, using QDir static methods
244 // will always return locations inside the sandbox Container
245
246 // furthermore, this is just a default and swapDir can always be configured
247 // to another location.
248
249 QString swap;
250
252 if ( bookmarkmngr->isSandboxed() ) {
253 QDir sandboxHome = QDir::home();
254 if (sandboxHome.cd("tmp")) {
255 swap = sandboxHome.path();
256 }
257 } else {
258 swap = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + '/' + suffix;
259 }
260#else
261 Q_UNUSED(suffix);
262 QString swap = QDir::tempPath();
263#endif
264 if (requestDefault) {
265 return swap;
266 }
267 const QString configuredSwap = m_config.readEntry(configKey, swap);
268 if (!configuredSwap.isEmpty()) {
269 swap = configuredSwap;
270 }
271
272 QString chosenLocation;
273 QStringList proposedSwapLocations;
274
275 proposedSwapLocations << swap;
276 proposedSwapLocations << QDir::tempPath();
277 proposedSwapLocations << QDir::homePath();
278
279 Q_FOREACH (const QString location, proposedSwapLocations) {
280 if (!QFileInfo(location).isWritable()) continue;
281
287 QTemporaryFile tempFile;
288 tempFile.setFileTemplate(location + '/' + "krita_test_swap_location");
289 if (tempFile.open() && !tempFile.fileName().isEmpty()) {
290 chosenLocation = location;
291 break;
292 }
293 }
294
295 if (chosenLocation.isEmpty()) {
296 qCritical() << "CRITICAL: no writable location for a swap file found! Tried the following paths:" << proposedSwapLocations;
297 qCritical() << "CRITICAL: hope I don't crash...";
298 chosenLocation = swap;
299 }
300
301 if (chosenLocation != swap) {
302 qWarning() << "WARNING: configured swap location is not writable, using a fall-back location" << swap << "->" << chosenLocation;
303 }
304
305 return chosenLocation;
306}
static KisMacosSecurityBookmarkManager * instance()

References KisMacosSecurityBookmarkManager::instance(), KisMacosSecurityBookmarkManager::isSandboxed(), and m_config.

◆ schedulerBalancingRatio()

qreal KisImageConfig::schedulerBalancingRatio ( ) const

updates-queue-size / strokes-queue-size

Definition at line 128 of file kis_image_config.cpp.

129{
133 return m_config.readEntry("schedulerBalancingRatio", 100.);
134}

References m_config.

◆ selectionOutlineOpacity()

qreal KisImageConfig::selectionOutlineOpacity ( bool defaultValue = false) const

Definition at line 687 of file kis_image_config.cpp.

688{
689 return defaultValue ? 1.0 : m_config.readEntry("selectionOutlineOpacity", 1.0);
690}

References m_config.

◆ selectionOverlayMaskColor()

QColor KisImageConfig::selectionOverlayMaskColor ( bool defaultValue = false) const

Definition at line 697 of file kis_image_config.cpp.

698{
699 QColor def(255, 0, 0, 128);
700 return (defaultValue ? def : m_config.readEntry("selectionOverlayMaskColor", def));
701}

References m_config.

◆ setAnimationCacheDir()

void KisImageConfig::setAnimationCacheDir ( const QString & value)

Definition at line 642 of file kis_image_config.cpp.

643{
644 m_config.writeEntry("animationCacheDir", value);
645}

References m_config, and value().

◆ setAnimationCacheFrameSizeLimit()

void KisImageConfig::setAnimationCacheFrameSizeLimit ( int value)

Definition at line 662 of file kis_image_config.cpp.

663{
664 m_config.writeEntry("animationCacheFrameSizeLimit", value);
665}

References m_config, and value().

◆ setAnimationCacheRegionOfInterestMargin()

void KisImageConfig::setAnimationCacheRegionOfInterestMargin ( qreal value)

Definition at line 682 of file kis_image_config.cpp.

683{
684 m_config.writeEntry("animationCacheRegionOfInterestMargin", value);
685}

References m_config, and value().

◆ setAutoKeyEnabled()

void KisImageConfig::setAutoKeyEnabled ( bool value)

Definition at line 396 of file kis_image_config.cpp.

397{
398 m_config.writeEntry("lazyFrameCreationEnabled", value);
399}

References m_config, and value().

◆ setAutoKeyModeDuplicate()

void KisImageConfig::setAutoKeyModeDuplicate ( bool value)

Definition at line 407 of file kis_image_config.cpp.

408{
409 m_config.writeEntry("lazyFrameModeDuplicate", value);
410}

References m_config, and value().

◆ setDefaultFrameColorLabel()

void KisImageConfig::setDefaultFrameColorLabel ( int label)

Definition at line 510 of file kis_image_config.cpp.

511{
512 m_config.writeEntry("defaultFrameColorLabel", label);
513}

References m_config.

◆ setDefaultProofingConfig()

void KisImageConfig::setDefaultProofingConfig ( const KisProofingConfiguration & config)

Definition at line 539 of file kis_image_config.cpp.

540{
541 if (*defaultProofingconfiguration() == config) return;
542
543 m_config.writeEntry("defaultProofingProfileName", config.proofingProfile);
544 m_config.writeEntry("defaultProofingProfileModel", config.proofingModel);
545 m_config.writeEntry("defaultProofingProfileDepth", config.proofingDepth);
546 m_config.writeEntry("defaultProofingConversionIntent", int(config.conversionIntent));
547 m_config.writeEntry("defaultProofingBlackpointCompensation", config.useBlackPointCompensationFirstTransform);
548 QColor c;
549 c = config.warningColor.toQColor();
550 m_config.writeEntry("defaultProofingGamutwarning", c);
551 m_config.writeEntry("defaultProofingAdaptationState", config.legacyAdaptationState());
552 m_config.writeEntry("defaultProofingDisplayBlackpointCompensation", config.displayFlags.testFlag(KoColorConversionTransformation::BlackpointCompensation));
553 m_config.writeEntry("defaultProofingProfileIntent", int(config.displayIntent));
554 m_config.writeEntry("defaultProofingDisplayMode", int(config.displayMode));
555
557}
static KisImageConfigNotifier * instance()
KisProofingConfigurationSP defaultProofingconfiguration(bool requestDefault=false)
void toQColor(QColor *c) const
a convenience method for the above.
Definition KoColor.cpp:198

References KoColorConversionTransformation::BlackpointCompensation, KisProofingConfiguration::conversionIntent, defaultProofingconfiguration(), KisProofingConfiguration::displayFlags, KisProofingConfiguration::displayIntent, KisProofingConfiguration::displayMode, KisImageConfigNotifier::instance(), KisProofingConfiguration::legacyAdaptationState(), m_config, KisImageConfigNotifier::notifyGlobalProofingConfigChanged(), KisProofingConfiguration::proofingDepth, KisProofingConfiguration::proofingModel, KisProofingConfiguration::proofingProfile, KoColor::toQColor(), KisProofingConfiguration::useBlackPointCompensationFirstTransform, and KisProofingConfiguration::warningColor.

◆ setDetectFpsLimit()

void KisImageConfig::setDetectFpsLimit ( bool value)

Definition at line 622 of file kis_image_config.cpp.

623{
624 m_config.writeEntry("detectFpsLimit", value);
625}

References m_config, and value().

◆ setEnablePerfLog()

void KisImageConfig::setEnablePerfLog ( bool value)

Definition at line 79 of file kis_image_config.cpp.

80{
81 m_config.writeEntry("enablePerfLog", value);
82}

References m_config, and value().

◆ setEnableProgressReporting()

void KisImageConfig::setEnableProgressReporting ( bool value)

Definition at line 68 of file kis_image_config.cpp.

69{
70 m_config.writeEntry("enableProgressReporting", value);
71}

References m_config, and value().

◆ setExportConfiguration()

void KisImageConfig::setExportConfiguration ( const QString & exportConfigId,
KisPropertiesConfigurationSP properties )

Definition at line 761 of file kis_image_config.cpp.

762{
763 const QString exportConfig = properties->toXML();
764 QString configId = "ExportConfiguration-" + exportConfigId;
765 m_config.writeEntry(configId, exportConfig);
766}

References m_config.

◆ setFpsLimit()

void KisImageConfig::setFpsLimit ( int value)

Definition at line 612 of file kis_image_config.cpp.

613{
614 m_config.writeEntry("fpsLimit", value);
615}

References m_config, and value().

◆ setFrameRenderingClones()

void KisImageConfig::setFrameRenderingClones ( int value)

Definition at line 590 of file kis_image_config.cpp.

591{
592 m_config.writeEntry("frameRenderingClones", value);
593}

References m_config, and value().

◆ setFrameRenderingTimeout()

void KisImageConfig::setFrameRenderingTimeout ( int value)

Definition at line 601 of file kis_image_config.cpp.

602{
603 m_config.writeEntry("frameRenderingTimeout", value);
604}

References m_config, and value().

◆ setMaxBrushSize()

void KisImageConfig::setMaxBrushSize ( int value)

Definition at line 713 of file kis_image_config.cpp.

714{
715 m_config.writeEntry("maximumBrushSize", value);
716}

References m_config, and value().

◆ setMaxNumberOfThreads()

void KisImageConfig::setMaxNumberOfThreads ( int value)

Definition at line 575 of file kis_image_config.cpp.

576{
577 if (value == QThread::idealThreadCount()) {
578 m_config.deleteEntry("maxNumberOfThreads");
579 } else {
580 m_config.writeEntry("maxNumberOfThreads", value);
581 }
582}

References m_config, and value().

◆ setMaxSwapSize()

void KisImageConfig::setMaxSwapSize ( int value)

Definition at line 147 of file kis_image_config.cpp.

148{
149 m_config.writeEntry("maxSwapSize", value);
150}

References m_config, and value().

◆ setMemoryHardLimitPercent()

void KisImageConfig::setMemoryHardLimitPercent ( qreal value)

Definition at line 201 of file kis_image_config.cpp.

202{
203 m_config.writeEntry("memoryHardLimitPercent", value);
204}

References m_config, and value().

◆ setMemoryPoolLimitPercent()

void KisImageConfig::setMemoryPoolLimitPercent ( qreal value)

Definition at line 223 of file kis_image_config.cpp.

224{
225 m_config.writeEntry("memoryPoolLimitPercent", value);
226}

References m_config, and value().

◆ setMemorySoftLimitPercent()

void KisImageConfig::setMemorySoftLimitPercent ( qreal value)

Definition at line 212 of file kis_image_config.cpp.

213{
214 m_config.writeEntry("memorySoftLimitPercent", value);
215}

References m_config, and value().

◆ setNumberOfOnionSkins()

void KisImageConfig::setNumberOfOnionSkins ( int value)

Definition at line 324 of file kis_image_config.cpp.

325{
326 m_config.writeEntry("numberOfOnionSkins", value);
327}

References m_config, and value().

◆ setOnionSkinOpacity()

void KisImageConfig::setOnionSkinOpacity ( int offset,
int value )

Definition at line 354 of file kis_image_config.cpp.

355{
356 m_config.writeEntry("onionSkinOpacity_" + QString::number(offset), value);
357}

References m_config, and value().

◆ setOnionSkinState()

void KisImageConfig::setOnionSkinState ( int offset,
bool value )

Definition at line 365 of file kis_image_config.cpp.

366{
367 m_config.writeEntry("onionSkinState_" + QString::number(offset), value);
368}

References m_config, and value().

◆ setOnionSkinTintColorBackward()

void KisImageConfig::setOnionSkinTintColorBackward ( const QColor & value)

Definition at line 375 of file kis_image_config.cpp.

376{
377 m_config.writeEntry("onionSkinTintColorBackward", value);
378}

References m_config, and value().

◆ setOnionSkinTintColorForward()

void KisImageConfig::setOnionSkinTintColorForward ( const QColor & value)

Definition at line 385 of file kis_image_config.cpp.

386{
387 m_config.writeEntry("oninSkinTintColorForward", value);
388}

References m_config, and value().

◆ setOnionSkinTintFactor()

void KisImageConfig::setOnionSkinTintFactor ( int value)

Definition at line 334 of file kis_image_config.cpp.

335{
336 m_config.writeEntry("onionSkinTintFactor", value);
337}

References m_config, and value().

◆ setRenameDuplicatedLayers()

void KisImageConfig::setRenameDuplicatedLayers ( bool value)

Definition at line 738 of file kis_image_config.cpp.

739{
740 m_config.writeEntry("renameDuplicatedLayers", value);
741}

References m_config, and value().

◆ setRenameMergedLayers()

void KisImageConfig::setRenameMergedLayers ( bool value)

Definition at line 728 of file kis_image_config.cpp.

729{
730 m_config.writeEntry("renameMergedLayers", value);
731}

References m_config, and value().

◆ setSchedulerBalancingRatio()

void KisImageConfig::setSchedulerBalancingRatio ( qreal value)

Definition at line 136 of file kis_image_config.cpp.

137{
138 m_config.writeEntry("schedulerBalancingRatio", value);
139}

References m_config, and value().

◆ setSelectionOutlineOpacity()

void KisImageConfig::setSelectionOutlineOpacity ( qreal value)

Definition at line 692 of file kis_image_config.cpp.

693{
694 m_config.writeEntry("selectionOutlineOpacity", value);
695}

References m_config, and value().

◆ setSelectionOverlayMaskColor()

void KisImageConfig::setSelectionOverlayMaskColor ( const QColor & color)

Definition at line 703 of file kis_image_config.cpp.

704{
705 m_config.writeEntry("selectionOverlayMaskColor", color);
706}

References m_config.

◆ setShowAdditionalOnionSkinsSettings()

void KisImageConfig::setShowAdditionalOnionSkinsSettings ( bool value)

Definition at line 500 of file kis_image_config.cpp.

501{
502 m_config.writeEntry("showAdditionalOnionSkinsSettings", value);
503}

References m_config, and value().

◆ setSwapDir()

void KisImageConfig::setSwapDir ( const QString & swapDir)

Definition at line 314 of file kis_image_config.cpp.

315{
316 m_config.writeEntry("swaplocation", swapDir);
317}
QString swapDir(bool requestDefault=false)

References m_config, and swapDir().

◆ setSwapSlabSize()

void KisImageConfig::setSwapSlabSize ( int value)

Definition at line 157 of file kis_image_config.cpp.

158{
159 m_config.writeEntry("swapSlabSize", value);
160}

References m_config, and value().

◆ setSwapWindowSize()

void KisImageConfig::setSwapWindowSize ( int value)

Definition at line 167 of file kis_image_config.cpp.

168{
169 m_config.writeEntry("swapWindowSize", value);
170}

References m_config, and value().

◆ setUpdatePatchHeight()

void KisImageConfig::setUpdatePatchHeight ( int value)

Definition at line 96 of file kis_image_config.cpp.

97{
98 m_config.writeEntry("updatePatchHeight", value);
99}

References m_config, and value().

◆ setUpdatePatchWidth()

void KisImageConfig::setUpdatePatchWidth ( int value)

Definition at line 108 of file kis_image_config.cpp.

109{
110 m_config.writeEntry("updatePatchWidth", value);
111}

References m_config, and value().

◆ setUseAnimationCacheFrameSizeLimit()

void KisImageConfig::setUseAnimationCacheFrameSizeLimit ( bool value)

Definition at line 652 of file kis_image_config.cpp.

653{
654 m_config.writeEntry("useAnimationCacheFrameSizeLimit", value);
655}

References m_config, and value().

◆ setUseAnimationCacheRegionOfInterest()

void KisImageConfig::setUseAnimationCacheRegionOfInterest ( bool value)

Definition at line 672 of file kis_image_config.cpp.

673{
674 m_config.writeEntry("useAnimationCacheRegionOfInterest", value);
675}

References m_config, and value().

◆ setUseLodForColorizeMask()

void KisImageConfig::setUseLodForColorizeMask ( bool value)

Definition at line 565 of file kis_image_config.cpp.

566{
567 m_config.writeEntry("useLodForColorizeMask", value);
568}

References m_config, and value().

◆ setUseOnDiskAnimationCacheSwapping()

void KisImageConfig::setUseOnDiskAnimationCacheSwapping ( bool value)

Definition at line 632 of file kis_image_config.cpp.

633{
634 m_config.writeEntry("useOnDiskAnimationCacheSwapping", value);
635}

References m_config, and value().

◆ showAdditionalOnionSkinsSettings()

bool KisImageConfig::showAdditionalOnionSkinsSettings ( bool requestDefault = false) const

Definition at line 494 of file kis_image_config.cpp.

495{
496 return !requestDefault ?
497 m_config.readEntry("showAdditionalOnionSkinsSettings", true) : true;
498}

References m_config.

◆ swapDir()

QString KisImageConfig::swapDir ( bool requestDefault = false)
Returns
a specific directory for the swapfile, if set. If not set, return an empty QString and use the default KDE directory.

Definition at line 309 of file kis_image_config.cpp.

310{
311 return safelyGetWritableTempLocation("swap", "swaplocation", requestDefault);
312}

References safelyGetWritableTempLocation().

◆ swapSlabSize()

int KisImageConfig::swapSlabSize ( ) const

Definition at line 152 of file kis_image_config.cpp.

153{
154 return m_config.readEntry("swapSlabSize", 64); // in MiB
155}

References m_config.

◆ swapWindowSize()

int KisImageConfig::swapWindowSize ( ) const

Definition at line 162 of file kis_image_config.cpp.

163{
164 return m_config.readEntry("swapWindowSize", 16); // in MiB
165}

References m_config.

◆ tilesHardLimit()

int KisImageConfig::tilesHardLimit ( ) const

Definition at line 172 of file kis_image_config.cpp.

173{
174 qreal hp = qreal(memoryHardLimitPercent()) / 100.0;
175 qreal pp = qreal(memoryPoolLimitPercent()) / 100.0;
176
177 return totalRAM() * hp * (1 - pp);
178}

References memoryHardLimitPercent(), memoryPoolLimitPercent(), and totalRAM().

◆ tilesSoftLimit()

int KisImageConfig::tilesSoftLimit ( ) const

Definition at line 180 of file kis_image_config.cpp.

181{
182 qreal sp = qreal(memorySoftLimitPercent()) / 100.0;
183
184 return tilesHardLimit() * sp;
185}
int tilesHardLimit() const
qreal memorySoftLimitPercent(bool requestDefault=false) const

References memorySoftLimitPercent(), and tilesHardLimit().

◆ totalRAM()

int KisImageConfig::totalRAM ( )
static

Definition at line 425 of file kis_image_config.cpp.

426{
427 // let's think that default memory size is 1000MiB
428 int totalMemory = 1000; // MiB
429 int error = 1;
430
431#if defined Q_OS_LINUX
432 struct sysinfo info;
433
434 error = sysinfo(&info);
435 if(!error) {
436 totalMemory = info.totalram * info.mem_unit / (1UL << 20);
437 }
438#elif defined Q_OS_HAIKU
439 system_info info;
440 error = get_system_info(&info) == B_OK ? 0 : 1;
441 if (!error) {
442 uint64_t size = (info.max_pages * B_PAGE_SIZE);
443 totalMemory = size >> 20;
444 }
445#elif defined Q_OS_FREEBSD || defined Q_OS_NETBSD || defined Q_OS_OPENBSD
446 u_long physmem;
447# if defined HW_PHYSMEM64 // NetBSD only
448 int mib[] = {CTL_HW, HW_PHYSMEM64};
449# else
450 int mib[] = {CTL_HW, HW_PHYSMEM};
451# endif
452 size_t len = sizeof(physmem);
453
454 error = sysctl(mib, 2, &physmem, &len, 0, 0);
455 if(!error) {
456 totalMemory = physmem >> 20;
457 }
458#elif defined Q_OS_WIN
459 MEMORYSTATUSEX status;
460 status.dwLength = sizeof(status);
461 error = !GlobalMemoryStatusEx(&status);
462
463 if (!error) {
464 totalMemory = status.ullTotalPhys >> 20;
465 }
466
467 // For 32 bit windows, the total memory available is at max the 2GB per process memory limit.
468# if defined ENV32BIT
469 totalMemory = qMin(totalMemory, 2000);
470# endif
471#elif defined Q_OS_MACOS
472 int mib[2] = { CTL_HW, HW_MEMSIZE };
473 u_int namelen = sizeof(mib) / sizeof(mib[0]);
474 uint64_t size;
475 size_t len = sizeof(size);
476
477 errno = 0;
478 if (sysctl(mib, namelen, &size, &len, 0, 0) >= 0) {
479 totalMemory = size >> 20;
480 error = 0;
481 }
482 else {
483 dbgKrita << "sysctl(\"hw.memsize\") raised error" << strerror(errno);
484 }
485#endif
486
487 if (error) {
488 warnKrita << "Cannot get the size of your RAM. Using 1 GiB by default.";
489 }
490
491 return totalMemory;
492}
#define warnKrita
Definition kis_debug.h:87
int size(const Forest< T > &forest)
Definition KisForest.h:1232

References dbgKrita, and warnKrita.

◆ transformMaskOffBoundsReadArea()

qreal KisImageConfig::transformMaskOffBoundsReadArea ( ) const

Definition at line 84 of file kis_image_config.cpp.

85{
86 return m_config.readEntry("transformMaskOffBoundsReadArea", 0.5);
87}

References m_config.

◆ updatePatchHeight()

int KisImageConfig::updatePatchHeight ( ) const

Definition at line 89 of file kis_image_config.cpp.

90{
91 int patchHeight = m_config.readEntry("updatePatchHeight", 512);
92 if (patchHeight <= 0) return 512;
93 return patchHeight;
94}

References m_config.

◆ updatePatchWidth()

int KisImageConfig::updatePatchWidth ( ) const

Definition at line 101 of file kis_image_config.cpp.

102{
103 int patchWidth = m_config.readEntry("updatePatchWidth", 512);
104 if (patchWidth <= 0) return 512;
105 return patchWidth;
106}

References m_config.

◆ useAnimationCacheFrameSizeLimit()

bool KisImageConfig::useAnimationCacheFrameSizeLimit ( bool defaultValue = false) const

Definition at line 647 of file kis_image_config.cpp.

648{
649 return defaultValue ? true : m_config.readEntry("useAnimationCacheFrameSizeLimit", true);
650}

References m_config.

◆ useAnimationCacheRegionOfInterest()

bool KisImageConfig::useAnimationCacheRegionOfInterest ( bool defaultValue = false) const

Definition at line 667 of file kis_image_config.cpp.

668{
669 return defaultValue ? true : m_config.readEntry("useAnimationCacheRegionOfInterest", true);
670}

References m_config.

◆ useLodForColorizeMask()

bool KisImageConfig::useLodForColorizeMask ( bool requestDefault = false) const

Definition at line 559 of file kis_image_config.cpp.

560{
561 return !requestDefault ?
562 m_config.readEntry("useLodForColorizeMask", false) : false;
563}

References m_config.

◆ useOnDiskAnimationCacheSwapping()

bool KisImageConfig::useOnDiskAnimationCacheSwapping ( bool defaultValue = false) const

Definition at line 627 of file kis_image_config.cpp.

628{
629 return defaultValue ? true : m_config.readEntry("useOnDiskAnimationCacheSwapping", true);
630}

References m_config.

◆ writeEntry()

template<class T >
void KisImageConfig::writeEntry ( const QString & name,
const T & value )
inline

Definition at line 155 of file kis_image_config.h.

155 {
156 m_config.writeEntry(name, value);
157 }

References value().

◆ writeList()

template<class T >
void KisImageConfig::writeList ( const QString & name,
const QList< T > & value )
inline

Definition at line 160 of file kis_image_config.h.

160 {
161 m_config.writeEntry(name, value);
162 }

References value().

Member Data Documentation

◆ m_config

KConfigGroup KisImageConfig::m_config
private

Definition at line 190 of file kis_image_config.h.

◆ m_readOnly

bool KisImageConfig::m_readOnly
private

Definition at line 191 of file kis_image_config.h.


The documentation for this class was generated from the following files: