Commit 9c8b5b14 authored by Adrian Page's avatar Adrian Page

Port to KConfigGroup.


svn path=/trunk/koffice/; revision=651465
parent e4d3138c
......@@ -43,107 +43,100 @@ namespace {
}
KisConfig::KisConfig()
: m_cfg(KGlobal::config()->group(""))
{
m_cfg = KGlobal::config();
if (!m_cfg) {
// Allow unit tests to test parts of the code without having to run the
// full application.
m_cfg = KSharedConfig::openConfig();
}
m_cfg->setGroup("");
}
KisConfig::~KisConfig()
{
m_cfg->sync();
m_cfg.sync();
}
int KisConfig::borderSize() const
{
return m_cfg->readEntry( "borderSize", DEFAULT_BORDER_SIZE );
return m_cfg.readEntry( "borderSize", DEFAULT_BORDER_SIZE );
}
void KisConfig::setBorderSize( int borderSize )
{
m_cfg->writeEntry( "borderSize", borderSize );
m_cfg.writeEntry( "borderSize", borderSize );
}
bool KisConfig::fixDockerWidth() const
{
return m_cfg->readEntry("fixDockerWidth", true);
return m_cfg.readEntry("fixDockerWidth", true);
}
void KisConfig::setFixedDockerWidth(bool fix)
{
m_cfg->writeEntry("fixDockerWidth", fix);
m_cfg.writeEntry("fixDockerWidth", fix);
}
bool KisConfig::useProjections() const
{
return m_cfg->readEntry( "useProjections", true );
return m_cfg.readEntry( "useProjections", true );
}
void KisConfig::setUseProjections( bool useProj )
{
m_cfg->writeEntry( "useProjections", useProj );
m_cfg.writeEntry( "useProjections", useProj );
}
bool KisConfig::undoEnabled() const
{
return m_cfg->readEntry("undoEnabled", true);
return m_cfg.readEntry("undoEnabled", true);
}
void KisConfig::setUndoEnabled(bool undo)
{
m_cfg->writeEntry("undoEnabled", undo);
m_cfg.writeEntry("undoEnabled", undo);
}
qint32 KisConfig::defUndoLimit() const
{
return m_cfg->readEntry("undolimit", DEFAULT_UNDO_LIMIT);
return m_cfg.readEntry("undolimit", DEFAULT_UNDO_LIMIT);
}
void KisConfig::defUndoLimit(qint32 limit)
{
m_cfg->writeEntry("undolimit", limit);
m_cfg.writeEntry("undolimit", limit);
}
qint32 KisConfig::defImgWidth() const
{
return m_cfg->readEntry("imgWidthDef", IMG_DEFAULT_WIDTH);
return m_cfg.readEntry("imgWidthDef", IMG_DEFAULT_WIDTH);
}
qint32 KisConfig::defImgHeight() const
{
return m_cfg->readEntry("imgHeightDef", IMG_DEFAULT_HEIGHT);
return m_cfg.readEntry("imgHeightDef", IMG_DEFAULT_HEIGHT);
}
double KisConfig::defImgResolution() const
{
return m_cfg->readEntry("imgResolutionDef", IMG_DEFAULT_RESOLUTION);
return m_cfg.readEntry("imgResolutionDef", IMG_DEFAULT_RESOLUTION);
}
void KisConfig::defImgWidth(qint32 width)
{
m_cfg->writeEntry("imgWidthDef", width);
m_cfg.writeEntry("imgWidthDef", width);
}
void KisConfig::defImgHeight(qint32 height)
{
m_cfg->writeEntry("imgHeightDef", height);
m_cfg.writeEntry("imgHeightDef", height);
}
void KisConfig::defImgResolution(double res)
{
m_cfg->writeEntry("imgResolutionDef", res);
m_cfg.writeEntry("imgResolutionDef", res);
}
enumCursorStyle KisConfig::cursorStyle() const
{
return (enumCursorStyle) m_cfg->readEntry("cursorStyleDef", int(DEFAULT_CURSOR_STYLE));
return (enumCursorStyle) m_cfg.readEntry("cursorStyleDef", int(DEFAULT_CURSOR_STYLE));
}
enumCursorStyle KisConfig::getDefaultCursorStyle() const
......@@ -153,155 +146,155 @@ enumCursorStyle KisConfig::getDefaultCursorStyle() const
void KisConfig::setCursorStyle(enumCursorStyle style)
{
m_cfg->writeEntry("cursorStyleDef", (int)style);
m_cfg.writeEntry("cursorStyleDef", (int)style);
}
QString KisConfig::monitorProfile() const
{
return m_cfg->readEntry("monitorProfile", "");
return m_cfg.readEntry("monitorProfile", "");
}
void KisConfig::setMonitorProfile(const QString & monitorProfile)
{
m_cfg->writeEntry("monitorProfile", monitorProfile);
m_cfg.writeEntry("monitorProfile", monitorProfile);
}
QString KisConfig::workingColorSpace() const
{
return m_cfg->readEntry("workingColorSpace", "RGBA");
return m_cfg.readEntry("workingColorSpace", "RGBA");
}
void KisConfig::setWorkingColorSpace(const QString & workingColorSpace)
{
m_cfg->writeEntry(workingColorSpace, workingColorSpace);
m_cfg.writeEntry(workingColorSpace, workingColorSpace);
}
QString KisConfig::printerColorSpace() const
{
return m_cfg->readEntry("printerColorSpace", "CMYK");
return m_cfg.readEntry("printerColorSpace", "CMYK");
}
void KisConfig::setPrinterColorSpace(const QString & printerColorSpace)
{
m_cfg->writeEntry("printerColorSpace", printerColorSpace);
m_cfg.writeEntry("printerColorSpace", printerColorSpace);
}
QString KisConfig::printerProfile() const
{
return m_cfg->readEntry("printerProfile", "");
return m_cfg.readEntry("printerProfile", "");
}
void KisConfig::setPrinterProfile(const QString & printerProfile)
{
m_cfg->writeEntry("printerProfile", printerProfile);
m_cfg.writeEntry("printerProfile", printerProfile);
}
bool KisConfig::useBlackPointCompensation() const
{
return m_cfg->readEntry("useBlackPointCompensation", false);
return m_cfg.readEntry("useBlackPointCompensation", false);
}
void KisConfig::setUseBlackPointCompensation(bool useBlackPointCompensation)
{
m_cfg->writeEntry("useBlackPointCompensation", useBlackPointCompensation);
m_cfg.writeEntry("useBlackPointCompensation", useBlackPointCompensation);
}
bool KisConfig::showRulers() const
{
return m_cfg->readEntry("showrulers", false);
return m_cfg.readEntry("showrulers", false);
}
void KisConfig::setShowRulers(bool rulers)
{
m_cfg->writeEntry("showrulers", rulers);
m_cfg.writeEntry("showrulers", rulers);
}
qint32 KisConfig::pasteBehaviour() const
{
return m_cfg->readEntry("pasteBehaviour", 2);
return m_cfg.readEntry("pasteBehaviour", 2);
}
void KisConfig::setPasteBehaviour(qint32 renderIntent)
{
m_cfg->writeEntry("pasteBehaviour", renderIntent);
m_cfg.writeEntry("pasteBehaviour", renderIntent);
}
qint32 KisConfig::renderIntent() const
{
return m_cfg->readEntry("renderIntent", INTENT_PERCEPTUAL);
return m_cfg.readEntry("renderIntent", INTENT_PERCEPTUAL);
}
void KisConfig::setRenderIntent(qint32 renderIntent)
{
m_cfg->writeEntry("renderIntent", renderIntent);
m_cfg.writeEntry("renderIntent", renderIntent);
}
bool KisConfig::useOpenGL() const
{
return m_cfg->readEntry("useOpenGL", false);
return m_cfg.readEntry("useOpenGL", false);
}
void KisConfig::setUseOpenGL(bool useOpenGL)
{
m_cfg->writeEntry("useOpenGL", useOpenGL);
m_cfg.writeEntry("useOpenGL", useOpenGL);
}
bool KisConfig::useOpenGLShaders() const
{
return m_cfg->readEntry("useOpenGLShaders", false);
return m_cfg.readEntry("useOpenGLShaders", false);
}
void KisConfig::setUseOpenGLShaders(bool useOpenGLShaders)
{
m_cfg->writeEntry("useOpenGLShaders", useOpenGLShaders);
m_cfg.writeEntry("useOpenGLShaders", useOpenGLShaders);
}
qint32 KisConfig::maxNumberOfThreads()
{
return m_cfg->readEntry("maxthreads", DEFAULT_MAX_THREADS);
return m_cfg.readEntry("maxthreads", DEFAULT_MAX_THREADS);
}
void KisConfig::setMaxNumberOfThreads(qint32 maxThreads)
{
m_cfg->writeEntry("maxthreads", maxThreads);
m_cfg.writeEntry("maxthreads", maxThreads);
}
qint32 KisConfig::maxTilesInMem() const
{
return m_cfg->readEntry("maxtilesinmem", DEFAULT_MAX_TILES_MEM);
return m_cfg.readEntry("maxtilesinmem", DEFAULT_MAX_TILES_MEM);
}
void KisConfig::setMaxTilesInMem(qint32 tiles)
{
m_cfg->writeEntry("maxtilesinmem", tiles);
m_cfg.writeEntry("maxtilesinmem", tiles);
}
qint32 KisConfig::swappiness() const
{
return m_cfg->readEntry("swappiness", DEFAULT_SWAPPINESS);
return m_cfg.readEntry("swappiness", DEFAULT_SWAPPINESS);
}
void KisConfig::setSwappiness(qint32 swappiness)
{
m_cfg->writeEntry("swappiness", swappiness);
m_cfg.writeEntry("swappiness", swappiness);
}
qint32 KisConfig::getPressureCorrection()
{
return m_cfg->readEntry( "pressurecorrection", DEFAULT_PRESSURE_CORRECTION );
return m_cfg.readEntry( "pressurecorrection", DEFAULT_PRESSURE_CORRECTION );
}
void KisConfig::setPressureCorrection( qint32 correction )
{
m_cfg->writeEntry( "pressurecorrection", correction );
m_cfg.writeEntry( "pressurecorrection", correction );
}
qint32 KisConfig::getDefaultPressureCorrection()
......@@ -311,32 +304,32 @@ qint32 KisConfig::getDefaultPressureCorrection()
bool KisConfig::tabletDeviceEnabled(const QString& tabletDeviceName) const
{
return m_cfg->readEntry("TabletDevice" + tabletDeviceName + "Enabled", false);
return m_cfg.readEntry("TabletDevice" + tabletDeviceName + "Enabled", false);
}
void KisConfig::setTabletDeviceEnabled(const QString& tabletDeviceName, bool enabled)
{
m_cfg->writeEntry("TabletDevice" + tabletDeviceName + "Enabled", enabled);
m_cfg.writeEntry("TabletDevice" + tabletDeviceName + "Enabled", enabled);
}
qint32 KisConfig::tabletDeviceAxis(const QString& tabletDeviceName, const QString& axisName, qint32 defaultAxis) const
{
return m_cfg->readEntry("TabletDevice" + tabletDeviceName + axisName, defaultAxis);
return m_cfg.readEntry("TabletDevice" + tabletDeviceName + axisName, defaultAxis);
}
void KisConfig::setTabletDeviceAxis(const QString& tabletDeviceName, const QString& axisName, qint32 axis) const
{
m_cfg->writeEntry("TabletDevice" + tabletDeviceName + axisName, axis);
m_cfg.writeEntry("TabletDevice" + tabletDeviceName + axisName, axis);
}
void KisConfig::setDockability( qint32 dockability )
{
m_cfg->writeEntry( "palettesdockability", dockability );
m_cfg.writeEntry( "palettesdockability", dockability );
}
qint32 KisConfig::dockability()
{
return m_cfg->readEntry("palettesdockability", DEFAULT_DOCKABILITY);
return m_cfg.readEntry("palettesdockability", DEFAULT_DOCKABILITY);
}
qint32 KisConfig::getDefaultDockability()
......@@ -346,7 +339,7 @@ qint32 KisConfig::getDefaultDockability()
float KisConfig::dockerFontSize()
{
return (float) m_cfg->readEntry("palettefontsize", (int)getDefaultDockerFontSize());
return (float) m_cfg.readEntry("palettefontsize", (int)getDefaultDockerFontSize());
}
float KisConfig::getDefaultDockerFontSize()
......@@ -358,12 +351,12 @@ float KisConfig::getDefaultDockerFontSize()
void KisConfig::setDockerFontSize(float size)
{
m_cfg->writeEntry("palettefontsize", (double)size);
m_cfg.writeEntry("palettefontsize", (double)size);
}
quint32 KisConfig::getGridMainStyle()
{
quint32 v = m_cfg->readEntry("gridmainstyle", 0);
quint32 v = m_cfg.readEntry("gridmainstyle", 0);
if (v > 2)
v = 2;
return v;
......@@ -371,125 +364,125 @@ quint32 KisConfig::getGridMainStyle()
void KisConfig::setGridMainStyle(quint32 v)
{
m_cfg->writeEntry("gridmainstyle", v);
m_cfg.writeEntry("gridmainstyle", v);
}
quint32 KisConfig::getGridSubdivisionStyle()
{
quint32 v = m_cfg->readEntry("gridsubdivisionstyle", 1);
quint32 v = m_cfg.readEntry("gridsubdivisionstyle", 1);
if (v > 2) v = 2;
return v;
}
void KisConfig::setGridSubdivisionStyle(quint32 v)
{
m_cfg->writeEntry("gridsubdivisionstyle", v);
m_cfg.writeEntry("gridsubdivisionstyle", v);
}
QColor KisConfig::getGridMainColor()
{
QColor col(99,99,99);
return m_cfg->readEntry("gridmaincolor", col);
return m_cfg.readEntry("gridmaincolor", col);
}
void KisConfig::setGridMainColor(QColor v)
{
m_cfg->writeEntry("gridmaincolor", v);
m_cfg.writeEntry("gridmaincolor", v);
}
QColor KisConfig::getGridSubdivisionColor()
{
QColor col(150,150,150);
return m_cfg->readEntry("gridsubdivisioncolor",col);
return m_cfg.readEntry("gridsubdivisioncolor",col);
}
void KisConfig::setGridSubdivisionColor(QColor v)
{
m_cfg->writeEntry("gridsubdivisioncolor", v);
m_cfg.writeEntry("gridsubdivisioncolor", v);
}
quint32 KisConfig::getGridHSpacing()
{
qint32 v = m_cfg->readEntry("gridhspacing", 10);
qint32 v = m_cfg.readEntry("gridhspacing", 10);
return (quint32)qMax(1, v );
}
void KisConfig::setGridHSpacing(quint32 v)
{
m_cfg->writeEntry("gridhspacing", v);
m_cfg.writeEntry("gridhspacing", v);
}
quint32 KisConfig::getGridVSpacing()
{
qint32 v = m_cfg->readEntry("gridvspacing", 10);
qint32 v = m_cfg.readEntry("gridvspacing", 10);
return (quint32)qMax(1, v );
}
void KisConfig::setGridVSpacing(quint32 v)
{
m_cfg->writeEntry("gridvspacing", v);
m_cfg.writeEntry("gridvspacing", v);
}
quint32 KisConfig::getGridSubdivisions()
{
qint32 v = m_cfg->readEntry("gridsubsivisons", 2);
qint32 v = m_cfg.readEntry("gridsubsivisons", 2);
return (quint32)qMax(1, v );
}
void KisConfig::setGridSubdivisions(quint32 v)
{
m_cfg->writeEntry("gridsubsivisons", v);
m_cfg.writeEntry("gridsubsivisons", v);
}
quint32 KisConfig::getGridOffsetX()
{
qint32 v = m_cfg->readEntry("gridoffsetx", 0);
qint32 v = m_cfg.readEntry("gridoffsetx", 0);
return (quint32)qMax(0, v );
}
void KisConfig::setGridOffsetX(quint32 v)
{
m_cfg->writeEntry("gridoffsetx", v);
m_cfg.writeEntry("gridoffsetx", v);
}
quint32 KisConfig::getGridOffsetY()
{
qint32 v = m_cfg->readEntry("gridoffsety", 0);
qint32 v = m_cfg.readEntry("gridoffsety", 0);
return (quint32)qMax(0, v );
}
void KisConfig::setGridOffsetY(quint32 v)
{
m_cfg->writeEntry("gridoffsety", v);
m_cfg.writeEntry("gridoffsety", v);
}
qint32 KisConfig::checkSize()
{
return m_cfg->readEntry( "checksize", 32 );
return m_cfg.readEntry( "checksize", 32 );
}
void KisConfig::setCheckSize( qint32 checksize )
{
m_cfg->writeEntry( "checksize", checksize );
m_cfg.writeEntry( "checksize", checksize );
}
bool KisConfig::scrollCheckers() const
{
return m_cfg->readEntry("scrollingcheckers", false);
return m_cfg.readEntry("scrollingcheckers", false);
}
void KisConfig::setScrollingCheckers(bool sc)
{
m_cfg->writeEntry("scrollingcheckers", sc);
m_cfg.writeEntry("scrollingcheckers", sc);
}
QColor KisConfig::checkersColor()
{
QColor col(220, 220, 220);
return m_cfg->readEntry("checkerscolor", col);
return m_cfg.readEntry("checkerscolor", col);
}
void KisConfig::setCheckersColor(QColor v)
{
m_cfg->writeEntry("checkerscolor", v);
m_cfg.writeEntry("checkerscolor", v);
}
......@@ -157,7 +157,7 @@ private:
KisConfig& operator=(const KisConfig&);
private:
mutable KSharedConfigPtr m_cfg;
mutable KConfigGroup m_cfg;
};
#endif // KIS_CONFIG_H_
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment