File indexing completed on 2025-01-19 03:55:50
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2013-08-19 0007 * Description : Image quality Settings Container. 0008 * 0009 * SPDX-FileCopyrightText: 2013-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * SPDX-FileCopyrightText: 2021-2022 by Phuoc Khanh Le <phuockhanhnk94 at gmail dot com> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 #include "imagequalitycontainer.h" 0017 0018 // KDE includes 0019 0020 #include <kconfiggroup.h> 0021 #include <ksharedconfig.h> 0022 0023 // Local includes 0024 0025 #include "digikam_globals.h" 0026 0027 namespace Digikam 0028 { 0029 0030 ImageQualityContainer::ImageQualityContainer() 0031 : detectBlur (true), 0032 detectNoise (true), 0033 detectCompression (true), 0034 detectExposure (true), 0035 detectAesthetic (true), 0036 lowQRejected (true), 0037 mediumQPending (true), 0038 highQAccepted (true), 0039 rejectedThreshold (10), 0040 pendingThreshold (40), 0041 acceptedThreshold (60), 0042 blurWeight (100), 0043 noiseWeight (100), 0044 compressionWeight (100), 0045 exposureWeight (100) 0046 { 0047 } 0048 0049 ImageQualityContainer::ImageQualityContainer(const ImageQualityContainer& other) 0050 : detectBlur (other.detectBlur), 0051 detectNoise (other.detectNoise), 0052 detectCompression (other.detectCompression), 0053 detectExposure (other.detectExposure), 0054 detectAesthetic (other.detectAesthetic), 0055 lowQRejected (other.lowQRejected), 0056 mediumQPending (other.mediumQPending), 0057 highQAccepted (other.highQAccepted), 0058 rejectedThreshold (other.rejectedThreshold), 0059 pendingThreshold (other.pendingThreshold), 0060 acceptedThreshold (other.acceptedThreshold), 0061 blurWeight (other.blurWeight), 0062 noiseWeight (other.noiseWeight), 0063 compressionWeight (other.compressionWeight), 0064 exposureWeight (other.exposureWeight) 0065 { 0066 } 0067 0068 ImageQualityContainer& ImageQualityContainer::operator=(const ImageQualityContainer& other) 0069 { 0070 detectBlur = other.detectBlur; 0071 detectNoise = other.detectNoise; 0072 detectCompression = other.detectCompression; 0073 detectExposure = other.detectExposure; 0074 detectAesthetic = other.detectAesthetic; 0075 lowQRejected = other.lowQRejected; 0076 mediumQPending = other.mediumQPending; 0077 highQAccepted = other.highQAccepted; 0078 rejectedThreshold = other.rejectedThreshold; 0079 pendingThreshold = other.pendingThreshold; 0080 acceptedThreshold = other.acceptedThreshold; 0081 blurWeight = other.blurWeight; 0082 noiseWeight = other.noiseWeight; 0083 compressionWeight = other.compressionWeight; 0084 exposureWeight = other.exposureWeight; 0085 0086 return *this; 0087 } 0088 0089 ImageQualityContainer::~ImageQualityContainer() 0090 { 0091 } 0092 0093 void ImageQualityContainer::readFromConfig() 0094 { 0095 KSharedConfig::Ptr config = KSharedConfig::openConfig(); 0096 KConfigGroup group = config->group(QLatin1String("Image Quality Settings")); 0097 readFromConfig(group); 0098 } 0099 0100 void ImageQualityContainer::readFromConfig(const KConfigGroup& group) 0101 { 0102 detectBlur = group.readEntry("Detect Blur", true); 0103 detectNoise = group.readEntry("Detect Noise", true); 0104 detectCompression = group.readEntry("Detect Compression", true); 0105 detectExposure = group.readEntry("Detect Exposure", true); 0106 detectAesthetic = group.readEntry("Detect Aesthetic", true); 0107 lowQRejected = group.readEntry("LowQ Rejected", true); 0108 mediumQPending = group.readEntry("MediumQ Pending", true); 0109 highQAccepted = group.readEntry("HighQ Accepted", true); 0110 rejectedThreshold = group.readEntry("Rejected Threshold", 10); 0111 pendingThreshold = group.readEntry("Pending Threshold", 40); 0112 acceptedThreshold = group.readEntry("Accepted Threshold", 60); 0113 blurWeight = group.readEntry("Blur Weight", 100); 0114 noiseWeight = group.readEntry("Noise Weight", 100); 0115 compressionWeight = group.readEntry("Compression Weight", 100); 0116 exposureWeight = group.readEntry("Exposure Weight", 100); 0117 } 0118 0119 void ImageQualityContainer::writeToConfig() 0120 { 0121 KSharedConfig::Ptr config = KSharedConfig::openConfig(); 0122 KConfigGroup group = config->group(QLatin1String("Image Quality Settings")); 0123 writeToConfig(group); 0124 } 0125 0126 void ImageQualityContainer::writeToConfig(KConfigGroup& group) 0127 { 0128 group.writeEntry("Detect Blur", detectBlur); 0129 group.writeEntry("Detect Noise", detectNoise); 0130 group.writeEntry("Detect Compression", detectCompression); 0131 group.writeEntry("Detect Exposure", detectExposure); 0132 group.writeEntry("Detect Aesthetic", detectAesthetic); 0133 group.writeEntry("LowQ Rejected", lowQRejected); 0134 group.writeEntry("MediumQ Pending", mediumQPending); 0135 group.writeEntry("HighQ Accepted", highQAccepted); 0136 group.writeEntry("Rejected Threshold", rejectedThreshold); 0137 group.writeEntry("Pending Threshold", pendingThreshold); 0138 group.writeEntry("Accepted Threshold", acceptedThreshold); 0139 group.writeEntry("Blur Weight", blurWeight); 0140 group.writeEntry("Noise Weight", noiseWeight); 0141 group.writeEntry("Compression Weight", compressionWeight); 0142 group.writeEntry("Exposure Weight", exposureWeight); 0143 } 0144 0145 QDebug operator<<(QDebug dbg, const ImageQualityContainer& s) 0146 { 0147 dbg.nospace() << QT_ENDL; 0148 dbg.nospace() << "DetectBlur :" << s.detectBlur << QT_ENDL; 0149 dbg.nospace() << "DetectNoise :" << s.detectNoise << QT_ENDL; 0150 dbg.nospace() << "DetectCompression :" << s.detectCompression << QT_ENDL; 0151 dbg.nospace() << "DetectExposure :" << s.detectExposure << QT_ENDL; 0152 dbg.nospace() << "DetectAesthetic :" << s.detectAesthetic << QT_ENDL; 0153 dbg.nospace() << "LowQRejected :" << s.lowQRejected << QT_ENDL; 0154 dbg.nospace() << "MediumQPending :" << s.mediumQPending << QT_ENDL; 0155 dbg.nospace() << "HighQAccepted :" << s.highQAccepted << QT_ENDL; 0156 dbg.nospace() << "Rejected Threshold :" << s.rejectedThreshold << QT_ENDL; 0157 dbg.nospace() << "Pending Threshold :" << s.pendingThreshold << QT_ENDL; 0158 dbg.nospace() << "Accepted Threshold :" << s.acceptedThreshold << QT_ENDL; 0159 dbg.nospace() << "Blur Weight :" << s.blurWeight << QT_ENDL; 0160 dbg.nospace() << "Noise Weight :" << s.noiseWeight << QT_ENDL; 0161 dbg.nospace() << "Compression Weight :" << s.compressionWeight << QT_ENDL; 0162 dbg.nospace() << "Exposure Weight :" << s.exposureWeight << QT_ENDL; 0163 0164 return dbg.space(); 0165 } 0166 0167 } // namespace Digikam