File indexing completed on 2024-05-19 04:28:55

0001 /*
0002  *  SPDX-FileCopyrightText: 2002 Patrick Julien <freak@codepimps.org>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #include "kis_config.h"
0008 
0009 #include <QtGlobal>
0010 #include <QApplication>
0011 #include <QDesktopWidget>
0012 #include <QMutex>
0013 #include <QFont>
0014 #include <QThread>
0015 #include <QStringList>
0016 #include <QSettings>
0017 #include <QStandardPaths>
0018 #include <QDebug>
0019 #include <QFileInfo>
0020 #include <QScreen>
0021 
0022 #include <kconfig.h>
0023 
0024 #include <KisDocument.h>
0025 #include <KisResourceLocator.h>
0026 
0027 #include <KoColor.h>
0028 #include <KoColorSpaceRegistry.h>
0029 #include <KoColorModelStandardIds.h>
0030 #include <KoColorProfile.h>
0031 
0032 #include <kis_debug.h>
0033 #include <kis_types.h>
0034 
0035 #include "kis_canvas_resource_provider.h"
0036 #include "kis_config_notifier.h"
0037 #include "kis_snap_config.h"
0038 
0039 #include <config-ocio.h>
0040 
0041 #include <kis_color_manager.h>
0042 #include <KisOcioConfiguration.h>
0043 #include <KisUsageLogger.h>
0044 #include <kis_image_config.h>
0045 #include <KisCumulativeUndoData.h>
0046 
0047 #ifdef Q_OS_WIN
0048 #include "config_use_qt_tablet_windows.h"
0049 #endif
0050 
0051 KisConfig::KisConfig(bool readOnly)
0052     : m_cfg( KSharedConfig::openConfig()->group(""))
0053     , m_readOnly(readOnly)
0054 {
0055     if (!readOnly) {
0056         KIS_SAFE_ASSERT_RECOVER_RETURN(qApp && qApp->thread() == QThread::currentThread());
0057     }
0058 }
0059 
0060 KisConfig::~KisConfig()
0061 {
0062     if (m_readOnly) return;
0063 
0064     if (qApp && qApp->thread() != QThread::currentThread()) {
0065         dbgKrita.noquote() << "WARNING: KisConfig: requested config synchronization from nonGUI thread! Called from:" << kisBacktrace();
0066         return;
0067     }
0068 
0069     m_cfg.sync();
0070 }
0071 
0072 void KisConfig::logImportantSettings() const
0073 {
0074     KisUsageLogger::writeSysInfo("Current Settings\n");
0075     KisUsageLogger::writeSysInfo(QString("  Current Swap Location: %1").arg(KisImageConfig(true).swapDir()));
0076     KisUsageLogger::writeSysInfo(QString("  Current Swap Location writable: %1").arg(QFileInfo(KisImageConfig(true).swapDir()).isWritable() ? "true" : "false"));
0077     KisUsageLogger::writeSysInfo(QString("  Undo Enabled: %1").arg(undoEnabled()? "true" : "false"));
0078     KisUsageLogger::writeSysInfo(QString("  Undo Stack Limit: %1").arg(undoStackLimit()));
0079     KisUsageLogger::writeSysInfo(QString("  Use OpenGL: %1").arg(useOpenGL() ? "true" : "false"));
0080     KisUsageLogger::writeSysInfo(QString("  Use OpenGL Texture Buffer: %1").arg(useOpenGLTextureBuffer() ? "true" : "false"));
0081     KisUsageLogger::writeSysInfo(QString("  Disable Vector Optimizations: %1").arg(disableVectorOptimizations() ? "true" : "false"));
0082     KisUsageLogger::writeSysInfo(QString("  Disable AVX Optimizations: %1").arg(disableAVXOptimizations() ? "true" : "false"));
0083     KisUsageLogger::writeSysInfo(QString("  Canvas State: %1").arg(canvasState()));
0084     KisUsageLogger::writeSysInfo(QString("  Autosave Interval: %1").arg(autoSaveInterval()));
0085     KisUsageLogger::writeSysInfo(QString("  Use Backup Files: %1").arg(backupFile() ? "true" : "false"));
0086     KisUsageLogger::writeSysInfo(QString("  Number of Backups Kept: %1").arg(m_cfg.readEntry("numberofbackupfiles", 1)));
0087     KisUsageLogger::writeSysInfo(QString("  Backup File Suffix: %1").arg(m_cfg.readEntry("backupfilesuffix", "~")));
0088 
0089     QString backupDir;
0090     switch(m_cfg.readEntry("backupfilelocation", 0)) {
0091     case 1:
0092         backupDir = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
0093         break;
0094     case 2:
0095         backupDir = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
0096         break;
0097     default:
0098         // Do nothing: the empty string is user file location
0099         backupDir = "Same Folder as the File";
0100     }
0101     KisUsageLogger::writeSysInfo(QString("  Backup Location: %1").arg(backupDir));
0102     KisUsageLogger::writeSysInfo(QString("  Backup Location writable: %1").arg(QFileInfo(backupDir).isWritable() ? "true" : "false"));
0103     KisUsageLogger::writeSysInfo(QString("  Resource Location: %1").arg(m_cfg.readEntry(KisResourceLocator::resourceLocationKey)));
0104 
0105     KisUsageLogger::writeSysInfo(QString("  Use Win8 Pointer Input: %1").arg(useWin8PointerInput() ? "true" : "false"));
0106     KisUsageLogger::writeSysInfo(QString("  Use RightMiddleTabletButton Workaround: %1").arg(useRightMiddleTabletButtonWorkaround() ? "true" : "false"));
0107     KisUsageLogger::writeSysInfo(QString("  Levels of Detail Enabled: %1").arg(levelOfDetailEnabled() ? "true" : "false"));
0108     KisUsageLogger::writeSysInfo(QString("  Use Zip64: %1").arg(useZip64() ? "true" : "false"));
0109 
0110     KisUsageLogger::writeSysInfo("\n");
0111 }
0112 
0113 bool KisConfig::disableTouchOnCanvas(bool defaultValue) const
0114 {
0115     return (defaultValue ? false : m_cfg.readEntry("disableTouchOnCanvas", false));
0116 }
0117 
0118 void KisConfig::setDisableTouchOnCanvas(bool value) const
0119 {
0120     m_cfg.writeEntry("disableTouchOnCanvas", value);
0121 }
0122 
0123 bool KisConfig::useProjections(bool defaultValue) const
0124 {
0125     return (defaultValue ? true : m_cfg.readEntry("useProjections", true));
0126 }
0127 
0128 void KisConfig::setUseProjections(bool useProj) const
0129 {
0130     m_cfg.writeEntry("useProjections", useProj);
0131 }
0132 
0133 bool KisConfig::undoEnabled(bool defaultValue) const
0134 {
0135     return (defaultValue ? true : m_cfg.readEntry("undoEnabled", true));
0136 }
0137 
0138 void KisConfig::setUndoEnabled(bool undo) const
0139 {
0140     m_cfg.writeEntry("undoEnabled", undo);
0141 }
0142 
0143 int KisConfig::undoStackLimit(bool defaultValue) const
0144 {
0145     return (defaultValue ? 200 : m_cfg.readEntry("undoStackLimit", 200));
0146 }
0147 
0148 void KisConfig::setUndoStackLimit(int limit) const
0149 {
0150     m_cfg.writeEntry("undoStackLimit", limit);
0151 }
0152 
0153 bool KisConfig::useCumulativeUndoRedo(bool defaultValue) const
0154 {
0155     return (defaultValue ? false : m_cfg.readEntry("useCumulativeUndoRedo",false));
0156 }
0157 
0158 void KisConfig::setCumulativeUndoRedo(bool value)
0159 {
0160     m_cfg.writeEntry("useCumulativeUndoRedo", value);
0161 }
0162 
0163 KisCumulativeUndoData KisConfig::cumulativeUndoData(bool defaultValue) const
0164 {
0165     if (defaultValue) {
0166         return KisCumulativeUndoData::defaultValue;
0167     }
0168 
0169     KisCumulativeUndoData data;
0170     data.read(&m_cfg);
0171     return data;
0172 }
0173 
0174 void KisConfig::setCumulativeUndoData(KisCumulativeUndoData value)
0175 {
0176     value.write(&m_cfg);
0177 }
0178 
0179 qint32 KisConfig::defImageWidth(bool defaultValue) const
0180 {
0181     return (defaultValue ? 2480 : m_cfg.readEntry("imageWidthDef", 2480));
0182 }
0183 
0184 qint32 KisConfig::defImageHeight(bool defaultValue) const
0185 {
0186     return (defaultValue ? 3508 : m_cfg.readEntry("imageHeightDef", 3508));
0187 }
0188 
0189 qreal KisConfig::defImageResolution(bool defaultValue) const
0190 {
0191     return (defaultValue ? 300.0 : m_cfg.readEntry("imageResolutionDef", 300.0)) / 72.0;
0192 }
0193 
0194 QString KisConfig::defColorModel(bool defaultValue) const
0195 {
0196     return (defaultValue ? KoColorSpaceRegistry::instance()->rgb8()->colorModelId().id()
0197                         : m_cfg.readEntry("colorModelDef", KoColorSpaceRegistry::instance()->rgb8()->colorModelId().id()));
0198 }
0199 
0200 void KisConfig::defColorModel(const QString & model) const
0201 {
0202     m_cfg.writeEntry("colorModelDef", model);
0203 }
0204 
0205 QString KisConfig::defaultColorDepth(bool defaultValue) const
0206 {
0207     return (defaultValue ? KoColorSpaceRegistry::instance()->rgb8()->colorDepthId().id()
0208                         : m_cfg.readEntry("colorDepthDef", KoColorSpaceRegistry::instance()->rgb8()->colorDepthId().id()));
0209 }
0210 
0211 void KisConfig::setDefaultColorDepth(const QString & depth) const
0212 {
0213     m_cfg.writeEntry("colorDepthDef", depth);
0214 }
0215 
0216 QString KisConfig::defColorProfile(bool defaultValue) const
0217 {
0218     return (defaultValue ? KoColorSpaceRegistry::instance()->rgb8()->profile()->name() :
0219                            m_cfg.readEntry("colorProfileDef",
0220                                            KoColorSpaceRegistry::instance()->rgb8()->profile()->name()));
0221 }
0222 
0223 void KisConfig::defColorProfile(const QString & profile) const
0224 {
0225     m_cfg.writeEntry("colorProfileDef", profile);
0226 }
0227 
0228 void KisConfig::defImageWidth(qint32 width) const
0229 {
0230     m_cfg.writeEntry("imageWidthDef", width);
0231 }
0232 
0233 void KisConfig::defImageHeight(qint32 height) const
0234 {
0235     m_cfg.writeEntry("imageHeightDef", height);
0236 }
0237 
0238 void KisConfig::defImageResolution(qreal res) const
0239 {
0240     m_cfg.writeEntry("imageResolutionDef", res*72.0);
0241 }
0242 
0243 int KisConfig::preferredVectorImportResolutionPPI(bool defaultValue) const
0244 {
0245     return defaultValue ? 100.0 : m_cfg.readEntry("preferredVectorImportResolution", 100.0);
0246 }
0247 
0248 void KisConfig::setPreferredVectorImportResolutionPPI(int value) const
0249 {
0250     m_cfg.writeEntry("preferredVectorImportResolution", value);
0251 }
0252 
0253 bool KisConfig::useDefaultColorSpace(bool defaultvalue) const
0254 {
0255     return (defaultvalue?   false:  m_cfg.readEntry("useDefaultColorSpace", false));
0256 }
0257 
0258 void KisConfig::setUseDefaultColorSpace(bool value) const
0259 {
0260     m_cfg.writeEntry("useDefaultColorSpace", value);
0261 }
0262 
0263 // brush cursor settings
0264 
0265 void cleanOldCursorStyleKeys(KConfigGroup &cfg)
0266 {
0267     if (cfg.hasKey("newCursorStyle") &&
0268         cfg.hasKey("newOutlineStyle")) {
0269 
0270         cfg.deleteEntry("cursorStyleDef");
0271     }
0272 }
0273 
0274 CursorStyle KisConfig::newCursorStyle(bool defaultValue) const
0275 {
0276     if (defaultValue) {
0277         return CURSOR_STYLE_NO_CURSOR;
0278     }
0279 
0280 
0281     int style = m_cfg.readEntry("newCursorStyle", int(-1));
0282 
0283     if (style < 0) {
0284         // old style format
0285         style = m_cfg.readEntry("cursorStyleDef", int(OLD_CURSOR_STYLE_OUTLINE));
0286 
0287         switch (style) {
0288         case OLD_CURSOR_STYLE_TOOLICON:
0289             style = CURSOR_STYLE_TOOLICON;
0290             break;
0291         case OLD_CURSOR_STYLE_CROSSHAIR:
0292         case OLD_CURSOR_STYLE_OUTLINE_CENTER_CROSS:
0293             style = CURSOR_STYLE_CROSSHAIR;
0294             break;
0295         case OLD_CURSOR_STYLE_POINTER:
0296             style = CURSOR_STYLE_POINTER;
0297             break;
0298         case OLD_CURSOR_STYLE_OUTLINE:
0299         case OLD_CURSOR_STYLE_NO_CURSOR:
0300             style = CURSOR_STYLE_NO_CURSOR;
0301             break;
0302         case OLD_CURSOR_STYLE_SMALL_ROUND:
0303         case OLD_CURSOR_STYLE_OUTLINE_CENTER_DOT:
0304             style = CURSOR_STYLE_SMALL_ROUND;
0305             break;
0306         case OLD_CURSOR_STYLE_TRIANGLE_RIGHTHANDED:
0307         case OLD_CURSOR_STYLE_OUTLINE_TRIANGLE_RIGHTHANDED:
0308             style = CURSOR_STYLE_TRIANGLE_RIGHTHANDED;
0309             break;
0310         case OLD_CURSOR_STYLE_TRIANGLE_LEFTHANDED:
0311         case OLD_CURSOR_STYLE_OUTLINE_TRIANGLE_LEFTHANDED:
0312             style = CURSOR_STYLE_TRIANGLE_LEFTHANDED;
0313             break;
0314         default:
0315             style = -1;
0316         }
0317     }
0318 
0319     cleanOldCursorStyleKeys(m_cfg);
0320 
0321     // compatibility with future versions
0322     if (style < 0 || style >= N_CURSOR_STYLE_SIZE) {
0323         style = CURSOR_STYLE_NO_CURSOR;
0324     }
0325 
0326     return (CursorStyle) style;
0327 }
0328 
0329 void KisConfig::setNewCursorStyle(CursorStyle style)
0330 {
0331     m_cfg.writeEntry("newCursorStyle", (int)style);
0332 }
0333 
0334 QColor KisConfig::getCursorMainColor(bool defaultValue) const
0335 {
0336     QColor col;
0337     col.setRgbF(0.501961, 1.0, 0.501961);
0338     return (defaultValue ? col : m_cfg.readEntry("cursorMaincColor", col));
0339 }
0340 
0341 void KisConfig::setCursorMainColor(const QColor &v) const
0342 {
0343     m_cfg.writeEntry("cursorMaincColor", v);
0344 }
0345 
0346 OutlineStyle KisConfig::newOutlineStyle(bool defaultValue) const
0347 {
0348     if (defaultValue) {
0349         return OUTLINE_FULL;
0350     }
0351 
0352     int style = m_cfg.readEntry("newOutlineStyle", int(-1));
0353 
0354     if (style < 0) {
0355         // old style format
0356         style = m_cfg.readEntry("cursorStyleDef", int(OLD_CURSOR_STYLE_OUTLINE));
0357 
0358         switch (style) {
0359         case OLD_CURSOR_STYLE_TOOLICON:
0360         case OLD_CURSOR_STYLE_CROSSHAIR:
0361         case OLD_CURSOR_STYLE_POINTER:
0362         case OLD_CURSOR_STYLE_NO_CURSOR:
0363         case OLD_CURSOR_STYLE_SMALL_ROUND:
0364         case OLD_CURSOR_STYLE_TRIANGLE_RIGHTHANDED:
0365         case OLD_CURSOR_STYLE_TRIANGLE_LEFTHANDED:
0366             style = OUTLINE_NONE;
0367             break;
0368         case OLD_CURSOR_STYLE_OUTLINE:
0369         case OLD_CURSOR_STYLE_OUTLINE_CENTER_DOT:
0370         case OLD_CURSOR_STYLE_OUTLINE_CENTER_CROSS:
0371         case OLD_CURSOR_STYLE_OUTLINE_TRIANGLE_RIGHTHANDED:
0372         case OLD_CURSOR_STYLE_OUTLINE_TRIANGLE_LEFTHANDED:
0373             style = OUTLINE_FULL;
0374             break;
0375         default:
0376             style = -1;
0377         }
0378     }
0379 
0380     cleanOldCursorStyleKeys(m_cfg);
0381 
0382     // compatibility with future versions
0383     if (style < 0 || style >= N_OUTLINE_STYLE_SIZE) {
0384         style = OUTLINE_FULL;
0385     }
0386 
0387     return (OutlineStyle) style;
0388 }
0389 
0390 void KisConfig::setNewOutlineStyle(OutlineStyle style)
0391 {
0392     m_cfg.writeEntry("newOutlineStyle", (int)style);
0393 }
0394 
0395 OutlineStyle KisConfig::lastUsedOutlineStyle(bool defaultValue) const
0396 {
0397     if (defaultValue) {
0398         return OUTLINE_NONE;
0399     }
0400 
0401     int style = m_cfg.readEntry("lastUsedOutlineStyle", int(-1));
0402 
0403     return (OutlineStyle) style;
0404 }
0405 
0406 void KisConfig::setLastUsedOutlineStyle(OutlineStyle style)
0407 {
0408     m_cfg.writeEntry("lastUsedOutlineStyle", (int)style);
0409 }
0410 
0411 // eraser cursor settings
0412 
0413 bool KisConfig::separateEraserCursor(bool defaultValue) const
0414 {
0415     return (defaultValue ? false : m_cfg.readEntry("separateEraserCursor", false));
0416 }
0417 
0418 void KisConfig::setSeparateEraserCursor(bool value) const
0419 {
0420     m_cfg.writeEntry("separateEraserCursor", value);
0421 }
0422 
0423 CursorStyle KisConfig::eraserCursorStyle(bool defaultValue) const
0424 {
0425     if (defaultValue) {
0426         return CURSOR_STYLE_ERASER;
0427     }
0428 
0429     int style = m_cfg.readEntry("eraserCursorStyle", int(-1));
0430 
0431     // compatibility with future versions
0432     if (style < 0 || style >= N_CURSOR_STYLE_SIZE) {
0433         style = CURSOR_STYLE_ERASER;
0434     }
0435 
0436     return (CursorStyle) style;
0437 }
0438 
0439 void KisConfig::setEraserCursorStyle(CursorStyle style)
0440 {
0441     m_cfg.writeEntry("eraserCursorStyle", (int)style);
0442 }
0443 
0444 QColor KisConfig::getEraserCursorMainColor(bool defaultValue) const
0445 {
0446     QColor col;
0447     col.setRgbF(0.501961, 1.0, 0.501961);
0448     return (defaultValue ? col : m_cfg.readEntry("eraserCursorMaincColor", col));
0449 }
0450 
0451 void KisConfig::setEraserCursorMainColor(const QColor &v) const
0452 {
0453     m_cfg.writeEntry("eraserCursorMaincColor", v);
0454 }
0455 
0456 OutlineStyle KisConfig::eraserOutlineStyle(bool defaultValue) const
0457 {
0458     if (defaultValue) {
0459         return OUTLINE_FULL;
0460     }
0461 
0462     int style = m_cfg.readEntry("eraserOutlineStyle", int(-1));
0463 
0464     // compatibility with future versions
0465     if (style < 0 || style >= N_OUTLINE_STYLE_SIZE) {
0466         style = OUTLINE_FULL;
0467     }
0468 
0469     return (OutlineStyle) style;
0470 }
0471 
0472 void KisConfig::setEraserOutlineStyle(OutlineStyle style)
0473 {
0474     m_cfg.writeEntry("eraserOutlineStyle", (int)style);
0475 }
0476 
0477 QRect KisConfig::colorPreviewRect() const
0478 {
0479     return m_cfg.readEntry("colorPreviewRect", QVariant(QRect(32, 32, 48, 48))).toRect();
0480 }
0481 
0482 void KisConfig::setColorPreviewRect(const QRect &rect)
0483 {
0484     m_cfg.writeEntry("colorPreviewRect", QVariant(rect));
0485 }
0486 
0487 bool KisConfig::useDirtyPresets(bool defaultValue) const
0488 {
0489    return (defaultValue ? false : m_cfg.readEntry("useDirtyPresets", true));
0490 }
0491 void KisConfig::setUseDirtyPresets(bool value)
0492 {
0493     m_cfg.writeEntry("useDirtyPresets",value);
0494     KisConfigNotifier::instance()->notifyConfigChanged();
0495 }
0496 
0497 bool KisConfig::useEraserBrushSize(bool defaultValue) const
0498 {
0499    return (defaultValue ? false : m_cfg.readEntry("useEraserBrushSize", false));
0500 }
0501 
0502 void KisConfig::setUseEraserBrushSize(bool value)
0503 {
0504     m_cfg.writeEntry("useEraserBrushSize",value);
0505     KisConfigNotifier::instance()->notifyConfigChanged();
0506 }
0507 
0508 bool KisConfig::useEraserBrushOpacity(bool defaultValue) const
0509 {
0510    return (defaultValue ? false : m_cfg.readEntry("useEraserBrushOpacity",false));
0511 }
0512 
0513 void KisConfig::setUseEraserBrushOpacity(bool value)
0514 {
0515     m_cfg.writeEntry("useEraserBrushOpacity",value);
0516     KisConfigNotifier::instance()->notifyConfigChanged();
0517 }
0518 
0519 QPoint KisConfig::getDefaultGridSpacing(bool defaultValue) const
0520 {
0521     return (defaultValue ? QPoint(16, 16) : m_cfg.readEntry("defaultGridSpacing", QPoint(16, 16)));
0522 }
0523 
0524 void KisConfig::setDefaultGridSpacing(QPoint gridSpacing)
0525 {
0526     m_cfg.writeEntry("defaultGridSpacing", gridSpacing);
0527 }
0528 
0529 QString KisConfig::getMDIBackgroundColor(bool defaultValue) const
0530 {
0531     QColor col(77, 77, 77);
0532     KoColor kol(KoColorSpaceRegistry::instance()->rgb8());
0533     kol.fromQColor(col);
0534     QString xml = kol.toXML();
0535     return (defaultValue ? xml : m_cfg.readEntry("mdiBackgroundColorXML", xml));
0536 }
0537 
0538 void KisConfig::setMDIBackgroundColor(const QString &v) const
0539 {
0540     m_cfg.writeEntry("mdiBackgroundColorXML", v);
0541 }
0542 
0543 QString KisConfig::getMDIBackgroundImage(bool defaultValue) const
0544 {
0545     return (defaultValue ? "" : m_cfg.readEntry("mdiBackgroundImage", ""));
0546 }
0547 
0548 void KisConfig::setMDIBackgroundImage(const QString &filename) const
0549 {
0550     m_cfg.writeEntry("mdiBackgroundImage", filename);
0551 }
0552 
0553 QString KisConfig::monitorProfile(int screen) const
0554 {
0555     // Note: keep this in sync with the default profile for the RGB colorspaces!
0556     const QString defaultProfile = "sRGB-elle-V2-srgbtrc.icc";
0557 
0558     QString profile;
0559     const QString screenIdentifier = getScreenStringIdentfier(screen);
0560     const QString screenIdentifierKey = "monitorProfile" + screenIdentifier;
0561 
0562     /**
0563      * Screen identifier may be empty (e.g. on macOS), so the identifier
0564      * key will be plain 'monitorProfile', which is the key fot the **first**
0565      * display's profile, so we shouldn't fall into this trap...
0566      */
0567     if (!screenIdentifier.isEmpty() && m_cfg.hasKey(screenIdentifierKey)) {
0568         profile = m_cfg.readEntry(screenIdentifierKey, defaultProfile);
0569     } else {
0570         profile = m_cfg.readEntry("monitorProfile" + QString(screen == 0 ? "": QString("_%1").arg(screen)), defaultProfile);
0571     }
0572 
0573     //dbgKrita << "KisConfig::monitorProfile()" << profile;
0574     return profile;
0575 }
0576 
0577 QString KisConfig::monitorForScreen(int screen, const QString &defaultMonitor, bool defaultValue) const
0578 {
0579     return (defaultValue ? defaultMonitor
0580                          : m_cfg.readEntry(QString("monitor_for_screen_%1").arg(screen), defaultMonitor));
0581 }
0582 
0583 void KisConfig::setMonitorForScreen(int screen, const QString& monitor)
0584 {
0585     m_cfg.writeEntry(QString("monitor_for_screen_%1").arg(screen), monitor);
0586 }
0587 
0588 void KisConfig::setMonitorProfile(int screen, const QString & monitorProfile, bool override) const
0589 {
0590     m_cfg.writeEntry("monitorProfile/OverrideX11", override);
0591     m_cfg.writeEntry("monitorProfile" + QString(screen == 0 ? "": QString("_%1").arg(screen)), monitorProfile);
0592     if (!getScreenStringIdentfier(screen).isEmpty()) {
0593         m_cfg.writeEntry("monitorProfile" + getScreenStringIdentfier(screen), monitorProfile);
0594     }
0595 }
0596 
0597 // TODO: rename into getSystemScreenProfile
0598 const KoColorProfile *KisConfig::getScreenProfile(int screen)
0599 {
0600     if (screen < 0) return 0;
0601 
0602     KisConfig cfg(true);
0603     QString monitorId;
0604     if (KisColorManager::instance()->devices().size() > screen) {
0605         monitorId = cfg.monitorForScreen(screen, KisColorManager::instance()->devices()[screen]);
0606     }
0607     //dbgKrita << "getScreenProfile(). Screen" << screen << "monitor id" << monitorId;
0608 
0609     if (monitorId.isEmpty()) {
0610         return 0;
0611     }
0612 
0613     QByteArray bytes = KisColorManager::instance()->displayProfile(monitorId);
0614 
0615     //dbgKrita << "\tgetScreenProfile()" << bytes.size();
0616     const KoColorProfile * profile = 0;
0617     if (bytes.length() > 0) {
0618         profile = KoColorSpaceRegistry::instance()->createColorProfile(RGBAColorModelID.id(), Integer8BitsColorDepthID.id(), bytes);
0619         //dbgKrita << "\tKisConfig::getScreenProfile for screen" << screen << profile->name();
0620     }
0621     return profile;
0622 }
0623 
0624 const KoColorProfile *KisConfig::displayProfile(int screen) const
0625 {
0626     if (screen < 0) return 0;
0627 
0628     // if the user plays with the settings, they can override the display profile, in which case
0629     // we don't want the system setting.
0630     bool override = useSystemMonitorProfile();
0631     //dbgKrita << "KisConfig::displayProfile(). Override X11:" << override;
0632     const KoColorProfile *profile = 0;
0633     if (override) {
0634         //dbgKrita << "\tGoing to get the screen profile";
0635         profile = KisConfig::getScreenProfile(screen);
0636     }
0637 
0638     // if it fails. check the configuration
0639     if (!profile || !profile->isSuitableForDisplay()) {
0640         //dbgKrita << "\tGoing to get the monitor profile";
0641         QString monitorProfileName = monitorProfile(screen);
0642         //dbgKrita << "\t\tmonitorProfileName:" << monitorProfileName;
0643         if (!monitorProfileName.isEmpty()) {
0644             profile = KoColorSpaceRegistry::instance()->profileByName(monitorProfileName);
0645         }
0646         if (profile) {
0647             //dbgKrita << "\t\tsuitable for display" << profile->isSuitableForDisplay();
0648         }
0649         else {
0650             //dbgKrita << "\t\tstill no profile";
0651         }
0652     }
0653     // if we still don't have a profile, or the profile isn't suitable for display,
0654     // we need to get a last-resort profile. the built-in sRGB is a good choice then.
0655     if (!profile || !profile->isSuitableForDisplay()) {
0656         //dbgKrita << "\tnothing worked, going to get sRGB built-in";
0657         profile = KoColorSpaceRegistry::instance()->profileByName("sRGB Built-in");
0658     }
0659 
0660     if (profile) {
0661         //dbgKrita << "\tKisConfig::displayProfile for screen" << screen << "is" << profile->name();
0662     }
0663     else {
0664         //dbgKrita << "\tCouldn't get a display profile at all";
0665     }
0666 
0667     return profile;
0668 }
0669 
0670 const QString KisConfig::getScreenStringIdentfier(int screenNo) const {
0671     if (screenNo < 0 || screenNo >= QGuiApplication::screens().length()) {
0672         return QString();
0673     }
0674     QScreen* screen = QGuiApplication::screens()[screenNo];
0675 
0676     QString manufacturer = screen->manufacturer();
0677     QString model = screen->model();
0678     QString serialNumber = screen->serialNumber();
0679 
0680     if (manufacturer == "" && model == "" && serialNumber == "") {
0681         return QString(); // it would be scary to base the profile just on resolution
0682     }
0683 
0684     QString identifier = QStringList({manufacturer, model, serialNumber}).join("_");
0685     return identifier;
0686 }
0687 
0688 QString KisConfig::workingColorSpace(bool defaultValue) const
0689 {
0690     return (defaultValue ? "RGBA" : m_cfg.readEntry("workingColorSpace", "RGBA"));
0691 }
0692 
0693 void KisConfig::setWorkingColorSpace(const QString & workingColorSpace) const
0694 {
0695     m_cfg.writeEntry("workingColorSpace", workingColorSpace);
0696 }
0697 
0698 QString KisConfig::printerColorSpace(bool /*defaultValue*/) const
0699 {
0700     //TODO currently only rgb8 is supported
0701     //return (defaultValue ? "RGBA" : m_cfg.readEntry("printerColorSpace", "RGBA"));
0702     return QString("RGBA");
0703 }
0704 
0705 void KisConfig::setPrinterColorSpace(const QString & printerColorSpace) const
0706 {
0707     m_cfg.writeEntry("printerColorSpace", printerColorSpace);
0708 }
0709 
0710 
0711 QString KisConfig::printerProfile(bool defaultValue) const
0712 {
0713     return (defaultValue ? "" : m_cfg.readEntry("printerProfile", ""));
0714 }
0715 
0716 void KisConfig::setPrinterProfile(const QString & printerProfile) const
0717 {
0718     m_cfg.writeEntry("printerProfile", printerProfile);
0719 }
0720 
0721 
0722 bool KisConfig::useBlackPointCompensation(bool defaultValue) const
0723 {
0724     return (defaultValue ? true : m_cfg.readEntry("useBlackPointCompensation", true));
0725 }
0726 
0727 void KisConfig::setUseBlackPointCompensation(bool useBlackPointCompensation) const
0728 {
0729     m_cfg.writeEntry("useBlackPointCompensation", useBlackPointCompensation);
0730 }
0731 
0732 bool KisConfig::allowLCMSOptimization(bool defaultValue) const
0733 {
0734     return (defaultValue ? true : m_cfg.readEntry("allowLCMSOptimization", true));
0735 }
0736 
0737 void KisConfig::setAllowLCMSOptimization(bool allowLCMSOptimization)
0738 {
0739     m_cfg.writeEntry("allowLCMSOptimization", allowLCMSOptimization);
0740 }
0741 
0742 bool KisConfig::forcePaletteColors(bool defaultValue) const
0743 {
0744     return (defaultValue ? false : m_cfg.readEntry("colorsettings/forcepalettecolors", false));
0745 }
0746 
0747 void KisConfig::setForcePaletteColors(bool forcePaletteColors)
0748 {
0749     m_cfg.writeEntry("colorsettings/forcepalettecolors", forcePaletteColors);
0750 }
0751 
0752 bool KisConfig::showRulers(bool defaultValue) const
0753 {
0754     return (defaultValue ? false : m_cfg.readEntry("showrulers", false));
0755 }
0756 
0757 void KisConfig::setShowRulers(bool rulers) const
0758 {
0759     m_cfg.writeEntry("showrulers", rulers);
0760 }
0761 
0762 bool KisConfig::forceShowSaveMessages(bool defaultValue) const
0763 {
0764     return (defaultValue ? false : m_cfg.readEntry("forceShowSaveMessages", false));
0765 }
0766 
0767 void KisConfig::setForceShowSaveMessages(bool value) const
0768 {
0769     m_cfg.writeEntry("forceShowSaveMessages", value);
0770 }
0771 
0772 bool KisConfig::forceShowAutosaveMessages(bool defaultValue) const
0773 {
0774     return (defaultValue ? false : m_cfg.readEntry("forceShowAutosaveMessages", false));
0775 }
0776 
0777 void KisConfig::setForceShowAutosaveMessages(bool value) const
0778 {
0779     m_cfg.writeEntry("forceShowAutosaveMessages", value);
0780 }
0781 
0782 bool KisConfig::rulersTrackMouse(bool defaultValue) const
0783 {
0784     return (defaultValue ? true : m_cfg.readEntry("rulersTrackMouse", true));
0785 }
0786 
0787 void KisConfig::setRulersTrackMouse(bool value) const
0788 {
0789     m_cfg.writeEntry("rulersTrackMouse", value);
0790 }
0791 
0792 qint32 KisConfig::pasteBehaviour(bool defaultValue) const
0793 {
0794     return (defaultValue ? 2 : m_cfg.readEntry("pasteBehaviour", 2));
0795 }
0796 
0797 void KisConfig::setPasteBehaviour(qint32 renderIntent) const
0798 {
0799     m_cfg.writeEntry("pasteBehaviour", renderIntent);
0800 }
0801 
0802 qint32 KisConfig::pasteFormat(bool defaultValue) const
0803 {
0804     return defaultValue ? 0 : m_cfg.readEntry("pasteFormat", 0);
0805 }
0806 
0807 void KisConfig::setPasteFormat(qint32 format)
0808 {
0809     m_cfg.writeEntry("pasteFormat", format);
0810 }
0811 
0812 qint32 KisConfig::monitorRenderIntent(bool defaultValue) const
0813 {
0814     qint32 intent = m_cfg.readEntry("renderIntent", INTENT_PERCEPTUAL);
0815     if (intent > 3) intent = 3;
0816     if (intent < 0) intent = 0;
0817     return (defaultValue ? INTENT_PERCEPTUAL : intent);
0818 }
0819 
0820 void KisConfig::setRenderIntent(qint32 renderIntent) const
0821 {
0822     if (renderIntent > 3) renderIntent = 3;
0823     if (renderIntent < 0) renderIntent = 0;
0824     m_cfg.writeEntry("renderIntent", renderIntent);
0825 }
0826 
0827 bool KisConfig::useOpenGL(bool defaultValue) const
0828 {
0829     if (defaultValue) {
0830         return true;
0831     }
0832 
0833     const QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
0834     QSettings kritarc(configPath + QStringLiteral("/kritadisplayrc"), QSettings::IniFormat);
0835 
0836     return kritarc.value("OpenGLRenderer", "auto").toString() != "none";
0837 }
0838 
0839 void KisConfig::disableOpenGL() const
0840 {
0841     const QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
0842     QSettings kritarc(configPath + QStringLiteral("/kritadisplayrc"), QSettings::IniFormat);
0843 
0844     kritarc.setValue("OpenGLRenderer", "none");
0845 }
0846 
0847 int KisConfig::openGLFilteringMode(bool defaultValue) const
0848 {
0849     return (defaultValue ? 3 : m_cfg.readEntry("OpenGLFilterMode", 3));
0850 }
0851 
0852 void KisConfig::setOpenGLFilteringMode(int filteringMode)
0853 {
0854     m_cfg.writeEntry("OpenGLFilterMode", filteringMode);
0855 }
0856 
0857 void KisConfig::setWidgetStyle(QString name)
0858 {
0859     m_cfg.writeEntry("widgetStyle", name);
0860 }
0861 
0862 QString KisConfig::widgetStyle(bool defaultValue)
0863 {
0864     return (defaultValue ? "" : m_cfg.readEntry("widgetStyle", ""));
0865 }
0866 
0867 bool KisConfig::useOpenGLTextureBuffer(bool defaultValue) const
0868 {
0869     return (defaultValue ? true : m_cfg.readEntry("useOpenGLTextureBuffer", true));
0870 }
0871 
0872 void KisConfig::setUseOpenGLTextureBuffer(bool useBuffer)
0873 {
0874     m_cfg.writeEntry("useOpenGLTextureBuffer", useBuffer);
0875 }
0876 
0877 int KisConfig::openGLTextureSize(bool defaultValue) const
0878 {
0879     return (defaultValue ? 256 : m_cfg.readEntry("textureSize", 256));
0880 }
0881 
0882 bool KisConfig::forceOpenGLFenceWorkaround(bool defaultValue) const
0883 {
0884     return (defaultValue ? false : m_cfg.readEntry("forceOpenGLFenceWorkaround", false));
0885 }
0886 
0887 int KisConfig::numMipmapLevels(bool defaultValue) const
0888 {
0889     return (defaultValue ? 4 : m_cfg.readEntry("numMipmapLevels", 4));
0890 }
0891 
0892 int KisConfig::textureOverlapBorder() const
0893 {
0894     return 1 << qMax(0, numMipmapLevels());
0895 }
0896 
0897 quint32 KisConfig::getGridMainStyle(bool defaultValue) const
0898 {
0899     int v = m_cfg.readEntry("gridmainstyle", 0);
0900     v = qBound(0, v, 2);
0901     return (defaultValue ? 0 : v);
0902 }
0903 
0904 void KisConfig::setGridMainStyle(quint32 v) const
0905 {
0906     m_cfg.writeEntry("gridmainstyle", v);
0907 }
0908 
0909 quint32 KisConfig::getGridSubdivisionStyle(bool defaultValue) const
0910 {
0911     quint32 v = m_cfg.readEntry("gridsubdivisionstyle", 1);
0912     if (v > 2) v = 2;
0913     return (defaultValue ? 1 : v);
0914 }
0915 
0916 void KisConfig::setGridSubdivisionStyle(quint32 v) const
0917 {
0918     m_cfg.writeEntry("gridsubdivisionstyle", v);
0919 }
0920 
0921 QColor KisConfig::getGridMainColor(bool defaultValue) const
0922 {
0923     QColor col(99, 99, 99);
0924     return (defaultValue ? col : m_cfg.readEntry("gridmaincolor", col));
0925 }
0926 
0927 void KisConfig::setGridMainColor(const QColor & v) const
0928 {
0929     m_cfg.writeEntry("gridmaincolor", v);
0930 }
0931 
0932 QColor KisConfig::getGridSubdivisionColor(bool defaultValue) const
0933 {
0934     QColor col(150, 150, 150);
0935     return (defaultValue ? col : m_cfg.readEntry("gridsubdivisioncolor", col));
0936 }
0937 
0938 void KisConfig::setGridSubdivisionColor(const QColor & v) const
0939 {
0940     m_cfg.writeEntry("gridsubdivisioncolor", v);
0941 }
0942 
0943 QColor KisConfig::getPixelGridColor(bool defaultValue) const
0944 {
0945     QColor col(255, 255, 255);
0946     return (defaultValue ? col : m_cfg.readEntry("pixelGridColor", col));
0947 }
0948 
0949 void KisConfig::setPixelGridColor(const QColor & v) const
0950 {
0951     m_cfg.writeEntry("pixelGridColor", v);
0952 }
0953 
0954 qreal KisConfig::getPixelGridDrawingThreshold(bool defaultValue) const
0955 {
0956     qreal border = 24.0f;
0957     return (defaultValue ? border : m_cfg.readEntry("pixelGridDrawingThreshold", border));
0958 }
0959 
0960 void KisConfig::setPixelGridDrawingThreshold(qreal v) const
0961 {
0962     m_cfg.writeEntry("pixelGridDrawingThreshold", v);
0963 }
0964 
0965 bool KisConfig::pixelGridEnabled(bool defaultValue) const
0966 {
0967     bool enabled = true;
0968     return (defaultValue ? enabled : m_cfg.readEntry("pixelGridEnabled", enabled));
0969 }
0970 
0971 void KisConfig::enablePixelGrid(bool v) const
0972 {
0973     m_cfg.writeEntry("pixelGridEnabled", v);
0974 }
0975 
0976 quint32 KisConfig::guidesLineStyle(bool defaultValue) const
0977 {
0978     int v = m_cfg.readEntry("guidesLineStyle", 0);
0979     v = qBound(0, v, 2);
0980     return (defaultValue ? 0 : v);
0981 }
0982 
0983 void KisConfig::setGuidesLineStyle(quint32 v) const
0984 {
0985     m_cfg.writeEntry("guidesLineStyle", v);
0986 }
0987 
0988 QColor KisConfig::guidesColor(bool defaultValue) const
0989 {
0990     QColor col(99, 99, 99);
0991     return (defaultValue ? col : m_cfg.readEntry("guidesColor", col));
0992 }
0993 
0994 void KisConfig::setGuidesColor(const QColor & v) const
0995 {
0996     m_cfg.writeEntry("guidesColor", v);
0997 }
0998 
0999 void KisConfig::loadSnapConfig(KisSnapConfig *config, bool defaultValue) const
1000 {
1001     KisSnapConfig defaultConfig(false);
1002 
1003     if (defaultValue) {
1004         *config = defaultConfig;
1005         return;
1006     }
1007 
1008     config->setOrthogonal(m_cfg.readEntry("globalSnapOrthogonal", defaultConfig.orthogonal()));
1009     config->setNode(m_cfg.readEntry("globalSnapNode", defaultConfig.node()));
1010     config->setExtension(m_cfg.readEntry("globalSnapExtension", defaultConfig.extension()));
1011     config->setIntersection(m_cfg.readEntry("globalSnapIntersection", defaultConfig.intersection()));
1012     config->setBoundingBox(m_cfg.readEntry("globalSnapBoundingBox", defaultConfig.boundingBox()));
1013     config->setImageBounds(m_cfg.readEntry("globalSnapImageBounds", defaultConfig.imageBounds()));
1014     config->setImageCenter(m_cfg.readEntry("globalSnapImageCenter", defaultConfig.imageCenter()));
1015     config->setToPixel(m_cfg.readEntry("globalSnapToPixel", defaultConfig.toPixel()));
1016 }
1017 
1018 void KisConfig::saveSnapConfig(const KisSnapConfig &config)
1019 {
1020     m_cfg.writeEntry("globalSnapOrthogonal", config.orthogonal());
1021     m_cfg.writeEntry("globalSnapNode", config.node());
1022     m_cfg.writeEntry("globalSnapExtension", config.extension());
1023     m_cfg.writeEntry("globalSnapIntersection", config.intersection());
1024     m_cfg.writeEntry("globalSnapBoundingBox", config.boundingBox());
1025     m_cfg.writeEntry("globalSnapImageBounds", config.imageBounds());
1026     m_cfg.writeEntry("globalSnapImageCenter", config.imageCenter());
1027     m_cfg.writeEntry("globalSnapToPixel", config.toPixel());
1028 }
1029 
1030 qint32 KisConfig::checkSize(bool defaultValue) const
1031 {
1032     qint32 size = (defaultValue ? 32 : m_cfg.readEntry("checksize", 32));
1033     if (size == 0) size = 32;
1034     return size;
1035 }
1036 
1037 void KisConfig::setCheckSize(qint32 checksize) const
1038 {
1039     if (checksize == 0) {
1040         checksize = 32;
1041     }
1042     m_cfg.writeEntry("checksize", checksize);
1043 }
1044 
1045 bool KisConfig::scrollCheckers(bool defaultValue) const
1046 {
1047     return (defaultValue ? false : m_cfg.readEntry("scrollingcheckers", false));
1048 }
1049 
1050 void KisConfig::setScrollingCheckers(bool sc) const
1051 {
1052     m_cfg.writeEntry("scrollingcheckers", sc);
1053 }
1054 
1055 QColor KisConfig::canvasBorderColor(bool defaultValue) const
1056 {
1057     QColor color(QColor(128,128,128));
1058     return (defaultValue ? color : m_cfg.readEntry("canvasBorderColor", color));
1059 }
1060 
1061 void KisConfig::setCanvasBorderColor(const QColor& color) const
1062 {
1063     m_cfg.writeEntry("canvasBorderColor", color);
1064 }
1065 
1066 bool KisConfig::hideScrollbars(bool defaultValue) const
1067 {
1068     return (defaultValue ? false : m_cfg.readEntry("hideScrollbars", false));
1069 }
1070 
1071 void KisConfig::setHideScrollbars(bool value) const
1072 {
1073     m_cfg.writeEntry("hideScrollbars", value);
1074 }
1075 
1076 bool KisConfig::scrollbarZoomEnabled(bool defaultValue) const
1077 {
1078     return (defaultValue ? true : m_cfg.readEntry("scrollbarZoomEnabled", true));
1079 }
1080 
1081 void KisConfig::setScrollbarZoomEnabled(bool enabled) const
1082 {
1083     m_cfg.writeEntry("scrollbarZoomEnabled", enabled);
1084 }
1085 
1086 QColor KisConfig::checkersColor1(bool defaultValue) const
1087 {
1088     QColor col(220, 220, 220);
1089     return (defaultValue ? col : m_cfg.readEntry("checkerscolor", col));
1090 }
1091 
1092 void KisConfig::setCheckersColor1(const QColor & v) const
1093 {
1094     m_cfg.writeEntry("checkerscolor", v);
1095 }
1096 
1097 QColor KisConfig::checkersColor2(bool defaultValue) const
1098 {
1099     return (defaultValue ? QColor(Qt::white) : m_cfg.readEntry("checkerscolor2", QColor(Qt::white)));
1100 }
1101 
1102 void KisConfig::setCheckersColor2(const QColor & v) const
1103 {
1104     m_cfg.writeEntry("checkerscolor2", v);
1105 }
1106 
1107 bool KisConfig::antialiasCurves(bool defaultValue) const
1108 {
1109     return (defaultValue ? true : m_cfg.readEntry("antialiascurves", true));
1110 }
1111 
1112 void KisConfig::setAntialiasCurves(bool v) const
1113 {
1114     m_cfg.writeEntry("antialiascurves", v);
1115 }
1116 
1117 bool KisConfig::antialiasSelectionOutline(bool defaultValue) const
1118 {
1119     return (defaultValue ? false : m_cfg.readEntry("AntialiasSelectionOutline", false));
1120 }
1121 
1122 void KisConfig::setAntialiasSelectionOutline(bool v) const
1123 {
1124     m_cfg.writeEntry("AntialiasSelectionOutline", v);
1125 }
1126 
1127 bool KisConfig::showRootLayer(bool defaultValue) const
1128 {
1129     return (defaultValue ? false : m_cfg.readEntry("ShowRootLayer", false));
1130 }
1131 
1132 void KisConfig::setShowRootLayer(bool showRootLayer) const
1133 {
1134     m_cfg.writeEntry("ShowRootLayer", showRootLayer);
1135 }
1136 
1137 bool KisConfig::showGlobalSelection(bool defaultValue) const
1138 {
1139     return (defaultValue ? false : m_cfg.readEntry("ShowGlobalSelection", false));
1140 }
1141 
1142 void KisConfig::setShowGlobalSelection(bool showGlobalSelection) const
1143 {
1144     m_cfg.writeEntry("ShowGlobalSelection", showGlobalSelection);
1145 }
1146 
1147 // brush outline settings
1148 
1149 bool KisConfig::showOutlineWhilePainting(bool defaultValue) const
1150 {
1151     return (defaultValue ? true : m_cfg.readEntry("ShowOutlineWhilePainting", true));
1152 }
1153 
1154 void KisConfig::setShowOutlineWhilePainting(bool showOutlineWhilePainting) const
1155 {
1156     m_cfg.writeEntry("ShowOutlineWhilePainting", showOutlineWhilePainting);
1157 }
1158 
1159 bool KisConfig::forceAlwaysFullSizedOutline(bool defaultValue) const
1160 {
1161     return (defaultValue ? false : m_cfg.readEntry("forceAlwaysFullSizedOutline", false));
1162 }
1163 
1164 void KisConfig::setForceAlwaysFullSizedOutline(bool value) const
1165 {
1166     m_cfg.writeEntry("forceAlwaysFullSizedOutline", value);
1167 }
1168 
1169 // eraser outline settings
1170 
1171 bool KisConfig::showEraserOutlineWhilePainting(bool defaultValue) const
1172 {
1173     return (defaultValue ? true : m_cfg.readEntry("ShowEraserOutlineWhilePainting", true));
1174 }
1175 
1176 void KisConfig::setShowEraserOutlineWhilePainting(bool showEraserOutlineWhilePainting) const
1177 {
1178     m_cfg.writeEntry("ShowEraserOutlineWhilePainting", showEraserOutlineWhilePainting);
1179 }
1180 
1181 bool KisConfig::forceAlwaysFullSizedEraserOutline(bool defaultValue) const
1182 {
1183     return (defaultValue ? false : m_cfg.readEntry("forceAlwaysFullSizedEraserOutline", false));
1184 }
1185 
1186 void KisConfig::setForceAlwaysFullSizedEraserOutline(bool value) const
1187 {
1188     m_cfg.writeEntry("forceAlwaysFullSizedEraserOutline", value);
1189 }
1190 
1191 KisConfig::SessionOnStartup KisConfig::sessionOnStartup(bool defaultValue) const
1192 {
1193     int value = defaultValue ? SOS_BlankSession : m_cfg.readEntry("sessionOnStartup", (int)SOS_BlankSession);
1194     return (KisConfig::SessionOnStartup)value;
1195 }
1196 void KisConfig::setSessionOnStartup(SessionOnStartup value)
1197 {
1198     m_cfg.writeEntry("sessionOnStartup", (int)value);
1199 }
1200 
1201 bool KisConfig::saveSessionOnQuit(bool defaultValue) const
1202 {
1203     return defaultValue ? false : m_cfg.readEntry("saveSessionOnQuit", false);
1204 }
1205 void KisConfig::setSaveSessionOnQuit(bool value)
1206 {
1207     m_cfg.writeEntry("saveSessionOnQuit", value);
1208 }
1209 
1210 bool KisConfig::hideDevFundBanner(bool defaultValue) const
1211 {
1212     return defaultValue ? false : m_cfg.readEntry("hideDevFundBanner", false);
1213 }
1214 
1215 void KisConfig::setHideDevFundBanner(bool value)
1216 {
1217     m_cfg.writeEntry("hideDevFundBanner", value);
1218 }
1219 
1220 qreal KisConfig::outlineSizeMinimum(bool defaultValue) const
1221 {
1222     return (defaultValue ? 1.0 : m_cfg.readEntry("OutlineSizeMinimum", 1.0));
1223 }
1224 
1225 void KisConfig::setOutlineSizeMinimum(qreal outlineSizeMinimum) const
1226 {
1227     m_cfg.writeEntry("OutlineSizeMinimum", outlineSizeMinimum);
1228 }
1229 
1230 qreal KisConfig::selectionViewSizeMinimum(bool defaultValue) const
1231 {
1232     return (defaultValue ? 5.0 : m_cfg.readEntry("SelectionViewSizeMinimum", 5.0));
1233 }
1234 
1235 void KisConfig::setSelectionViewSizeMinimum(qreal outlineSizeMinimum) const
1236 {
1237     m_cfg.writeEntry("SelectionViewSizeMinimum", outlineSizeMinimum);
1238 }
1239 
1240 int KisConfig::autoSaveInterval(bool defaultValue)  const
1241 {
1242     int def = 7 * 60;
1243     return (defaultValue ? def : m_cfg.readEntry("AutoSaveInterval", def));
1244 }
1245 
1246 void KisConfig::setAutoSaveInterval(int seconds)  const
1247 {
1248     return m_cfg.writeEntry("AutoSaveInterval", seconds);
1249 }
1250 
1251 bool KisConfig::backupFile(bool defaultValue) const
1252 {
1253     return (defaultValue ? true : m_cfg.readEntry("CreateBackupFile", true));
1254 }
1255 
1256 void KisConfig::setBackupFile(bool backupFile) const
1257 {
1258     m_cfg.writeEntry("CreateBackupFile", backupFile);
1259 }
1260 
1261 bool KisConfig::showFilterGallery(bool defaultValue) const
1262 {
1263     return (defaultValue ? false : m_cfg.readEntry("showFilterGallery", false));
1264 }
1265 
1266 void KisConfig::setShowFilterGallery(bool showFilterGallery) const
1267 {
1268     m_cfg.writeEntry("showFilterGallery", showFilterGallery);
1269 }
1270 
1271 bool KisConfig::showFilterGalleryLayerMaskDialog(bool defaultValue) const
1272 {
1273     return (defaultValue ? true : m_cfg.readEntry("showFilterGalleryLayerMaskDialog", true));
1274 }
1275 
1276 void KisConfig::setShowFilterGalleryLayerMaskDialog(bool showFilterGallery) const
1277 {
1278     m_cfg.writeEntry("setShowFilterGalleryLayerMaskDialog", showFilterGallery);
1279 }
1280 
1281 QString KisConfig::canvasState(bool defaultValue) const
1282 {
1283     const QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
1284     QSettings kritarc(configPath + QStringLiteral("/kritadisplayrc"), QSettings::IniFormat);
1285     return (defaultValue ? "OPENGL_NOT_TRIED" : kritarc.value("canvasState", "OPENGL_NOT_TRIED").toString());
1286 }
1287 
1288 void KisConfig::setCanvasState(const QString& state) const
1289 {
1290     static QStringList acceptableStates;
1291     if (acceptableStates.isEmpty()) {
1292         acceptableStates << "OPENGL_SUCCESS" << "TRY_OPENGL" << "OPENGL_NOT_TRIED" << "OPENGL_FAILED";
1293     }
1294     if (acceptableStates.contains(state)) {
1295         const QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
1296         QSettings kritarc(configPath + QStringLiteral("/kritadisplayrc"), QSettings::IniFormat);
1297         kritarc.setValue("canvasState", state);
1298     }
1299 }
1300 
1301 bool KisConfig::toolOptionsPopupDetached(bool defaultValue) const
1302 {
1303     return (defaultValue ? false : m_cfg.readEntry("ToolOptionsPopupDetached", false));
1304 }
1305 
1306 void KisConfig::setToolOptionsPopupDetached(bool detached) const
1307 {
1308     m_cfg.writeEntry("ToolOptionsPopupDetached", detached);
1309 }
1310 
1311 
1312 bool KisConfig::paintopPopupDetached(bool defaultValue) const
1313 {
1314     return (defaultValue ? true : m_cfg.readEntry("PaintopPopupDetached", true));
1315 }
1316 
1317 void KisConfig::setPaintopPopupDetached(bool detached) const
1318 {
1319     m_cfg.writeEntry("PaintopPopupDetached", detached);
1320 }
1321 
1322 QString KisConfig::pressureTabletCurve(bool defaultValue) const
1323 {
1324     return (defaultValue ? "0,0;1,1" : m_cfg.readEntry("tabletPressureCurve","0,0;1,1;"));
1325 }
1326 
1327 void KisConfig::setPressureTabletCurve(const QString& curveString) const
1328 {
1329     m_cfg.writeEntry("tabletPressureCurve", curveString);
1330 }
1331 
1332 bool KisConfig::useWin8PointerInput(bool defaultValue) const
1333 {
1334 #ifdef Q_OS_WIN
1335 #ifdef USE_QT_TABLET_WINDOWS
1336     const QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
1337     QSettings kritarc(configPath + QStringLiteral("/kritadisplayrc"), QSettings::IniFormat);
1338 
1339     return useWin8PointerInputNoApp(&kritarc, defaultValue);
1340 #else
1341     return (defaultValue ? false : m_cfg.readEntry("useWin8PointerInput", false));
1342 #endif
1343 #else
1344     Q_UNUSED(defaultValue);
1345     return false;
1346 #endif
1347 }
1348 
1349 void KisConfig::setUseWin8PointerInput(bool value)
1350 {
1351 #ifdef Q_OS_WIN
1352 
1353     // Special handling: Only set value if changed
1354     // I don't want it to be set if the user hasn't touched it
1355     if (useWin8PointerInput() != value) {
1356 
1357 #ifdef USE_QT_TABLET_WINDOWS
1358         const QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
1359         QSettings kritarc(configPath + QStringLiteral("/kritadisplayrc"), QSettings::IniFormat);
1360         setUseWin8PointerInputNoApp(&kritarc, value);
1361 #else
1362         m_cfg.writeEntry("useWin8PointerInput", value);
1363 #endif
1364 
1365     }
1366 
1367 #else
1368     Q_UNUSED(value);
1369 #endif
1370 }
1371 
1372 bool KisConfig::useWin8PointerInputNoApp(QSettings *settings, bool defaultValue)
1373 {
1374     return defaultValue ? false : settings->value("useWin8PointerInput", false).toBool();
1375 }
1376 
1377 void KisConfig::setUseWin8PointerInputNoApp(QSettings *settings, bool value)
1378 {
1379     settings->setValue("useWin8PointerInput", value);
1380 }
1381 
1382 bool KisConfig::useRightMiddleTabletButtonWorkaround(bool defaultValue) const
1383 {
1384     return (defaultValue ? false : m_cfg.readEntry("useRightMiddleTabletButtonWorkaround", false));
1385 }
1386 
1387 void KisConfig::setUseRightMiddleTabletButtonWorkaround(bool value)
1388 {
1389     m_cfg.writeEntry("useRightMiddleTabletButtonWorkaround", value);
1390 }
1391 
1392 qreal KisConfig::vastScrolling(bool defaultValue) const
1393 {
1394     return (defaultValue ? 0.9 : m_cfg.readEntry("vastScrolling", 0.9));
1395 }
1396 
1397 void KisConfig::setVastScrolling(const qreal factor) const
1398 {
1399     m_cfg.writeEntry("vastScrolling", factor);
1400 }
1401 
1402 int KisConfig::presetChooserViewMode(bool defaultValue) const
1403 {
1404     return (defaultValue ? 0 : m_cfg.readEntry("presetChooserViewMode", 0));
1405 }
1406 
1407 void KisConfig::setPresetChooserViewMode(const int mode) const
1408 {
1409     m_cfg.writeEntry("presetChooserViewMode", mode);
1410 }
1411 
1412 int KisConfig::presetIconSize(bool defaultValue) const
1413 {
1414     return (defaultValue ? 60 : m_cfg.readEntry("presetIconSize", 60));
1415 }
1416 
1417 void KisConfig::setPresetIconSize(const int value) const
1418 {
1419     m_cfg.writeEntry("presetIconSize", value);
1420 }
1421 
1422 bool KisConfig::firstRun(bool defaultValue) const
1423 {
1424     return (defaultValue ? true : m_cfg.readEntry("firstRun", true));
1425 }
1426 
1427 void KisConfig::setFirstRun(const bool first) const
1428 {
1429     m_cfg.writeEntry("firstRun", first);
1430 }
1431 
1432 int KisConfig::horizontalSplitLines(bool defaultValue) const
1433 {
1434     return (defaultValue ? 1 : m_cfg.readEntry("horizontalSplitLines", 1));
1435 }
1436 void KisConfig::setHorizontalSplitLines(const int numberLines) const
1437 {
1438     m_cfg.writeEntry("horizontalSplitLines", numberLines);
1439 }
1440 
1441 int KisConfig::verticalSplitLines(bool defaultValue) const
1442 {
1443     return (defaultValue ? 1 : m_cfg.readEntry("verticalSplitLines", 1));
1444 }
1445 
1446 void KisConfig::setVerticalSplitLines(const int numberLines) const
1447 {
1448     m_cfg.writeEntry("verticalSplitLines", numberLines);
1449 }
1450 
1451 bool KisConfig::clicklessSpacePan(bool defaultValue) const
1452 {
1453     return (defaultValue ? true : m_cfg.readEntry("clicklessSpacePan", true));
1454 }
1455 
1456 void KisConfig::setClicklessSpacePan(const bool toggle) const
1457 {
1458     m_cfg.writeEntry("clicklessSpacePan", toggle);
1459 }
1460 
1461 
1462 bool KisConfig::hideDockersFullscreen(bool defaultValue) const
1463 {
1464     return (defaultValue ? true : m_cfg.readEntry("hideDockersFullScreen", true));
1465 }
1466 
1467 void KisConfig::setHideDockersFullscreen(const bool value) const
1468 {
1469     m_cfg.writeEntry("hideDockersFullScreen", value);
1470 }
1471 
1472 bool KisConfig::showDockerTitleBars(bool defaultValue) const
1473 {
1474     return (defaultValue ? true : m_cfg.readEntry("showDockerTitleBars", true));
1475 }
1476 
1477 void KisConfig::setShowDockerTitleBars(const bool value) const
1478 {
1479     m_cfg.writeEntry("showDockerTitleBars", value);
1480 }
1481 
1482 bool KisConfig::showDockers(bool defaultValue) const
1483 {
1484     return (defaultValue ? true : m_cfg.readEntry("showDockers", true));
1485 }
1486 
1487 void KisConfig::setShowDockers(const bool value) const
1488 {
1489     m_cfg.writeEntry("showDockers", value);
1490 }
1491 
1492 bool KisConfig::showStatusBar(bool defaultValue) const
1493 {
1494     return (defaultValue ? true : m_cfg.readEntry("showStatusBar", true));
1495 }
1496 
1497 void KisConfig::setShowStatusBar(const bool value) const
1498 {
1499     m_cfg.writeEntry("showStatusBar", value);
1500 }
1501 
1502 bool KisConfig::hideMenuFullscreen(bool defaultValue) const
1503 {
1504     return (defaultValue ? true: m_cfg.readEntry("hideMenuFullScreen", true));
1505 }
1506 
1507 void KisConfig::setHideMenuFullscreen(const bool value) const
1508 {
1509     m_cfg.writeEntry("hideMenuFullScreen", value);
1510 }
1511 
1512 bool KisConfig::hideScrollbarsFullscreen(bool defaultValue) const
1513 {
1514     return (defaultValue ? true : m_cfg.readEntry("hideScrollbarsFullScreen", true));
1515 }
1516 
1517 void KisConfig::setHideScrollbarsFullscreen(const bool value) const
1518 {
1519     m_cfg.writeEntry("hideScrollbarsFullScreen", value);
1520 }
1521 
1522 bool KisConfig::hideStatusbarFullscreen(bool defaultValue) const
1523 {
1524     return (defaultValue ? true: m_cfg.readEntry("hideStatusbarFullScreen", true));
1525 }
1526 
1527 void KisConfig::setHideStatusbarFullscreen(const bool value) const
1528 {
1529     m_cfg.writeEntry("hideStatusbarFullScreen", value);
1530 }
1531 
1532 bool KisConfig::hideTitlebarFullscreen(bool defaultValue) const
1533 {
1534     return (defaultValue ? true : m_cfg.readEntry("hideTitleBarFullscreen", true));
1535 }
1536 
1537 void KisConfig::setHideTitlebarFullscreen(const bool value) const
1538 {
1539     m_cfg.writeEntry("hideTitleBarFullscreen", value);
1540 }
1541 
1542 bool KisConfig::hideToolbarFullscreen(bool defaultValue) const
1543 {
1544     return (defaultValue ? true : m_cfg.readEntry("hideToolbarFullscreen", true));
1545 }
1546 
1547 void KisConfig::setHideToolbarFullscreen(const bool value) const
1548 {
1549     m_cfg.writeEntry("hideToolbarFullscreen", value);
1550 }
1551 
1552 bool KisConfig::fullscreenMode(bool defaultValue) const
1553 {
1554     return (defaultValue ? true : m_cfg.readEntry("fullscreenMode", false));
1555 }
1556 
1557 void KisConfig::setFullscreenMode(const bool value) const
1558 {
1559     m_cfg.writeEntry("fullscreenMode", value);
1560 }
1561 
1562 QStringList KisConfig::favoriteCompositeOps(bool defaultValue) const
1563 {
1564     return (defaultValue ? QStringList() :
1565                            m_cfg.readEntry("favoriteCompositeOps",
1566                                            QString("normal,erase,multiply,burn,darken,add,dodge,screen,overlay,soft_light_svg,luminize,lighten,saturation,color,divide").split(',')));
1567 }
1568 
1569 void KisConfig::setFavoriteCompositeOps(const QStringList& compositeOps) const
1570 {
1571     m_cfg.writeEntry("favoriteCompositeOps", compositeOps);
1572 }
1573 
1574 QString KisConfig::exportConfigurationXML(const QString &filterId, bool defaultValue) const
1575 {
1576     return (defaultValue ? QString() : m_cfg.readEntry("ExportConfiguration-" + filterId, QString()));
1577 }
1578 
1579 KisPropertiesConfigurationSP KisConfig::exportConfiguration(const QString &filterId, bool defaultValue) const
1580 {
1581     KisPropertiesConfigurationSP cfg = new KisPropertiesConfiguration();
1582     const QString xmlData = exportConfigurationXML(filterId, defaultValue);
1583     cfg->fromXML(xmlData);
1584     return cfg;
1585 }
1586 
1587 void KisConfig::setExportConfiguration(const QString &filterId, KisPropertiesConfigurationSP properties) const
1588 {
1589     QString exportConfig = properties->toXML();
1590     m_cfg.writeEntry("ExportConfiguration-" + filterId, exportConfig);
1591 }
1592 
1593 QString KisConfig::importConfiguration(const QString &filterId, bool defaultValue) const
1594 {
1595     return (defaultValue ? QString() : m_cfg.readEntry("ImportConfiguration-" + filterId, QString()));
1596 }
1597 
1598 void KisConfig::setImportConfiguration(const QString &filterId, KisPropertiesConfigurationSP properties) const
1599 {
1600     QString importConfig = properties->toXML();
1601     m_cfg.writeEntry("ImportConfiguration-" + filterId, importConfig);
1602 }
1603 
1604 bool KisConfig::useOcio(bool defaultValue) const
1605 {
1606 #ifdef HAVE_OCIO
1607     return (defaultValue ? false : m_cfg.readEntry("Krita/Ocio/UseOcio", false));
1608 #else
1609     Q_UNUSED(defaultValue);
1610     return false;
1611 #endif
1612 }
1613 
1614 void KisConfig::setUseOcio(bool useOCIO) const
1615 {
1616     m_cfg.writeEntry("Krita/Ocio/UseOcio", useOCIO);
1617 }
1618 
1619 int KisConfig::favoritePresets(bool defaultValue) const
1620 {
1621     return (defaultValue ? 10: m_cfg.readEntry("numFavoritePresets", 10));
1622 }
1623 
1624 void KisConfig::setFavoritePresets(const int value)
1625 {
1626     m_cfg.writeEntry("numFavoritePresets", value);
1627 }
1628 
1629 bool KisConfig::levelOfDetailEnabled(bool defaultValue) const
1630 {
1631     return (defaultValue ? false : m_cfg.readEntry("levelOfDetailEnabled", false));
1632 }
1633 
1634 void KisConfig::setLevelOfDetailEnabled(bool value)
1635 {
1636     m_cfg.writeEntry("levelOfDetailEnabled", value);
1637 }
1638 
1639 KisOcioConfiguration KisConfig::ocioConfiguration(bool defaultValue) const
1640 {
1641     KisOcioConfiguration cfg;
1642 
1643     if (!defaultValue) {
1644         cfg.mode = (KisOcioConfiguration::Mode)m_cfg.readEntry("Krita/Ocio/OcioColorManagementMode", 0);
1645         cfg.configurationPath = m_cfg.readEntry("Krita/Ocio/OcioConfigPath", QString());
1646         cfg.lutPath = m_cfg.readEntry("Krita/Ocio/OcioLutPath", QString());
1647         cfg.inputColorSpace = m_cfg.readEntry("Krita/Ocio/InputColorSpace", QString());
1648         cfg.displayDevice = m_cfg.readEntry("Krita/Ocio/DisplayDevice", QString());
1649         cfg.displayView = m_cfg.readEntry("Krita/Ocio/DisplayView", QString());
1650         cfg.look = m_cfg.readEntry("Krita/Ocio/DisplayLook", QString());
1651     }
1652 
1653     return cfg;
1654 }
1655 
1656 void KisConfig::setOcioConfiguration(const KisOcioConfiguration &cfg)
1657 {
1658     m_cfg.writeEntry("Krita/Ocio/OcioColorManagementMode", (int) cfg.mode);
1659     m_cfg.writeEntry("Krita/Ocio/OcioConfigPath", cfg.configurationPath);
1660     m_cfg.writeEntry("Krita/Ocio/OcioLutPath", cfg.lutPath);
1661     m_cfg.writeEntry("Krita/Ocio/InputColorSpace", cfg.inputColorSpace);
1662     m_cfg.writeEntry("Krita/Ocio/DisplayDevice", cfg.displayDevice);
1663     m_cfg.writeEntry("Krita/Ocio/DisplayView", cfg.displayView);
1664     m_cfg.writeEntry("Krita/Ocio/DisplayLook", cfg.look);
1665 }
1666 
1667 KisConfig::OcioColorManagementMode
1668 KisConfig::ocioColorManagementMode(bool defaultValue) const
1669 {
1670     // FIXME: this option duplicates ocioConfiguration(), please deprecate it
1671     return (OcioColorManagementMode)(defaultValue ? INTERNAL
1672                                                   : m_cfg.readEntry("Krita/Ocio/OcioColorManagementMode", (int) INTERNAL));
1673 }
1674 
1675 void KisConfig::setOcioColorManagementMode(OcioColorManagementMode mode) const
1676 {
1677     // FIXME: this option duplicates ocioConfiguration(), please deprecate it
1678     m_cfg.writeEntry("Krita/Ocio/OcioColorManagementMode", (int) mode);
1679 }
1680 
1681 int KisConfig::ocioLutEdgeSize(bool defaultValue) const
1682 {
1683     return (defaultValue ? 64 : m_cfg.readEntry("Krita/Ocio/LutEdgeSize", 64));
1684 }
1685 
1686 void KisConfig::setOcioLutEdgeSize(int value)
1687 {
1688     m_cfg.writeEntry("Krita/Ocio/LutEdgeSize", value);
1689 }
1690 
1691 bool KisConfig::ocioLockColorVisualRepresentation(bool defaultValue) const
1692 {
1693     return (defaultValue ? false : m_cfg.readEntry("Krita/Ocio/OcioLockColorVisualRepresentation", false));
1694 }
1695 
1696 void KisConfig::setOcioLockColorVisualRepresentation(bool value)
1697 {
1698     m_cfg.writeEntry("Krita/Ocio/OcioLockColorVisualRepresentation", value);
1699 }
1700 
1701 QString KisConfig::defaultPalette(bool defaultValue) const
1702 {
1703     return (defaultValue ? QString() : m_cfg.readEntry("defaultPalette", "Default"));
1704 }
1705 
1706 void KisConfig::setDefaultPalette(const QString& name) const
1707 {
1708     m_cfg.writeEntry("defaultPalette", name);
1709 }
1710 
1711 QString KisConfig::toolbarSlider(int sliderNumber, bool defaultValue) const
1712 {
1713     QString def = "flow";
1714     if (sliderNumber == 1) {
1715         def = "opacity";
1716     }
1717     if (sliderNumber == 2) {
1718         def = "size";
1719     }
1720     return (defaultValue ? def : m_cfg.readEntry(QString("toolbarslider_%1").arg(sliderNumber), def));
1721 }
1722 
1723 void KisConfig::setToolbarSlider(int sliderNumber, const QString &slider)
1724 {
1725     m_cfg.writeEntry(QString("toolbarslider_%1").arg(sliderNumber), slider);
1726 }
1727 
1728 int KisConfig::layerThumbnailSize(bool defaultValue) const
1729 {
1730     return (defaultValue ? 20 : m_cfg.readEntry("layerThumbnailSize", 20));
1731 }
1732 
1733 void KisConfig::setLayerThumbnailSize(int size)
1734 {
1735     m_cfg.writeEntry("layerThumbnailSize", size);
1736 }
1737 
1738 int KisConfig::layerTreeIndentation(bool defaultValue) const
1739 {
1740     return (defaultValue ? 50 : m_cfg.readEntry("layerTreeIndentation", 50));
1741 }
1742 
1743 void KisConfig::setLayerTreeIndentation(int percentage)
1744 {
1745     m_cfg.writeEntry("layerTreeIndentation", percentage);
1746 }
1747 
1748 bool KisConfig::sliderLabels(bool defaultValue) const
1749 {
1750     return (defaultValue ? true : m_cfg.readEntry("sliderLabels", true));
1751 }
1752 
1753 void KisConfig::setSliderLabels(bool enabled)
1754 {
1755     m_cfg.writeEntry("sliderLabels", enabled);
1756 }
1757 
1758 QString KisConfig::currentInputProfile(bool defaultValue) const
1759 {
1760     return (defaultValue ? QString() : m_cfg.readEntry("currentInputProfile", QString()));
1761 }
1762 
1763 void KisConfig::setCurrentInputProfile(const QString& name)
1764 {
1765     m_cfg.writeEntry("currentInputProfile", name);
1766 }
1767 
1768 bool KisConfig::useSystemMonitorProfile(bool defaultValue) const
1769 {
1770     return (defaultValue ? false : m_cfg.readEntry("ColorManagement/UseSystemMonitorProfile", false));
1771 }
1772 
1773 void KisConfig::setUseSystemMonitorProfile(bool _useSystemMonitorProfile) const
1774 {
1775     m_cfg.writeEntry("ColorManagement/UseSystemMonitorProfile", _useSystemMonitorProfile);
1776 }
1777 
1778 bool KisConfig::presetStripVisible(bool defaultValue) const
1779 {
1780     return (defaultValue ? true : m_cfg.readEntry("presetStripVisible", true));
1781 }
1782 
1783 void KisConfig::setPresetStripVisible(bool visible)
1784 {
1785     m_cfg.writeEntry("presetStripVisible", visible);
1786 }
1787 
1788 bool KisConfig::scratchpadVisible(bool defaultValue) const
1789 {
1790     return (defaultValue ? true : m_cfg.readEntry("scratchpadVisible", true));
1791 }
1792 
1793 void KisConfig::setScratchpadVisible(bool visible)
1794 {
1795     m_cfg.writeEntry("scratchpadVisible", visible);
1796 }
1797 
1798 bool KisConfig::showSingleChannelAsColor(bool defaultValue) const
1799 {
1800     return (defaultValue ? false : m_cfg.readEntry("showSingleChannelAsColor", false));
1801 }
1802 
1803 void KisConfig::setShowSingleChannelAsColor(bool asColor)
1804 {
1805     m_cfg.writeEntry("showSingleChannelAsColor", asColor);
1806 }
1807 
1808 bool KisConfig::hidePopups(bool defaultValue) const
1809 {
1810     return (defaultValue ? false : m_cfg.readEntry("hidePopups", false));
1811 }
1812 
1813 void KisConfig::setHidePopups(bool hidePopups)
1814 {
1815     m_cfg.writeEntry("hidePopups", hidePopups);
1816 }
1817 
1818 int KisConfig::numDefaultLayers(bool defaultValue) const
1819 {
1820     return (defaultValue ? 2 : m_cfg.readEntry("NumberOfLayersForNewImage", 2));
1821 }
1822 
1823 void KisConfig::setNumDefaultLayers(int num)
1824 {
1825     m_cfg.writeEntry("NumberOfLayersForNewImage", num);
1826 }
1827 
1828 quint8 KisConfig::defaultBackgroundOpacity(bool defaultValue) const
1829 {
1830   return (defaultValue ? (int)OPACITY_OPAQUE_U8 : m_cfg.readEntry("BackgroundOpacityForNewImage", (int)OPACITY_OPAQUE_U8));
1831 }
1832 
1833 void KisConfig::setDefaultBackgroundOpacity(quint8 value)
1834 {
1835   m_cfg.writeEntry("BackgroundOpacityForNewImage", (int)value);
1836 }
1837 
1838 QColor KisConfig::defaultBackgroundColor(bool defaultValue) const
1839 {
1840   return (defaultValue ? QColor(Qt::white) : m_cfg.readEntry("BackgroundColorForNewImage", QColor(Qt::white)));
1841 }
1842 
1843 void KisConfig::setDefaultBackgroundColor(const QColor &value)
1844 {
1845   m_cfg.writeEntry("BackgroundColorForNewImage", value);
1846 }
1847 
1848 KisConfig::BackgroundStyle KisConfig::defaultBackgroundStyle(bool defaultValue) const
1849 {
1850   return (KisConfig::BackgroundStyle)(defaultValue ? RASTER_LAYER : m_cfg.readEntry("BackgroundStyleForNewImage", (int)RASTER_LAYER));
1851 }
1852 
1853 void KisConfig::setDefaultBackgroundStyle(KisConfig::BackgroundStyle value)
1854 {
1855   m_cfg.writeEntry("BackgroundStyleForNewImage", (int)value);
1856 }
1857 
1858 int KisConfig::lineSmoothingType(bool defaultValue) const
1859 {
1860     return (defaultValue ? 1 : m_cfg.readEntry("LineSmoothingType", 1));
1861 }
1862 
1863 void KisConfig::setLineSmoothingType(int value)
1864 {
1865     m_cfg.writeEntry("LineSmoothingType", value);
1866 }
1867 
1868 qreal KisConfig::lineSmoothingDistance(bool defaultValue) const
1869 {
1870     return (defaultValue ? 50.0 : m_cfg.readEntry("LineSmoothingDistance", 50.0));
1871 }
1872 
1873 void KisConfig::setLineSmoothingDistance(qreal value)
1874 {
1875     m_cfg.writeEntry("LineSmoothingDistance", value);
1876 }
1877 
1878 qreal KisConfig::lineSmoothingTailAggressiveness(bool defaultValue) const
1879 {
1880     return (defaultValue ? 0.15 : m_cfg.readEntry("LineSmoothingTailAggressiveness", 0.15));
1881 }
1882 
1883 void KisConfig::setLineSmoothingTailAggressiveness(qreal value)
1884 {
1885     m_cfg.writeEntry("LineSmoothingTailAggressiveness", value);
1886 }
1887 
1888 bool KisConfig::lineSmoothingSmoothPressure(bool defaultValue) const
1889 {
1890     return (defaultValue ? false : m_cfg.readEntry("LineSmoothingSmoothPressure", false));
1891 }
1892 
1893 void KisConfig::setLineSmoothingSmoothPressure(bool value)
1894 {
1895     m_cfg.writeEntry("LineSmoothingSmoothPressure", value);
1896 }
1897 
1898 bool KisConfig::lineSmoothingScalableDistance(bool defaultValue) const
1899 {
1900     return (defaultValue ? true : m_cfg.readEntry("LineSmoothingScalableDistance", true));
1901 }
1902 
1903 void KisConfig::setLineSmoothingScalableDistance(bool value)
1904 {
1905     m_cfg.writeEntry("LineSmoothingScalableDistance", value);
1906 }
1907 
1908 qreal KisConfig::lineSmoothingDelayDistance(bool defaultValue) const
1909 {
1910     return (defaultValue ? 50.0 : m_cfg.readEntry("LineSmoothingDelayDistance", 50.0));
1911 }
1912 
1913 void KisConfig::setLineSmoothingDelayDistance(qreal value)
1914 {
1915     m_cfg.writeEntry("LineSmoothingDelayDistance", value);
1916 }
1917 
1918 bool KisConfig::lineSmoothingUseDelayDistance(bool defaultValue) const
1919 {
1920     return (defaultValue ? true : m_cfg.readEntry("LineSmoothingUseDelayDistance", true));
1921 }
1922 
1923 void KisConfig::setLineSmoothingUseDelayDistance(bool value)
1924 {
1925     m_cfg.writeEntry("LineSmoothingUseDelayDistance", value);
1926 }
1927 
1928 bool KisConfig::lineSmoothingFinishStabilizedCurve(bool defaultValue) const
1929 {
1930     return (defaultValue ? true : m_cfg.readEntry("LineSmoothingFinishStabilizedCurve", true));
1931 }
1932 
1933 void KisConfig::setLineSmoothingFinishStabilizedCurve(bool value)
1934 {
1935     m_cfg.writeEntry("LineSmoothingFinishStabilizedCurve", value);
1936 }
1937 
1938 bool KisConfig::lineSmoothingStabilizeSensors(bool defaultValue) const
1939 {
1940     return (defaultValue ? true : m_cfg.readEntry("LineSmoothingStabilizeSensors", true));
1941 }
1942 
1943 void KisConfig::setLineSmoothingStabilizeSensors(bool value)
1944 {
1945     m_cfg.writeEntry("LineSmoothingStabilizeSensors", value);
1946 }
1947 
1948 int KisConfig::tabletEventsDelay(bool defaultValue) const
1949 {
1950     return (defaultValue ? 10 : m_cfg.readEntry("tabletEventsDelay", 10));
1951 }
1952 
1953 void KisConfig::setTabletEventsDelay(int value)
1954 {
1955     m_cfg.writeEntry("tabletEventsDelay", value);
1956 }
1957 
1958 bool KisConfig::trackTabletEventLatency(bool defaultValue) const
1959 {
1960     return (defaultValue ? false : m_cfg.readEntry("trackTabletEventLatency", false));
1961 }
1962 
1963 void KisConfig::setTrackTabletEventLatency(bool value)
1964 {
1965     m_cfg.writeEntry("trackTabletEventLatency", value);
1966 }
1967 
1968 bool KisConfig::testingAcceptCompressedTabletEvents(bool defaultValue) const
1969 {
1970     return (defaultValue ? false : m_cfg.readEntry("testingAcceptCompressedTabletEvents", false));
1971 }
1972 
1973 void KisConfig::setTestingAcceptCompressedTabletEvents(bool value)
1974 {
1975     m_cfg.writeEntry("testingAcceptCompressedTabletEvents", value);
1976 }
1977 
1978 bool KisConfig::shouldEatDriverShortcuts(bool defaultValue) const
1979 {
1980     return (defaultValue ? false : m_cfg.readEntry("shouldEatDriverShortcuts", false));
1981 }
1982 
1983 bool KisConfig::testingCompressBrushEvents(bool defaultValue) const
1984 {
1985     return (defaultValue ? false : m_cfg.readEntry("testingCompressBrushEvents", false));
1986 }
1987 
1988 void KisConfig::setTestingCompressBrushEvents(bool value)
1989 {
1990     m_cfg.writeEntry("testingCompressBrushEvents", value);
1991 }
1992 
1993 int KisConfig::workaroundX11SmoothPressureSteps(bool defaultValue) const
1994 {
1995     return (defaultValue ? 0 : m_cfg.readEntry("workaroundX11SmoothPressureSteps", 0));
1996 }
1997 
1998 bool KisConfig::showCanvasMessages(bool defaultValue) const
1999 {
2000     return (defaultValue ? true : m_cfg.readEntry("showOnCanvasMessages", true));
2001 }
2002 
2003 void KisConfig::setShowCanvasMessages(bool show)
2004 {
2005     m_cfg.writeEntry("showOnCanvasMessages", show);
2006 }
2007 
2008 bool KisConfig::compressKra(bool defaultValue) const
2009 {
2010     return (defaultValue ? false : m_cfg.readEntry("compressLayersInKra", false));
2011 }
2012 
2013 void KisConfig::setCompressKra(bool compress)
2014 {
2015     m_cfg.writeEntry("compressLayersInKra", compress);
2016 }
2017 
2018 bool KisConfig::trimKra(bool defaultValue) const
2019 {
2020     return (defaultValue ? false : m_cfg.readEntry("TrimKra", false));
2021 }
2022 
2023 void KisConfig::setTrimKra(bool trim)
2024 {
2025     m_cfg.writeEntry("TrimKra", trim);
2026 }
2027 
2028 bool KisConfig::trimFramesImport(bool defaultValue) const
2029 {
2030     return (defaultValue ? false : m_cfg.readEntry("TrimFramesImport", false));
2031 }
2032 void KisConfig::setTrimFramesImport(bool trim)
2033 {
2034     m_cfg.writeEntry("TrimFramesImport", trim);
2035 }
2036 
2037 bool KisConfig::toolOptionsInDocker(bool defaultValue) const
2038 {
2039     return (defaultValue ? true : m_cfg.readEntry("ToolOptionsInDocker", true));
2040 }
2041 
2042 void KisConfig::setToolOptionsInDocker(bool inDocker)
2043 {
2044     m_cfg.writeEntry("ToolOptionsInDocker", inDocker);
2045 }
2046 
2047 bool KisConfig::kineticScrollingEnabled(bool defaultValue) const
2048 {
2049     return (defaultValue ? true : m_cfg.readEntry("KineticScrollingEnabled", true));
2050 }
2051 
2052 void KisConfig::setKineticScrollingEnabled(bool value)
2053 {
2054     m_cfg.writeEntry("KineticScrollingEnabled", value);
2055 }
2056 
2057 int KisConfig::kineticScrollingGesture(bool defaultValue) const
2058 {
2059 #ifdef Q_OS_ANDROID
2060     int defaultGesture = 1; // LeftMouseButtonGesture
2061 #else
2062     int defaultGesture = 2; // MiddleMouseButtonGesture
2063 #endif
2064 
2065     return (defaultValue ? defaultGesture : m_cfg.readEntry("KineticScrollingGesture", defaultGesture));
2066 }
2067 
2068 void KisConfig::setKineticScrollingGesture(int gesture)
2069 {
2070     m_cfg.writeEntry("KineticScrollingGesture", gesture);
2071 }
2072 
2073 int KisConfig::kineticScrollingSensitivity(bool defaultValue) const
2074 {
2075     return (defaultValue ? 75 : m_cfg.readEntry("KineticScrollingSensitivity", 75));
2076 }
2077 
2078 void KisConfig::setKineticScrollingSensitivity(int sensitivity)
2079 {
2080     m_cfg.writeEntry("KineticScrollingSensitivity", sensitivity);
2081 }
2082 
2083 bool KisConfig::kineticScrollingHiddenScrollbars(bool defaultValue) const
2084 {
2085     return (defaultValue ? false : m_cfg.readEntry("KineticScrollingHideScrollbar", false));
2086 }
2087 
2088 void KisConfig::setKineticScrollingHideScrollbars(bool scrollbar)
2089 {
2090     m_cfg.writeEntry("KineticScrollingHideScrollbar", scrollbar);
2091 }
2092 
2093 int KisConfig::zoomSteps(bool defaultValue) const
2094 {
2095     return (defaultValue ? 2 : m_cfg.readEntry("zoomSteps", 2));
2096 }
2097 
2098 void KisConfig::setZoomSteps(int steps)
2099 {
2100     m_cfg.writeEntry("zoomSteps", steps);
2101 }
2102 
2103 int KisConfig::zoomMarginSize(bool defaultValue) const
2104 {
2105     return (defaultValue ? 0 : m_cfg.readEntry("zoomMarginSize", 0));
2106 }
2107 
2108 void KisConfig::setZoomMarginSize(int zoomMarginSize)
2109 {
2110     m_cfg.writeEntry("zoomMarginSize", zoomMarginSize);
2111 }
2112 
2113 const KoColorSpace* KisConfig::customColorSelectorColorSpace(bool defaultValue) const
2114 {
2115     const KoColorSpace *cs = 0;
2116 
2117     KConfigGroup cfg =  KSharedConfig::openConfig()->group("advancedColorSelector");
2118     if (defaultValue || cfg.readEntry("useCustomColorSpace", true)) {
2119         KoColorSpaceRegistry* csr = KoColorSpaceRegistry::instance();
2120         QString modelID = cfg.readEntry("customColorSpaceModel", "RGBA");
2121         QString depthID = cfg.readEntry("customColorSpaceDepthID", "U8");
2122         QString profile = cfg.readEntry("customColorSpaceProfile", "sRGB built-in - (lcms internal)");
2123         if (profile == "default") {
2124           // qDebug() << "Falling back to default color profile.";
2125           profile = "sRGB built-in - (lcms internal)";
2126         }
2127         cs = csr->colorSpace(modelID, depthID, profile);
2128     }
2129 
2130     return cs;
2131 }
2132 
2133 void KisConfig::setCustomColorSelectorColorSpace(const KoColorSpace *cs)
2134 {
2135     KConfigGroup cfg =  KSharedConfig::openConfig()->group("advancedColorSelector");
2136     cfg.writeEntry("useCustomColorSpace", bool(cs));
2137     if(cs) {
2138         cfg.writeEntry("customColorSpaceModel", cs->colorModelId().id());
2139         cfg.writeEntry("customColorSpaceDepthID", cs->colorDepthId().id());
2140         cfg.writeEntry("customColorSpaceProfile", cs->profile()->name());
2141     }
2142 }
2143 
2144 bool KisConfig::enableOpenGLFramerateLogging(bool defaultValue) const
2145 {
2146     return (defaultValue ? false : m_cfg.readEntry("enableOpenGLFramerateLogging", false));
2147 }
2148 
2149 void KisConfig::setEnableOpenGLFramerateLogging(bool value) const
2150 {
2151     m_cfg.writeEntry("enableOpenGLFramerateLogging", value);
2152 }
2153 
2154 bool KisConfig::enableBrushSpeedLogging(bool defaultValue) const
2155 {
2156     return (defaultValue ? false : m_cfg.readEntry("enableBrushSpeedLogging", false));
2157 }
2158 
2159 void KisConfig::setEnableBrushSpeedLogging(bool value) const
2160 {
2161     m_cfg.writeEntry("enableBrushSpeedLogging", value);
2162 }
2163 
2164 void KisConfig::setDisableVectorOptimizations(bool value)
2165 {
2166     // use the old key name for compatibility
2167     m_cfg.writeEntry("amdDisableVectorWorkaround", value);
2168 }
2169 
2170 bool KisConfig::disableVectorOptimizations(bool defaultValue) const
2171 {
2172     // use the old key name for compatibility
2173     return (defaultValue ? false : m_cfg.readEntry("amdDisableVectorWorkaround", false));
2174 }
2175 
2176 void KisConfig::setDisableAVXOptimizations(bool value)
2177 {
2178     m_cfg.writeEntry("disableAVXOptimizations", value);
2179 }
2180 
2181 bool KisConfig::disableAVXOptimizations(bool defaultValue) const
2182 {
2183     return (defaultValue ? false : m_cfg.readEntry("disableAVXOptimizations", false));
2184 }
2185 
2186 void KisConfig::setAnimationPlaybackBackend(int value)
2187 {
2188     m_cfg.writeEntry("animationPlaybackBackend", value);
2189 }
2190 
2191 int KisConfig::animationPlaybackBackend(bool defaultValue) const
2192 {
2193     return (defaultValue ? 1 : m_cfg.readEntry("animationPlaybackBackend", 1));
2194 }
2195 
2196 void KisConfig::setAnimationDropFrames(bool value)
2197 {
2198     bool oldValue = animationDropFrames();
2199 
2200     if (value == oldValue) return;
2201 
2202     m_cfg.writeEntry("animationDropFrames", value);
2203     KisConfigNotifier::instance()->notifyDropFramesModeChanged();
2204 }
2205 
2206 bool KisConfig::autoPinLayersToTimeline(bool defaultValue) const
2207 {
2208     return (defaultValue ? true : m_cfg.readEntry("autoPinLayers", true));
2209 }
2210 
2211 void KisConfig::setAutoPinLayersToTimeline(bool value)
2212 {
2213     m_cfg.writeEntry("autoPinLayers", value);
2214 }
2215 
2216 bool KisConfig::adaptivePlaybackRange(bool defaultValue) const
2217 {
2218     return (defaultValue ? true : m_cfg.readEntry("adaptivePlaybackRange", true));
2219 }
2220 
2221 void KisConfig::setAdaptivePlaybackRange(bool value)
2222 {
2223     m_cfg.writeEntry("adaptivePlaybackRange", value);
2224 }
2225 
2226 QString KisConfig::ffmpegLocation(bool defaultValue) const {
2227     return (defaultValue ? "" : m_cfg.readEntry("ffmpegLocation", ""));
2228 }
2229 
2230 void KisConfig::setFFMpegLocation(const QString& value) {
2231     m_cfg.writeEntry("ffmpegLocation", value);
2232 }   
2233 
2234 qreal KisConfig::timelineZoom(bool defaultValue) const
2235 {
2236     return (defaultValue ? 1.0f : m_cfg.readEntry("timelineZoom", 1.0f));
2237 }
2238 
2239 void KisConfig::setTimelineZoom(qreal value)
2240 {
2241     m_cfg.writeEntry("timelineZoom", value);
2242 }
2243 
2244 bool KisConfig::animationDropFrames(bool defaultValue) const
2245 {
2246     return (defaultValue ? true : m_cfg.readEntry("animationDropFrames", true));
2247 }
2248 
2249 int KisConfig::scrubbingUpdatesDelay(bool defaultValue) const
2250 {
2251     return (defaultValue ? 30 : m_cfg.readEntry("scrubbingUpdatesDelay", 30));
2252 }
2253 
2254 void KisConfig::setScrubbingUpdatesDelay(int value)
2255 {
2256     m_cfg.writeEntry("scrubbingUpdatesDelay", value);
2257 }
2258 
2259 int KisConfig::scrubbingAudioUpdatesDelay(bool defaultValue) const
2260 {
2261     return (defaultValue ? -1 : m_cfg.readEntry("scrubbingAudioUpdatesDelay", -1));
2262 }
2263 
2264 void KisConfig::setScrubbingAudioUpdatesDelay(int value)
2265 {
2266     m_cfg.writeEntry("scrubbingAudioUpdatesDelay", value);
2267 }
2268 
2269 int KisConfig::audioOffsetTolerance(bool defaultValue) const
2270 {
2271     return (defaultValue ? -1 : m_cfg.readEntry("audioOffsetTolerance", -1));
2272 }
2273 
2274 void KisConfig::setAudioOffsetTolerance(int value)
2275 {
2276     m_cfg.writeEntry("audioOffsetTolerance", value);
2277 }
2278 
2279 bool KisConfig::switchSelectionCtrlAlt(bool defaultValue) const
2280 {
2281     return defaultValue ? false : m_cfg.readEntry("switchSelectionCtrlAlt", false);
2282 }
2283 
2284 void KisConfig::setSwitchSelectionCtrlAlt(bool value)
2285 {
2286     m_cfg.writeEntry("switchSelectionCtrlAlt", value);
2287 }
2288 
2289 bool KisConfig::convertToImageColorspaceOnImport(bool defaultValue) const
2290 {
2291     return defaultValue ? false : m_cfg.readEntry("ConvertToImageColorSpaceOnImport", false);
2292 }
2293 
2294 void KisConfig::setConvertToImageColorspaceOnImport(bool value)
2295 {
2296     m_cfg.writeEntry("ConvertToImageColorSpaceOnImport", value);
2297 }
2298 
2299 int KisConfig::stabilizerSampleSize(bool defaultValue) const
2300 {
2301 #ifdef Q_OS_WIN
2302     const int defaultSampleSize = 50;
2303 #else
2304     const int defaultSampleSize = 15;
2305 #endif
2306 
2307     return defaultValue ?
2308         defaultSampleSize : m_cfg.readEntry("stabilizerSampleSize", defaultSampleSize);
2309 }
2310 
2311 void KisConfig::setStabilizerSampleSize(int value)
2312 {
2313     m_cfg.writeEntry("stabilizerSampleSize", value);
2314 }
2315 
2316 bool KisConfig::stabilizerDelayedPaint(bool defaultValue) const
2317 {
2318     const bool defaultEnabled = true;
2319 
2320     return defaultValue ?
2321         defaultEnabled : m_cfg.readEntry("stabilizerDelayedPaint", defaultEnabled);
2322 }
2323 
2324 void KisConfig::setStabilizerDelayedPaint(bool value)
2325 {
2326     m_cfg.writeEntry("stabilizerDelayedPaint", value);
2327 }
2328 
2329 bool KisConfig::showBrushHud(bool defaultValue) const
2330 {
2331     return defaultValue ? false : m_cfg.readEntry("showBrushHud", false);
2332 }
2333 
2334 void KisConfig::setShowBrushHud(bool value)
2335 {
2336     m_cfg.writeEntry("showBrushHud", value);
2337 }
2338 
2339 bool KisConfig::showPaletteBottomBar(bool defaultValue) const
2340 {
2341     return defaultValue ? true : m_cfg.readEntry("showPaletteBottomBar", true);
2342 }
2343 
2344 void KisConfig::setShowPaletteBottomBar(bool value)
2345 {
2346     m_cfg.writeEntry("showPaletteBottomBar", value);
2347 }
2348 
2349 QString KisConfig::brushHudSetting(bool defaultValue) const
2350 {
2351     QString defaultDoc = "<!DOCTYPE hud_properties>\n<hud_properties>\n <version value=\"1\" type=\"value\"/>\n <paintbrush>\n  <properties_list type=\"array\">\n   <item_0 value=\"size\" type=\"value\"/>\n   <item_1 value=\"opacity\" type=\"value\"/>\n   <item_2 value=\"angle\" type=\"value\"/>\n  </properties_list>\n </paintbrush>\n <colorsmudge>\n  <properties_list type=\"array\">\n   <item_0 value=\"size\" type=\"value\"/>\n   <item_1 value=\"opacity\" type=\"value\"/>\n   <item_2 value=\"smudge_mode\" type=\"value\"/>\n   <item_3 value=\"smudge_length\" type=\"value\"/>\n   <item_4 value=\"smudge_color_rate\" type=\"value\"/>\n  </properties_list>\n </colorsmudge>\n <sketchbrush>\n  <properties_list type=\"array\">\n   <item_0 value=\"opacity\" type=\"value\"/>\n   <item_1 value=\"size\" type=\"value\"/>\n  </properties_list>\n </sketchbrush>\n <hairybrush>\n  <properties_list type=\"array\">\n   <item_0 value=\"size\" type=\"value\"/>\n   <item_1 value=\"opacity\" type=\"value\"/>\n  </properties_list>\n </hairybrush>\n <experimentbrush>\n  <properties_list type=\"array\">\n   <item_0 value=\"opacity\" type=\"value\"/>\n   <item_1 value=\"shape_windingfill\" type=\"value\"/>\n  </properties_list>\n </experimentbrush>\n <spraybrush>\n  <properties_list type=\"array\">\n   <item_0 value=\"size\" type=\"value\"/>\n   <item_1 value=\"opacity\" type=\"value\"/>\n   <item_2 value=\"spray_particlecount\" type=\"value\"/>\n   <item_3 value=\"spray_density\" type=\"value\"/>\n  </properties_list>\n </spraybrush>\n <hatchingbrush>\n  <properties_list type=\"array\">\n   <item_0 value=\"size\" type=\"value\"/>\n   <item_1 value=\"opacity\" type=\"value\"/>\n   <item_2 value=\"hatching_angle\" type=\"value\"/>\n   <item_3 value=\"hatching_thickness\" type=\"value\"/>\n   <item_4 value=\"hatching_separation\" type=\"value\"/>\n  </properties_list>\n </hatchingbrush>\n <gridbrush>\n  <properties_list type=\"array\">\n   <item_0 value=\"size\" type=\"value\"/>\n   <item_1 value=\"opacity\" type=\"value\"/>\n   <item_2 value=\"grid_divisionlevel\" type=\"value\"/>\n  </properties_list>\n </gridbrush>\n <curvebrush>\n  <properties_list type=\"array\">\n   <item_0 value=\"opacity\" type=\"value\"/>\n   <item_1 value=\"curve_historysize\" type=\"value\"/>\n   <item_2 value=\"curve_linewidth\" type=\"value\"/>\n   <item_3 value=\"curve_lineopacity\" type=\"value\"/>\n   <item_4 value=\"curve_connectionline\" type=\"value\"/>\n  </properties_list>\n </curvebrush>\n <dynabrush>\n  <properties_list type=\"array\">\n   <item_0 value=\"dyna_diameter\" type=\"value\"/>\n   <item_1 value=\"opacity\" type=\"value\"/>\n   <item_2 value=\"dyna_mass\" type=\"value\"/>\n   <item_3 value=\"dyna_drag\" type=\"value\"/>\n  </properties_list>\n </dynabrush>\n <particlebrush>\n  <properties_list type=\"array\">\n   <item_0 value=\"opacity\" type=\"value\"/>\n   <item_1 value=\"particle_particles\" type=\"value\"/>\n   <item_2 value=\"particle_opecityweight\" type=\"value\"/>\n   <item_3 value=\"particle_iterations\" type=\"value\"/>\n  </properties_list>\n </particlebrush>\n <duplicate>\n  <properties_list type=\"array\">\n   <item_0 value=\"size\" type=\"value\"/>\n   <item_1 value=\"opacity\" type=\"value\"/>\n   <item_2 value=\"clone_healing\" type=\"value\"/>\n   <item_3 value=\"clone_movesource\" type=\"value\"/>\n  </properties_list>\n </duplicate>\n <deformbrush>\n  <properties_list type=\"array\">\n   <item_0 value=\"size\" type=\"value\"/>\n   <item_1 value=\"opacity\" type=\"value\"/>\n   <item_2 value=\"deform_amount\" type=\"value\"/>\n   <item_3 value=\"deform_mode\" type=\"value\"/>\n  </properties_list>\n </deformbrush>\n <tangentnormal>\n  <properties_list type=\"array\">\n   <item_0 value=\"size\" type=\"value\"/>\n   <item_1 value=\"opacity\" type=\"value\"/>\n  </properties_list>\n </tangentnormal>\n <filter>\n  <properties_list type=\"array\">\n   <item_0 value=\"size\" type=\"value\"/>\n   <item_1 value=\"opacity\" type=\"value\"/>\n  </properties_list>\n </filter>\n <roundmarker>\n  <properties_list type=\"array\">\n   <item_0 value=\"opacity\" type=\"value\"/>\n   <item_1 value=\"size\" type=\"value\"/>\n  </properties_list>\n </roundmarker>\n</hud_properties>\n";
2352     return defaultValue ? defaultDoc : m_cfg.readEntry("brushHudSettings", defaultDoc);
2353 }
2354 
2355 void KisConfig::setBrushHudSetting(const QString &value) const
2356 {
2357     m_cfg.writeEntry("brushHudSettings", value);
2358 }
2359 
2360 bool KisConfig::calculateAnimationCacheInBackground(bool defaultValue) const
2361 {
2362     return defaultValue ? true : m_cfg.readEntry("calculateAnimationCacheInBackground", true);
2363 }
2364 
2365 void KisConfig::setCalculateAnimationCacheInBackground(bool value)
2366 {
2367     m_cfg.writeEntry("calculateAnimationCacheInBackground", value);
2368 }
2369 
2370 QColor KisConfig::defaultAssistantsColor(bool defaultValue) const
2371 {
2372     static const QColor defaultColor = QColor(176, 176, 176, 255);
2373     return defaultValue ? defaultColor : m_cfg.readEntry("defaultAssistantsColor", defaultColor);
2374 }
2375 
2376 void KisConfig::setDefaultAssistantsColor(const QColor &color) const
2377 {
2378     m_cfg.writeEntry("defaultAssistantsColor", color);
2379 }
2380 
2381 bool KisConfig::autoSmoothBezierCurves(bool defaultValue) const
2382 {
2383     return defaultValue ? false : m_cfg.readEntry("autoSmoothBezierCurves", false);
2384 }
2385 
2386 void KisConfig::setAutoSmoothBezierCurves(bool value)
2387 {
2388     m_cfg.writeEntry("autoSmoothBezierCurves", value);
2389 }
2390 
2391 bool KisConfig::activateTransformToolAfterPaste(bool defaultValue) const
2392 {
2393     return defaultValue ? false : m_cfg.readEntry("activateTransformToolAfterPaste", false);
2394 }
2395 
2396 void KisConfig::setActivateTransformToolAfterPaste(bool value)
2397 {
2398     m_cfg.writeEntry("activateTransformToolAfterPaste", value);
2399 }
2400 
2401 bool KisConfig::zoomHorizontal(bool defaultValue) const
2402 {
2403     return defaultValue ? false : m_cfg.readEntry("zoomHorizontal", false);
2404 }
2405 
2406 void KisConfig::setZoomHorizontal(bool value)
2407 {
2408     m_cfg.writeEntry("zoomHorizontal", value);
2409 }
2410 
2411 KisConfig::RootSurfaceFormat KisConfig::rootSurfaceFormat(bool defaultValue) const
2412 {
2413     const QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
2414     QSettings kritarc(configPath + QStringLiteral("/kritadisplayrc"), QSettings::IniFormat);
2415 
2416     return rootSurfaceFormat(&kritarc, defaultValue);
2417 }
2418 
2419 void KisConfig::setRootSurfaceFormat(KisConfig::RootSurfaceFormat value)
2420 {
2421     const QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
2422     QSettings kritarc(configPath + QStringLiteral("/kritadisplayrc"), QSettings::IniFormat);
2423 
2424     setRootSurfaceFormat(&kritarc, value);
2425 }
2426 
2427 KisConfig::RootSurfaceFormat KisConfig::rootSurfaceFormat(QSettings *displayrc, bool defaultValue)
2428 {
2429     QString textValue = "bt709-g22";
2430 
2431     if (!defaultValue) {
2432         textValue = displayrc->value("rootSurfaceFormat", textValue).toString();
2433     }
2434 
2435     return textValue == "bt709-g10" ? BT709_G10 :
2436            textValue == "bt2020-pq" ? BT2020_PQ :
2437            BT709_G22;
2438 }
2439 
2440 void KisConfig::setRootSurfaceFormat(QSettings *displayrc, KisConfig::RootSurfaceFormat value)
2441 {
2442     const QString textValue =
2443         value == BT709_G10 ? "bt709-g10" :
2444         value == BT2020_PQ ? "bt2020-pq" :
2445         "bt709-g22";
2446 
2447     displayrc->setValue("rootSurfaceFormat", textValue);
2448 }
2449 
2450 bool KisConfig::useZip64(bool defaultValue) const
2451 {
2452     return defaultValue ? false : m_cfg.readEntry("UseZip64", false);
2453 }
2454 
2455 void KisConfig::setUseZip64(bool value)
2456 {
2457     m_cfg.writeEntry("UseZip64", value);
2458 }
2459 
2460 bool KisConfig::convertLayerColorSpaceInProperties(bool defaultValue) const
2461 {
2462     return defaultValue ? true : m_cfg.readEntry("convertLayerColorSpaceInProperties", true);
2463 }
2464 
2465 void KisConfig::setConvertLayerColorSpaceInProperties(bool value)
2466 {
2467     m_cfg.writeEntry("convertLayerColorSpaceInProperties", value);
2468 }
2469 
2470 bool KisConfig::renamePastedLayers(bool defaultValue) const
2471 {
2472     return defaultValue ? true : m_cfg.readEntry("renamePastedLayers", true);
2473 }
2474 
2475 void KisConfig::setRenamePastedLayers(bool value)
2476 {
2477     m_cfg.writeEntry("renamePastedLayers", value);
2478 }
2479 
2480 KisConfig::LayerInfoTextStyle KisConfig::layerInfoTextStyle(bool defaultValue) const
2481 {
2482     return (KisConfig::LayerInfoTextStyle)(defaultValue ? INFOTEXT_NONE : m_cfg.readEntry("layerInfoTextStyle", (int)INFOTEXT_NONE));
2483 }
2484 
2485 void KisConfig::setLayerInfoTextStyle(KisConfig::LayerInfoTextStyle value)
2486 {
2487     m_cfg.writeEntry("layerInfoTextStyle", (int)value);
2488 }
2489 
2490 int KisConfig::layerInfoTextOpacity(bool defaultValue) const
2491 {
2492     return defaultValue ? 55 : m_cfg.readEntry("layerInfoTextOpacity", 55);
2493 }
2494 
2495 void KisConfig::setLayerInfoTextOpacity(int value)
2496 {
2497     m_cfg.writeEntry("layerInfoTextOpacity", value);
2498 }
2499 
2500 bool KisConfig::useInlineLayerInfoText(bool defaultValue) const
2501 {
2502     return defaultValue ? false : m_cfg.readEntry("useInlineLayerInfoText", false);
2503 }
2504 
2505 void KisConfig::setUseInlineLayerInfoText(bool value)
2506 {
2507     m_cfg.writeEntry("useInlineLayerInfoText", value);
2508 }
2509 
2510 bool KisConfig::useLayerSelectionCheckbox(bool defaultValue) const
2511 {
2512     return defaultValue ? false : m_cfg.readEntry("useLayerSelectionCheckbox", true);
2513 }
2514 
2515 void KisConfig::setUseLayerSelectionCheckbox(bool value)
2516 {
2517     m_cfg.writeEntry("useLayerSelectionCheckbox", value);
2518 }
2519 
2520 KisConfig::AssistantsDrawMode KisConfig::assistantsDrawMode(bool defaultValue) const
2521 {
2522     if (defaultValue) {
2523         return ASSISTANTS_DRAW_MODE_DIRECT;
2524     }
2525 
2526     return static_cast<AssistantsDrawMode>(
2527                 m_cfg.readEntry("assistantsDrawMode", static_cast<int>(ASSISTANTS_DRAW_MODE_DIRECT)));
2528 }
2529 
2530 void  KisConfig::setAssistantsDrawMode(AssistantsDrawMode value)
2531 {
2532     m_cfg.writeEntry("assistantsDrawMode", static_cast<int>(value));
2533 }
2534 
2535 #include <QDomDocument>
2536 #include <QDomElement>
2537 
2538 void KisConfig::writeKoColor(const QString& name, const KoColor& color) const
2539 {
2540     QDomDocument doc = QDomDocument(name);
2541     QDomElement el = doc.createElement(name);
2542     doc.appendChild(el);
2543     color.toXML(doc, el);
2544     m_cfg.writeEntry(name, doc.toString());
2545 }
2546 
2547 //ported from kispropertiesconfig.
2548 KoColor KisConfig::readKoColor(const QString& name, const KoColor& _color) const
2549 {
2550     QDomDocument doc;
2551 
2552     KoColor color = _color;
2553 
2554     if (!m_cfg.readEntry(name).isNull()) {
2555         doc.setContent(m_cfg.readEntry(name));
2556         QDomElement e = doc.documentElement().firstChild().toElement();
2557         color = KoColor::fromXML(e, Integer16BitsColorDepthID.id());
2558     }
2559     else {
2560         QString blackColor = "<!DOCTYPE Color>\n<Color>\n <RGB r=\"0\" space=\"sRGB-elle-V2-srgbtrc.icc\" b=\"0\" g=\"0\"/>\n</Color>\n";
2561         doc.setContent(blackColor);
2562         QDomElement e = doc.documentElement().firstChild().toElement();
2563         color =  KoColor::fromXML(e, Integer16BitsColorDepthID.id());
2564     }
2565     return color;
2566 
2567 }