| 1 |
/* ============================================================ |
| 2 |
* |
| 3 |
* This file is a part of digiKam project |
| 4 |
* https://www.digikam.org |
| 5 |
* |
| 6 |
* Date : 2020-08-13 |
| 7 |
* Description : batch tool to add texture. |
| 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 "texture.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 "digikam_debug.h" |
| 28 |
#include "dimg.h" |
| 29 |
#include "texturefilter.h" |
| 30 |
|
| 31 |
namespace DigikamBqmTexturePlugin |
| 32 |
{ |
| 33 |
|
| 34 |
Texture::Texture(QObject* const parent) |
| 35 |
: BatchTool(QLatin1String("Texture"), DecorateTool, parent) |
| 36 |
{ |
| 37 |
} |
| 38 |
|
| 39 |
BatchTool* Texture::clone(QObject* const parent) const |
| 40 |
{ |
| 41 |
return new Texture(parent); |
| 42 |
} |
| 43 |
|
| 44 |
void Texture::registerSettingsWidget() |
| 45 |
{ |
| 46 |
m_settingsWidget = new QWidget; |
| 47 |
m_settingsView = new TextureSettings(m_settingsWidget); |
| 48 |
m_settingsView->resetToDefault(); |
| 49 |
|
| 50 |
connect(m_settingsView, SIGNAL(signalSettingsChanged()), |
| 51 |
this, SLOT(slotSettingsChanged())); |
| 52 |
|
| 53 |
BatchTool::registerSettingsWidget(); |
| 54 |
} |
| 55 |
|
| 56 |
BatchToolSettings Texture::defaultSettings() |
| 57 |
{ |
| 58 |
BatchToolSettings prm; |
| 59 |
TextureContainer defaultPrm = m_settingsView->defaultSettings(); |
| 60 |
|
| 61 |
prm.insert(QLatin1String("blendGain"), defaultPrm.blendGain); |
| 62 |
prm.insert(QLatin1String("textureType"), defaultPrm.textureType); |
| 63 |
|
| 64 |
return prm; |
| 65 |
} |
| 66 |
|
| 67 |
void Texture::slotAssignSettings2Widget() |
| 68 |
{ |
| 69 |
TextureContainer prm; |
| 70 |
|
| 71 |
prm.blendGain = settings().value(QLatin1String("blendGain")).toInt(); |
| 72 |
prm.textureType = settings().value(QLatin1String("textureType")).toInt(); |
| 73 |
|
| 74 |
m_settingsView->setSettings(prm); |
| 75 |
} |
| 76 |
|
| 77 |
void Texture::slotSettingsChanged() |
| 78 |
{ |
| 79 |
BatchToolSettings prm; |
| 80 |
TextureContainer currentPrm = m_settingsView->settings(); |
| 81 |
|
| 82 |
prm.insert(QLatin1String("blendGain"), currentPrm.blendGain); |
| 83 |
prm.insert(QLatin1String("textureType"), currentPrm.textureType); |
| 84 |
|
| 85 |
BatchTool::slotSettingsChanged(prm); |
| 86 |
} |
| 87 |
|
| 88 |
bool Texture::toolOperations() |
| 89 |
{ |
| 90 |
if (!loadToDImg()) |
| 91 |
{ |
| 92 |
return false; |
| 93 |
} |
| 94 |
|
| 95 |
TextureContainer prm; |
| 96 |
prm.blendGain = settings().value(QLatin1String("blendGain")).toInt(); |
| 97 |
prm.textureType = settings().value(QLatin1String("textureType")).toInt(); |
| 98 |
|
| 99 |
TextureFilter bd(&image(), nullptr, prm); |
| 100 |
applyFilter(&bd); |
| 101 |
|
| 102 |
return (savefromDImg()); |
| 103 |
} |
| 104 |
|
| 105 |
} // namespace DigikamBqmTexturePlugin |
| 106 |
|
| 107 |
#include "moc_texture.cpp" |