Cppcheck - HTML report - digiKam-master-rev-960d3ce42d

# Cppcheck report - digiKam-master-rev-960d3ce42d: ../../core/libs/dimg/filters/redeye/redeyecorrectionsettings.cpp

      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    /* ============================================================
     *
     * This file is a part of digiKam project
     * https://www.digikam.org
     *
     * Date        : 2010-02-09
     * Description : Red Eyes auto correction settings view.
     *
     * SPDX-FileCopyrightText: 2010-2026 by Gilles Caulier <caulier dot gilles at gmail dot com>
     * SPDX-FileCopyrightText: 2016      by Omar Amin <Omar dot moh dot amin at gmail dot com>
     *
     * SPDX-License-Identifier: GPL-2.0-or-later
     *
     * ============================================================ */

    #include "redeyecorrectionsettings.h"

    // Qt includes

    #include <QGridLayout>
    #include <QLabel>
    #include <QString>
    #include <QFile>
    #include <QTextStream>
    #include <QCheckBox>
    #include <QUrl>
    #include <QApplication>
    #include <QStyle>

    // KDE includes

    #include <kconfiggroup.h>
    #include <klocalizedstring.h>

    // Local includes

    #include "dnuminput.h"
    #include "digikam_debug.h"
    #include "dexpanderbox.h"

    namespace Digikam
    {

    class Q_DECL_HIDDEN RedEyeCorrectionSettings::Private
    {
    public:

        Private() = default;

        const QString configRedToAvgRatioAdjustmentEntry = QLatin1String("RedToAvgRatioAdjustment");

        DDoubleNumInput* redtoavgratioInput = nullptr;
    };

    // --------------------------------------------------------

    RedEyeCorrectionSettings::RedEyeCorrectionSettings(QWidget* const parent)
        : QWidget(parent),
          d      (new Private)
    {
        const int spacing       = layoutSpacing();
        QGridLayout* const grid = new QGridLayout(parent);

        QLabel* const label2    = new QLabel(i18n("Red Level:"));
        d->redtoavgratioInput   = new DDoubleNumInput();
        d->redtoavgratioInput->setRange(1.5, 3.0, 0.1);
        d->redtoavgratioInput->setDefaultValue(2.1);
        d->redtoavgratioInput->setWhatsThis(i18n("Set here the reducing level of red to the average of blue and green."));

        // -------------------------------------------------------------

        grid->addWidget(label2,                0, 0, 1, 1);
        grid->addWidget(d->redtoavgratioInput, 1, 0, 1, 1);
        grid->setRowStretch(6, 10);
        grid->setContentsMargins(spacing, spacing, spacing, spacing);
        grid->setSpacing(spacing);

        // -------------------------------------------------------------

        connect(d->redtoavgratioInput, SIGNAL(valueChanged(double)),
                this, SIGNAL(signalSettingsChanged()));
    }

    RedEyeCorrectionSettings::~RedEyeCorrectionSettings()
    {
        delete d;
    }

    RedEyeCorrectionContainer RedEyeCorrectionSettings::settings() const
    {
        RedEyeCorrectionContainer prm;
        prm.m_redToAvgRatio = (double)d->redtoavgratioInput->value();

        return prm;
    }

    void RedEyeCorrectionSettings::setSettings(const RedEyeCorrectionContainer& settings)<--- Shadow argument
    {
        blockSignals(true);
        d->redtoavgratioInput->setValue(settings.m_redToAvgRatio);
        blockSignals(false);
    }

    void RedEyeCorrectionSettings::resetToDefault()
    {
        blockSignals(true);
        d->redtoavgratioInput->slotReset();
        blockSignals(false);
    }

    RedEyeCorrectionContainer RedEyeCorrectionSettings::defaultSettings() const
    {
        RedEyeCorrectionContainer prm;
        prm.m_redToAvgRatio = (double)(d->redtoavgratioInput->defaultValue());

        return prm;
    }

    void RedEyeCorrectionSettings::readSettings(const KConfigGroup& group)
    {
        RedEyeCorrectionContainer prm;
        RedEyeCorrectionContainer defaultPrm = defaultSettings();
        prm.m_redToAvgRatio                  = group.readEntry(d->configRedToAvgRatioAdjustmentEntry,
                                                               defaultPrm.m_redToAvgRatio);

        setSettings(prm);
    }

    void RedEyeCorrectionSettings::writeSettings(KConfigGroup& group)
    {
        RedEyeCorrectionContainer prm = settings();
        group.writeEntry(d->configRedToAvgRatioAdjustmentEntry, prm.m_redToAvgRatio);
    }

    } // namespace Digikam

    #include "moc_redeyecorrectionsettings.cpp"