File indexing completed on 2025-01-19 03:50:54
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2020-08-13 0007 * Description : batch tool to add texture. 0008 * 0009 * SPDX-FileCopyrightText: 2020-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #include "texture.h" 0016 0017 // Qt includes 0018 0019 #include <QWidget> 0020 0021 // KDE includes 0022 0023 #include <klocalizedstring.h> 0024 0025 // Local includes 0026 0027 #include "digikam_debug.h" 0028 #include "dimg.h" 0029 #include "texturefilter.h" 0030 0031 namespace DigikamBqmTexturePlugin 0032 { 0033 0034 Texture::Texture(QObject* const parent) 0035 : BatchTool(QLatin1String("Texture"), DecorateTool, parent), 0036 m_settingsView(nullptr) 0037 { 0038 } 0039 0040 Texture::~Texture() 0041 { 0042 } 0043 0044 BatchTool* Texture::clone(QObject* const parent) const 0045 { 0046 return new Texture(parent); 0047 } 0048 0049 void Texture::registerSettingsWidget() 0050 { 0051 m_settingsWidget = new QWidget; 0052 m_settingsView = new TextureSettings(m_settingsWidget); 0053 m_settingsView->resetToDefault(); 0054 0055 connect(m_settingsView, SIGNAL(signalSettingsChanged()), 0056 this, SLOT(slotSettingsChanged())); 0057 0058 BatchTool::registerSettingsWidget(); 0059 } 0060 0061 BatchToolSettings Texture::defaultSettings() 0062 { 0063 BatchToolSettings prm; 0064 TextureContainer defaultPrm = m_settingsView->defaultSettings(); 0065 0066 prm.insert(QLatin1String("blendGain"), defaultPrm.blendGain); 0067 prm.insert(QLatin1String("textureType"), defaultPrm.textureType); 0068 0069 return prm; 0070 } 0071 0072 void Texture::slotAssignSettings2Widget() 0073 { 0074 TextureContainer prm; 0075 0076 prm.blendGain = settings()[QLatin1String("blendGain")].toInt(); 0077 prm.textureType = settings()[QLatin1String("textureType")].toInt(); 0078 0079 m_settingsView->setSettings(prm); 0080 } 0081 0082 void Texture::slotSettingsChanged() 0083 { 0084 BatchToolSettings prm; 0085 TextureContainer currentPrm = m_settingsView->settings(); 0086 0087 prm.insert(QLatin1String("blendGain"), currentPrm.blendGain); 0088 prm.insert(QLatin1String("textureType"), currentPrm.textureType); 0089 0090 BatchTool::slotSettingsChanged(prm); 0091 } 0092 0093 bool Texture::toolOperations() 0094 { 0095 if (!loadToDImg()) 0096 { 0097 return false; 0098 } 0099 0100 TextureContainer prm; 0101 prm.blendGain = settings()[QLatin1String("blendGain")].toInt(); 0102 prm.textureType = settings()[QLatin1String("textureType")].toInt(); 0103 0104 TextureFilter bd(&image(), nullptr, prm); 0105 applyFilter(&bd); 0106 0107 return (savefromDImg()); 0108 } 0109 0110 } // namespace DigikamBqmTexturePlugin 0111 0112 #include "moc_texture.cpp"