File indexing completed on 2024-05-12 15:58:22
0001 /* 0002 * SPDX-FileCopyrightText: 2010 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KIS_IMAGE_CONFIG_H_ 0008 #define KIS_IMAGE_CONFIG_H_ 0009 0010 #include <kconfiggroup.h> 0011 #include "kritaimage_export.h" 0012 #include "KisProofingConfiguration.h" 0013 #include "kis_types.h" 0014 0015 class KRITAIMAGE_EXPORT KisImageConfig 0016 { 0017 public: 0018 KisImageConfig(bool readOnly); 0019 ~KisImageConfig(); 0020 0021 bool enableProgressReporting(bool requestDefault = false) const; 0022 void setEnableProgressReporting(bool value); 0023 0024 bool enablePerfLog(bool requestDefault = false) const; 0025 void setEnablePerfLog(bool value); 0026 0027 qreal transformMaskOffBoundsReadArea() const; 0028 0029 int updatePatchHeight() const; 0030 void setUpdatePatchHeight(int value); 0031 int updatePatchWidth() const; 0032 void setUpdatePatchWidth(int value); 0033 0034 qreal maxCollectAlpha() const; 0035 qreal maxMergeAlpha() const; 0036 qreal maxMergeCollectAlpha() const; 0037 qreal schedulerBalancingRatio() const; 0038 void setSchedulerBalancingRatio(qreal value); 0039 0040 int maxSwapSize(bool requestDefault = false) const; 0041 void setMaxSwapSize(int value); 0042 0043 int swapSlabSize() const; 0044 void setSwapSlabSize(int value); 0045 0046 int swapWindowSize() const; 0047 void setSwapWindowSize(int value); 0048 0049 int tilesHardLimit() const; // MiB 0050 int tilesSoftLimit() const; // MiB 0051 int poolLimit() const; // MiB 0052 0053 qreal memoryHardLimitPercent(bool requestDefault = false) const; // % of total RAM 0054 qreal memorySoftLimitPercent(bool requestDefault = false) const; // % of memoryHardLimitPercent() * (1 - 0.01 * memoryPoolLimitPercent()) 0055 qreal memoryPoolLimitPercent(bool requestDefault = false) const; // % of memoryHardLimitPercent() 0056 void setMemoryHardLimitPercent(qreal value); 0057 void setMemorySoftLimitPercent(qreal value); 0058 void setMemoryPoolLimitPercent(qreal value); 0059 0060 static int totalRAM(); // MiB 0061 0062 /** 0063 * @return a specific directory for the swapfile, if set. If not set, return an 0064 * empty QString and use the default KDE directory. 0065 */ 0066 QString swapDir(bool requestDefault = false); 0067 void setSwapDir(const QString &swapDir); 0068 0069 int numberOfOnionSkins() const; 0070 void setNumberOfOnionSkins(int value); 0071 0072 int onionSkinTintFactor() const; 0073 void setOnionSkinTintFactor(int value); 0074 0075 int onionSkinOpacity(int offset) const; 0076 void setOnionSkinOpacity(int offset, int value); 0077 0078 bool onionSkinState(int offset) const; 0079 void setOnionSkinState(int offset, bool value); 0080 0081 QColor onionSkinTintColorBackward() const; 0082 void setOnionSkinTintColorBackward(const QColor &value); 0083 0084 QColor onionSkinTintColorForward() const; 0085 void setOnionSkinTintColorForward(const QColor &value); 0086 0087 bool autoKeyEnabled(bool requestDefault = false) const; 0088 void setAutoKeyEnabled(bool value); 0089 0090 bool autoKeyModeDuplicate(bool requestDefault = false) const; 0091 void setAutoKeyModeDuplicate(bool value); 0092 0093 bool showAdditionalOnionSkinsSettings(bool requestDefault = false) const; 0094 void setShowAdditionalOnionSkinsSettings(bool value); 0095 0096 int defaultFrameColorLabel() const; 0097 void setDefaultFrameColorLabel(int label); 0098 0099 KisProofingConfigurationSP defaultProofingconfiguration(); 0100 void setDefaultProofingConfig(const KoColorSpace *proofingSpace, int proofingIntent, bool blackPointCompensation, KoColor warningColor, double adaptationState); 0101 0102 bool useLodForColorizeMask(bool requestDefault = false) const; 0103 void setUseLodForColorizeMask(bool value); 0104 0105 int maxNumberOfThreads(bool defaultValue = false) const; 0106 void setMaxNumberOfThreads(int value); 0107 0108 int frameRenderingClones(bool defaultValue = false) const; 0109 void setFrameRenderingClones(int value); 0110 0111 int frameRenderingTimeout(bool defaultValue = false) const; 0112 void setFrameRenderingTimeout(int value); 0113 0114 int fpsLimit(bool defaultValue = false) const; 0115 void setFpsLimit(int value); 0116 0117 bool useOnDiskAnimationCacheSwapping(bool defaultValue = false) const; 0118 void setUseOnDiskAnimationCacheSwapping(bool value); 0119 0120 QString animationCacheDir(bool defaultValue = false) const; 0121 void setAnimationCacheDir(const QString &value); 0122 0123 bool useAnimationCacheFrameSizeLimit(bool defaultValue = false) const; 0124 void setUseAnimationCacheFrameSizeLimit(bool value); 0125 0126 int animationCacheFrameSizeLimit(bool defaultValue = false) const; 0127 void setAnimationCacheFrameSizeLimit(int value); 0128 0129 bool useAnimationCacheRegionOfInterest(bool defaultValue = false) const; 0130 void setUseAnimationCacheRegionOfInterest(bool value); 0131 0132 qreal animationCacheRegionOfInterestMargin(bool defaultValue = false) const; 0133 void setAnimationCacheRegionOfInterestMargin(qreal value); 0134 0135 QColor selectionOverlayMaskColor(bool defaultValue = false) const; 0136 void setSelectionOverlayMaskColor(const QColor &color); 0137 0138 int maxBrushSize(bool defaultValue = false) const; 0139 void setMaxBrushSize(int value); 0140 0141 int maxMaskingBrushSize() const; 0142 0143 template<class T> 0144 void writeEntry(const QString& name, const T& value) { 0145 m_config.writeEntry(name, value); 0146 } 0147 0148 template<class T> 0149 void writeList(const QString& name, const QList<T>& value) { 0150 m_config.writeEntry(name, value); 0151 } 0152 0153 template<class T> 0154 T readEntry(const QString& name, const T& defaultValue=T()) { 0155 return m_config.readEntry(name, defaultValue); 0156 } 0157 0158 template<class T> 0159 QList<T> readList(const QString& name, const QList<T>& defaultValue=QList<T>()) { 0160 return m_config.readEntry(name, defaultValue); 0161 } 0162 0163 /* Per-File Export Configurations 0164 * Export configurations can optionally be saved into the file. If no configuration exists, 0165 * the user should try loading a configuration from the global system instead. 0166 */ 0167 QString exportConfigurationXML(const QString &exportConfigId, bool defaultValue = false) const; 0168 bool hasExportConfiguration(const QString& exportConfigID); 0169 KisPropertiesConfigurationSP exportConfiguration(const QString &exportConfigId, bool defaultValue = false) const; 0170 void setExportConfiguration(const QString &exportConfigId, KisPropertiesConfigurationSP properties); 0171 0172 static void resetConfig(); 0173 private: 0174 Q_DISABLE_COPY(KisImageConfig) 0175 0176 QString safelyGetWritableTempLocation(const QString &suffix, const QString &configKey, bool requestDefault) const; 0177 0178 private: 0179 KConfigGroup m_config; 0180 bool m_readOnly; 0181 }; 0182 0183 0184 #endif /* KIS_IMAGE_CONFIG_H_ */ 0185