summaryrefslogtreecommitdiffstats
path: root/chalk/ui/kis_config.cc
blob: 64939c4a692feffdcb9a27b5d5563d900c75bedd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
/*
 *  Copyright (c) 2002 Patrick Julien <[email protected]>
 *
 *  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
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */
#include <limits.h>

#include <tdeglobalsettings.h>
#include <tdeconfig.h>
#include <tdeglobal.h>
#include <kdebug.h>
#include <config.h>

#include LCMS_HEADER

#include "kis_global.h"
#include "kis_config.h"

namespace {
    const double IMG_DEFAULT_RESOLUTION = 100.0;
    const TQ_INT32 IMG_DEFAULT_WIDTH = 512;
    const TQ_INT32 IMG_DEFAULT_HEIGHT = 512;
    const enumCursorStyle DEFAULT_CURSOR_STYLE = CURSOR_STYLE_OUTLINE;
    const TQ_INT32 DEFAULT_MAX_THREADS = 4;
    const TQ_INT32 DEFAULT_MAX_TILES_MEM = 500; // 8192 kilobytes given 64x64 tiles with 32bpp
    const TQ_INT32 DEFAULT_SWAPPINESS = 100;
    const TQ_INT32 DEFAULT_PRESSURE_CORRECTION = 50;
    const TQ_INT32 DEFAULT_DOCKABILITY = 0;
    const TQ_INT32 DEFAULT_UNDO_LIMIT = 50;
}

KisConfig::KisConfig()
{

    m_cfg = TDEGlobal::config();
    if (!m_cfg) {
        // Allow unit tests to test parts of the code without having to run the
        // full application.
        m_cfg = new TDEConfig();
    }
    m_cfg->setGroup("");
}

KisConfig::~KisConfig()
{
    m_cfg->sync();
}


bool KisConfig::fixDockerWidth() const
{
    return m_cfg->readBoolEntry("fixDockerWidth", true);
}

void KisConfig::setFixedDockerWidth(bool fix)
{
    m_cfg->writeEntry("fixDockerWidth", fix);
}

bool KisConfig::undoEnabled() const
{
    return m_cfg->readBoolEntry("undoEnabled", true);
}

void KisConfig::setUndoEnabled(bool undo)
{
    m_cfg->writeEntry("undoEnabled", undo);
}


TQ_INT32 KisConfig::defUndoLimit() const
{
    return m_cfg->readNumEntry("undolimit", DEFAULT_UNDO_LIMIT);
}

void KisConfig::defUndoLimit(TQ_INT32 limit)
{
    m_cfg->writeEntry("undolimit", limit);
}

TQ_INT32 KisConfig::defImgWidth() const
{
    return m_cfg->readNumEntry("imgWidthDef", IMG_DEFAULT_WIDTH);
}

TQ_INT32 KisConfig::defImgHeight() const
{
    return m_cfg->readNumEntry("imgHeightDef", IMG_DEFAULT_HEIGHT);
}

double KisConfig::defImgResolution() const
{
    return m_cfg->readDoubleNumEntry("imgResolutionDef", IMG_DEFAULT_RESOLUTION);
}

void KisConfig::defImgWidth(TQ_INT32 width)
{
    m_cfg->writeEntry("imgWidthDef", width);
}

void KisConfig::defImgHeight(TQ_INT32 height)
{
    m_cfg->writeEntry("imgHeightDef", height);
}

void KisConfig::defImgResolution(double res)
{
    m_cfg->writeEntry("imgResolutionDef", res);
}

enumCursorStyle KisConfig::cursorStyle() const
{
    return (enumCursorStyle) m_cfg->readNumEntry("cursorStyleDef", DEFAULT_CURSOR_STYLE);
}

enumCursorStyle KisConfig::getDefaultCursorStyle() const
{
    return DEFAULT_CURSOR_STYLE;
}

void KisConfig::setCursorStyle(enumCursorStyle style)
{
    m_cfg->writeEntry("cursorStyleDef", style);
}


TQString KisConfig::monitorProfile() const
{
    return m_cfg->readEntry("monitorProfile", "");
}

void KisConfig::setMonitorProfile(TQString monitorProfile)
{
    m_cfg->writeEntry("monitorProfile", monitorProfile);
}


TQString KisConfig::workingColorSpace() const
{
    return m_cfg->readEntry("workingColorSpace", "RGBA");
}

void KisConfig::setWorkingColorSpace(TQString workingColorSpace)
{
    m_cfg->writeEntry(workingColorSpace, workingColorSpace);
}


TQString KisConfig::printerColorSpace() const
{
    return m_cfg->readEntry("printerColorSpace", "CMYK");
}

void KisConfig::setPrinterColorSpace(TQString printerColorSpace)
{
    m_cfg->writeEntry("printerColorSpace", printerColorSpace);
}


TQString KisConfig::printerProfile() const
{
    return m_cfg->readEntry("printerProfile", "");
}

void KisConfig::setPrinterProfile(TQString printerProfile)
{
    m_cfg->writeEntry("printerProfile", printerProfile);
}


bool KisConfig::useBlackPointCompensation() const
{
    return m_cfg->readBoolEntry("useBlackPointCompensation", false);
}

void KisConfig::setUseBlackPointCompensation(bool useBlackPointCompensation)
{
    m_cfg->writeEntry("useBlackPointCompensation", useBlackPointCompensation);
}


bool KisConfig::showRulers() const
{
    return m_cfg->readBoolEntry("showrulers", false);
}

void KisConfig::setShowRulers(bool rulers)
{
    m_cfg->writeEntry("showrulers", rulers);
}


TQ_INT32 KisConfig::pasteBehaviour() const
{
    return m_cfg->readNumEntry("pasteBehaviour", 2);
}

void KisConfig::setPasteBehaviour(TQ_INT32 renderIntent)
{
    m_cfg->writeEntry("pasteBehaviour", renderIntent);
}


TQ_INT32 KisConfig::renderIntent() const
{
    return m_cfg->readNumEntry("renderIntent", INTENT_PERCEPTUAL);
}

void KisConfig::setRenderIntent(TQ_INT32 renderIntent)
{
    m_cfg->writeEntry("renderIntent", renderIntent);
}

bool KisConfig::useOpenGL() const
{
    return m_cfg->readBoolEntry("useOpenGL", false);
}

void KisConfig::setUseOpenGL(bool useOpenGL)
{
    m_cfg->writeEntry("useOpenGL", useOpenGL);
}

bool KisConfig::useOpenGLShaders() const
{
    return m_cfg->readBoolEntry("useOpenGLShaders", false);
}

void KisConfig::setUseOpenGLShaders(bool useOpenGLShaders)
{
    m_cfg->writeEntry("useOpenGLShaders", useOpenGLShaders);
}

TQ_INT32 KisConfig::maxNumberOfThreads()
{
    return m_cfg->readNumEntry("maxthreads", DEFAULT_MAX_THREADS);
}

void KisConfig::setMaxNumberOfThreads(TQ_INT32 maxThreads)
{
    m_cfg->writeEntry("maxthreads", maxThreads);
}

TQ_INT32 KisConfig::maxTilesInMem() const
{
    return m_cfg->readNumEntry("maxtilesinmem", DEFAULT_MAX_TILES_MEM);
}

void KisConfig::setMaxTilesInMem(TQ_INT32 tiles)
{
    m_cfg->writeEntry("maxtilesinmem", tiles);
}

TQ_INT32 KisConfig::swappiness() const
{
    return m_cfg->readNumEntry("swappiness", DEFAULT_SWAPPINESS);
}

void KisConfig::setSwappiness(TQ_INT32 swappiness)
{
    m_cfg->writeEntry("swappiness", swappiness);
}

TQ_INT32 KisConfig::getPressureCorrection()
{
    return m_cfg->readNumEntry( "pressurecorrection", DEFAULT_PRESSURE_CORRECTION );
}

void KisConfig::setPressureCorrection( TQ_INT32 correction )
{
    m_cfg->writeEntry( "pressurecorrection",  correction );
}

TQ_INT32 KisConfig::getDefaultPressureCorrection()
{
    return DEFAULT_PRESSURE_CORRECTION;
}

bool KisConfig::tabletDeviceEnabled(const TQString& tabletDeviceName) const
{
    return m_cfg->readBoolEntry("TabletDevice" + tabletDeviceName + "Enabled", false);
}

void KisConfig::setTabletDeviceEnabled(const TQString& tabletDeviceName, bool enabled)
{
    m_cfg->writeEntry("TabletDevice" + tabletDeviceName + "Enabled", enabled);
}

TQ_INT32 KisConfig::tabletDeviceAxis(const TQString& tabletDeviceName, const TQString& axisName, TQ_INT32 defaultAxis) const
{
    return m_cfg->readNumEntry("TabletDevice" + tabletDeviceName + axisName, defaultAxis);
}

void KisConfig::setTabletDeviceAxis(const TQString& tabletDeviceName, const TQString& axisName, TQ_INT32 axis) const
{
    m_cfg->writeEntry("TabletDevice" + tabletDeviceName + axisName, axis);
}

void KisConfig::setDockability( TQ_INT32 dockability )
{
    m_cfg->writeEntry( "palettesdockability", dockability );
}

TQ_INT32 KisConfig::dockability()
{
    return m_cfg->readNumEntry("palettesdockability", DEFAULT_DOCKABILITY);
}

TQ_INT32 KisConfig::getDefaultDockability()
{
    return DEFAULT_DOCKABILITY;
}

float KisConfig::dockerFontSize()
{
    return (float) m_cfg->readNumEntry("palettefontsize", (int)getDefaultDockerFontSize());
}

float KisConfig::getDefaultDockerFontSize()
{
    float ps = TQMIN(9, TDEGlobalSettings::generalFont().pointSize() * 0.8);
    if (ps < 6) ps = 6;
    return ps;
}

void KisConfig::setDockerFontSize(float size)
{
    m_cfg->writeEntry("palettefontsize", size);
}

TQ_UINT32 KisConfig::getGridMainStyle()
{
    TQ_UINT32 v = m_cfg->readNumEntry("gridmainstyle", 0);
    if (v > 2)
        v = 2;
    return v;
}

void KisConfig::setGridMainStyle(TQ_UINT32 v)
{
    m_cfg->writeEntry("gridmainstyle", v);
}

TQ_UINT32 KisConfig::getGridSubdivisionStyle()
{
    TQ_UINT32 v = m_cfg->readNumEntry("gridsubdivisionstyle", 1);
    if (v > 2) v = 2;
    return v;
}

void KisConfig::setGridSubdivisionStyle(TQ_UINT32 v)
{
    m_cfg->writeEntry("gridsubdivisionstyle", v);
}

TQColor KisConfig::getGridMainColor()
{
    return m_cfg->readColorEntry("gridmaincolor", new TQColor(99,99,99));
}

void KisConfig::setGridMainColor(TQColor v)
{
    m_cfg->writeEntry("gridmaincolor", v);
}

TQColor KisConfig::getGridSubdivisionColor()
{
    return m_cfg->readColorEntry("gridsubdivisioncolor", new TQColor(150,150,150));
}

void KisConfig::setGridSubdivisionColor(TQColor v)
{
    m_cfg->writeEntry("gridsubdivisioncolor", v);
}

TQ_UINT32 KisConfig::getGridHSpacing()
{
    TQ_INT32 v = m_cfg->readNumEntry("gridhspacing", 10);
    return (TQ_UINT32)TQMAX(1, v );
}

void KisConfig::setGridHSpacing(TQ_UINT32 v)
{
    m_cfg->writeEntry("gridhspacing", v);
}

TQ_UINT32 KisConfig::getGridVSpacing()
{
    TQ_INT32 v = m_cfg->readNumEntry("gridvspacing", 10);
    return (TQ_UINT32)TQMAX(1, v );
}

void KisConfig::setGridVSpacing(TQ_UINT32 v)
{
    m_cfg->writeEntry("gridvspacing", v);
}

TQ_UINT32 KisConfig::getGridSubdivisions()
{
    TQ_INT32 v = m_cfg->readNumEntry("gridsubsivisons", 2);
    return (TQ_UINT32)TQMAX(1, v );
}

void KisConfig::setGridSubdivisions(TQ_UINT32 v)
{
    return m_cfg->writeEntry("gridsubsivisons", v);
}

TQ_UINT32 KisConfig::getGridOffsetX()
{
    TQ_INT32 v = m_cfg->readNumEntry("gridoffsetx", 0);
    return (TQ_UINT32)TQMAX(0, v );
}

void KisConfig::setGridOffsetX(TQ_UINT32 v)
{
    m_cfg->writeEntry("gridoffsetx", v);
}

TQ_UINT32 KisConfig::getGridOffsetY()
{
    TQ_INT32 v = m_cfg->readNumEntry("gridoffsety", 0);
    return (TQ_UINT32)TQMAX(0, v );
}

void KisConfig::setGridOffsetY(TQ_UINT32 v)
{
    m_cfg->writeEntry("gridoffsety", v);
}