File indexing completed on 2024-05-12 16:01:29

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