File indexing completed on 2025-01-05 03:57:26
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2010-06-18 0007 * Description : settings container for versioning 0008 * 0009 * SPDX-FileCopyrightText: 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> 0010 * SPDX-FileCopyrightText: 2010 by Martin Klapetek <martin dot klapetek at gmail dot com> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 #include "versionmanagersettings.h" 0017 0018 // KDE includes 0019 0020 #include <kconfiggroup.h> 0021 0022 // Local includes 0023 0024 #include "digikam_debug.h" 0025 0026 namespace Digikam 0027 { 0028 0029 class Q_DECL_HIDDEN VersionManagerSettingsConfig 0030 { 0031 public: 0032 0033 static const QString configEnabled; 0034 static const QString configIntermediateAfterEachSession; 0035 static const QString configIntermediateAfterRawConversion; 0036 static const QString configIntermediateWhenNotReproducible; 0037 static const QString configViewShowIntermediates; 0038 static const QString configViewShowOriginal; 0039 static const QString configAutoSaveWhenClosingEditor; 0040 static const QString configVersionStorageFormat; 0041 }; 0042 0043 const QString VersionManagerSettingsConfig::configEnabled(QLatin1String("Non-Destructive Editing Enabled")); 0044 const QString VersionManagerSettingsConfig::configIntermediateAfterEachSession(QLatin1String("Save Intermediate After Each Session")); 0045 const QString VersionManagerSettingsConfig::configIntermediateAfterRawConversion(QLatin1String("Save Intermediate After Raw Conversion")); 0046 const QString VersionManagerSettingsConfig::configIntermediateWhenNotReproducible(QLatin1String("Save Intermediate When Not Reproducible")); 0047 const QString VersionManagerSettingsConfig::configViewShowIntermediates(QLatin1String("Show Intermediates in View")); 0048 const QString VersionManagerSettingsConfig::configViewShowOriginal(QLatin1String("Show Original in View")); 0049 const QString VersionManagerSettingsConfig::configAutoSaveWhenClosingEditor(QLatin1String("Auto-Save When Closing Editor")); 0050 const QString VersionManagerSettingsConfig::configVersionStorageFormat(QLatin1String("Saving Format for Versions")); 0051 0052 VersionManagerSettings::VersionManagerSettings() 0053 : enabled (true), 0054 saveIntermediateVersions(NoIntermediates), 0055 showInViewFlags (ShowOriginal), 0056 editorClosingMode (AlwaysAsk), 0057 format (QLatin1String("JPG")) 0058 { 0059 } 0060 0061 void VersionManagerSettings::readFromConfig(const KConfigGroup& group) 0062 { 0063 enabled = group.readEntry(VersionManagerSettingsConfig::configEnabled, true); 0064 saveIntermediateVersions = NoIntermediates; 0065 0066 if (group.readEntry(VersionManagerSettingsConfig::configIntermediateAfterEachSession, false)) 0067 { 0068 saveIntermediateVersions |= AfterEachSession; 0069 } 0070 0071 if (group.readEntry(VersionManagerSettingsConfig::configIntermediateAfterRawConversion, false)) 0072 { 0073 saveIntermediateVersions |= AfterRawConversion; 0074 } 0075 0076 if (group.readEntry(VersionManagerSettingsConfig::configIntermediateWhenNotReproducible, false)) 0077 { 0078 saveIntermediateVersions |= WhenNotReproducible; 0079 } 0080 0081 showInViewFlags = OnlyShowCurrent; 0082 0083 if (group.readEntry(VersionManagerSettingsConfig::configViewShowOriginal, true)) 0084 { 0085 showInViewFlags |= ShowOriginal; 0086 } 0087 0088 if (group.readEntry(VersionManagerSettingsConfig::configViewShowIntermediates, true)) 0089 { 0090 showInViewFlags |= ShowIntermediates; 0091 } 0092 0093 bool autoSave = group.readEntry(VersionManagerSettingsConfig::configAutoSaveWhenClosingEditor, false); 0094 editorClosingMode = autoSave ? AutoSave : AlwaysAsk; 0095 0096 format = group.readEntry(VersionManagerSettingsConfig::configVersionStorageFormat, 0097 QString::fromLatin1("JPG")).toUpper(); 0098 } 0099 0100 void VersionManagerSettings::writeToConfig(KConfigGroup& group) const 0101 { 0102 group.writeEntry(VersionManagerSettingsConfig::configEnabled, enabled); 0103 group.writeEntry(VersionManagerSettingsConfig::configIntermediateAfterEachSession, bool(saveIntermediateVersions & AfterEachSession)); 0104 group.writeEntry(VersionManagerSettingsConfig::configIntermediateAfterRawConversion, bool(saveIntermediateVersions & AfterRawConversion)); 0105 group.writeEntry(VersionManagerSettingsConfig::configIntermediateWhenNotReproducible, bool(saveIntermediateVersions & WhenNotReproducible)); 0106 group.writeEntry(VersionManagerSettingsConfig::configViewShowIntermediates, bool(showInViewFlags & ShowIntermediates)); 0107 group.writeEntry(VersionManagerSettingsConfig::configViewShowOriginal, bool(showInViewFlags & ShowOriginal)); 0108 group.writeEntry(VersionManagerSettingsConfig::configAutoSaveWhenClosingEditor, bool(editorClosingMode == AutoSave)); 0109 group.writeEntry(VersionManagerSettingsConfig::configVersionStorageFormat, format); 0110 } 0111 0112 } // namespace Digikam