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 : 2008-11-28 0007 * Description : TIFF image Converter batch tool. 0008 * 0009 * SPDX-FileCopyrightText: 2008-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 "converttotiff.h" 0016 0017 // Qt includes 0018 0019 #include <QFileInfo> 0020 #include <QWidget> 0021 0022 // KDE includes 0023 0024 #include <kconfiggroup.h> 0025 #include <klocalizedstring.h> 0026 #include <ksharedconfig.h> 0027 0028 // Local includes 0029 0030 #include "dimg.h" 0031 #include "dpluginloader.h" 0032 0033 namespace DigikamBqmConvertToTiffPlugin 0034 { 0035 0036 ConvertToTIFF::ConvertToTIFF(QObject* const parent) 0037 : BatchTool(QLatin1String("ConvertToTIFF"), ConvertTool, parent), 0038 m_changeSettings(true) 0039 { 0040 } 0041 0042 ConvertToTIFF::~ConvertToTIFF() 0043 { 0044 } 0045 0046 BatchTool* ConvertToTIFF::clone(QObject* const parent) const 0047 { 0048 return new ConvertToTIFF(parent); 0049 } 0050 0051 void ConvertToTIFF::registerSettingsWidget() 0052 { 0053 DImgLoaderSettings* const TIFBox = DPluginLoader::instance()->exportWidget(QLatin1String("TIFF")); 0054 0055 connect(TIFBox, SIGNAL(signalSettingsChanged()), 0056 this, SLOT(slotSettingsChanged())); 0057 0058 m_settingsWidget = TIFBox; 0059 0060 BatchTool::registerSettingsWidget(); 0061 } 0062 0063 BatchToolSettings ConvertToTIFF::defaultSettings() 0064 { 0065 KSharedConfig::Ptr config = KSharedConfig::openConfig(); 0066 KConfigGroup group = config->group(QLatin1String("ImageViewer Settings")); 0067 bool compression = group.readEntry(QLatin1String("TIFFCompression"), false); 0068 BatchToolSettings settings; 0069 settings.insert(QLatin1String("compress"), compression); 0070 0071 return settings; 0072 } 0073 0074 void ConvertToTIFF::slotAssignSettings2Widget() 0075 { 0076 m_changeSettings = false; 0077 0078 DImgLoaderSettings* const TIFBox = dynamic_cast<DImgLoaderSettings*>(m_settingsWidget); 0079 0080 if (TIFBox) 0081 { 0082 DImgLoaderPrms set; 0083 set.insert(QLatin1String("compress"), settings()[QLatin1String("compress")].toBool()); 0084 TIFBox->setSettings(set); 0085 } 0086 0087 m_changeSettings = true; 0088 } 0089 0090 void ConvertToTIFF::slotSettingsChanged() 0091 { 0092 if (m_changeSettings) 0093 { 0094 DImgLoaderSettings* const TIFBox = dynamic_cast<DImgLoaderSettings*>(m_settingsWidget); 0095 0096 if (TIFBox) 0097 { 0098 BatchToolSettings settings; 0099 settings.insert(QLatin1String("compress"), TIFBox->settings()[QLatin1String("compress")].toBool()); 0100 BatchTool::slotSettingsChanged(settings); 0101 } 0102 } 0103 } 0104 0105 QString ConvertToTIFF::outputSuffix() const 0106 { 0107 return QLatin1String("tif"); 0108 } 0109 0110 bool ConvertToTIFF::toolOperations() 0111 { 0112 if (!loadToDImg()) 0113 { 0114 return false; 0115 } 0116 0117 image().setAttribute(QLatin1String("compress"), settings()[QLatin1String("compress")].toBool()); 0118 0119 return (savefromDImg()); 0120 } 0121 0122 } // namespace DigikamBqmConvertToTiffPlugin 0123 0124 #include "moc_converttotiff.cpp"