Cppcheck - HTML report - digiKam-nl-search-more-criteria-rev-e2466e0973

# Cppcheck report - digiKam-nl-search-more-criteria-rev-e2466e0973: ../../core/libs/dimg/filters/lens/lensfunsettings.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
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    /* ============================================================
     *
     * Date        : 2008-02-10
     * Description : a tool to fix automatically camera lens aberrations
     *
     * SPDX-FileCopyrightText: 2008      by Adrian Schroeter <adrian at suse dot de>
     * SPDX-FileCopyrightText: 2008-2026 by Gilles Caulier <caulier dot gilles at gmail dot com>
     *
     * SPDX-License-Identifier: GPL-2.0-or-later
     *
     * ============================================================ */

    #include "lensfunsettings.h"

    // Qt includes

    #include <QCheckBox>
    #include <QGridLayout>
    #include <QLabel>
    #include <QString>
    #include <QApplication>
    #include <QStyle>

    // KDE includes

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

    // Local includes

    #include "digikam_debug.h"

    namespace Digikam
    {

    class Q_DECL_HIDDEN LensFunSettings::Private
    {
    public:

        Private() = default;

        const QString configCCAEntry        = QLatin1String("CCA");
        const QString configVignettingEntry = QLatin1String("Vignetting");
        const QString configDistortionEntry = QLatin1String("Distortion");
        const QString configGeometryEntry   = QLatin1String("Geometry");

        QCheckBox*           filterCCA      = nullptr;
        QCheckBox*           filterVIG      = nullptr;
        QCheckBox*           filterDST      = nullptr;
        QCheckBox*           filterGEO      = nullptr;
    };

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

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

        QGridLayout* const grid = new QGridLayout(this);

        QLabel* const title     = new QLabel(i18n("Lens Corrections to Apply:"));
        d->filterCCA            = new QCheckBox(i18n("Chromatic Aberration"));
        d->filterCCA->setWhatsThis(i18n("Chromatic aberration is easily recognized as color fringes "
                                        "towards the image corners. CA is due to a varying lens focus "
                                        "for different colors."));
        d->filterVIG  = new QCheckBox(i18n("Vignetting"));
        d->filterVIG->setWhatsThis(i18n("Vignetting refers to an image darkening, mostly in the corners. "
                                        "Optical and natural vignetting can be canceled out with this option, "
                                        "whereas mechanical vignetting will not be cured."));
        d->filterDST = new QCheckBox(i18n("Distortion"));
        d->filterDST->setWhatsThis(i18n("Distortion refers to an image deformation, which is most pronounced "
                                        "towards the corners. These Seidel aberrations are known as pincushion "
                                        "and barrel distortions."));
        d->filterGEO = new QCheckBox(i18n("Geometry"));
        d->filterGEO->setWhatsThis(i18n("Four geometries are handled here: Rectilinear (99 percent of all lenses), "
                                        "Fisheye, Cylindrical, Equirectangular."));
        QLabel* const note = new QLabel(i18n("<b>Note: lens correction options depend of filters available in LensFun library. "
                                             "See <a href='http://lensfun.sourceforge.net'>LensFun project web site</a> "       // krazy:exclude=insecurenet
                                             "for more information.</b>"), this);
        note->setOpenExternalLinks(true);
        note->setWordWrap(true);
        note->setFrameStyle(QFrame::StyledPanel | QFrame::Raised);

        grid->addWidget(title,        0, 0, 1, 2);
        grid->addWidget(d->filterCCA, 1, 0, 1, 2);
        grid->addWidget(d->filterVIG, 2, 0, 1, 2);
        grid->addWidget(d->filterDST, 4, 0, 1, 2);
        grid->addWidget(d->filterGEO, 5, 0, 1, 2);
        grid->addWidget(note,         6, 0, 1, 2);
        grid->setRowStretch(7, 10);
        grid->setContentsMargins(spacing, spacing, spacing, spacing);
        grid->setSpacing(spacing);

        connect(d->filterCCA, SIGNAL(toggled(bool)),
                this, SIGNAL(signalSettingsChanged()));

        connect(d->filterVIG, SIGNAL(toggled(bool)),
                this, SIGNAL(signalSettingsChanged()));

        connect(d->filterDST, SIGNAL(toggled(bool)),
                this, SIGNAL(signalSettingsChanged()));

        connect(d->filterGEO, SIGNAL(toggled(bool)),
                this, SIGNAL(signalSettingsChanged()));
    }

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

    void LensFunSettings::setEnabledCCA(bool b)
    {
        d->filterCCA->setEnabled(b);
    }

    void LensFunSettings::setEnabledVig(bool b)
    {
        d->filterVIG->setEnabled(b);
    }

    void LensFunSettings::setEnabledDist(bool b)
    {
        d->filterDST->setEnabled(b);
    }

    void LensFunSettings::setEnabledGeom(bool b)
    {
        d->filterGEO->setEnabled(b);
    }

    void LensFunSettings::assignFilterSettings(LensFunContainer& prm)
    {
        prm.filterCCA = (d->filterCCA->isChecked() && d->filterCCA->isEnabled());
        prm.filterVIG = (d->filterVIG->isChecked() && d->filterVIG->isEnabled());
        prm.filterDST = (d->filterDST->isChecked() && d->filterDST->isEnabled());
        prm.filterGEO = (d->filterGEO->isChecked() && d->filterGEO->isEnabled());
    }

    void LensFunSettings::setFilterSettings(const LensFunContainer& settings)<--- Shadow argument
    {
        blockSignals(true);
        d->filterCCA->setChecked(settings.filterCCA);
        d->filterVIG->setChecked(settings.filterVIG);
        d->filterDST->setChecked(settings.filterDST);
        d->filterGEO->setChecked(settings.filterGEO);
        blockSignals(false);
    }

    void LensFunSettings::resetToDefault()
    {
        setFilterSettings(LensFunContainer());
    }

    LensFunContainer LensFunSettings::defaultSettings() const
    {
        LensFunContainer prm;
        return prm;
    }

    LensFunContainer LensFunSettings::settings() const
    {
        LensFunContainer prm;
        prm.filterCCA = d->filterCCA->isChecked();
        prm.filterVIG = d->filterVIG->isChecked();
        prm.filterDST = d->filterDST->isChecked();
        prm.filterGEO = d->filterGEO->isChecked();
        return prm;
    }

    void LensFunSettings::readSettings(const KConfigGroup& group)
    {
        LensFunContainer prm;
        LensFunContainer defaultPrm = defaultSettings();
        prm.filterCCA = group.readEntry(d->configCCAEntry,        defaultPrm.filterCCA);
        prm.filterVIG = group.readEntry(d->configVignettingEntry, defaultPrm.filterVIG);
        prm.filterDST = group.readEntry(d->configDistortionEntry, defaultPrm.filterDST);
        prm.filterGEO = group.readEntry(d->configGeometryEntry,   defaultPrm.filterGEO);
        setFilterSettings(prm);
    }

    void LensFunSettings::writeSettings(KConfigGroup& group)
    {
        LensFunContainer prm;
        assignFilterSettings(prm);

        if (d->filterCCA->isEnabled())
        {
            group.writeEntry(d->configCCAEntry, (prm.filterCCA));
        }

        if (d->filterVIG->isEnabled())
        {
            group.writeEntry(d->configVignettingEntry, (prm.filterVIG));
        }

        if (d->filterDST->isEnabled())
        {
            group.writeEntry(d->configDistortionEntry, (prm.filterDST));
        }

        if (d->filterGEO->isEnabled())
        {
            group.writeEntry(d->configGeometryEntry, (prm.filterGEO));
        }
    }

    } // namespace Digikam

    #include "moc_lensfunsettings.cpp"