1 /************************************************************************** 2 ** ** 3 ** Copyright (C) 2018 Lukas Spies ** 4 ** Contact: http://photoqt.org ** 5 ** ** 6 ** This file is part of PhotoQt. ** 7 ** ** 8 ** PhotoQt is free software: you can redistribute it and/or modify ** 9 ** it under the terms of the GNU General Public License as published by ** 10 ** the Free Software Foundation, either version 2 of the License, or ** 11 ** (at your option) any later version. ** 12 ** ** 13 ** PhotoQt is distributed in the hope that it will be useful, ** 14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** 15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 16 ** GNU General Public License for more details. ** 17 ** ** 18 ** You should have received a copy of the GNU General Public License ** 19 ** along with PhotoQt. If not, see <http://www.gnu.org/licenses/>. ** 20 ** ** 21 **************************************************************************/ 22 23 #ifndef STARTUPCHECK_SETTINGS_H 24 #define STARTUPCHECK_SETTINGS_H 25 26 #include "../configfiles.h" 27 #include "../logger.h" 28 #include "../settings/settings.h" 29 30 namespace StartupCheck { 31 32 namespace Settings { 33 moveToNewKeyNames()34 static inline void moveToNewKeyNames() { 35 36 QFile fileIn(ConfigFiles::SETTINGS_FILE()); 37 38 if(!fileIn.exists()) 39 return; 40 41 if(!fileIn.open(QIODevice::ReadOnly)) { 42 LOG << CURDATE << "StartupCheck::Settings::moveToNewKeyNames() - ERROR: unable to open settings file for reading -> unable to ensure values are preserved between sessions." << NL; 43 return; 44 } 45 46 QTextStream in(&fileIn); 47 48 QString all = in.readAll(); 49 50 fileIn.close(); 51 52 // THESE SETTINGS CHANGED NAME!! 53 54 if(!all.contains("Animations=")) 55 all.replace("MyWidgetAnimated=", "Animations="); 56 57 if(!all.contains("ImageTransition=")) 58 all.replace("Transition=", "ImageTransition="); 59 60 if(!all.contains("CloseOnEmptyBackground=")) 61 all.replace("CloseOnGrey=", "CloseOnEmptyBackground="); 62 63 if(!all.contains("MarginAroundImage=")) 64 all.replace("BorderAroundImg=", "MarginAroundImage="); 65 66 if(!all.contains("HotEdgeWidth=")) 67 all.replace("MenuSensitivity=", "HotEdgeWidth="); 68 69 if(!all.contains("SlideShowImageTransition=")) 70 all.replace("SlideShowTransition=", "SlideShowImageTransition="); 71 72 if(!all.contains("ThumbnailCacheFile=")) 73 all.replace("ThbCacheFile=", "ThumbnailCacheFile="); 74 75 76 if(!all.contains("backgroundColorRed=")) 77 all.replace("bgColorRed=", "backgroundColorRed="); 78 79 if(!all.contains("backgroundColorGreen=")) 80 all.replace("bgColorGreen=", "backgroundColorGreen="); 81 82 if(!all.contains("backgroundColorBlue=")) 83 all.replace("bgColorBlue=", "backgroundColorBlue="); 84 85 if(!all.contains("backgroundColorAlpha=")) 86 all.replace("bgColorAlpha=", "backgroundColorAlpha="); 87 88 89 if(!all.contains("QuickInfoHideCounter=")) 90 all.replace("HideCounter=", "QuickInfoHideCounter="); 91 92 if(!all.contains("QuickInfoHideFilepath=")) 93 all.replace("HideFilepathShowFilename=", "QuickInfoHideFilepath="); 94 95 if(!all.contains("QuickInfoHideFilename=")) 96 all.replace("HideFilename=", "QuickInfoHideFilename="); 97 98 if(!all.contains("QuickInfoHideX=")) 99 all.replace("HideX=", "QuickInfoHideX="); 100 101 if(!all.contains("QuickInfoFullX=")) 102 all.replace("FancyX=", "QuickInfoFullX="); 103 104 if(!all.contains("QuickInfoCloseXSize=")) 105 all.replace("CloseXSize=", "QuickInfoCloseXSize="); 106 107 108 if(!all.contains("MetaFilename=")) 109 all.replace("ExifFilename=", "MetaFilename="); 110 111 if(!all.contains("MetaFileType=")) 112 all.replace("ExifFiletype=", "MetaFileType="); 113 114 if(!all.contains("MetaFileSize=")) 115 all.replace("ExifFilesize=", "MetaFileSize="); 116 117 if(!all.contains("MetaImageNumber=")) 118 all.replace("ExifImageNumber=", "MetaImageNumber="); 119 120 if(!all.contains("MetaDimensions=")) 121 all.replace("ExifDimensions=", "MetaDimensions="); 122 123 if(!all.contains("MetaMake=")) 124 all.replace("ExifMake=", "MetaMake="); 125 126 if(!all.contains("MetaModel=")) 127 all.replace("ExifModel=", "MetaModel="); 128 129 if(!all.contains("MetaSoftware=")) 130 all.replace("ExifSoftware=", "MetaSoftware="); 131 132 if(!all.contains("MetaTimePhotoTaken=")) 133 all.replace("ExifPhotoTaken=", "MetaTimePhotoTaken="); 134 135 if(!all.contains("MetaExposureTime=")) 136 all.replace("ExifExposureTime=", "MetaExposureTime="); 137 138 if(!all.contains("MetaFlash=")) 139 all.replace("ExifFlash=", "MetaFlash="); 140 141 if(!all.contains("MetaIso=")) 142 all.replace("ExifIso=", "MetaIso="); 143 144 if(!all.contains("MetaSceneType=")) 145 all.replace("ExifSceneType=", "MetaSceneType="); 146 147 if(!all.contains("MetaFLength=")) 148 all.replace("ExifFLength=", "MetaFLength="); 149 150 if(!all.contains("MetaFNumber=")) 151 all.replace("ExifFNumber=", "MetaFNumber="); 152 153 if(!all.contains("MetaLightSource=")) 154 all.replace("ExifLightSource=", "MetaLightSource="); 155 156 if(!all.contains("MetaGps=")) 157 all.replace("ExifGps=", "MetaGps="); 158 159 if(!all.contains("MetaGpsMapService=")) 160 all.replace("ExifGPSMapService=", "MetaGpsMapService="); 161 162 163 if(!all.contains("MetaKeywords=")) 164 all.replace("IptcKeywords=", "MetaKeywords="); 165 166 if(!all.contains("MetaLocation=")) 167 all.replace("IptcLocation=", "MetaLocation="); 168 169 if(!all.contains("MetaCopyright=")) 170 all.replace("IptcCopyright=", "MetaCopyright="); 171 172 173 if(!all.contains("MetadataEnableHotEdge=")) 174 all.replace("ExifEnableMouseTriggering=", "MetadataEnableHotEdge="); 175 176 if(!all.contains("MetadataFontSize=")) 177 all.replace("ExifFontSize=", "MetadataFontSize="); 178 179 if(!all.contains("MetadataOpacity=")) 180 all.replace("ExifOpacity=", "MetadataOpacity="); 181 182 if(!all.contains("MetadataWindowWidth=")) 183 all.replace("ExifMetadaWindowWidth=", "MetadataWindowWidth="); 184 185 QFile fileOut(ConfigFiles::SETTINGS_FILE()); 186 if(!fileOut.open(QIODevice::WriteOnly|QIODevice::Truncate)) { 187 LOG << CURDATE << "ERROR! Startup::Settings - unable to open settings file for writing -> unable to ensure values are preserved between sessions." << NL; 188 return; 189 } 190 191 QTextStream out(&fileOut); 192 out << all; 193 fileOut.close(); 194 } 195 196 } 197 } 198 199 #endif // STARTUPCHECK_SETTINGS_H 200