krita/ui

kis_config.cc

Go to the documentation of this file.
00001 /*
00002  *  Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 
00019 #include "kis_config.h"
00020 #include <limits.h>
00021 
00022 #include <kglobalsettings.h>
00023 #include <kglobal.h>
00024 #include <kis_debug.h>
00025 #include <kconfig.h>
00026 #include <QFont>
00027 #include <QThread>
00028 
00029 #include <lcms.h>
00030 
00031 #include "kis_global.h"
00032 
00033 
00034 namespace
00035 {
00036 const double IMG_DEFAULT_RESOLUTION = 100.0; // dpi
00037 const qint32 IMG_DEFAULT_WIDTH = 1600;
00038 const qint32 IMG_DEFAULT_HEIGHT = 1200;
00039 const enumCursorStyle DEFAULT_CURSOR_STYLE = CURSOR_STYLE_TOOLICON;
00040 const qint32 DEFAULT_MAX_TILES_MEM = 5000;
00041 const qint32 DEFAULT_SWAPPINESS = 100;
00042 }
00043 
00044 KisConfig::KisConfig()
00045         : m_cfg(KGlobal::config()->group(""))
00046 {
00047 }
00048 
00049 KisConfig::~KisConfig()
00050 {
00051     m_cfg.sync();
00052 }
00053 
00054 
00055 bool KisConfig::useProjections() const
00056 {
00057     return m_cfg.readEntry("useProjections", true);
00058 }
00059 
00060 void KisConfig::setUseProjections(bool useProj)
00061 {
00062     m_cfg.writeEntry("useProjections", useProj);
00063 }
00064 
00065 bool KisConfig::undoEnabled() const
00066 {
00067     return m_cfg.readEntry("undoEnabled", true);
00068 }
00069 
00070 void KisConfig::setUndoEnabled(bool undo)
00071 {
00072     m_cfg.writeEntry("undoEnabled", undo);
00073 }
00074 
00075 qint32 KisConfig::defImgWidth() const
00076 {
00077     return m_cfg.readEntry("imgWidthDef", IMG_DEFAULT_WIDTH);
00078 }
00079 
00080 qint32 KisConfig::defImgHeight() const
00081 {
00082     return m_cfg.readEntry("imgHeightDef", IMG_DEFAULT_HEIGHT);
00083 }
00084 
00085 double KisConfig::defImgResolution() const
00086 {
00087     return m_cfg.readEntry("imgResolutionDef", IMG_DEFAULT_RESOLUTION) / 72.0;
00088 }
00089 
00090 void KisConfig::defImgWidth(qint32 width)
00091 {
00092     m_cfg.writeEntry("imgWidthDef", width);
00093 }
00094 
00095 void KisConfig::defImgHeight(qint32 height)
00096 {
00097     m_cfg.writeEntry("imgHeightDef", height);
00098 }
00099 
00100 void KisConfig::defImgResolution(double res)
00101 {
00102     m_cfg.writeEntry("imgResolutionDef", res*72.0);
00103 }
00104 
00105 enumCursorStyle KisConfig::cursorStyle() const
00106 {
00107     return (enumCursorStyle) m_cfg.readEntry("cursorStyleDef", int(DEFAULT_CURSOR_STYLE));
00108 }
00109 
00110 enumCursorStyle KisConfig::getDefaultCursorStyle() const
00111 {
00112     return DEFAULT_CURSOR_STYLE;
00113 }
00114 
00115 void KisConfig::setCursorStyle(enumCursorStyle style)
00116 {
00117     m_cfg.writeEntry("cursorStyleDef", (int)style);
00118 }
00119 
00120 
00121 QString KisConfig::monitorProfile() const
00122 {
00123     return m_cfg.readEntry("monitorProfile", "");
00124 }
00125 
00126 void KisConfig::setMonitorProfile(const QString & monitorProfile)
00127 {
00128     m_cfg.writeEntry("monitorProfile", monitorProfile);
00129 }
00130 
00131 
00132 QString KisConfig::workingColorSpace() const
00133 {
00134     return m_cfg.readEntry("workingColorSpace", "RGBA");
00135 }
00136 
00137 void KisConfig::setWorkingColorSpace(const QString & workingColorSpace)
00138 {
00139     m_cfg.writeEntry(workingColorSpace, workingColorSpace);
00140 }
00141 
00142 
00143 QString KisConfig::printerColorSpace() const
00144 {
00145     return m_cfg.readEntry("printerColorSpace", "RGBA");
00146 }
00147 
00148 void KisConfig::setPrinterColorSpace(const QString & printerColorSpace)
00149 {
00150     m_cfg.writeEntry("printerColorSpace", printerColorSpace);
00151 }
00152 
00153 
00154 QString KisConfig::printerProfile() const
00155 {
00156     return m_cfg.readEntry("printerProfile", "");
00157 }
00158 
00159 void KisConfig::setPrinterProfile(const QString & printerProfile)
00160 {
00161     m_cfg.writeEntry("printerProfile", printerProfile);
00162 }
00163 
00164 
00165 bool KisConfig::useBlackPointCompensation() const
00166 {
00167     return m_cfg.readEntry("useBlackPointCompensation", false);
00168 }
00169 
00170 void KisConfig::setUseBlackPointCompensation(bool useBlackPointCompensation)
00171 {
00172     m_cfg.writeEntry("useBlackPointCompensation", useBlackPointCompensation);
00173 }
00174 
00175 
00176 bool KisConfig::showRulers() const
00177 {
00178     return m_cfg.readEntry("showrulers", false);
00179 }
00180 
00181 void KisConfig::setShowRulers(bool rulers)
00182 {
00183     m_cfg.writeEntry("showrulers", rulers);
00184 }
00185 
00186 
00187 qint32 KisConfig::pasteBehaviour() const
00188 {
00189     return m_cfg.readEntry("pasteBehaviour", 2);
00190 }
00191 
00192 void KisConfig::setPasteBehaviour(qint32 renderIntent)
00193 {
00194     m_cfg.writeEntry("pasteBehaviour", renderIntent);
00195 }
00196 
00197 
00198 qint32 KisConfig::renderIntent() const
00199 {
00200     return m_cfg.readEntry("renderIntent", INTENT_PERCEPTUAL);
00201 }
00202 
00203 void KisConfig::setRenderIntent(qint32 renderIntent)
00204 {
00205     m_cfg.writeEntry("renderIntent", renderIntent);
00206 }
00207 
00208 bool KisConfig::useOpenGL() const
00209 {
00210     return m_cfg.readEntry("useOpenGL", false);
00211 }
00212 
00213 void KisConfig::setUseOpenGL(bool useOpenGL)
00214 {
00215     m_cfg.writeEntry("useOpenGL", useOpenGL);
00216 }
00217 
00218 bool KisConfig::useOpenGLShaders() const
00219 {
00220     return m_cfg.readEntry("useOpenGLShaders", false);
00221 }
00222 
00223 void KisConfig::setUseOpenGLShaders(bool useOpenGLShaders)
00224 {
00225     m_cfg.writeEntry("useOpenGLShaders", useOpenGLShaders);
00226 }
00227 
00228 qint32 KisConfig::maxNumberOfThreads()
00229 {
00230     return m_cfg.readEntry("maxthreads", QThread::idealThreadCount());
00231 }
00232 
00233 void KisConfig::setMaxNumberOfThreads(qint32 maxThreads)
00234 {
00235     m_cfg.writeEntry("maxthreads", maxThreads);
00236 }
00237 
00238 qint32 KisConfig::maxTilesInMem() const
00239 {
00240     return m_cfg.readEntry("maxtilesinmem", DEFAULT_MAX_TILES_MEM);
00241 }
00242 
00243 void KisConfig::setMaxTilesInMem(qint32 tiles)
00244 {
00245     m_cfg.writeEntry("maxtilesinmem", tiles);
00246 }
00247 
00248 qint32 KisConfig::swappiness() const
00249 {
00250     return m_cfg.readEntry("swappiness", DEFAULT_SWAPPINESS);
00251 }
00252 
00253 void KisConfig::setSwappiness(qint32 swappiness)
00254 {
00255     m_cfg.writeEntry("swappiness", swappiness);
00256 }
00257 
00258 quint32 KisConfig::getGridMainStyle()
00259 {
00260     quint32 v = m_cfg.readEntry("gridmainstyle", 0);
00261     if (v > 2)
00262         v = 2;
00263     return v;
00264 }
00265 
00266 void KisConfig::setGridMainStyle(quint32 v)
00267 {
00268     m_cfg.writeEntry("gridmainstyle", v);
00269 }
00270 
00271 quint32 KisConfig::getGridSubdivisionStyle()
00272 {
00273     quint32 v = m_cfg.readEntry("gridsubdivisionstyle", 1);
00274     if (v > 2) v = 2;
00275     return v;
00276 }
00277 
00278 void KisConfig::setGridSubdivisionStyle(quint32 v)
00279 {
00280     m_cfg.writeEntry("gridsubdivisionstyle", v);
00281 }
00282 
00283 QColor KisConfig::getGridMainColor()
00284 {
00285     QColor col(99, 99, 99);
00286     return m_cfg.readEntry("gridmaincolor", col);
00287 }
00288 
00289 void KisConfig::setGridMainColor(const QColor & v)
00290 {
00291     m_cfg.writeEntry("gridmaincolor", v);
00292 }
00293 
00294 QColor KisConfig::getGridSubdivisionColor()
00295 {
00296     QColor col(150, 150, 150);
00297     return m_cfg.readEntry("gridsubdivisioncolor", col);
00298 }
00299 
00300 void KisConfig::setGridSubdivisionColor(const QColor & v)
00301 {
00302     m_cfg.writeEntry("gridsubdivisioncolor", v);
00303 }
00304 
00305 quint32 KisConfig::getGridHSpacing()
00306 {
00307     qint32 v = m_cfg.readEntry("gridhspacing", 10);
00308     return (quint32)qMax(1, v);
00309 }
00310 
00311 void KisConfig::setGridHSpacing(quint32 v)
00312 {
00313     m_cfg.writeEntry("gridhspacing", v);
00314 }
00315 
00316 quint32 KisConfig::getGridVSpacing()
00317 {
00318     qint32 v = m_cfg.readEntry("gridvspacing", 10);
00319     return (quint32)qMax(1, v);
00320 }
00321 
00322 void KisConfig::setGridVSpacing(quint32 v)
00323 {
00324     m_cfg.writeEntry("gridvspacing", v);
00325 }
00326 
00327 quint32 KisConfig::getGridSubdivisions()
00328 {
00329     qint32 v = m_cfg.readEntry("gridsubsivisons", 2);
00330     return (quint32)qMax(1, v);
00331 }
00332 
00333 void KisConfig::setGridSubdivisions(quint32 v)
00334 {
00335     m_cfg.writeEntry("gridsubsivisons", v);
00336 }
00337 
00338 quint32 KisConfig::getGridOffsetX()
00339 {
00340     qint32 v = m_cfg.readEntry("gridoffsetx", 0);
00341     return (quint32)qMax(0, v);
00342 }
00343 
00344 void KisConfig::setGridOffsetX(quint32 v)
00345 {
00346     m_cfg.writeEntry("gridoffsetx", v);
00347 }
00348 
00349 quint32 KisConfig::getGridOffsetY()
00350 {
00351     qint32 v = m_cfg.readEntry("gridoffsety", 0);
00352     return (quint32)qMax(0, v);
00353 }
00354 
00355 void KisConfig::setGridOffsetY(quint32 v)
00356 {
00357     m_cfg.writeEntry("gridoffsety", v);
00358 }
00359 
00360 qint32 KisConfig::checkSize()
00361 {
00362     return m_cfg.readEntry("checksize", 32);
00363 }
00364 
00365 void KisConfig::setCheckSize(qint32 checksize)
00366 {
00367     m_cfg.writeEntry("checksize", checksize);
00368 }
00369 
00370 bool KisConfig::scrollCheckers() const
00371 {
00372     return m_cfg.readEntry("scrollingcheckers", false);
00373 }
00374 
00375 void KisConfig::setScrollingCheckers(bool sc)
00376 {
00377     m_cfg.writeEntry("scrollingcheckers", sc);
00378 }
00379 
00380 QColor KisConfig::checkersColor()
00381 {
00382     QColor col(220, 220, 220);
00383     return m_cfg.readEntry("checkerscolor", col);
00384 }
00385 
00386 void KisConfig::setCheckersColor(const QColor & v)
00387 {
00388     m_cfg.writeEntry("checkerscolor", v);
00389 }
00390 
00391 int KisConfig::numProjectionThreads()
00392 {
00393     return m_cfg.readEntry("maxprojectionthreads", QThread::idealThreadCount());
00394 }
00395 
00396 void KisConfig::setNumProjectThreads(int num)
00397 {
00398     m_cfg.writeEntry("maxprojectionthreads", num);
00399 }
00400 
00401 int KisConfig::projectionChunkSize()
00402 {
00403     return m_cfg.readEntry("updaterectsize", 1024);
00404 }
00405 
00406 void KisConfig::setProjectionChunkSize(int num)
00407 {
00408     m_cfg.writeEntry("updaterectsize", num);
00409 }
00410 
00411 bool KisConfig::aggregateDirtyRegionsInPainter()
00412 {
00413     return m_cfg.readEntry("aggregate_dirty_regions", true);
00414 }
00415 
00416 void KisConfig::setAggregateDirtyRegionsInPainter(bool aggregate)
00417 {
00418     m_cfg.writeEntry("aggregate_dirty_regions", aggregate);
00419 }
00420 
00421 bool KisConfig::useBoundingRectInProjection()
00422 {
00423     return m_cfg.readEntry("use_bounding_rect_of_dirty_region", true);
00424 }
00425 
00426 void KisConfig::setUseBoundingRectInProjection(bool use)
00427 {
00428     m_cfg.writeEntry("use_bounding_rect_of_dirty_region", use);
00429 }
00430 
00431 bool KisConfig::useRegionOfInterestInProjection()
00432 {
00433     return m_cfg.readEntry("use_region_of_interest", false);
00434 }
00435 
00436 void KisConfig::setUseRegionOfInterestInProjection(bool use)
00437 {
00438     m_cfg.writeEntry("use_region_of_interest", use);
00439 }
00440 
00441 bool KisConfig::useNearestNeighbour()
00442 {
00443     return m_cfg.readEntry("fast_zoom", false);
00444 }
00445 
00446 void KisConfig::setUseNearestNeighbour(bool useNearestNeigbour)
00447 {
00448     m_cfg.writeEntry("fast_zoom", useNearestNeigbour);
00449 }
00450 
00451 bool KisConfig::useMipmapping()
00452 {
00453     return m_cfg.readEntry("useMipmapping", true);
00454 }
00455 
00456 void KisConfig::setUseMipmapping(bool useMipmapping)
00457 {
00458     m_cfg.writeEntry("useMipmapping", useMipmapping);
00459 }
00460 
00461 bool KisConfig::useSampling()
00462 {
00463     return m_cfg.readEntry("sampled_scaling", false);
00464 }
00465 
00466 void KisConfig::setSampling(bool sampling)
00467 {
00468     m_cfg.writeEntry("sampled_scaling", sampling);
00469 }
00470 
00471 bool KisConfig::threadColorSpaceConversion()
00472 {
00473     return m_cfg.readEntry("thread_colorspace_conversion", false);
00474 }
00475 
00476 void KisConfig::setThreadColorSpaceConversion(bool threadColorSpaceConversion)
00477 {
00478     m_cfg.writeEntry("thread_colorspace_conversion", threadColorSpaceConversion);
00479 }
00480 
00481 bool KisConfig::cacheKisImageAsQImage()
00482 {
00483     return m_cfg.readEntry("cache_kis_image_as_qimage", true);
00484 }
00485 
00486 void KisConfig::setCacheKisImageAsQImage(bool cacheKisImageAsQImage)
00487 {
00488     m_cfg.writeEntry("cache_kis_image_as_qimage", cacheKisImageAsQImage);
00489 }
00490 
00491 
00492 bool KisConfig::drawMaskVisualisationOnUnscaledCanvasCache()
00493 {
00494     return m_cfg.readEntry("drawMaskVisualisationOnUnscaledCanvasCache", false);
00495 }
00496 
00497 void KisConfig::setDrawMaskVisualisationOnUnscaledCanvasCache(bool drawMaskVisualisationOnUnscaledCanvasCache)
00498 {
00499     m_cfg.writeEntry("drawMaskVisualisationOnUnscaledCanvasCache", drawMaskVisualisationOnUnscaledCanvasCache);
00500 }
00501 
00502 bool KisConfig::noXRender()
00503 {
00504     return m_cfg.readEntry("NoXRender",  false);
00505 }
00506 
00507 void KisConfig::setNoXRender(bool noXRender)
00508 {
00509     m_cfg.writeEntry("NoXRender",  noXRender);
00510 }
00511 
00512 bool KisConfig::showRootLayer()
00513 {
00514     return m_cfg.readEntry("ShowRootLayer", false);
00515 }
00516 
00517 void KisConfig::setShowRootLayer(bool showRootLayer)
00518 {
00519     m_cfg.writeEntry("ShowRootLayer", showRootLayer);
00520 }
00521 
00522 
00523 quint32 KisConfig::maxCachedImageSize()
00524 {
00525     // Let's say, 5 megapixels
00526     return m_cfg.readEntry("maxCachedImageSize", 5);
00527 }
00528 
00529 void KisConfig::setMaxCachedImageSize(quint32 size)
00530 {
00531     m_cfg.writeEntry("maxCachedImageSize", size);
00532 }
00533 
00534 
00535 bool KisConfig::showFilterGallery()
00536 {
00537     return m_cfg.readEntry("showFilterGallery", true);
00538 }
00539 
00540 void KisConfig::setShowFilterGallery(bool showFilterGallery)
00541 {
00542     m_cfg.writeEntry("showFilterGallery", showFilterGallery);
00543 }