9#include <ksharedconfig.h>
21#include <QApplication>
27#include <QTemporaryFile>
35 : m_config(KSharedConfig::openConfig()->group(QString()))
36 , m_readOnly(readOnly)
43 QString swap =
m_config.readEntry(
"swaplocation",
"");
44 if (swap.startsWith(
"/var/folders/")) {
45 m_config.deleteEntry(
"swaplocation");
54 if (qApp->thread() != QThread::currentThread()) {
55 dbgKrita <<
"KisImageConfig: requested config synchronization from nonGUI thread! Called from" <<
kisBacktrace();
64 return !requestDefault ?
65 m_config.readEntry(
"enableProgressReporting",
true) :
true;
75 return !requestDefault ?
76 m_config.readEntry(
"enablePerfLog",
false) :
false;
86 return m_config.readEntry(
"transformMaskOffBoundsReadArea", 0.5);
91 int patchHeight =
m_config.readEntry(
"updatePatchHeight", 512);
92 if (patchHeight <= 0)
return 512;
103 int patchWidth =
m_config.readEntry(
"updatePatchWidth", 512);
104 if (patchWidth <= 0)
return 512;
115 return m_config.readEntry(
"maxCollectAlpha", 2.5);
120 return m_config.readEntry(
"maxMergeAlpha", 1.);
125 return m_config.readEntry(
"maxMergeCollectAlpha", 1.5);
133 return m_config.readEntry(
"schedulerBalancingRatio", 100.);
143 return !requestDefault ?
144 m_config.readEntry(
"maxSwapSize", 4096) : 4096;
154 return m_config.readEntry(
"swapSlabSize", 64);
164 return m_config.readEntry(
"swapWindowSize", 16);
197 return !requestDefault ?
198 m_config.readEntry(
"memoryHardLimitPercent", 50.) : 50.;
208 return !requestDefault ?
209 m_config.readEntry(
"memorySoftLimitPercent", 2.) : 2.;
219 return !requestDefault ?
220 m_config.readEntry(
"memoryPoolLimitPercent", 0.0) : 0.0;
253 QDir sandboxHome = QDir::home();
254 if (sandboxHome.cd(
"tmp")) {
255 swap = sandboxHome.path();
258 swap = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) +
'/' + suffix;
262 QString swap = QDir::tempPath();
264 if (requestDefault) {
267 const QString configuredSwap =
m_config.readEntry(configKey, swap);
268 if (!configuredSwap.isEmpty()) {
269 swap = configuredSwap;
272 QString chosenLocation;
275 proposedSwapLocations << swap;
276 proposedSwapLocations << QDir::tempPath();
277 proposedSwapLocations << QDir::homePath();
279 Q_FOREACH (
const QString location, proposedSwapLocations) {
280 if (!QFileInfo(location).isWritable())
continue;
287 QTemporaryFile tempFile;
288 tempFile.setFileTemplate(location +
'/' +
"krita_test_swap_location");
289 if (tempFile.open() && !tempFile.fileName().isEmpty()) {
290 chosenLocation = location;
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;
301 if (chosenLocation != swap) {
302 qWarning() <<
"WARNING: configured swap location is not writable, using a fall-back location" << swap <<
"->" << chosenLocation;
305 return chosenLocation;
321 return m_config.readEntry(
"numberOfOnionSkins", 10);
331 return m_config.readEntry(
"onionSkinTintFactor", 192);
341 int value =
m_config.readEntry(
"onionSkinOpacity_" + QString::number(offset), -1);
343 if (
value < 0 || requestDefault) {
346 const qreal dx = qreal(qAbs(offset)) / num;
347 value = 0.7 * exp(-
pow2(dx) / 0.5) * 255;
356 m_config.writeEntry(
"onionSkinOpacity_" + QString::number(offset),
value);
361 bool enableByDefault = (qAbs(offset) <= 2);
362 return m_config.readEntry(
"onionSkinState_" + QString::number(offset), enableByDefault);
367 m_config.writeEntry(
"onionSkinState_" + QString::number(offset),
value);
372 return m_config.readEntry(
"onionSkinTintColorBackward", QColor(Qt::red));
382 return m_config.readEntry(
"oninSkinTintColorForward", QColor(Qt::green));
392 return !requestDefault ?
393 m_config.readEntry(
"lazyFrameCreationEnabled",
true) :
true;
403 return !requestDefault ?
404 m_config.readEntry(
"lazyFrameModeDuplicate",
true) :
true;
412#if defined Q_OS_LINUX
413#include <sys/sysinfo.h>
414#elif defined Q_OS_HAIKU
416#elif defined Q_OS_FREEBSD || defined Q_OS_NETBSD || defined Q_OS_OPENBSD
417#include <sys/sysctl.h>
418#elif defined Q_OS_WIN
420#elif defined Q_OS_MACOS
421#include <sys/types.h>
422#include <sys/sysctl.h>
428 int totalMemory = 1000;
431#if defined Q_OS_LINUX
434 error = sysinfo(&info);
436 totalMemory = info.totalram * info.mem_unit / (1UL << 20);
438#elif defined Q_OS_HAIKU
440 error = get_system_info(&info) == B_OK ? 0 : 1;
442 uint64_t size = (info.max_pages * B_PAGE_SIZE);
443 totalMemory = size >> 20;
445#elif defined Q_OS_FREEBSD || defined Q_OS_NETBSD || defined Q_OS_OPENBSD
447# if defined HW_PHYSMEM64
448 int mib[] = {CTL_HW, HW_PHYSMEM64};
450 int mib[] = {CTL_HW, HW_PHYSMEM};
452 size_t len =
sizeof(physmem);
454 error = sysctl(mib, 2, &physmem, &len, 0, 0);
456 totalMemory = physmem >> 20;
458#elif defined Q_OS_WIN
459 MEMORYSTATUSEX status;
460 status.dwLength =
sizeof(status);
461 error = !GlobalMemoryStatusEx(&status);
464 totalMemory = status.ullTotalPhys >> 20;
469 totalMemory = qMin(totalMemory, 2000);
471#elif defined Q_OS_MACOS
472 int mib[2] = { CTL_HW, HW_MEMSIZE };
473 u_int namelen =
sizeof(mib) /
sizeof(mib[0]);
475 size_t len =
sizeof(size);
478 if (sysctl(mib, namelen, &size, &len, 0, 0) >= 0) {
479 totalMemory = size >> 20;
483 dbgKrita <<
"sysctl(\"hw.memsize\") raised error" << strerror(errno);
488 warnKrita <<
"Cannot get the size of your RAM. Using 1 GiB by default.";
496 return !requestDefault ?
497 m_config.readEntry(
"showAdditionalOnionSkinsSettings",
true) :
true;
502 m_config.writeEntry(
"showAdditionalOnionSkinsSettings",
value);
507 return m_config.readEntry(
"defaultFrameColorLabel", 0);
512 m_config.writeEntry(
"defaultFrameColorLabel", label);
518 if (!requestDefault) {
528 QColor def(Qt::green);
529 def =
m_config.readEntry(
"defaultProofingGamutwarning", def);
550 m_config.writeEntry(
"defaultProofingGamutwarning", c);
561 return !requestDefault ?
562 m_config.readEntry(
"useLodForColorizeMask",
false) :
false;
572 return (defaultValue ? QThread::idealThreadCount() :
m_config.readEntry(
"maxNumberOfThreads", QThread::idealThreadCount()));
577 if (
value == QThread::idealThreadCount()) {
578 m_config.deleteEntry(
"maxNumberOfThreads");
587 return defaultValue ? defaultClonesCount :
m_config.readEntry(
"frameRenderingClones", defaultClonesCount);
597 const int defaultFrameRenderingTimeout = 30000;
598 return defaultValue ? defaultFrameRenderingTimeout :
m_config.readEntry(
"frameRenderingTimeout", defaultFrameRenderingTimeout);
608 int limit = defaultValue ? 100 :
m_config.readEntry(
"fpsLimit", 100);
609 return limit > 0 ? limit : 1;
619 return defaultValue ? true :
m_config.readEntry(
"detectFpsLimit",
true);
629 return defaultValue ? true :
m_config.readEntry(
"useOnDiskAnimationCacheSwapping",
true);
634 m_config.writeEntry(
"useOnDiskAnimationCacheSwapping",
value);
649 return defaultValue ? true :
m_config.readEntry(
"useAnimationCacheFrameSizeLimit",
true);
654 m_config.writeEntry(
"useAnimationCacheFrameSizeLimit",
value);
659 return defaultValue ? 2500 :
m_config.readEntry(
"animationCacheFrameSizeLimit", 2500);
669 return defaultValue ? true :
m_config.readEntry(
"useAnimationCacheRegionOfInterest",
true);
674 m_config.writeEntry(
"useAnimationCacheRegionOfInterest",
value);
679 return defaultValue ? 0.25 :
m_config.readEntry(
"animationCacheRegionOfInterestMargin", 0.25);
684 m_config.writeEntry(
"animationCacheRegionOfInterestMargin",
value);
689 return defaultValue ? 1.0 :
m_config.readEntry(
"selectionOutlineOpacity", 1.0);
699 QColor def(255, 0, 0, 128);
700 return (defaultValue ? def :
m_config.readEntry(
"selectionOverlayMaskColor", def));
705 m_config.writeEntry(
"selectionOverlayMaskColor", color);
710 return !defaultValue ?
m_config.readEntry(
"maximumBrushSize", 1000) : 1000;
725 return defaultValue ? true :
m_config.readEntry(
"renameMergedLayers",
true);
735 return defaultValue ? true :
m_config.readEntry(
"renameDuplicatedLayers",
true);
745 return (defaultValue ? QString() :
m_config.readEntry(
"ExportConfiguration-" + exportConfigId, QString()));
750 return m_config.hasKey(
"ExportConfiguration-" + exportConfigID);
757 cfg->fromXML(xmlData);
763 const QString exportConfig = properties->toXML();
764 QString configId =
"ExportConfiguration-" + exportConfigId;
765 m_config.writeEntry(configId, exportConfig);
770 KConfigGroup config = KSharedConfig::openConfig()->group(QString());
771 config.deleteGroup();
float value(const T *src, size_t ch)
void notifyGlobalProofingConfigChanged()
static KisImageConfigNotifier * instance()
int numberOfOnionSkins() const
int maxMaskingBrushSize() const
void setExportConfiguration(const QString &exportConfigId, KisPropertiesConfigurationSP properties)
void setEnableProgressReporting(bool value)
void setUseAnimationCacheRegionOfInterest(bool value)
int updatePatchWidth() const
void setUpdatePatchWidth(int value)
bool useAnimationCacheFrameSizeLimit(bool defaultValue=false) const
void setAnimationCacheFrameSizeLimit(int value)
void setUpdatePatchHeight(int value)
QColor onionSkinTintColorBackward() const
qreal transformMaskOffBoundsReadArea() const
qreal maxMergeCollectAlpha() const
qreal schedulerBalancingRatio() const
void setFrameRenderingClones(int value)
QString exportConfigurationXML(const QString &exportConfigId, bool defaultValue=false) const
int animationCacheFrameSizeLimit(bool defaultValue=false) const
KisProofingConfigurationSP defaultProofingconfiguration(bool requestDefault=false)
void setMaxNumberOfThreads(int value)
bool useAnimationCacheRegionOfInterest(bool defaultValue=false) const
int frameRenderingClones(bool defaultValue=false) const
void setDetectFpsLimit(bool value)
void setFpsLimit(int value)
QString safelyGetWritableTempLocation(const QString &suffix, const QString &configKey, bool requestDefault) const
QString swapDir(bool requestDefault=false)
int maxNumberOfThreads(bool defaultValue=false) const
void setOnionSkinState(int offset, bool value)
KisImageConfig(bool readOnly)
bool autoKeyEnabled(bool requestDefault=false) const
qreal memoryPoolLimitPercent(bool requestDefault=false) const
int maxBrushSize(bool defaultValue=false) const
int onionSkinOpacity(int offset, bool requestDefault=false) const
int updatePatchHeight() const
void setEnablePerfLog(bool value)
bool detectFpsLimit(bool defaultValue=false) const
void setSwapSlabSize(int value)
bool enableProgressReporting(bool requestDefault=false) const
void setUseAnimationCacheFrameSizeLimit(bool value)
int onionSkinTintFactor() const
int fpsLimit(bool defaultValue=false) const
void setOnionSkinTintColorForward(const QColor &value)
void setSelectionOutlineOpacity(qreal value)
bool renameDuplicatedLayers(bool defaultValue=false) const
int maxSwapSize(bool requestDefault=false) const
int tilesHardLimit() const
bool onionSkinState(int offset) const
void setOnionSkinTintFactor(int value)
void setAutoKeyEnabled(bool value)
bool hasExportConfiguration(const QString &exportConfigID)
static void resetConfig()
void setUseOnDiskAnimationCacheSwapping(bool value)
void setOnionSkinOpacity(int offset, int value)
int defaultFrameColorLabel() const
qreal animationCacheRegionOfInterestMargin(bool defaultValue=false) const
qreal maxMergeAlpha() const
int swapWindowSize() const
void setFrameRenderingTimeout(int value)
void setMaxSwapSize(int value)
qreal memoryHardLimitPercent(bool requestDefault=false) const
void setUseLodForColorizeMask(bool value)
void setSchedulerBalancingRatio(qreal value)
qreal maxCollectAlpha() const
void setMemorySoftLimitPercent(qreal value)
bool showAdditionalOnionSkinsSettings(bool requestDefault=false) const
void setAnimationCacheDir(const QString &value)
void setSwapDir(const QString &swapDir)
void setSelectionOverlayMaskColor(const QColor &color)
void setAutoKeyModeDuplicate(bool value)
qreal selectionOutlineOpacity(bool defaultValue=false) const
void setSwapWindowSize(int value)
void setRenameDuplicatedLayers(bool value)
QColor onionSkinTintColorForward() const
bool renameMergedLayers(bool defaultValue=false) const
int frameRenderingTimeout(bool defaultValue=false) const
bool enablePerfLog(bool requestDefault=false) const
void setMaxBrushSize(int value)
void setDefaultFrameColorLabel(int label)
void setRenameMergedLayers(bool value)
void setNumberOfOnionSkins(int value)
int tilesSoftLimit() const
QString animationCacheDir(bool defaultValue=false) const
bool autoKeyModeDuplicate(bool requestDefault=false) const
void setDefaultProofingConfig(const KisProofingConfiguration &config)
QColor selectionOverlayMaskColor(bool defaultValue=false) const
qreal memorySoftLimitPercent(bool requestDefault=false) const
bool useLodForColorizeMask(bool requestDefault=false) const
void setMemoryHardLimitPercent(qreal value)
bool useOnDiskAnimationCacheSwapping(bool defaultValue=false) const
void setMemoryPoolLimitPercent(qreal value)
void setAnimationCacheRegionOfInterestMargin(qreal value)
void setShowAdditionalOnionSkinsSettings(bool value)
KisPropertiesConfigurationSP exportConfiguration(const QString &exportConfigId, bool defaultValue=false) const
void setOnionSkinTintColorBackward(const QColor &value)
static KisMacosSecurityBookmarkManager * instance()
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.
qreal legacyAdaptationState() const
void setOpacity(quint8 alpha)
void fromQColor(const QColor &c)
Convenient function for converting from a QColor.
void toQColor(QColor *c) const
a convenience method for the above.
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
#define INTENT_ABSOLUTE_COLORIMETRIC
#define INTENT_RELATIVE_COLORIMETRIC
QSharedPointer< T > toQShared(T *ptr)
static KoColorSpaceRegistry * instance()