kis_config.cc 35.8 KB
Newer Older
1
/*
Patrick Julien's avatar
Patrick Julien committed
2
 *  Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
3 4 5 6 7 8 9 10 11 12 13 14 15
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
16
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
 */
Boudewijn Rempt's avatar
Boudewijn Rempt committed
18 19

#include "kis_config.h"
20

21
#include <limits.h>
22

23 24
#include <QApplication>
#include <QDesktopWidget>
25
#include <QMutex>
David Faure's avatar
David Faure committed
26
#include <QFont>
27
#include <QThread>
28
#include <QStringList>
29 30 31 32

#include <kglobal.h>
#include <kconfig.h>

33
#include <KisDocument.h>
34

35
#include <KoColorSpaceRegistry.h>
36
#include <KoColorModelStandardIds.h>
37
#include <KoColorProfile.h>
Boudewijn Rempt's avatar
Boudewijn Rempt committed
38

39 40 41 42
#include <kis_debug.h>

#include "kis_canvas_resource_provider.h"
#include "kis_global.h"
43
#include "kis_config_notifier.h"
44

Yuri Chornoivan's avatar
Yuri Chornoivan committed
45
#include <config-ocio.h>
46

47
#include <kis_color_manager.h>
48

Boudewijn Rempt's avatar
Boudewijn Rempt committed
49 50
namespace
{
Boudewijn Rempt's avatar
Boudewijn Rempt committed
51 52 53
const double IMAGE_DEFAULT_RESOLUTION = 100.0; // dpi
const qint32 IMAGE_DEFAULT_WIDTH = 1600;
const qint32 IMAGE_DEFAULT_HEIGHT = 1200;
54
const enumCursorStyle DEFAULT_CURSOR_STYLE = CURSOR_STYLE_OUTLINE;
Boudewijn Rempt's avatar
Boudewijn Rempt committed
55
const qint32 DEFAULT_MAX_TILES_MEM = 5000;
56 57 58

static QMutex s_synchLocker;

59 60
}

Patrick Julien's avatar
Patrick Julien committed
61
KisConfig::KisConfig()
62
    : m_cfg(KGlobal::config()->group(""))
63 64 65 66 67
{
}

KisConfig::~KisConfig()
{
68
    s_synchLocker.lock();
Adrian Page's avatar
Adrian Page committed
69
    m_cfg.sync();
70
    s_synchLocker.unlock();
71 72 73
}


74 75 76 77 78 79 80 81 82 83
bool KisConfig::disableTouchOnCanvas() const
{
    return m_cfg.readEntry("disableTouchOnCanvas", false);
}

void KisConfig::setDisableTouchOnCanvas(bool value) const
{
    m_cfg.writeEntry("disableTouchOnCanvas", value);
}

84 85
bool KisConfig::useProjections() const
{
Boudewijn Rempt's avatar
Boudewijn Rempt committed
86
    return m_cfg.readEntry("useProjections", true);
87 88
}

89
void KisConfig::setUseProjections(bool useProj) const
90
{
Boudewijn Rempt's avatar
Boudewijn Rempt committed
91
    m_cfg.writeEntry("useProjections", useProj);
92 93
}

94 95
bool KisConfig::undoEnabled() const
{
Adrian Page's avatar
Adrian Page committed
96
    return m_cfg.readEntry("undoEnabled", true);
97 98
}

99
void KisConfig::setUndoEnabled(bool undo) const
100
{
Adrian Page's avatar
Adrian Page committed
101
    m_cfg.writeEntry("undoEnabled", undo);
102 103
}

104 105
int KisConfig::undoStackLimit() const
{
106
    return m_cfg.readEntry("undoStackLimit", 30);
107 108
}

109
void KisConfig::setUndoStackLimit(int limit) const
110 111 112
{
    m_cfg.writeEntry("undoStackLimit", limit);
}
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
bool KisConfig::useCumulativeUndoRedo()
{
    return m_cfg.readEntry("useCumulativeUndoRedo",false);
}

void KisConfig::setCumulativeUndoRedo(bool value)
{
    m_cfg.writeEntry("useCumulativeUndoRedo", value);
}

double KisConfig::stackT1()
{
     return m_cfg.readEntry("stackT1",5);
}

void KisConfig::setStackT1(int T1)
{
    m_cfg.writeEntry("stackT1", T1);
}

double KisConfig::stackT2()
{
     return m_cfg.readEntry("stackT2",1);
}

void KisConfig::setStackT2(int T2)
{
    m_cfg.writeEntry("stackT2", T2);
}

int KisConfig::stackN()
{
    return m_cfg.readEntry("stackN",5);
}

void KisConfig::setStackN(int N)
{
     m_cfg.writeEntry("stackN", N);
}
152

Boudewijn Rempt's avatar
Boudewijn Rempt committed
153
qint32 KisConfig::defImageWidth() const
154
{
Boudewijn Rempt's avatar
Boudewijn Rempt committed
155
    return m_cfg.readEntry("imageWidthDef", IMAGE_DEFAULT_WIDTH);
156 157
}

Boudewijn Rempt's avatar
Boudewijn Rempt committed
158
qint32 KisConfig::defImageHeight() const
159
{
Boudewijn Rempt's avatar
Boudewijn Rempt committed
160
    return m_cfg.readEntry("imageHeightDef", IMAGE_DEFAULT_HEIGHT);
161 162
}

Boudewijn Rempt's avatar
Boudewijn Rempt committed
163
double KisConfig::defImageResolution() const
164
{
Boudewijn Rempt's avatar
Boudewijn Rempt committed
165
    return m_cfg.readEntry("imageResolutionDef", IMAGE_DEFAULT_RESOLUTION) / 72.0;
166 167
}

168 169 170 171 172
QString KisConfig::defColorModel() const
{
    return m_cfg.readEntry("colorModelDef", KoColorSpaceRegistry::instance()->rgb8()->colorModelId().id());
}

173
void KisConfig::defColorModel(const QString & model) const
174 175 176 177
{
    m_cfg.writeEntry("colorModelDef", model);
}

178
QString KisConfig::defaultColorDepth() const
179 180 181 182
{
    return m_cfg.readEntry("colorDepthDef", KoColorSpaceRegistry::instance()->rgb8()->colorDepthId().id());
}

183
void KisConfig::setDefaultColorDepth(const QString & depth) const
184 185 186 187 188 189 190 191 192
{
    m_cfg.writeEntry("colorDepthDef", depth);
}

QString KisConfig::defColorProfile() const
{
    return m_cfg.readEntry("colorProfileDef", KoColorSpaceRegistry::instance()->rgb8()->profile()->name());
}

193
void KisConfig::defColorProfile(const QString & profile) const
194 195 196 197
{
    m_cfg.writeEntry("colorProfileDef", profile);
}

198
void KisConfig::defImageWidth(qint32 width) const
199
{
Boudewijn Rempt's avatar
Boudewijn Rempt committed
200
    m_cfg.writeEntry("imageWidthDef", width);
201 202
}

203
void KisConfig::defImageHeight(qint32 height) const
204
{
Boudewijn Rempt's avatar
Boudewijn Rempt committed
205
    m_cfg.writeEntry("imageHeightDef", height);
206 207
}

208
void KisConfig::defImageResolution(double res) const
209
{
Boudewijn Rempt's avatar
Boudewijn Rempt committed
210
    m_cfg.writeEntry("imageResolutionDef", res*72.0);
211 212
}

213 214 215 216 217 218 219 220 221 222
bool KisConfig::defAutoFrameBreakEnabled() const
{
    return m_cfg.readEntry("autoFrameBreakEnabled", false);
}

void KisConfig::defAutoFrameBreakEnabled(bool state) const
{
    m_cfg.writeEntry("autoFrameBreakEnabled", state);
}

223 224 225 226 227 228 229 230 231 232
bool KisConfig::defOnionSkinningEnabled() const
{
    return m_cfg.readEntry("onionSkinningEnabled", false);
}

void KisConfig::defOnionSkinningEnabled(bool state) const
{
    m_cfg.writeEntry("onionSkinningEnabled", state);
}

233 234 235 236 237 238 239 240 241 242
int KisConfig::defFps() const
{
    return m_cfg.readEntry("fps", 12);
}

void KisConfig::defFps(int value) const
{
    m_cfg.writeEntry("fps", value);
}

243 244 245 246 247 248 249 250 251 252
int KisConfig::defLocalPlaybackRange() const
{
    return m_cfg.readEntry("localPlaybackRange", 15);
}

void KisConfig::defLocalPlaybackRange(int value) const
{
    m_cfg.writeEntry("localPlaybackRange", value);
}

253 254 255 256 257 258 259 260 261 262
bool KisConfig::defLoopingEnabled() const
{
    return m_cfg.readEntry("loopingEnabled", true);
}

void KisConfig::defLoopingEnabled(bool state) const
{
    m_cfg.writeEntry("loopingEnabled", state);
}

263
enumCursorStyle KisConfig::cursorStyle() const
264
{
Adrian Page's avatar
Adrian Page committed
265
    return (enumCursorStyle) m_cfg.readEntry("cursorStyleDef", int(DEFAULT_CURSOR_STYLE));
266 267
}

268 269 270 271 272
enumCursorStyle KisConfig::getDefaultCursorStyle() const
{
    return DEFAULT_CURSOR_STYLE;
}

273
void KisConfig::setCursorStyle(enumCursorStyle style) const
274
{
Adrian Page's avatar
Adrian Page committed
275
    m_cfg.writeEntry("cursorStyleDef", (int)style);
276
}
277

278 279 280 281 282 283 284
bool KisConfig::useDirtyPresets() const
{
   return m_cfg.readEntry("useDirtyPresets",false);
}
void KisConfig::setUseDirtyPresets(bool value)
{
    m_cfg.writeEntry("useDirtyPresets",value);
285
    KisConfigNotifier::instance()->notifyConfigChanged();
286
}
287

288 289 290 291
bool KisConfig::useEraserBrushSize() const
{
   return m_cfg.readEntry("useEraserBrushSize",false);
}
292

293 294 295
void KisConfig::setUseEraserBrushSize(bool value)
{
    m_cfg.writeEntry("useEraserBrushSize",value);
296
    KisConfigNotifier::instance()->notifyConfigChanged();
297 298
}

299 300
QColor KisConfig::getMDIBackgroundColor() const
{
301
    QColor col(77, 77, 77);
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318
    return m_cfg.readEntry("mdiBackgroundColor", col);
}

void KisConfig::setMDIBackgroundColor(const QColor &v) const
{
    m_cfg.writeEntry("mdiBackgroundColor", v);
}

QString KisConfig::getMDIBackgroundImage() const
{
    return m_cfg.readEntry("mdiBackgroundImage", "");
}

void KisConfig::setMDIBackgroundImage(const QString &filename) const
{
    m_cfg.writeEntry("mdiBackgroundImage", filename);
}
319

320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342
QString KisConfig::monitorProfile(int screen) const
{
    QString profile = m_cfg.readEntry("monitorProfile" + QString(screen == 0 ? "": QString("_%1").arg(screen)), "");
    //qDebug() << "KisConfig::monitorProfile()" << profile;
    return profile;
}

QString KisConfig::monitorForScreen(int screen, const QString &defaultMonitor) const
{
    return m_cfg.readEntry(QString("monitor_for_screen_%1").arg(screen), defaultMonitor);
}

void KisConfig::setMonitorForScreen(int screen, const QString& monitor)
{
    m_cfg.writeEntry(QString("monitor_for_screen_%1").arg(screen), monitor);
}

void KisConfig::setMonitorProfile(int screen, const QString & monitorProfile, bool override) const
{
    m_cfg.writeEntry("monitorProfile/OverrideX11", override);
    m_cfg.writeEntry("monitorProfile" + QString(screen == 0 ? "": QString("_%1").arg(screen)), monitorProfile);
}

343 344
const KoColorProfile *KisConfig::getScreenProfile(int screen)
{
345 346 347 348 349 350 351 352 353
    KisConfig cfg;
    QString monitorId = cfg.monitorForScreen(screen, "");
    if (monitorId.isEmpty()) {
        return 0;
    }

    QByteArray bytes = KisColorManager::instance()->displayProfile(monitorId);

    if (bytes.length() > 0) {
354 355 356
        const KoColorProfile *profile = KoColorSpaceRegistry::instance()->createColorProfile(RGBAColorModelID.id(), Integer8BitsColorDepthID.id(), bytes);
        //qDebug() << "KisConfig::getScreenProfile for screen" << screen << profile->name();
        return profile;
357 358
    }
    else {
359
        //qDebug() << "Could not get a system monitor profile";
360 361 362 363
        return 0;
    }
}

364
const KoColorProfile *KisConfig::displayProfile(int screen) const
365
{
366
    // if the user plays with the settings, they can override the display profile, in which case
367
    // we don't want the system setting.
368
    bool override = m_cfg.readEntry("monitorProfile/OverrideX11", false);
369
    //qDebug() << "KisConfig::displayProfile(). Override X11:" << override;
370
    const KoColorProfile *profile = 0;
371 372
    if (override) {
        //qDebug() << "\tGoing to get the screen profile";
373 374
        profile = KisConfig::getScreenProfile(screen);
    }
375 376 377

    // if it fails. check the configuration
    if (!profile || !profile->isSuitableForDisplay()) {
378 379
        //ebug() << "\tGoing to get the monitor profile";
        QString monitorProfileName = monitorProfile(screen);
380
        //qDebug() << "\t\tmonitorProfileName:" << monitorProfileName;
381 382 383
        if (!monitorProfileName.isEmpty()) {
            profile = KoColorSpaceRegistry::instance()->profileByName(monitorProfileName);
        }
384 385 386 387 388 389
        if (profile) {
            //qDebug() << "\t\tsuitable for display6" << profile->isSuitableForDisplay();
        }
        else {
            //qDebug() << "\t\tstill no profile";
        }
390 391 392 393
    }
    // if we still don't have a profile, or the profile isn't suitable for display,
    // we need to get a last-resort profile. the built-in sRGB is a good choice then.
    if (!profile || !profile->isSuitableForDisplay()) {
394
        //qDebug() << "\tnothing worked, going to get sRGB built-in";
395
        profile = KoColorSpaceRegistry::instance()->profileByName("sRGB Built-in");
396
    }
397

398 399 400 401 402 403
    if (profile) {
        //qDebug() << "\tKisConfig::displayProfile for screen" << screen << "is" << profile->name();
    }
    else {
        //qDebug() << "\tCOuldn't get a display profile at all";
    }
404

405 406
    return profile;
}
407 408 409

QString KisConfig::workingColorSpace() const
{
Adrian Page's avatar
Adrian Page committed
410
    return m_cfg.readEntry("workingColorSpace", "RGBA");
411 412
}

413
void KisConfig::setWorkingColorSpace(const QString & workingColorSpace) const
414
{
415
    m_cfg.writeEntry("workingColorSpace", workingColorSpace);
416 417 418 419
}

QString KisConfig::printerColorSpace() const
{
420 421 422
    //TODO currently only rgb8 is supported
    //return m_cfg.readEntry("printerColorSpace", "RGBA");
    return QString("RGBA");
423 424
}

425
void KisConfig::setPrinterColorSpace(const QString & printerColorSpace) const
426
{
Adrian Page's avatar
Adrian Page committed
427
    m_cfg.writeEntry("printerColorSpace", printerColorSpace);
428 429 430 431 432
}


QString KisConfig::printerProfile() const
{
Adrian Page's avatar
Adrian Page committed
433
    return m_cfg.readEntry("printerProfile", "");
434 435
}

436
void KisConfig::setPrinterProfile(const QString & printerProfile) const
437
{
Adrian Page's avatar
Adrian Page committed
438
    m_cfg.writeEntry("printerProfile", printerProfile);
439 440 441 442 443
}


bool KisConfig::useBlackPointCompensation() const
{
444
    return m_cfg.readEntry("useBlackPointCompensation", true);
445 446
}

447
void KisConfig::setUseBlackPointCompensation(bool useBlackPointCompensation) const
448
{
Adrian Page's avatar
Adrian Page committed
449
    m_cfg.writeEntry("useBlackPointCompensation", useBlackPointCompensation);
450 451
}

452 453 454 455 456 457 458 459 460 461
bool KisConfig::allowLCMSOptimization() const
{
    return m_cfg.readEntry("allowLCMSOptimization", true);
}

void KisConfig::setAllowLCMSOptimization(bool allowLCMSOptimization)
{
    m_cfg.writeEntry("allowLCMSOptimization", allowLCMSOptimization);
}

462

463 464
bool KisConfig::showRulers() const
{
Adrian Page's avatar
Adrian Page committed
465
    return m_cfg.readEntry("showrulers", false);
466 467
}

468
void KisConfig::setShowRulers(bool rulers) const
469
{
Adrian Page's avatar
Adrian Page committed
470
    m_cfg.writeEntry("showrulers", rulers);
471
}
472 473


Laurent Montel's avatar
Laurent Montel committed
474
qint32 KisConfig::pasteBehaviour() const
475
{
Adrian Page's avatar
Adrian Page committed
476
    return m_cfg.readEntry("pasteBehaviour", 2);
477 478
}

479
void KisConfig::setPasteBehaviour(qint32 renderIntent) const
480
{
Adrian Page's avatar
Adrian Page committed
481
    m_cfg.writeEntry("pasteBehaviour", renderIntent);
482 483 484
}


Laurent Montel's avatar
Laurent Montel committed
485
qint32 KisConfig::renderIntent() const
486
{
487 488 489 490
    qint32 intent = m_cfg.readEntry("renderIntent", INTENT_PERCEPTUAL);
    if (intent > 3) intent = 3;
    if (intent < 0) intent = 0;
    return intent;
491 492
}

493
void KisConfig::setRenderIntent(qint32 renderIntent) const
494
{
495 496
    if (renderIntent > 3) renderIntent = 3;
    if (renderIntent < 0) renderIntent = 0;
Adrian Page's avatar
Adrian Page committed
497
    m_cfg.writeEntry("renderIntent", renderIntent);
498 499
}

500 501
bool KisConfig::useOpenGL() const
{
502
    if (qApp->applicationName() == "krita" || qApp->applicationName() == "kritaanimation") {
503
        //qDebug() << "use opengl" << m_cfg.readEntry("useOpenGL", true) << "success" << m_cfg.readEntry("canvasState", "OPENGL_SUCCESS");
Boudewijn Rempt's avatar
Boudewijn Rempt committed
504
        QString canvasState = m_cfg.readEntry("canvasState", "OPENGL_SUCCESS");
505
        return (m_cfg.readEntry("useOpenGL", true) && (canvasState == "OPENGL_SUCCESS" || canvasState == "TRY_OPENGL"));
506 507 508
    }
    else if (qApp->applicationName() == "kritasketch" || qApp->applicationName() == "kritagemini") {
        return true; // for sketch and gemini
509
    } else {
510 511
        return false;
    }
512 513
}

514
void KisConfig::setUseOpenGL(bool useOpenGL) const
515
{
Adrian Page's avatar
Adrian Page committed
516
    m_cfg.writeEntry("useOpenGL", useOpenGL);
517 518
}

519
int KisConfig::openGLFilteringMode() const
520
{
Boudewijn Rempt's avatar
Boudewijn Rempt committed
521
    return m_cfg.readEntry("OpenGLFilterMode", 3);
522 523
}

524
void KisConfig::setOpenGLFilteringMode(int filteringMode)
525
{
526
    m_cfg.writeEntry("OpenGLFilterMode", filteringMode);
527 528
}

529 530
bool KisConfig::useOpenGLTextureBuffer() const
{
Boudewijn Rempt's avatar
Boudewijn Rempt committed
531
    return m_cfg.readEntry("useOpenGLTextureBuffer", true);
532 533 534 535 536 537 538
}

void KisConfig::setUseOpenGLTextureBuffer(bool useBuffer)
{
    m_cfg.writeEntry("useOpenGLTextureBuffer", useBuffer);
}

539 540 541 542 543
int KisConfig::openGLTextureSize() const
{
    return m_cfg.readEntry("textureSize", 256);
}

544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569

bool KisConfig::disableDoubleBuffering() const
{
    return m_cfg.readEntry("disableDoubleBuffering", true);
}

void KisConfig::setDisableDoubleBuffering(bool disableDoubleBuffering)
{
    m_cfg.writeEntry("disableDoubleBuffering", disableDoubleBuffering);
}

bool KisConfig::disableVSync() const
{
    return m_cfg.readEntry("disableVSync", true);
}

void KisConfig::setDisableVSync(bool disableVSync)
{
    m_cfg.writeEntry("disableVSync", disableVSync);
}

bool KisConfig::showAdvancedOpenGLSettings() const
{
    return m_cfg.readEntry("showAdvancedOpenGLSettings", false);
}

570 571 572 573 574
bool KisConfig::forceOpenGLFenceWorkaround() const
{
    return m_cfg.readEntry("forceOpenGLFenceWorkaround", false);
}

575 576 577 578 579 580 581
int KisConfig::numMipmapLevels() const
{
    return m_cfg.readEntry("numMipmapLevels", 4);
}

int KisConfig::textureOverlapBorder() const
{
582
    return 1 << qMax(0, numMipmapLevels());
583 584
}

Laurent Montel's avatar
Laurent Montel committed
585
qint32 KisConfig::maxNumberOfThreads()
586
{
Boudewijn Rempt's avatar
Boudewijn Rempt committed
587
    return m_cfg.readEntry("maxthreads", QThread::idealThreadCount());
588 589
}

Laurent Montel's avatar
Laurent Montel committed
590
void KisConfig::setMaxNumberOfThreads(qint32 maxThreads)
591
{
Adrian Page's avatar
Adrian Page committed
592
    m_cfg.writeEntry("maxthreads", maxThreads);
593 594
}

Laurent Montel's avatar
Laurent Montel committed
595
qint32 KisConfig::maxTilesInMem() const
596
{
Adrian Page's avatar
Adrian Page committed
597
    return m_cfg.readEntry("maxtilesinmem", DEFAULT_MAX_TILES_MEM);
598 599
}

600
void KisConfig::setMaxTilesInMem(qint32 tiles) const
601
{
Adrian Page's avatar
Adrian Page committed
602
    m_cfg.writeEntry("maxtilesinmem", tiles);
603 604
}

605
quint32 KisConfig::getGridMainStyle() const
606
{
Adrian Page's avatar
Adrian Page committed
607
    quint32 v = m_cfg.readEntry("gridmainstyle", 0);
608 609 610
    if (v > 2)
        v = 2;
    return v;
611 612
}

613
void KisConfig::setGridMainStyle(quint32 v) const
614
{
Adrian Page's avatar
Adrian Page committed
615
    m_cfg.writeEntry("gridmainstyle", v);
616 617
}

618
quint32 KisConfig::getGridSubdivisionStyle() const
619
{
Adrian Page's avatar
Adrian Page committed
620
    quint32 v = m_cfg.readEntry("gridsubdivisionstyle", 1);
621 622
    if (v > 2) v = 2;
    return v;
623 624
}

625
void KisConfig::setGridSubdivisionStyle(quint32 v) const
626
{
Adrian Page's avatar
Adrian Page committed
627
    m_cfg.writeEntry("gridsubdivisionstyle", v);
628 629
}

630
QColor KisConfig::getGridMainColor() const
631
{
Boudewijn Rempt's avatar
Boudewijn Rempt committed
632
    QColor col(99, 99, 99);
Adrian Page's avatar
Adrian Page committed
633
    return m_cfg.readEntry("gridmaincolor", col);
634 635
}

636
void KisConfig::setGridMainColor(const QColor & v) const
637
{
Adrian Page's avatar
Adrian Page committed
638
    m_cfg.writeEntry("gridmaincolor", v);
639 640
}

641
QColor KisConfig::getGridSubdivisionColor() const
642
{
Boudewijn Rempt's avatar
Boudewijn Rempt committed
643 644
    QColor col(150, 150, 150);
    return m_cfg.readEntry("gridsubdivisioncolor", col);
645 646
}

647
void KisConfig::setGridSubdivisionColor(const QColor & v) const
648
{
Adrian Page's avatar
Adrian Page committed
649
    m_cfg.writeEntry("gridsubdivisioncolor", v);
650 651
}

652
quint32 KisConfig::getGridHSpacing() const
653
{
Adrian Page's avatar
Adrian Page committed
654
    qint32 v = m_cfg.readEntry("gridhspacing", 10);
Boudewijn Rempt's avatar
Boudewijn Rempt committed
655
    return (quint32)qMax(1, v);
656 657
}

658
void KisConfig::setGridHSpacing(quint32 v) const
659
{
Adrian Page's avatar
Adrian Page committed
660
    m_cfg.writeEntry("gridhspacing", v);
661 662
}

663
quint32 KisConfig::getGridVSpacing() const
664
{
Adrian Page's avatar
Adrian Page committed
665
    qint32 v = m_cfg.readEntry("gridvspacing", 10);
Boudewijn Rempt's avatar
Boudewijn Rempt committed
666
    return (quint32)qMax(1, v);
667 668
}

669
void KisConfig::setGridVSpacing(quint32 v) const
670
{
Adrian Page's avatar
Adrian Page committed
671
    m_cfg.writeEntry("gridvspacing", v);
672 673
}

674
bool KisConfig::getGridSpacingAspect() const
675 676 677 678 679
{
    bool v = m_cfg.readEntry("gridspacingaspect", false);
    return v;
}

680
void KisConfig::setGridSpacingAspect(bool v) const
681 682 683 684
{
    m_cfg.writeEntry("gridspacingaspect", v);
}

685
quint32 KisConfig::getGridSubdivisions() const
686
{
Adrian Page's avatar
Adrian Page committed
687
    qint32 v = m_cfg.readEntry("gridsubsivisons", 2);
Boudewijn Rempt's avatar
Boudewijn Rempt committed
688
    return (quint32)qMax(1, v);
689 690
}

691
void KisConfig::setGridSubdivisions(quint32 v) const
692
{
Adrian Page's avatar
Adrian Page committed
693
    m_cfg.writeEntry("gridsubsivisons", v);
694 695
}

696
quint32 KisConfig::getGridOffsetX() const
697
{
Adrian Page's avatar
Adrian Page committed
698
    qint32 v = m_cfg.readEntry("gridoffsetx", 0);
Boudewijn Rempt's avatar
Boudewijn Rempt committed
699
    return (quint32)qMax(0, v);
700 701
}

702
void KisConfig::setGridOffsetX(quint32 v) const
703
{
Adrian Page's avatar
Adrian Page committed
704
    m_cfg.writeEntry("gridoffsetx", v);
705 706
}

707
quint32 KisConfig::getGridOffsetY() const
708
{
Adrian Page's avatar
Adrian Page committed
709
    qint32 v = m_cfg.readEntry("gridoffsety", 0);
Boudewijn Rempt's avatar
Boudewijn Rempt committed
710
    return (quint32)qMax(0, v);
711 712
}

713
void KisConfig::setGridOffsetY(quint32 v) const
714
{
Adrian Page's avatar
Adrian Page committed
715
    m_cfg.writeEntry("gridoffsety", v);
716 717
}

718
bool KisConfig::getGridOffsetAspect() const
719 720 721 722 723
{
    bool v = m_cfg.readEntry("gridoffsetaspect", false);
    return v;
}

724
void KisConfig::setGridOffsetAspect(bool v) const
725 726 727 728
{
    m_cfg.writeEntry("gridoffsetaspect", v);
}

729
qint32 KisConfig::checkSize() const
730
{
Boudewijn Rempt's avatar
Boudewijn Rempt committed
731
    return m_cfg.readEntry("checksize", 32);
732 733
}

734
void KisConfig::setCheckSize(qint32 checksize) const
735
{
Boudewijn Rempt's avatar
Boudewijn Rempt committed
736
    m_cfg.writeEntry("checksize", checksize);
737 738 739 740
}

bool KisConfig::scrollCheckers() const
{
Adrian Page's avatar
Adrian Page committed
741
    return m_cfg.readEntry("scrollingcheckers", false);
742 743
}

744
void KisConfig::setScrollingCheckers(bool sc) const
745
{
Adrian Page's avatar
Adrian Page committed
746
    m_cfg.writeEntry("scrollingcheckers", sc);
747
}
748

749
QColor KisConfig::canvasBorderColor() const
750
{
Boudewijn Rempt's avatar
Boudewijn Rempt committed
751
    QColor color(QColor(128,128,128));
752 753 754
    return m_cfg.readEntry("canvasBorderColor", color);
}

755
void KisConfig::setCanvasBorderColor(const QColor& color) const
756 757 758 759
{
    m_cfg.writeEntry("canvasBorderColor", color);
}

760 761 762 763 764 765 766 767 768 769
bool KisConfig::hideScrollbars() const
{
    return m_cfg.readEntry("hideScrollbars", false);
}

void KisConfig::setHideScrollbars(bool value) const
{
    m_cfg.writeEntry("hideScrollbars", value);
}

770

771
QColor KisConfig::checkersColor1() const
772 773
{
    QColor col(220, 220, 220);
Adrian Page's avatar
Adrian Page committed
774
    return m_cfg.readEntry("checkerscolor", col);
775 776
}

777
void KisConfig::setCheckersColor1(const QColor & v) const
778
{
Adrian Page's avatar
Adrian Page committed
779
    m_cfg.writeEntry("checkerscolor", v);
780
}
781

782
QColor KisConfig::checkersColor2() const
783 784 785 786
{
    return m_cfg.readEntry("checkerscolor2", QColor(Qt::white));
}

787
void KisConfig::setCheckersColor2(const QColor & v) const
788 789 790 791
{
    m_cfg.writeEntry("checkerscolor2", v);
}

792
bool KisConfig::antialiasCurves() const
793
{
794
    return m_cfg.readEntry("antialiascurves", true);
795 796
}

797
void KisConfig::setAntialiasCurves(bool v) const
798 799 800 801
{
    m_cfg.writeEntry("antialiascurves", v);
}

802 803 804 805 806 807 808 809 810 811 812
QColor KisConfig::selectionOverlayMaskColor() const
{
    QColor def(255, 0, 0, 220);
    return m_cfg.readEntry("selectionOverlayMaskColor", def);
}

void KisConfig::setSelectionOverlayMaskColor(const QColor &color)
{
    m_cfg.writeEntry("selectionOverlayMaskColor", color);
}

813 814 815 816 817 818 819 820 821 822
bool KisConfig::antialiasSelectionOutline() const
{
    return m_cfg.readEntry("AntialiasSelectionOutline", false);
}

void KisConfig::setAntialiasSelectionOutline(bool v) const
{
    m_cfg.writeEntry("AntialiasSelectionOutline", v);
}

823
bool KisConfig::showRootLayer() const
824 825 826 827
{
    return m_cfg.readEntry("ShowRootLayer", false);
}

828
void KisConfig::setShowRootLayer(bool showRootLayer) const
829 830
{
    m_cfg.writeEntry("ShowRootLayer", showRootLayer);
Thomas Zander's avatar
Thomas Zander committed
831
}
832

Dmitry Kazakov's avatar
Dmitry Kazakov committed
833 834 835 836 837 838 839 840 841 842
bool KisConfig::showGlobalSelection() const
{
    return m_cfg.readEntry("ShowGlobalSelection", false);
}

void KisConfig::setShowGlobalSelection(bool showGlobalSelection) const
{
    m_cfg.writeEntry("ShowGlobalSelection", showGlobalSelection);
}

843
bool KisConfig::showOutlineWhilePainting() const
844
{
845
    return m_cfg.readEntry("ShowOutlineWhilePainting", true);
846 847
}

848
void KisConfig::setShowOutlineWhilePainting(bool showOutlineWhilePainting) const
849 850 851 852
{
    m_cfg.writeEntry("ShowOutlineWhilePainting", showOutlineWhilePainting);
}

853 854 855 856 857 858 859 860 861 862
qreal KisConfig::outlineSizeMinimum() const
{
    return m_cfg.readEntry("OutlineSizeMinimum", 1.0);
}

void KisConfig::setOutlineSizeMinimum(qreal outlineSizeMinimum) const
{
    m_cfg.writeEntry("OutlineSizeMinimum", outlineSizeMinimum);
}

863 864
int KisConfig::autoSaveInterval()  const
{
865
    return m_cfg.readEntry("AutoSaveInterval", KisDocument::defaultAutoSave());
866 867
}

868 869
void KisConfig::setAutoSaveInterval(int seconds)  const
{
870 871
    return m_cfg.writeEntry("AutoSaveInterval", seconds);
}
872

873
bool KisConfig::backupFile() const
874 875 876 877
{
    return m_cfg.readEntry("CreateBackupFile", true);
}

878
void KisConfig::setBackupFile(bool backupFile) const
879
{
880
    m_cfg.writeEntry("CreateBackupFile", backupFile);
881 882
}

883
bool KisConfig::showFilterGallery() const
884
{
885
    return m_cfg.readEntry("showFilterGallery", false);
886 887
}

888
void KisConfig::setShowFilterGallery(bool showFilterGallery) const
889 890 891
{
    m_cfg.writeEntry("showFilterGallery", showFilterGallery);
}
892

893
bool KisConfig::showFilterGalleryLayerMaskDialog() const
894 895 896 897
{
    return m_cfg.readEntry("showFilterGalleryLayerMaskDialog", true);
}

898
void KisConfig::setShowFilterGalleryLayerMaskDialog(bool showFilterGallery) const
899 900 901 902
{
    m_cfg.writeEntry("setShowFilterGalleryLayerMaskDialog", showFilterGallery);
}

903
QString KisConfig::defaultPainterlyColorModelId() const
904
{
905
    return m_cfg.readEntry("defaultpainterlycolormodel", "KS6");
906 907
}

908
void KisConfig::setDefaultPainterlyColorModelId(const QString& def) const
909
{
Edward Apap's avatar
Edward Apap committed
910
    m_cfg.writeEntry("defaultpainterlycolormodel", def);
911 912
}

913
QString KisConfig::defaultPainterlyColorDepthId() const
914 915 916 917
{
    return m_cfg.readEntry("defaultpainterlycolordepth", "F32");
}

918
void KisConfig::setDefaultPainterlyColorDepthId(const QString& def) const
919
{
Edward Apap's avatar
Edward Apap committed
920
    m_cfg.writeEntry("defaultpainterlycolordepth", def);
921
}
922 923 924 925 926 927

QString KisConfig::canvasState() const
{
    return m_cfg.readEntry("canvasState", "OPENGL_NOT_TRIED");
}

928
void KisConfig::setCanvasState(const QString& state) const
929 930 931 932 933 934 935
{
    static QStringList acceptableStates;
    if (acceptableStates.isEmpty()) {
        acceptableStates << "OPENGL_SUCCESS" << "TRY_OPENGL" << "OPENGL_NOT_TRIED" << "OPENGL_FAILED";
    }
    if (acceptableStates.contains(state)) {
        m_cfg.writeEntry("canvasState", state);
936
        m_cfg.sync();
937 938
    }
}
939 940 941 942 943 944

bool KisConfig::paintopPopupDetached() const
{
    return m_cfg.readEntry("PaintopPopupDetached", false);
}

945
void KisConfig::setPaintopPopupDetached(bool detached) const
946 947 948
{
    m_cfg.writeEntry("PaintopPopupDetached", detached);
}
949 950 951 952 953 954 955 956 957 958

QString KisConfig::pressureTabletCurve() const
{
    return m_cfg.readEntry("tabletPressureCurve","0,0;1,1;");
}

void KisConfig::setPressureTabletCurve(const QString& curveString) const
{
    m_cfg.writeEntry("tabletPressureCurve", curveString);
}
959

960
qreal KisConfig::vastScrolling() const
961
{
962
    return m_cfg.readEntry("vastScrolling", 0.9);
963 964
}

965
void KisConfig::setVastScrolling(const qreal factor) const
966
{
967
    m_cfg.writeEntry("vastScrolling", factor);
968
}
969 970 971 972 973 974

int KisConfig::presetChooserViewMode() const
{
    return m_cfg.readEntry("presetChooserViewMode", 0);
}

975
void KisConfig::setPresetChooserViewMode(const int mode) const
976 977 978 979
{
    m_cfg.writeEntry("presetChooserViewMode", mode);
}

980 981 982 983 984 985 986 987 988
bool KisConfig::firstRun() const
{
    return m_cfg.readEntry("firstRun", true);
}

void KisConfig::setFirstRun(const bool first) const
{
    m_cfg.writeEntry("firstRun", first);
}
989

990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008
int KisConfig::horizontalSplitLines() const
{
    return m_cfg.readEntry("horizontalSplitLines", 1);
}
void KisConfig::setHorizontalSplitLines(const int numberLines) const
{
    m_cfg.writeEntry("horizontalSplitLines", numberLines);
}

int KisConfig::verticalSplitLines() const
{
    return m_cfg.readEntry("verticalSplitLines", 1);
}

void KisConfig::setVerticalSplitLines(const int numberLines) const
{
    m_cfg.writeEntry("verticalSplitLines", numberLines);
}

1009 1010 1011 1012 1013 1014 1015 1016 1017
bool KisConfig::clicklessSpacePan() const
{
    return m_cfg.readEntry("clicklessSpacePan", true);
}

void KisConfig::setClicklessSpacePan(const bool toggle) const
{
    m_cfg.writeEntry("clicklessSpacePan", toggle);
}
1018 1019


1020
int KisConfig::hideDockersFullscreen() const
1021 1022 1023 1024 1025 1026 1027 1028 1029
{
    return m_cfg.readEntry("hideDockersFullScreen", (int)Qt::Checked);
}

void KisConfig::setHideDockersFullscreen(const int value) const
{
    m_cfg.writeEntry("hideDockersFullScreen", value);
}

1030 1031 1032 1033 1034 1035 1036 1037 1038 1039
bool KisConfig::showDockerTitleBars() const
{
    return m_cfg.readEntry("showDockerTitleBars", true);
}

void KisConfig::setShowDockerTitleBars(const bool value) const
{
    m_cfg.writeEntry("showDockerTitleBars", value);
}

1040
int KisConfig::hideMenuFullscreen() const
1041 1042 1043 1044 1045 1046 1047 1048 1049
{
    return m_cfg.readEntry("hideMenuFullScreen", (int)Qt::Checked);
}

void KisConfig::setHideMenuFullscreen(const int value) const
{
    m_cfg.writeEntry("hideMenuFullScreen", value);
}

1050
int KisConfig::hideScrollbarsFullscreen() const
1051 1052 1053 1054 1055 1056 1057 1058 1059
{
    return m_cfg.readEntry("hideScrollbarsFullScreen", (int)Qt::Checked);
}

void KisConfig::setHideScrollbarsFullscreen(const int value) const
{
    m_cfg.writeEntry("hideScrollbarsFullScreen", value);
}

1060
int KisConfig::hideStatusbarFullscreen() const
1061 1062 1063 1064 1065 1066 1067 1068 1069
{
    return m_cfg.readEntry("hideStatusbarFullScreen", (int)Qt::Checked);
}

void KisConfig::setHideStatusbarFullscreen(const int value) const
{
    m_cfg.writeEntry("hideStatusbarFullScreen", value);
}

1070
int KisConfig::hideTitlebarFullscreen() const
1071 1072 1073
{
    return m_cfg.readEntry("hideTitleBarFullscreen", (int)Qt::Checked);
}
1074

1075 1076 1077 1078 1079
void KisConfig::setHideTitlebarFullscreen(const int value) const
{
    m_cfg.writeEntry("hideTitleBarFullscreen", value);
}

1080
int KisConfig::hideToolbarFullscreen() const
1081 1082 1083 1084 1085 1086 1087 1088
{
    return m_cfg.readEntry("hideToolbarFullscreen", (int)Qt::Checked);
}