File indexing completed on 2024-05-19 08:23:17
0001 /* This file is part of the KDE project 0002 Copyright (C) 1998-2003 Carsten Pfeiffer <pfeiffer@kde.org> 0003 0004 This program is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU General Public 0006 License as published by the Free Software Foundation, version 2. 0007 0008 This program is distributed in the hope that it will be useful, 0009 but WITHOUT ANY WARRANTY; without even the implied warranty of 0010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0011 General Public License for more details. 0012 0013 You should have received a copy of the GNU General Public License 0014 along with this program; see the file COPYING. If not, write to 0015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0016 Boston, MA 02110-1301, USA. 0017 */ 0018 0019 #include "kuickdata.h" 0020 0021 #include <KConfigGroup> 0022 #include <KSharedConfig> 0023 0024 #include <QColor> 0025 0026 #include <stdlib.h> 0027 0028 0029 KuickData::KuickData() 0030 { 0031 fileFilter = "*.jpeg *.jpg *.gif *.xpm *.ppm *.pgm *.pbm *.pnm *.png *.bmp *.psd *.eim *.tif *.tiff *.xcf";// *.mng"; 0032 slideDelay = 3000; 0033 slideshowCycles = 1; 0034 slideshowFullscreen = true; 0035 slideshowStartAtFirst = true; 0036 0037 preloadImage = true; 0038 0039 isModsEnabled = true; 0040 fullScreen = false; 0041 autoRotation = true; 0042 downScale = true; 0043 upScale = false; 0044 flipVertically = false; 0045 flipHorizontally = false; 0046 0047 maxUpScale = 3; 0048 rotation = ROT_0; 0049 0050 brightnessSteps = 1; 0051 contrastSteps = 1; 0052 gammaSteps = 1; 0053 scrollSteps = 1; 0054 zoomSteps = 1.5; 0055 0056 maxZoomFactor = 4.0; 0057 0058 maxCachedImages = 4; 0059 backgroundColor = Qt::black; 0060 0061 startInLastDir = true; 0062 modificationCacheSize = 500; 0063 0064 idata = new ImData; 0065 } 0066 0067 KuickData::~KuickData() 0068 { 0069 delete idata; 0070 } 0071 0072 0073 void KuickData::load() 0074 { 0075 KSharedConfig::Ptr kc = KSharedConfig::openConfig(); 0076 0077 KuickData def; 0078 0079 KConfigGroup generalGroup( kc, "GeneralConfiguration" ); 0080 fileFilter = generalGroup.readEntry( "FileFilter", def.fileFilter ); 0081 slideDelay = generalGroup.readEntry( "SlideShowDelay", def.slideDelay ); 0082 slideshowCycles = generalGroup.readEntry( "SlideshowCycles", 1 ); 0083 slideshowFullscreen = generalGroup.readEntry( "SlideshowFullscreen", true ); 0084 slideshowStartAtFirst = generalGroup.readEntry("SlideshowStartAtFirst", true ); 0085 0086 preloadImage = generalGroup.readEntry( "PreloadNextImage", def.preloadImage ); 0087 0088 fullScreen = generalGroup.readEntry( "Fullscreen", def.fullScreen); 0089 autoRotation = generalGroup.readEntry( "AutoRotation", def.autoRotation); 0090 downScale = generalGroup.readEntry( "ShrinkToScreenSize", def.downScale ); 0091 upScale = generalGroup.readEntry( "ZoomToScreenSize", def.upScale ); 0092 flipVertically = generalGroup.readEntry( "FlipVertically", def.flipVertically ); 0093 flipHorizontally = generalGroup.readEntry( "FlipHorizontally", 0094 def.flipHorizontally ); 0095 maxUpScale = generalGroup.readEntry( "MaxUpscale Factor", def.maxUpScale ); 0096 int rawRotation = generalGroup.readEntry( "Rotation", int(def.rotation) ); 0097 0098 isModsEnabled = generalGroup.readEntry( "ApplyDefaultModifications", 0099 def.isModsEnabled ); 0100 0101 brightnessSteps = generalGroup.readEntry("BrightnessStepSize",def.brightnessSteps); 0102 contrastSteps = generalGroup.readEntry("ContrastStepSize", def.contrastSteps); 0103 gammaSteps = generalGroup.readEntry("GammaStepSize", def.gammaSteps); 0104 scrollSteps = generalGroup.readEntry("ScrollingStepSize", def.scrollSteps); 0105 zoomSteps = generalGroup.readEntry("ZoomStepSize", (double)def.zoomSteps); 0106 0107 maxZoomFactor = generalGroup.readEntry( "MaximumZoomFactorByDesktop", def.maxZoomFactor ); 0108 0109 maxWidth = abs( generalGroup.readEntry( "MaximumImageWidth", def.maxWidth ) ); 0110 maxHeight = abs( generalGroup.readEntry( "MaximumImageHeight", def.maxHeight)); 0111 0112 maxCachedImages = generalGroup.readEntry( "MaxCachedImages", 0113 def.maxCachedImages ); 0114 QColor _col(Qt::black); 0115 backgroundColor = generalGroup.readEntry( "BackgroundColor", _col ); 0116 0117 startInLastDir = generalGroup.readEntry( "StartInLastDir", true); 0118 modificationCacheSize = qMax(0, generalGroup.readEntry("ModificationCacheSize", def.modificationCacheSize)); 0119 0120 idata->load( kc ); 0121 0122 // compatibility with KuickShow <= 0.8.3 0123 switch ( rawRotation ) 0124 { 0125 case ROT_0: 0126 case ROT_90: 0127 case ROT_180: 0128 case ROT_270: 0129 rotation = (Rotation) rawRotation; 0130 break; 0131 0132 case 90: 0133 rotation = ROT_90; 0134 break; 0135 case 180: 0136 rotation = ROT_180; 0137 break; 0138 case 270: 0139 rotation = ROT_270; 0140 break; 0141 0142 default: 0143 // everything else is invalid and the default rotation is used 0144 rotation = def.rotation; 0145 break; 0146 } 0147 } 0148 0149 0150 void KuickData::save() 0151 { 0152 KSharedConfig::Ptr kc = KSharedConfig::openConfig(); 0153 0154 KConfigGroup generalGroup(kc, "GeneralConfiguration"); 0155 0156 generalGroup.writeEntry( "FileFilter", fileFilter ); 0157 generalGroup.writeEntry( "SlideShowDelay", slideDelay ); 0158 generalGroup.writeEntry( "SlideshowCycles", slideshowCycles ); 0159 generalGroup.writeEntry( "SlideshowFullscreen", slideshowFullscreen ); 0160 generalGroup.writeEntry( "SlideshowStartAtFirst", slideshowStartAtFirst ); 0161 0162 generalGroup.writeEntry( "PreloadNextImage", preloadImage ); 0163 0164 generalGroup.writeEntry( "Fullscreen", fullScreen ); 0165 generalGroup.writeEntry( "AutoRotation", autoRotation ); 0166 generalGroup.writeEntry( "ShrinkToScreenSize", downScale ); 0167 generalGroup.writeEntry( "ZoomToScreenSize", upScale ); 0168 generalGroup.writeEntry( "FlipVertically", flipVertically ); 0169 generalGroup.writeEntry( "FlipHorizontally", flipHorizontally ); 0170 generalGroup.writeEntry( "MaxUpscale Factor", maxUpScale ); 0171 generalGroup.writeEntry( "Rotation", int(rotation) ); 0172 0173 generalGroup.writeEntry( "ApplyDefaultModifications", isModsEnabled ); 0174 0175 0176 generalGroup.writeEntry( "BrightnessStepSize", brightnessSteps ); 0177 generalGroup.writeEntry( "ContrastStepSize", contrastSteps ); 0178 generalGroup.writeEntry( "GammaStepSize", gammaSteps ); 0179 0180 generalGroup.writeEntry( "ScrollingStepSize", scrollSteps ); 0181 generalGroup.writeEntry( "ZoomStepSize", zoomSteps ); 0182 0183 generalGroup.writeEntry( "MaximumZoomFactorByDesktop", maxZoomFactor ); 0184 0185 generalGroup.writeEntry( "MaximumImageWidth", maxWidth ); 0186 generalGroup.writeEntry( "MaximumImageHeight", maxHeight ); 0187 0188 generalGroup.writeEntry( "MaxCachedImages", maxCachedImages ); 0189 generalGroup.writeEntry( "BackgroundColor", backgroundColor ); 0190 0191 generalGroup.writeEntry( "StartInLastDir", startInLastDir ); 0192 0193 idata->save( kc ); 0194 0195 kc->sync(); 0196 }