| 1 |
/* ============================================================ |
| 2 |
* |
| 3 |
* This file is a part of digiKam project |
| 4 |
* https://www.digikam.org |
| 5 |
* |
| 6 |
* Date : 2020-08-07 |
| 7 |
* Description : Hot Pixels Fixer batch tool. |
| 8 |
* |
| 9 |
* SPDX-FileCopyrightText: 2020-2026 by Gilles Caulier <caulier dot gilles at gmail dot com> |
| 10 |
* |
| 11 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 12 |
* |
| 13 |
* ============================================================ */ |
| 14 |
|
| 15 |
#include "hotpixels.h" |
| 16 |
|
| 17 |
// Qt includes |
| 18 |
|
| 19 |
#include <QWidget> |
| 20 |
|
| 21 |
// KDE includes |
| 22 |
|
| 23 |
#include <klocalizedstring.h> |
| 24 |
|
| 25 |
// Local includes |
| 26 |
|
| 27 |
#include "dimg.h" |
| 28 |
#include "hotpixelcontainer.h" |
| 29 |
#include "hotpixelfixer.h" |
| 30 |
#include "hotpixelprops.h" |
| 31 |
|
| 32 |
namespace DigikamBqmHotPixelsPlugin |
| 33 |
{ |
| 34 |
|
| 35 |
HotPixels::HotPixels(QObject* const parent) |
| 36 |
: BatchTool(QLatin1String("HotPixels"), EnhanceTool, parent) |
| 37 |
{ |
| 38 |
} |
| 39 |
|
| 40 |
BatchTool* HotPixels::clone(QObject* const parent) const |
| 41 |
{ |
| 42 |
return new HotPixels(parent); |
| 43 |
} |
| 44 |
|
| 45 |
void HotPixels::registerSettingsWidget() |
| 46 |
{ |
| 47 |
m_settingsWidget = new QWidget; |
| 48 |
m_settingsView = new HotPixelSettings(m_settingsWidget); |
| 49 |
|
| 50 |
connect(m_settingsView, SIGNAL(signalSettingsChanged()), |
| 51 |
this, SLOT(slotSettingsChanged())); |
| 52 |
|
| 53 |
BatchTool::registerSettingsWidget(); |
| 54 |
} |
| 55 |
|
| 56 |
BatchToolSettings HotPixels::defaultSettings() |
| 57 |
{ |
| 58 |
BatchToolSettings prm; |
| 59 |
HotPixelContainer defaultPrm = m_settingsView->defaultSettings(); |
| 60 |
|
| 61 |
prm.insert(QLatin1String("BlackFrameUrl"), defaultPrm.blackFrameUrl); |
| 62 |
prm.insert(QLatin1String("HotPixelsList"), HotPixelProps::toStringList(defaultPrm.hotPixelsList)); |
| 63 |
prm.insert(QLatin1String("FilterMethod"), (int)defaultPrm.filterMethod); |
| 64 |
|
| 65 |
return prm; |
| 66 |
} |
| 67 |
|
| 68 |
void HotPixels::slotAssignSettings2Widget() |
| 69 |
{ |
| 70 |
HotPixelContainer prm; |
| 71 |
prm.blackFrameUrl = settings().value(QLatin1String("BlackFrameUrl")).toUrl(); |
| 72 |
prm.hotPixelsList = HotPixelProps::fromStringList(settings().value(QLatin1String("HotPixelsList")).toStringList()); |
| 73 |
prm.filterMethod = (HotPixelContainer::InterpolationMethod)settings().value(QLatin1String("FilterMethod")).toInt(); |
| 74 |
m_settingsView->setSettings(prm); |
| 75 |
} |
| 76 |
|
| 77 |
void HotPixels::slotSettingsChanged() |
| 78 |
{ |
| 79 |
BatchToolSettings prm; |
| 80 |
HotPixelContainer currentPrm = m_settingsView->settings(); |
| 81 |
|
| 82 |
prm.insert(QLatin1String("BlackFrameUrl"), currentPrm.blackFrameUrl); |
| 83 |
prm.insert(QLatin1String("HotPixelsList"), HotPixelProps::toStringList(currentPrm.hotPixelsList)); |
| 84 |
prm.insert(QLatin1String("FilterMethod"), (int)currentPrm.filterMethod); |
| 85 |
|
| 86 |
BatchTool::slotSettingsChanged(prm); |
| 87 |
} |
| 88 |
|
| 89 |
bool HotPixels::toolOperations() |
| 90 |
{ |
| 91 |
if (!loadToDImg()) |
| 92 |
{ |
| 93 |
return false; |
| 94 |
} |
| 95 |
|
| 96 |
HotPixelContainer prm; |
| 97 |
|
| 98 |
prm.blackFrameUrl = settings().value(QLatin1String("BlackFrameUrl")).toUrl(); |
| 99 |
prm.hotPixelsList = HotPixelProps::fromStringList(settings().value(QLatin1String("HotPixelsList")).toStringList()); |
| 100 |
prm.filterMethod = (HotPixelContainer::InterpolationMethod)settings().value(QLatin1String("FilterMethod")).toInt(); |
| 101 |
|
| 102 |
HotPixelFixer hpf(&image(), nullptr, prm); |
| 103 |
applyFilter(&hpf); |
| 104 |
|
| 105 |
return (savefromDImg()); |
| 106 |
} |
| 107 |
|
| 108 |
} // namespace DigikamBqmHotPixelsPlugin |
| 109 |
|
| 110 |
#include "moc_hotpixels.cpp" |